2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 // Base dialog class, provides a way to run modal dialogs and
24 // set/get the widget values in member variables.
26 // Leonardo Zide (leo@lokigames.com)
31 #include "debugging/debugging.h"
34 #include "mainframe.h"
38 #include "stream/stringstream.h"
40 #include "gtkutil/dialog.h"
41 #include "gtkutil/button.h"
42 #include "gtkutil/entry.h"
43 #include "gtkutil/image.h"
48 GtkEntry* DialogEntry_new(){
49 auto entry = ui::Entry();
50 gtk_widget_show( GTK_WIDGET( entry ) );
51 gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
58 DialogEntryRow( ui::Widget row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){
64 DialogEntryRow DialogEntryRow_new( const char* name ){
65 ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
66 gtk_widget_show( alignment );
68 GtkEntry* entry = DialogEntry_new();
69 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) );
71 return DialogEntryRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), entry );
75 GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int fraction ){
76 double step = 1.0 / double(fraction);
77 unsigned int digits = 0;
78 for (; fraction > 1; fraction /= 10 )
82 GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
83 gtk_widget_show( GTK_WIDGET( spin ) );
84 gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
88 class DialogSpinnerRow
91 DialogSpinnerRow( ui::Widget row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){
94 GtkSpinButton* m_spin;
97 DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){
98 ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
99 gtk_widget_show( alignment );
101 GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction );
102 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) );
104 return DialogSpinnerRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), spin );
112 void( *Import ) ( Type_&, Other_ ),
113 void( *Export ) ( Type_&, const Callback1<Other_>& )
119 typedef Other_ Other;
121 typedef ReferenceCaller1<Type, Other, Import> ImportCaller;
122 typedef ReferenceCaller1<Type, const Callback1<Other>&, Export> ExportCaller;
125 typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
126 typedef ImportExport<int, int, IntImport, IntExport> IntImportExport;
127 typedef ImportExport<std::size_t, std::size_t, SizeImport, SizeExport> SizeImportExport;
128 typedef ImportExport<float, float, FloatImport, FloatExport> FloatImportExport;
129 typedef ImportExport<CopiedString, const char*, StringImport, StringExport> StringImportExport;
133 void BoolToggleImport( GtkToggleButton& widget, bool value ){
134 gtk_toggle_button_set_active( &widget, value );
136 void BoolToggleExport( GtkToggleButton& widget, const BoolImportCallback& importCallback ){
137 importCallback( gtk_toggle_button_get_active( &widget ) != FALSE );
139 typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport> BoolToggleImportExport;
142 void IntRadioImport( GtkRadioButton& widget, int index ){
143 radio_button_set_active( ui::RadioButton(&widget), index );
145 void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){
146 importCallback( radio_button_get_active( ui::RadioButton(&widget) ) );
148 typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
150 void TextEntryImport( GtkEntry& widget, const char* text ){
151 gtk_entry_set_text( &widget, text );
153 void TextEntryExport( GtkEntry& widget, const StringImportCallback& importCallback ){
154 importCallback( gtk_entry_get_text( &widget ) );
156 typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
159 void IntEntryImport( GtkEntry& widget, int value ){
160 entry_set_int( ui::Entry(&widget), value );
162 void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){
163 importCallback( atoi( gtk_entry_get_text( &widget ) ) );
165 typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImportExport;
168 void SizeEntryImport( GtkEntry& widget, std::size_t value ){
169 entry_set_int( ui::Entry(&widget), int(value) );
171 void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){
172 int value = atoi( gtk_entry_get_text( &widget ) );
176 importCallback( value );
178 typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> SizeEntryImportExport;
181 void FloatEntryImport( GtkEntry& widget, float value ){
182 entry_set_float( ui::Entry(&widget), value );
184 void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){
185 importCallback( (float)atof( gtk_entry_get_text( &widget ) ) );
187 typedef ImportExport<GtkEntry, float, FloatEntryImport, FloatEntryExport> FloatEntryImportExport;
190 void FloatSpinnerImport( GtkSpinButton& widget, float value ){
191 gtk_spin_button_set_value( &widget, value );
193 void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){
194 importCallback( float(gtk_spin_button_get_value( &widget ) ) );
196 typedef ImportExport<GtkSpinButton, float, FloatSpinnerImport, FloatSpinnerExport> FloatSpinnerImportExport;
199 void IntSpinnerImport( GtkSpinButton& widget, int value ){
200 gtk_spin_button_set_value( &widget, value );
202 void IntSpinnerExport( GtkSpinButton& widget, const IntImportCallback& importCallback ){
203 importCallback( gtk_spin_button_get_value_as_int( &widget ) );
205 typedef ImportExport<GtkSpinButton, int, IntSpinnerImport, IntSpinnerExport> IntSpinnerImportExport;
208 void IntAdjustmentImport( GtkAdjustment& widget, int value ){
209 gtk_adjustment_set_value( &widget, value );
211 void IntAdjustmentExport( GtkAdjustment& widget, const IntImportCallback& importCallback ){
212 importCallback( (int)gtk_adjustment_get_value( &widget ) );
214 typedef ImportExport<GtkAdjustment, int, IntAdjustmentImport, IntAdjustmentExport> IntAdjustmentImportExport;
217 void IntComboImport( GtkComboBox& widget, int value ){
218 gtk_combo_box_set_active( &widget, value );
220 void IntComboExport( GtkComboBox& widget, const IntImportCallback& importCallback ){
221 importCallback( gtk_combo_box_get_active( &widget ) );
223 typedef ImportExport<GtkComboBox, int, IntComboImport, IntComboExport> IntComboImportExport;
226 template<typename FirstArgument>
227 class CallbackDialogData : public DLG_DATA
230 typedef Callback1<FirstArgument> ImportCallback;
231 typedef Callback1<const ImportCallback&> ExportCallback;
234 ImportCallback m_importWidget;
235 ExportCallback m_exportWidget;
236 ImportCallback m_importViewer;
237 ExportCallback m_exportViewer;
240 CallbackDialogData( const ImportCallback& importWidget, const ExportCallback& exportWidget, const ImportCallback& importViewer, const ExportCallback& exportViewer )
241 : m_importWidget( importWidget ), m_exportWidget( exportWidget ), m_importViewer( importViewer ), m_exportViewer( exportViewer ){
246 void importData() const {
247 m_exportViewer( m_importWidget );
249 void exportData() const {
250 m_exportWidget( m_importViewer );
254 template<typename Widget, typename Viewer>
257 DialogDataList& m_data;
259 AddData( DialogDataList& data ) : m_data( data ){
261 void apply( typename Widget::Type& widget, typename Viewer::Type& viewer ) const {
263 new CallbackDialogData<typename Widget::Other>(
264 typename Widget::ImportCaller( widget ),
265 typename Widget::ExportCaller( widget ),
266 typename Viewer::ImportCaller( viewer ),
267 typename Viewer::ExportCaller( viewer )
273 template<typename Widget>
276 DialogDataList& m_data;
278 AddCustomData( DialogDataList& data ) : m_data( data ){
281 typename Widget::Type& widget,
282 const Callback1<typename Widget::Other>& importViewer,
283 const Callback1<const Callback1<typename Widget::Other>&>& exportViewer
286 new CallbackDialogData<typename Widget::Other>(
287 typename Widget::ImportCaller( widget ),
288 typename Widget::ExportCaller( widget ),
296 // =============================================================================
299 Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
303 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
308 ASSERT_MESSAGE( !m_window, "dialog window not destroyed" );
311 void Dialog::ShowDlg(){
312 ASSERT_MESSAGE( m_window, "dialog was not constructed" );
314 gtk_widget_show( GTK_WIDGET( m_window ) );
317 void Dialog::HideDlg(){
318 ASSERT_MESSAGE( m_window, "dialog was not constructed" );
320 gtk_widget_hide( GTK_WIDGET( m_window ) );
323 static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
324 reinterpret_cast<Dialog*>( data )->HideDlg();
325 reinterpret_cast<Dialog*>( data )->EndModal( eIDCANCEL );
329 void Dialog::Create(){
330 ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" );
332 m_window = BuildDialog();
333 g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this );
336 void Dialog::Destroy(){
337 ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" );
339 gtk_widget_destroy( GTK_WIDGET( m_window ) );
340 m_window = ui::Window();
344 void Dialog::AddBoolToggleData( GtkToggleButton& widget, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
345 AddCustomData<BoolToggleImportExport>( m_data ).apply( widget, importViewer, exportViewer );
348 void Dialog::AddIntRadioData( GtkRadioButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
349 AddCustomData<IntRadioImportExport>( m_data ).apply( widget, importViewer, exportViewer );
352 void Dialog::AddTextEntryData( GtkEntry& widget, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
353 AddCustomData<TextEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
356 void Dialog::AddIntEntryData( GtkEntry& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
357 AddCustomData<IntEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
360 void Dialog::AddSizeEntryData( GtkEntry& widget, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
361 AddCustomData<SizeEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
364 void Dialog::AddFloatEntryData( GtkEntry& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
365 AddCustomData<FloatEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
368 void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
369 AddCustomData<FloatSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
372 void Dialog::AddIntSpinnerData( GtkSpinButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
373 AddCustomData<IntSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
376 void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
377 AddCustomData<IntAdjustmentImportExport>( m_data ).apply( widget, importViewer, exportViewer );
380 void Dialog::AddIntComboData( GtkComboBox& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
381 AddCustomData<IntComboImportExport>( m_data ).apply( widget, importViewer, exportViewer );
385 void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
386 AddData<BoolToggleImportExport, BoolImportExport>( m_data ).apply( widget, data );
388 void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
389 AddData<IntRadioImportExport, IntImportExport>( m_data ).apply( widget, data );
391 void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
392 AddData<TextEntryImportExport, StringImportExport>( m_data ).apply( widget, data );
394 void Dialog::AddDialogData( GtkEntry& widget, int& data ){
395 AddData<IntEntryImportExport, IntImportExport>( m_data ).apply( widget, data );
397 void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
398 AddData<SizeEntryImportExport, SizeImportExport>( m_data ).apply( widget, data );
400 void Dialog::AddDialogData( GtkEntry& widget, float& data ){
401 AddData<FloatEntryImportExport, FloatImportExport>( m_data ).apply( widget, data );
403 void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
404 AddData<FloatSpinnerImportExport, FloatImportExport>( m_data ).apply( widget, data );
406 void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
407 AddData<IntSpinnerImportExport, IntImportExport>( m_data ).apply( widget, data );
409 void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
410 AddData<IntAdjustmentImportExport, IntImportExport>( m_data ).apply( widget, data );
412 void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
413 AddData<IntComboImportExport, IntImportExport>( m_data ).apply( widget, data );
416 void Dialog::exportData(){
417 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
419 ( *i )->exportData();
423 void Dialog::importData(){
424 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
426 ( *i )->importData();
430 void Dialog::EndModal( EMessageBoxReturn code ){
435 EMessageBoxReturn Dialog::DoModal(){
440 EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal );
441 ASSERT_TRUE( (bool) m_window );
442 if ( ret == eIDOK ) {
446 gtk_widget_hide( GTK_WIDGET( m_window ) );
448 PostModal( m_modal.ret );
454 ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
455 auto check = ui::CheckButton( flag );
456 gtk_widget_show( check );
457 AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
459 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(GTK_WIDGET( DialogRow_new( name, check ) ) ));
463 ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){
464 return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) );
467 void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
468 ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
469 gtk_widget_show( alignment );
471 ui::Widget combo = ui::ComboBoxText();
473 for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i )
475 gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i );
478 AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer );
480 gtk_widget_show( combo );
481 gtk_container_add( GTK_CONTAINER( alignment ), combo );
484 auto row = DialogRow_new( name, alignment );
485 DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row );
488 void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){
489 addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) );
492 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 ){
494 if ( draw_value == FALSE ) {
495 ui::Widget hbox2 = ui::HBox( FALSE, 0 );
496 gtk_widget_show( hbox2 );
497 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
499 ui::Widget label = ui::Label( low );
500 gtk_widget_show( label );
501 gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
504 ui::Widget label = ui::Label( high );
505 gtk_widget_show( label );
506 gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
512 auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 );
513 AddIntAdjustmentData( *GTK_ADJUSTMENT(adj), IntImportCaller( data ), IntExportCaller( data ) );
516 ui::Widget alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
517 gtk_widget_show( alignment );
519 ui::Widget scale = ui::HScale( adj );
520 gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT );
521 gtk_widget_show( scale );
522 gtk_container_add( GTK_CONTAINER( alignment ), scale );
524 gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
525 gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
527 auto row = DialogRow_new( name, alignment );
528 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
531 void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
532 ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
533 gtk_widget_show( alignment );
535 RadioHBox radioBox = RadioHBox_new( names );
536 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) );
537 AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
540 auto row = DialogRow_new( name, alignment );
541 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
544 void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){
545 addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) );
548 void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
549 ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE );
550 gtk_widget_show( table );
552 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
553 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
557 for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon )
559 guint pos = static_cast<guint>( icon - icons.first );
560 GtkImage* image = new_local_image( *icon );
561 gtk_widget_show( GTK_WIDGET( image ) );
562 gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( image ), pos, pos + 1, 0, 1,
563 (GtkAttachOptions) ( 0 ),
564 (GtkAttachOptions) ( 0 ), 0, 0 );
566 radio = ui::Widget(gtk_radio_button_new( group ));
567 gtk_widget_show( radio );
568 gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2,
569 (GtkAttachOptions) ( 0 ),
570 (GtkAttachOptions) ( 0 ), 0, 0 );
572 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
575 AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
577 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) );
580 void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){
581 addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) );
584 ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
585 DialogEntryRow row( DialogEntryRow_new( name ) );
586 AddIntEntryData( *row.m_entry, importViewer, exportViewer );
587 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
591 ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
592 DialogEntryRow row( DialogEntryRow_new( name ) );
593 AddSizeEntryData( *row.m_entry, importViewer, exportViewer );
594 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
598 ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
599 DialogEntryRow row( DialogEntryRow_new( name ) );
600 AddFloatEntryData( *row.m_entry, importViewer, exportViewer );
601 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
605 ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
606 PathEntry pathEntry = PathEntry_new();
607 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 );
609 AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer );
611 auto row = DialogRow_new( name, ui::Widget(GTK_WIDGET( pathEntry.m_frame )) );
612 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
614 return ui::Widget(GTK_WIDGET( row ));
617 ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool browse_directory ){
618 return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) );
621 ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
622 DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
623 AddIntSpinnerData( *row.m_spin, importViewer, exportViewer );
624 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
625 return ui::SpinButton(row.m_spin);
628 ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){
629 return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) );
632 ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
633 DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
634 AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer );
635 DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
636 return ui::SpinButton(row.m_spin);