X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/960b193e59a7700570cfcae914ef2f698e6ba3b8..6726a6b09748c707351987da56226ac0316d1a00:/src/msw/frame.cpp?ds=inline diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 6c5aaef10e..efc6a5c630 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -131,7 +131,7 @@ wxEND_FLAGS( wxFrameStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") wxBEGIN_PROPERTIES_TABLE(wxFrame) - wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) + wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style @@ -190,13 +190,15 @@ bool wxFrame::Create(wxWindow *parent, const wxString& name) { if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) - return FALSE; + return false; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); - wxModelessWindows.Append(this); +#ifdef __SMARTPHONE__ + SetLeftMenu(wxID_EXIT, _("Done")); +#endif - return TRUE; + return true; } wxFrame::~wxFrame() @@ -282,7 +284,7 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, wxWindowID id, const wxString& name) { - wxStatusBar *statusBar = NULL; + wxStatusBar *statusBar wxDUMMY_INITIALIZE(NULL); #if wxUSE_NATIVE_STATUSBAR if ( !UsesNativeStatusBar() ) @@ -320,7 +322,31 @@ void wxFrame::PositionStatusBar() void wxFrame::AttachMenuBar(wxMenuBar *menubar) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) +#if defined(__SMARTPHONE__) + + wxMenu *autoMenu = NULL; + + if( menubar->GetMenuCount() == 1 ) + { + autoMenu = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar->GetMenu(0)); + SetRightMenu(wxID_ANY, menubar->GetLabelTop(0), autoMenu); + } + else + { + autoMenu = new wxMenu; + + for( size_t n = 0; n < menubar->GetMenuCount(); n++ ) + { + wxMenu *item = menubar->GetMenu(n); + wxString label = menubar->GetLabelTop(n); + wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item); + autoMenu->Append(wxID_ANY, label, new_item); + } + + SetRightMenu(wxID_ANY, _("Menu"), autoMenu); + } + +#elif defined(WINCE_WITHOUT_COMMANDBAR) if (!GetToolBar()) { wxToolBar* toolBar = new wxToolBar(this, -1, @@ -330,20 +356,20 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) SetToolBar(toolBar); menubar->SetToolBar(toolBar); } - // Now adjust size for menu bar - int menuHeight = 26; - - //When the main window is created using CW_USEDEFAULT the height of the - // is created is not taken into account). So we resize the window after - // if a menubar is present - { - RECT rc; - ::GetWindowRect((HWND) GetHWND(), &rc); - // adjust for menu / titlebar height - rc.bottom -= (2*menuHeight-1); - - MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); - } + // Now adjust size for menu bar + int menuHeight = 26; + + //When the main window is created using CW_USEDEFAULT the height of the + // is created is not taken into account). So we resize the window after + // if a menubar is present + { + RECT rc; + ::GetWindowRect((HWND) GetHWND(), &rc); + // adjust for menu / titlebar height + rc.bottom -= (2*menuHeight-1); + + MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); + } #endif wxFrameBase::AttachMenuBar(menubar); @@ -356,7 +382,7 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) } else // set new non NULL menu bar { -#if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)) +#if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR) // Can set a menubar several times. if ( menubar->GetHMenu() ) { @@ -419,7 +445,8 @@ bool wxFrame::ShowFullScreen(bool show, long style) if (show) { #if wxUSE_TOOLBAR -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) + +#if defined(WINCE_WITH_COMMANDBAR) // TODO: hide commandbar #else wxToolBar *theToolBar = GetToolBar(); @@ -464,7 +491,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) else { #if wxUSE_TOOLBAR -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) +#if defined(WINCE_WITHOUT_COMMANDBAR) // TODO: show commandbar #else wxToolBar *theToolBar = GetToolBar(); @@ -510,7 +537,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) +#if defined(WINCE_WITHOUT_COMMANDBAR) // We may already have a toolbar from calling SetMenuBar. if (GetToolBar()) return GetToolBar(); @@ -528,7 +555,7 @@ void wxFrame::PositionToolBar() wxToolBar *toolbar = GetToolBar(); if ( toolbar && toolbar->IsShown() ) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) +#if defined(WINCE_WITHOUT_COMMANDBAR) // We want to do something different in WinCE, because // the toolbar should be associated with the commandbar, // and not an independent window. @@ -547,6 +574,18 @@ void wxFrame::PositionToolBar() } #endif // wxUSE_STATUSBAR + int x = 0; + int y = 0; +#if defined(WINCE_WITH_COMMANDBAR) + // We're using a commandbar - so we have to allow for it. + if (GetMenuBar() && GetMenuBar()->GetCommandBar()) + { + RECT rect; + ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); + y = rect.bottom - rect.top; + } +#endif + int tx, ty; int tw, th; toolbar->GetPosition(&tx, &ty); @@ -577,8 +616,8 @@ void wxFrame::PositionToolBar() // Optimise such that we don't have to always resize the toolbar // when the frame changes, otherwise we'll get a lot of flicker. - bool heightChanging = TRUE; - bool widthChanging = TRUE; + bool heightChanging wxDUMMY_INITIALIZE(true); + bool widthChanging wxDUMMY_INITIALIZE(true); if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) { @@ -602,7 +641,7 @@ void wxFrame::PositionToolBar() } if (tx != 0 || ty != 0 || widthChanging || heightChanging) - toolbar->SetSize(0, 0, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS); + toolbar->SetSize(x, y, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS); #endif // __WXWINCE__ } @@ -795,6 +834,23 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id) PositionToolBar(); #endif // wxUSE_TOOLBAR +#if defined(WINCE_WITH_COMMANDBAR) + // Position the menu command bar + if (GetMenuBar() && GetMenuBar()->GetCommandBar()) + { + RECT rect; + ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); + wxSize clientSz = GetClientSize(); + + if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) ) + { + wxLogLastError(wxT("MoveWindow")); + } + + } +#endif + + processed = wxWindow::HandleSize(x, y, id); } @@ -824,6 +880,14 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) } #endif // wxUSE_MENUS_NATIVE +#ifdef __SMARTPHONE__ + // handle here commands from Smartphone menu bar + if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) ) + { + return true; + } +#endif // __SMARTPHONE__ + if ( ProcessCommand(id) ) { return TRUE; @@ -969,3 +1033,45 @@ bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) return GetEventHandler()->ProcessEvent(event); } + +// ---------------------------------------------------------------------------- +// wxFrame size management: we exclude the areas taken by menu/status/toolbars +// from the client area, so the client area is what's really available for the +// frame contents +// ---------------------------------------------------------------------------- + +// get the origin of the client area in the client coordinates +wxPoint wxFrame::GetClientAreaOrigin() const +{ + wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); + +#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ + (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) + wxToolBar *toolbar = GetToolBar(); + if ( toolbar && toolbar->IsShown() ) + { + int w, h; + toolbar->GetSize(&w, &h); + + if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) + { + pt.x += w; + } + else + { + pt.y += h; + } + } +#endif // wxUSE_TOOLBAR + +#if defined(WINCE_WITH_COMMANDBAR) + if (GetMenuBar() && GetMenuBar()->GetCommandBar()) + { + RECT rect; + ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); + pt.y += (rect.bottom - rect.top); + } +#endif + + return pt; +}