toplevel fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11746 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2001-09-30 17:34:51 +00:00
parent 752b40b1da
commit a15eb0a5c8
8 changed files with 365 additions and 219 deletions
+13 -52
View File
@@ -28,15 +28,17 @@ wxList wxModalDialogs;
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, wxTopLevelWindow)
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()
@@ -58,15 +60,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
SetBackgroundColour(wxSystemSettings::GetSystemColour(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 ) ;
@@ -93,29 +89,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,17 +112,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
event.Skip();
}
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;
@@ -151,7 +123,6 @@ bool wxDialog::IsModalShowing() const
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
}
extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show)
@@ -295,16 +266,6 @@ 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)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));