#include "button.h"
#include "window.h"
-GtkVBox* create_dialog_vbox( int spacing, int border ){
- GtkVBox* vbox = ui::VBox( FALSE, spacing );
- gtk_widget_show( GTK_WIDGET( vbox ) );
+ui::VBox create_dialog_vbox( int spacing, int border ){
+ auto vbox = ui::VBox( FALSE, spacing );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), border );
return vbox;
}
-GtkHBox* create_dialog_hbox( int spacing, int border ){
- GtkHBox* hbox = ui::HBox( FALSE, spacing );
- gtk_widget_show( GTK_WIDGET( hbox ) );
+ui::HBox create_dialog_hbox( int spacing, int border ){
+ auto hbox = ui::HBox( FALSE, spacing );
+ hbox.show();
gtk_container_set_border_width( GTK_CONTAINER( hbox ), border );
return hbox;
}
-GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow ){
- GtkFrame* frame = ui::Frame( label );
- gtk_widget_show( GTK_WIDGET( frame ) );
+ui::Frame create_dialog_frame( const char* label, GtkShadowType shadow ){
+ auto frame = ui::Frame( label );
+ frame.show();
gtk_frame_set_shadow_type( frame, shadow );
return frame;
}
-GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){
- GtkTable* table = ui::Table( rows, columns, FALSE );
- gtk_widget_show( GTK_WIDGET( table ) );
+ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){
+ auto table = ui::Table( rows, columns, FALSE );
+ table.show();
gtk_table_set_row_spacings( table, row_spacing );
gtk_table_set_col_spacings( table, col_spacing );
gtk_container_set_border_width( GTK_CONTAINER( table ), border );
return table;
}
-GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ){
- GtkButton* button = ui::Button( label );
+ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ){
+ auto button = ui::Button( label );
gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ button.show();
g_signal_connect( G_OBJECT( button ), "clicked", func, data );
return button;
}
return window;
}
-gboolean modal_dialog_button_clicked( GtkWidget *widget, ModalDialogButton* button ){
+gboolean modal_dialog_button_clicked( ui::Widget widget, ModalDialogButton* button ){
button->m_dialog.loop = false;
button->m_dialog.ret = button->m_value;
return TRUE;
}
-gboolean modal_dialog_delete( GtkWidget *widget, GdkEvent* event, ModalDialog* dialog ){
+gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* dialog ){
dialog->loop = 0;
dialog->ret = eIDCANCEL;
return TRUE;
return dialog.ret;
}
-GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ){
+ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ){
return create_dialog_button( label, G_CALLBACK( modal_dialog_button_clicked ), &button );
}
}
ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width, int height ){
- ui::Window window = create_modal_dialog_window( parent, title, dialog, width, height );
+ auto window = create_modal_dialog_window( parent, title, dialog, width, height );
gtk_window_set_resizable( window, FALSE );
gtk_window_set_modal( window, TRUE );
return window;
}
-gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDOK;
return TRUE;
}
-gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDCANCEL;
return TRUE;
}
-gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDYES;
return TRUE;
}
-gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDNO;
return TRUE;
}
-gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ){
+gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ){
gtk_widget_hide( widget );
data->loop = false;
return TRUE;
}
-ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){
+ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ){
ui::Window window = create_fixedsize_modal_dialog_window(ui::Window(), title, dialog );
GtkVBox* vbox1 = create_dialog_vbox( 8, 4 );
}
typedef ReferenceCaller1<PathEntry, const char*, PathEntry_setPath> PathEntrySetPathCaller;
-void BrowsedPathEntry_clicked( GtkWidget* widget, BrowsedPathEntry* self ){
+void BrowsedPathEntry_clicked( ui::Widget widget, BrowsedPathEntry* self ){
self->m_browse( PathEntrySetPathCaller( self->m_entry ) );
}
}
-GtkLabel* DialogLabel_new( const char* name ){
- ui::Label label = ui::Label( name );
+ui::Label DialogLabel_new( const char* name ){
+ auto 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 );
return label;
}
-GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){
- GtkTable* table = ui::Table( 1, 3, TRUE );
+ui::Table DialogRow_new( const char* name, ui::Widget widget ){
+ auto table = ui::Table( 1, 3, TRUE );
gtk_widget_show( GTK_WIDGET( table ) );
gtk_table_set_col_spacings( table, 4 );
return table;
}
-void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ){
+void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){
gtk_box_pack_start( GTK_BOX( vbox ), row, FALSE, FALSE, 0 );
}
ui::Window create_fixedsize_modal_window( ui::Window parent, const char* title, int width, int height );
ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 );
-GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
-GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data );
-GtkVBox* create_dialog_vbox( int spacing, int border = 0 );
-GtkHBox* create_dialog_hbox( int spacing, int border = 0 );
-GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN );
+ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
+ui::Button create_dialog_button( const char* label, GCallback func, gpointer data );
+ui::VBox create_dialog_vbox( int spacing, int border = 0 );
+ui::HBox create_dialog_hbox( int spacing, int border = 0 );
+ui::Frame create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN );
-GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button );
+ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button );
ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 );
ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 );
EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog );
-gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data );
+gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_no( ui::Widget widget, ModalDialog* data );
+gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data );
-ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents );
+ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents );
class RadioHBox
{
BrowsedPathEntry( const BrowseCallback& browse );
};
-GtkLabel* DialogLabel_new( const char* name );
-GtkTable* DialogRow_new( const char* name, GtkWidget* widget );
-typedef struct _GtkVBox GtkVBox;
-void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row );
+ui::Label DialogLabel_new( const char* name );
+ui::Table DialogRow_new( const char* name, ui::Widget widget );
+void DialogVBox_packRow( ui::VBox vbox, ui::Widget row );
#endif
gtk_widget_show( check );
AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(GTK_WIDGET( DialogRow_new( name, check ) ) ));
return check;
}
gtk_container_add( GTK_CONTAINER( alignment ), combo );
}
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row );
}
void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){
gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
}
void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
}
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
}
void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){
AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) );
}
void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){
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 );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
return row.m_row;
}
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 );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
return row.m_row;
}
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 );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
return row.m_row;
}
AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer );
- GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, ui::Widget(GTK_WIDGET( pathEntry.m_frame )) );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
return ui::Widget(GTK_WIDGET( row ));
}
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 );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
return ui::SpinButton(row.m_spin);
}
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 );
+ DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
return ui::SpinButton(row.m_spin);
}
}
void EntityInspector_appendAttribute( const char* name, EntityAttribute& attribute ){
- GtkTable* row = DialogRow_new( name, attribute.getWidget() );
- DialogVBox_packRow( g_attributeBox, GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, attribute.getWidget() );
+ DialogVBox_packRow( ui::VBox(g_attributeBox), row );
}
{
public:
ui::Window BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
+ auto frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
{
Paths_constructPreferences( preferencesPage );
}
- return ui::Window(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, frame ));
}
};
}
ui::Window CGameDialog::BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN );
+ auto frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
{
CreateGlobalFrame( preferencesPage );
}
- return ui::Window(create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) ));
+ return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame );
}
class LoadGameFile