From 320e3b088c438c6d5b187da0a3fe503f5e28ca92 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 17 Feb 2016 13:14:37 +1100 Subject: [PATCH] Wrap GtkAlignment --- libs/gtkutil/dialog.cpp | 2 +- libs/gtkutil/messagebox.cpp | 4 ++-- libs/uilib/uilib.cpp | 4 ++++ libs/uilib/uilib.h | 17 ++++++++++------- radiant/dialog.cpp | 10 +++++----- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index cb174ca7..852d06e2 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -174,7 +174,7 @@ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& di gtk_container_add( GTK_CONTAINER( vbox1 ), contents ); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + ui::Alignment alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vbox1 ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 2dfc03de..b3d17a24 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -36,7 +36,7 @@ #include "widget.h" GtkWidget* create_padding( int width, int height ){ - GtkWidget* widget = gtk_alignment_new( 0.0, 0.0, 0.0, 0.0 ); + ui::Alignment widget = ui::Alignment( 0.0, 0.0, 0.0, 0.0 ); gtk_widget_show( widget ); gtk_widget_set_size_request( widget, width, height ); return widget; @@ -105,7 +105,7 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha GtkVBox* vboxDummy = create_dialog_vbox( 0, 0 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( vboxDummy ), FALSE, FALSE, 0 ); - GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) ); + GtkAlignment* alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vboxDummy ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 16f90e65..0ab8e955 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -84,6 +84,10 @@ namespace ui { return g_signal_connect(G_OBJECT(*this), "key-press-event", (GCallback) +func, &pass); } + Alignment::Alignment(float xalign, float yalign, float xscale, float yscale) + : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale))) + { } + Button::Button(const char *label) : Button(GTK_BUTTON(gtk_button_new_with_label(label))) { } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 64a1c690..17a76410 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -3,16 +3,15 @@ #include -using ui_typeinst = struct _GTypeInstance; -using ui_widget = struct _GtkWidget; -using ui_window = struct _GtkWindow; +using ui_alignment = struct _GtkAlignment; using ui_button = struct _GtkButton; -using ui_menuitem = struct _GtkMenuItem; -using ui_label = struct _GtkLabel; - using ui_evkey = struct _GdkEventKey; - +using ui_label = struct _GtkLabel; +using ui_menuitem = struct _GtkMenuItem; using ui_modal = struct ModalDialog; +using ui_typeinst = struct _GTypeInstance; +using ui_widget = struct _GtkWidget; +using ui_window = struct _GtkWindow; namespace ui { @@ -124,6 +123,10 @@ namespace ui { Label(const char *label); ); + WIDGET(Alignment, ui_alignment, + Alignment(float xalign, float yalign, float xscale, float yscale); + ); + } #endif diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index b2a9e768..4d7d096c 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -75,7 +75,7 @@ GtkEntry* m_entry; }; DialogEntryRow DialogEntryRow_new( const char* name ){ - ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); GtkEntry* entry = DialogEntry_new(); @@ -108,7 +108,7 @@ GtkSpinButton* m_spin; }; DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){ - ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 )); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction ); @@ -478,7 +478,7 @@ ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const ch } 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 )); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); { ui::Widget combo = ui::Widget(gtk_combo_box_new_text()); @@ -526,7 +526,7 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) ); // scale - ui::Widget alignment = ui::Widget(gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 )); + 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 ) )); @@ -542,7 +542,7 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d } 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 )); + ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); gtk_widget_show( alignment ); { RadioHBox radioBox = RadioHBox_new( names ); -- 2.39.2