X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a7ef993c98f0e6344f3945639cb12d9f2d021e45..70d213e08b854b26adf059dfbc8ca357f702b300:/src/os2/frame.cpp diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index 14a35cba8f..becb832a40 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -527,23 +527,25 @@ void wxFrame::SetMenuBar( return; } - wxCHECK_RET(!pMenuBar->GetFrame(), wxT("this menubar is already attached")); + m_frameMenuBar = NULL; - if (m_frameMenuBar) - delete m_frameMenuBar; - - m_hMenu = pMenuBar->Create(); - m_ulMenubarId = pMenuBar->GetMenubarId(); - if (m_ulMenubarId != FID_MENU) + // Can set a menubar several times. + // TODO: how to prevent a memory leak if you have a currently-unattached + // menubar? wxWindows assumes that the frame will delete the menu (otherwise + // there are problems for MDI). + if (pMenuBar->GetHMenu()) { - ::WinSetWindowUShort( m_hMenu - ,QWS_ID - ,(unsigned short)m_ulMenubarId - ); + m_hMenu = pMenuBar->GetHMenu(); } + else + { + pMenuBar->Detach(); - if (!m_hMenu) - return; + m_hMenu = pMenuBar->Create(); + + if (!m_hMenu) + return; + } InternalSetMenuBar(); @@ -585,6 +587,130 @@ void wxFrame::OnSysColourChanged( wxWindow::OnSysColourChanged(rEvent); } // end of wxFrame::OnSysColourChanged +// Pass TRUE to show full screen, FALSE to restore. +bool wxFrame::ShowFullScreen( + bool bShow +, long lStyle +) +{ + /* + // TODO + if (show) + { + if (IsFullScreen()) + return FALSE; + + m_fsIsShowing = TRUE; + m_fsStyle = style; + + wxToolBar *theToolBar = GetToolBar(); + wxStatusBar *theStatusBar = GetStatusBar(); + + int dummyWidth; + + if (theToolBar) + theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight); + if (theStatusBar) + theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight); + + // zap the toolbar, menubar, and statusbar + + if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar) + { + theToolBar->SetSize(-1,0); + theToolBar->Show(FALSE); + } + + if (style & wxFULLSCREEN_NOMENUBAR) + SetMenu((HWND)GetHWND(), (HMENU) NULL); + + // Save the number of fields in the statusbar + if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) + { + m_fsStatusBarFields = theStatusBar->GetFieldsCount(); + SetStatusBar((wxStatusBar*) NULL); + delete theStatusBar; + } + else + m_fsStatusBarFields = 0; + + // 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; + 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; + ::GetWindowRect(GetDesktopWindow(), &rect); + 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; + + wxToolBar *theToolBar = GetToolBar(); + + // restore the toolbar, menubar, and statusbar + if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR)) + { + theToolBar->SetSize(-1, m_fsToolBarHeight); + theToolBar->Show(TRUE); + } + + if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0)) + { + CreateStatusBar(m_fsStatusBarFields); + PositionStatusBar(); + } + + if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0)) + SetMenu((HWND)GetHWND(), (HMENU)m_hMenu); + + 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; + } +*/ + return TRUE; +} // end of wxFrame::ShowFullScreen + // // Frame window // @@ -601,70 +727,63 @@ bool wxFrame::OS2Create( , long ulStyle ) { - ULONG ulPmFlags = 0; - ULONG ulExtraFlags = 0; - ULONG ulTempFlags = FCF_TITLEBAR | - FCF_SYSMENU | - FCF_MINBUTTON | - FCF_MAXBUTTON | - FCF_SIZEBORDER | - FCF_ICON | - FCF_MENU | - FCF_ACCELTABLE | - FCF_SHELLPOSITION | - FCF_TASKLIST; + ULONG ulPmFlags = 0L; + ULONG ulExtraFlags = 0L; + ULONG ulTempFlags = FCF_STANDARD; m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); - if ((ulStyle & wxCAPTION) == wxCAPTION) - ulPmFlags = FCF_TASKLIST; + if (ulStyle == wxDEFAULT_FRAME_STYLE) + ulPmFlags = FCF_STANDARD; else - ulPmFlags = FCF_NOMOVEWITHOWNER; - - if (ulStyle & wxMINIMIZE_BOX) - ulPmFlags |= FCF_MINBUTTON; - if (ulStyle & wxMAXIMIZE_BOX) - ulPmFlags |= FCF_MAXBUTTON; - if (ulStyle & wxTHICK_FRAME) - ulPmFlags |= FCF_DLGBORDER; - if (ulStyle & wxSYSTEM_MENU) - ulPmFlags |= FCF_SYSMENU; - if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) - ulPmFlags |= WS_MINIMIZED; - if (ulStyle & wxMAXIMIZE) - ulPmFlags |= WS_MAXIMIZED; - if (ulStyle & wxCAPTION) - ulPmFlags |= FCF_TASKLIST; - if (ulStyle & wxCLIP_CHILDREN) { - // Invalid for frame windows under PM - } + if ((ulStyle & wxCAPTION) == wxCAPTION) + ulPmFlags = FCF_TASKLIST; + else + ulPmFlags = FCF_NOMOVEWITHOWNER; + + if (ulStyle & wxMINIMIZE_BOX) + ulPmFlags |= FCF_MINBUTTON; + if (ulStyle & wxMAXIMIZE_BOX) + ulPmFlags |= FCF_MAXBUTTON; + if (ulStyle & wxTHICK_FRAME) + ulPmFlags |= FCF_DLGBORDER; + if (ulStyle & wxSYSTEM_MENU) + ulPmFlags |= FCF_SYSMENU; + if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) + ulPmFlags |= WS_MINIMIZED; + if (ulStyle & wxMAXIMIZE) + ulPmFlags |= WS_MAXIMIZED; + if (ulStyle & wxCAPTION) + ulPmFlags |= FCF_TASKLIST; + if (ulStyle & wxCLIP_CHILDREN) + { + // Invalid for frame windows under PM + } - // - // Keep this in wxFrame because it saves recoding this function - // in wxTinyFrame - // + // + // Keep this in wxFrame because it saves recoding this function + // in wxTinyFrame + // #if wxUSE_ITSY_BITSY - if (ulStyle & wxTINY_CAPTION_VERT) - ulExtraFlags |= kVertCaption; - if (ulStyle & wxTINY_CAPTION_HORIZ) - ulExtraFlags |= kHorzCaption; + if (ulStyle & wxTINY_CAPTION_VERT) + ulExtraFlags |= kVertCaption; + if (ulStyle & wxTINY_CAPTION_HORIZ) + ulExtraFlags |= kHorzCaption; #else - if (ulStyle & wxTINY_CAPTION_VERT) - ulPmFlags |= FCF_TASKLIST; - if (ulStyle & wxTINY_CAPTION_HORIZ) - ulPmFlags |= FCF_TASKLIST; + if (ulStyle & wxTINY_CAPTION_VERT) + ulPmFlags |= FCF_TASKLIST; + if (ulStyle & wxTINY_CAPTION_HORIZ) + ulPmFlags |= FCF_TASKLIST; #endif - if ((ulStyle & wxTHICK_FRAME) == 0) - ulPmFlags |= FCF_BORDER; - if (ulStyle & wxFRAME_TOOL_WINDOW) - ulExtraFlags = kFrameToolWindow; - - if (ulStyle & wxSTAY_ON_TOP) - ulPmFlags |= FCF_SYSMODAL; + if ((ulStyle & wxTHICK_FRAME) == 0) + ulPmFlags |= FCF_BORDER; + if (ulStyle & wxFRAME_TOOL_WINDOW) + ulExtraFlags = kFrameToolWindow; - if (ulPmFlags & ulTempFlags) - ulPmFlags = FCF_STANDARD; + if (ulStyle & wxSTAY_ON_TOP) + ulPmFlags |= FCF_SYSMODAL; + } // // Clear the visible flag, we always call show //