X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/93cf77c076b699e8e0b3b0049bd4f80de15997dd..342751763793b5cdad252d731aac0618d0674e5b:/src/stubs/dialog.cpp diff --git a/src/stubs/dialog.cpp b/src/stubs/dialog.cpp index 9b72fb0f69..f0358af36a 100644 --- a/src/stubs/dialog.cpp +++ b/src/stubs/dialog.cpp @@ -25,7 +25,6 @@ wxList wxModalDialogs; wxList wxModelessWindows; // Frames and modeless dialogs extern wxList wxPendingDelete; -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel) @@ -37,7 +36,6 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel) EVT_CLOSE(wxDialog::OnCloseWindow) END_EVENT_TABLE() -#endif wxDialog::wxDialog() { @@ -107,10 +105,8 @@ wxDialog::~wxDialog() // By default, pressing escape cancels the dialog void wxDialog::OnCharHook(wxKeyEvent& event) { - if (GetHWND()) + if (event.m_keyCode == WXK_ESCAPE) { - if (event.m_keyCode == WXK_ESCAPE) - { // Behaviour changed in 2.0: we'll send a Cancel message // to the dialog instead of Close. wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); @@ -118,7 +114,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event) GetEventHandler()->ProcessEvent(cancelEvent); return; - } } // We didn't process this event. event.Skip(); @@ -167,20 +162,13 @@ void wxDialog::Centre(int direction) int x_offset,y_offset ; int display_width, display_height; int width, height, x, y; - wxFrame *frame ; - if (direction & wxCENTER_FRAME) + wxWindow *parent = GetParent(); + if ((direction & wxCENTER_FRAME) && parent) { - frame = (wxFrame*)GetParent() ; - if (frame) - { - frame->GetPosition(&x_offset,&y_offset) ; - frame->GetSize(&display_width,&display_height) ; - } + parent->GetPosition(&x_offset,&y_offset) ; + parent->GetSize(&display_width,&display_height) ; } else - frame = NULL ; - - if (frame==NULL) { wxDisplaySize(&display_width, &display_height); x_offset = 0 ; @@ -247,35 +235,34 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); - - return FALSE; -} - -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || event.GetForce()) - { - this->Destroy(); - } } // Destroy the window (delayed, if a managed window) @@ -292,3 +279,6 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) Refresh(); } +void wxDialog::Fit() +{ +}