From 0584b7c0910f4a22b2b7e4339fc371563b0ea5f4 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 17 Feb 2016 18:46:54 +1100 Subject: [PATCH] Wrap GtkHScale --- contrib/bkgrnd2d/dialog.cpp | 2 +- contrib/camera/dialogs.cpp | 2 +- contrib/gtkgensurf/gendlgs.cpp | 4 ++-- contrib/prtview/ConfigDialog.cpp | 8 ++++---- libs/uilib/uilib.cpp | 6 ++++++ libs/uilib/uilib.h | 6 ++++++ radiant/dialog.cpp | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index 35dd5ff5..0764daca 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -245,7 +245,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); gtk_widget_show( w ); - w = gtk_hscale_new_with_range( 0.0,1.0,0.01 ); + w = ui::HScale( 0.0, 1.0, 0.01 ); gtk_range_set_value( GTK_RANGE( w ),0.5 ); gtk_scale_set_value_pos( GTK_SCALE( w ),GTK_POS_LEFT ); g_signal_connect( G_OBJECT( w ), "value-changed", diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index 0100f9b2..6d1c30cf 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -1221,7 +1221,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){ g_pTimeLine = ui::Adjustment( 0, 0, 30000, 100, 250, 0 ); gtk_signal_connect( GTK_OBJECT( g_pTimeLine ), "value_changed", GTK_SIGNAL_FUNC( ci_timeline_changed ), NULL ); - w = gtk_hscale_new( g_pTimeLine ); + w = ui::HScale( g_pTimeLine ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); gtk_scale_set_draw_value( GTK_SCALE( w ), FALSE ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index 089054c6..f817f925 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -1346,7 +1346,7 @@ void create_tooltips(){ GtkWidget* create_main_dialog(){ GtkWidget *dlg, *vbox, *hbox, *hbox2, *button, *notebook, *frame, *table, *table2; GtkWidget *check, *spin, *radio, *label, *entry, *scale; - GtkObject *adj; + ui::Adjustment adj; GSList *group; int i; const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" }; @@ -1700,7 +1700,7 @@ GtkWidget* create_main_dialog(){ adj = ui::Adjustment( 0, 0, 110, 1, 10, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_decimate ), NULL ); g_object_set_data( G_OBJECT( dlg ), "decimate_adj", adj ); - scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + scale = ui::HScale( adj ); gtk_widget_show( scale ); gtk_box_pack_start( GTK_BOX( hbox2 ), scale, TRUE, TRUE, 0 ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_RIGHT ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 26cc21df..aa2f7bb6 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -274,7 +274,7 @@ void DoConfigDialog(){ gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, TRUE, 0 ); auto adj = ui::Adjustment( portals.width_3d, 2, 40, 1, 1, 0 ); - lw3slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + lw3slider = ui::HScale( adj ); gtk_widget_show( lw3slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw3slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw3slider ), FALSE ); @@ -365,7 +365,7 @@ void DoConfigDialog(){ gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); adj = ui::Adjustment( portals.trans_3d, 0, 100, 1, 1, 0 ); - transslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + transslider = ui::HScale( adj ); gtk_widget_show( transslider ); gtk_table_attach( GTK_TABLE( table ), transslider, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -381,7 +381,7 @@ void DoConfigDialog(){ gtk_signal_connect( GTK_OBJECT(adj), "value_changed", GTK_SIGNAL_FUNC( OnScrollTrans ), translabel ); adj = ui::Adjustment( portals.clip_range, 1, 128, 1, 1, 0 ); - clipslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + clipslider = ui::HScale( adj ); gtk_widget_show( clipslider ); gtk_table_attach( GTK_TABLE( table ), clipslider, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), @@ -424,7 +424,7 @@ void DoConfigDialog(){ gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 ); adj = ui::Adjustment( portals.width_2d, 2, 40, 1, 1, 0 ); - lw2slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) ); + lw2slider = ui::HScale( adj ); gtk_widget_show( lw2slider ); gtk_box_pack_start( GTK_BOX( hbox ), lw2slider, TRUE, TRUE, 0 ); gtk_scale_set_draw_value( GTK_SCALE( lw2slider ), FALSE ); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 3b169faf..b25bfee2 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -137,6 +137,12 @@ namespace ui { HBox::HBox(bool homogenous, int spacing) : HBox(GTK_HBOX(gtk_hbox_new(homogenous, spacing))) { } + HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment))) + { } + + HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step))) + { } + Image::Image() : Image(GTK_IMAGE(gtk_image_new())) { } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 3afaa0cb..a5164b02 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -16,6 +16,7 @@ using ui_entry = struct _GtkEntry; using ui_evkey = struct _GdkEventKey; using ui_frame = struct _GtkFrame; using ui_hbox = struct _GtkHBox; +using ui_hscale = struct _GtkHScale; using ui_hpaned = struct _GtkHPaned; using ui_image = struct _GtkImage; using ui_label = struct _GtkLabel; @@ -183,6 +184,11 @@ namespace ui { HBox(bool homogenous, int spacing); ); + WRAP(HScale, Widget, ui_hscale, + HScale(Adjustment adjustment); + HScale(double min, double max, double step); + ); + WRAP(Image, Widget, ui_image, Image(); ); diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 7ccb087c..3c4f98fe 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -529,7 +529,7 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d ui::Widget alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 ); gtk_widget_show( alignment ); - ui::Widget scale = ui::Widget(gtk_hscale_new( GTK_ADJUSTMENT( adj ) )); + ui::Widget scale = ui::HScale( adj ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT ); gtk_widget_show( scale ); gtk_container_add( GTK_CONTAINER( alignment ), scale ); -- 2.39.2