X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a49afa93ca428a2236d5bc76f628241036f01629..7379599933e8db2dc319bd5240b4992687db4e46:/src/mac/carbon/dialog.cpp diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index 044002d970..959fe01dfd 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -19,24 +19,26 @@ #include "wx/app.h" #include "wx/settings.h" -#include +#include "wx/mac/uma.h" // Lists to keep track of windows, so we can disable/enable them // for modal dialogs wxList wxModalDialogs; -wxList wxModelessWindows; // Frames and modeless dialogs +//wxList wxModelessWindows; // Frames and modeless dialogs extern wxList wxPendingDelete; #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) +IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow) -BEGIN_EVENT_TABLE(wxDialog, wxPanel) - EVT_SIZE(wxDialog::OnSize) +BEGIN_EVENT_TABLE(wxDialog, wxDialogBase) EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) + EVT_CHAR_HOOK(wxDialog::OnCharHook) + EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged) + EVT_CLOSE(wxDialog::OnCloseWindow) END_EVENT_TABLE() @@ -45,7 +47,7 @@ END_EVENT_TABLE() wxDialog::wxDialog() { m_isShown = FALSE; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); } bool wxDialog::Create(wxWindow *parent, wxWindowID id, @@ -56,21 +58,16 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, const wxString& name) { - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); - if (!parent) - wxTopLevelWindows.Append(this); - - if (parent) parent->AddChild(this); - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) + return FALSE; MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ; - m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; return TRUE; } @@ -93,29 +90,16 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { m_isBeingDeleted = TRUE ; - wxTopLevelWindows.DeleteObject(this); - - Show(FALSE); - - if ( !IsModal() ) - wxModelessWindows.DeleteObject(this); - - // If this is the last top-level window, exit. - if (wxTheApp && (wxTopLevelWindows.Number() == 0)) - { - wxTheApp->SetTopWindow(NULL); - - if (wxTheApp->GetExitOnFrameDelete()) - { - wxTheApp->ExitMainLoop() ; - } - } + Show(FALSE); } -// By default, pressing escape cancels the dialog +// By default, pressing escape cancels the dialog , on mac command-stop does the same thing void wxDialog::OnCharHook(wxKeyEvent& event) { - if (event.m_keyCode == WXK_ESCAPE) + if ( + ( event.m_keyCode == WXK_ESCAPE || + ( event.m_keyCode == '.' && event.MetaDown() ) ) + && FindWindow(wxID_CANCEL) ) { // Behaviour changed in 2.0: we'll send a Cancel message // to the dialog instead of Close. @@ -129,27 +113,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event) event.Skip(); } -void wxDialog::Iconize(bool WXUNUSED(iconize)) -{ - // mac dialogs cannot be iconized -} - -bool wxDialog::IsIconized() const -{ - // mac dialogs cannot be iconized - return FALSE; -} - -void wxDialog::DoSetClientSize(int width, int height) -{ - wxWindow::DoSetClientSize( width , height ) ; -} - -void wxDialog::DoGetPosition(int *x, int *y) const -{ - wxWindow::DoGetPosition( x , y ) ; -} - bool wxDialog::IsModal() const { return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0; @@ -161,7 +124,6 @@ bool wxDialog::IsModalShowing() const return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast } - extern bool s_macIsInModalLoop ; bool wxDialog::Show(bool show) @@ -255,7 +217,7 @@ void wxDialog::EndModal(int retCode) } // Standard buttons -void wxDialog::OnOK(wxCommandEvent& event) +void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { if ( Validate() && TransferDataFromWindow() ) { @@ -263,19 +225,19 @@ void wxDialog::OnOK(wxCommandEvent& event) } } -void wxDialog::OnApply(wxCommandEvent& event) +void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) { if (Validate()) TransferDataFromWindow(); // TODO probably need to disable the Apply button until things change again } -void wxDialog::OnCancel(wxCommandEvent& event) +void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - EndModal(wxID_CANCEL); + EndModal(wxID_CANCEL); } -void wxDialog::OnCloseWindow(wxCloseEvent& event) +void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { // We'll send a Cancel message by default, // which may close the dialog. @@ -305,19 +267,9 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) closing.DeleteObject(this); } -// Destroy the window (delayed, if a managed window) -bool wxDialog::Destroy() -{ - wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE, - _T("wxDialog destroyed twice") ); - - wxPendingDelete.Append(this); - return TRUE; -} - -void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) +void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) { - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); Refresh(); }