// load a .bmp file and create a GtkImage widget from it
// NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
typedef struct _GtkImage GtkImage;
-typedef GtkImage* ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
+typedef ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
// ========================================
#include <gtk/gtk.h>
-inline GtkWidget* container_add_widget( GtkContainer* container, GtkWidget* widget ){
+inline ui::Widget container_add_widget( ui::Container container, ui::Widget widget ){
gtk_container_add( container, widget );
return widget;
}
-inline void container_remove( GtkWidget* item, gpointer data ){
- gtk_container_remove( GTK_CONTAINER( data ), item );
+inline void container_remove( ui::Widget item, gpointer data ){
+ auto container = ui::Container(GTK_CONTAINER( data ));
+ gtk_container_remove( container, item );
}
-inline void container_remove_all( GtkContainer* container ){
- gtk_container_foreach( container, container_remove, container );
+inline void container_remove_all( ui::Container container ){
+ gtk_container_foreach(container, (GtkCallback) container_remove, container );
}
#endif
ui::MenuItem menu_separator( ui::Menu menu ){
auto menu_item = ui::MenuItem(GTK_MENU_ITEM( gtk_menu_item_new() ));
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) );
+ container_add_widget( menu, menu_item );
gtk_widget_set_sensitive( GTK_WIDGET( menu_item ), FALSE );
menu_item.show();
return menu_item;
ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){
auto menu_item = ui::TearoffMenuItem(GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() ));
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) );
+ container_add_widget( menu, menu_item );
// gtk_widget_set_sensitive(GTK_WIDGET(menu_item), FALSE); -- controls whether menu is detachable
menu_item.show();
return menu_item;
ui::Menu create_sub_menu_with_mnemonic( ui::MenuShell parent, const char* mnemonic ){
auto item = new_sub_menu_item_with_mnemonic( mnemonic );
- container_add_widget( GTK_CONTAINER( parent ), GTK_WIDGET( item ) );
+ container_add_widget( parent, item );
return ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( item ) ));
}
ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const Callback& callback ){
auto item = new_menu_item_with_mnemonic( mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ container_add_widget( menu, item );
return item;
}
ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback& callback ){
auto item = new_check_menu_item_with_mnemonic( mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ container_add_widget( menu, item );
return item;
}
ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback& callback ){
auto item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ container_add_widget( menu, item );
return item;
}
,
);
- WRAP(Table, Widget, _GtkTable, (),
+ WRAP(Table, Container, _GtkTable, (),
Table(std::size_t rows, std::size_t columns, bool homogenous);
,
);
- WRAP(TextView, Widget, _GtkTextView, (),
+ WRAP(TextView, Container, _GtkTextView, (),
TextView();
,
);
- WRAP(Toolbar, Widget, _GtkToolbar, (),
+ WRAP(Toolbar, Container, _GtkToolbar, (),
,
);
ui::Widget item(ui::MenuItem( "Clear" ));
g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 );
gtk_widget_show( item );
- container_add_widget( GTK_CONTAINER( menu ), item );
+ container_add_widget( menu, item );
}
gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){
// the table is a 4x4 in which we need to put the comment box g_entityClassComment and the spawn flags..
GtkTable* g_spawnflagsTable;
-GtkVBox* g_attributeBox = 0;
+ui::VBox g_attributeBox{nullptr};
typedef std::vector<EntityAttribute*> EntityAttributes;
EntityAttributes g_entityAttributes;
}
if ( eclass != g_current_attributes ) {
g_current_attributes = eclass;
- container_remove_all( GTK_CONTAINER( g_attributeBox ) );
+ container_remove_all( g_attributeBox );
GlobalEntityAttributes_clear();
for ( EntityClassAttributes::const_iterator i = eclass->m_attributes.begin(); i != eclass->m_attributes.end(); ++i )
#include "mainframe.h"
#include "plugin.h"
-GtkImage* new_plugin_image( const char* filename ){
+ui::Image new_plugin_image( const char* filename ){
{
StringOutputStream fullpath( 256 );
fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename;
toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), G_CALLBACK( ActivateToolbarButton ), reinterpret_cast<gpointer>( const_cast<IToolbarButton*>( button ) ) );
}
-GtkToolbar* g_plugin_toolbar = 0;
+ui::Toolbar g_plugin_toolbar{nullptr};
void PluginToolbar_populate(){
class AddToolbarItemVisitor : public ToolbarModules::Visitor
}
void PluginToolbar_clear(){
- container_remove_all( GTK_CONTAINER( g_plugin_toolbar ) );
+ container_remove_all( g_plugin_toolbar );
}
-GtkToolbar* create_plugin_toolbar(){
- GtkToolbar *toolbar;
+ui::Toolbar create_plugin_toolbar(){
- toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
+ auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() ));
gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
+ toolbar.show();
g_plugin_toolbar = toolbar;
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_PLUGINTOOLBAR_H )
#define INCLUDED_PLUGINTOOLBAR_H
-typedef struct _GtkToolbar GtkToolbar;
-GtkToolbar* create_plugin_toolbar();
+ui::Toolbar create_plugin_toolbar();
void PluginToolbar_populate();
void PluginToolbar_clear();
-typedef struct _GtkImage GtkImage;
-GtkImage* new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path
+ui::Image new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path
#endif
void pushMenu( const CopiedString& name ){
auto item = ui::MenuItem( name.c_str() );
item.show();
- container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) );
+ container_add_widget( m_stack.back().first, item );
auto submenu = ui::Menu();
gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) );