Add a helper macro for setting standard button callbacks in a dialog.

Yes, it's a macro, but it can reduce the copy-paste factor of a
pre_show() function quite a lot when there are many buttons.
This commit is contained in:
Tomasz Śniatowski 2009-07-05 18:47:39 +01:00
parent 9fe323644d
commit c538e687c3

View file

@ -33,6 +33,12 @@ void dialog_callback(twidget* caller)
(dialog->*fptr)(*window);
}
#define GUI2_EASY_BUTTON_CALLBACK(ID, MY_TYPE) \
tbutton* ID##_btn = dynamic_cast<tbutton*>(window.find_widget(#ID, false)); \
VALIDATE(ID##_btn, missing_widget(#ID)); \
ID##_btn->set_callback_mouse_left_click(dialog_callback<MY_TYPE, \
&MY_TYPE::ID##_button_callback>);
} // namespace gui2
#endif