mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-21 13:26:08 +08:00
Implemented PocketPC menubar/toolbar as wxToolMenuBar derived
from wxToolBar, solving the problem of how normal toolbars can co-exist with combined ones. Tidied up WinCE toolbar code. Implemented wxToolBar as 'dummy' toolbar under Smartphone. Dialogs now show an empty menubar to hide inactive one underneath. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32853 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -186,14 +186,14 @@ XLife is (c) 1989 by Jon Bennett et al.")),
|
||||
sizer->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 5 );
|
||||
#endif // wxUSE_STATLINE
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__))
|
||||
sizer->Add( CreateButtonSizer(wxOK), 0, wxCENTRE | wxALL, 10 );
|
||||
#endif
|
||||
|
||||
// activate
|
||||
SetSizer(sizer);
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__))
|
||||
sizer->SetSizeHints(this);
|
||||
sizer->Fit(this);
|
||||
Centre(wxBOTH | wxCENTRE_ON_SCREEN);
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ LifeFrame::LifeFrame() :
|
||||
menuFile->Append(wxID_NEW, wxGetStockLabel(wxID_NEW), _("Start a new game"));
|
||||
menuFile->Append(wxID_OPEN, wxGetStockLabel(wxID_OPEN), _("Open an existing Life pattern"));
|
||||
menuFile->Append(ID_SAMPLES, _("&Sample game..."), _("Select a sample configuration"));
|
||||
#ifndef __WXWINCE__
|
||||
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__))
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(wxID_EXIT, wxGetStockLabel(wxID_EXIT, true, _T("Alt-X")), _("Quit this program"));
|
||||
|
||||
|
||||
@@ -241,6 +241,11 @@ with \helpref{wxFrame::SetToolBar}{wxframesettoolbar}, the frame will manage the
|
||||
position and adjust the return value from \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize} to
|
||||
reflect the available space for application windows.
|
||||
|
||||
Under Pocket PC, you should {\it always} use this function for creating the toolbar
|
||||
to be managed by the frame, so that wxWidgets can use a combined
|
||||
menubar and toolbar. Where you manage your own toolbars, create a wxToolBar
|
||||
as usual.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar},\rtfsp
|
||||
|
||||
@@ -23,19 +23,18 @@ wxToolBarBase\\
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/toolbar.h> (to allow wxWidgets to select an appropriate toolbar class)\\
|
||||
<wx/tbarbase.h> (the base class)\\
|
||||
<wx/tbarmsw.h> (the non-Windows 95 Windows toolbar class)\\
|
||||
<wx/tbar95.h> (the Windows 95/98 toolbar class)\\
|
||||
<wx/tbarbase.h> (the base class)
|
||||
|
||||
\wxheading{Remarks}
|
||||
|
||||
You may also create a toolbar that is managed by the frame, by
|
||||
calling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.
|
||||
calling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}. Under Pocket PC,
|
||||
you should {\it always} use this function for creating the toolbar
|
||||
to be managed by the frame, so that wxWidgets can use a combined
|
||||
menubar and toolbar. Where you manage your own toolbars, create a wxToolBar
|
||||
as usual.
|
||||
|
||||
Due to the use of native toolbars on the various platforms, certain adaptions will
|
||||
often have to be made in order to get optimal look on all platforms as some platforms
|
||||
ignore the values for explicit placement and use their own layout and the meaning
|
||||
of a "separator" is a vertical line under Windows95 vs. simple space under GTK etc.
|
||||
The meaning of a "separator" is a vertical line under Windows and simple space under GTK+.
|
||||
|
||||
{\bf wxToolBar95:} Note that this toolbar paints tools to reflect system-wide colours.
|
||||
If you use more than 16 colours in your tool bitmaps, you may wish to suppress
|
||||
|
||||
+37
-6
@@ -136,16 +136,38 @@ provided, to show settings in the correct style on PocketPC and on other platfor
|
||||
Notifications (bubble HTML text with optional buttons and links) will also be
|
||||
implemented in the future for PocketPC.
|
||||
|
||||
Modeless dialogs probably don't make sense for PocketPC and Smartphone, since
|
||||
frames and dialogs are normally full-screen, and a modeless dialog is normally
|
||||
intended to co-exist with the main application frame.
|
||||
|
||||
\subsubsection{Menubars and toolbars in wxWinCE}
|
||||
|
||||
Menubars and toolbars can only be implemented using a combined control,
|
||||
but you can use the same syntax as before; wxWidgets will combine the menubar
|
||||
and toolbar.
|
||||
\wxheading{Menubars and toolbars in PocketPC}
|
||||
|
||||
On PocketPC, a frame must always have a menubar, even if it's empty.
|
||||
An empty menubar is automatically provided for dialogs, to hide
|
||||
any existing menubar for the duration of the dialog.
|
||||
|
||||
Menubars and toolbars are implemented using a combined control,
|
||||
but you can use essentially the usual wxWidgets API; wxWidgets will combine the menubar
|
||||
and toolbar. However, there are some restrictions:
|
||||
|
||||
\itemsep=0pt
|
||||
\begin{itemize}
|
||||
\item You must create the frame's primary toolbar with wxFrame::CreateToolBar,
|
||||
because this uses the special wxToolMenuBar class (derived from wxToolBar)
|
||||
to implement the combined toolbar and menubar. Otherwise, you can create and manage toolbars
|
||||
using the wxToolBar class as usual, for example to implement an optional
|
||||
formatting toolbar above the menubar as Pocket Word does. But don't assign
|
||||
a wxToolBar to a frame using SetToolBar - you should always use CreateToolBar
|
||||
for the main frame toolbar.
|
||||
\item Deleting and adding tools to wxToolMenuBar is not supported.
|
||||
\end{itemize}
|
||||
|
||||
\wxheading{Menubars and toolbars in Smartphone}
|
||||
|
||||
On Smartphone, there are only two menu buttons, so a menubar is simulated
|
||||
using a nested menu on the right menu button. Toolbars are simply ignored on
|
||||
using a nested menu on the right menu button. Any toolbars are simply ignored on
|
||||
Smartphone.
|
||||
|
||||
\subsubsection{Closing windows in wxWinCE}
|
||||
@@ -160,9 +182,15 @@ wxID\_EXIT, it will do the right thing.
|
||||
|
||||
\subsubsection{Control differences on wxWinCE}
|
||||
|
||||
This section is to be written.
|
||||
These controls are missing from wxWinCE:
|
||||
|
||||
Can someone remind us why wxChoice was rewritten for Smartphone?
|
||||
\itemsep=0pt
|
||||
\begin{itemize}
|
||||
\item {\bf wxCheckListBox} This can be implemented using a wxListCtrl in report mode
|
||||
with checked/unchecked images.
|
||||
\end{itemize}
|
||||
|
||||
This section is currently incomplete.
|
||||
|
||||
\subsubsection{Online help in wxWinCE}
|
||||
|
||||
@@ -197,6 +225,9 @@ Win32.
|
||||
the correct size on the emulator, but too small on a VGA Pocket Loox device.
|
||||
\item {\bf wxStaticLine.} Lines don't show up, and the documentation suggests that
|
||||
missing styles are implemented with WM\_PAINT.
|
||||
\item {\bf wxCheckListBox.} This class needs to be implemented in terms of a wxListCtrl
|
||||
in report mode, using icons for checkbox states. This is necessary because owner-draw listboxes
|
||||
are not supported on Windows CE.
|
||||
\item {\bf OK button.} We should allow the OK button on a dialog to be optional, perhaps
|
||||
by using wxCLOSE\_BOX to indicate when the OK button should be displayed.
|
||||
\item {\bf Dynamic adaptation.} We should probably be using run-time tests more
|
||||
|
||||
@@ -165,6 +165,11 @@ protected:
|
||||
void ReloadAllButtons();
|
||||
#endif // __SMARTPHONE__ && __WXWINCE__
|
||||
|
||||
// Empty menubar for dialogs
|
||||
#ifdef __POCKETPC__
|
||||
WXHWND m_menuBarHWND;
|
||||
#endif
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW)
|
||||
};
|
||||
|
||||
@@ -20,13 +20,74 @@
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
|
||||
// Smartphones don't have toolbars, so use a dummy class
|
||||
#ifdef __SMARTPHONE__
|
||||
|
||||
class WXDLLEXPORT wxToolBar : public wxToolBarBase
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
wxToolBar() { Init(); }
|
||||
wxToolBar() { }
|
||||
|
||||
wxToolBar(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxNO_BORDER | wxTB_HORIZONTAL,
|
||||
const wxString& name = wxToolBarNameStr)
|
||||
{
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxNO_BORDER | wxTB_HORIZONTAL,
|
||||
const wxString& name = wxToolBarNameStr);
|
||||
|
||||
// override/implement base class virtuals
|
||||
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
|
||||
virtual bool Realize() { return true; }
|
||||
|
||||
protected:
|
||||
// implement base class pure virtuals
|
||||
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
|
||||
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
|
||||
|
||||
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
|
||||
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
|
||||
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
|
||||
|
||||
virtual wxToolBarToolBase *CreateTool(int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
const wxBitmap& bmpDisabled,
|
||||
wxItemKind kind,
|
||||
wxObject *clientData,
|
||||
const wxString& shortHelp,
|
||||
const wxString& longHelp);
|
||||
virtual wxToolBarToolBase *CreateTool(wxControl *control);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
||||
DECLARE_NO_COPY_CLASS(wxToolBar)
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
// For __POCKETPC__
|
||||
|
||||
#include "wx/msw/tbar95.h"
|
||||
|
||||
class WXDLLEXPORT wxToolMenuBar : public wxToolBar
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
wxToolMenuBar() { Init(); }
|
||||
|
||||
wxToolMenuBar(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
@@ -47,32 +108,15 @@ public:
|
||||
const wxString& name = wxToolBarNameStr,
|
||||
wxMenuBar* menuBar = NULL);
|
||||
|
||||
virtual ~wxToolBar();
|
||||
virtual ~wxToolMenuBar();
|
||||
|
||||
// override/implement base class virtuals
|
||||
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
|
||||
|
||||
virtual bool Realize();
|
||||
|
||||
virtual void SetToolBitmapSize(const wxSize& size);
|
||||
virtual wxSize GetToolSize() const;
|
||||
|
||||
virtual void SetRows(int nRows);
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
virtual void SetWindowStyleFlag(long style);
|
||||
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
void SetFocus() {}
|
||||
|
||||
static WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height);
|
||||
|
||||
// Return HMENU for the menu associated with the commandbar
|
||||
WXHMENU GetHMenu();
|
||||
@@ -97,10 +141,6 @@ protected:
|
||||
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
|
||||
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
|
||||
|
||||
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
|
||||
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
|
||||
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
|
||||
|
||||
virtual wxToolBarToolBase *CreateTool(int id,
|
||||
const wxString& label,
|
||||
const wxBitmap& bmpNormal,
|
||||
@@ -111,34 +151,18 @@ protected:
|
||||
const wxString& longHelp);
|
||||
virtual wxToolBarToolBase *CreateTool(wxControl *control);
|
||||
|
||||
// override WndProc mainly to process WM_SIZE
|
||||
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
// return the appropriate size and flags for the toolbar control
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||
|
||||
// handlers for various events
|
||||
void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
// should be called whenever the toolbar size changes
|
||||
void UpdateSize();
|
||||
|
||||
// the total number of toolbar elements
|
||||
size_t m_nButtons;
|
||||
|
||||
// the tool the cursor is in
|
||||
wxToolBarToolBase *m_pInTool;
|
||||
|
||||
// The menubar associated with this toolbar
|
||||
wxMenuBar* m_menuBar;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
||||
DECLARE_NO_COPY_CLASS(wxToolBar)
|
||||
DECLARE_DYNAMIC_CLASS(wxToolMenuBar)
|
||||
DECLARE_NO_COPY_CLASS(wxToolMenuBar)
|
||||
};
|
||||
|
||||
#endif
|
||||
// __SMARTPHONE__
|
||||
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
#endif
|
||||
|
||||
@@ -489,9 +489,15 @@ wxToolBar* wxFrameBase::OnCreateToolBar(long style,
|
||||
wxWindowID id,
|
||||
const wxString& name)
|
||||
{
|
||||
#if defined(__WXWINCE__) && defined(__POCKETPC__)
|
||||
return new wxToolMenuBar(this, id,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style, name);
|
||||
#else
|
||||
return new wxToolBar(this, id,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxFrameBase::SetToolBar(wxToolBar *toolbar)
|
||||
|
||||
+1
-1
@@ -357,7 +357,7 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar)
|
||||
#elif defined(WINCE_WITHOUT_COMMANDBAR)
|
||||
if (!GetToolBar())
|
||||
{
|
||||
wxToolBar* toolBar = new wxToolBar(this, wxID_ANY,
|
||||
wxToolMenuBar* toolBar = new wxToolMenuBar(this, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxBORDER_NONE | wxTB_HORIZONTAL,
|
||||
wxToolBarNameStr, menubar);
|
||||
|
||||
+6
-2
@@ -716,9 +716,13 @@ wxMenuBar::~wxMenuBar()
|
||||
{
|
||||
// In Windows CE (not .NET), the menubar is always associated
|
||||
// with a toolbar, which destroys the menu implicitly.
|
||||
#if defined(WINCE_WITHOUT_COMMANDBAR)
|
||||
#if defined(WINCE_WITHOUT_COMMANDBAR) && defined(__POCKETPC__)
|
||||
if (GetToolBar())
|
||||
GetToolBar()->SetMenuBar(NULL);
|
||||
{
|
||||
wxToolMenuBar* toolMenuBar = wxDynamicCast(GetToolBar(), wxToolMenuBar);
|
||||
if (toolMenuBar)
|
||||
toolMenuBar->SetMenuBar(NULL);
|
||||
}
|
||||
#else
|
||||
// we should free Windows resources only if Windows doesn't do it for us
|
||||
// which happens if we're attached to a frame
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
#include "wx/control.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)))
|
||||
#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && !defined(__SMARTPHONE__)
|
||||
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/sysopt.h"
|
||||
|
||||
@@ -148,6 +148,10 @@ void wxTopLevelWindowMSW::Init()
|
||||
#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
|
||||
m_MenuBarHWND = 0;
|
||||
#endif
|
||||
#ifdef __POCKETPC__
|
||||
// A dummy menubar for dialogs
|
||||
m_menuBarHWND = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
|
||||
@@ -415,6 +419,27 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
|
||||
::SetWindowText(GetHwnd(), title);
|
||||
}
|
||||
|
||||
#ifdef __POCKETPC__
|
||||
// Create an empty menubar so that we don't see the menubar underneath
|
||||
SHMENUBARINFO mbi;
|
||||
|
||||
memset (&mbi, 0, sizeof (SHMENUBARINFO));
|
||||
mbi.cbSize = sizeof (SHMENUBARINFO);
|
||||
mbi.hwndParent = (HWND) GetParent()->GetHWND();
|
||||
mbi.nToolBarId = 5000;
|
||||
mbi.nBmpId = 0;
|
||||
mbi.cBmpImages = 0;
|
||||
mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR;
|
||||
mbi.hInstRes = wxGetInstance();
|
||||
|
||||
if (!SHCreateMenuBar(&mbi))
|
||||
{
|
||||
wxFAIL_MSG( _T("SHCreateMenuBar failed") );
|
||||
}
|
||||
|
||||
m_menuBarHWND = (WXHWND) mbi.hwndMB;
|
||||
#endif
|
||||
|
||||
SubclassWin(m_hWnd);
|
||||
|
||||
#ifdef __SMARTPHONE__
|
||||
@@ -563,6 +588,15 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
|
||||
|
||||
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
|
||||
{
|
||||
#ifdef __POCKETPC__
|
||||
// Destroy the dummy menubar for dialogs
|
||||
if (m_menuBarHWND)
|
||||
{
|
||||
::DestroyWindow((HWND) m_menuBarHWND);
|
||||
m_menuBarHWND = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// after destroying an owned window, Windows activates the next top level
|
||||
// window in Z order but it may be different from our owner (to reproduce
|
||||
// this simply Alt-TAB to another application and back before closing the
|
||||
|
||||
+90
-447
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user