From 960b193e59a7700570cfcae914ef2f698e6ba3b8 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 20 Apr 2004 22:17:24 +0000 Subject: [PATCH] Don't use wxUSE_POCKETPC_UI, determine appropriate UI from SDK defines. Now creates menubar at bottom of window for PPC. Window uses default position and size in PPC. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26889 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/menu.h | 4 ++-- include/wx/msw/wince/setup.h | 6 +++++- include/wx/toolbar.h | 2 +- src/common/framecmn.cpp | 2 +- src/msw/frame.cpp | 26 ++++++++++++++++++++------ src/msw/menu.cpp | 31 ++++++++++++++++++------------- src/msw/tbar95.cpp | 2 +- src/msw/toplevel.cpp | 11 +++++++++-- src/msw/wince/tbarwce.cpp | 14 +++++++------- src/msw/window.cpp | 14 ++++++++++++++ 10 files changed, 78 insertions(+), 34 deletions(-) diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h index 15232791d0..3d18cf67e0 100644 --- a/include/wx/msw/menu.h +++ b/include/wx/msw/menu.h @@ -172,7 +172,7 @@ public: virtual void Detach(); virtual void Attach(wxFrame *frame); -#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) // Under WinCE, a menubar is owned by the frame's toolbar void SetToolBar(wxToolBar* toolBar) { m_toolBar = toolBar; } wxToolBar* GetToolBar() const { return m_toolBar; } @@ -220,7 +220,7 @@ protected: // Not using a combined wxToolBar/wxMenuBar? then use // a commandbar in WinCE .NET to implement the // menubar, since there is no ::SetMenu function. -#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && defined(WIN32_PLATFORM_WFSP)) WXHWND m_commandBar; #endif diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index 6f3db8bc1e..edd5317f25 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -1079,7 +1079,11 @@ // So if you're using WinCE .NET, and wxUSE_POCKETPC_UI is 0, // you will be able to create separate toolbars and menubars, // but _not_ the combined toolbar/menubar. -#define wxUSE_POCKETPC_UI 1 + +// NOW OBSOLETE: we test WIN32_PLATFORM_PSPC and WIN32_PLATFORM_WFSP +// instead + +// #define wxUSE_POCKETPC_UI 1 // ---------------------------------------------------------------------------- // obsolete settings diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index ff1ae8a51f..736e3b19b7 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -123,7 +123,7 @@ enum #else // wxUSE_TOOLBAR_NATIVE #if defined(__WXUNIVERSAL__) #include "wx/univ/toolbar.h" - #elif defined(__WXMSW__) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI)) + #elif defined(__WXMSW__) && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP))) #include "wx/msw/tbar95.h" #elif defined(__WXWINCE__) #include "wx/msw/wince/tbarwce.h" diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 74b8205590..f451627440 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -156,7 +156,7 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ - (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI)) + (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP))) wxToolBar *toolbar = GetToolBar(); if ( toolbar && toolbar->IsShown() ) { diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 45130000d1..6c5aaef10e 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -320,7 +320,7 @@ void wxFrame::PositionStatusBar() void wxFrame::AttachMenuBar(wxMenuBar *menubar) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (!GetToolBar()) { wxToolBar* toolBar = new wxToolBar(this, -1, @@ -330,6 +330,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); + } #endif wxFrameBase::AttachMenuBar(menubar); @@ -342,7 +356,7 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) } else // set new non NULL menu bar { -#if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if !defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)) // Can set a menubar several times. if ( menubar->GetHMenu() ) { @@ -405,7 +419,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) if (show) { #if wxUSE_TOOLBAR -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) // TODO: hide commandbar #else wxToolBar *theToolBar = GetToolBar(); @@ -450,7 +464,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) else { #if wxUSE_TOOLBAR -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) // TODO: show commandbar #else wxToolBar *theToolBar = GetToolBar(); @@ -496,7 +510,7 @@ bool wxFrame::ShowFullScreen(bool show, long style) wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) // We may already have a toolbar from calling SetMenuBar. if (GetToolBar()) return GetToolBar(); @@ -514,7 +528,7 @@ void wxFrame::PositionToolBar() wxToolBar *toolbar = GetToolBar(); if ( toolbar && toolbar->IsShown() ) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) // We want to do something different in WinCE, because // the toolbar should be associated with the commandbar, // and not an independent window. diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 881f980179..385c7fb320 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -676,13 +676,13 @@ void wxMenuBar::Init() { m_eventHandler = this; m_hMenu = 0; -#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) m_toolBar = NULL; #endif // Not using a combined wxToolBar/wxMenuBar? then use // a commandbar in WinCE .NET just to implement the // menubar. -#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)) m_commandBar = NULL; #endif } @@ -716,7 +716,7 @@ wxMenuBar::~wxMenuBar() { // In Windows CE (not .NET), the menubar is always associated // with a toolbar, which destroys the menu implicitly. -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (GetToolBar()) GetToolBar()->SetMenuBar(NULL); #else @@ -724,7 +724,7 @@ wxMenuBar::~wxMenuBar() // which happens if we're attached to a frame if (m_hMenu && !IsAttached()) { -#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)) ::DestroyWindow((HWND) m_commandBar); m_commandBar = (WXHWND) NULL; #else @@ -743,12 +743,12 @@ void wxMenuBar::Refresh() { wxCHECK_RET( IsAttached(), wxT("can't refresh unattached menubar") ); -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (GetToolBar()) { CommandBar_DrawMenuBar((HWND) GetToolBar()->GetHWND(), 0); } -#elif defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#elif defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)) if (m_commandBar) DrawMenuBar((HWND) m_commandBar); #else @@ -762,7 +762,7 @@ WXHMENU wxMenuBar::Create() // since you have to use resources. // We'll have to find another way to add a menu // by changing/adding menu items to an existing menu. -#if defined(__WXWINCE__) && _WIN32_WCE < 400 +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if ( m_hMenu != 0 ) return m_hMenu; @@ -998,7 +998,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) if ( IsAttached() ) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (!GetToolBar()) return FALSE; TBBUTTON tbButton; @@ -1052,7 +1052,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) if ( IsAttached() ) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (!GetToolBar()) return FALSE; TBBUTTON tbButton; @@ -1103,7 +1103,7 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( IsAttached() ) { -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) if (GetToolBar()) { if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0)) @@ -1170,10 +1170,14 @@ void wxMenuBar::Attach(wxFrame *frame) { wxMenuBarBase::Attach(frame); -#if defined(__WXWINCE__) && _WIN32_WCE >= 400 +#if defined(__WXWINCE__) if (!m_hMenu) this->Create(); -#if wxUSE_POCKETPC_UI +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) + + // No idea why this was here, but it seems to be obsolete. + // Remove after testing with other WinCE combinations - April 2004 +#if 0 if (GetToolBar()) { HWND hCommandBar = (HWND) GetToolBar()->GetHWND(); @@ -1182,6 +1186,7 @@ void wxMenuBar::Attach(wxFrame *frame) wxLogLastError(wxT("CommandBar_InsertMenubarEx")); } } +#endif #else if (!m_commandBar) m_commandBar = (WXHWND) CommandBar_Create(wxGetInstance(), (HWND) frame->GetHWND(), NewControlId()); @@ -1196,7 +1201,7 @@ void wxMenuBar::Attach(wxFrame *frame) } } #endif - // wxUSE_POCKETPC_UI + // PSPC/WFSP #endif // __WXWINCE__ && _WIN32_WCE >= 400 diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index ab987ad5a3..d439d680f4 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -39,7 +39,7 @@ #include "wx/control.h" #endif -#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI)) +#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(WIN32_PLATFORM_PSPC) && defined(WIN32_PLATFORM_WFSP))) #include "wx/toolbar.h" #include "wx/sysopt.h" diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 3ad3dc4c45..e1195914b9 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -414,7 +414,13 @@ bool wxTopLevelWindowMSW::CreateFrame(const wxString& title, WXDWORD exflags; WXDWORD flags = MSWGetCreateWindowFlags(&exflags); - return MSWCreate(wxCanvasClassName, title, pos, size, flags, exflags); + wxSize sz(size); +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) + // Always expand to fit the screen in PocketPC or SmartPhone + sz = wxDefaultSize; +#endif + + return MSWCreate(wxCanvasClassName, title, pos, sz, flags, exflags); } bool wxTopLevelWindowMSW::Create(wxWindow *parent, @@ -807,12 +813,13 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return FALSE; } - +#ifndef __WXWINCE__ // update appearance immediately if ( !::DrawMenuBar(GetHwnd()) ) { wxLogLastError(_T("DrawMenuBar")); } +#endif #endif // !__WXMICROWIN__ return TRUE; diff --git a/src/msw/wince/tbarwce.cpp b/src/msw/wince/tbarwce.cpp index 746b2280f9..6ef10da2e7 100644 --- a/src/msw/wince/tbarwce.cpp +++ b/src/msw/wince/tbarwce.cpp @@ -41,7 +41,7 @@ // Use the WinCE-specific toolbar only if we're either compiling // with a WinCE earlier than 4, or we wish to emulate a PocketPC-style UI -#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) #include "wx/toolbar.h" @@ -56,7 +56,7 @@ #include #include #include -#if _WIN32_WCE < 400 +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) #include #endif #include "wx/msw/wince/missing.h" @@ -249,17 +249,14 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB if (m_menuBar) m_menuBar->SetToolBar(this); -#if _WIN32_WCE >= 400 - HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); - SetHWND((WXHWND) hWnd); -#else +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) // Create the menubar. SHMENUBARINFO mbi; memset (&mbi, 0, sizeof (SHMENUBARINFO)); mbi.cbSize = sizeof (SHMENUBARINFO); mbi.hwndParent = (HWND) GetParent()->GetHWND(); -#if wxUSE_SMARTPHONE +#if defined(WIN32_PLATFORM_WFSP) mbi.nToolBarId = 5002; #else mbi.nToolBarId = 5000; @@ -276,6 +273,9 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB } SetHWND((WXHWND) mbi.hwndMB); +#else + HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); + SetHWND((WXHWND) hWnd); #endif // install wxWindows window proc for this window diff --git a/src/msw/window.cpp b/src/msw/window.cpp index b7c5b66709..48b20868d0 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3059,12 +3059,26 @@ bool wxWindowMSW::MSWGetCreateWindowCoords(const wxPoint& pos, // level window in some smart way which we can't do, but we can // guess a reasonably good size for a new window just as well // ourselves + + // However, on PocketPC devices, we must use the default + // size if possible. +#ifdef _WIN32_WCE + if (size.x == -1) + w = CW_USEDEFAULT; + else + w = size.x; + if (size.y == -1) + h = CW_USEDEFAULT; + else + h = size.y; +#else if ( size.x == -1 || size.y == -1) { nonDefault = true; } w = WidthDefault(size.x); h = HeightDefault(size.y); +#endif AdjustForParentClientOrigin(x, y); -- 2.45.2