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
This commit is contained in:
Julian Smart
2004-04-20 22:17:24 +00:00
parent d1faf43f89
commit 960b193e59
10 changed files with 78 additions and 34 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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() )
{

View File

@@ -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.

View File

@@ -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

View File

@@ -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"

View File

@@ -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;

View File

@@ -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 <ole2.h>
#include <shellapi.h>
#include <commctrl.h>
#if _WIN32_WCE < 400
#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
#include <aygshell.h>
#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

View File

@@ -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);