X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/87728739f23c6fcc737614e2e726f68778f9415b..87419e97c6f15a9906de69690e7ba59ec0ffd119:/samples/xrc/derivdlg.cpp?ds=sidebyside diff --git a/samples/xrc/derivdlg.cpp b/samples/xrc/derivdlg.cpp index b784e322b4..6a6da8a9a2 100644 --- a/samples/xrc/derivdlg.cpp +++ b/samples/xrc/derivdlg.cpp @@ -8,15 +8,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// GCC implementation -//----------------------------------------------------------------------------- - -#ifdef __GNUG__ - #pragma implementation "derivdlg.h" -#endif - -//----------------------------------------------------------------------------- -// Standard wxWindows headers +// Standard wxWidgets headers //----------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx/wx.h". @@ -27,7 +19,7 @@ #endif // For all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWindows headers) +// need because it includes almost all "standard" wxWidgets headers) #ifndef WX_PRECOMP #include "wx/wx.h" #endif @@ -49,8 +41,8 @@ //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog) - EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked ) - EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OuUpdateUIMyCheckbox ) + EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked ) + EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OnUpdateUIMyCheckbox ) // Note that the ID here isn't a XRCID, it is one of the standard wx ID's. EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK ) END_EVENT_TABLE() @@ -60,13 +52,8 @@ END_EVENT_TABLE() //----------------------------------------------------------------------------- // Constructor (Notice how small and easy it is) PreferencesDialog::PreferencesDialog(wxWindow* parent) -{ - wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog")); -} - -// Destructor. (Empty, as I don't need anything special done when destructing). -PreferencesDialog::~PreferencesDialog() { + wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog")); } //----------------------------------------------------------------------------- @@ -76,29 +63,29 @@ PreferencesDialog::~PreferencesDialog() void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) ) { // Construct a message dialog. - wxMessageDialog msgDlg(this, _("You clicked on My Button")); - + wxMessageDialog msgDlg(this, _("You clicked on My Button")); + // Show it modally. msgDlg.ShowModal(); } -// Update the enabled/disabled state of the edit/delete buttons depending on +// Update the enabled/disabled state of the edit/delete buttons depending on // whether a row (item) is selected in the listctrl -void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) ) +void PreferencesDialog::OnUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) ) { // Get a boolean value of whether the checkbox is checked - bool myCheckBoxIsChecked; + bool myCheckBoxIsChecked; // You could just write: // myCheckBoxIsChecked = event.IsChecked(); - // since the event that was passed into this function already has the - // is a pointer to the right control. However, + // since the event that was passed into this function already has the + // is a pointer to the right control. However, // this is the XRCCTRL way (which is more obvious as to what is going on). myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked(); - // Now call either Enable(TRUE) or Enable(FALSE) on the textctrl, depending - // on the value of that boolean. - XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked); + // Now call either Enable(true) or Enable(false) on the textctrl, depending + // on the value of that boolean. + XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked); } @@ -108,16 +95,16 @@ void PreferencesDialog::OnOK( wxCommandEvent& WXUNUSED(event) ) wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"), _("Overriding base class OK button handler"), wxOK | wxCANCEL | wxCENTER ); - + // Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)... if (msgDlg2.ShowModal() == wxID_OK) { - // ...then end this Preferences dialog. + // ...then end this Preferences dialog. EndModal( wxID_OK ); // You could also have used event.Skip() which would then skip up // to the wxDialog's event table and see if there was a EVT_BUTTON - // handler for wxID_OK and if there was, then execute that code. + // handler for wxID_OK and if there was, then execute that code. } - + // Otherwise do nothing. }