From ec5f0c24123fe801fb82b69771c171c0b9d064fc Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Sat, 19 Mar 2005 12:06:56 +0000
Subject: [PATCH] Added wxDialog::GetToolBar for PocketPC Added note about
 creating installers for PPC

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/changes.txt          |  2 ++
 docs/latex/wx/dialog.tex  | 10 ++++++++++
 docs/latex/wx/wxmsw.tex   | 38 ++++++++++++++++++++++++++++++++++++--
 include/wx/msw/dialog.h   | 23 ++++++++++++++++++++++-
 include/wx/msw/toplevel.h |  5 -----
 src/msw/dialog.cpp        | 29 +++++++++++++++++++++++++++++
 src/msw/toplevel.cpp      | 34 ----------------------------------
 src/msw/wince/tbarwce.cpp |  2 +-
 8 files changed, 100 insertions(+), 43 deletions(-)

diff --git a/docs/changes.txt b/docs/changes.txt
index 0f6ce4a398..5a64ce5bcd 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -61,6 +61,8 @@ wxWinCE:
 - Sends wxEVT_HIBERNATE event.
 - Now fakes wxEVT_ACTIVATE_APP to be symmetrical with wxEVT_HIBERNATE.
 - Added wxTE_CAPITALIZE for CAPEDIT controls.
+- wxDialog::GetToolBar can be used if you need to add buttons
+  to the dialog's toolbar.
 
 2.5.4
 -----
diff --git a/docs/latex/wx/dialog.tex b/docs/latex/wx/dialog.tex
index 37da8f7112..2fb1789b78 100644
--- a/docs/latex/wx/dialog.tex
+++ b/docs/latex/wx/dialog.tex
@@ -242,6 +242,16 @@ a code to the application.
 
 Returns the title of the dialog box.
 
+\membersection{wxDialog::GetToolBar}\label{wxdialoggettoolbar}
+
+\constfunc{wxToolBar*}{GetToolBar}{\void}
+
+On PocketPC, a dialog is automatically provided with an empty toolbar. GetToolBar
+allows you to access the toolbar and add tools to it. Removing tools and adding
+arbitrary controls are not currently supported.
+
+This function is not available on any other platform.
+
 \membersection{wxDialog::Iconize}\label{wxdialogiconized}
 
 \func{void}{Iconize}{\param{const bool}{ iconize}}
diff --git a/docs/latex/wx/wxmsw.tex b/docs/latex/wx/wxmsw.tex
index 4f22b9b3ae..d936a5733e 100644
--- a/docs/latex/wx/wxmsw.tex
+++ b/docs/latex/wx/wxmsw.tex
@@ -176,7 +176,7 @@ intended to co-exist with the main application frame.
 \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
+An empty menubar/toolbar 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,
@@ -193,8 +193,16 @@ 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.
+\item For speed, colours are not remapped to the system colours as they are
+in wxMSW. Provide the tool bitmaps either with the correct system button background,
+or with transparency (for example, using XPMs).
 \end{itemize}
 
+Unlike in all other ports, a wxDialog has a wxToolBar, automatically created
+for you. You may either leave it blank, or access it with wxDialog::GetToolBar
+and add buttons, then calling wxToolBar::Realize. You cannot set or recreate
+the toolbar.
+
 \wxheading{Menubars and toolbars in Smartphone}
 
 On Smartphone, there are only two menu buttons, so a menubar is simulated
@@ -227,6 +235,32 @@ This section is currently incomplete.
 
 You can use the help controller wxWinceHelpController which controls
 simple {\tt .htm} files, usually installed in the Windows directory.
