\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%
-\section{What is wxWindows?}
+\section{What is wxWidgets?}\label{whatis}
-wxWindows is a C++ framework providing GUI (Graphical User
-Interface) and other facilities on more than one platform. Version 2 currently
-supports MS Windows (16-bit, Windows 95 and Windows NT), Unix with GTK+, Unix with Motif,
-and Mac. An OS/2 port is in progress.
+wxWidgets is a C++ framework providing GUI (Graphical User
+Interface) and other facilities on more than one platform. Version 2 and higher
+currently support all desktop versions of MS Windows, Unix with GTK+ 1.x or 2.x,
+Unix with Motif, Unix with just X11, Unix with DirectFB, Mac OS X, OS/2.
-wxWindows was originally developed at the Artificial Intelligence
+wxWidgets was originally developed at the Artificial Intelligence
Applications Institute, University of Edinburgh, for internal use,
-and was first made publicly available in 1993.
+and was first made publicly available in 1992.
Version 2 is a vastly improved version written and maintained by
-Julian Smart, Robert Roebling, Vadim Zeitlin and many others.
+Julian Smart, Robert Roebling, Vadim Zeitlin, Vaclav Slavik and many others.
-This manual discusses wxWindows in the context of multi-platform
-development.\helpignore{For more detail on the wxWindows version 2.0 API
-(Application Programming Interface) please refer to the separate
-wxWindows reference manual.}
+This manual contains a class reference and topic overviews.
+For a selection of wxWidgets tutorials, please see the documentation page on the \urlref{wxWidgets web site}{http://www.wxwidgets.org}.
Please note that in the following, ``MS Windows" often refers to all
-platforms related to Microsoft Windows, including 16-bit and 32-bit
+platforms related to Microsoft Windows, including 32-bit and 64-bit
variants, unless otherwise stated. All trademarks are acknowledged.
-\section{Why another cross-platform development tool?}
+\section{Why another cross-platform development tool?}\label{why}
-wxWindows was developed to provide a cheap and flexible way to maximize
+wxWidgets was developed to provide a cheap and flexible way to maximize
investment in GUI application development. While a number of commercial
class libraries already existed for cross-platform development,
none met all of the following criteria:
\item support for a wide range of compilers.
\end{enumerate}
-Since wxWindows was started, several other free or almost-free GUI frameworks have
-emerged. However, none has the range of features, flexibility, documentation and the
-well-established development team that wxWindows has.
-
-As open source software, wxWindows has
-benefited from comments, ideas, bug fixes, enhancements and the sheer
-enthusiasm of users. This gives wxWindows a
-certain advantage over its commercial competitors (and over free libraries
-without an independent development team), plus a robustness against
-the transience of one individual or company. This openness and
-availability of source code is especially important when the future of
-thousands of lines of application code may depend upon the longevity of
-the underlying class library.
-
-Version 2 goes much further than previous versions in terms of generality and features,
-allowing applications to be produced
-that are often indistinguishable from those produced using single-platform
-toolkits such as Motif, GTK+ and MFC.
-
-The importance of using a platform-independent class library cannot be
-overstated, since GUI application development is very time-consuming,
-and sustained popularity of particular GUIs cannot be guaranteed.
-Code can very quickly become obsolete if it addresses the wrong
-platform or audience. wxWindows helps to insulate the programmer from
-these winds of change. Although wxWindows may not be suitable for
-every application (such as an OLE-intensive program), it provides access to most of the functionality a
-GUI program normally requires, plus many extras such as network programming,
-PostScript output, and HTML rendering; and it can of course be extended as needs dictate. As a bonus, it provides
-a far cleaner and easier programming interface than the native
-APIs. Programmers may find it worthwhile to use wxWindows even if they
-are developing on only one platform.
-
-It is impossible to sum up the functionality of wxWindows in a few paragraphs, but
+Since wxWidgets was started, several other free or almost-free
+GUI frameworks have emerged. However, none has the range of
+features, flexibility, documentation and the well-established
+development team that wxWidgets has.
+
+As open source software, wxWidgets has benefited from comments,
+ideas, bug fixes, enhancements and the sheer enthusiasm of
+users. This gives wxWidgets a certain advantage over its
+commercial competitors (and over free libraries without an
+independent development team), plus a robustness against the
+transience of one individual or company. This openness and
+availability of source code is especially important when the
+future of thousands of lines of application code may depend upon
+the longevity of the underlying class library.
+
+Version 2 goes much further than previous versions in terms of
+generality and features, allowing applications to be produced
+that are often indistinguishable from those produced using
+single-platform toolkits such as Motif, GTK+ and MFC.
+
+The importance of using a platform-independent class library
+cannot be overstated, since GUI application development is very
+time-consuming, and sustained popularity of particular GUIs
+cannot be guaranteed. Code can very quickly become obsolete if
+it addresses the wrong platform or audience. wxWidgets helps to
+insulate the programmer from these winds of change. Although
+wxWidgets may not be suitable for every application (such as an
+OLE-intensive program), it provides access to most of the
+functionality a GUI program normally requires, plus many extras
+such as network programming, PostScript output, and HTML
+rendering; and it can of course be extended as needs dictate.
+As a bonus, it provides a far cleaner and easier programming
+interface than the native APIs. Programmers may find it
+worthwhile to use wxWidgets even if they are developing on only
+one platform.
+
+It is impossible to sum up the functionality of wxWidgets in a few paragraphs, but
here are some of the benefits:
\begin{itemize}\itemsep=0pt
\item You get the source.
\item Available on a variety of popular platforms.
\item Works with almost all popular C++ compilers and Python.
-\item Over 50 example programs.
+\item Over 70 example programs.
\item Over 1000 pages of printable and on-line documentation.
-\item Includes Tex2RTF, to allow you to produce your own documentation
-in Windows Help, HTML and Word RTF formats.
\item Simple-to-use, object-oriented API.
\item Flexible event system.
\item Graphics calls include lines, rounded rectangles, splines, polylines, etc.
them to the clipboard.
\item An API for invoking help from applications.
\item Ready-to-use HTML window (supporting a subset of HTML).
-\item Dialog Editor for building dialogs.
\item Network support via a family of socket and protocol classes.
\item Support for platform independent image processing.
\item Built-in support for many file formats (BMP, PNG, JPEG, GIF, XPM, PNM, PCX).
+\item Includes Tex2RTF, to allow you to produce your own documentation
+in Windows Help, HTML and Word RTF formats.
\end{itemize}
-\begin{comment}
-\section{Changes from version 2.0}\label{versionchanges20}
-
-These are a few of the differences between versions 2.0 and 2.2.
-
-Removals:
-
-\begin{itemize}\itemsep=0pt
-\item GTK 1.0 no longer supported.
-\end{itemize}
-
-Additions and changes:
-
-\begin{itemize}\itemsep=0pt
-\item Corrected many classes to conform better to documented behaviour.
-\item Added handlers for more image formats (Now GIF, JPEG, PCX, BMP, XPM, PNG, PNM).
-\item Improved support for socket and network functions.
-\item Support for different national font encodings.
-\item Sizer based layout system.
-\item HTML widget and help system.
-\item Added some controls (e.g. wxSpinCtrl) and supplemented many.
-\item Many optical improvements to GTK port.
-\item Support for menu accelerators in GTK port.
-\item Enhanced and improved support for scrolling, including child windows.
-\item Complete rewrite of clipboard and drag and drop classes.
-\item Improved support for ODBC databases.
-\item Improved tab traversal in dialogs.
-\end{itemize}
-\end{comment}
-
-\section{wxWindows requirements}\label{requirements}
+\section{wxWidgets requirements}\label{requirements}
-To make use of wxWindows, you currently need one of the following setups.
+To make use of wxWidgets, you currently need one of the following setups.
(a) MS-Windows:
\begin{enumerate}\itemsep=0pt
-\item A 486 or higher PC running MS Windows.
-\item A Windows compiler: most are supported, but please see {\tt install.txt} for
-details. Supported compilers include Microsoft Visual C++ 4.0 or higher, Borland C++, Cygwin,
-Metrowerks CodeWarrior.
-\item At least 60 MB of disk space.
+\item A 32-bit or 64-bit PC running MS Windows.
+\item A Windows compiler: MS Visual C++ (embedded Visual C++ for wxWinCE
+port), Borland C++, Watcom C++, Cygwin, MinGW, Metrowerks CodeWarrior,
+Digital Mars C++. See {\tt install.txt} for details about compiler
+version supported.
\end{enumerate}
(b) Unix:
\begin{enumerate}\itemsep=0pt
-\item Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).
-\item Almost any Unix workstation, and one of: GTK+ 1.2, Motif 1.2 or higher, Lesstif.
-\item At least 60 MB of disk space.
+\item Almost any C++ compiler, including GNU C++ and many Unix vendors
+compilers such as Sun CC, HP-UX aCC or SGI mipsPro.
+\item Almost any Unix workstation, and one of: GTK+ 2.4 or higher (GTK+ 1.2.10
+may still be supported but wxGTK1 port is not maintained any longer and lacks
+many features of wxGTK2), Motif 1.2 or higher or Lesstif. If using the wxX11
+port, no such widget set is required.
\end{enumerate}
(c) Mac OS/Mac OS X:
\begin{enumerate}\itemsep=0pt
-\item A PowerPC Mac running Mac OS 8.6/9.x (eg. Classic) or Mac OS X 10.x.
-\item CodeWarrior 5.3, 6 or 7 for Classic Mac OS.
-\item The Apple Developer Tools (eg. GNU C++) or CodeWarrior 7 for Mac OS X.
-\item At least 60 MB of disk space.
+\item A PowerPC or Intel Mac running Mac OS X 10.3 or higher
+\item The Apple Developer Tools (eg. GNU C++) or MetroWerks CodeWarrior (not
+actively supported)
\end{enumerate}
-\section{Availability and location of wxWindows}
+Under all platforms it's recommended to have large amounts of free hard disk
+space. The exact amount needed depends on the port, compiler and build
+configurations but to give an example, a debug build of the library may take up
+to 500MB.
-\winhelponly{wxWindows is available by anonymous FTP and World Wide Web
-from ftp://www.remstar.com/pub/wxwin and/or http://www.wxwindows.org.}
-\winhelpignore{wxWindows is available by anonymous FTP and World Wide Web
-from \urlref{ftp://www.remstar.com/pub/wxwin}{ftp://www.remstar.com/pub/wxwin}
-and/or \urlref{http://www.wxwindows.org}{http://www.wxwindows.org}.}
+\section{Availability and location of wxWidgets}\label{where}
-You can also buy a CD-ROM using the form on the Web site.
+\winhelponly{wxWidgets is available by anonymous FTP and World Wide Web
+from ftp://biolpc22.york.ac.uk/pub and/or http://www.wxwidgets.org.}
+\winhelpignore{wxWidgets is available by anonymous FTP and World Wide Web
+from \urlref{ftp://biolpc22.york.ac.uk/pub}{ftp://biolpc22.york.ac.uk/pub}
+and/or \urlref{http://www.wxwidgets.org}{http://www.wxwidgets.org}.}
-\section{Acknowledgments}
+You can also buy a CD-ROM using the form on the Web site.
-Thanks are due to AIAI for being willing to release the original version of
-wxWindows into the public domain, and to our patient partners.
+\section{Acknowledgements}\label{acknowledgements}
+
+The following is the list of the core, active developers of wxWidgets which keep
+it running and have provided an invaluable, extensive and high-quality amount of
+changes over the many of years of wxWidgets' life:
+
+\begin{description}\itemsep=0pt
+\item Julian Smart
+\item Vadim Zeitlin
+\item Robert Roebling
+\item Robin Dunn
+\item Stefan Csomor
+\item Vaclav Slavik
+\item Paul Cornett
+\item Wlodzimierz `ABX' Skiba
+\item Chris Elliott
+\item David Elliott
+\item Kevin Hock
+\item Stefan Neis
+\item Michael Wetherell
+\end{description}
-We would particularly like to thank the following for their contributions to wxWindows, and the many others who have been involved in
-the project over the years. Apologies for any unintentional omissions from this list.
+We would particularly like to thank the following peoples for their contributions
+to wxWidgets, and the many others who have been involved in the project over the years.
+Apologies for any unintentional omissions from this alphabetic list:
-Yiorgos Adamopoulos, Jamshid Afshar, Alejandro Aguilar-Sierra, AIAI, Patrick Albert, Karsten Ballueder, Michael Bedward, Kai Bendorf, Yura Bidus, Keith
-Gary Boyce, Chris Breeze, Pete Britton, Ian Brown, C. Buckley, Dmitri Chubraev, Robin Corbet, Cecil Coupe, Andrew Davison, Neil Dudman, Robin
-Dunn, Hermann Dunkel, Jos van Eijndhoven, Tom Felici, Thomas Fettig, Matthew Flatt, Pasquale Foggia, Josep Fortiana, Todd Fries, Dominic Gallagher,
-Guillermo Rodriguez Garcia, Wolfram Gloger, Norbert Grotz, Stefan Gunter, Bill Hale, Patrick Halke, Stefan Hammes, Guillaume Helle, Harco de Hilster, Cord Hockemeyer, Markus
-Holzem, Olaf Klein, Leif Jensen, Bart Jourquin, Guilhem Lavaux, Jan Lessner, Nicholas Liebmann, Torsten Liermann, Per Lindqvist, Thomas Runge, Tatu
-M\"{a}nnist\"{o}, Scott Maxwell, Thomas Myers, Oliver Niedung, Stefan Neis, Hernan Otero, Ian Perrigo, Timothy Peters, Giordano Pezzoli, Harri Pasanen, Thomaso Paoletti,
-Garrett Potts, Marcel Rasche, Robert Roebling, Dino Scaringella, Jobst Schmalenbach, Arthur Seaton, Paul Shirley, Vaclav Slavik, Stein Somers, Petr Smilauer, Neil Smith,
-Kari Syst\"{a}, Arthur Tetzlaff-Deas, Jonathan Tonberg, Jyrki Tuomi, David Webster, Janos Vegh, Andrea Venturoli, Vadim Zeitlin, Xiaokun Zhu, Edward Zimmermann.
+Yiorgos Adamopoulos, Jamshid Afshar, Alejandro Aguilar-Sierra, AIAI,
+Patrick Albert, Karsten Ballueder, Mattia Barbon, Michael Bedward,
+Kai Bendorf, Yura Bidus, Keith Gary Boyce, Chris Breeze, Pete Britton,
+Ian Brown, C. Buckley, Marco Cavallini, Dmitri Chubraev, Robin Corbet, Cecil Coupe,
+Andrew Davison, Gilles Depeyrot, Neil Dudman, Hermann Dunkel, Jos van Eijndhoven,
+Tom Felici, Thomas Fettig, Matthew Flatt, Pasquale Foggia, Josep Fortiana, Todd Fries,
+Dominic Gallagher, Guillermo Rodriguez Garcia, Wolfram Gloger, Norbert Grotz,
+Stefan Gunter, Bill Hale, Patrick Halke, Stefan Hammes, Guillaume Helle,
+Harco de Hilster, Cord Hockemeyer, Markus Holzem, Olaf Klein, Leif Jensen,
+Bart Jourquin, Guilhem Lavaux, Ron Lee, Jan Lessner, Nicholas Liebmann,
+Torsten Liermann, Per Lindqvist, Francesco Montorsi, Thomas Runge, Tatu M\"{a}nnist\"{o},
+Scott Maxwell, Thomas Myers, Oliver Niedung, Ryan Norton, Hernan Otero,
+Ian Perrigo, Timothy Peters, Giordano Pezzoli, Harri Pasanen, Thomaso Paoletti,
+Garrett Potts, Marcel Rasche, Dino Scaringella, Jobst Schmalenbach, Arthur Seaton,
+Paul Shirley, Stein Somers, Petr Smilauer, Neil Smith, Kari Syst\"{a}, George Tasker,
+Arthur Tetzlaff-Deas, Jonathan Tonberg, Jyrki Tuomi, Janos Vegh, Andrea Venturoli,
+David Webster, Otto Wyss, Xiaokun Zhu, Edward Zimmermann.
+
+Many thanks also to AIAI for being willing to release the original version of
+wxWidgets into the public domain, and to our patient partners.
`Graphplace', the basis for the wxGraphLayout library, is copyright Dr. Jos
T.J. van Eijndhoven of Eindhoven University of Technology. The code has
-been used in wxGraphLayout with his permission.
+been used in wxGraphLayout (not in wxWidgets anymore) with his permission.
We also acknowledge the author of XFIG, the excellent Unix drawing tool,
from the source of which we have borrowed some spline drawing code.
suitability of this software for any purpose. It is provided ``as is''
without express or implied warranty.}
-\chapter{Multi-platform development with wxWindows}\label{multiplat}
+\chapter{Multi-platform development with wxWidgets}\label{multiplat}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%
-This chapter describes the practical details of using wxWindows. Please
+This chapter describes the practical details of using wxWidgets. Please
see the file install.txt for up-to-date installation instructions, and
changes.txt for differences between versions.
-\section{Include files}
+\section{Include files}\label{includefiles}
The main include file is {\tt "wx/wx.h"}; this includes the most commonly
-used modules of wxWindows.
+used modules of wxWidgets.
To save on compilation time, include only those header files relevant to the
source file. If you are using precompiled headers, you should include
The file {\tt "wx/wxprec.h"} includes {\tt "wx/wx.h"}. Although this incantation
may seem quirky, it is in fact the end result of a lot of experimentation,
-and several Windows compilers to use precompilation (those tested are Microsoft Visual C++, Borland C++
-and Watcom C++).
-
-Borland precompilation is largely automatic. Visual C++ requires specification of {\tt "wx/wxprec.h"} as
-the file to use for precompilation. Watcom C++ is automatic apart from the specification of
-the .pch file. Watcom C++ is strange in requiring the precompiled header to be used only for
-object files compiled in the same directory as that in which the precompiled header was created.
-Therefore, the wxWindows Watcom C++ makefiles go through hoops deleting and recreating
-a single precompiled header file for each module, thus preventing an accumulation of many
-multi-megabyte .pch files.
-
-\section{Libraries}
+and several Windows compilers to use precompilation which is largely automatic for
+compilers with necessary support. Currently it is used for Visual C++ (including
+embedded Visual C++), Borland C++, Open Watcom C++, Digital Mars C++
+and newer versions of GCC.
+Some compilers might need extra work from the application developer to set the
+build environment up as necessary for the support.
-The GTK and Motif ports of wxWindow can create either a static library or a shared
-library on most Unix or Unix-like systems. The static library is called libwx\_gtk.a
-and libwx\_motif.a whereas the name of the shared library is dependent on the
-system it is created on and the version you are using. The library name for the
-GTK version of wxWindows 2.2 on Linux and Solaris will be libwx\_gtk-2.2.so.0.0.0,
-on HP-UX, it will be libwx\_gtk-2.2.sl, on AIX just libwx\_gtk.a etc.
+\section{Libraries}\label{libraries}
-Under Windows, use the library wx.lib (release) or wxd.lib (debug) for stand-alone Windows
-applications, or wxdll.lib (wxdlld.lib) for creating DLLs.
+Most ports of wxWidgets can create either a static library or a shared
+library. wxWidgets can also be built in multilib and monolithic variants.
+See the \helpref{libraries list}{librarieslist} for more
+information on these.
-\section{Configuration}
+\section{Configuration}\label{configuration}
-Options are configurable in the file
+When using project files and makefiles directly to build wxWidgets,
+options are configurable in the file
\rtfsp{\tt "wx/XXX/setup.h"} where XXX is the required platform (such as msw, motif, gtk, mac). Some
settings are a matter of taste, some help with platform-specific problems, and
others can be set to minimize the size of the library. Please see the setup.h file
and {\tt install.txt} files for details on configuration.
-Under Unix (GTK and Motif) the corresponding setup.h files are generated automatically
-when configuring the wxWindows using the "configure" script. When using the RPM packages
-for installing wxWindows on Linux, a correct setup.h is shipped in the package and
+When using the 'configure' script to configure wxWidgets (on Unix and other platforms where
+configure is available), the corresponding setup.h files are generated automatically
+along with suitable makefiles. When using the RPM packages
+for installing wxWidgets on Linux, a correct setup.h is shipped in the package and
this must not be changed.
-\section{Makefiles}
+\section{Makefiles}\label{makefiles}
+
+On Microsoft Windows, wxWidgets has a different set of makefiles for each
+compiler, because each compiler's 'make' tool is slightly different.
+Popular Windows compilers that we cater for, and the corresponding makefile
+extensions, include: Microsoft Visual C++ (.vc), Borland C++ (.bcc),
+OpenWatcom C++ (.wat) and MinGW/Cygwin (.gcc). Makefiles are provided
+for the wxWidgets library itself, samples, demos, and utilities.
+
+On Linux, Mac and OS/2, you use the 'configure' command to
+generate the necessary makefiles. You should also use this method when
+building with MinGW/Cygwin on Windows.
-At the moment there is no attempt to make Unix makefiles and
-PC makefiles compatible, i.e. one makefile is required for
-each environment. The Unix ports use a sophisticated system based
-on the GNU autoconf tool and this system will create the
-makefiles as required on the respective platform. Although the
-makefiles are not identical in Windows, Mac and Unix, care has
-been taken to make them relatively similar so that moving from
-one platform to another will be painless.
+We also provide project files for some compilers, such as
+Microsoft VC++. However, we recommend using makefiles
+to build the wxWidgets library itself, because makefiles
+can be more powerful and less manual intervention is required.
-Sample makefiles for Unix (suffix .unx), MS C++ (suffix .DOS and .NT), Borland
-C++ (.BCC and .B32) and Symantec C++ (.SC) are included for the library, demos
-and utilities.
+On Windows using a compiler other than MinGW/Cygwin, you would
+build the wxWidgets library from the build/msw directory
+which contains the relevant makefiles.
-The controlling makefile for wxWindows is in the MS-Windows
-directory {\tt src/msw} for the different Windows compiler and
-in the build directory when using the Unix ports. The build
-directory can be chosen by the user. It is the directory in
-which the "configure" script is run. This can be the normal
-base directory (by running {\tt ./configure} there) or any other
-directory (e.g. {\tt ../configure} after creating a build-directory
-in the directory level above the base directory).
+On Windows using MinGW/Cygwin, and on Unix, MacOS X and OS/2, you invoke
+'configure' (found in the top-level of the wxWidgets source hierarchy),
+from within a suitable empty directory for containing makefiles, object files and
+libraries.
-Please see the platform-specific {\tt install.txt} file for further details.
+For details on using makefiles, configure, and project files,
+please see docs/xxx/install.txt in your distribution, where
+xxx is the platform of interest, such as msw, gtk, x11, mac.
-\section{Windows-specific files}
+\section{Windows-specific files}\label{windowsfiles}
-wxWindows application compilation under MS Windows requires at least two
-extra files, resource and module definition files.
+wxWidgets application compilation under MS Windows requires at least one
+extra file: a resource file.
\subsection{Resource file}\label{resources}
is the following statement:
\begin{verbatim}
-rcinclude "wx/msw/wx.rc"
+#include "wx/msw/wx.rc"
\end{verbatim}
-which includes essential internal wxWindows definitions. The resource script
+which includes essential internal wxWidgets definitions. The resource script
may also contain references to icons, cursors, etc., for example:
\begin{verbatim}
so programs that search your executable for icons (such
as the Program Manager) find your application icon first.}
-\subsection{Module definition file}
-
-A module definition file (extension DEF) is required for 16-bit applications, and
-looks like the following:
-
-\begin{verbatim}
-NAME Hello
-DESCRIPTION 'Hello'
-EXETYPE WINDOWS
-STUB 'WINSTUB.EXE'
-CODE PRELOAD MOVEABLE DISCARDABLE
-DATA PRELOAD MOVEABLE MULTIPLE
-HEAPSIZE 1024
-STACKSIZE 8192
-\end{verbatim}
-
-The only lines which will usually have to be changed per application are
-NAME and DESCRIPTION.
-
-\section{Allocating and deleting wxWindows objects}
+\section{Allocating and deleting wxWidgets objects}\label{allocatingobjects}
In general, classes derived from wxWindow must dynamically allocated
with {\it new} and deleted with {\it delete}. If you delete a window,
so you don't need to delete these descendants explicitly.
When deleting a frame or dialog, use {\bf Destroy} rather than {\bf delete} so
-that the wxWindows delayed deletion can take effect. This waits until idle time
+that the wxWidgets delayed deletion can take effect. This waits until idle time
(when all messages have been processed) to actually delete the window, to avoid
problems associated with the GUI sending events to deleted windows.
with delayed deletion.
If you decide to allocate a C++ array of objects (such as wxBitmap) that may
-be cleaned up by wxWindows, make sure you delete the array explicitly
-before wxWindows has a chance to do so on exit, since calling {\it delete} on
+be cleaned up by wxWidgets, make sure you delete the array explicitly
+before wxWidgets has a chance to do so on exit, since calling {\it delete} on
array members will cause memory problems.
wxColour can be created statically: it is not automatically cleaned
a drawing object that may be in use. Code that doesn't do this will probably work
fine on some platforms, and then fail under Windows.
-\section{Architecture dependency}
+\section{Architecture dependency}\label{architecturedependency}
A problem which sometimes arises from writing multi-platform programs is that
the basic C types are not defined the same on all platforms. This holds true
for both the length in bits of the standard types (such as int and long) as
well as their byte order, which might be little endian (typically
-on Intel computers) or big endian (typically on some Unix workstations). wxWindows
+on Intel computers) or big endian (typically on some Unix workstations). wxWidgets
defines types and macros that make it easy to write architecture independent
code. The types are:
as well).
The macros handling bit-swapping with respect to the applications endianness
-are described in the \helpref{Macros}{macros} section.
+are described in the \helpref{Byte order macros}{byteordermacros} section.
-\section{Conditional compilation}
+\section{Conditional compilation}\label{conditionalcompilation}
-One of the purposes of wxWindows is to reduce the need for conditional
+One of the purposes of wxWidgets is to reduce the need for conditional
compilation in source code, which can be messy and confusing to follow.
However, sometimes it is necessary to incorporate platform-specific
-features (such as metafile use under MS Windows). The symbols
-listed in the file {\tt symbols.txt} may be used for this purpose,
+features (such as metafile use under MS Windows). The \helpref{wxUSE\_*}{wxusedef}
+symbols listed in the file {\tt setup.h} may be used for this purpose,
along with any user-supplied ones.
-\section{C++ issues}
+\section{C++ issues}\label{cpp}
The following documents some miscellaneous C++ issues.
-\subsection{Templates}
+\subsection{Templates}\label{templates}
-wxWindows does not use templates since it is a notoriously unportable feature.
+wxWidgets does not use templates (except for some advanced features that
+are switched off by default) since it is a notoriously unportable feature.
-\subsection{RTTI}
+\subsection{RTTI}\label{rtti}
-wxWindows does not use run-time type information since wxWindows provides
+wxWidgets does not use C++ run-time type information since wxWidgets provides
its own run-time type information system, implemented using macros.
-\subsection{Type of NULL}
+\subsection{Type of NULL}\label{null}
Some compilers (e.g. the native IRIX cc) define NULL to be 0L so that
no conversion to pointers is allowed. Because of that, all these
-occurrences of NULL in the GTK port use an explicit conversion such
+occurrences of NULL in the GTK+ port use an explicit conversion such
as
{\small
\begin{verbatim}
wxWindow *my_window = (wxWindow*) NULL;
\end{verbatim}
-}
+}%
-It is recommended to adhere to this in all code using wxWindows as
+It is recommended to adhere to this in all code using wxWidgets as
this make the code (a bit) more portable.
-\subsection{Precompiled headers}
+\subsection{Precompiled headers}\label{precompiledheaders}
Some compilers, such as Borland C++ and Microsoft C++, support
precompiled headers. This can save a great deal of compiling time. The
recommended approach is to precompile {\tt "wx.h"}, using this
-precompiled header for compiling both wxWindows itself and any
-wxWindows applications. For Windows compilers, two dummy source files
+precompiled header for compiling both wxWidgets itself and any
+wxWidgets applications. For Windows compilers, two dummy source files
are provided (one for normal applications and one for creating DLLs)
to allow initial creation of the precompiled header.
is that to take advantage of the facility, you often need to include
more header files than would normally be the case. This means that
changing a header file will cause more recompilations (in the case of
-wxWindows, everything needs to be recompiled since everything includes {\tt "wx.h"}!)
+wxWidgets, everything needs to be recompiled since everything includes {\tt "wx.h"}!)
A related problem is that for compilers that don't have precompiled
headers, including a lot of header files slows down compilation
biased towards the precompiled headers facility available
in Microsoft C++.
-\section{File handling}
+\section{File handling}\label{filehandling}
When building an application which may be used under different
environments, one difficulty is coping with documents which may be
moved to different directories on other machines. Saving a file which
-has pointers to full pathnames is going to be inherently unportable. One
-approach is to store filenames on their own, with no directory
-information. The application searches through a number of locally
-defined directories to find the file. To support this, the class {\bf
-wxPathList} makes adding directories and searching for files easy, and
-the global function {\bf wxFileNameFromPath} allows the application to
-strip off the filename from the path if the filename must be stored.
-This has undesirable ramifications for people who have documents of the
-same name in different directories.
-
-As regards the limitations of DOS 8+3 single-case filenames versus
-unrestricted Unix filenames, the best solution is to use DOS filenames
-for your application, and also for document filenames {\it if} the user
-is likely to be switching platforms regularly. Obviously this latter
-choice is up to the application user to decide. Some programs (such as
-YACC and LEX) generate filenames incompatible with DOS; the best
-solution here is to have your Unix makefile rename the generated files
-to something more compatible before transferring the source to DOS.
-Transferring DOS files to Unix is no problem, of course, apart from EOL
-conversion for which there should be a utility available (such as
-dos2unix).
-
-See also the File Functions section of the reference manual for
-descriptions of miscellaneous file handling functions.
-
-\begin{comment}
-\chapter{Utilities supplied with wxWindows}\label{utilities}
-\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
-\setfooter{\thepage}{}{}{}{}{\thepage}%
+has pointers to full pathnames is going to be inherently unportable.
-A number of `extras' are supplied with wxWindows, to complement
-the GUI functionality in the main class library. These are found
-below the utils directory and usually have their own source, library
-and documentation directories. For other user-contributed packages,
-see the directory ftp://www.remstar.com/pub/wxwin/contrib, which is
-more easily accessed via the Contributions page on the Web site.
-
-\section{wxHelp}\label{wxhelp}
-
-wxHelp is a stand-alone program, written using wxWindows,
-for displaying hypertext help. It is necessary since not all target
-systems (notably X) supply an adequate
-standard for on-line help. wxHelp is modeled on the MS Windows help
-system, with contents, search and browse buttons, but does not reformat
-text to suit the size of window, as WinHelp does, and its input files
-are uncompressed ASCII with some embedded font commands and an .xlp
-extension. Most wxWindows documentation (user manuals and class
-references) is supplied in wxHelp format, and also in Windows Help
-format. The wxWindows 2.0 project will presently use an HTML widget
-in a new and improved wxHelp implementation, under X.
-
-Note that an application can be programmed to use Windows Help under
-MS Windows, and wxHelp under X. An alternative help viewer under X is
-Mosaic, a World Wide Web viewer that uses HTML as its native hypertext
-format. However, this is not currently integrated with wxWindows
-applications.
-
-wxHelp works in two modes---edit and end-user. In edit mode, an ASCII
-file may be marked up with different fonts and colours, and divided into
-sections. In end-user mode, no editing is possible, and the user browses
-principally by clicking on highlighted blocks.
-
-When an application invokes wxHelp, subsequent sections, blocks or
-files may be viewed using the same instance of wxHelp since the two
-programs are linked using wxWindows interprocess communication
-facilities. When the application exits, that application's instance of
-wxHelp may be made to exit also. See the {\bf wxHelpControllerBase} entry in the
-reference section for how an application controls wxHelp.
-
-\section{Tex2RTF}\label{textortf}
-
-Supplied with wxWindows is a utility called Tex2RTF for converting\rtfsp
-\LaTeX\ manuals to the following formats:
-
-\begin{description}
-\item[wxHelp]
-wxWindows help system format (XLP).
-\item[Linear RTF]
-Rich Text Format suitable for importing into a word processor.
-\item[Windows Help RTF]
-Rich Text Format suitable for compiling into a WinHelp HLP file with the
-help compiler.
-\item[HTML]
-HTML is the native format for Mosaic, the main hypertext viewer for
-the World Wide Web. Since it is freely available it is a good candidate
-for being the wxWindows help system under X, as an alternative to wxHelp.
-\end{description}
+One approach is to store filenames on their own, with no directory
+information. The application then searches into a list of standard
+paths (platform-specific) through the use of \helpref{wxStandardPaths}{wxstandardpaths}.
-Tex2RTF is used for the wxWindows manuals and can be used independently
-by authors wishing to create on-line and printed manuals from the same\rtfsp
-\LaTeX\ source. Please see the separate documentation for Tex2RTF.
+Eventually you may want to use also the \helpref{wxPathList}{wxpathlist} class.
-\section{wxTreeLayout}
+Nowadays the limitations of DOS 8+3 filenames doesn't apply anymore.
+Most modern operating systems allow at least 255 characters in the filename;
+the exact maximum length, as well as the characters allowed in the filenames,
+are OS-specific so you should try to avoid extremely long (> 255 chars) filenames
+and/or filenames with non-ANSI characters.
-This is a simple class library for drawing trees in a reasonably pretty
-fashion. It provides only minimal default drawing capabilities, since
-the algorithm is meant to be used for implementing custom tree-based
-tools.
+Another thing you need to keep in mind is that all Windows operating systems
+are case-insensitive, while Unix operating systems (Linux, Mac, etc) are
+case-sensitive.
-Directed graphs may also be drawn using this library, if cycles are
-removed before the nodes and arcs are passed to the algorithm.
+Also, for text files, different OSes use different End Of Lines (EOL).
+Windows uses CR+LF convention, Linux uses LF only, Mac CR only.
-Tree displays are used in many applications: directory browsers,
-hypertext systems, class browsers, and decision trees are a few
-possibilities.
+The \helpref{wxTextFile}{wxtextfile},\helpref{wxTextInputStream}{wxtextinputstream},
+\helpref{wxTextOutputStream}{wxtextoutputstream} classes help to abstract
+from these differences.
+Of course, there are also 3rd party utilities such as \tt{dos2unix} and \tt{unix2dos}
+which do the EOL conversions.
-See the separate manual and the directory utils/wxtree.
+See also the \helpref{File Functions}{filefunctions} section of the reference
+manual for the description of miscellaneous file handling functions.
-\end{comment}
+\chapter{Utilities and libraries supplied with wxWidgets}\label{utilities}
+\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
+\setfooter{\thepage}{}{}{}{}{\thepage}%
+
+In addition to the \helpref{wxWidgets libraries}{librarieslist}, some
+additional utilities are supplied in the \tt{utils} hierarchy.
+
+For other user-contributed packages, please see the Contributions page
+on the \urlref{wxWidgets Web site}{http://www.wxwidgets.org}.
+
+\begin{description}\itemsep=0pt
+\item[{\bf Helpview}]
+Helpview is a program for displaying wxWidgets HTML
+Help files. In many cases, you may wish to use the wxWidgets HTML
+Help classes from within your application, but this provides a
+handy stand-alone viewer. See \helpref{wxHTML Notes}{wxhtml} for more details.
+You can find it in {\tt samples/html/helpview}.
+\item[{\bf Tex2RTF}]
+Supplied with wxWidgets is a utility called Tex2RTF for converting\rtfsp
+\LaTeX\ manuals HTML, MS HTML Help, wxHTML Help, RTF, and Windows
+Help RTF formats. Tex2RTF is used for the wxWidgets manuals and can be used independently
+by authors wishing to create on-line and printed manuals from the same\rtfsp
+\LaTeX\ source. Please see the separate documentation for Tex2RTF.
+You can find it under {\tt utils/tex2rtf}.
+\item[{\bf Helpgen}]
+Helpgen takes C++ header files and generates a Tex2RTF-compatible
+documentation file for each class it finds, using comments as appropriate.
+This is a good way to start a reference for a set of classes.
+Helpgen can be found in {\tt utils/HelpGen}.
+\item[{\bf Emulator}]
+Xnest-based display emulator for X11-based PDA applications. On some
+systems, the Xnest window does not synchronise with the
+'skin' window. This program can be found in {\tt utils/emulator}.
+\end{description}
\chapter{Programming strategies}\label{strategies}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%
This chapter is intended to list strategies that may be useful when
-writing and debugging wxWindows programs. If you have any good tips,
+writing and debugging wxWidgets programs. If you have any good tips,
please submit them for inclusion here.
-\section{Strategies for reducing programming errors}
+\section{Strategies for reducing programming errors}\label{reducingerrors}
-\subsection{Use ASSERT}
+\subsection{Use ASSERT}\label{useassert}
-Although I haven't done this myself within wxWindows, it is good
-practice to use ASSERT statements liberally, that check for conditions that
-should or should not hold, and print out appropriate error messages.
-These can be compiled out of a non-debugging version of wxWindows
+It is good practice to use ASSERT statements liberally, that check for conditions
+that should or should not hold, and print out appropriate error messages.
+
+These can be compiled out of a non-debugging version of wxWidgets
and your application. Using ASSERT is an example of `defensive programming':
it can alert you to problems later on.
-\subsection{Use wxString in preference to character arrays}
+See \helpref{wxASSERT}{wxassert} for more info.
+
+\subsection{Use wxString in preference to character arrays}\label{usewxstring}
+
+Using \helpref{wxString}{wxstring} can be much safer and more convenient than using wxChar *.
-Using wxString can be much safer and more convenient than using char *.
-Again, I haven't practiced what I'm preaching, but I'm now trying to use
-wxString wherever possible. You can reduce the possibility of memory
-leaks substantially, and it is much more convenient to use the overloaded
-operators than functions such as strcmp. wxString won't add a significant
-overhead to your program; the overhead is compensated for by easier
-manipulation (which means less code).
+You can reduce the possibility of memory leaks substantially, and it is much more
+convenient to use the overloaded operators than functions such as \tt{strcmp}.
+wxString won't add a significant overhead to your program; the overhead is compensated
+for by easier manipulation (which means less code).
The same goes for other data types: use classes wherever possible.
-\section{Strategies for portability}
+\section{Strategies for portability}\label{portability}
-\subsection{Use relative positioning or constraints}
+\subsection{Use sizers}\label{usesizers}
Don't use absolute panel item positioning if you can avoid it. Different GUIs have
-very differently sized panel items. Consider using the constraint system, although this
-can be complex to program.
+very differently sized panel items. Consider using the \helpref{sizers}{sizeroverview} instead.
-Alternatively, you could use alternative .wrc (wxWindows resource files) on different
-platforms, with slightly different dimensions in each. Or space your panel items out
-to avoid problems.
+\subsection{Use wxWidgets resource files}\label{useresources}
-\subsection{Use wxWindows resource files}
-
-Use .wrc (wxWindows resource files) where possible, because they can be easily changed
-independently of source code. Bitmap resources can be set up to load different
-kinds of bitmap depending on platform (see the section on resource files).
+Use .xrc (wxWidgets resource files) where possible, because they can be easily changed
+independently of source code. See the \helpref{XRC overview}{xrcoverview} for more info.
\section{Strategies for debugging}\label{debugstrategies}
-\subsection{Positive thinking}
+\subsection{Positive thinking}\label{positivethinking}
It is common to blow up the problem in one's imagination, so that it seems to threaten
weeks, months or even years of work. The problem you face may seem insurmountable:
isn't painful at the time. Try not to worry -- there are many more important
things in life.
-\subsection{Simplify the problem}
+\subsection{Simplify the problem}\label{simplifyproblem}
Reduce the code exhibiting the problem to the smallest program possible
that exhibits the problem. If it is not possible to reduce a large and
to the problem. In some cases though, such as memory leaks or wrong
deallocation, this can still give totally spurious results!
-\subsection{Use a debugger}
+\subsection{Use a debugger}\label{usedebugger}
This sounds like facetious advice, but it is surprising how often people
don't use a debugger. Often it is an overhead to install or learn how to
use a debugger, but it really is essential for anything but the most
trivial programs.
-\subsection{Use logging functions}
+\subsection{Use logging functions}\label{uselogging}
There is a variety of logging functions that you can use in your program:
see \helpref{Logging functions}{logfunctions}.
in some circumstances (such as when your debugger doesn't support a lot
of debugging code, or you wish to print a bunch of variables).
-\subsection{Use the wxWindows debugging facilities}
+\subsection{Use the wxWidgets debugging facilities}\label{usedebuggingfacilities}
-You can use wxDebugContext to check for
-memory leaks and corrupt memory: in fact in debugging mode, wxWindows will
-automatically check for memory leaks at the end of the program if wxWindows is suitably
+You can use \helpref{wxDebugContext}{wxdebugcontext} to check for
+memory leaks and corrupt memory: in fact in debugging mode, wxWidgets will
+automatically check for memory leaks at the end of the program if wxWidgets is suitably
configured. Depending on the operating system and compiler, more or less
specific information about the problem will be logged.
See the \helpref{debugging overview}{debuggingoverview} for further information.
-\subsection{Check Windows debug messages}
-
-Under Windows, it is worth running your program with
-\urlref{DbgView}{http://www.sysinternals.com} running or
-some other program that shows Windows-generated debug messages. It is
-possible it will show invalid handles being used. You may have fun seeing
-what commercial programs cause these normally hidden errors! Microsoft
-recommend using the debugging version of Windows, which shows up even
-more problems. However, I doubt it is worth the hassle for most
-applications. wxWindows is designed to minimize the possibility of such
-errors, but they can still happen occasionally, slipping through unnoticed
-because they are not severe enough to cause a crash.
-
-\subsection{Genetic mutation}
-
-If we had sophisticated genetic algorithm tools that could be applied
-to programming, we could use them. Until then, a common -- if rather irrational --
-technique is to just make arbitrary changes to the code until something
-different happens. You may have an intuition why a change will make a difference;
-otherwise, just try altering the order of code, comment lines out, anything
-to get over an impasse. Obviously, this is usually a last resort.
-