~wxDialog();
- virtual bool Destroy();
+// virtual bool Destroy();
bool Show(bool show);
void SetModal(bool flag);
// --------------
// event handlers
- bool OnClose();
+// bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
- // override more base class virtuals
- virtual void DoGetPosition(int *x, int *y) const;
- virtual void DoSetClientSize(int width, int height);
-
// show modal dialog and enter modal loop
void DoShowModal();
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()
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 ) ;
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.
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;
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
}
-
extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show)
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));
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxFrameMac, wxFrameBase)
-// EVT_SIZE(wxFrameMac::OnSize)
EVT_ACTIVATE(wxFrameMac::OnActivate)
// EVT_MENU_HIGHLIGHT_ALL(wxFrameMac::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrameMac::OnSysColourChanged)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
- if ( id > -1 )
- m_windowId = id;
- else
- m_windowId = (int)NewControlId();
-
- if (parent) parent->AddChild(this);
-
- if (!parent)
- wxTopLevelWindows.Append(this);
+ if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+ return FALSE;
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
wxFrameMac::~wxFrameMac()
{
m_isBeingDeleted = TRUE;
- wxTopLevelWindows.DeleteObject(this);
DeleteAllBars();
-/* Check if it's the last top-level window */
-
- if (wxTheApp && (wxTopLevelWindows.Number() == 0))
- {
- wxTheApp->SetTopWindow(NULL);
-
- if (wxTheApp->GetExitOnFrameDelete())
- {
- wxTheApp->ExitMainLoop() ;
- }
- }
-
- wxModelessWindows.DeleteObject(this);
}
{
if ( !event.GetActive() )
{
- // remember the last focused child
+ // remember the last focused child if it is our child
m_winLastFocused = FindFocus();
- while ( m_winLastFocused )
+
+ // so we NULL it out if it's a child from some other frame
+ wxWindow *win = m_winLastFocused;
+ while ( win )
{
- if ( GetChildren().Find(m_winLastFocused) )
+ if ( win->IsTopLevel() )
+ {
+ if ( win != this )
+ {
+ m_winLastFocused = NULL;
+ }
+
break;
+ }
- m_winLastFocused = m_winLastFocused->GetParent();
+ win = win->GetParent();
}
event.Skip();
}
else
{
-/*
- for ( wxWindowList::Node *node = GetChildren().GetFirst();
- node;
- node = node->GetNext() )
- {
- // FIXME all this is totally bogus - we need to do the same as wxPanel,
- // but how to do it without duplicating the code?
-
- // restore focus
- wxWindow *child = node->GetData();
-
- if ( !child->IsTopLevel() && child->AcceptsFocus()
-#if wxUSE_TOOLBAR
- && !wxDynamicCast(child, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
- && !wxDynamicCast(child, wxStatusBar)
-#endif // wxUSE_STATUSBAR
- )
+ // restore focus to the child which was last focused
+ wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
+ : NULL;
+ if ( !parent )
{
- child->SetFocus();
- break;
+ parent = this;
}
- }
- */
- wxSetFocusToChild(this, &m_winLastFocused);
+
+ wxSetFocusToChild(parent, &m_winLastFocused);
if ( m_frameMenuBar != NULL )
{
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: mac/toplevel.cpp
+// Purpose: implements wxTopLevelWindow for MSW
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 24.09.01
+// RCS-ID: $Id$
+// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// License: wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "toplevel.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/toplevel.h"
+ #include "wx/string.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
+#endif //WX_PRECOMP
+
+// ----------------------------------------------------------------------------
+// globals
+// ----------------------------------------------------------------------------
+
+// list of all frames and modeless dialogs
+wxWindowList wxModelessWindows;
+
+// ============================================================================
+// wxTopLevelWindowMac implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac creation
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Init()
+{
+ m_iconized =
+ m_maximizeOnShow = FALSE;
+}
+
+bool wxTopLevelWindowMac::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ // init our fields
+ Init();
+
+ m_windowStyle = style;
+
+ SetName(name);
+
+ m_windowId = id == -1 ? NewControlId() : id;
+
+ wxTopLevelWindows.Append(this);
+
+ if ( parent )
+ parent->AddChild(this);
+
+ return TRUE;
+}
+
+wxTopLevelWindowMac::~wxTopLevelWindowMac()
+{
+ wxTopLevelWindows.DeleteObject(this);
+
+ if ( wxModelessWindows.Find(this) )
+ 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() ;
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac maximize/minimize
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Maximize(bool maximize)
+{
+ // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsMaximized() const
+{
+ return false ;
+}
+
+void wxTopLevelWindowMac::Iconize(bool iconize)
+{
+ // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsIconized() const
+{
+ // mac dialogs cannot be iconized
+ return FALSE;
+}
+
+void wxTopLevelWindowMac::Restore()
+{
+ // not available on mac
+}
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac misc
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
+{
+ // this sets m_icon
+ wxTopLevelWindowBase::SetIcon(icon);
+}
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()
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 ) ;
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.
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;
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
}
-
extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show)
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));
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxFrameMac, wxFrameBase)
-// EVT_SIZE(wxFrameMac::OnSize)
EVT_ACTIVATE(wxFrameMac::OnActivate)
// EVT_MENU_HIGHLIGHT_ALL(wxFrameMac::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrameMac::OnSysColourChanged)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
- if ( id > -1 )
- m_windowId = id;
- else
- m_windowId = (int)NewControlId();
-
- if (parent) parent->AddChild(this);
-
- if (!parent)
- wxTopLevelWindows.Append(this);
+ if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+ return FALSE;
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
wxFrameMac::~wxFrameMac()
{
m_isBeingDeleted = TRUE;
- wxTopLevelWindows.DeleteObject(this);
DeleteAllBars();
-/* Check if it's the last top-level window */
-
- if (wxTheApp && (wxTopLevelWindows.Number() == 0))
- {
- wxTheApp->SetTopWindow(NULL);
-
- if (wxTheApp->GetExitOnFrameDelete())
- {
- wxTheApp->ExitMainLoop() ;
- }
- }
-
- wxModelessWindows.DeleteObject(this);
}
{
if ( !event.GetActive() )
{
- // remember the last focused child
+ // remember the last focused child if it is our child
m_winLastFocused = FindFocus();
- while ( m_winLastFocused )
+
+ // so we NULL it out if it's a child from some other frame
+ wxWindow *win = m_winLastFocused;
+ while ( win )
{
- if ( GetChildren().Find(m_winLastFocused) )
+ if ( win->IsTopLevel() )
+ {
+ if ( win != this )
+ {
+ m_winLastFocused = NULL;
+ }
+
break;
+ }
- m_winLastFocused = m_winLastFocused->GetParent();
+ win = win->GetParent();
}
event.Skip();
}
else
{
-/*
- for ( wxWindowList::Node *node = GetChildren().GetFirst();
- node;
- node = node->GetNext() )
- {
- // FIXME all this is totally bogus - we need to do the same as wxPanel,
- // but how to do it without duplicating the code?
-
- // restore focus
- wxWindow *child = node->GetData();
-
- if ( !child->IsTopLevel() && child->AcceptsFocus()
-#if wxUSE_TOOLBAR
- && !wxDynamicCast(child, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
- && !wxDynamicCast(child, wxStatusBar)
-#endif // wxUSE_STATUSBAR
- )
+ // restore focus to the child which was last focused
+ wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
+ : NULL;
+ if ( !parent )
{
- child->SetFocus();
- break;
+ parent = this;
}
- }
- */
- wxSetFocusToChild(this, &m_winLastFocused);
+
+ wxSetFocusToChild(parent, &m_winLastFocused);
if ( m_frameMenuBar != NULL )
{
** to the local tempPathname).
*/
-#if !TARGET_CARBON
+#if TARGET_CARBON
pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname,
short vRefNum,
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: mac/toplevel.cpp
+// Purpose: implements wxTopLevelWindow for MSW
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 24.09.01
+// RCS-ID: $Id$
+// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// License: wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "toplevel.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/toplevel.h"
+ #include "wx/string.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
+#endif //WX_PRECOMP
+
+// ----------------------------------------------------------------------------
+// globals
+// ----------------------------------------------------------------------------
+
+// list of all frames and modeless dialogs
+wxWindowList wxModelessWindows;
+
+// ============================================================================
+// wxTopLevelWindowMac implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac creation
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Init()
+{
+ m_iconized =
+ m_maximizeOnShow = FALSE;
+}
+
+bool wxTopLevelWindowMac::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ // init our fields
+ Init();
+
+ m_windowStyle = style;
+
+ SetName(name);
+
+ m_windowId = id == -1 ? NewControlId() : id;
+
+ wxTopLevelWindows.Append(this);
+
+ if ( parent )
+ parent->AddChild(this);
+
+ return TRUE;
+}
+
+wxTopLevelWindowMac::~wxTopLevelWindowMac()
+{
+ wxTopLevelWindows.DeleteObject(this);
+
+ if ( wxModelessWindows.Find(this) )
+ 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() ;
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac maximize/minimize
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Maximize(bool maximize)
+{
+ // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsMaximized() const
+{
+ return false ;
+}
+
+void wxTopLevelWindowMac::Iconize(bool iconize)
+{
+ // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsIconized() const
+{
+ // mac dialogs cannot be iconized
+ return FALSE;
+}
+
+void wxTopLevelWindowMac::Restore()
+{
+ // not available on mac
+}
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac misc
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
+{
+ // this sets m_icon
+ wxTopLevelWindowBase::SetIcon(icon);
+}