From: TimePath Date: Wed, 17 Feb 2016 01:24:54 +0000 (+1100) Subject: Wrap gtk X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3cc39e2cbe3639e4c3e6a0dff6b3d41bd6b4732c;p=xonotic%2Fnetradiant.git Wrap gtk --- diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index 6d63bc3f..687efb10 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -183,15 +183,15 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ switch ( m_vt ) { case XY: - m_pTabLabel = gtk_label_new( "X/Y" ); + m_pTabLabel = ui::Label( "X/Y" ); m_pImage = &backgroundXY; break; case XZ: - m_pTabLabel = gtk_label_new( "X/Z" ); + m_pTabLabel = ui::Label( "X/Z" ); m_pImage = &backgroundXZ; break; case YZ: - m_pTabLabel = gtk_label_new( "Y/Z" ); + m_pTabLabel = ui::Label( "Y/Z" ); m_pImage = &backgroundYZ; break; } @@ -207,7 +207,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_container_add( GTK_CONTAINER( frame ), hbox ); // label to display filename - m_pFileLabel = gtk_label_new( NO_FILE_MSG ); + m_pFileLabel = ui::Label( NO_FILE_MSG ); gtk_label_set_selectable( GTK_LABEL( m_pFileLabel ),TRUE ); //TODO set min size ? done with spaces right now gtk_box_pack_start( GTK_BOX( hbox ),m_pFileLabel, TRUE, TRUE, 5 ); @@ -241,7 +241,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); gtk_container_add( GTK_CONTAINER( frame ), hbox ); - w = gtk_label_new( "Vertex alpha:" ); + w = ui::Label( "Vertex alpha:" ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_widget_show( w ); diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index c1169a9d..73c8e2fd 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -210,11 +210,11 @@ bool ValidateTextInt( const char* pData, const char* error_title, int* value ){ */ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){ - GtkWidget *window, *w, *vbox, *hbox; + ui::Widget window, w, vbox, hbox; EMessageBoxReturn ret; int loop = 1; - window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + window = ui::Widget(gtk_window_new( GTK_WINDOW_TOPLEVEL )); gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL ); gtk_signal_connect( GTK_OBJECT( window ), "destroy", @@ -225,25 +225,25 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess g_object_set_data( G_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = gtk_vbox_new( FALSE, 10 ); + vbox = ui::Widget(gtk_vbox_new( FALSE, 10 )); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); - w = gtk_hseparator_new(); + w = ui::Widget(gtk_hseparator_new()); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_widget_show( w ); - hbox = gtk_hbox_new( FALSE, 10 ); + hbox = ui::Widget(gtk_hbox_new( FALSE, 10 )); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 ); gtk_widget_show( hbox ); if ( type == eMB_OK ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Widget(gtk_button_new_with_label( "Ok" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); @@ -253,7 +253,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess ret = eIDOK; } else if ( type == eMB_OKCANCEL ) { - w = gtk_button_new_with_label( "Ok" ); + w = ui::Widget(gtk_button_new_with_label( "Ok" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) ); @@ -261,7 +261,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Widget(gtk_button_new_with_label( "Cancel" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); @@ -269,7 +269,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess ret = eIDCANCEL; } else if ( type == eMB_YESNOCANCEL ) { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Widget(gtk_button_new_with_label( "Yes" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); @@ -277,13 +277,13 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Widget(gtk_button_new_with_label( "No" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "Cancel" ); + w = ui::Widget(gtk_button_new_with_label( "Cancel" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) ); @@ -292,7 +292,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess } else /* if (mode == MB_YESNO) */ { - w = gtk_button_new_with_label( "Yes" ); + w = ui::Widget(gtk_button_new_with_label( "Yes" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) ); @@ -300,7 +300,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_widget_grab_default( w ); gtk_widget_show( w ); - w = gtk_button_new_with_label( "No" ); + w = ui::Widget(gtk_button_new_with_label( "No" )); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) ); @@ -471,7 +471,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Sides" ); + w = ui::Label( "Number Of Sides" ); gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -489,7 +489,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Border Width" ); + w = ui::Label( "Border Width" ); gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -624,7 +624,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_widget_show( hbox ); // dunno if you want this text or not ... - w = gtk_label_new( text ); + w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ... gtk_widget_show( w ); @@ -643,7 +643,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 ); gtk_widget_show( textStairHeight ); - w = gtk_label_new( "Stair Height" ); + w = ui::Label( "Stair Height" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); @@ -653,7 +653,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Direction:" ); + w = ui::Label( "Direction:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); @@ -697,7 +697,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Style:" ); + w = ui::Label( "Style:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 ); gtk_widget_show( w ); @@ -745,7 +745,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 ); gtk_widget_show( textMainTex ); - w = gtk_label_new( "Main Texture" ); + w = ui::Label( "Main Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); @@ -759,7 +759,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 ); gtk_widget_show( textRiserTex ); - w = gtk_label_new( "Riser Texture" ); + w = ui::Label( "Riser Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); @@ -891,7 +891,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 ); gtk_widget_show( textFrontBackTex ); - w = gtk_label_new( "Door Front/Back Texture" ); + w = ui::Label( "Door Front/Back Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -905,7 +905,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 ); gtk_widget_show( textTrimTex ); - w = gtk_label_new( "Door Trim Texture" ); + w = ui::Label( "Door Trim Texture" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -990,7 +990,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Orientation" ); + w = ui::Label( "Orientation" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1103,7 +1103,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 ); gtk_widget_show( text1 ); - w = gtk_label_new( "Number Of Points" ); + w = ui::Label( "Number Of Points" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -1121,14 +1121,14 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 ); gtk_widget_show( text2 ); - w = gtk_label_new( "Multipler" ); + w = ui::Label( "Multipler" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); // ---- /hbox ---- - w = gtk_label_new( "Path Distance = dist(start -> apex) * multiplier" ); + w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -1144,7 +1144,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 ); gtk_widget_show( text3 ); - w = gtk_label_new( "Gravity" ); + w = ui::Label( "Gravity" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -1341,7 +1341,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ texSelected = "Currently Selected Texture: "; texSelected += GetCurrentTexture(); - w = gtk_label_new( texSelected ); + w = ui::Label( texSelected ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); @@ -1368,7 +1368,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "Old Name: " ); + w = ui::Label( "Old Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1381,7 +1381,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( dlgTexReset.editTexOld ); - w = gtk_label_new( "New Name: " ); + w = ui::Label( "New Name: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1416,7 +1416,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Scale: " ); + w = ui::Label( "New Horizontal Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1437,7 +1437,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Scale: " ); + w = ui::Label( "New Vertical Scale: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1472,7 +1472,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Horizontal Shift: " ); + w = ui::Label( "New Horizontal Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1493,7 +1493,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Vertical Shift: " ); + w = ui::Label( "New Vertical Shift: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1527,7 +1527,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); - w = gtk_label_new( "New Rotation Value: " ); + w = ui::Label( "New Rotation Value: " ); gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1687,7 +1687,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "X: " ); + w = ui::Label( "X: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1702,7 +1702,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "Y: " ); + w = ui::Label( "Y: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1730,7 +1730,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1745,7 +1745,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1772,7 +1772,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Start: " ); + w = ui::Label( "Start: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1787,7 +1787,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - w = gtk_label_new( "End: " ); + w = ui::Label( "End: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1815,7 +1815,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- frame ---- - w = gtk_label_new( "Number: " ); + w = ui::Label( "Number: " ); gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -1936,7 +1936,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_show( hbox ); // dunno if you want this text or not ... - w = gtk_label_new( text ); + w = ui::Label( text ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1955,7 +1955,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 ); gtk_widget_show( textlinkNum ); - w = gtk_label_new( "Number of elements in chain" ); + w = ui::Label( "Number of elements in chain" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); @@ -1969,7 +1969,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 ); gtk_widget_show( textlinkName ); - w = gtk_label_new( "Basename for chain's targetnames." ); + w = ui::Label( "Basename for chain's targetnames." ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 ); gtk_widget_show( w ); diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index 6a346f3a..828ccdea 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -18,7 +18,7 @@ void OnDestroy( GtkWidget* w, gpointer data ){ } void OnExportClicked( GtkButton* button, gpointer user_data ){ - GtkWidget* window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); + ui::Widget window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" ); ASSERT_NOTNULL( window ); const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true ); if ( !cpath ) { @@ -68,7 +68,7 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){ { radio = lookup_widget( GTK_WIDGET( button ), "r_nocollapse" ); ASSERT_NOTNULL( radio ); - ASSERT_NOTNULL( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); + ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ); mode = COLLAPSE_NONE; } } diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index 76279ab0..ee679ba7 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -111,7 +111,7 @@ create_w_plugplug2( void ){ gtk_box_pack_start( GTK_BOX( vbox1 ), vbox2, TRUE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 2 ); - label1 = gtk_label_new( "Ignored materials:" ); + label1 = ui::Label( "Ignored materials:" ); gtk_widget_set_name( label1, "label1" ); gtk_widget_show( label1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), label1, FALSE, FALSE, 0 ); @@ -206,7 +206,7 @@ GtkWidget* g_brushexp_window = 0; // spawn plugin window (and make sure it got destroyed first or never created) void CreateWindow( void ){ - ASSERT_NOTNULL( !g_brushexp_window ); + ASSERT_TRUE( !g_brushexp_window ); GtkWidget* wnd = create_w_plugplug2(); diff --git a/contrib/brushexport/plugin.cpp b/contrib/brushexport/plugin.cpp index 274c840e..49b3df06 100644 --- a/contrib/brushexport/plugin.cpp +++ b/contrib/brushexport/plugin.cpp @@ -50,11 +50,11 @@ bool IsWindowOpen( void ); namespace BrushExport { -GtkWindow* g_mainwnd; +ui::Window g_mainwnd; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = (GtkWindow*)pMainWidget; - ASSERT_NOTNULL( g_mainwnd ); + g_mainwnd = ui::Window(GTK_WINDOW(pMainWidget)); + ASSERT_TRUE( g_mainwnd ); return ""; } const char* getName(){ @@ -69,7 +69,7 @@ const char* getCommandTitleList(){ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" + GlobalRadiant().m_pfnMessageBox( g_mainwnd, "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n" "Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...", eMB_OK, eMB_ICONDEFAULT ); diff --git a/contrib/brushexport/support.cpp b/contrib/brushexport/support.cpp index 79c5e145..c74ef620 100644 --- a/contrib/brushexport/support.cpp +++ b/contrib/brushexport/support.cpp @@ -1,8 +1,9 @@ #include +#include #include "support.h" -GtkWidget* +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ){ GtkWidget *parent, *found_widget; @@ -29,5 +30,5 @@ lookup_widget( GtkWidget *widget, if ( !found_widget ) { g_warning( "Widget not found: %s", widget_name ); } - return found_widget; + return ui::Widget(found_widget); } diff --git a/contrib/brushexport/support.h b/contrib/brushexport/support.h index e8f4cb04..8a64631d 100644 --- a/contrib/brushexport/support.h +++ b/contrib/brushexport/support.h @@ -7,6 +7,7 @@ #endif #include +#include /* * Public Functions. @@ -18,5 +19,5 @@ * or alternatively any widget in the component, and the name of the widget * you want returned. */ -GtkWidget* lookup_widget( GtkWidget *widget, +ui::Widget lookup_widget( GtkWidget *widget, const gchar *widget_name ); diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index acd2fbd4..63ccbb9a 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -384,7 +384,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -503,7 +503,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -878,7 +878,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Parameters:" ); + w = ui::Label( "Parameters:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1032,7 +1032,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "File:" ); + w = ui::Label( "File:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1046,7 +1046,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Name:" ); + w = ui::Label( "Name:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1054,11 +1054,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( hbox ), g_pCamName, FALSE, FALSE, 0 ); gtk_widget_show( g_pCamName ); - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCamType = GTK_LABEL( w ); @@ -1087,7 +1087,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Edit:" ); + w = ui::Label( "Edit:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1126,11 +1126,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE ); } - w = gtk_label_new( "Type: " ); + w = ui::Label( "Type: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "" ); + w = ui::Label( "" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pPathType = GTK_LABEL( w ); @@ -1181,7 +1181,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Length (seconds):" ); + w = ui::Label( "Length (seconds):" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); @@ -1195,20 +1195,20 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Current Time: " ); + w = ui::Label( "Current Time: " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pCurrentTime = GTK_LABEL( w ); - w = gtk_label_new( " of " ); + w = ui::Label( " of " ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); - w = gtk_label_new( "0.00" ); + w = ui::Label( "0.00" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); g_pTotalTime = GTK_LABEL( w ); @@ -1242,7 +1242,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = gtk_label_new( "Events:" ); + w = ui::Label( "Events:" ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_widget_show( w ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index c5f4aebb..d341948a 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -1380,7 +1380,7 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "General" ); + label = ui::Label( "General" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), table, label ); @@ -1455,7 +1455,7 @@ GtkWidget* create_main_dialog(){ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Wavelength:" ); + label = ui::Label( "Wavelength:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1463,7 +1463,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Max. amplitude:" ); + label = ui::Label( "Max. amplitude:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1471,7 +1471,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Roughness:" ); + label = ui::Label( "Roughness:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1479,7 +1479,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Random seed:" ); + label = ui::Label( "Random seed:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1528,7 +1528,7 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Extents" ); + label = ui::Label( "Extents" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); @@ -1547,41 +1547,41 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmin_text", label ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hmax_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmin_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vmax_text", label ); - label = gtk_label_new( "Lower-left" ); + label = ui::Label( "Lower-left" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right" ); + label = ui::Label( "Upper-right" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1634,14 +1634,14 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "X:" ); + label = ui::Label( "X:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "nh_text", label ); - label = gtk_label_new( "Y:" ); + label = ui::Label( "Y:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1675,7 +1675,7 @@ GtkWidget* create_main_dialog(){ g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_use_patches ), NULL ); // ^Fishman - Snap to grid, replaced scroll bar with a texbox. - label = gtk_label_new( "Snap to grid:" ); + label = ui::Label( "Snap to grid:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); gtk_object_set_data( GTK_OBJECT( dlg ), "snap_text", label ); @@ -1693,7 +1693,7 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 10 ); - label = gtk_label_new( "Decimate:" ); + label = ui::Label( "Decimate:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); @@ -1718,25 +1718,25 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Upper-left:" ); + label = ui::Label( "Upper-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-left:" ); + label = ui::Label( "Lower-left:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Upper-right:" ); + label = ui::Label( "Upper-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Lower-right:" ); + label = ui::Label( "Lower-right:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1790,11 +1790,11 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Bitmap" ); + label = ui::Label( "Bitmap" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "" ); + label = ui::Label( "" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); g_object_set_data( G_OBJECT( dlg ), "bmp_note", label ); @@ -1806,7 +1806,7 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Filename:" ); + label = ui::Label( "Filename:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1848,7 +1848,7 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Map color 0 to:" ); + label = ui::Label( "Map color 0 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1857,7 +1857,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT ); - label = gtk_label_new( "Map color 255 to:" ); + label = ui::Label( "Map color 255 to:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1896,11 +1896,11 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Fix Points" ); + label = ui::Label( "Fix Points" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); - label = gtk_label_new( "Click on a vertex in the lower half of the preview window,\n" + label = ui::Label( "Click on a vertex in the lower half of the preview window,\n" "then use the arrow keys or text box to assign a value.\n" "Use Ctrl+Click to select multiple vertices/toggle a\n" "selection. Use Shift+Click to select a range of vertices.\n\n" @@ -1916,7 +1916,7 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Value:" ); + label = ui::Label( "Value:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -1924,7 +1924,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_value_text", label ); - label = gtk_label_new( "Range affected:" ); + label = ui::Label( "Range affected:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -1932,7 +1932,7 @@ GtkWidget* create_main_dialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); g_object_set_data( G_OBJECT( dlg ), "fix_range_text", label ); - label = gtk_label_new( "Rate of change:" ); + label = ui::Label( "Rate of change:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -1991,7 +1991,7 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - label = gtk_label_new( "Texture" ); + label = ui::Label( "Texture" ); gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label ); @@ -2002,21 +2002,21 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Surface:" ); + label = ui::Label( "Surface:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Other:" ); + label = ui::Label( "Other:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); - label = gtk_label_new( "Steep:" ); + label = ui::Label( "Steep:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -2053,7 +2053,7 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); - label = gtk_label_new( "\"Steep\" angle:" ); + label = ui::Label( "\"Steep\" angle:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); @@ -2069,13 +2069,13 @@ GtkWidget* create_main_dialog(){ gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Offset " ); + label = ui::Label( "Offset " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - label = gtk_label_new( "Scale " ); + label = ui::Label( "Scale " ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -2145,7 +2145,7 @@ GtkWidget* create_main_dialog(){ g_object_set_data( G_OBJECT( dlg ), "go", button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_go ), NULL ); - label = gtk_label_new( "Settings:" ); + label = ui::Label( "Settings:" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 ); diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index cb6859e7..1b27db56 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -388,7 +388,7 @@ void CreateViewWindow(){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, TRUE, 0 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 3 ); - label = gtk_label_new( "Elevation" ); + label = ui::Label( "Elevation" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); @@ -407,7 +407,7 @@ void CreateViewWindow(){ gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); gtk_box_pack_end( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 ); - label = gtk_label_new( "Azimuth" ); + label = ui::Label( "Azimuth" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_box_pack_end( GTK_BOX( hbox ), label, FALSE, TRUE, 0 ); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 44393ea1..f790bf30 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -99,7 +99,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index e9458c0e..4b3719d0 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -20,6 +20,7 @@ #include "AboutDialog.h" #include #include +#include #include "version.h" #include "gtkutil/pointer.h" @@ -71,7 +72,7 @@ void DoAboutDlg(){ "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n" "Built against NetRadiant " +radiant::version()+ "\n" __DATE__; - label = gtk_label_new( label_text.c_str() ); + label = ui::Label( label_text.c_str() ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 ); gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index a91a6a2b..be8c3197 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -20,6 +20,7 @@ #include "ConfigDialog.h" #include #include +#include #include "gtkutil/pointer.h" #include "iscenegraph.h" @@ -279,7 +280,7 @@ void DoConfigDialog(){ gtk_box_pack_start( GTK_BOX( hbox ), lw3slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw3slider ), FALSE ); - lw3label = gtk_label_new( "" ); + lw3label = ui::Label( "" ); gtk_widget_show( lw3label ); gtk_box_pack_start( GTK_BOX( hbox ), lw3label, FALSE, TRUE, 0 ); gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll3d ), lw3label ); @@ -372,7 +373,7 @@ void DoConfigDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( transslider ), FALSE ); - translabel = gtk_label_new( "" ); + translabel = ui::Label( "" ); gtk_widget_show( translabel ); gtk_table_attach( GTK_TABLE( table ), translabel, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -388,7 +389,7 @@ void DoConfigDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_scale_set_draw_value( GTK_SCALE( clipslider ), FALSE ); - cliplabel = gtk_label_new( "" ); + cliplabel = ui::Label( "" ); gtk_widget_show( cliplabel ); gtk_table_attach( GTK_TABLE( table ), cliplabel, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -429,7 +430,7 @@ void DoConfigDialog(){ gtk_box_pack_start( GTK_BOX( hbox ), lw2slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw2slider ), FALSE ); - lw2label = gtk_label_new( "" ); + lw2label = ui::Label( "" ); gtk_widget_show( lw2label ); gtk_box_pack_start( GTK_BOX( hbox ), lw2label, FALSE, TRUE, 0 ); gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll2d ), lw2label ); diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 0cf2cbd0..7c0fd857 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -57,7 +57,7 @@ ShaderPlugPluginDependencies() : namespace Shaderplug { -GtkWindow* g_window; +ui::Window g_window; std::vector archives; std::set shaders; @@ -67,7 +67,7 @@ XmlTagBuilder TagBuilder; void CreateTagFile(); const char* init( void* hApp, void* pMainWidget ){ - g_window = GTK_WINDOW( pMainWidget ); + g_window = ui::Window(GTK_WINDOW( pMainWidget )); return ""; } const char* getName(){ @@ -81,7 +81,7 @@ const char* getCommandTitleList(){ } void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), "Shaderplug (1.0)\n\n" + GlobalRadiant().m_pfnMessageBox( g_window, "Shaderplug (1.0)\n\n" "by Shaderman (shaderman@gmx.net)", "About", eMB_OK, @@ -181,23 +181,23 @@ void CreateTagFile(){ strcat( message, "\nPlease restart Radiant now.\n" ); if ( file_exists( tagFile ) ) { - EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( g_window , "WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?", eMB_NOYES, eMB_ICONWARNING ); if ( result == eIDYES ) { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), + GlobalRadiant().m_pfnMessageBox( g_window, "No shaders or textures found. No XML tag file created!\n" "", "ERROR", diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 482a2227..df782bdf 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -268,7 +268,7 @@ void about_plugin_window(){ vbox = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window - label = gtk_label_new( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label + label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box @@ -383,15 +383,15 @@ void MapCoordinator(){ gtk_table_set_col_spacings( GTK_TABLE( table ), 8 ); // set column spacings gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, FALSE, 2 ); // insert table into vbox - label = gtk_label_new( "x" ); // create label + label = ui::Label( "x" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 1, 2, 0, 1 ); // insert label into table - label = gtk_label_new( "y" ); // create label + label = ui::Label( "y" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 2, 3, 0, 1 ); // insert label into table - label = gtk_label_new( "mapcoordsmins" ); // create label + label = ui::Label( "mapcoordsmins" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 1, 2 ); // insert label into table @@ -401,7 +401,7 @@ void MapCoordinator(){ spinnerMinY = gtk_spin_button_new( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinY, 2, 3, 1, 2 ); // insert spinbox into table - label = gtk_label_new( "mapcoordsmaxs" ); // create label + label = ui::Label( "mapcoordsmaxs" ); // create label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 2, 3 ); // insert label into table @@ -429,7 +429,7 @@ void MapCoordinator(){ else { globalOutputStream() << "SunPlug: no worldspawn found!\n"; // output error to console - label = gtk_label_new( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label + label = ui::Label( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index df695104..392fc9e1 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -59,10 +59,10 @@ UFOAIPluginDependencies( void ) : namespace UFOAI { -GtkWindow* g_mainwnd; + ui::Window g_mainwnd; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = GTK_WINDOW( pMainWidget ); + g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget )); return "Initializing GTKRadiant UFOAI plugin"; } const char* getName(){ @@ -82,7 +82,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush "\nRadiant version: " +radiant::version()+ "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n"; - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), + GlobalRadiant().m_pfnMessageBox( g_mainwnd, version_string.c_str(), "About", eMB_OK, eMB_ICONDEFAULT ); } @@ -133,7 +133,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush } if ( message != NULL ) { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), + GlobalRadiant().m_pfnMessageBox( g_mainwnd, message, "Note", eMB_OK, eMB_ICONDEFAULT ); } diff --git a/include/qerplugin.h b/include/qerplugin.h index 3c1db046..e74369da 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -26,6 +26,7 @@ #ifndef __QERPLUGIN_H__ #define __QERPLUGIN_H__ +#include "uilib/uilib.h" #include "generic/constant.h" @@ -35,7 +36,6 @@ // NOTE: parent can be 0 in all functions but it's best to set them // this API does not depend on gtk+ or glib -typedef struct _GtkWidget GtkWidget; enum EMessageBoxType { @@ -65,22 +65,22 @@ enum EMessageBoxReturn // simple Message Box, see above for the 'type' flags -typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( GtkWidget *parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); +typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); // file and directory selection functions return null if the user hits cancel // - 'title' is the dialog title (can be null) // - 'path' is used to set the initial directory (can be null) // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples -typedef const char* ( *PFN_QERAPP_FILEDIALOG )( GtkWidget *parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); +typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); // returns a gchar* string that must be g_free'd by the user -typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); +typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); // return true if the user closed the dialog with 'Ok' // 'color' is used to set the initial value and store the selected value template class BasicVector3; typedef BasicVector3 Vector3; -typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color, +typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color, const char* title /* = "Choose Color"*/ ); // load a .bmp file and create a GtkImage widget from it diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 5db20f38..1be865b1 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -28,6 +28,7 @@ add_subdirectory(signal) add_subdirectory(splines) add_subdirectory(stream) add_subdirectory(string) +add_subdirectory(uilib) add_subdirectory(xml) add_library(etclib diff --git a/libs/debugging/debugging.h b/libs/debugging/debugging.h index c549a2f2..ae9f1412 100644 --- a/libs/debugging/debugging.h +++ b/libs/debugging/debugging.h @@ -116,7 +116,8 @@ inline DebugMessageHandler& globalDebugMessageHandler(){ globalDebugMessageHandler().getOutputStream() << FILE_LINE "\nruntime error: " << message << "\n"; \ if ( !globalDebugMessageHandler().handleMessage() ) { DEBUGGER_BREAKPOINT(); }} while ( 0 ) -#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" # ptr "\" is null" ) +#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != nullptr, "pointer \"" # ptr "\" is null" ) +#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" # flag "\" is false" ) #else diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 59f5c5d9..cb174ca7 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -245,8 +245,8 @@ BrowsedPathEntry::BrowsedPathEntry( const BrowseCallback& browse ) : GtkLabel* DialogLabel_new( const char* name ){ - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); - gtk_widget_show( GTK_WIDGET( label ) ); + ui::Label label = ui::Label( name ); + gtk_widget_show(label); gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index 55130efd..92bc5e6c 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -233,7 +234,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c return g_file_dialog_file; } -char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ +char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ GtkWidget* dialog = gtk_file_chooser_dialog_new( title, GTK_WINDOW( parent ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, @@ -258,15 +259,15 @@ char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){ return filename; } -const char* file_dialog( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ for (;; ) { const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save ); if ( open - || file == 0 + || file == nullptr || !file_exists( file ) - || gtk_MessageBox( parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION ) == eIDYES ) { + || parent.alert("The file specified already exists.\nDo you want to replace it?", title, ui::alert_type::NOYES, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) { return file; } } diff --git a/libs/gtkutil/filechooser.h b/libs/gtkutil/filechooser.h index f4610bea..ae7c0b34 100644 --- a/libs/gtkutil/filechooser.h +++ b/libs/gtkutil/filechooser.h @@ -19,20 +19,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_FILECHOOSER_H ) #define INCLUDED_GTKUTIL_FILECHOOSER_H /// \file /// GTK+ file-chooser dialogs. -typedef struct _GtkWidget GtkWidget; -const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); +const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); /// \brief Prompts the user to browse for a directory. /// The prompt window will be transient to \p parent. /// The directory will initially default to \p path, which must be an absolute path. /// The returned string is allocated with \c g_malloc and must be freed with \c g_free. -char* dir_dialog( GtkWidget *parent, const char* title = "Choose Directory", const char* path = "" ); +char* dir_dialog( ui::Widget parent, const char* title = "Choose Directory", const char* path = "" ); #endif diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 8f9fb7fa..2dfc03de 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -59,14 +59,14 @@ const char* messagebox_stock_icon( EMessageBoxIcon type ){ } } -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); ModalDialogButton yes_button( dialog, eIDYES ); ModalDialogButton no_button( dialog, eIDNO ); - GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW( parent ) : 0; + GtkWindow* parentWindow = parent ? GTK_WINDOW( parent ) : nullptr; GtkWindow* window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 ); @@ -94,7 +94,7 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha gtk_widget_show( GTK_WIDGET( image ) ); gtk_box_pack_start( GTK_BOX( iconBox ), GTK_WIDGET( image ), FALSE, FALSE, 0 ); - GtkLabel* label = GTK_LABEL( gtk_label_new( text ) ); + GtkLabel* label = GTK_LABEL( ui::Label( text ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); diff --git a/libs/gtkutil/messagebox.h b/libs/gtkutil/messagebox.h index 8bdc0ba2..69939939 100644 --- a/libs/gtkutil/messagebox.h +++ b/libs/gtkutil/messagebox.h @@ -24,8 +24,7 @@ #include "qerplugin.h" -typedef struct _GtkWidget GtkWidget; /// \brief Shows a modal message-box. -EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); +EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); #endif diff --git a/libs/gtkutil/xorrectangle.h b/libs/gtkutil/xorrectangle.h index 6c4d64fc..35d72e5f 100644 --- a/libs/gtkutil/xorrectangle.h +++ b/libs/gtkutil/xorrectangle.h @@ -23,6 +23,7 @@ #define INCLUDED_XORRECTANGLE_H #include +#include #include "math/vector.h" class rectangle_t @@ -92,7 +93,7 @@ void draw() const { } public: -XORRectangle( GtkWidget* widget ) : m_widget( widget ), m_gc( 0 ){ +XORRectangle( ui::Widget widget ) : m_widget( widget ), m_gc( 0 ){ } ~XORRectangle(){ if ( initialised() ) { diff --git a/libs/uilib/CMakeLists.txt b/libs/uilib/CMakeLists.txt new file mode 100644 index 00000000..4eccdd3d --- /dev/null +++ b/libs/uilib/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(uilib + uilib.cpp + uilib.h +) diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp new file mode 100644 index 00000000..5ce21dbb --- /dev/null +++ b/libs/uilib/uilib.cpp @@ -0,0 +1,90 @@ +#include "uilib.h" + +#include + +#include + +#include "gtkutil/dialog.h" +#include "gtkutil/filechooser.h" +#include "gtkutil/messagebox.h" +#include "gtkutil/window.h" + +namespace ui { + + void init(int argc, char *argv[]) + { + gtk_disable_setlocale(); + gtk_init(&argc, &argv); + } + + void main() + { + gtk_main(); + } + + Widget root; + + alert_response Widget::alert(std::string text, std::string title, alert_type type, alert_icon icon) + { + auto ret = gtk_MessageBox(*this, text.c_str(), + title.c_str(), + type == alert_type::OK ? eMB_OK : + type == alert_type::OKCANCEL ? eMB_OKCANCEL : + type == alert_type::YESNO ? eMB_YESNO : + type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL : + type == alert_type::NOYES ? eMB_NOYES : + eMB_OK, + icon == alert_icon::DEFAULT ? eMB_ICONDEFAULT : + icon == alert_icon::ERROR ? eMB_ICONERROR : + icon == alert_icon::WARNING ? eMB_ICONWARNING : + icon == alert_icon::QUESTION ? eMB_ICONQUESTION : + icon == alert_icon::ASTERISK ? eMB_ICONASTERISK : + eMB_ICONDEFAULT + ); + return + ret == eIDOK ? alert_response::OK : + ret == eIDCANCEL ? alert_response::CANCEL : + ret == eIDYES ? alert_response::YES : + ret == eIDNO ? alert_response::NO : + alert_response::OK; + } + + const char *Widget::file_dialog(bool open, const char *title, const char *path, + const char *pattern, bool want_load, bool want_import, + bool want_save) + { + return ::file_dialog(*this, open, title, path, pattern, want_load, want_import, want_save); + } + + Window Window::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h) + { + return Window(::create_dialog_window(*this, title, func, data, default_w, default_h)); + } + + Window Window::create_modal_dialog_window(const char *title, ui_modal &dialog, int default_w, int default_h) + { + return Window(::create_modal_dialog_window(*this, title, dialog, default_w, default_h)); + } + + Window Window::create_floating_window(const char *title) + { + return Window(::create_floating_window(title, *this)); + } + + std::uint64_t Window::on_key_press(bool (*f)(Widget widget, ui_evkey *event, void *extra), void *extra) + { + auto pass = std::make_tuple(f, extra); + auto func = [](ui_widget *widget, GdkEventKey *event, void *pass_) -> bool { + using pass_t = decltype(pass); + auto &args = *(pass_t *) pass_; + auto func = std::get<0>(args); + auto pass = std::get<1>(args); + return func(Widget(widget), event, pass); + }; + return g_signal_connect(G_OBJECT(*this), "key-press-event", (GCallback) +func, &pass); + } + + Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label))) + { } + +} diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h new file mode 100644 index 00000000..61386801 --- /dev/null +++ b/libs/uilib/uilib.h @@ -0,0 +1,124 @@ +#ifndef INCLUDED_UILIB_H +#define INCLUDED_UILIB_H + +#include + +using ui_typeinst = struct _GTypeInstance; +using ui_widget = struct _GtkWidget; +using ui_window = struct _GtkWindow; +using ui_menuitem = struct _GtkMenuItem; +using ui_label = struct _GtkLabel; + +using ui_evkey = struct _GdkEventKey; + +using ui_modal = struct ModalDialog; + +namespace ui { + + void init(int argc, char *argv[]); + + void main(); + + enum class alert_type { + OK, + OKCANCEL, + YESNO, + YESNOCANCEL, + NOYES, + }; + + enum class alert_icon { + DEFAULT, + ERROR, + WARNING, + QUESTION, + ASTERISK, + }; + + enum class alert_response { + OK, + CANCEL, + YES, + NO, + }; + + template + class Convertible { + public: + T *handle() const + { return (T *) static_cast(this)->_handle; } + + operator T *() const + { return handle(); } + }; + + class Base { + public: + void *_handle; + + Base(void *h) : _handle(h) + { } + + explicit operator bool() const + { return _handle != nullptr; } + + explicit operator ui_typeinst *() const + { return (ui_typeinst *) _handle; } + + explicit operator void *() const + { return _handle; } + }; + + static_assert(sizeof(Base) == sizeof(ui_widget *), "object slicing"); + + class Widget : public Base, public Convertible { + public: + explicit Widget(ui_widget *h = nullptr) : Base((void *) h) + { } + + alert_response alert(std::string text, std::string title = "NetRadiant", + alert_type type = alert_type::OK, alert_icon icon = alert_icon::DEFAULT); + + const char *file_dialog(bool open, const char *title, const char *path = nullptr, + const char *pattern = nullptr, bool want_load = false, bool want_import = false, + bool want_save = false); + }; + + static_assert(sizeof(Widget) == sizeof(Base), "object slicing"); + + extern Widget root; + +#define WIDGET(name, impl, methods) \ + class name : public Widget, public Convertible { \ + public: \ + explicit name(impl *h = nullptr) : Widget(reinterpret_cast(h)) {} \ + methods \ + }; \ + static_assert(sizeof(name) == sizeof(Widget), "object slicing") + + WIDGET(Window, ui_window, + Window create_dialog_window(const char *title, void func(), void *data, int default_w = -1, + int default_h = -1); + + Window create_modal_dialog_window(const char *title, ui_modal &dialog, int default_w = -1, + int default_h = -1); + + Window create_floating_window(const char *title); + + std::uint64_t on_key_press(bool (*f)(Widget widget, ui_evkey *event, void *extra), + void *extra = nullptr); + ); + + WIDGET(CheckButton, ui_widget,); + + WIDGET(SpinButton, ui_widget,); + + WIDGET(MenuItem, ui_menuitem,); + + WIDGET(Label, ui_label, + Label(const char *label); + ); + +} + +#endif diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 50fbf125..cebd2359 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -69,7 +69,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); - w = gtk_label_new( lpText ); + w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT ); gtk_widget_show( w ); diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index fc68fc99..9879a55e 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -208,6 +208,7 @@ target_link_libraries(radiant splines stream string + uilib xmllib ) if(NOT WIN32) diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp index fe42687c..b9f9b824 100644 --- a/radiant/autosave.cpp +++ b/radiant/autosave.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "autosave.h" #include "os/file.h" @@ -91,7 +92,7 @@ void Map_Snapshot(){ { StringOutputStream strMsg( 256 ); strMsg << "Snapshot save failed.. unabled to create directory\n" << snapshotsDir.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), strMsg.c_str() ); + MainFrame_getWindow().alert( strMsg.c_str() ); } } /* @@ -174,8 +175,8 @@ void QE_CheckAutoSave( void ){ } void Autosave_constructPreferences( PreferencesPage& page ){ - GtkWidget* autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); - GtkWidget* autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); + ui::CheckButton autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled ); + ui::SpinButton autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 ); Widget_connectToggleDependency( autosave_frequency, autosave_enabled ); page.appendCheckBox( "", "Save Snapshots", g_SnapShots_Enabled ); } diff --git a/radiant/build.cpp b/radiant/build.cpp index 779ab6bc..4ba1e913 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -716,7 +716,7 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch return FALSE; } -gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList* projectList ){ +gboolean project_key_press( ui::Widget widget, GdkEventKey* event, ProjectList* projectList ){ Project& project = projectList->m_project; if ( event->keyval == GDK_Delete ) { @@ -818,7 +818,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc return FALSE; } -gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore* store ){ +gboolean commands_key_press( ui::Widget widget, GdkEventKey* event, GtkListStore* store ){ if ( g_current_build == 0 ) { return FALSE; } @@ -845,10 +845,10 @@ gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore } -GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Build Menu", G_CALLBACK( dialog_delete_callback ), &modal, -1, 400 ); +ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){ + ui::Window window = MainFrame_getWindow().create_dialog_window("Build Menu", G_CALLBACK(dialog_delete_callback ), &modal, -1, 400 ); - GtkWidget* buildView = 0; + ui::Widget buildView; { GtkTable* table1 = create_dialog_table( 2, 2, 4, 4, 4 ); @@ -879,7 +879,7 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); @@ -916,7 +916,7 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); @@ -960,7 +960,7 @@ void DoBuildMenu(){ ProjectList projectList( g_build_project ); - GtkWindow* window = BuildMenuDialog_construct( modal, projectList ); + ui::Window window = BuildMenuDialog_construct( modal, projectList ); if ( modal_dialog_show( window, modal ) == eIDCANCEL ) { build_commands_clear(); diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 7a64d396..dd36b064 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -667,8 +667,8 @@ static Shader* m_state_select2; FreezePointer m_freezePointer; public: -GtkWidget* m_gl_widget; -GtkWindow* m_parent; +ui::Widget m_gl_widget; +ui::Window m_parent; SelectionSystemWindowObserver* m_window_observer; XORRectangle m_XORRectangle; @@ -754,17 +754,17 @@ void GlobalCamera_setCamWnd( CamWnd& camwnd ){ } -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ){ +ui::Widget CamWnd_getWidget( CamWnd& camwnd ){ return camwnd.m_gl_widget; } -GtkWindow* CamWnd_getParent( CamWnd& camwnd ){ +ui::Window CamWnd_getParent( CamWnd& camwnd ){ return camwnd.m_parent; } ToggleShown g_camera_shown( true ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ){ +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ){ camwnd.m_parent = parent; g_camera_shown.connect( GTK_WIDGET( camwnd.m_parent ) ); } @@ -797,7 +797,7 @@ void Camera_setAngles( CamWnd& camwnd, const Vector3& angles ){ // ============================================================================= // CamWnd class -gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean enable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->EnableFreeMove(); return TRUE; @@ -805,7 +805,7 @@ gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean disable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { camwnd->DisableFreeMove(); return TRUE; @@ -814,7 +814,7 @@ gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event } #if 0 -gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ +gboolean mousecontrol_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { Cam_MouseControl( camwnd->getCamera(), event->x, widget->allocation.height - 1 - event->y ); } @@ -829,14 +829,14 @@ void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){ } -gboolean selection_button_press( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } @@ -848,30 +848,30 @@ void selection_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->onMouseMotion( WindowVector_forDouble( x, y ), modifiers_for_state( state ) ); } -inline WindowVector windowvector_for_widget_centre( GtkWidget* widget ){ - return WindowVector( static_cast( widget->allocation.width / 2 ), static_cast( widget->allocation.height / 2 ) ); +inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){ + return WindowVector( static_cast( widget.handle()->allocation.width / 2 ), static_cast( widget.handle()->allocation.height / 2 ) ); } -gboolean selection_button_press_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_press_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_PRESS ) { observer->onMouseDown( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_button_release_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){ +gboolean selection_button_release_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){ if ( event->type == GDK_BUTTON_RELEASE ) { observer->onMouseUp( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) ); } return FALSE; } -gboolean selection_motion_freemove( GtkWidget *widget, GdkEventMotion *event, WindowObserver* observer ){ +gboolean selection_motion_freemove( ui::Widget widget, GdkEventMotion *event, WindowObserver* observer ){ observer->onMouseMotion( windowvector_for_widget_centre( widget ), modifiers_for_state( event->state ) ); return FALSE; } -gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){ +gboolean wheelmove_scroll( ui::Widget widget, GdkEventScroll* event, CamWnd* camwnd ){ if ( event->direction == GDK_SCROLL_UP ) { Camera_Freemove_updateAxes( camwnd->getCamera() ); Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); @@ -884,7 +884,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam return FALSE; } -gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, CamWnd* camwnd ){ +gboolean camera_size_allocate( ui::Widget widget, GtkAllocation* allocation, CamWnd* camwnd ){ camwnd->getCamera().width = allocation->width; camwnd->getCamera().height = allocation->height; Camera_updateProjection( camwnd->getCamera() ); @@ -893,7 +893,7 @@ gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, Cam return FALSE; } -gboolean camera_expose( GtkWidget* widget, GdkEventExpose* event, gpointer data ){ +gboolean camera_expose( ui::Widget widget, GdkEventExpose* event, gpointer data ){ reinterpret_cast( data )->draw(); return FALSE; } @@ -1140,7 +1140,7 @@ CamWnd::CamWnd() : m_view( true ), m_Camera( &m_view, CamWndQueueDraw( *this ) ), m_cameraview( m_Camera, &m_view, ReferenceCaller( *this ) ), - m_gl_widget( glwidget_new( TRUE ) ), + m_gl_widget( ui::Widget(glwidget_new( TRUE )) ), m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ), @@ -1276,7 +1276,7 @@ void CamWnd::Cam_PositionDrag(){ // NOTE TTimo if there's an OS-level focus out of the application // then we can release the camera cursor grab -static gboolean camwindow_freemove_focusout( GtkWidget* widget, GdkEventFocus* event, gpointer data ){ +static gboolean camwindow_freemove_focusout( ui::Widget widget, GdkEventFocus* event, gpointer data ){ reinterpret_cast( data )->DisableFreeMove(); return FALSE; } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 8e578c85..bfe449e5 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -22,12 +22,10 @@ #if !defined( INCLUDED_CAMWINDOW_H ) #define INCLUDED_CAMWINDOW_H +#include #include "math/vector.h" #include "signal/signalfwd.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - class CamWnd; CamWnd* NewCamWnd(); void DeleteCamWnd( CamWnd* camwnd ); @@ -36,8 +34,8 @@ void AddCameraMovedCallback( const SignalHandler& handler ); void CamWnd_Update( CamWnd& camwnd ); -GtkWidget* CamWnd_getWidget( CamWnd& camwnd ); -void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ); +ui::Widget CamWnd_getWidget( CamWnd& camwnd ); +void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 067a1258..7cf2d344 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -22,12 +22,10 @@ #include "commands.h" #include "debugging/debugging.h" -#include "warnings.h" #include #include "string/string.h" #include "versionlib.h" -#include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" #include #include @@ -150,13 +148,9 @@ void connect_accelerator( const char *name ){ } -#include - #include -#include -#include -#include #include +#include #include "gtkutil/dialog.h" #include "mainframe.h" @@ -239,7 +233,7 @@ void accelerator_edit_button_clicked( GtkButton *btn, gpointer dialogptr ){ dialog.m_waiting_for_key = true; } -gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gpointer dialogptr ){ +bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpointer dialogptr ){ command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr; if ( !dialog.m_waiting_for_key ) { @@ -293,11 +287,11 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp { const char *commandName; const Accelerator &newAccel; - GtkWidget *widget; + ui::Widget widget; GtkTreeModel *model; public: bool allow; - VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, GtkWidget *w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ + VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, ui::Widget w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){ } void visit( const char* name, Accelerator& accelerator ){ if ( !strcmp( name, commandName ) ) { @@ -313,8 +307,8 @@ public: StringOutputStream msg; msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n" << "Do you want to unassign " << name << " first?"; - EMessageBoxReturn r = gtk_MessageBox( widget, msg.c_str(), "Key already used", eMB_YESNOCANCEL ); - if ( r == eIDYES ) { + auto r = widget.alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL ); + if ( r == ui::alert_response::YES ) { // clear the ACTUAL accelerator too! disconnect_accelerator( name ); // delete the modifier @@ -338,7 +332,7 @@ public: } } } - else if ( r == eIDCANCEL ) { + else if ( r == ui::alert_response::CANCEL ) { // aborted allow = false; } @@ -394,8 +388,10 @@ public: void DoCommandListDlg(){ command_list_dialog_t dialog; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Mapped Commands", dialog, -1, 400 ); - g_signal_connect( G_OBJECT( window ), "key-press-event", (GCallback) accelerator_window_key_press, &dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400); + window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) { + return accelerator_window_key_press(widget, event, dialogptr); + }, &dialog); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel ); @@ -410,7 +406,7 @@ void DoCommandListDlg(){ { GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store))); dialog.m_list = GTK_TREE_VIEW( view ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying @@ -478,7 +474,7 @@ public: GtkButton* clearbutton = create_dialog_button( "Clear", (GCallback) accelerator_clear_button_clicked, &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( clearbutton ), FALSE, FALSE, 0 ); - GtkWidget *spacer = gtk_image_new(); + ui::Widget spacer = ui::Widget(gtk_image_new()); gtk_widget_show( spacer ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( spacer ), TRUE, TRUE, 0 ); diff --git a/radiant/console.cpp b/radiant/console.cpp index 11e9b843..c075152f 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "gtkutil/accelerator.h" #include "gtkutil/messagebox.h" @@ -71,8 +72,8 @@ void Sys_LogFile( bool enable ){ << radiant::about_msg() << "\n"; } else{ - gtk_MessageBox( 0, "Failed to create log file, check write permissions in Radiant directory.\n", - "Console logging", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "Failed to create log file, check write permissions in Radiant directory.\n", + "Console logging", ui::alert_type::OK, ui::alert_icon::ERROR ); } } else if ( !enable && g_hLogFile != 0 ) { @@ -85,7 +86,7 @@ void Sys_LogFile( bool enable ){ } } -GtkWidget* g_console = 0; +ui::Widget g_console; void console_clear(){ GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) ); @@ -95,27 +96,27 @@ void console_clear(){ void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){ menu_separator( menu ); - GtkWidget* item = gtk_menu_item_new_with_label( "Clear" ); + ui::Widget item(gtk_menu_item_new_with_label( "Clear" )); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 ); gtk_widget_show( item ); container_add_widget( GTK_CONTAINER( menu ), item ); } -gboolean destroy_set_null( GtkWindow* widget, GtkWidget** p ){ - *p = 0; +gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){ + *p = ui::Widget(); return FALSE; } WidgetFocusPrinter g_consoleWidgetFocusPrinter( "console" ); -GtkWidget* Console_constructWindow( GtkWindow* toplevel ){ - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); +ui::Widget Console_constructWindow( ui::Window toplevel ){ + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); gtk_widget_show( scr ); { - GtkWidget* text = gtk_text_view_new(); + ui::Widget text = ui::Widget(gtk_text_view_new()); gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE ); @@ -167,7 +168,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ } if ( level != SYS_NOCON ) { - if ( g_console != 0 ) { + if ( g_console ) { GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) ); GtkTextIter iter; diff --git a/radiant/console.h b/radiant/console.h index 38e479fd..8bbe71e1 100644 --- a/radiant/console.h +++ b/radiant/console.h @@ -23,6 +23,7 @@ #define INCLUDED_CONSOLE_H #include +#include #define SYS_VRB 0 ///< verbose support (on/off) #define SYS_STD 1 ///< standard print level - this is the default @@ -35,9 +36,7 @@ class TextOutputStream; TextOutputStream& getSysPrintOutputStream(); TextOutputStream& getSysPrintErrorStream(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* Console_constructWindow( GtkWindow* toplevel ); +ui::Widget Console_constructWindow( ui::Window toplevel ); // will open/close the log file based on the parameter void Sys_LogFile( bool enable ); diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 58a6f4e1..b2a9e768 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -68,20 +68,20 @@ GtkEntry* DialogEntry_new(){ class DialogEntryRow { public: -DialogEntryRow( GtkWidget* row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){ +DialogEntryRow( ui::Widget row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){ } -GtkWidget* m_row; +ui::Widget m_row; GtkEntry* m_entry; }; DialogEntryRow DialogEntryRow_new( const char* name ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); + ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); gtk_widget_show( alignment ); GtkEntry* entry = DialogEntry_new(); gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) ); - return DialogEntryRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), entry ); + return DialogEntryRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), entry ); } @@ -101,20 +101,20 @@ GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int class DialogSpinnerRow { public: -DialogSpinnerRow( GtkWidget* row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ +DialogSpinnerRow( ui::Widget row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){ } -GtkWidget* m_row; +ui::Widget m_row; GtkSpinButton* m_spin; }; DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); + ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); gtk_widget_show( alignment ); GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction ); gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) ); - return DialogSpinnerRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), spin ); + return DialogSpinnerRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), spin ); } @@ -318,39 +318,39 @@ Dialog::~Dialog(){ ( *i )->release(); } - ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" ); + ASSERT_MESSAGE( !m_window, "dialog window not destroyed" ); } void Dialog::ShowDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); importData(); gtk_widget_show( GTK_WIDGET( m_window ) ); } void Dialog::HideDlg(){ - ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" ); + ASSERT_MESSAGE( m_window, "dialog was not constructed" ); exportData(); gtk_widget_hide( GTK_WIDGET( m_window ) ); } -static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ +static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ reinterpret_cast( data )->HideDlg(); reinterpret_cast( data )->EndModal( eIDCANCEL ); return TRUE; } void Dialog::Create(){ - ASSERT_MESSAGE( m_window == 0, "dialog cannot be constructed" ); + ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" ); m_window = BuildDialog(); g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this ); } void Dialog::Destroy(){ - ASSERT_MESSAGE( m_window != 0, "dialog cannot be destroyed" ); + ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" ); gtk_widget_destroy( GTK_WIDGET( m_window ) ); - m_window = 0; + m_window = ui::Window(nullptr); } @@ -451,7 +451,7 @@ EMessageBoxReturn Dialog::DoModal(){ PreModal(); EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal ); - ASSERT_NOTNULL( m_window ); + ASSERT_TRUE( (bool) m_window ); if ( ret == eIDOK ) { exportData(); } @@ -464,24 +464,24 @@ EMessageBoxReturn Dialog::DoModal(){ } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ - GtkWidget* check = gtk_check_button_new_with_label( flag ); +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ + ui::Widget check = ui::Widget(gtk_check_button_new_with_label( flag )); gtk_widget_show( check ); AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) ); - return check; + return ui::CheckButton(check); } -GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ){ +ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){ return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); +void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); gtk_widget_show( alignment ); { - GtkWidget* combo = gtk_combo_box_new_text(); + ui::Widget combo = ui::Widget(gtk_combo_box_new_text()); for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i ) { @@ -498,23 +498,23 @@ void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange value DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ){ +void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){ addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ +void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ #if 0 if ( draw_value == FALSE ) { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 ); + ui::Widget hbox2 = gtk_hbox_new( FALSE, 0 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( low ); + ui::Widget label = ui::Label( low ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } { - GtkWidget* label = gtk_label_new( high ); + ui::Widget label = ui::Label( high ); gtk_widget_show( label ); gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); } @@ -526,10 +526,10 @@ void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean d AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) ); // scale - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 ); + ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 )); gtk_widget_show( alignment ); - GtkWidget* scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + ui::Widget scale = ui::Widget(gtk_hscale_new( GTK_ADJUSTMENT( adj ) )); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT ); gtk_widget_show( scale ); gtk_container_add( GTK_CONTAINER( alignment ), scale ); @@ -541,8 +541,8 @@ void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean d DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 ); +void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); gtk_widget_show( alignment ); { RadioHBox radioBox = RadioHBox_new( names ); @@ -554,19 +554,19 @@ void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); } -void Dialog::addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ){ +void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){ addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - GtkWidget* table = gtk_table_new( 2, static_cast( icons.last - icons.first ), FALSE ); +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ + ui::Widget table = ui::Widget(gtk_table_new( 2, static_cast( icons.last - icons.first ), FALSE )); gtk_widget_show( table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); GSList* group = 0; - GtkWidget* radio = 0; + ui::Widget radio; for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon ) { guint pos = static_cast( icon - icons.first ); @@ -576,7 +576,7 @@ void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); - radio = gtk_radio_button_new( group ); + radio = ui::Widget(gtk_radio_button_new( group )); gtk_widget_show( radio ); gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2, (GtkAttachOptions) ( 0 ), @@ -590,32 +590,32 @@ void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) ); } -void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ){ +void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){ addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* Dialog::addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddIntEntryData( *row.m_entry, importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ +ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddSizeEntryData( *row.m_entry, importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddFloatEntryData( *row.m_entry, importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); return row.m_row; } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ PathEntry pathEntry = PathEntry_new(); g_signal_connect( G_OBJECT( pathEntry.m_button ), "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry ); @@ -624,27 +624,27 @@ GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_ GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) ); DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) ); - return GTK_WIDGET( row ); + return ui::Widget(GTK_WIDGET( row )); } -GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, std::string& data, bool browse_directory ){ +ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, std::string& data, bool browse_directory ){ return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) ); AddIntSpinnerData( *row.m_spin, importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); - return row.m_row; + return ui::SpinButton(row.m_row); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){ return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) ); } -GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) ); AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer ); DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row ); - return row.m_row; + return ui::SpinButton(row.m_row); } diff --git a/radiant/dialog.h b/radiant/dialog.h index 3ed229e6..13ed10ad 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -23,6 +23,7 @@ #define INCLUDED_DIALOG_H #include +#include #include "gtkutil/dialog.h" #include "generic/callback.h" @@ -94,7 +95,6 @@ public: virtual void exportData() const = 0; }; -typedef struct _GtkWindow GtkWindow; typedef struct _GtkToggleButton GtkToggleButton; typedef struct _GtkRadioButton GtkRadioButton; typedef struct _GtkSpinButton GtkSpinButton; @@ -109,11 +109,11 @@ typedef std::list DialogDataList; class Dialog { -GtkWindow* m_window; +ui::Window m_window; DialogDataList m_data; public: ModalDialog m_modal; -GtkWindow* m_parent; +ui::Window m_parent; Dialog(); virtual ~Dialog(); @@ -124,7 +124,7 @@ virtual ~Dialog(); */ EMessageBoxReturn DoModal(); void EndModal( EMessageBoxReturn code ); -virtual GtkWindow* BuildDialog() = 0; +virtual ui::Window BuildDialog() = 0; virtual void exportData(); virtual void importData(); virtual void PreModal() { }; @@ -133,39 +133,39 @@ virtual void ShowDlg(); virtual void HideDlg(); void Create(); void Destroy(); -GtkWindow* GetWidget(){ +ui::Window GetWidget(){ return m_window; } -const GtkWindow* GetWidget() const { +const ui::Window GetWidget() const { return m_window; } -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); -GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ); -void addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ); -void addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); -void addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ); -void addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ); -GtkWidget* addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, int& data ){ +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); +ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ); +void addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ); +void addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); +void addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ); +void addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ); +ui::Widget addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, int& data ){ return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) ); } -GtkWidget* addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, std::size_t& data ){ +ui::Widget addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, std::size_t& data ){ return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) ); } -GtkWidget* addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -GtkWidget* addEntry( GtkWidget* vbox, const char* name, float& data ){ +ui::Widget addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addEntry( ui::Widget vbox, const char* name, float& data ){ return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) ); } -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); -GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, std::string& data, bool directory ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::Widget vbox, const char* name, std::string& data, bool directory ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); protected: diff --git a/radiant/entity.cpp b/radiant/entity.cpp index ab3243b0..49ed045b 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -45,6 +45,8 @@ #include "qe3.h" #include "commands.h" +#include "uilib/uilib.h" + struct entity_globals_t { Vector3 color_entity; @@ -287,7 +289,7 @@ int g_iLastLightIntensity; void Entity_createFromSelection( const char* name, const Vector3& origin ){ #if 0 if ( string_equal_nocase( name, "worldspawn" ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); + ui::alert( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" ); return; } #endif @@ -381,7 +383,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){ } if ( isModel ) { - const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) ); + const char* model = misc_model_dialog(MainFrame_getWindow()); if ( model != 0 ) { Node_getEntity( node )->setKeyValue( "model", model ); } @@ -501,7 +503,7 @@ void Entity_setColour(){ normalize = false; } - if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) { + if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) { if ( normalize ) { NormalizeColor( g_entity_globals.color_entity ); } @@ -517,7 +519,7 @@ void Entity_setColour(){ } } -const char* misc_model_dialog( GtkWidget* parent ){ +const char* misc_model_dialog( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; @@ -528,7 +530,7 @@ const char* misc_model_dialog( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char *filename = file_dialog( parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); + const char *filename = parent.file_dialog( TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); if ( filename != 0 ) { // use VFS to get the correct relative path const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); diff --git a/radiant/entity.h b/radiant/entity.h index eaf73cbb..752ff189 100644 --- a/radiant/entity.h +++ b/radiant/entity.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_ENTITY_H ) #define INCLUDED_ENTITY_H +#include + template class BasicVector3; typedef BasicVector3 Vector3; void Entity_createFromSelection( const char* name, const Vector3& origin ); @@ -30,8 +32,7 @@ void Scene_EntitySetKeyValue_Selected( const char* key, const char* value ); void Scene_EntitySetClassname_Selected( const char* classname ); -typedef struct _GtkWidget GtkWidget; -const char* misc_model_dialog( GtkWidget* parent ); +const char* misc_model_dialog( ui::Widget parent ); typedef struct _GtkMenu GtkMenu; void Entity_constructMenu( GtkMenu* menu ); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 550353d1..087ea62b 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include "os/path.h" @@ -119,7 +120,7 @@ class EntityAttribute { public: virtual ~EntityAttribute(){} -virtual GtkWidget* getWidget() const = 0; +virtual ui::Widget getWidget() const = 0; virtual void update() = 0; virtual void release() = 0; }; @@ -129,7 +130,7 @@ class BooleanAttribute : public EntityAttribute std::string m_key; GtkCheckButton* m_check; -static gboolean toggled( GtkWidget *widget, BooleanAttribute* self ){ +static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){ self->apply(); return FALSE; } @@ -147,8 +148,8 @@ BooleanAttribute( const char* key ) : update(); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_check ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_check )); } void release(){ delete this; @@ -189,8 +190,8 @@ StringAttribute( const char* key ) : m_entry = entry; m_nonModal.connect( m_entry ); } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } GtkEntry* getEntry() const { return m_entry; @@ -238,8 +239,8 @@ ModelAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -254,7 +255,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = misc_model_dialog( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) )); if ( filename != 0 ) { setPath( filename ); @@ -264,7 +265,7 @@ void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ typedef MemberCaller1 BrowseCaller; }; -const char* browse_sound( GtkWidget* parent ){ +const char* browse_sound( ui::Widget parent ){ StringOutputStream buffer( 1024 ); buffer << g_qeglobals.m_userGamePath.c_str() << "sound/"; @@ -275,7 +276,7 @@ const char* browse_sound( GtkWidget* parent ){ buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } - const char* filename = file_dialog( parent, TRUE, "Open Wav File", buffer.c_str(), "sound" ); + const char* filename = parent.file_dialog(TRUE, "Open Wav File", buffer.c_str(), "sound" ); if ( filename != 0 ) { const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); if ( relative == filename ) { @@ -301,8 +302,8 @@ SoundAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry.m_entry.m_frame ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame )); } void apply(){ StringOutputStream value( 64 ); @@ -317,7 +318,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) ); + const char *filename = browse_sound( ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) )) ); if ( filename != 0 ) { setPath( filename ); @@ -348,8 +349,8 @@ AngleAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_entry ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_entry )); } void apply(){ StringOutputStream angle( 32 ); @@ -409,8 +410,8 @@ DirectionAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angle( 32 ); @@ -511,8 +512,8 @@ AnglesAttribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream angles( 64 ); @@ -598,8 +599,8 @@ Vector3Attribute( const char* key ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_hbox ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_hbox )); } void apply(){ StringOutputStream vector3( 64 ); @@ -691,8 +692,8 @@ ListAttribute( const char* key, const ListAttributeType& type ) : void release(){ delete this; } -GtkWidget* getWidget() const { - return GTK_WIDGET( m_combo ); +ui::Widget getWidget() const { + return ui::Widget(GTK_WIDGET( m_combo )); } void apply(){ Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_type[gtk_combo_box_get_active( m_combo )].second.c_str() ); @@ -716,8 +717,8 @@ typedef MemberCaller UpdateCaller; namespace { -GtkWidget* g_entity_split1 = 0; -GtkWidget* g_entity_split2 = 0; +ui::Widget g_entity_split1; +ui::Widget g_entity_split2; int g_entitysplit1_position; int g_entitysplit2_position; @@ -874,7 +875,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), " " ); gtk_widget_hide( widget ); gtk_widget_ref( widget ); @@ -887,7 +888,7 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ { for ( int i = 0; i < g_spawnflag_count; ++i ) { - GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] ); + ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] )); gtk_widget_show( widget ); StringOutputStream str( 16 ); @@ -1107,7 +1108,7 @@ void EntityClassList_createEntity(){ GtkTreeModel* model; GtkTreeIter iter; if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) ), "You must have a selected class to create an entity", "info" ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) )).alert( "You must have a selected class to create an entity", "info" ); return; } @@ -1135,14 +1136,14 @@ void EntityInspector_applyKeyValue(){ // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "Cannot change \"classname\" key back to worldspawn.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK ); return; } // RR2DO2: we don't want spaces in entity keys if ( strstr( key.c_str(), " " ) ) { - gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "No spaces are allowed in entity keys.", 0, eMB_OK ); + ui::Widget(gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry )) ).alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK ); return; } @@ -1198,7 +1199,7 @@ static void EntityClassList_selection_changed( GtkTreeSelection* selection, gpoi } } -static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){ +static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){ if ( event->type == GDK_2BUTTON_PRESS ) { EntityClassList_createEntity(); return TRUE; @@ -1206,7 +1207,7 @@ static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *eve return FALSE; } -static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +static gint EntityClassList_keypress( ui::Widget widget, GdkEventKey* event, gpointer data ){ unsigned int code = gdk_keyval_to_upper( event->keyval ); if ( event->keyval == GDK_Return ) { @@ -1270,7 +1271,7 @@ static void EntityProperties_selection_changed( GtkTreeSelection* selection, gpo g_free( val ); } -static void SpawnflagCheck_toggled( GtkWidget *widget, gpointer data ){ +static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){ EntityInspector_applySpawnflags(); } @@ -1294,7 +1295,7 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer return FALSE; } -void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ +void EntityInspector_destroyWindow( ui::Widget widget, gpointer data ){ g_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) ); g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) ); @@ -1302,22 +1303,22 @@ void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){ GlobalEntityAttributes_clear(); } -GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ - GtkWidget* vbox = gtk_vbox_new( FALSE, 2 ); +ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ + ui::Widget vbox = ui::Widget(gtk_vbox_new( FALSE, 2 )); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 ); g_signal_connect( G_OBJECT( vbox ), "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 ); { - GtkWidget* split1 = gtk_vpaned_new(); + ui::Widget split1 = ui::Widget(gtk_vpaned_new()); gtk_box_pack_start( GTK_BOX( vbox ), split1, TRUE, TRUE, 0 ); gtk_widget_show( split1 ); g_entity_split1 = split1; { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::Widget(gtk_vpaned_new()); gtk_paned_add1( GTK_PANED( split1 ), split2 ); gtk_widget_show( split2 ); @@ -1325,7 +1326,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // class list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_widget_show( scr ); gtk_paned_add1( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -1362,7 +1363,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_widget_show( scr ); gtk_paned_add2( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -1381,12 +1382,12 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* split2 = gtk_vpaned_new(); + ui::Widget split2 = ui::Widget(gtk_vpaned_new()); gtk_paned_add2( GTK_PANED( split1 ), split2 ); gtk_widget_show( split2 ); { - GtkWidget* vbox2 = gtk_vbox_new( FALSE, 2 ); + ui::Widget vbox2 = ui::Widget(gtk_vbox_new( FALSE, 2 )); gtk_widget_show( vbox2 ); gtk_paned_pack1( GTK_PANED( split2 ), vbox2, FALSE, FALSE ); @@ -1409,7 +1410,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { // key/value list - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_widget_show( scr ); gtk_box_pack_start( GTK_BOX( vbox2 ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); @@ -1418,7 +1419,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); @@ -1480,7 +1481,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Value" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Value" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_FILL ), @@ -1489,7 +1490,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Key" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Key" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_FILL ), @@ -1519,11 +1520,11 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ } { - GtkWidget* scr = gtk_scrolled_window_new( 0, 0 ); + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_widget_show( scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - GtkWidget* viewport = gtk_viewport_new( 0, 0 ); + ui::Widget viewport = ui::Widget(gtk_viewport_new( 0, 0 )); gtk_widget_show( viewport ); gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE ); diff --git a/radiant/entityinspector.h b/radiant/entityinspector.h index 1afa2584..e0d359ec 100644 --- a/radiant/entityinspector.h +++ b/radiant/entityinspector.h @@ -19,12 +19,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYINSPECTOR_H ) #define INCLUDED_ENTITYINSPECTOR_H -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -GtkWidget* EntityInspector_constructWindow( GtkWindow* parent ); +ui::Widget EntityInspector_constructWindow( ui::Window parent ); void EntityInspector_construct(); void EntityInspector_destroy(); const char *EntityInspector_getCurrentKey(); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 4fdc5b4e..7aa5a80f 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "string/string.h" #include "scenelib.h" @@ -62,7 +63,7 @@ EDirty m_dirty; IdleDraw m_idleDraw; WindowPositionTracker m_positionTracker; -GtkWindow* m_window; +ui::Window m_window; GtkTreeView* m_tree_view; GraphTreeModel* m_tree_model; bool m_selection_disabled; @@ -75,7 +76,7 @@ EntityList() : } bool visible() const { - return GTK_WIDGET_VISIBLE( GTK_WIDGET( m_window ) ); + return GTK_WIDGET_VISIBLE( m_window ); } }; @@ -282,10 +283,10 @@ void DetachEntityTreeModel(){ gtk_tree_view_set_model( getEntityList().m_tree_view, 0 ); } -void EntityList_constructWindow( GtkWindow* main_window ){ - ASSERT_MESSAGE( getEntityList().m_window == 0, "error" ); +void EntityList_constructWindow( ui::Window main_window ){ + ASSERT_TRUE( !getEntityList().m_window ); - GtkWindow* window = create_persistent_floating_window( "Entity List", main_window ); + ui::Window window = ui::Window(create_persistent_floating_window( "Entity List", main_window )); gtk_window_add_accel_group( window, global_accel ); @@ -299,7 +300,7 @@ void EntityList_constructWindow( GtkWindow* main_window ){ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); { - GtkWidget* view = gtk_tree_view_new(); + ui::Widget view = ui::Widget(gtk_tree_view_new()); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); diff --git a/radiant/entitylist.h b/radiant/entitylist.h index e29f1b9a..4830bb8d 100644 --- a/radiant/entitylist.h +++ b/radiant/entitylist.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_ENTITYLIST_H ) #define INCLUDED_ENTITYLIST_H void EntityList_Construct(); void EntityList_Destroy(); -typedef struct _GtkWindow GtkWindow; -void EntityList_constructWindow( GtkWindow* main_window ); +void EntityList_constructWindow( ui::Window main_window ); void EntityList_destroyWindow(); void EntityList_toggleShown(); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 1d2856f5..0c7632c9 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -279,7 +279,7 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ // push in the list g_ptr_array_add( m_pFeedbackElements, (void *)pHandler ); - if ( GetWidget() == 0 ) { + if ( !GetWidget() ) { Create(); } @@ -295,10 +295,10 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ ShowDlg(); } -GtkWindow* CDbgDlg::BuildDialog(){ - GtkWindow* window = create_floating_window( "Q3Map debug window", MainFrame_getWindow() ); +ui::Window CDbgDlg::BuildDialog(){ + ui::Window window = MainFrame_getWindow().create_floating_window("Q3Map debug window" ); - GtkWidget* scr = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scr = ui::Widget(gtk_scrolled_window_new( NULL, NULL )); gtk_widget_show( scr ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); @@ -307,7 +307,7 @@ GtkWindow* CDbgDlg::BuildDialog(){ { GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { diff --git a/radiant/feedback.h b/radiant/feedback.h index 04e98bb2..78f4fd04 100644 --- a/radiant/feedback.h +++ b/radiant/feedback.h @@ -171,13 +171,13 @@ void draw2D( VIEWTYPE viewType ){ } } void destroyWindow(){ - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } // void HideDlg(); protected: -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); }; extern CDbgDlg g_DbgDlg; diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index e2cf2673..36ccafb1 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -65,9 +65,9 @@ static void updateTextures( const char* name ); FindTextureDialog(); virtual ~FindTextureDialog(); -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); -void constructWindow( GtkWindow* parent ){ +void constructWindow( ui::Window parent ){ m_parent = parent; Create(); } @@ -95,7 +95,7 @@ void FindTextureDialog_apply(){ FindReplaceTextures( find.c_str(), replace.c_str(), g_FindTextureDialog.m_bSelectedOnly ); } -static void OnApply( GtkWidget* widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_FindTextureDialog.exportData(); FindTextureDialog_apply(); } @@ -111,17 +111,17 @@ static void OnOK( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.HideDlg(); }*/ -static void OnClose( GtkWidget* widget, gpointer data ){ +static void OnClose( ui::Widget widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } -static gint find_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint find_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = true; return FALSE; } -static gint replace_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){ +static gint replace_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){ g_bFindActive = false; return FALSE; } @@ -137,42 +137,42 @@ FindTextureDialog::FindTextureDialog(){ FindTextureDialog::~FindTextureDialog(){ } -GtkWindow* FindTextureDialog::BuildDialog(){ - GtkWidget* vbox, *hbox, *table, *label; - GtkWidget* button, *check, *entry; +ui::Window FindTextureDialog::BuildDialog(){ + ui::Widget vbox, hbox, table, label; + ui::Widget button, check, entry; - GtkWindow* dlg = create_floating_window( "Find / Replace Texture(s)", m_parent ); + ui::Window dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent )); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::Widget(gtk_hbox_new( FALSE, 5 )); gtk_widget_show( hbox ); gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( hbox ) ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::Widget(gtk_vbox_new( FALSE, 5 )); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); - table = gtk_table_new( 2, 2, FALSE ); + table = ui::Widget(gtk_table_new( 2, 2, FALSE )); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); - label = gtk_label_new( "Find:" ); + label = ui::Label( "Find:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - label = gtk_label_new( "Replace:" ); + label = ui::Label( "Replace:" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); - entry = gtk_entry_new(); + entry = ui::Widget(gtk_entry_new()); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -182,7 +182,7 @@ GtkWindow* FindTextureDialog::BuildDialog(){ AddDialogData( *GTK_ENTRY( entry ), m_strFind ); GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); - entry = gtk_entry_new(); + entry = ui::Widget(gtk_entry_new()); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -192,23 +192,23 @@ GtkWindow* FindTextureDialog::BuildDialog(){ AddDialogData( *GTK_ENTRY( entry ), m_strReplace ); GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); - check = gtk_check_button_new_with_label( "Within selected brushes only" ); + check = ui::Widget(gtk_check_button_new_with_label( "Within selected brushes only" )); gtk_widget_show( check ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); AddDialogData( *GTK_TOGGLE_BUTTON( check ), m_bSelectedOnly ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::Widget(gtk_vbox_new( FALSE, 5 )); gtk_widget_show( vbox ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); - button = gtk_button_new_with_label( "Apply" ); + button = ui::Widget(gtk_button_new_with_label( "Apply" )); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnApply ), 0 ); gtk_widget_set_usize( button, 60, -2 ); - button = gtk_button_new_with_label( "Close" ); + button = ui::Widget(gtk_button_new_with_label( "Close" )); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", @@ -251,7 +251,7 @@ void FindTextureDialog::show(){ } -void FindTextureDialog_constructWindow( GtkWindow* main_window ){ +void FindTextureDialog_constructWindow( ui::Window main_window ){ g_FindTextureDialog.constructWindow( main_window ); } diff --git a/radiant/findtexturedialog.h b/radiant/findtexturedialog.h index 2bf06dbb..66022e8b 100644 --- a/radiant/findtexturedialog.h +++ b/radiant/findtexturedialog.h @@ -19,14 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_FINDTEXTUREDIALOG_H ) #define INCLUDED_FINDTEXTUREDIALOG_H void FindTextureDialog_Construct(); void FindTextureDialog_Destroy(); -typedef struct _GtkWindow GtkWindow; -void FindTextureDialog_constructWindow( GtkWindow* main_window ); +void FindTextureDialog_constructWindow( ui::Window main_window ); void FindTextureDialog_destroyWindow(); bool FindTextureDialog_isOpen(); void FindTextureDialog_selectTexture( const char* name ); diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 2e717d12..7e4b67c1 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -52,11 +52,11 @@ class GroupDlg { public: -GtkWidget* m_pNotebook; -GtkWindow* m_window; +ui::Widget m_pNotebook; +ui::Window m_window; GroupDlg(); -void Create( GtkWindow* parent ); +void Create( ui::Window parent ); void Show(){ // workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event @@ -78,14 +78,14 @@ std::size_t g_current_page; std::vector g_pages; } -void GroupDialog_updatePageTitle( GtkWindow* window, std::size_t pageIndex ){ +void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){ if ( pageIndex < g_pages.size() ) { g_pages[pageIndex]( PointerCaller1( window ) ); } } static gboolean switch_page( GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data ){ - GroupDialog_updatePageTitle( GTK_WINDOW( data ), page_num ); + GroupDialog_updatePageTitle( ui::Window(GTK_WINDOW( data )), page_num ); g_current_page = page_num; return FALSE; @@ -95,10 +95,10 @@ GroupDlg::GroupDlg() : m_window( 0 ){ m_position_tracker.setPosition( c_default_window_pos ); } -void GroupDlg::Create( GtkWindow* parent ){ - ASSERT_MESSAGE( m_window == 0, "dialog already created" ); +void GroupDlg::Create( ui::Window parent ){ + ASSERT_MESSAGE( !m_window, "dialog already created" ); - GtkWindow* window = create_persistent_floating_window( "Entities", parent ); + ui::Window window = ui::Window(create_persistent_floating_window( "Entities", parent )); global_accel_connect_window( window ); @@ -116,21 +116,21 @@ void GroupDlg::Create( GtkWindow* parent ){ m_position_tracker.connect( window ); { - GtkWidget* notebook = gtk_notebook_new(); + ui::Widget notebook = ui::Widget(gtk_notebook_new()); gtk_widget_show( notebook ); gtk_container_add( GTK_CONTAINER( window ), notebook ); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); m_pNotebook = notebook; - g_signal_connect( G_OBJECT( notebook ), "switch_page", G_CALLBACK( switch_page ), window ); + g_signal_connect( notebook, "switch_page", G_CALLBACK( switch_page ), window ); } } -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ){ - GtkWidget* w = gtk_label_new( tabLabel ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ){ + ui::Widget w = ui::Label( tabLabel ); gtk_widget_show( w ); - GtkWidget* page = gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ); + ui::Widget page = ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) )); g_pages.push_back( title ); return page; @@ -147,33 +147,33 @@ void GroupDialog_ToggleShow(){ GroupDialog_setShown( !GroupDialog_isShown() ); } -void GroupDialog_constructWindow( GtkWindow* main_window ){ +void GroupDialog_constructWindow( ui::Window main_window ){ g_GroupDlg.Create( main_window ); } void GroupDialog_destroyWindow(){ - ASSERT_NOTNULL( g_GroupDlg.m_window ); + ASSERT_TRUE( g_GroupDlg.m_window ); destroy_floating_window( g_GroupDlg.m_window ); - g_GroupDlg.m_window = 0; + g_GroupDlg.m_window = ui::Window(); } -GtkWindow* GroupDialog_getWindow(){ - return g_GroupDlg.m_window; +ui::Window GroupDialog_getWindow(){ + return ui::Window(g_GroupDlg.m_window); } void GroupDialog_show(){ g_GroupDlg.Show(); } -GtkWidget* GroupDialog_getPage(){ - return gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); +ui::Widget GroupDialog_getPage(){ + return ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) )); } -void GroupDialog_setPage( GtkWidget* page ){ +void GroupDialog_setPage( ui::Widget page ){ g_current_page = gtk_notebook_page_num( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), page ); gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_showPage( GtkWidget* page ){ +void GroupDialog_showPage( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_ToggleShow(); } @@ -189,7 +189,7 @@ void GroupDialog_cycle(){ gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ); } -void GroupDialog_updatePageTitle( GtkWidget* page ){ +void GroupDialog_updatePageTitle( ui::Widget page ){ if ( GroupDialog_getPage() == page ) { GroupDialog_updatePageTitle( g_GroupDlg.m_window, g_current_page ); } diff --git a/radiant/groupdialog.h b/radiant/groupdialog.h index 349802b1..50e880b4 100644 --- a/radiant/groupdialog.h +++ b/radiant/groupdialog.h @@ -22,28 +22,26 @@ #if !defined( INCLUDED_GROUPDIALOG_H ) #define INCLUDED_GROUPDIALOG_H +#include #include "generic/callback.h" -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - void GroupDialog_Construct(); void GroupDialog_Destroy(); -void GroupDialog_constructWindow( GtkWindow* main_window ); +void GroupDialog_constructWindow( ui::Window main_window ); void GroupDialog_destroyWindow(); -GtkWindow* GroupDialog_getWindow(); +ui::Window GroupDialog_getWindow(); void GroupDialog_show(); inline void RawStringExport( const char* string, const StringImportCallback& importer ){ importer( string ); } typedef ConstPointerCaller1 RawStringExportCaller; -GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ); +ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const StringExportCallback& title ); -void GroupDialog_showPage( GtkWidget* page ); -void GroupDialog_updatePageTitle( GtkWidget* page ); +void GroupDialog_showPage( ui::Widget page ); +void GroupDialog_updatePageTitle( ui::Widget page ); bool GroupDialog_isShown(); -GtkWidget* GroupDialog_getPage(); +ui::Widget GroupDialog_getPage(); #endif diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index ab8b3699..c3aba62b 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include "os/path.h" #include "math/aabb.h" @@ -171,7 +172,7 @@ struct GameCombo GtkEntry* fsgame_entry; }; -gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){ +gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){ const char *gamename; { GtkTreeIter iter; @@ -214,8 +215,8 @@ GameCombo game_combo; GtkComboBox* gamemode_combo; }; -GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Project Settings", G_CALLBACK( dialog_delete_callback ), &modal ); +ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ + ui::Window window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal ); { GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 ); @@ -244,7 +245,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Select mod" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Select mod" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -269,7 +270,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "fs_game" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "fs_game" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -287,7 +288,7 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } if ( globalMappingMode().do_mapping_mode ) { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Mapping mode" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Mapping mode" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), @@ -366,7 +367,7 @@ void DoProjectSettings(){ ModalDialog modal; ProjectSettingsDialog dialog; - GtkWindow* window = ProjectSettingsDialog_construct( dialog, modal ); + ui::Window window = ProjectSettingsDialog_construct( dialog, modal ); if ( modal_dialog_show( window, modal ) == eIDOK ) { ProjectSettingsDialog_ok( dialog ); @@ -383,7 +384,7 @@ void DoSides( int type, int axis ){ ModalDialog dialog; GtkEntry* sides_entry; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel ); @@ -392,7 +393,7 @@ void DoSides( int type, int axis ){ GtkHBox* hbox = create_dialog_hbox( 4, 4 ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Sides:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Sides:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } @@ -432,13 +433,13 @@ void DoSides( int type, int axis ){ // ============================================================================= // About dialog (no program is complete without one) -void about_button_changelog( GtkWidget *widget, gpointer data ){ +void about_button_changelog( ui::Widget widget, gpointer data ){ StringOutputStream log( 256 ); log << AppPath_get() << "changelog.txt"; OpenURL( log.c_str() ); } -void about_button_credits( GtkWidget *widget, gpointer data ){ +void about_button_credits( ui::Widget widget, gpointer data ){ StringOutputStream cred( 256 ); cred << AppPath_get() << "credits.html"; OpenURL( cred.c_str() ); @@ -448,7 +449,7 @@ void DoAbout(){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); { GtkVBox* vbox = create_dialog_vbox( 4, 4 ); @@ -482,7 +483,7 @@ void DoAbout(){ "you may report your problems at\n" "https://gitlab.com/xonotic/netradiant/issues"; - GtkLabel* label = GTK_LABEL( gtk_label_new( label_text.c_str() ) ); + GtkLabel* label = GTK_LABEL( ui::Label( label_text.c_str() ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); @@ -514,7 +515,7 @@ void DoAbout(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vendor:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vendor:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -522,7 +523,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Version:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Version:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -530,7 +531,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Renderer:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Renderer:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -538,7 +539,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VENDOR ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_VENDOR ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -546,7 +547,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_VERSION ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_VERSION ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -554,7 +555,7 @@ void DoAbout(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast( glGetString( GL_RENDERER ) ) ) ); + GtkLabel* label = GTK_LABEL( ui::Label( reinterpret_cast( glGetString( GL_RENDERER ) ) ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), @@ -569,7 +570,7 @@ void DoAbout(){ GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) ); { - GtkWidget* text_extensions = gtk_text_view_new(); + ui::Widget text_extensions = ui::Widget(gtk_text_view_new()); gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE ); gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions ); GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) ); @@ -601,7 +602,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkEntry* x; GtkEntry* y; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Patch texture layout", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel ); @@ -613,7 +614,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture will be fit across the patch based\n" + GtkLabel* label = GTK_LABEL( ui::Label( "Texture will be fit across the patch based\n" "on the x and y values given. Values of 1x1\n" "will \"fit\" the texture. 2x2 will repeat\n" "it twice, etc." ) ); @@ -626,7 +627,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ gtk_widget_show( GTK_WIDGET( table ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture x:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Texture x:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -634,7 +635,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture y:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Texture y:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -709,11 +710,11 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ // Text Editor dialog // master window widget -static GtkWidget *text_editor = 0; -static GtkWidget *text_widget; // slave, text widget from the gtk editor +static ui::Widget text_editor; +static ui::Widget text_widget; // slave, text widget from the gtk editor -static gint editor_delete( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static gint editor_delete( ui::Widget widget, gpointer data ){ + if ( widget.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::NO ) { return TRUE; } @@ -722,12 +723,12 @@ static gint editor_delete( GtkWidget *widget, gpointer data ){ return TRUE; } -static void editor_save( GtkWidget *widget, gpointer data ){ +static void editor_save( ui::Widget widget, gpointer data ){ FILE *f = fopen( (char*)g_object_get_data( G_OBJECT( data ), "filename" ), "w" ); gpointer text = g_object_get_data( G_OBJECT( data ), "text" ); if ( f == 0 ) { - gtk_MessageBox( GTK_WIDGET( data ), "Error saving file !" ); + ui::Widget(GTK_WIDGET( data )).alert( "Error saving file !" ); return; } @@ -736,8 +737,8 @@ static void editor_save( GtkWidget *widget, gpointer data ){ fclose( f ); } -static void editor_close( GtkWidget *widget, gpointer data ){ - if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) { +static void editor_close( ui::Widget widget, gpointer data ){ + if ( text_editor.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::NO ) { return; } @@ -745,44 +746,44 @@ static void editor_close( GtkWidget *widget, gpointer data ){ } static void CreateGtkTextEditor(){ - GtkWidget *dlg; - GtkWidget *vbox, *hbox, *button, *scr, *text; + ui::Widget dlg; + ui::Widget vbox, hbox, button, scr, text; - dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + dlg = ui::Widget(gtk_window_new( GTK_WINDOW_TOPLEVEL )); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( editor_delete ), 0 ); gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 ); - vbox = gtk_vbox_new( FALSE, 5 ); + vbox = ui::Widget(gtk_vbox_new( FALSE, 5 )); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - scr = gtk_scrolled_window_new( 0, 0 ); + scr = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_widget_show( scr ); gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); - text = gtk_text_view_new(); + text = ui::Widget(gtk_text_view_new()); gtk_container_add( GTK_CONTAINER( scr ), text ); gtk_widget_show( text ); - g_object_set_data( G_OBJECT( dlg ), "text", text ); + g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text ); gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE ); - hbox = gtk_hbox_new( FALSE, 5 ); + hbox = ui::Widget(gtk_hbox_new( FALSE, 5 )); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); - button = gtk_button_new_with_label( "Close" ); + button = ui::Widget(gtk_button_new_with_label( "Close" )); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( editor_close ), dlg ); gtk_widget_set_usize( button, 60, -2 ); - button = gtk_button_new_with_label( "Save" ); + button = ui::Widget(gtk_button_new_with_label( "Save" )); gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", @@ -862,7 +863,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Light intensity", dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 ); GtkAccelGroup *accel_group = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel_group ); @@ -874,7 +875,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC for default, ENTER to validate" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "ESC for default, ENTER to validate" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } @@ -929,7 +930,7 @@ EMessageBoxReturn DoShaderTagDlg( std::string* tag, const char* title ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); GtkAccelGroup *accel_group = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel_group ); @@ -942,7 +943,7 @@ EMessageBoxReturn DoShaderTagDlg( std::string* tag, const char* title ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { //GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces")); - GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC to cancel, ENTER to validate" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "ESC to cancel, ENTER to validate" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } @@ -988,7 +989,7 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); GtkAccelGroup *accel_group = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel_group ); @@ -1000,22 +1001,22 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "The selected shader" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "The selected shader" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( name ) ); + GtkLabel* label = GTK_LABEL( ui::Label( name ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "is located in file" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "is located in file" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( filename ) ); + GtkLabel* label = GTK_LABEL( ui::Label( filename ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 59dab2a9..e988544b 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -36,6 +36,7 @@ #include #include +#include "uilib/uilib.h" #include "math/vector.h" #include "os/path.h" @@ -97,8 +98,8 @@ GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* // ============================================================================= // File dialog -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ - GtkWidget* dlg; +bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ + ui::Widget dlg; double clr[3]; ModalDialog dialog; @@ -106,13 +107,13 @@ bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ clr[1] = color[1]; clr[2] = color[2]; - dlg = gtk_color_selection_dialog_new( title ); + dlg = ui::Widget(gtk_color_selection_dialog_new( title )); gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); - if ( parent != 0 ) { + if ( parent ) { gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) ); } @@ -134,17 +135,17 @@ bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ return ok; } -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){ - const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) ); +void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ){ + const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { gtk_entry_set_text( entry, filename ); } } -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ){ +void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ){ const char* text = gtk_entry_get_text( entry ); - char *dir = dir_dialog( gtk_widget_get_toplevel( widget ), "Choose Directory", path_is_absolute( text ) ? text : "" ); + char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" ); if ( dir != 0 ) { gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 14cdd816..3588c252 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -32,6 +32,7 @@ #define INCLUDED_GTKMISC_H #include +#include inline void process_gui(){ while ( gtk_events_pending() ) @@ -66,10 +67,10 @@ GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* template class BasicVector3; typedef BasicVector3 Vector3; -bool color_dialog( GtkWidget *parent, Vector3& color, const char* title = "Choose Color" ); +bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" ); typedef struct _GtkEntry GtkEntry; -void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ); -void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ); +void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ); +void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ); #endif diff --git a/radiant/main.cpp b/radiant/main.cpp index 0463944c..65a45497 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -69,6 +69,7 @@ #include "iundo.h" +#include "uilib/uilib.h" #include #include "cmdlib.h" @@ -309,12 +310,12 @@ bool handleMessage(){ ScopedLock lock( m_lock ); #if defined _DEBUG m_buffer << "Break into the debugger?\n"; - bool handled = gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO; + bool handled = ui::alert( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO; m_buffer.clear(); return handled; #else m_buffer << "Please report this error to the developers\n"; - gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_OK, eMB_ICONERROR ); + ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::ERROR ); m_buffer.clear(); #endif } @@ -411,7 +412,7 @@ bool check_version(){ << ") doesn't match what the latest setup has configured in this directory\n" "Make sure you run the right/latest editor binary you installed\n" << AppPath_get(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT ); + ui::alert( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT ); } return bVerIsGood; #else @@ -439,7 +440,7 @@ void create_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::ERROR ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -449,14 +450,14 @@ void create_global_pid(){ "The failure may be related to current global preferences.\n" "Do you want to reset global preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) { g_GamesDialog.Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // set without saving, the class is not in a coherent state yet @@ -480,7 +481,7 @@ void remove_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::ERROR ); } } @@ -498,7 +499,7 @@ void create_local_pid(){ if ( remove( g_pidGameFile.c_str() ) == -1 ) { StringOutputStream msg; msg << "WARNING: Could not delete " << g_pidGameFile.c_str(); - gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR ); + ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::ERROR ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -508,14 +509,14 @@ void create_local_pid(){ "The failure may be caused by current preferences.\n" "Do you want to reset all preferences to defaults?"; - if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) { + if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) { Preferences_Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK ); + ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // force console logging on! (will go in prefs too) @@ -573,8 +574,7 @@ int main( int argc, char* argv[] ){ } #endif - gtk_disable_setlocale(); - gtk_init( &argc, &argv ); + ui::init(argc, argv); // redirect Gtk warnings to the console g_log_set_handler( "Gdk", (GLogLevelFlags)( G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | @@ -650,7 +650,7 @@ int main( int argc, char* argv[] ){ remove_local_pid(); - gtk_main(); + ui::main(); // avoid saving prefs when the app is minimized if ( g_pParentWnd->IsSleeping() ) { diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index bd512582..447296bd 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -27,13 +27,10 @@ #include "mainframe.h" -#include "debugging/debugging.h" #include "version.h" #include "ifilesystem.h" #include "iundo.h" -#include "ifilter.h" -#include "itoolbar.h" #include "editable.h" #include "ientity.h" #include "ishaders.h" @@ -50,13 +47,9 @@ #include #include #include -#include -#include -#include #include "cmdlib.h" -#include "scenelib.h" #include "stream/stringstream.h" #include "signal/isignal.h" #include "os/path.h" @@ -65,14 +58,11 @@ #include "moduleobservers.h" #include "gtkutil/clipboard.h" -#include "gtkutil/container.h" #include "gtkutil/frame.h" -#include "gtkutil/glfont.h" #include "gtkutil/glwidget.h" #include "gtkutil/image.h" #include "gtkutil/menu.h" #include "gtkutil/paned.h" -#include "gtkutil/widget.h" #include "autosave.h" #include "build.h" @@ -101,7 +91,6 @@ #include "pluginmanager.h" #include "pluginmenu.h" #include "plugintoolbar.h" -#include "points.h" #include "preferences.h" #include "qe3.h" #include "qgl.h" @@ -432,18 +421,18 @@ void Paths_registerPreferencesPage(){ class PathsDialog : public Dialog { public: -GtkWindow* BuildDialog(){ +ui::Window BuildDialog(){ GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Paths_constructPreferences( preferencesPage ); } - return create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) ); + return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) )); } }; @@ -805,7 +794,7 @@ ChooseColour( const GetColourCallback& get, const SetColourCallback& set ) void operator()(){ Vector3 colour; m_get( colour ); - color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour ); + color_dialog( MainFrame_getWindow(), colour ); m_set( colour ); } }; @@ -970,13 +959,13 @@ void OpenBugReportURL(){ } -GtkWidget* g_page_console; +ui::Widget g_page_console; void Console_ToggleShow(){ GroupDialog_showPage( g_page_console ); } -GtkWidget* g_page_entity; +ui::Widget g_page_entity; void EntityInspector_ToggleShow(){ GroupDialog_showPage( g_page_entity ); @@ -1616,22 +1605,22 @@ void EverySecondTimer_disable(){ } } -gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){ - gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); +gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( widget.handle()->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); return FALSE; } class WaitDialog { public: -GtkWindow* m_window; +ui::Window m_window; GtkLabel* m_label; }; WaitDialog create_wait_dialog( const char* title, const char* text ){ WaitDialog dialog; - dialog.m_window = create_floating_window( title, MainFrame_getWindow() ); + dialog.m_window = MainFrame_getWindow().create_floating_window(title); gtk_window_set_resizable( dialog.m_window, FALSE ); gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 ); gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT ); @@ -1639,7 +1628,7 @@ WaitDialog create_wait_dialog( const char* title, const char* text ){ g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 ); { - dialog.m_label = GTK_LABEL( gtk_label_new( text ) ); + dialog.m_label = GTK_LABEL( ui::Label( text ) ); gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 ); gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT ); gtk_widget_show( GTK_WIDGET( dialog.m_label ) ); @@ -1727,7 +1716,7 @@ void ScreenUpdates_Enable(){ gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) ); destroy_floating_window( g_wait.m_window ); - g_wait.m_window = 0; + g_wait.m_window = ui::Window(); //gtk_window_present(MainFrame_getWindow()); } @@ -1891,10 +1880,10 @@ void fill_view_xz_front_menu( GtkMenu* menu ){ } -GtkWidget* g_toggle_z_item = 0; -GtkWidget* g_toggle_console_item = 0; -GtkWidget* g_toggle_entity_item = 0; -GtkWidget* g_toggle_entitylist_item = 0; +ui::Widget g_toggle_z_item; +ui::Widget g_toggle_console_item; +ui::Widget g_toggle_entity_item; +ui::Widget g_toggle_entitylist_item; GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ // View menu @@ -2400,17 +2389,17 @@ GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){ return toolbar; } -GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){ +ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){ GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) ); gtk_widget_show( GTK_WIDGET( table ) ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 ); - pStatusLabel[c_command_status] = GTK_WIDGET( label ); + pStatusLabel[c_command_status] = ui::Widget(GTK_WIDGET( label )); } for ( int i = 1; i < c_count_status; ++i ) @@ -2420,16 +2409,16 @@ GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){ gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 ); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); - GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) ); - pStatusLabel[i] = GTK_WIDGET( label ); + pStatusLabel[i] = ui::Widget(GTK_WIDGET( label )); } - return GTK_WIDGET( table ); + return ui::Widget(GTK_WIDGET( table )); } #if 0 @@ -2441,15 +2430,15 @@ class WindowFocusPrinter { const char* m_name; -static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){ +static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " frame_event\n"; return FALSE; } -static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){ +static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){ globalOutputStream() << self->m_name << " keys_changed\n"; return FALSE; } -static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){ +static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){ if ( gtk_window_is_active( window ) ) { globalOutputStream() << self->m_name << " takes toplevel focus\n"; } @@ -2462,7 +2451,7 @@ static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* s public: WindowFocusPrinter( const char* name ) : m_name( name ){ } -void connect( GtkWindow* toplevel_window ){ +void connect( ui::Window toplevel_window ){ g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this ); g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this ); @@ -2476,15 +2465,15 @@ WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" ); class MainWindowActive { -static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){ - if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { +static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){ + if ( g_wait.m_window && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) { gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); } return FALSE; } public: -void connect( GtkWindow* toplevel_window ){ +void connect( ui::Window toplevel_window ){ g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this ); } }; @@ -2510,16 +2499,14 @@ void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){ // ============================================================================= // MainFrame class -MainFrame* g_pParentWnd = 0; +MainFrame* g_pParentWnd = nullptr; -GtkWindow* MainFrame_getWindow(){ - if ( g_pParentWnd == 0 ) { - return 0; - } - return g_pParentWnd->m_window; +ui::Window MainFrame_getWindow() +{ + return g_pParentWnd ? g_pParentWnd->m_window : ui::Window(); } -std::vector g_floating_windows; +std::vector g_floating_windows; MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){ m_pXYWnd = 0; @@ -2531,7 +2518,7 @@ MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusText for ( int n = 0; n < c_count_status; n++ ) { - m_pStatusLabel[n] = 0; + m_pStatusLabel[n] = ui::root; } m_bSleeping = false; @@ -2546,7 +2533,7 @@ MainFrame::~MainFrame(){ Shutdown(); - for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) + for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) { gtk_widget_destroy( *i ); } @@ -2671,8 +2658,8 @@ void MainFrame::OnSleep(){ } -GtkWindow* create_splash(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); +ui::Window create_splash(){ + ui::Window window = ui::Window(GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) )); gtk_window_set_decorated( window, FALSE ); gtk_window_set_resizable( window, FALSE ); gtk_window_set_modal( window, TRUE ); @@ -2690,7 +2677,7 @@ GtkWindow* create_splash(){ return window; } -static GtkWindow *splash_screen = 0; +static ui::Window splash_screen; void show_splash(){ splash_screen = create_splash(); @@ -2707,7 +2694,7 @@ WindowPositionTracker g_posXYWnd; WindowPositionTracker g_posXZWnd; WindowPositionTracker g_posYZWnd; -static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){ +static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){ if ( ConfirmModified( "Exit Radiant" ) ) { gtk_main_quit(); } @@ -2716,7 +2703,7 @@ static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data } void MainFrame::Create(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); + ui::Window window = ui::Window(GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) )); GlobalWindowObservers_connectTopLevel( window ); @@ -2744,9 +2731,9 @@ void MainFrame::Create(){ g_MainWindowActive.connect( window ); - GetPlugInMgr().Init( GTK_WIDGET( window ) ); + GetPlugInMgr().Init( window ); - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); + ui::Widget vbox = ui::Widget(gtk_vbox_new( FALSE, 0 )); gtk_container_add( GTK_CONTAINER( window ), vbox ); gtk_widget_show( vbox ); @@ -2768,7 +2755,7 @@ void MainFrame::Create(){ } gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 ); - GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel ); + ui::Widget main_statusbar = create_main_statusbar( m_pStatusLabel ); gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 ); GroupDialog_constructWindow( window ); @@ -2801,17 +2788,17 @@ void MainFrame::Create(){ if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { { - GtkWidget* vsplit = gtk_vpaned_new(); + ui::Widget vsplit = ui::Widget(gtk_vpaned_new()); m_vSplit = vsplit; gtk_box_pack_start( GTK_BOX( vbox ), vsplit, TRUE, TRUE, 0 ); gtk_widget_show( vsplit ); // console - GtkWidget* console_window = Console_constructWindow( window ); + ui::Widget console_window = Console_constructWindow( window ); gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); { - GtkWidget* hsplit = gtk_hpaned_new(); + ui::Widget hsplit = ui::Widget(gtk_hpaned_new()); gtk_widget_show( hsplit ); m_hSplit = hsplit; gtk_paned_add1( GTK_PANED( vsplit ), hsplit ); @@ -2819,10 +2806,10 @@ void MainFrame::Create(){ // xy m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) ); + ui::Widget xy_window = ui::Widget(GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) )); { - GtkWidget* vsplit2 = gtk_vpaned_new(); + ui::Widget vsplit2 = ui::Widget(gtk_vpaned_new()); gtk_widget_show( vsplit2 ); m_vSplit2 = vsplit2; @@ -2867,7 +2854,7 @@ void MainFrame::Create(){ } else if ( CurrentStyle() == eFloating ) { { - GtkWindow* window = create_persistent_floating_window( "Camera", m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window )); global_accel_connect_window( window ); g_posCamWnd.connect( window ); @@ -2882,11 +2869,11 @@ void MainFrame::Create(){ } CamWnd_setParent( *m_pCamWnd, window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window )); global_accel_connect_window( window ); g_posXYWnd.connect( window ); @@ -2901,11 +2888,11 @@ void MainFrame::Create(){ } XY_Top_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window )); global_accel_connect_window( window ); g_posXZWnd.connect( window ); @@ -2920,11 +2907,11 @@ void MainFrame::Create(){ XZ_Front_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { - GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window ); + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window )); global_accel_connect_window( window ); g_posYZWnd.connect( window ); @@ -2939,12 +2926,12 @@ void MainFrame::Create(){ YZ_Side_Shown_Construct( window ); - g_floating_windows.push_back( GTK_WIDGET( window ) ); + g_floating_windows.push_back( window ); } { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } GroupDialog_show(); @@ -2955,29 +2942,29 @@ void MainFrame::Create(){ GlobalCamera_setCamWnd( *m_pCamWnd ); CamWnd_setParent( *m_pCamWnd, window ); - GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd ); + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); m_pYZWnd = new XYWnd(); m_pYZWnd->SetViewType( YZ ); - GtkWidget* yz = m_pYZWnd->GetWidget(); + ui::Widget yz = m_pYZWnd->GetWidget(); m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); - GtkWidget* xy = m_pXYWnd->GetWidget(); + ui::Widget xy = m_pXYWnd->GetWidget(); m_pXZWnd = new XYWnd(); m_pXZWnd->SetViewType( XZ ); - GtkWidget* xz = m_pXZWnd->GetWidget(); + ui::Widget xz = m_pXZWnd->GetWidget(); GtkHPaned* split = create_split_views( camera, yz, xy, xz ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 ); { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); } } diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 95d61670..e4553408 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_MAINFRAME_H ) #define INCLUDED_MAINFRAME_H +#include #include "gtkutil/window.h" #include "gtkutil/idledraw.h" #include "gtkutil/widget.h" @@ -36,9 +37,6 @@ class XYWnd; class CamWnd; class ZWnd; -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; - const int c_command_status = 0; const int c_position_status = 1; const int c_brushcount_status = 2; @@ -60,7 +58,7 @@ enum EViewStyle MainFrame(); ~MainFrame(); -GtkWindow* m_window; +ui::Window m_window; std::string m_command_status; std::string m_position_status; @@ -73,9 +71,9 @@ void Create(); void SaveWindowInfo(); void Shutdown(); -GtkWidget* m_vSplit; -GtkWidget* m_hSplit; -GtkWidget* m_vSplit2; +ui::Widget m_vSplit; +ui::Widget m_hSplit; +ui::Widget m_vSplit2; XYWnd* m_pXYWnd; XYWnd* m_pYZWnd; @@ -86,7 +84,7 @@ XYWnd* m_pActiveXY; bool m_bSleeping; -GtkWidget *m_pStatusLabel[c_count_status]; +ui::Widget m_pStatusLabel[c_count_status]; EViewStyle m_nCurrentStyle; @@ -142,7 +140,7 @@ bool FloatingGroupDialog(){ extern MainFrame* g_pParentWnd; -GtkWindow* MainFrame_getWindow(); +ui::Window MainFrame_getWindow(); enum EMouseButtonMode { @@ -271,6 +269,6 @@ void XYWindowDestroyed_disconnect( SignalHandlerId id ); MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler ); void XYWindowMouseDown_disconnect( MouseEventHandlerId id ); -extern GtkWidget* g_page_entity; +extern ui::Widget g_page_entity; #endif diff --git a/radiant/map.cpp b/radiant/map.cpp index 44633afa..0de6707f 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -50,6 +50,7 @@ MapModules& ReferenceAPI_getMapModules(); #include #include #include +#include "uilib/uilib.h" #include "scenelib.h" #include "transformlib.h" @@ -769,7 +770,7 @@ void DoMapInfo(){ GtkEntry* entities_entry; GtkListStore* EntityBreakdownWalker; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Map Info", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog ); window_set_position( window, g_posMapInfoWnd ); @@ -806,7 +807,7 @@ void DoMapInfo(){ entities_entry = entry; } { - GtkWidget* label = gtk_label_new( "Total Brushes" ); + ui::Widget label = ui::Label( "Total Brushes" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -814,7 +815,7 @@ void DoMapInfo(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkWidget* label = gtk_label_new( "Total Entities" ); + ui::Widget label = ui::Label( "Total Entities" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -833,7 +834,7 @@ void DoMapInfo(){ } } { - GtkWidget* label = gtk_label_new( "Entity breakdown" ); + ui::Widget label = ui::Label( "Entity breakdown" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, TRUE, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); @@ -845,7 +846,7 @@ void DoMapInfo(){ { GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE ); { @@ -1775,15 +1776,15 @@ const char* getMapsPath(){ } const char* map_open( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), true, false, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getMapsPath(), MapFormat::Name(), true, false, false ); } const char* map_import( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), false, true, false ); + return MainFrame_getWindow().file_dialog( TRUE, title, getMapsPath(), MapFormat::Name(), false, true, false ); } const char* map_save( const char* title ){ - return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getMapsPath(), MapFormat::Name(), false, false, true ); + return MainFrame_getWindow().file_dialog( FALSE, title, getMapsPath(), MapFormat::Name(), false, false, true ); } void OpenMap(){ @@ -2004,7 +2005,7 @@ void DoFind(){ GtkEntry* entity; GtkEntry* brush; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Find Brush", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel ); @@ -2016,14 +2017,14 @@ void DoFind(){ GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( "Entity number" ); + ui::Widget label = ui::Label( "Entity number" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Brush number" ); + ui::Widget label = ui::Label( "Brush number" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), diff --git a/radiant/multimon.cpp b/radiant/multimon.cpp index 04407591..281a5bff 100644 --- a/radiant/multimon.cpp +++ b/radiant/multimon.cpp @@ -32,8 +32,8 @@ multimon_globals_t g_multimon_globals; LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" ); void MultiMonitor_constructPreferences( PreferencesPage& page ){ - GtkWidget* primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); - GtkWidget* popup = page.appendCheckBox( + ui::CheckButton primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); + ui::CheckButton popup = page.appendCheckBox( "", "Disable system menu on popup windows", LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ), BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched ) diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 29d8d195..98e0894e 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -212,7 +212,7 @@ static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){ class PatchInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); Subdivisions m_subdivisions; NonModalEntry m_horizontalSubdivisionsEntry; NonModalEntry m_verticalSubdivisionsEntry; @@ -284,7 +284,7 @@ void exportData(); PatchInspector g_PatchInspector; -void PatchInspector_constructWindow( GtkWindow* main_window ){ +void PatchInspector_constructWindow( ui::Window main_window ){ g_PatchInspector.m_parent = main_window; g_PatchInspector.Create(); } @@ -320,7 +320,7 @@ void PatchInspector_toggleShown(){ // static functions // memorize the current state (that is don't try to undo our do before changing something else) -static void OnApply( GtkWidget *widget, gpointer data ){ +static void OnApply( ui::Widget widget, gpointer data ){ g_PatchInspector.exportData(); if ( g_PatchInspector.m_Patch != 0 ) { UndoableCommand command( "patchSetTexture" ); @@ -347,7 +347,7 @@ static void OnApply( GtkWidget *widget, gpointer data ){ } } -static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){ +static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){ if ( !g_PatchInspector.m_bListenChanged ) { return; } @@ -375,27 +375,27 @@ void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){ SceneChangeNotify(); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchfit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){ Patch_FlipTextureX(); } -static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){ Patch_FlipTextureY(); } @@ -455,7 +455,7 @@ void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) ); } -static void OnBtnPatchAutoCap( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){ Patch_AutoCapTexture(); } @@ -544,12 +544,12 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){ } // update the point-by-point view - OnSelchangeComboColRow( 0,0 ); + OnSelchangeComboColRow( ui::root ,0 ); } -static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){ if ( event->keyval == GDK_Return ) { - OnApply( 0, 0 ); + OnApply( ui::root, 0 ); return TRUE; } else if ( event->keyval == GDK_Escape ) { @@ -562,8 +562,8 @@ static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){ // ============================================================================= // PatchInspector class -GtkWindow* PatchInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Patch Properties", m_parent ); +ui::Window PatchInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Patch Properties", m_parent )); m_position_tracker.connect( window ); @@ -602,14 +602,14 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Row:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Row:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Column:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Column:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -647,35 +647,35 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "X:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "X:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Y:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Y:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Z:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Z:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "S:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "S:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( 0 ), 0, 0 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "T:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "T:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -749,7 +749,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Fixed" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Fixed" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -766,7 +766,7 @@ GtkWindow* PatchInspector::BuildDialog(){ g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -782,7 +782,7 @@ GtkWindow* PatchInspector::BuildDialog(){ m_horizontalSubdivisionsEntry.connect( entry ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -811,7 +811,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Name:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Name:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 ); gtk_label_set_justify( label, GTK_JUSTIFY_LEFT ); @@ -833,7 +833,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_table_set_row_spacings( table, 5 ); gtk_table_set_col_spacings( table, 5 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -841,7 +841,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Shift Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -849,7 +849,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Stretch Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Horizontal Stretch Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -866,7 +866,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Vertical Stretch Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), @@ -883,7 +883,7 @@ GtkWindow* PatchInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Rotate Step" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5, (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ), diff --git a/radiant/patchdialog.h b/radiant/patchdialog.h index 1304ccbe..ca1f6c9e 100644 --- a/radiant/patchdialog.h +++ b/radiant/patchdialog.h @@ -19,15 +19,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PATCHDIALOG_H ) #define INCLUDED_PATCHDIALOG_H void PatchInspector_Construct(); void PatchInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void PatchInspector_constructWindow( GtkWindow* main_window ); +void PatchInspector_constructWindow( ui::Window main_window ); void PatchInspector_destroyWindow(); namespace scene diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index a666ee10..f82c19ac 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -851,7 +851,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkComboBox* width; GtkComboBox* height; - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog ); + ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel ); @@ -863,7 +863,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Width:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -871,7 +871,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) ); + GtkLabel* label = GTK_LABEL( ui::Label( "Height:" ) ); gtk_widget_show( GTK_WIDGET( label ) ); gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), @@ -972,13 +972,13 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - GtkWidget* bevel; - GtkWidget* ibevel; - GtkWidget* endcap; - GtkWidget* iendcap; - GtkWidget* cylinder; + ui::Widget bevel; + ui::Widget ibevel; + ui::Widget endcap; + ui::Widget iendcap; + ui::Widget cylinder; - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog ); + ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog ); GtkAccelGroup *accel_group = gtk_accel_group_new(); gtk_window_add_accel_group( window, accel_group ); @@ -1037,7 +1037,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GSList* group = 0; { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1047,7 +1047,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ bevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1057,7 +1057,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ endcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1067,7 +1067,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ibevel = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), @@ -1077,7 +1077,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ iendcap = button; } { - GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" ); + ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" )); gtk_widget_show( button ); gtk_table_attach( table, button, 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ), diff --git a/radiant/pluginmanager.cpp b/radiant/pluginmanager.cpp index 8d90f18e..7d59ac68 100644 --- a/radiant/pluginmanager.cpp +++ b/radiant/pluginmanager.cpp @@ -53,7 +53,7 @@ public: /*! build directly from a SYN_PROVIDE interface */ -CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ); +CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ); /*! dispatching a command by name to the plugin */ @@ -69,7 +69,7 @@ bool ownsCommandID( std::size_t n ); }; -CPluginSlot::CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +CPluginSlot::CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mpTable = &table; m_menu_name = name; @@ -149,7 +149,7 @@ std::list mSlots; public: virtual ~CPluginSlots(); -void AddPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){ +void AddPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){ mSlots.push_back( new CPluginSlot( main_window, name, table ) ); } @@ -190,13 +190,13 @@ bool CPluginSlots::Dispatch( std::size_t n, const char* p ){ CPluginSlots g_plugin_slots; -void FillPluginSlots( CPluginSlots& slots, GtkWidget* main_window ){ +void FillPluginSlots( CPluginSlots& slots, ui::Widget main_window ){ class AddPluginVisitor : public PluginModules::Visitor { CPluginSlots& m_slots; - GtkWidget* m_main_window; + ui::Widget m_main_window; public: - AddPluginVisitor( CPluginSlots& slots, GtkWidget* main_window ) + AddPluginVisitor( CPluginSlots& slots, ui::Widget main_window ) : m_slots( slots ), m_main_window( main_window ){ } void visit( const char* name, const _QERPluginTable& table ) const { @@ -220,7 +220,7 @@ void CPlugInManager::Dispatch( std::size_t n, const char * p ){ g_plugin_slots.Dispatch( n, p ); } -void CPlugInManager::Init( GtkWidget* main_window ){ +void CPlugInManager::Init( ui::Widget main_window ){ FillPluginSlots( g_plugin_slots, main_window ); } diff --git a/radiant/pluginmanager.h b/radiant/pluginmanager.h index d7943fb3..6603f6e1 100644 --- a/radiant/pluginmanager.h +++ b/radiant/pluginmanager.h @@ -23,8 +23,8 @@ #define INCLUDED_PLUGINMANAGER_H #include +#include -typedef struct _GtkWidget GtkWidget; /*! \class IPlugin @@ -55,7 +55,7 @@ class CPlugInManager { public: void Dispatch( std::size_t n, const char *p ); -void Init( GtkWidget* main_window ); +void Init( ui::Widget main_window ); void constructMenu( PluginsVisitor& menu ); void Shutdown(); }; diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 4708a78c..56fcd61d 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -36,26 +36,26 @@ int m_nNextPlugInID = 0; -void plugin_activated( GtkWidget* widget, gpointer data ){ +void plugin_activated( ui::Widget widget, gpointer data ){ const char* str = (const char*)g_object_get_data( G_OBJECT( widget ),"command" ); GetPlugInMgr().Dispatch( gpointer_to_int( data ), str ); } #include -typedef std::stack WidgetStack; +typedef std::stack WidgetStack; void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ - GtkWidget *menu, *item, *parent, *subMenu; + ui::Widget menu, item, parent, subMenu; const char *menuText, *menuCommand; WidgetStack menuStack; - parent = gtk_menu_item_new_with_label( pPlugIn->getMenuName() ); + parent = ui::Widget(gtk_menu_item_new_with_label( pPlugIn->getMenuName() )); gtk_widget_show( parent ); gtk_container_add( GTK_CONTAINER( plugin_menu ), parent ); std::size_t nCount = pPlugIn->getCommandCount(); if ( nCount > 0 ) { - menu = gtk_menu_new(); + menu = ui::Widget(gtk_menu_new()); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( GTK_MENU( menu ) ); } @@ -66,7 +66,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ if ( menuText != 0 && strlen( menuText ) > 0 ) { if ( !strcmp( menuText, "-" ) ) { - item = gtk_menu_item_new(); + item = ui::Widget(gtk_menu_item_new()); gtk_widget_set_sensitive( item, FALSE ); } else if ( !strcmp( menuText, ">" ) ) { @@ -77,11 +77,11 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ continue; } - item = gtk_menu_item_new_with_label( menuText ); + item = ui::Widget(gtk_menu_item_new_with_label( menuText )); gtk_widget_show( item ); gtk_container_add( GTK_CONTAINER( menu ), item ); - subMenu = gtk_menu_new(); + subMenu = ui::Widget(gtk_menu_new()); gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu ); menuStack.push( menu ); menu = subMenu; @@ -100,7 +100,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } else { - item = gtk_menu_item_new_with_label( menuText ); + item = ui::Widget(gtk_menu_item_new_with_label( menuText )); g_object_set_data( G_OBJECT( item ),"command", const_cast( static_cast( menuCommand ) ) ); g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); } diff --git a/radiant/plugintoolbar.cpp b/radiant/plugintoolbar.cpp index 03ef2074..9c762f46 100644 --- a/radiant/plugintoolbar.cpp +++ b/radiant/plugintoolbar.cpp @@ -85,7 +85,7 @@ void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, co gtk_toolbar_append_element( toolbar, gtktoolbarchildtype_for_toolbarbuttontype( type ), 0, text, tooltip, "", GTK_WIDGET( new_plugin_image( icon ) ), handler, data ); } -void ActivateToolbarButton( GtkWidget *widget, gpointer data ){ +void ActivateToolbarButton( ui::Widget widget, gpointer data ){ const_cast( reinterpret_cast( data ) )->activate(); } diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index b5a1ac59..c84538a7 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -74,8 +74,8 @@ void Interface_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Default Text Editor", g_TextEditor_useWin32Editor ); #else { - GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); - GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); + ui::CheckButton use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); + ui::Widget custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); Widget_connectToggleDependency( custom_editor, use_custom ); } #endif @@ -104,6 +104,7 @@ void Mouse_registerPreferencesPage(){ */ #include +#include inline const char* xmlAttr_getName( xmlAttrPtr attr ){ return reinterpret_cast( attr->name ); @@ -327,19 +328,19 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){ page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt ); } -GtkWindow* CGameDialog::BuildDialog(){ +ui::Window CGameDialog::BuildDialog(){ GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); GtkVBox* vbox2 = create_dialog_vbox( 0, 4 ); gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); { - PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) ); + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); Global_constructPreferences( preferencesPage ); CreateGlobalFrame( preferencesPage ); } - return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) ); + return ui::Window(create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) )); } class LoadGameFile @@ -468,7 +469,7 @@ CGameDialog::~CGameDialog(){ delete ( *iGame ); *iGame = 0; } - if ( GetWidget() != 0 ) { + if ( GetWidget() ) { Destroy(); } } @@ -497,11 +498,11 @@ CGameDialog g_GamesDialog; // ============================================================================= // Widget callbacks for PrefsDlg -static void OnButtonClean( GtkWidget *widget, gpointer data ){ +static void OnButtonClean( ui::Widget widget, gpointer data ){ // make sure this is what the user wants - if ( gtk_MessageBox( GTK_WIDGET( g_Preferences.GetWidget() ), "This will close Radiant and clean the corresponding registry entries.\n" + if ( ui::Widget(GTK_WIDGET( g_Preferences.GetWidget() )).alert( "This will close Radiant and clean the corresponding registry entries.\n" "Next time you start Radiant it will be good as new. Do you wish to continue?", - "Reset Registry", eMB_YESNO, eMB_ICONASTERISK ) == eIDYES ) { + "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::ASTERISK ) == ui::alert_response::YES ) { PrefsDlg *dlg = (PrefsDlg*)data; dlg->EndModal( eIDCANCEL ); @@ -547,14 +548,14 @@ void PrefsDlg::Init(){ g_string_append( m_inipath, PREFS_LOCAL_FILENAME ); } -void notebook_set_page( GtkWidget* notebook, GtkWidget* page ){ +void notebook_set_page( ui::Widget notebook, ui::Widget page ){ int pagenum = gtk_notebook_page_num( GTK_NOTEBOOK( notebook ), page ); if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) ) != pagenum ) { gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), pagenum ); } } -void PrefsDlg::showPrefPage( GtkWidget* prefpage ){ +void PrefsDlg::showPrefPage( ui::Widget prefpage ){ notebook_set_page( m_notebook, prefpage ); return; } @@ -565,7 +566,7 @@ static void treeSelection( GtkTreeSelection* selection, gpointer data ){ GtkTreeModel* model; GtkTreeIter selected; if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) { - GtkWidget* prefpage; + ui::Widget prefpage; gtk_tree_model_get( model, &selected, 1, (gpointer*)&prefpage, -1 ); dlg->showPrefPage( prefpage ); } @@ -625,47 +626,47 @@ void PreferencesDialog_addSettingsPage( const PreferenceGroupCallback& callback PreferenceGroupCallbacks_pushBack( g_settingsCallbacks, callback ); } -void Widget_updateDependency( GtkWidget* self, GtkWidget* toggleButton ){ +void Widget_updateDependency( ui::Widget self, ui::Widget toggleButton ){ gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && GTK_WIDGET_IS_SENSITIVE( toggleButton ) ); } -void ToggleButton_toggled_Widget_updateDependency( GtkWidget *toggleButton, GtkWidget* self ){ +void ToggleButton_toggled_Widget_updateDependency( ui::Widget toggleButton, ui::Widget self ){ Widget_updateDependency( self, toggleButton ); } -void ToggleButton_state_changed_Widget_updateDependency( GtkWidget* toggleButton, GtkStateType state, GtkWidget* self ){ +void ToggleButton_state_changed_Widget_updateDependency( ui::Widget toggleButton, GtkStateType state, ui::Widget self ){ if ( state == GTK_STATE_INSENSITIVE ) { Widget_updateDependency( self, toggleButton ); } } -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ){ +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){ g_signal_connect( G_OBJECT( toggleButton ), "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self ); g_signal_connect( G_OBJECT( toggleButton ), "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self ); Widget_updateDependency( self, toggleButton ); } -inline GtkWidget* getVBox( GtkWidget* page ){ - return gtk_bin_get_child( GTK_BIN( page ) ); +inline ui::Widget getVBox( ui::Widget page ){ + return ui::Widget(gtk_bin_get_child( GTK_BIN( page ) )); } -GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, GtkWidget* page ){ +GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){ GtkTreeIter group; gtk_tree_store_append( store, &group, parent ); gtk_tree_store_set( store, &group, 0, name, 1, page, -1 ); return group; } -GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ - GtkWidget* preflabel = gtk_label_new( name ); +ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){ + ui::Widget preflabel = ui::Label( name ); gtk_widget_show( preflabel ); - GtkWidget* pageframe = gtk_frame_new( name ); + ui::Widget pageframe = ui::Widget(gtk_frame_new( name )); gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 ); gtk_widget_show( pageframe ); - GtkWidget* vbox = gtk_vbox_new( FALSE, 4 ); + ui::Widget vbox = ui::Widget(gtk_vbox_new( FALSE, 4 )); gtk_widget_show( vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 ); gtk_container_add( GTK_CONTAINER( pageframe ), vbox ); @@ -679,37 +680,37 @@ GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){ class PreferenceTreeGroup : public PreferenceGroup { Dialog& m_dialog; -GtkWidget* m_notebook; +ui::Widget m_notebook; GtkTreeStore* m_store; GtkTreeIter m_group; public: -PreferenceTreeGroup( Dialog& dialog, GtkWidget* notebook, GtkTreeStore* store, GtkTreeIter group ) : +PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, GtkTreeStore* store, GtkTreeIter group ) : m_dialog( dialog ), m_notebook( notebook ), m_store( store ), m_group( group ){ } PreferencesPage createPage( const char* treeName, const char* frameName ){ - GtkWidget* page = PreferencePages_addPage( m_notebook, frameName ); + ui::Widget page = PreferencePages_addPage( m_notebook, frameName ); PreferenceTree_appendPage( m_store, &m_group, treeName, page ); return PreferencesPage( m_dialog, getVBox( page ) ); } }; -GtkWindow* PrefsDlg::BuildDialog(){ +ui::Window PrefsDlg::BuildDialog(){ PreferencesDialog_addInterfacePreferences( FreeCaller1() ); Mouse_registerPreferencesPage(); - GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent ); + ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent )); { - GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 ); + ui::Widget mainvbox = ui::Widget(gtk_vbox_new( FALSE, 5 )); gtk_container_add( GTK_CONTAINER( dialog ), mainvbox ); gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 ); gtk_widget_show( mainvbox ); { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::Widget(gtk_hbox_new( FALSE, 5 )); gtk_widget_show( hbox ); gtk_box_pack_end( GTK_BOX( mainvbox ), hbox, FALSE, TRUE, 0 ); @@ -728,19 +729,19 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = ui::Widget(gtk_hbox_new( FALSE, 5 )); gtk_box_pack_start( GTK_BOX( mainvbox ), hbox, TRUE, TRUE, 0 ); gtk_widget_show( hbox ); { - GtkWidget* sc_win = gtk_scrolled_window_new( 0, 0 ); + ui::Widget sc_win = ui::Widget(gtk_scrolled_window_new( 0, 0 )); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 ); gtk_widget_show( sc_win ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN ); // prefs pages notebook - m_notebook = gtk_notebook_new(); + m_notebook = ui::Widget(gtk_notebook_new()); // hide the notebook tabs since its not supposed to look like a notebook gtk_notebook_set_show_tabs( GTK_NOTEBOOK( m_notebook ), FALSE ); gtk_box_pack_start( GTK_BOX( hbox ), m_notebook, TRUE, TRUE, 0 ); @@ -750,7 +751,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ { GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ); - GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ); + ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) )); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE ); { @@ -777,14 +778,14 @@ GtkWindow* PrefsDlg::BuildDialog(){ PreferencePages_addPage( m_notebook, "Front Page" ); { - GtkWidget* global = PreferencePages_addPage( m_notebook, "Global Preferences" ); + ui::Widget global = PreferencePages_addPage( m_notebook, "Global Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( global ) ); Global_constructPreferences( preferencesPage ); } GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global ); { - GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" ); + ui::Widget game = PreferencePages_addPage( m_notebook, "Game" ); PreferencesPage preferencesPage( *this, getVBox( game ) ); g_GamesDialog.CreateGlobalFrame( preferencesPage ); @@ -793,7 +794,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); + ui::Widget interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( interfacePage ) ); PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage ); @@ -806,7 +807,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* display = PreferencePages_addPage( m_notebook, "Display Preferences" ); + ui::Widget display = PreferencePages_addPage( m_notebook, "Display Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( display ) ); PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage ); @@ -818,7 +819,7 @@ GtkWindow* PrefsDlg::BuildDialog(){ } { - GtkWidget* settings = PreferencePages_addPage( m_notebook, "General Settings" ); + ui::Widget settings = PreferencePages_addPage( m_notebook, "General Settings" ); { PreferencesPage preferencesPage( *this, getVBox( settings ) ); PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage ); @@ -849,7 +850,7 @@ preferences_globals_t g_preferences_globals; PrefsDlg g_Preferences; // global prefs instance -void PreferencesDialog_constructWindow( GtkWindow* main_window ){ +void PreferencesDialog_constructWindow( ui::Window main_window ){ g_Preferences.m_parent = main_window; g_Preferences.Create(); } @@ -937,7 +938,7 @@ void PreferencesDialog_showDialog(){ { message << ( *i ) << '\n'; } - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), message.c_str() ); + MainFrame_getWindow().alert( message.c_str() ); g_restart_required.clear(); } } diff --git a/radiant/preferences.h b/radiant/preferences.h index b6cded4e..086a6ee4 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -34,19 +34,19 @@ #include #include -void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ); +void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ); class PreferencesPage { Dialog& m_dialog; -GtkWidget* m_vbox; +ui::Widget m_vbox; public: -PreferencesPage( Dialog& dialog, GtkWidget* vbox ) : m_dialog( dialog ), m_vbox( vbox ){ +PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){ } -GtkWidget* appendCheckBox( const char* name, const char* flag, bool& data ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){ return m_dialog.addCheckBox( m_vbox, name, flag, data ); } -GtkWidget* appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ +ui::CheckButton appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){ return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback ); } void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ @@ -70,37 +70,37 @@ void appendRadioIcons( const char* name, StringArrayRange icons, const IntImport void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){ m_dialog.addRadioIcons( m_vbox, name, data, icons ); } -GtkWidget* appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, int& data ){ +ui::Widget appendEntry( const char* name, int& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){ return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, std::size_t& data ){ +ui::Widget appendEntry( const char* name, std::size_t& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::Widget appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback ); } -GtkWidget* appendEntry( const char* name, float& data ){ +ui::Widget appendEntry( const char* name, float& data ){ return m_dialog.addEntry( m_vbox, name, data ); } -GtkWidget* appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ +ui::Widget appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){ return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback ); } -GtkWidget* appendPathEntry( const char* name, std::string& data, bool directory ){ +ui::Widget appendPathEntry( const char* name, std::string& data, bool directory ){ return m_dialog.addPathEntry( m_vbox, name, data, directory ); } -GtkWidget* appendSpinner( const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){ return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } -GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ +ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback ); } }; @@ -197,7 +197,6 @@ void Dump(); extern CGameDescription *g_pGameDescription; -typedef struct _GtkWidget GtkWidget; class PrefsDlg; class PreferencesPage; @@ -272,7 +271,7 @@ void DoGameDialog(); Dialog API this is only called when the dialog is built at startup for main engine select */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void GameFileImport( int value ); void GameFileExport( const IntImportCallback& importCallback ) const; @@ -331,7 +330,7 @@ std::list mGames; public: -GtkWidget *m_notebook; +ui::Widget m_notebook; virtual ~PrefsDlg(){ g_string_free( m_rc_path, true ); @@ -364,12 +363,12 @@ GString *m_inipath; void Init(); /*! Utility function for swapping notebook pages for tree list selections */ -void showPrefPage( GtkWidget* prefpage ); +void showPrefPage( ui::Widget prefpage ); protected: /*! Dialog API */ -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); void PostModal( EMessageBoxReturn code ); }; @@ -384,8 +383,7 @@ struct preferences_globals_t }; extern preferences_globals_t g_preferences_globals; -typedef struct _GtkWindow GtkWindow; -void PreferencesDialog_constructWindow( GtkWindow* main_window ); +void PreferencesDialog_constructWindow( ui::Window main_window ); void PreferencesDialog_destroyWindow(); void PreferencesDialog_showDialog(); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 1bce60b9..ee54ab8d 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -42,6 +42,7 @@ #include #include +#include #include "stream/textfilestream.h" #include "cmdlib.h" @@ -140,11 +141,11 @@ bool ConfirmModified( const char* title ){ return true; } - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, eMB_YESNOCANCEL, eMB_ICONQUESTION ); - if ( result == eIDCANCEL ) { + auto result = MainFrame_getWindow().alert( "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::QUESTION ); + if ( result == ui::alert_response::CANCEL ) { return false; } - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { if ( Map_Unnamed( g_map ) ) { return Map_SaveAs(); } @@ -324,7 +325,7 @@ void Sys_SetTitle( const char *text, bool modified ){ title << " *"; } - gtk_window_set_title( MainFrame_getWindow(), title.c_str() ); + gtk_window_set_title(MainFrame_getWindow(), title.c_str() ); } bool g_bWaitCursor = false; diff --git a/radiant/select.cpp b/radiant/select.cpp index 5d34645a..3c2899b0 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -870,10 +870,10 @@ struct RotateDialog GtkSpinButton* x; GtkSpinButton* y; GtkSpinButton* z; - GtkWindow *window; + ui::Window window; }; -static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){ Vector3 eulerXYZ; eulerXYZ[0] = static_cast( gtk_spin_button_get_value( rotateDialog->x ) ); @@ -888,7 +888,7 @@ static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ) return TRUE; } -static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){ gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close @@ -898,21 +898,21 @@ static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog return TRUE; } -static gboolean rotatedlg_ok( GtkWidget *widget, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){ rotatedlg_apply( widget, rotateDialog ); gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); return TRUE; } -static gboolean rotatedlg_delete( GtkWidget *widget, GdkEventAny *event, RotateDialog* rotateDialog ){ +static gboolean rotatedlg_delete( ui::Widget widget, GdkEventAny *event, RotateDialog* rotateDialog ){ rotatedlg_cancel( widget, rotateDialog ); return TRUE; } RotateDialog g_rotate_dialog; void DoRotateDlg(){ - if ( g_rotate_dialog.window == NULL ) { - g_rotate_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK( rotatedlg_delete ), &g_rotate_dialog ); + if ( !g_rotate_dialog.window ) { + g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( g_rotate_dialog.window, accel ); @@ -924,21 +924,21 @@ void DoRotateDlg(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); + ui::Widget label = ui::Label( " X " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); + ui::Widget label = ui::Label( " Y " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); + ui::Widget label = ui::Label( " Z " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), @@ -1018,13 +1018,13 @@ void DoRotateDlg(){ struct ScaleDialog { - GtkWidget* x; - GtkWidget* y; - GtkWidget* z; - GtkWindow *window; + ui::Widget x; + ui::Widget y; + ui::Widget z; + ui::Window window; }; -static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ float sx, sy, sz; sx = static_cast( atof( gtk_entry_get_text( GTK_ENTRY( scaleDialog->x ) ) ) ); @@ -1040,7 +1040,7 @@ static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" ); @@ -1050,13 +1050,13 @@ static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){ return TRUE; } -static gboolean scaledlg_ok( GtkWidget *widget, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){ scaledlg_apply( widget, scaleDialog ); gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); return TRUE; } -static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ +static gboolean scaledlg_delete( ui::Widget widget, GdkEventAny *event, ScaleDialog* scaleDialog ){ scaledlg_cancel( widget, scaleDialog ); return TRUE; } @@ -1064,8 +1064,8 @@ static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDia ScaleDialog g_scale_dialog; void DoScaleDlg(){ - if ( g_scale_dialog.window == NULL ) { - g_scale_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary scale", G_CALLBACK( scaledlg_delete ), &g_scale_dialog ); + if ( !g_scale_dialog.window ) { + g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog ); GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group( g_scale_dialog.window, accel ); @@ -1077,28 +1077,28 @@ void DoScaleDlg(){ GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); { - GtkWidget* label = gtk_label_new( " X " ); + ui::Widget label = ui::Label( " X " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 0, 1, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Y " ); + ui::Widget label = ui::Label( " Y " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 1, 2, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( " Z " ); + ui::Widget label = ui::Label( " Z " ); gtk_widget_show( label ); gtk_table_attach( table, label, 0, 1, 2, 3, (GtkAttachOptions) ( 0 ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Widget(gtk_entry_new()); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 0, 1, @@ -1108,7 +1108,7 @@ void DoScaleDlg(){ g_scale_dialog.x = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Widget(gtk_entry_new()); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 1, 2, @@ -1118,7 +1118,7 @@ void DoScaleDlg(){ g_scale_dialog.y = entry; } { - GtkWidget* entry = gtk_entry_new(); + ui::Widget entry = ui::Widget(gtk_entry_new()); gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" ); gtk_widget_show( entry ); gtk_table_attach( table, entry, 1, 2, 2, 3, diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index ddd0bfd5..dbd07612 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -89,18 +89,18 @@ namespace TexTool { //Shamus: Textool function prototypes -gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer ); -gboolean expose( GtkWidget *, GdkEventExpose *, gpointer ); -gboolean button_press( GtkWidget *, GdkEventButton *, gpointer ); -gboolean button_release( GtkWidget *, GdkEventButton *, gpointer ); -gboolean motion( GtkWidget *, GdkEventMotion *, gpointer ); +gboolean size_allocate( ui::Widget, GtkAllocation *, gpointer ); +gboolean expose( ui::Widget, GdkEventExpose *, gpointer ); +gboolean button_press( ui::Widget, GdkEventButton *, gpointer ); +gboolean button_release( ui::Widget, GdkEventButton *, gpointer ); +gboolean motion( ui::Widget, GdkEventMotion *, gpointer ); void flipX( GtkToggleButton *, gpointer ); void flipY( GtkToggleButton *, gpointer ); //End Textool function prototypes //Shamus: Textool globals -GtkWidget * g_textoolWin; +ui::Widget g_textoolWin; //End Textool globals void queueDraw(){ @@ -145,7 +145,7 @@ void SurfaceInspector_GridChange(); class SurfaceInspector : public Dialog { -GtkWindow* BuildDialog(); +ui::Window BuildDialog(); NonModalEntry m_textureEntry; NonModalSpinner m_hshiftSpinner; @@ -208,7 +208,7 @@ SurfaceInspector() : m_positionTracker.setPosition( c_default_window_pos ); } -void constructWindow( GtkWindow* main_window ){ +void constructWindow( ui::Window main_window ){ m_parent = main_window; Create(); AddGridChangeCallback( FreeCaller() ); @@ -217,7 +217,7 @@ void destroyWindow(){ Destroy(); } bool visible() const { - return GTK_WIDGET_VISIBLE( const_cast( GetWidget() ) ); + return GTK_WIDGET_VISIBLE( GetWidget() ); } void queueDraw(){ if ( visible() ) { @@ -245,7 +245,7 @@ inline SurfaceInspector& getSurfaceInspector(){ } } -void SurfaceInspector_constructWindow( GtkWindow* main_window ){ +void SurfaceInspector_constructWindow( ui::Window main_window ){ getSurfaceInspector().constructWindow( main_window ); } void SurfaceInspector_destroyWindow(){ @@ -400,7 +400,7 @@ void SurfaceInspector_GridChange(){ // we move the textures in pixels, not world units. (i.e. increment values are in pixel) // depending on the texture scale it doesn't take the same amount of pixels to move of GetGridSize() // increment * scale = gridsize -static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ +static void OnBtnMatchGrid( ui::Widget widget, gpointer data ){ float hscale, vscale; hscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); vscale = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); @@ -417,7 +417,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){ // or update it because something new has been selected // Shamus: It does get called when the SI is hidden, but not when you select something new. ;-) void DoSurface( void ){ - if ( getSurfaceInspector().GetWidget() == 0 ) { + if ( !getSurfaceInspector().GetWidget() ) { getSurfaceInspector().Create(); } @@ -441,23 +441,23 @@ void SurfaceInspector_FitTexture(){ Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical ); } -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){ Patch_CapTexture(); } -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){ Patch_NaturalTexture(); } -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){ Patch_ResetTexture(); } -static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){ +static void OnBtnPatchFit( ui::Widget widget, gpointer data ){ Patch_FitTexture(); } -static void OnBtnAxial( GtkWidget *widget, gpointer data ){ +static void OnBtnAxial( ui::Widget widget, gpointer data ){ //globalOutputStream() << "--> [OnBtnAxial]...\n"; UndoableCommand undo( "textureDefault" ); TextureProjection projection; @@ -486,7 +486,7 @@ static void OnBtnAxial( GtkWidget *widget, gpointer data ){ Select_SetTexdef( projection ); } -static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){ +static void OnBtnFaceFit( ui::Widget widget, gpointer data ){ getSurfaceInspector().exportData(); SurfaceInspector_FitTexture(); } @@ -587,8 +587,8 @@ guint togglebutton_connect_toggled( GtkToggleButton* button, const Callback& cal return g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); } -GtkWindow* SurfaceInspector::BuildDialog(){ - GtkWindow* window = create_floating_window( "Surface Inspector", m_parent ); +ui::Window SurfaceInspector::BuildDialog(){ + ui::Window window = ui::Window(create_floating_window( "Surface Inspector", m_parent )); m_positionTracker.connect( window ); @@ -599,18 +599,18 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { // replaced by only the vbox: - GtkWidget* vbox = gtk_vbox_new( FALSE, 5 ); + ui::Widget vbox = ui::Widget(gtk_vbox_new( FALSE, 5 )); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); { - GtkWidget* hbox2 = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox2 = ui::Widget(gtk_hbox_new( FALSE, 5 )); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 ); { - GtkWidget* label = gtk_label_new( "Texture" ); + ui::Widget label = ui::Label( "Texture" ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); } @@ -626,13 +626,13 @@ GtkWindow* SurfaceInspector::BuildDialog(){ { - GtkWidget* table = gtk_table_new( 6, 4, FALSE ); + ui::Widget table = ui::Widget(gtk_table_new( 6, 4, FALSE )); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Horizontal shift" ); + ui::Widget label = ui::Label( "Horizontal shift" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, @@ -650,7 +650,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, @@ -668,7 +668,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ m_hshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical shift" ); + ui::Widget label = ui::Label( "Vertical shift" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, @@ -686,7 +686,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, @@ -704,7 +704,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ m_vshiftEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Horizontal stretch" ); + ui::Widget label = ui::Label( "Horizontal stretch" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, @@ -722,7 +722,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, @@ -740,7 +740,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ m_hscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Vertical stretch" ); + ui::Widget label = ui::Label( "Vertical stretch" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, @@ -758,7 +758,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, @@ -776,7 +776,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ m_vscaleEntry.connect( entry ); } { - GtkWidget* label = gtk_label_new( "Rotate" ); + ui::Widget label = ui::Label( "Rotate" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, @@ -795,7 +795,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_spin_button_set_wrap( spin, TRUE ); } { - GtkWidget* label = gtk_label_new( "Step" ); + ui::Widget label = ui::Label( "Step" ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, @@ -814,7 +814,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } { // match grid button - GtkWidget* button = gtk_button_new_with_label( "Match Grid" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Match Grid" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -824,46 +824,46 @@ GtkWindow* SurfaceInspector::BuildDialog(){ } { - GtkWidget* frame = gtk_frame_new( "Texturing" ); + ui::Widget frame = ui::Widget(gtk_frame_new( "Texturing" )); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkWidget* table = gtk_table_new( 4, 4, FALSE ); + ui::Widget table = ui::Widget(gtk_table_new( 4, 4, FALSE )); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); { - GtkWidget* label = gtk_label_new( "Brush" ); + ui::Widget label = ui::Label( "Brush" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Patch" ); + ui::Widget label = ui::Label( "Patch" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Width" ); + ui::Widget label = ui::Label( "Width" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* label = gtk_label_new( "Height" ); + ui::Widget label = ui::Label( "Height" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkWidget* button = gtk_button_new_with_label( "Axial" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Axial" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -873,7 +873,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Fit" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -883,7 +883,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* button = gtk_button_new_with_label( "CAP" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "CAP" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -893,7 +893,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* button = gtk_button_new_with_label( "Set..." ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Set..." )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -903,7 +903,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* button = gtk_button_new_with_label( "Natural" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Natural" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -913,7 +913,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* button = gtk_button_new_with_label( "Fit" ); + ui::Widget button = ui::Widget(gtk_button_new_with_label( "Fit" )); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -923,7 +923,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ gtk_widget_set_usize( button, 60, -2 ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); + ui::Widget spin = ui::Widget(gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 )); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -932,7 +932,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal ); } { - GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 ); + ui::Widget spin = ui::Widget(gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 )); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -1041,7 +1041,7 @@ GtkWindow* SurfaceInspector::BuildDialog(){ #if TEXTOOL_ENABLED if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) { // Shamus: Textool goodies... - GtkWidget * frame = gtk_frame_new( "Textool" ); + ui::Widget frame = gtk_frame_new( "Textool" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { @@ -1063,12 +1063,12 @@ GtkWindow* SurfaceInspector::BuildDialog(){ g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL ); } { - GtkWidget * hbox = gtk_hbox_new( FALSE, 5 ); + ui::Widget hbox = gtk_hbox_new( FALSE, 5 ); gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 ); // Checkboxes go here... (Flip X/Y) - GtkWidget * flipX = gtk_check_button_new_with_label( "Flip X axis" ); - GtkWidget * flipY = gtk_check_button_new_with_label( "Flip Y axis" ); + ui::Widget flipX = gtk_check_button_new_with_label( "Flip X axis" ); + ui::Widget flipY = gtk_check_button_new_with_label( "Flip Y axis" ); gtk_widget_show( flipX ); gtk_widget_show( flipY ); gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 ); @@ -1877,14 +1877,14 @@ void focus(){ // << extents.maxX << ", " << extents.minY << ", " << extents.maxY << "\n"; } -gboolean size_allocate( GtkWidget * win, GtkAllocation * a, gpointer ){ +gboolean size_allocate( ui::Widget win, GtkAllocation * a, gpointer ){ windowSize.x() = a->width; windowSize.y() = a->height; queueDraw(); return false; } -gboolean expose( GtkWidget * win, GdkEventExpose * e, gpointer ){ +gboolean expose( ui::Widget win, GdkEventExpose * e, gpointer ){ // globalOutputStream() << "--> Textool Window was exposed!\n"; // globalOutputStream() << " (window width/height: " << cc << "/" << e->area.height << ")\n"; @@ -1983,7 +1983,7 @@ Vector2 trans; Vector2 trans2; Vector2 dragPoint; // Defined in terms of window space (+x/-y) Vector2 oldTrans; -gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_press( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button press...\n"; if ( e->button == 1 ) { @@ -2045,7 +2045,7 @@ gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){ return false; } -gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ +gboolean button_release( ui::Widget win, GdkEventButton * e, gpointer ){ // globalOutputStream() << "--> Textool button release...\n"; if ( e->button == 1 ) { @@ -2107,7 +2107,7 @@ gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){ c[1] = ((float)(y))/((float)(m_rect.bottom-m_rect.top))*(m_Maxs[1]-m_Mins[1])+m_Mins[1]; } */ -gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){ +gboolean motion( ui::Widget win, GdkEventMotion * e, gpointer ){ // globalOutputStream() << "--> Textool motion...\n"; if ( lButtonDown ) { diff --git a/radiant/surfacedialog.h b/radiant/surfacedialog.h index 0e0ed24a..2c1d945d 100644 --- a/radiant/surfacedialog.h +++ b/radiant/surfacedialog.h @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_SURFACEDIALOG_H ) #define INCLUDED_SURFACEDIALOG_H @@ -26,9 +28,7 @@ void SurfaceInspector_Construct(); void SurfaceInspector_Destroy(); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void SurfaceInspector_constructWindow( GtkWindow* widget ); +void SurfaceInspector_constructWindow( ui::Window widget ); void SurfaceInspector_destroyWindow(); bool SelectedFaces_empty(); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 436377f1..ae4b57af 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include "signal/signal.h" #include "math/vector.h" @@ -216,21 +217,21 @@ int m_nTotalHeight; std::string shader; -GtkWindow* m_parent; -GtkWidget* m_gl_widget; -GtkWidget* m_texture_scroll; -GtkWidget* m_treeViewTree; -GtkWidget* m_treeViewTags; -GtkWidget* m_tag_frame; +ui::Window m_parent; +ui::Widget m_gl_widget; +ui::Widget m_texture_scroll; +ui::Widget m_treeViewTree; +ui::Widget m_treeViewTags; +ui::Widget m_tag_frame; GtkListStore* m_assigned_store; GtkListStore* m_available_store; -GtkWidget* m_assigned_tree; -GtkWidget* m_available_tree; -GtkWidget* m_scr_win_tree; -GtkWidget* m_scr_win_tags; -GtkWidget* m_tag_notebook; -GtkWidget* m_search_button; -GtkWidget* m_shader_info_item; +ui::Widget m_assigned_tree; +ui::Widget m_available_tree; +ui::Widget m_scr_win_tree; +ui::Widget m_scr_win_tags; +ui::Widget m_tag_notebook; +ui::Widget m_search_button; +ui::Widget m_shader_info_item; std::set m_all_tags; GtkListStore* m_all_tags_list; @@ -684,7 +685,7 @@ void visit( const char* name ){ void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ); -GtkWidget* g_page_textures; +ui::Widget g_page_textures; void TextureBrowser_toggleShow(){ GroupDialog_showPage( g_page_textures ); @@ -1297,7 +1298,7 @@ void BuildStoreAvailableTags( GtkListStore* storeAvailable, } } -gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_PRESS ) { if ( event->button == 3 ) { if ( GlobalTextureBrowser().m_tags ) { @@ -1330,7 +1331,7 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, return FALSE; } -gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_button_release( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){ if ( event->type == GDK_BUTTON_RELEASE ) { if ( event->button == 3 ) { if ( !GlobalTextureBrowser().m_tags ) { @@ -1341,11 +1342,11 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event return FALSE; } -gboolean TextureBrowser_motion( GtkWidget *widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_motion( ui::Widget widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){ return FALSE; } -gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){ if ( event->direction == GDK_SCROLL_UP ) { TextureBrowser_MouseWheel( *textureBrowser, true ); } @@ -1383,7 +1384,7 @@ void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){ } } -gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){ textureBrowser->width = allocation->width; textureBrowser->height = allocation->height; TextureBrowser_heightChanged( *textureBrowser ); @@ -1392,7 +1393,7 @@ gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocat return FALSE; } -gboolean TextureBrowser_expose( GtkWidget* widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ +gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){ if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) { GlobalOpenGL_debugAssertNoErrors(); TextureBrowser_evaluateHeight( *textureBrowser ); @@ -1529,7 +1530,7 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV void TextureBrowser_createTreeViewTree(){ GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTree = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTree = ui::Widget(GTK_WIDGET( gtk_tree_view_new() )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE ); @@ -1545,18 +1546,18 @@ void TextureBrowser_addTag(); void TextureBrowser_renameTag(); void TextureBrowser_deleteTag(); -void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *event ){ - GtkWidget* menu = gtk_menu_new(); +void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){ + ui::Widget menu = ui::Widget(gtk_menu_new()); - GtkWidget* menuitem = gtk_menu_item_new_with_label( "Add tag" ); + ui::Widget menuitem = ui::Widget(gtk_menu_item_new_with_label( "Add tag" )); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Rename tag" ); + menuitem = ui::Widget(gtk_menu_item_new_with_label( "Rename tag" )); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); - menuitem = gtk_menu_item_new_with_label( "Delete tag" ); + menuitem = ui::Widget(gtk_menu_item_new_with_label( "Delete tag" )); g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview ); gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem ); @@ -1567,7 +1568,7 @@ void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *even gdk_event_get_time( (GdkEvent*)event ) ); } -gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *event ){ +gboolean TreeViewTags_onButtonPressed( ui::Widget treeview, GdkEventButton *event ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) { GtkTreePath *path; GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ) ); @@ -1586,7 +1587,7 @@ gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *even void TextureBrowser_createTreeViewTags(){ GtkCellRenderer* renderer; - g_TextureBrowser.m_treeViewTags = GTK_WIDGET( gtk_tree_view_new() ); + g_TextureBrowser.m_treeViewTags = ui::Widget(GTK_WIDGET( gtk_tree_view_new() )); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE ); g_signal_connect( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL ); @@ -1599,8 +1600,8 @@ void TextureBrowser_createTreeViewTags(){ TextureBrowser_constructTreeStoreTags(); } -GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_View" ); +ui::MenuItem TextureBrowser_constructViewMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1636,7 +1637,7 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) { menu_separator( menu ); - g_TextureBrowser.m_shader_info_item = GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) ); + g_TextureBrowser.m_shader_info_item = ui::Widget(GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) )); gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE ); } @@ -1644,8 +1645,8 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" ); +ui::MenuItem TextureBrowser_constructToolsMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1657,8 +1658,8 @@ GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ return textures_menu_item; } -GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* menu ){ - GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "T_ags" ); +ui::MenuItem TextureBrowser_constructTagsMenu( GtkMenu* menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1865,9 +1866,9 @@ void TextureBrowser_toggleSearchButton(){ } void TextureBrowser_constructTagNotebook(){ - g_TextureBrowser.m_tag_notebook = gtk_notebook_new(); - GtkWidget* labelTags = gtk_label_new( "Tags" ); - GtkWidget* labelTextures = gtk_label_new( "Textures" ); + g_TextureBrowser.m_tag_notebook = ui::Widget(gtk_notebook_new()); + ui::Widget labelTags = ui::Label( "Tags" ); + ui::Widget labelTextures = ui::Label( "Textures" ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tree, labelTextures ); gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tags, labelTags ); @@ -1880,8 +1881,8 @@ void TextureBrowser_constructTagNotebook(){ void TextureBrowser_constructSearchButton(){ GtkTooltips* tooltips = gtk_tooltips_new(); - GtkWidget* image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ); - g_TextureBrowser.m_search_button = gtk_button_new(); + ui::Widget image = ui::Widget(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR )); + g_TextureBrowser.m_search_button = ui::Widget(gtk_button_new()); g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), g_TextureBrowser.m_search_button, "Search with selected tags", "Search with selected tags" ); gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image ); @@ -1935,7 +1936,7 @@ void TextureBrowser_SetNotex(){ g_shadernotex = name.c_str(); } -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ // The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider // position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't // seem to work in gtk 2.4 and the arrow buttons don't handle GTK_FILL, so here's another thing @@ -1948,23 +1949,23 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ g_TextureBrowser.m_parent = toplevel; - GtkWidget* table = gtk_table_new( 3, 3, FALSE ); - GtkWidget* frame_table = NULL; - GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); + ui::Widget table = ui::Widget(gtk_table_new( 3, 3, FALSE )); + ui::Widget frame_table; + ui::Widget vbox = ui::Widget(gtk_vbox_new( FALSE, 0 )); gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); gtk_widget_show( vbox ); - GtkWidget* menu_bar; + ui::Widget menu_bar; { // menu bar - menu_bar = gtk_menu_bar_new(); - GtkWidget* menu_view = gtk_menu_new(); - GtkWidget* view_item = (GtkWidget*)TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); + menu_bar = ui::Widget(gtk_menu_bar_new()); + ui::Widget menu_view = ui::Widget(gtk_menu_new()); + auto view_item = TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); - GtkWidget* menu_tools = gtk_menu_new(); - GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); + ui::Widget menu_tools = ui::Widget(gtk_menu_new()); + auto tools_item = TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item ); @@ -1972,7 +1973,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_widget_show( menu_bar ); } { // Texture TreeView - g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tree = ui::Widget(gtk_scrolled_window_new( NULL, NULL )); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 ); // vertical only scrolling for treeview @@ -1986,7 +1987,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); } { // gl_widget scrollbar - GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) ); + ui::Widget w = ui::Widget(gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) )); gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 ); gtk_widget_show( w ); g_TextureBrowser.m_texture_scroll = w; @@ -1997,7 +1998,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar ); } { // gl_widget - g_TextureBrowser.m_gl_widget = glwidget_new( FALSE ); + g_TextureBrowser.m_gl_widget = ui::Widget(glwidget_new( FALSE )); gtk_widget_ref( g_TextureBrowser.m_gl_widget ); gtk_widget_set_events( g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK ); @@ -2026,13 +2027,13 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ TextureBrowser_buildTagList(); } { // tag menu bar - GtkWidget* menu_tags = gtk_menu_new(); - GtkWidget* tags_item = (GtkWidget*)TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); + ui::Widget menu_tags = ui::Widget(gtk_menu_new()); + auto tags_item = TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item ); } { // Tag TreeView - g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tags = ui::Widget(gtk_scrolled_window_new( NULL, NULL )); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 ); // vertical only scrolling for treeview @@ -2055,9 +2056,9 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_box_pack_end( GTK_BOX( vbox ), g_TextureBrowser.m_search_button, FALSE, FALSE, 0 ); } { // Tag frame - frame_table = gtk_table_new( 3, 3, FALSE ); + frame_table = ui::Widget(gtk_table_new( 3, 3, FALSE )); - g_TextureBrowser.m_tag_frame = gtk_frame_new( "Tag assignment" ); + g_TextureBrowser.m_tag_frame = ui::Widget(gtk_frame_new( "Tag assignment" )); gtk_frame_set_label_align( GTK_FRAME( g_TextureBrowser.m_tag_frame ), 0.5, 0.5 ); gtk_frame_set_shadow_type( GTK_FRAME( g_TextureBrowser.m_tag_frame ), GTK_SHADOW_NONE ); @@ -2068,7 +2069,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table ); } { // assigned tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::Widget(gtk_scrolled_window_new( NULL, NULL )); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -2079,7 +2080,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ); + g_TextureBrowser.m_assigned_tree = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) )); g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) ); g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE ); @@ -2097,7 +2098,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // available tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::Widget(gtk_scrolled_window_new( NULL, NULL )); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -2107,7 +2108,7 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ); + g_TextureBrowser.m_available_tree = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) )); g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) ); g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE ); @@ -2125,10 +2126,10 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // tag arrow buttons - GtkWidget* m_btn_left = gtk_button_new(); - GtkWidget* m_btn_right = gtk_button_new(); - GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ); - GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ); + ui::Widget m_btn_left = ui::Widget(gtk_button_new()); + ui::Widget m_btn_right = ui::Widget(gtk_button_new()); + ui::Widget m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + ui::Widget m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left ); gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right ); @@ -2148,8 +2149,8 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ gtk_widget_show( m_arrow_right ); } { // tag fram labels - GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" ); - GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" ); + ui::Widget m_lbl_assigned = ui::Label( "Assigned" ); + ui::Widget m_lbl_unassigned = ui::Label( "Available" ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); @@ -2268,7 +2269,7 @@ void TextureBrowser_renameTag(){ } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for renaming." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for renaming." ); } } @@ -2279,9 +2280,9 @@ void TextureBrowser_deleteTag(){ gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected ); if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Are you sure you want to delete the selected tag?", "Delete Tag", eMB_YESNO, eMB_ICONQUESTION ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::QUESTION ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { GtkTreeIter iterSelected; gchar *rowTag; @@ -2308,7 +2309,7 @@ void TextureBrowser_deleteTag(){ } } else { - gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for deletion." ); + ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "Select a single tag for deletion." ); } } @@ -2360,7 +2361,7 @@ void RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); UpdateAllWindows(); - GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree); + GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*) GlobalTextureBrowser().m_treeViewTree.handle()); GtkTreeModel* model = NULL; GtkTreeIter iter; if ( gtk_tree_selection_get_selected (selection, &model, &iter) ) @@ -2400,9 +2401,9 @@ void TextureBrowser_showAll(){ } void TextureBrowser_showUntagged(){ - EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", eMB_YESNO, eMB_ICONWARNING ); + auto result = ui::Widget(GTK_WIDGET( g_TextureBrowser.m_parent )).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::WARNING ); - if ( result == eIDYES ) { + if ( result == ui::alert_response::YES ) { g_TextureBrowser.m_found_shaders.clear(); TagBuilder.GetUntagged( g_TextureBrowser.m_found_shaders ); std::set::iterator iter; diff --git a/radiant/texwindow.h b/radiant/texwindow.h index 3a872014..3910bb95 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -22,18 +22,16 @@ #if !defined( INCLUDED_TEXWINDOW_H ) #define INCLUDED_TEXWINDOW_H +#include #include "math/vector.h" #include "generic/callbackfwd.h" #include "signal/signalfwd.h" #include "xml/xmltextags.h" -typedef struct _GtkWidget GtkWidget; - class TextureBrowser; TextureBrowser& GlobalTextureBrowser(); -typedef struct _GtkWindow GtkWindow; -GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ); +ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ); void TextureBrowser_destroyWindow(); @@ -49,7 +47,7 @@ typedef Callback1 StringImportCallback; template class FreeCaller1; -extern GtkWidget* g_page_textures; +extern ui::Widget g_page_textures; void TextureBrowser_exportTitle( const StringImportCallback& importer ); typedef FreeCaller1 TextureBrowserExportTitleCaller; diff --git a/radiant/url.cpp b/radiant/url.cpp index e5ed0bc5..1885f44b 100644 --- a/radiant/url.cpp +++ b/radiant/url.cpp @@ -34,6 +34,8 @@ bool open_url( const char* url ){ #if defined( __linux__ ) || defined( __FreeBSD__ ) #include +#include + bool open_url( const char* url ){ // \todo FIXME: the way we open URLs on *nix should be improved. A script is good (see how I do on RTCW) char command[2 * PATH_MAX]; @@ -56,6 +58,6 @@ void OpenURL( const char *url ){ // let's put a little comment globalOutputStream() << "OpenURL: " << url << "\n"; if ( !open_url( url ) ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Failed to launch browser!" ); + MainFrame_getWindow().alert( "Failed to launch browser!" ); } } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index bcfc59aa..7ca79313 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -77,6 +77,7 @@ void message_print( message_info_t* self, const char* characters, std::size_t le #include +#include #include "xmlstuff.h" class CWatchBSP @@ -176,10 +177,10 @@ int g_WatchBSP_Timeout = 10; void Build_constructPreferences( PreferencesPage& page ){ - GtkWidget* monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); - GtkWidget* leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); - GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); - GtkWidget* sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); + ui::CheckButton monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled ); + ui::CheckButton leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop ); + ui::CheckButton runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake ); + ui::CheckButton sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep ); Widget_connectToggleDependency( leakstop, monitorbsp ); Widget_connectToggleDependency( runengine, monitorbsp ); Widget_connectToggleDependency( sleep, runengine ); @@ -519,7 +520,7 @@ void CWatchBSP::DoEBeginStep(){ if ( SetupListening() == false ) { const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n"; globalOutputStream() << msg; - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg, "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::ERROR ); return; } // set the timer for timeouts and step cancellation @@ -536,7 +537,7 @@ void CWatchBSP::DoEBeginStep(){ msg << reinterpret_cast( g_ptr_array_index( m_pCmd, m_iCurrentStep ) ); msg << "\nCheck that the file exists and that you don't run out of system resources.\n"; globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::ERROR ); return; } // re-initialise the debug window @@ -616,7 +617,7 @@ void CWatchBSP::RoutineProcessing(){ case EBeginStep: // timeout: if we don't get an incoming connection fast enough, go back to idle if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) { - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", eMB_OK ); + MainFrame_getWindow().alert( "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK ); EndMonitoringLoop(); #if 0 if ( m_bBSPPlugin ) { @@ -749,7 +750,7 @@ void CWatchBSP::RoutineProcessing(){ StringOutputStream msg; msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str(); globalOutputStream() << msg.c_str(); - gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR ); + MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::ERROR ); } } EndMonitoringLoop(); @@ -777,8 +778,8 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){ if ( m_eState != EIdle ) { globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n"; // prompt the user, should we cancel the current process and go ahead? - if ( gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", - "Build process monitoring", eMB_YESNO ) == eIDYES ) { + if ( MainFrame_getWindow().alert( "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?", + "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) { // disconnect and set EIdle state Reset(); } diff --git a/radiant/windowobservers.cpp b/radiant/windowobservers.cpp index 989c1196..24857c4d 100644 --- a/radiant/windowobservers.cpp +++ b/radiant/windowobservers.cpp @@ -50,7 +50,7 @@ inline void WindowObservers_OnModifierUp( WindowObservers& observers, ModifierFl #include -gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_press( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { case GDK_Alt_L: @@ -72,7 +72,7 @@ gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, Wi return FALSE; } -gboolean selection_modifier_key_release( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){ +gboolean selection_modifier_key_release( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){ switch ( event->keyval ) { case GDK_Alt_L: @@ -109,21 +109,21 @@ void WindowObservers_UpdateModifiers( WindowObservers& observers, ModifierFlags WindowObservers_UpdateModifier( observers, modifiers, c_modifierControl ); } -gboolean modifiers_button_press( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_press( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_PRESS ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_button_release( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){ +gboolean modifiers_button_release( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){ if ( event->type == GDK_BUTTON_RELEASE ) { WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); } return FALSE; } -gboolean modifiers_motion( GtkWidget *widget, GdkEventMotion *event, WindowObservers* observers ){ +gboolean modifiers_motion( ui::Widget widget, GdkEventMotion *event, WindowObservers* observers ){ WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) ); return FALSE; } @@ -139,12 +139,12 @@ void GlobalWindowObservers_add( WindowObserver* observer ){ g_window_observers.push_back( observer ); } -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ){ +void GlobalWindowObservers_connectTopLevel( ui::Window window ){ g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers ); g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers ); } -void GlobalWindowObservers_connectWidget( GtkWidget* widget ){ +void GlobalWindowObservers_connectWidget( ui::Widget widget ){ g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers ); g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers ); g_signal_connect( G_OBJECT( widget ), "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers ); diff --git a/radiant/windowobservers.h b/radiant/windowobservers.h index eab5fe59..fbe620c8 100644 --- a/radiant/windowobservers.h +++ b/radiant/windowobservers.h @@ -25,15 +25,14 @@ #include "windowobserver.h" #include +#include #include "math/vector.h" class WindowObserver; void GlobalWindowObservers_add( WindowObserver* observer ); -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; -void GlobalWindowObservers_connectWidget( GtkWidget* widget ); -void GlobalWindowObservers_connectTopLevel( GtkWindow* window ); +void GlobalWindowObservers_connectWidget( ui::Widget widget ); +void GlobalWindowObservers_connectTopLevel( ui::Window window ); inline ButtonIdentifier button_for_button( unsigned int button ){ switch ( button ) diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index b76e9178..686b9bfc 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -41,6 +41,7 @@ #include #include +#include #include "generic/callback.h" #include "string/string.h" @@ -549,7 +550,7 @@ void WXY_Print(){ unsigned char* img; const char* filename; - filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); + filename = ui::file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP ); if ( !filename ) { return; } @@ -711,7 +712,7 @@ void xy_update_xor_rectangle( XYWnd& self, rect_t area ){ } } -gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_press( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_PRESS ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -722,7 +723,7 @@ gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xy return FALSE; } -gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){ +gboolean xywnd_button_release( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){ if ( event->type == GDK_BUTTON_RELEASE ) { xywnd->XY_MouseUp( static_cast( event->x ), static_cast( event->y ), buttons_for_event_button( event ) ); @@ -731,7 +732,7 @@ gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* return FALSE; } -gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean xywnd_focus_in( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ if ( event->type == GDK_FOCUS_CHANGE ) { if ( event->in ) { g_pParentWnd->SetActiveXY( xywnd ); @@ -747,7 +748,7 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){ reinterpret_cast( data )->XY_MouseMoved( static_cast( x ), static_cast( y ), buttons_for_state( state ) ); } -gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){ +gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){ if ( event->direction == GDK_SCROLL_UP ) { XYWnd_ZoomIn( xywnd ); } @@ -757,7 +758,7 @@ gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xy return FALSE; } -gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){ +gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWnd* xywnd ){ xywnd->m_nWidth = allocation->width; xywnd->m_nHeight = allocation->height; xywnd->updateProjection(); @@ -765,7 +766,7 @@ gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWn return FALSE; } -gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){ +gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){ if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) { if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { GlobalOpenGL_debugAssertNoErrors(); @@ -945,12 +946,12 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) { GdkCursor *cursor; cursor = gdk_cursor_new( GDK_CROSSHAIR ); - gdk_window_set_cursor( m_gl_widget->window, cursor ); + gdk_window_set_cursor( m_gl_widget.handle()->window, cursor ); gdk_cursor_unref( cursor ); } else { - gdk_window_set_cursor( m_gl_widget->window, 0 ); + gdk_window_set_cursor( m_gl_widget.handle()->window, 0 ); } } @@ -1059,7 +1060,7 @@ void XYWnd::NewBrushDrag( int x, int y ){ "textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) ); } -void entitycreate_activated( GtkWidget* item ){ +void entitycreate_activated( ui::Widget item ){ scene::Node* world_node = Map_FindWorldspawn( g_map ); const char* entity_name = gtk_label_get_text( GTK_LABEL( GTK_BIN( item )->child ) ); @@ -1067,7 +1068,7 @@ void entitycreate_activated( GtkWidget* item ){ g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name ); } else { - GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( MainFrame_getWindow() ), "There's already a worldspawn in your map!" + GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!" "", "Info", eMB_OK, @@ -1173,7 +1174,7 @@ void XYWnd_moveDelta( int x, int y, unsigned int state, void* data ){ reinterpret_cast( data )->Scroll( -x, y ); } -gboolean XYWnd_Move_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Move_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Move_End(); return FALSE; } @@ -1183,13 +1184,13 @@ void XYWnd::Move_Begin(){ Move_End(); } m_move_started = true; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this ); m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); } void XYWnd::Move_End(){ m_move_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut ); } @@ -1218,7 +1219,7 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){ } } -gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){ +gboolean XYWnd_Zoom_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){ xywnd->Zoom_End(); return FALSE; } @@ -1229,13 +1230,13 @@ void XYWnd::Zoom_Begin(){ } m_zoom_started = true; g_dragZoom = 0; - g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); } void XYWnd::Zoom_End(){ m_zoom_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() ); + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut ); } @@ -1256,7 +1257,7 @@ void XYWnd::SetViewType( VIEWTYPE viewType ){ m_viewType = viewType; updateModelview(); - if ( m_parent != 0 ) { + if ( m_parent ) { gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) ); } } @@ -1486,12 +1487,12 @@ void XYWnd::XY_DisableBackground( void ){ void WXY_BackgroundSelect( void ){ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0; if ( !brushesSelected ) { - gtk_MessageBox( 0, "You have to select some brushes to get the bounding box for.\n", - "No selection", eMB_OK, eMB_ICONERROR ); + ui::root.alert( "You have to select some brushes to get the bounding box for.\n", + "No selection", ui::alert_type::OK, ui::alert_icon::ERROR ); return; } - const char *filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, "Background Image", NULL, NULL ); + const char *filename = MainFrame_getWindow().file_dialog( TRUE, "Background Image", NULL, NULL ); g_pParentWnd->ActiveXY()->XY_DisableBackground(); if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); @@ -2538,19 +2539,19 @@ void ToggleShowGrid(){ ToggleShown g_xy_top_shown( true ); -void XY_Top_Shown_Construct( GtkWindow* parent ){ +void XY_Top_Shown_Construct( ui::Window parent ){ g_xy_top_shown.connect( GTK_WIDGET( parent ) ); } ToggleShown g_yz_side_shown( false ); -void YZ_Side_Shown_Construct( GtkWindow* parent ){ +void YZ_Side_Shown_Construct( ui::Window parent ){ g_yz_side_shown.connect( GTK_WIDGET( parent ) ); } ToggleShown g_xz_front_shown( false ); -void XZ_Front_Shown_Construct( GtkWindow* parent ){ +void XZ_Front_Shown_Construct( ui::Window parent ){ g_xz_front_shown.connect( GTK_WIDGET( parent ) ); } diff --git a/radiant/xywindow.h b/radiant/xywindow.h index cbf37b43..66709784 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -40,7 +40,6 @@ namespace scene { class Node; } -typedef struct _GtkWindow GtkWindow; typedef struct _GtkMenu GtkMenu; @@ -65,21 +64,21 @@ inline const char* ViewType_getTitle( VIEWTYPE viewtype ){ class XYWnd { -GtkWidget* m_gl_widget; +ui::Widget m_gl_widget; guint m_sizeHandler; guint m_exposeHandler; DeferredDraw m_deferredDraw; DeferredMotion m_deferred_motion; public: -GtkWindow* m_parent; +ui::Window m_parent; XYWnd(); ~XYWnd(); void queueDraw(){ m_deferredDraw.draw(); } -GtkWidget* GetWidget(){ +ui::Widget GetWidget(){ return m_gl_widget; } @@ -281,10 +280,9 @@ extern xywindow_globals_t g_xywindow_globals; VIEWTYPE GlobalXYWnd_getCurrentViewType(); -typedef struct _GtkWindow GtkWindow; -void XY_Top_Shown_Construct( GtkWindow* parent ); -void YZ_Side_Shown_Construct( GtkWindow* parent ); -void XZ_Front_Shown_Construct( GtkWindow* parent ); +void XY_Top_Shown_Construct( ui::Window parent ); +void YZ_Side_Shown_Construct( ui::Window parent ); +void XZ_Front_Shown_Construct( ui::Window parent ); void XYWindow_Construct(); void XYWindow_Destroy();