1998-05-20 10:25:30 -04:00
|
|
|
\chapter{Introduction}\label{introduction}
|
|
|
|
\pagenumbering{arabic}%
|
|
|
|
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
|
|
|
\setfooter{\thepage}{}{}{}{}{\thepage}%
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{What is wxWidgets?}\label{whatis}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets is a C++ framework providing GUI (Graphical User
|
2007-05-11 18:43:40 -04:00
|
|
|
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.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets was originally developed at the Artificial Intelligence
|
2000-03-14 19:21:49 -05:00
|
|
|
Applications Institute, University of Edinburgh, for internal use,
|
2002-01-23 17:10:02 -05:00
|
|
|
and was first made publicly available in 1992.
|
2000-03-14 19:21:49 -05:00
|
|
|
Version 2 is a vastly improved version written and maintained by
|
2002-01-23 17:10:02 -05:00
|
|
|
Julian Smart, Robert Roebling, Vadim Zeitlin, Vaclav Slavik and many others.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2002-01-23 17:10:02 -05:00
|
|
|
This manual contains a class reference and topic overviews.
|
2004-05-04 04:27:20 -04:00
|
|
|
For a selection of wxWidgets tutorials, please see the documentation page on the \urlref{wxWidgets web site}{http://www.wxwidgets.org}.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Please note that in the following, ``MS Windows" often refers to all
|
2007-05-11 18:43:40 -04:00
|
|
|
platforms related to Microsoft Windows, including 32-bit and 64-bit
|
1998-05-20 10:25:30 -04:00
|
|
|
variants, unless otherwise stated. All trademarks are acknowledged.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Why another cross-platform development tool?}\label{why}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets was developed to provide a cheap and flexible way to maximize
|
1998-05-20 10:25:30 -04:00
|
|
|
investment in GUI application development. While a number of commercial
|
1999-01-07 10:22:05 -05:00
|
|
|
class libraries already existed for cross-platform development,
|
1998-05-20 10:25:30 -04:00
|
|
|
none met all of the following criteria:
|
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
|
|
|
\item low price;
|
|
|
|
\item source availability;
|
|
|
|
\item simplicity of programming;
|
|
|
|
\item support for a wide range of compilers.
|
|
|
|
\end{enumerate}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Since wxWidgets was started, several other free or almost-free
|
2002-01-23 17:10:02 -05:00
|
|
|
GUI frameworks have emerged. However, none has the range of
|
|
|
|
features, flexibility, documentation and the well-established
|
2004-05-04 04:27:20 -04:00
|
|
|
development team that wxWidgets has.
|
2002-01-23 17:10:02 -05:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
As open source software, wxWidgets has benefited from comments,
|
2002-01-23 17:10:02 -05:00
|
|
|
ideas, bug fixes, enhancements and the sheer enthusiasm of
|
2004-05-04 04:27:20 -04:00
|
|
|
users. This gives wxWidgets a certain advantage over its
|
2002-01-23 17:10:02 -05:00
|
|
|
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
|
2004-05-04 04:27:20 -04:00
|
|
|
it addresses the wrong platform or audience. wxWidgets helps to
|
2002-01-23 17:10:02 -05:00
|
|
|
insulate the programmer from these winds of change. Although
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets may not be suitable for every application (such as an
|
2002-01-23 17:10:02 -05:00
|
|
|
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
|
2004-05-04 04:27:20 -04:00
|
|
|
worthwhile to use wxWidgets even if they are developing on only
|
2002-01-23 17:10:02 -05:00
|
|
|
one platform.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
It is impossible to sum up the functionality of wxWidgets in a few paragraphs, but
|
1998-05-20 10:25:30 -04:00
|
|
|
here are some of the benefits:
|
|
|
|
|
|
|
|
\begin{itemize}\itemsep=0pt
|
|
|
|
\item Low cost (free, in fact!)
|
|
|
|
\item You get the source.
|
1999-01-07 10:22:05 -05:00
|
|
|
\item Available on a variety of popular platforms.
|
1999-11-22 07:13:55 -05:00
|
|
|
\item Works with almost all popular C++ compilers and Python.
|
2000-03-14 19:21:49 -05:00
|
|
|
\item Over 50 example programs.
|
|
|
|
\item Over 1000 pages of printable and on-line documentation.
|
1999-01-07 10:22:05 -05:00
|
|
|
\item Includes Tex2RTF, to allow you to produce your own documentation
|
|
|
|
in Windows Help, HTML and Word RTF formats.
|
1998-05-20 10:25:30 -04:00
|
|
|
\item Simple-to-use, object-oriented API.
|
1999-01-07 10:22:05 -05:00
|
|
|
\item Flexible event system.
|
|
|
|
\item Graphics calls include lines, rounded rectangles, splines, polylines, etc.
|
2000-07-15 15:51:35 -04:00
|
|
|
\item Constraint-based and sizer-based layouts.
|
1998-05-20 10:25:30 -04:00
|
|
|
\item Print/preview and document/view architectures.
|
1999-01-07 10:22:05 -05:00
|
|
|
\item Toolbar, notebook, tree control, advanced list control classes.
|
1999-11-22 07:13:55 -05:00
|
|
|
\item PostScript generation under Unix, normal MS Windows printing on the PC.
|
1998-12-28 07:35:49 -05:00
|
|
|
\item MDI (Multiple Document Interface) support.
|
|
|
|
\item Can be used to create DLLs under Windows, dynamic libraries on Unix.
|
1998-05-20 10:25:30 -04:00
|
|
|
\item Common dialogs for file browsing, printing, colour selection, etc.
|
|
|
|
\item Under MS Windows, support for creating metafiles and copying
|
|
|
|
them to the clipboard.
|
1998-12-28 07:35:49 -05:00
|
|
|
\item An API for invoking help from applications.
|
2000-03-14 19:21:49 -05:00
|
|
|
\item Ready-to-use HTML window (supporting a subset of HTML).
|
1999-01-07 10:22:05 -05:00
|
|
|
\item Network support via a family of socket and protocol classes.
|
2000-07-15 15:51:35 -04:00
|
|
|
\item Support for platform independent image processing.
|
1999-11-22 07:13:55 -05:00
|
|
|
\item Built-in support for many file formats (BMP, PNG, JPEG, GIF, XPM, PNM, PCX).
|
1998-05-20 10:25:30 -04:00
|
|
|
\end{itemize}
|
|
|
|
|
2002-01-23 10:17:44 -05:00
|
|
|
\begin{comment}
|
1999-11-22 07:13:55 -05:00
|
|
|
\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.
|
2000-07-15 15:51:35 -04:00
|
|
|
\item Complete rewrite of clipboard and drag and drop classes.
|
1999-11-22 07:13:55 -05:00
|
|
|
\item Improved support for ODBC databases.
|
|
|
|
\item Improved tab traversal in dialogs.
|
|
|
|
\end{itemize}
|
2002-01-23 10:17:44 -05:00
|
|
|
\end{comment}
|
1999-11-22 07:13:55 -05:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
\section{wxWidgets requirements}\label{requirements}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
To make use of wxWidgets, you currently need one of the following setups.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2001-10-31 17:55:13 -05:00
|
|
|
(a) MS-Windows:
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
2004-12-28 07:14:27 -05:00
|
|
|
\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.
|
|
|
|
\item At least 100 MB of disk space for source tree and additional space for
|
|
|
|
libraries and application building (depends on compiler and build settings).
|
1998-05-20 10:25:30 -04:00
|
|
|
\end{enumerate}
|
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
(b) Unix:
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
1999-06-13 11:24:01 -04:00
|
|
|
\item Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).
|
2002-05-31 03:41:46 -04:00
|
|
|
\item Almost any Unix workstation, and one of: GTK+ 1.2, GTK+ 2.0, Motif 1.2 or higher, Lesstif.
|
2003-08-24 04:16:37 -04:00
|
|
|
If using the wxX11 port, no such widget set is required.
|
2004-12-28 07:14:27 -05:00
|
|
|
\item At least 100 MB of disk space for source tree and additional space for
|
|
|
|
libraries and application building (depends on compiler and build settings).
|
1998-05-20 10:25:30 -04:00
|
|
|
\end{enumerate}
|
|
|
|
|
2001-10-31 17:55:13 -05:00
|
|
|
(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.
|
2004-12-28 07:14:27 -05:00
|
|
|
\item The Apple Developer Tools (eg. GNU C++), CodeWarrior 7 or above for Mac OS X.
|
|
|
|
\item At least 100 MB of disk space for source tree and additional space for
|
|
|
|
libraries and application building (depends on compiler and build settings).
|
2001-10-31 17:55:13 -05:00
|
|
|
\end{enumerate}
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Availability and location of wxWidgets}\label{where}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
\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
|
2002-07-22 09:37:07 -04:00
|
|
|
from \urlref{ftp://biolpc22.york.ac.uk/pub}{ftp://biolpc22.york.ac.uk/pub}
|
2004-05-04 04:27:20 -04:00
|
|
|
and/or \urlref{http://www.wxwidgets.org}{http://www.wxwidgets.org}.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2002-01-23 10:17:44 -05:00
|
|
|
You can also buy a CD-ROM using the form on the Web site.
|
1999-10-25 09:46:48 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Acknowledgements}\label{acknowledgements}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
Thanks are due to AIAI for being willing to release the original version of
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets into the public domain, and to our patient partners.
|
1998-07-31 05:33:36 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
We would particularly like to thank the following for their contributions to wxWidgets, and the many others who have been involved in
|
1998-07-31 05:33:36 -04:00
|
|
|
the project over the years. Apologies for any unintentional omissions from this list.
|
|
|
|
|
2004-05-18 08:42:57 -04:00
|
|
|
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,
|
2004-06-07 08:36:47 -04:00
|
|
|
Ian Brown, C. Buckley, Marco Cavallini, Dmitri Chubraev, Robin Corbet, Cecil Coupe,
|
2004-05-18 08:42:57 -04:00
|
|
|
Stefan Csomor, Andrew Davison, Gilles Depeyrot, Neil Dudman, Robin Dunn,
|
|
|
|
Hermann Dunkel, Jos van Eijndhoven, Chris Elliott, David Elliott, 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,
|
2005-04-19 14:26:46 -04:00
|
|
|
Harco de Hilster, Kevin Hock, Cord Hockemeyer, Markus Holzem, Olaf Klein, Leif Jensen,
|
2004-05-18 08:42:57 -04:00
|
|
|
Bart Jourquin, Guilhem Lavaux, Ron Lee, Jan Lessner, Nicholas Liebmann,
|
|
|
|
Torsten Liermann, Per Lindqvist, Thomas Runge, Tatu M\"{a}nnist\"{o},
|
2005-04-19 14:26:46 -04:00
|
|
|
Scott Maxwell, Thomas Myers, Oliver Niedung, Stefan Neis, Ryan Norton, Hernan Otero,
|
2004-05-18 08:42:57 -04:00
|
|
|
Ian Perrigo, Timothy Peters, Giordano Pezzoli, Harri Pasanen, Thomaso Paoletti,
|
|
|
|
Garrett Potts, Marcel Rasche, Robert Roebling, Dino Scaringella,
|
|
|
|
Jobst Schmalenbach, Arthur Seaton, Paul Shirley, Wlodzimierz `ABX' Skiba,
|
|
|
|
Vaclav Slavik, Julian Smart, 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,
|
|
|
|
Vadim Zeitlin, Xiaokun Zhu, Edward Zimmermann.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
`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.
|
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
We also acknowledge the author of XFIG, the excellent Unix drawing tool,
|
1998-05-20 10:25:30 -04:00
|
|
|
from the source of which we have borrowed some spline drawing code.
|
|
|
|
His copyright is included below.
|
|
|
|
|
|
|
|
{\it XFig2.1 is copyright (c) 1985 by Supoj Sutanthavibul. Permission to
|
|
|
|
use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided
|
|
|
|
that the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation, and that the name of M.I.T. not be used in advertising or
|
|
|
|
publicity pertaining to distribution of the software without specific,
|
|
|
|
written prior permission. M.I.T. makes no representations about the
|
|
|
|
suitability of this software for any purpose. It is provided ``as is''
|
|
|
|
without express or implied warranty.}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
\chapter{Multi-platform development with wxWidgets}\label{multiplat}
|
1998-05-20 10:25:30 -04:00
|
|
|
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
|
|
|
\setfooter{\thepage}{}{}{}{}{\thepage}%
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
This chapter describes the practical details of using wxWidgets. Please
|
1998-05-20 10:25:30 -04:00
|
|
|
see the file install.txt for up-to-date installation instructions, and
|
|
|
|
changes.txt for differences between versions.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Include files}\label{includefiles}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
The main include file is {\tt "wx/wx.h"}; this includes the most commonly
|
2004-05-04 04:27:20 -04:00
|
|
|
used modules of wxWidgets.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
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 following section before any other includes:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
1998-07-31 05:33:36 -04:00
|
|
|
#include <wx/wxprec.h>
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
1998-07-31 05:33:36 -04:00
|
|
|
// Include your minimal set of headers here, or wx.h
|
|
|
|
#include <wx/wx.h>
|
1998-05-20 10:25:30 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
... now your other include files ...
|
|
|
|
\end{verbatim}
|
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
The file {\tt "wx/wxprec.h"} includes {\tt "wx/wx.h"}. Although this incantation
|
1998-05-20 10:25:30 -04:00
|
|
|
may seem quirky, it is in fact the end result of a lot of experimentation,
|
2004-12-28 07:14:27 -05:00
|
|
|
and several Windows compilers to use precompilation which is largely automatic for
|
2005-06-30 11:24:18 -04:00
|
|
|
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.
|
2005-06-30 07:59:45 -04:00
|
|
|
Some compilers might need extra work from the application developer to set the
|
|
|
|
build environment up as necessary for the support.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Libraries}\label{libraries}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Most ports of wxWidgets can create either a static library or a shared
|
|
|
|
library. wxWidgets can also be built in multilib and monolithic variants.
|
2003-08-24 04:16:37 -04:00
|
|
|
See the \helpref{libraries list}{librarieslist} for more
|
|
|
|
information on these.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Configuration}\label{configuration}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
When using project files and makefiles directly to build wxWidgets,
|
2003-08-24 04:16:37 -04:00
|
|
|
options are configurable in the file
|
1999-11-22 07:13:55 -05:00
|
|
|
\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
|
1998-12-28 07:35:49 -05:00
|
|
|
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.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
When using the 'configure' script to configure wxWidgets (on Unix and other platforms where
|
2003-08-24 04:16:37 -04:00
|
|
|
configure is available), the corresponding setup.h files are generated automatically
|
|
|
|
along with suitable makefiles. When using the RPM packages
|
2004-05-04 04:27:20 -04:00
|
|
|
for installing wxWidgets on Linux, a correct setup.h is shipped in the package and
|
1999-11-22 07:13:55 -05:00
|
|
|
this must not be changed.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Makefiles}\label{makefiles}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
On Microsoft Windows, wxWidgets has a different set of makefiles for each
|
2003-08-24 04:16:37 -04:00
|
|
|
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
|
2004-05-04 04:27:20 -04:00
|
|
|
for the wxWidgets library itself, samples, demos, and utilities.
|
2003-08-24 04:16:37 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
We also provide project files for some compilers, such as
|
|
|
|
Microsoft VC++. However, we recommend using makefiles
|
2004-05-04 04:27:20 -04:00
|
|
|
to build the wxWidgets library itself, because makefiles
|
2003-08-24 04:16:37 -04:00
|
|
|
can be more powerful and less manual intervention is required.
|
|
|
|
|
|
|
|
On Windows using a compiler other than MinGW/Cygwin, you would
|
2004-05-04 04:27:20 -04:00
|
|
|
build the wxWidgets library from the build/msw directory
|
2003-08-24 04:16:37 -04:00
|
|
|
which contains the relevant makefiles.
|
|
|
|
|
|
|
|
On Windows using MinGW/Cygwin, and on Unix, MacOS X and OS/2, you invoke
|
2004-05-04 04:27:20 -04:00
|
|
|
'configure' (found in the top-level of the wxWidgets source hierarchy),
|
2003-08-24 04:16:37 -04:00
|
|
|
from within a suitable empty directory for containing makefiles, object files and
|
|
|
|
libraries.
|
|
|
|
|
|
|
|
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.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Windows-specific files}\label{windowsfiles}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2005-05-22 09:36:34 -04:00
|
|
|
wxWidgets application compilation under MS Windows requires at least one
|
|
|
|
extra file: a resource file.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\subsection{Resource file}\label{resources}
|
|
|
|
|
|
|
|
The least that must be defined in the Windows resource file (extension RC)
|
|
|
|
is the following statement:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
2003-08-24 04:16:37 -04:00
|
|
|
#include "wx/msw/wx.rc"
|
1998-05-20 10:25:30 -04:00
|
|
|
\end{verbatim}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
which includes essential internal wxWidgets definitions. The resource script
|
1998-05-20 10:25:30 -04:00
|
|
|
may also contain references to icons, cursors, etc., for example:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
wxicon icon wx.ico
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
The icon can then be referenced by name when creating a frame icon. See
|
|
|
|
the MS Windows SDK documentation.
|
|
|
|
|
|
|
|
\normalbox{Note: include wx.rc {\it after} any ICON statements
|
|
|
|
so programs that search your executable for icons (such
|
|
|
|
as the Program Manager) find your application icon first.}
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Allocating and deleting wxWidgets objects}\label{allocatingobjects}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
In general, classes derived from wxWindow must dynamically allocated
|
|
|
|
with {\it new} and deleted with {\it delete}. If you delete a window,
|
|
|
|
all of its children and descendants will be automatically deleted,
|
|
|
|
so you don't need to delete these descendants explicitly.
|
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
When deleting a frame or dialog, use {\bf Destroy} rather than {\bf delete} so
|
2004-05-04 04:27:20 -04:00
|
|
|
that the wxWidgets delayed deletion can take effect. This waits until idle time
|
1998-07-31 05:33:36 -04:00
|
|
|
(when all messages have been processed) to actually delete the window, to avoid
|
|
|
|
problems associated with the GUI sending events to deleted windows.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
Don't create a window on the stack, because this will interfere
|
|
|
|
with delayed deletion.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
If you decide to allocate a C++ array of objects (such as wxBitmap) that may
|
2004-05-04 04:27:20 -04:00
|
|
|
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
|
1998-05-20 10:25:30 -04:00
|
|
|
array members will cause memory problems.
|
|
|
|
|
|
|
|
wxColour can be created statically: it is not automatically cleaned
|
|
|
|
up and is unlikely to be shared between other objects; it is lightweight
|
|
|
|
enough for copies to be made.
|
|
|
|
|
|
|
|
Beware of deleting objects such as a wxPen or wxBitmap if they are still in use.
|
|
|
|
Windows is particularly sensitive to this: so make sure you
|
1998-07-31 05:33:36 -04:00
|
|
|
make calls like wxDC::SetPen(wxNullPen) or wxDC::SelectObject(wxNullBitmap) before deleting
|
1998-05-20 10:25:30 -04:00
|
|
|
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.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Architecture dependency}\label{architecturedependency}
|
1999-06-13 11:24:01 -04:00
|
|
|
|
|
|
|
A problem which sometimes arises from writing multi-platform programs is that
|
2000-07-15 15:51:35 -04:00
|
|
|
the basic C types are not defined the same on all platforms. This holds true
|
1999-06-13 11:24:01 -04:00
|
|
|
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
|
2004-05-04 04:27:20 -04:00
|
|
|
on Intel computers) or big endian (typically on some Unix workstations). wxWidgets
|
1999-06-13 11:24:01 -04:00
|
|
|
defines types and macros that make it easy to write architecture independent
|
|
|
|
code. The types are:
|
|
|
|
|
|
|
|
wxInt32, wxInt16, wxInt8, wxUint32, wxUint16 = wxWord, wxUint8 = wxByte
|
|
|
|
|
|
|
|
where wxInt32 stands for a 32-bit signed integer type etc. You can also check
|
|
|
|
which architecture the program is compiled on using the wxBYTE\_ORDER define
|
|
|
|
which is either wxBIG\_ENDIAN or wxLITTLE\_ENDIAN (in the future maybe wxPDP\_ENDIAN
|
|
|
|
as well).
|
|
|
|
|
|
|
|
The macros handling bit-swapping with respect to the applications endianness
|
2002-04-08 13:14:53 -04:00
|
|
|
are described in the \helpref{Byte order macros}{byteordermacros} section.
|
1999-06-13 11:24:01 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Conditional compilation}\label{conditionalcompilation}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
One of the purposes of wxWidgets is to reduce the need for conditional
|
1998-05-20 10:25:30 -04:00
|
|
|
compilation in source code, which can be messy and confusing to follow.
|
|
|
|
However, sometimes it is necessary to incorporate platform-specific
|
1998-12-28 07:35:49 -05:00
|
|
|
features (such as metafile use under MS Windows). The symbols
|
|
|
|
listed in the file {\tt symbols.txt} may be used for this purpose,
|
|
|
|
along with any user-supplied ones.
|
1998-08-18 10:54:21 -04:00
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{C++ issues}\label{cpp}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-07-31 05:33:36 -04:00
|
|
|
The following documents some miscellaneous C++ issues.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Templates}\label{templates}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets does not use templates (except for some advanced features that
|
2003-08-24 04:16:37 -04:00
|
|
|
are switched off by default) since it is a notoriously unportable feature.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{RTTI}\label{rtti}
|
1999-01-09 10:53:52 -05:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets does not use C++ run-time type information since wxWidgets provides
|
1999-01-09 10:53:52 -05:00
|
|
|
its own run-time type information system, implemented using macros.
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Type of NULL}\label{null}
|
1999-01-09 10:53:52 -05:00
|
|
|
|
|
|
|
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
|
2003-08-24 04:16:37 -04:00
|
|
|
occurrences of NULL in the GTK+ port use an explicit conversion such
|
1999-01-09 10:53:52 -05:00
|
|
|
as
|
|
|
|
|
|
|
|
{\small
|
|
|
|
\begin{verbatim}
|
|
|
|
wxWindow *my_window = (wxWindow*) NULL;
|
|
|
|
\end{verbatim}
|
2004-02-21 20:16:32 -05:00
|
|
|
}%
|
1999-01-09 10:53:52 -05:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
It is recommended to adhere to this in all code using wxWidgets as
|
1999-01-09 10:53:52 -05:00
|
|
|
this make the code (a bit) more portable.
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Precompiled headers}\label{precompiledheaders}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Some compilers, such as Borland C++ and Microsoft C++, support
|
|
|
|
precompiled headers. This can save a great deal of compiling time. The
|
1999-01-07 10:22:05 -05:00
|
|
|
recommended approach is to precompile {\tt "wx.h"}, using this
|
2004-05-04 04:27:20 -04:00
|
|
|
precompiled header for compiling both wxWidgets itself and any
|
|
|
|
wxWidgets applications. For Windows compilers, two dummy source files
|
1998-05-20 10:25:30 -04:00
|
|
|
are provided (one for normal applications and one for creating DLLs)
|
|
|
|
to allow initial creation of the precompiled header.
|
|
|
|
|
|
|
|
However, there are several downsides to using precompiled headers. One
|
|
|
|
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
|
2004-05-04 04:27:20 -04:00
|
|
|
wxWidgets, everything needs to be recompiled since everything includes {\tt "wx.h"}!)
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
A related problem is that for compilers that don't have precompiled
|
|
|
|
headers, including a lot of header files slows down compilation
|
|
|
|
considerably. For this reason, you will find (in the common
|
|
|
|
X and Windows parts of the library) conditional
|
1998-07-31 05:33:36 -04:00
|
|
|
compilation that under Unix, includes a minimal set of headers;
|
1998-05-20 10:25:30 -04:00
|
|
|
and when using Visual C++, includes {\tt wx.h}. This should help provide
|
|
|
|
the optimal compilation for each compiler, although it is
|
2000-07-15 15:51:35 -04:00
|
|
|
biased towards the precompiled headers facility available
|
1998-05-20 10:25:30 -04:00
|
|
|
in Microsoft C++.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{File handling}\label{filehandling}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
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
|
1998-12-28 07:35:49 -05:00
|
|
|
the global function {\bf wxFileNameFromPath} allows the application to
|
1998-05-20 10:25:30 -04:00
|
|
|
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
|
1998-07-31 05:33:36 -04:00
|
|
|
unrestricted Unix filenames, the best solution is to use DOS filenames
|
1998-05-20 10:25:30 -04:00
|
|
|
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
|
1998-07-31 05:33:36 -04:00
|
|
|
solution here is to have your Unix makefile rename the generated files
|
1998-05-20 10:25:30 -04:00
|
|
|
to something more compatible before transferring the source to DOS.
|
1998-07-31 05:33:36 -04:00
|
|
|
Transferring DOS files to Unix is no problem, of course, apart from EOL
|
1998-05-20 10:25:30 -04:00
|
|
|
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.
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
\chapter{Utilities and libraries supplied with wxWidgets}\label{utilities}
|
1998-05-20 10:25:30 -04:00
|
|
|
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
|
|
|
\setfooter{\thepage}{}{}{}{}{\thepage}%
|
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
In addition to the \helpref{wxWidgets libraries}{librarieslist}, some
|
|
|
|
additional utilities are supplied in the \tt{utils} hierarchy.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2002-01-23 17:10:02 -05:00
|
|
|
For other user-contributed packages, please see the Contributions page
|
2004-05-04 04:27:20 -04:00
|
|
|
on the \urlref{wxWidgets Web site}{http://www.wxwidgets.org}.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2002-01-23 17:10:02 -05:00
|
|
|
\begin{description}\itemsep=0pt
|
2002-01-26 16:52:55 -05:00
|
|
|
\item[{\bf Helpview}]
|
2004-05-04 04:27:20 -04:00
|
|
|
Helpview is a program for displaying wxWidgets HTML
|
|
|
|
Help files. In many cases, you may wish to use the wxWidgets HTML
|
2002-01-23 17:10:02 -05:00
|
|
|
Help classes from within your application, but this provides a
|
|
|
|
handy stand-alone viewer. See \helpref{wxHTML Notes}{wxhtml} for more details.
|
2002-05-05 10:24:07 -04:00
|
|
|
You can find it in {\tt samples/html/helpview}.
|
2002-01-26 16:52:55 -05:00
|
|
|
\item[{\bf Tex2RTF}]
|
2004-05-04 04:27:20 -04:00
|
|
|
Supplied with wxWidgets is a utility called Tex2RTF for converting\rtfsp
|
2002-01-23 17:10:02 -05:00
|
|
|
\LaTeX\ manuals HTML, MS HTML Help, wxHTML Help, RTF, and Windows
|
2004-05-04 04:27:20 -04:00
|
|
|
Help RTF formats. Tex2RTF is used for the wxWidgets manuals and can be used independently
|
2002-01-23 17:10:02 -05:00
|
|
|
by authors wishing to create on-line and printed manuals from the same\rtfsp
|
|
|
|
\LaTeX\ source. Please see the separate documentation for Tex2RTF.
|
2002-05-05 10:24:07 -04:00
|
|
|
You can find it under {\tt utils/tex2rtf}.
|
2002-01-26 16:52:55 -05:00
|
|
|
\item[{\bf Helpgen}]
|
2002-01-23 17:10:02 -05:00
|
|
|
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.
|
2004-01-13 12:48:33 -05:00
|
|
|
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}.
|
2002-01-23 17:10:02 -05:00
|
|
|
\end{description}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\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
|
2004-05-04 04:27:20 -04:00
|
|
|
writing and debugging wxWidgets programs. If you have any good tips,
|
1998-05-20 10:25:30 -04:00
|
|
|
please submit them for inclusion here.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Strategies for reducing programming errors}\label{reducingerrors}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use ASSERT}\label{useassert}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
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.
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
These can be compiled out of a non-debugging version of wxWidgets
|
1998-05-20 10:25:30 -04:00
|
|
|
and your application. Using ASSERT is an example of `defensive programming':
|
|
|
|
it can alert you to problems later on.
|
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
See \helpref{wxASSERT}{wxassert} for more info.
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use wxString in preference to character arrays}\label{usewxstring}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
Using \helpref{wxString}{wxstring} can be much safer and more convenient than using wxChar *.
|
|
|
|
|
|
|
|
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).
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
The same goes for other data types: use classes wherever possible.
|
|
|
|
|
2004-09-16 12:36:40 -04:00
|
|
|
\section{Strategies for portability}\label{portability}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
\subsection{Use sizers}\label{usesizers}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Don't use absolute panel item positioning if you can avoid it. Different GUIs have
|
2007-05-12 14:24:12 -04:00
|
|
|
very differently sized panel items. Consider using the \helpref{sizers}{sizeroverview} instead.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use wxWidgets resource files}\label{useresources}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Use .xrc (wxWidgets resource files) where possible, because they can be easily changed
|
2007-05-12 14:24:12 -04:00
|
|
|
independently of source code. See the \helpref{XRC overview}{xrcoverview} for more info.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-11-21 10:40:35 -05:00
|
|
|
\section{Strategies for debugging}\label{debugstrategies}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Positive thinking}\label{positivethinking}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
It is common to blow up the problem in one's imagination, so that it seems to threaten
|
1998-05-20 10:25:30 -04:00
|
|
|
weeks, months or even years of work. The problem you face may seem insurmountable:
|
|
|
|
but almost never is. Once you have been programming for some time, you will be able
|
|
|
|
to remember similar incidents that threw you into the depths of despair. But
|
|
|
|
remember, you always solved the problem, somehow!
|
|
|
|
|
|
|
|
Perseverance is often the key, even though a seemingly trivial problem
|
|
|
|
can take an apparently inordinate amount of time to solve. In the end,
|
|
|
|
you will probably wonder why you worried so much. That's not to say it
|
|
|
|
isn't painful at the time. Try not to worry -- there are many more important
|
|
|
|
things in life.
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Simplify the problem}\label{simplifyproblem}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
complex program to a very small program, then try to ensure your code
|
|
|
|
doesn't hide the problem (you may have attempted to minimize the problem
|
|
|
|
in some way: but now you want to expose it).
|
|
|
|
|
|
|
|
With luck, you can add a small amount of code that causes the program
|
|
|
|
to go from functioning to non-functioning state. This should give a clue
|
|
|
|
to the problem. In some cases though, such as memory leaks or wrong
|
|
|
|
deallocation, this can still give totally spurious results!
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use a debugger}\label{usedebugger}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
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
|
1998-05-20 10:25:30 -04:00
|
|
|
use a debugger, but it really is essential for anything but the most
|
1998-11-21 10:40:35 -05:00
|
|
|
trivial programs.
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use logging functions}\label{uselogging}
|
1998-11-21 10:40:35 -05:00
|
|
|
|
|
|
|
There is a variety of logging functions that you can use in your program:
|
|
|
|
see \helpref{Logging functions}{logfunctions}.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Using tracing statements may be more convenient than using the debugger
|
|
|
|
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).
|
|
|
|
|
2004-09-20 07:21:04 -04:00
|
|
|
\subsection{Use the wxWidgets debugging facilities}\label{usedebuggingfacilities}
|
1998-11-21 10:40:35 -05:00
|
|
|
|
2007-05-12 14:24:12 -04:00
|
|
|
You can use \helpref{wxDebugContext}{wxdebugcontext} to check for
|
2004-05-04 04:27:20 -04:00
|
|
|
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
|
1998-11-21 10:40:35 -05:00
|
|
|
configured. Depending on the operating system and compiler, more or less
|
|
|
|
specific information about the problem will be logged.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1998-11-21 10:40:35 -05:00
|
|
|
You should also use \helpref{debug macros}{debugmacros} as part of a `defensive programming' strategy,
|
|
|
|
scattering wxASSERTs liberally to test for problems in your code as early as possible. Forward thinking
|
|
|
|
will save a surprising amount of time in the long run.
|
|
|
|
|
|
|
|
See the \helpref{debugging overview}{debuggingoverview} for further information.
|
1998-05-20 10:25:30 -04:00
|
|
|
|