wxmsw.tex
来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 423 行 · 第 1/2 页
TEX
423 行
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: wxmsw.tex
%% Purpose: wxMSW and wxWinCE platform specific informations
%% Author: wxWidgets Team
%% Modified by:
%% Created:
%% RCS-ID: $Id: wxmsw.tex,v 1.30 2006/05/28 10:03:03 MR Exp $
%% Copyright: (c) wxWidgets Team
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{wxMSW port}\label{wxmswport}
wxMSW is a port of wxWidgets for the Windows platforms
including Windows 95, 98, ME, 2000, NT, XP in ANSI and
Unicode mode (for Windows 95 through the MSLU extension
library). wxMSW ensures native look and feel for XP
as well when using wxWidgets version 2.3.3 or higher.
wxMSW can be compile with a great variety of compilers
including MS VC++, Borland 5.5, MinGW32, Cygwin and
Watcom as well as cross-compilation with a Linux hosted
MinGW32 tool chain.
For further information, please see the files in docs/msw
in the distribution.
\subsection{wxWinCE}\label{wxwince}
wxWinCE is the name given to wxMSW when compiled on Windows CE devices;
most of wxMSW is common to Win32 and Windows CE but there are
some simplifications, enhancements, and differences in
behaviour.
For building instructions, see docs/msw/wince in the
distribution, also the section about Visual Studio 2005 project
files below. The rest of this section documents issues you
need to be aware of when programming for Windows CE devices.
\subsubsection{General issues for wxWinCE programming}
Mobile applications generally have fewer features and
simpler user interfaces. Simply omit whole sizers, static
lines and controls in your dialogs, and use comboboxes instead
of listboxes where appropriate. You also need to reduce
the amount of spacing used by sizers, for which you can
use a macro such as this:
\begin{verbatim}
#if defined(__WXWINCE__)
#define wxLARGESMALL(large,small) small
#else
#define wxLARGESMALL(large,small) large
#endif
// Usage
topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) );
\end{verbatim}
There is only ever one instance of a Windows CE application running,
and wxWidgets will take care of showing the current instance and
shutting down the second instance if necessary.
You can test the return value of wxSystemSettings::GetScreenType()
for a qualitative assessment of what kind of display is available,
or use wxGetDisplaySize() if you need more information.
You can also use wxGetOsVersion to test for a version of Windows CE at
run-time (see the next section). However, because different builds
are currently required to target different kinds of device, these
values are hard-wired according to the build, and you cannot
dynamically adapt the same executable for different major Windows CE
platforms. This would require a different approach to the way
wxWidgets adapts its behaviour (such as for menubars) to suit the
style of device.
See the "Life!" example (demos/life) for an example of
an application that has been tailored for PocketPC and Smartphone use.
{\bf Note:} don't forget to have this line in your .rc file, as for
desktop Windows applications:
\begin{verbatim}
#include "wx/msw/wx.rc"
\end{verbatim}
\subsubsection{Testing for WinCE SDKs}
Use these preprocessor symbols to test for the different types of device or SDK:
\begin{twocollist}\itemsep=0pt
\twocolitem{\_\_SMARTPHONE\_\_}{Generic mobile devices with phone buttons and a small display}
\twocolitem{\_\_PDA\_\_}{Generic mobile devices with no phone}
\twocolitem{\_\_HANDHELDPC\_\_}{Generic mobile device with a keyboard}
\twocolitem{\_\_WXWINCE\_\_}{Microsoft-powered Windows CE devices, whether PocketPC, Smartphone or Standard SDK}
\twocolitem{WIN32\_PLATFORM\_WFSP}{Microsoft-powered smartphone}
\twocolitem{\_\_POCKETPC\_\_}{Microsoft-powered PocketPC devices with touch-screen}
\twocolitem{\_\_WINCE\_STANDARDSDK\_\_}{Microsoft-powered Windows CE devices, for generic Windows CE applications}
\twocolitem{\_\_WINCE\_NET\_\_}{Microsoft-powered Windows CE .NET devices (\_WIN32\_WCE is 400 or greater)}
\end{twocollist}
wxGetOsVersion will return these values:
\begin{twocollist}\itemsep=0pt
\twocolitem{wxWINDOWS\_POCKETPC}{The application is running under PocketPC.}
\twocolitem{wxWINDOWS\_SMARTPHONE}{The application is running under Smartphone.}
\twocolitem{wxWINDOWS\_CE}{The application is running under Windows CE (built with the Standard SDK).}
\end{twocollist}
\subsubsection{Window sizing in wxWinCE}
Top level windows (dialogs, frames) are created always full-screen. Fit() of sizers will not rescale top
level windows but instead will scale window content.
If the screen orientation changes, the windows will automatically be resized
so no further action needs to be taken (unless you want to change the layout
according to the orientation, which you could detect in idle time, for example).
When input panel (SIP) is shown, top level windows (frames and dialogs) resize
accordingly (see \helpref{wxTopLevelWindow::HandleSettingChange}{wxtoplevelwindowhandlesettingchange}).
\subsubsection{Closing top-level windows in wxWinCE}
You won't get a wxCloseEvent when the user clicks on the X in the titlebar
on Smartphone and PocketPC; the window is simply hidden instead. However the system may send the
event to force the application to close down.
\subsubsection{Hibernation in wxWinCE}
Smartphone and PocketPC will send a wxEVT\_HIBERNATE to the application object in low
memory conditions. Your application should release memory and close dialogs,
and wake up again when the next wxEVT\_ACTIVATE or wxEVT\_ACTIVATE\_APP message is received.
(wxEVT\_ACTIVATE\_APP is generated whenever a wxEVT\_ACTIVATE event is received
in Smartphone and PocketPC, since these platforms do not support WM\_ACTIVATEAPP.)
\subsubsection{Hardware buttons in wxWinCE}
Special hardware buttons are sent to a window via the wxEVT\_HOTKEY event
under Smartphone and PocketPC. You should first register each required button with \helpref{wxWindow::RegisterHotKey}{wxwindowregisterhotkey},
and unregister the button when you're done with it. For example:
\begin{verbatim}
win->RegisterHotKey(0, wxMOD_WIN, WXK_SPECIAL1);
win->UnregisterHotKey(0);
\end{verbatim}
You may have to register the buttons in a wxEVT\_ACTIVATE event handler
since other applications will grab the buttons.
There is currently no method of finding out the names of the special
buttons or how many there are.
\subsubsection{Dialogs in wxWinCE}
PocketPC dialogs have an OK button on the caption, and so you should generally
not repeat an OK button on the dialog. You can add a Cancel button if necessary, but some dialogs
simply don't offer you the choice (the guidelines recommend you offer an Undo facility
to make up for it). When the user clicks on the OK button, your dialog will receive
a wxID\_OK event by default. If you wish to change this, call \helpref{wxDialog::SetAffirmativeId}{wxdialogsetaffirmativeid}
with the required identifier to be used. Or, override \helpref{wxDialog::DoOK}{wxdialogdook} (return false to
have wxWidgets simply call Close to dismiss the dialog).
Smartphone dialogs do {\it not} have an OK button on the caption, and are closed
using one of the two menu buttons. You need to assign these using \helpref{wxTopLevelWindow::SetLeftMenu}{wxtoplevelwindowsetleftmenu}
and \helpref{wxTopLevelWindow::SetRightMenu}{wxtoplevelwindowsetrightmenu}, for example:
\begin{verbatim}
#ifdef __SMARTPHONE__
SetLeftMenu(wxID_OK);
SetRightMenu(wxID_CANCEL, _("Cancel"));
#elif defined(__POCKETPC__)
// No OK/Cancel buttons on PocketPC, OK on caption will close
#else
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxEXPAND | wxALL, 10 );
#endif
\end{verbatim}
For implementing property sheets (flat tabs), use a wxNotebook with wxNB\_FLAT|wxNB\_BOTTOM
and have the notebook left, top and right sides overlap the dialog by about 3 pixels
to eliminate spurious borders. You can do this by using a negative spacing in your
sizer Add() call. The cross-platform property sheet dialog \helpref{wxPropertySheetDialog}{wxpropertysheetdialog} is
provided, to show settings in the correct style on PocketPC and on other platforms.
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}
\wxheading{Menubars and toolbars in PocketPC}
On PocketPC, a frame must always have a menubar, even if it's empty.
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,
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 after Realize is called 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,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?