+See the Windows CE reference for how to format the HTML files.
+
+\subsubsection{Installing your PocketPC and Smartphone applications}
+
+To install your application, you need to build a CAB file using
+the parameters defined in a special .inf file. The CabWiz program
+in your SDK will compile the CAB file from the .inf file and
+files that it specifies.
+
+For delivery, you can simply ask the user to copy the CAB file to the
+device and execute the CAB file using File Explorer. Or, you can
+write a program for the desktop PC that will find the ActiveSync
+Application Manager and install the CAB file on the device,
+which is obviously much easier for the user.
+
+Here are some links that may help.
+
+\itemsep=0pt
+\begin{itemize}
+\item A setup builder that takes CABs and builds a setup program is at \urlref{http://www.eskimo.com/~scottlu/win/index.html}{http://www.eskimo.com/~scottlu/win/index.html}.
+\item Sample installation files can be found in {\tt Windows CE Tools/wce420/POCKET PC 2003/Samples/Win32/AppInst}.
+\item An installer generator using wxPython can be found at \urlref{http://ppcquicksoft.iespana.es/ppcquicksoft/myinstall.html}{http://ppcquicksoft.iespana.es/ppcquicksoft/myinstall.html}.
+\item Miscellaneous Windows CE resources can be found at \urlref{http://www.orbworks.com/pcce/resources.html}{http://www.orbworks.com/pcce/resources.html}.
+\item Installer creation instructions with a setup.exe for installing to PPC can be found at \urlref{http://www.pocketpcdn.com/articles/creatingsetup.html}{http://www.pocketpcdn.com/articles/creatingsetup.html}.
+\item Microsoft instructions are at \urlref{http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnce30/html/appinstall30.asp?frame=true&hidetoc=true}{http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnce30/html/appinstall30.asp?frame=true&hidetoc=true}.
+\end{itemize}
 
 \subsubsection{Remaining issues}
 
@@ -245,7 +279,7 @@ icons, should be implemented. This will be quite straightforward.
 and the remaining area, by calling SHSipInfo. We also may need to be able to show and hide
 the SIP programmatically, with SHSipPreference. See also the {\it Input Dialogs} topic in
 the {\it Programming Windows CE} guide for more on this, and how to have dialogs
-show the SIP automatically using the WC_SIPREF control.
+show the SIP automatically using the WC\_SIPREF control.
 \item {\bf Drawing.} The "Life!" demo shows some droppings being left on the window,
 indicating that drawing works a bit differently between desktop and mobile versions of
 Win32.
diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h
index f89e7ef11a..319cd2bcc4 100644
--- a/include/wx/msw/dialog.h
+++ b/include/wx/msw/dialog.h
@@ -22,6 +22,10 @@ extern WXDLLEXPORT_DATA(const wxChar*) wxDialogNameStr;
 
 class WXDLLEXPORT wxDialogModalData;
 
+#if wxUSE_TOOLBAR && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
+class WXDLLEXPORT wxToolBar;
+#endif
+
 // Dialog boxes
 class WXDLLEXPORT wxDialog : public wxDialogBase
 {
@@ -59,6 +63,20 @@ public:
     // may be called to terminate the dialog with the given return code
     virtual void EndModal(int retCode);
 
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+    // create main toolbar by calling OnCreateToolBar()
+    virtual wxToolBar* CreateToolBar(long style = -1,
+                                     wxWindowID winid = wxID_ANY,
+                                     const wxString& name = wxToolBarNameStr);
+    // return a new toolbar
+    virtual wxToolBar *OnCreateToolBar(long style,
+                                       wxWindowID winid,
+                                       const wxString& name );
+
+    // get the main toolbar
+    wxToolBar *GetToolBar() const { return m_dialogToolBar; }
+#endif
+
     // implementation only from now on
     // -------------------------------
 
@@ -123,10 +141,13 @@ private:
     wxWindow*   m_oldFocus;
     bool        m_endModalCalled; // allow for closing within InitDialog
 
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+    wxToolBar*  m_dialogToolBar;
+#endif
+
     // this pointer is non-NULL only while the modal event loop is running
     wxDialogModalData *m_modalData;
 
-
     DECLARE_DYNAMIC_CLASS(wxDialog)
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(wxDialog)
diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h
index 377a446cce..2033fb0d4e 100644
--- a/include/wx/msw/toplevel.h
+++ b/include/wx/msw/toplevel.h
@@ -165,11 +165,6 @@ protected:
     void ReloadAllButtons();
 #endif // __SMARTPHONE__ && __WXWINCE__
 
-    // Empty menubar for dialogs
-#ifdef __POCKETPC__
-    WXHWND                   m_menuBarHWND;
-#endif
-
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW)
 };
diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp
index a42c6494aa..33f2cbf86f 100644
--- a/src/msw/dialog.cpp
+++ b/src/msw/dialog.cpp
@@ -51,6 +51,10 @@
     #include "wx/msw/wince/resources.h"
 #endif // __SMARTPHONE__ && __WXWINCE__
 
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+#include "wx/toolbar.h"
+#endif
+
 // ----------------------------------------------------------------------------
 // wxWin macros
 // ----------------------------------------------------------------------------
@@ -160,6 +164,9 @@ void wxDialog::Init()
     m_isShown = false;
     m_modalData = NULL;
     m_endModalCalled = false;
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+    m_dialogToolBar = NULL;
+#endif
 }
 
 bool wxDialog::Create(wxWindow *parent,
@@ -187,6 +194,9 @@ bool wxDialog::Create(wxWindow *parent,
 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
     SetLeftMenu(wxID_OK, _("OK"));
 #endif
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+    CreateToolBar();
+#endif
 
     return true;
 }
@@ -457,6 +467,25 @@ bool wxDialog::DoOK()
 }
 #endif
 
+#if wxUSE_TOOLBAR && defined(__POCKETPC__)
+// create main toolbar by calling OnCreateToolBar()
+wxToolBar* wxDialog::CreateToolBar(long style, wxWindowID winid, const wxString& name)
+{
+    m_dialogToolBar = OnCreateToolBar(style, winid, name);
+
+    return m_dialogToolBar;
+}
+
+// return a new toolbar
+wxToolBar *wxDialog::OnCreateToolBar(long style,
+                                       wxWindowID winid,
+                                       const wxString& name)
+{
+    return new wxToolMenuBar(this, winid,
+                         wxDefaultPosition, wxDefaultSize,
+                         style, name);
+}                                        
+#endif
 
 // ---------------------------------------------------------------------------
 // dialog window proc
diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp
index 09e60871b1..f5ae3f72e8 100644
--- a/src/msw/toplevel.cpp
+++ b/src/msw/toplevel.cpp
@@ -148,10 +148,6 @@ 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
@@ -419,27 +415,6 @@ 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__
@@ -588,15 +563,6 @@ 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
diff --git a/src/msw/wince/tbarwce.cpp b/src/msw/wince/tbarwce.cpp
index c2d6df75b0..33f429e306 100644
--- a/src/msw/wince/tbarwce.cpp
+++ b/src/msw/wince/tbarwce.cpp
@@ -414,7 +414,7 @@ bool wxToolMenuBar::Realize()
 
                 wxBitmap bmpToUse = bmp;
 
-                if (bmp.GetWidth() < 16 || bmp.GetHeight() < 16)
+                if (bmp.GetWidth() < 16 || bmp.GetHeight() < 16 || bmp.GetMask() != NULL)
                 {
                     wxMemoryDC memDC;
                     wxBitmap b(16,16);
-- 
2.50.0

