/////////////////////////////////////////////////////////////////////////////
// Name: msw/frame.cpp
-// Purpose: wxFrameMSW
+// Purpose: wxFrame
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// event tables
// ----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(wxFrameMSW, wxFrameBase)
- EVT_ACTIVATE(wxFrameMSW::OnActivate)
- EVT_SYS_COLOUR_CHANGED(wxFrameMSW::OnSysColourChanged)
+BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
+ EVT_ACTIVATE(wxFrame::OnActivate)
+ EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
END_EVENT_TABLE()
-#ifndef __WXUNIVERSAL__
- IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
-#endif
+IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
// ============================================================================
// implementation
#if wxUSE_STATUSBAR
#if wxUSE_NATIVE_STATUSBAR
- bool wxFrameMSW::m_useNativeStatusBar = TRUE;
+ bool wxFrame::m_useNativeStatusBar = TRUE;
#else
- bool wxFrameMSW::m_useNativeStatusBar = FALSE;
+ bool wxFrame::m_useNativeStatusBar = FALSE;
#endif
#endif // wxUSE_NATIVE_STATUSBAR
// creation/destruction
// ----------------------------------------------------------------------------
-void wxFrameMSW::Init()
+void wxFrame::Init()
{
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
// Data to save/restore when calling ShowFullScreen
- m_fsStyle = 0;
- m_fsOldWindowStyle = 0;
m_fsStatusBarFields = 0;
m_fsStatusBarHeight = 0;
m_fsToolBarHeight = 0;
// m_fsMenu = 0;
- m_fsIsMaximized = FALSE;
- m_fsIsShowing = FALSE;
- m_winLastFocused = (wxWindow *)NULL;
+ m_wasMinimized = FALSE;
- // unlike (almost?) all other windows, frames are created hidden
- m_isShown = FALSE;
+ m_winLastFocused = (wxWindow *)NULL;
}
-bool wxFrameMSW::Create(wxWindow *parent,
+bool wxFrame::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
return FALSE;
- // the frame must have NULL parent HWND or it would be always on top of its
- // parent which is not what we usually want (in fact, we only want it for
- // frames with the special wxFRAME_TOOL_WINDOW style handled elsewhere)
- if ( !MSWCreate(m_windowId, NULL, wxFrameClassName, this, title,
- pos.x, pos.y, size.x, size.y, style) )
- return FALSE;
-
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
wxModelessWindows.Append(this);
return TRUE;
}
-wxFrameMSW::~wxFrameMSW()
+wxFrame::~wxFrame()
{
m_isBeingDeleted = TRUE;
}
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
-void wxFrameMSW::DoGetClientSize(int *x, int *y) const
+void wxFrame::DoGetClientSize(int *x, int *y) const
{
RECT rect;
::GetClientRect(GetHwnd(), &rect);
*y = rect.bottom;
}
-void wxFrameMSW::DoSetClientSize(int width, int height)
+void wxFrame::DoSetClientSize(int width, int height)
{
// leave enough space for the status bar if we have (and show) it
#if wxUSE_STATUSBAR
}
// ----------------------------------------------------------------------------
-// wxFrameMSW: various geometry-related functions
+// wxFrame: various geometry-related functions
// ----------------------------------------------------------------------------
-void wxFrameMSW::Raise()
+void wxFrame::Raise()
{
#ifdef __WIN16__
// no SetForegroundWindow() in Win16
}
// generate an artificial resize event
-void wxFrameMSW::SendSizeEvent()
+void wxFrame::SendSizeEvent()
{
if ( !m_iconized )
{
}
#if wxUSE_STATUSBAR
-wxStatusBar *wxFrameMSW::OnCreateStatusBar(int number,
+wxStatusBar *wxFrame::OnCreateStatusBar(int number,
long style,
wxWindowID id,
const wxString& name)
statusBar = new wxStatusBar(this, id, style, name);
}
- // Set the height according to the font and the border size
- wxClientDC dc(statusBar);
- dc.SetFont(statusBar->GetFont());
-
- wxCoord y;
- dc.GetTextExtent(_T("X"), NULL, &y );
-
- int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
-
- statusBar->SetSize(-1, -1, -1, height);
-
statusBar->SetFieldsCount(number);
return statusBar;
}
-void wxFrameMSW::PositionStatusBar()
+void wxFrame::PositionStatusBar()
{
if ( !m_frameStatusBar )
return;
#if wxUSE_MENUS_NATIVE
-void wxFrameMSW::AttachMenuBar(wxMenuBar *menubar)
+void wxFrame::AttachMenuBar(wxMenuBar *menubar)
{
wxFrameBase::AttachMenuBar(menubar);
}
}
-void wxFrameMSW::InternalSetMenuBar()
+void wxFrame::InternalSetMenuBar()
{
#ifndef __WXMICROWIN__
if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) )
#endif // wxUSE_MENUS_NATIVE
// Responds to colour changes, and passes event on to children.
-void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent& event)
+void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
Refresh();
}
// Pass TRUE to show full screen, FALSE to restore.
-bool wxFrameMSW::ShowFullScreen(bool show, long style)
+bool wxFrame::ShowFullScreen(bool show, long style)
{
+ if ( IsFullScreen() == show )
+ return FALSE;
+
if (show)
{
- if (IsFullScreen())
- return FALSE;
-
- m_fsIsShowing = TRUE;
- m_fsStyle = style;
-
#if wxUSE_TOOLBAR
wxToolBar *theToolBar = GetToolBar();
if (theToolBar)
else
m_fsStatusBarFields = 0;
#endif // wxUSE_STATUSBAR
-
- // zap the frame borders
-
- // save the 'normal' window style
- m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
-
- // save the old position, width & height, maximize state
- m_fsOldSize = GetRect();
- m_fsIsMaximized = IsMaximized();
-
- // decide which window style flags to turn off
- LONG newStyle = m_fsOldWindowStyle;
- LONG offFlags = 0;
-
- if (style & wxFULLSCREEN_NOBORDER)
- offFlags |= WS_BORDER | WS_THICKFRAME;
- if (style & wxFULLSCREEN_NOCAPTION)
- offFlags |= (WS_CAPTION | WS_SYSMENU);
-
- newStyle &= (~offFlags);
-
- // change our window style to be compatible with full-screen mode
- ::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
-
- // resize to the size of the desktop
- int width, height;
-
- RECT rect = wxGetWindowRect(::GetDesktopWindow());
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
-
- SetSize(width, height);
-
- // now flush the window style cache and actually go full-screen
- SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
-
- wxSizeEvent event(wxSize(width, height), GetId());
- GetEventHandler()->ProcessEvent(event);
-
- return TRUE;
}
else
{
- if (!IsFullScreen())
- return FALSE;
-
- m_fsIsShowing = FALSE;
-
#if wxUSE_TOOLBAR
wxToolBar *theToolBar = GetToolBar();
if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
#endif
-
- Maximize(m_fsIsMaximized);
- SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
- SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
- m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
-
- return TRUE;
}
-}
-
-/*
- * Frame window
- *
- */
-
-bool wxFrameMSW::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow *wx_win, const wxChar *title,
- int x, int y, int width, int height, long style)
-
-{
- // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
- // could be the culprit. But without it, you can get a lot of flicker.
-
- DWORD msflags = 0;
- if ( style & wxCAPTION )
- {
- if ( style & wxFRAME_TOOL_WINDOW )
- msflags |= WS_POPUPWINDOW;
- else
- msflags |= WS_OVERLAPPED;
- }
- else
- {
- msflags |= WS_POPUP;
- }
-
- if (style & wxMINIMIZE_BOX)
- msflags |= WS_MINIMIZEBOX;
- if (style & wxMAXIMIZE_BOX)
- msflags |= WS_MAXIMIZEBOX;
- if (style & wxTHICK_FRAME)
- msflags |= WS_THICKFRAME;
- if (style & wxSYSTEM_MENU)
- msflags |= WS_SYSMENU;
- if ( style & wxMINIMIZE )
- msflags |= WS_MINIMIZE;
- if (style & wxMAXIMIZE)
- msflags |= WS_MAXIMIZE;
- if (style & wxCAPTION)
- msflags |= WS_CAPTION;
- if (style & wxCLIP_CHILDREN)
- msflags |= WS_CLIPCHILDREN;
-
- // Keep this in wxFrameMSW because it saves recoding this function
- // in wxTinyFrame
-#if wxUSE_ITSY_BITSY && !defined(__WIN32__)
- if (style & wxTINY_CAPTION_VERT)
- msflags |= IBS_VERTCAPTION;
- if (style & wxTINY_CAPTION_HORIZ)
- msflags |= IBS_HORZCAPTION;
-#else
- if (style & wxTINY_CAPTION_VERT)
- msflags |= WS_CAPTION;
- if (style & wxTINY_CAPTION_HORIZ)
- msflags |= WS_CAPTION;
-#endif
- if ((style & wxTHICK_FRAME) == 0)
- msflags |= WS_BORDER;
-
- WXDWORD extendedStyle = MakeExtendedStyle(style);
-
- // make all frames appear in the win9x shell taskbar unless
- // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them
- // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
-#if !defined(__WIN16__) && !defined(__SC__)
- if ( (style & wxFRAME_TOOL_WINDOW) ||
- (style & wxFRAME_NO_TASKBAR) )
- extendedStyle |= WS_EX_TOOLWINDOW;
- else if ( !(style & wxFRAME_NO_TASKBAR) )
- extendedStyle |= WS_EX_APPWINDOW;
-#endif
-
- if (style & wxSTAY_ON_TOP)
- extendedStyle |= WS_EX_TOPMOST;
-
-#ifndef __WIN16__
- if (m_exStyle & wxFRAME_EX_CONTEXTHELP)
- extendedStyle |= WS_EX_CONTEXTHELP;
-#endif
-
- m_iconized = FALSE;
- if ( !wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height,
- msflags, NULL, extendedStyle) )
- return FALSE;
-
- // Seems to be necessary if we use WS_POPUP
- // style instead of WS_OVERLAPPED
- if (width > -1 && height > -1)
- ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(width, height));
-
- return TRUE;
+
+ return wxFrameBase::ShowFullScreen(show, style);
}
// Default activation behaviour - set the focus for the first child
// subwindow found.
-void wxFrameMSW::OnActivate(wxActivateEvent& event)
+void wxFrame::OnActivate(wxActivateEvent& event)
{
if ( event.GetActive() )
{
// restore focus to the child which was last focused
- wxLogTrace(_T("focus"), _T("wxFrameMSW %08x activated."), m_hWnd);
+ wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
: NULL;
}
wxLogTrace(_T("focus"),
- _T("wxFrameMSW %08x deactivated, last focused: %08x."),
+ _T("wxFrame %08x deactivated, last focused: %08x."),
m_hWnd,
m_winLastFocused ? GetHwndOf(m_winLastFocused)
: NULL);
#if wxUSE_TOOLBAR
-wxToolBar* wxFrameMSW::CreateToolBar(long style, wxWindowID id, const wxString& name)
+wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
if ( wxFrameBase::CreateToolBar(style, id, name) )
{
return m_frameToolBar;
}
-void wxFrameMSW::PositionToolBar()
+void wxFrame::PositionToolBar()
{
RECT rect;
::GetClientRect(GetHwnd(), &rect);
// propagate our state change to all child frames: this allows us to emulate X
// Windows behaviour where child frames float independently of the parent one
// on the desktop, but are iconized/restored with it
-void wxFrameMSW::IconizeChildFrames(bool bIconize)
+void wxFrame::IconizeChildFrames(bool bIconize)
{
for ( wxWindowList::Node *node = GetChildren().GetFirst();
node;
#endif // wxUSE_MDI_ARCHITECTURE
)
{
- frame->Iconize(bIconize);
+ // we don't want to restore the child frames which had been
+ // iconized even before we were iconized, so save the child frame
+ // status when iconizing the parent frame and check it when
+ // restoring it
+ if ( bIconize )
+ {
+ frame->m_wasMinimized = frame->IsIconized();
+ }
+
+ // this test works for both iconizing and restoring
+ if ( !frame->m_wasMinimized )
+ frame->Iconize(bIconize);
}
}
}
-WXHICON wxFrameMSW::GetDefaultIcon() const
+WXHICON wxFrame::GetDefaultIcon() const
{
return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON);
// preprocessing
// ---------------------------------------------------------------------------
-bool wxFrameMSW::MSWTranslateMessage(WXMSG* pMsg)
+bool wxFrame::MSWTranslateMessage(WXMSG* pMsg)
{
if ( wxWindow::MSWTranslateMessage(pMsg) )
return TRUE;
// our private (non virtual) message handlers
// ---------------------------------------------------------------------------
-bool wxFrameMSW::HandlePaint()
+bool wxFrame::HandlePaint()
{
RECT rect;
if ( GetUpdateRect(GetHwnd(), &rect, FALSE) )
}
}
-bool wxFrameMSW::HandleSize(int x, int y, WXUINT id)
+bool wxFrame::HandleSize(int x, int y, WXUINT id)
{
bool processed = FALSE;
#ifndef __WXMICROWIN__
return processed;
}
-bool wxFrameMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
+bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
{
if ( control )
{
return FALSE;
}
-bool wxFrameMSW::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
+bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
{
int item;
if ( flags == 0xFFFF && hMenu == 0 )
}
// ---------------------------------------------------------------------------
-// the window proc for wxFrameMSW
+// the window proc for wxFrame
// ---------------------------------------------------------------------------
-long wxFrameMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
long rc = 0;
bool processed = FALSE;