X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe604ccddcf5696a751892ad70dbc822be239c95..766571a7039fe4428dabe5e2aabcb4055ceb9db9:/docs/latex/wx/body.tex?ds=inline diff --git a/docs/latex/wx/body.tex b/docs/latex/wx/body.tex index c5787bffed..aa983ac361 100644 --- a/docs/latex/wx/body.tex +++ b/docs/latex/wx/body.tex @@ -3,32 +3,31 @@ \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. It currently -supports subsets of Motif, Xt and MS Windows (16-bit, Windows 95 and Windows NT). +wxWidgets is a C++ framework providing GUI (Graphical User +Interface) and other facilities on more than one platform. Version 2 currently +supports all desktop versions of MS Windows, Unix with GTK+, Unix with Motif, +and MacOS. An OS/2 port is in progress. -wxWindows was originally developed at the Artificial Intelligence -Applications Institute, University of Edinburgh, for internal use. -wxWindows has been released into the public domain in the hope -that others will also find it useful. Version 2.0 is written and -maintained by Julian Smart and Markus Holzem, with support from users. +wxWidgets was originally developed at the Artificial Intelligence +Applications Institute, University of Edinburgh, for internal use, +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, 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 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 exist for cross-platform development, +class libraries already existed for cross-platform development, none met all of the following criteria: \begin{enumerate}\itemsep=0pt @@ -38,194 +37,183 @@ none met all of the following criteria: \item support for a wide range of compilers. \end{enumerate} -As public domain software and a project open to everyone, wxWindows has -benefited from comments, ideas, bug fixes, enhancements and the sheer -enthusiasm of users, especially via the Internet. This gives wxWindows a -certain advantage over its commercial brothers, and 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. - -In writing wxWindows, completeness has sometimes been traded for -portability and simplicity of programming. Version 2.0 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 and MFC. - -wxWindows 2.0 currently maps to two native APIs: Motif and -MS Windows. An Xt port is also in preparation. - -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, it provides access to most of the functionality a -GUI program normally requires, plus some extras such as form -construction, interprocess communication and PostScript output, and -can of course be extended as needs dictate. As a bonus, it provides -a cleaner 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 Low cost (free, in fact!) \item You get the source. -\item Several example programs. -\item Over 200 pages of printable and on-line documentation. +\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 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 Graphics calls include splines, polylines, rounded rectangles, etc. -\item Constraint-based layout option. +\item Flexible event system. +\item Graphics calls include lines, rounded rectangles, splines, polylines, etc. +\item Constraint-based and sizer-based layouts. \item Print/preview and document/view architectures. -\item Status line facility, toolbar -\item Easy, object-oriented interprocess comms (DDE subset) under UNIX and -MS Windows. -\item Encapsulated PostScript generation under UNIX, normal MS Windows printing on the -PC. -\item MDI support under Windows. -\item Can be used to create DLLs under Windows, dynamic libraries on the Sun. +\item Toolbar, notebook, tree control, advanced list control classes. +\item PostScript generation under Unix, normal MS Windows printing on the PC. +\item MDI (Multiple Document Interface) support. +\item Can be used to create DLLs under Windows, dynamic libraries on Unix. \item Common dialogs for file browsing, printing, colour selection, etc. \item Under MS Windows, support for creating metafiles and copying them to the clipboard. -\item Hypertext help facility, with an API for invocation from applications. -\item Dialog Editor for building dialogs. +\item An API for invoking help from applications. +\item Ready-to-use HTML window (supporting a subset of HTML). +\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). \end{itemize} -\section{Changes from version 1.xx}\label{versionchanges} +\begin{comment} +\section{Changes from version 2.0}\label{versionchanges20} -These are a few of the major differences between versions 1.xx and 2.0. +These are a few of the differences between versions 2.0 and 2.2. Removals: \begin{itemize}\itemsep=0pt -\item XView is no longer supported; -\item Mac is not yet supported; -\item all controls (panel items) no longer have labels attached to them; -\item wxForm removed; -\item wxCanvasDC, wxPanelDC removed (replaced by wxClientDC, wxWindowDC, wxPaintDC which -can be used for any window); -\item wxMultiText, wxTextWindow, wxText removed and replaced by wxTextCtrl; -\item classes no longer divided into generic and platform-specific parts, for efficiency. +\item GTK 1.0 no longer supported. \end{itemize} Additions and changes: \begin{itemize}\itemsep=0pt -\item class hierarchy changed, and restrictions about subwindow nesting lifted; -\item header files reorganised to conform to normal C++ standards; -\item classes less dependent on each another, to reduce executable size; -\item wxString used instead of char* wherever possible; -\item the number of separate but mandatory utilities reduced; -\item the event system has been overhauled, with -virtual functions and callbacks being replaced with MFC-like event tables; -\item new controls, such as wxTreeCtrl, wxListCtrl, wxSpinButton; -\item less inconsistency about what events can be handled, so for example -mouse clicks or key presses on controls can now be intercepted; -\item the status bar is now a separate class, wxStatusBar, and is -implemented in generic wxWindows code; -\item some renaming of controls for greater consistency; -\item wxBitmap has the notion of bitmap handlers to allow for extension to new formats -without ifdefing; -\item new dialogs: wxPageSetupDialog, wxFileDialog, wxDirDialog, -wxMessageDialog, wxSingleChoiceDialog, wxTextEntryDialog; -\item GDI objects are reference-counted and are now passed to most functions -by reference, making memory management far easier; -\item wxSystemSettings class allows querying for various system-wide properties -such as dialog font, colours, user interface element sizes, and so on; -\item better platform look and feel conformance; -\item toolbar functionality now separated out into a family of classes with the -same API; -\item device contexts are no longer accessed using wxWindow::GetDC - they are created -temporarily with the window as an argument; -\item events from sliders and scrollbars can be handled more flexibly; -\item the handling of window close events has been changed in line with the new -event system, but backward {\bf OnClose} compatibility has been retained; -\item the concept of {\it validator} has been added to allow much easier coding of -the relationship between controls and application data; -\item the documentation has been revised, with more cross-referencing. +\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} -Platform-specific changes: +\section{wxWidgets requirements}\label{requirements} -\begin{itemize}\itemsep=0pt -\item The Windows header file (windows.h) is no longer included by wxWindows headers; -\item wx.dll supported under Visual C++; -\item the full range of Windows 95 window decorations are supported, such as modal frame -borders; -\item MDI classes brought out of wxFrame into separate classes, and made more flexible. -\end{itemize} - -\section{wxWindows requirements}\label{requirements} +To make use of wxWidgets, you currently need one of the following setups. -To make use of wxWindows, you currently need one or both of the -following setups. - -(a) PC: +(a) MS-Windows: \begin{enumerate}\itemsep=0pt -\item A 486 or higher PC running MS Windows. -\item One of Microsoft Visual C++, Borland C++, Watcom C++, MetroWerks C++, -Symantec C++, GNU-WIN32. -\item At least 30 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. +\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). \end{enumerate} -(b) UNIX: +(b) Unix: \begin{enumerate}\itemsep=0pt -\item Almost any C++ compiler, including GNU C++. -\item Almost any UNIX workstation (VMS is supported too) and Motif 1.2 or higher (not necessary -for the Xt version) -\item At least 30 MB of disk space. +\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, GTK+ 2.0, Motif 1.2 or higher, Lesstif. +If using the wxX11 port, no such widget set is required. +\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). \end{enumerate} -\section{Availability and location of wxWindows} - -wxWindows is currently available from the Artificial Intelligence -Applications Institute by anonymous FTP and World Wide Web: - -\begin{verbatim} - ftp://ftp.aiai.ed.ac.uk/pub/packages/wxwin - http://web.ukonline.co.uk/julian.smart/wxwin -\end{verbatim} - -\section{Acknowledgments} +(c) Mac OS/Mac OS X: -Thanks are due to the AIAI for being willing to release wxWindows into -the public domain, and to our patient wives Harriet and Tanja. - -The Internet has been an essential prop when coming up against tricky -problems. Thanks to those who answered our -queries or submitted bug fixes and enhancements; wxWindows is very -much a team effort. - -Hermann Dunkel contributed XPM support; Arthur Seaton wrote the memory -checking code; Olaf Klein and Patrick Halke wrote the ODBC classes; -Harri Pasanen and Robin Dunn wrote wxPython and contributed to the -wxExtend library. - -Markus Holzem write the Xt port. Jonathan Tonberg, Bill Hale, -Cecil Coupe, Thomaso Paoletti, Thomas Fettig, and others slaved away -writing the Mac port. Keith Gary Boyce ported wxWindows to the free -GNU-WIN32 compiler, refusing to give up when shortcuts were suggested. +\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++), 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). +\end{enumerate} -Many thanks also to: Timothy Peters, Jamshid Afshar, Patrick Albert, C. Buckley, -Robin Corbet, Harco de Hilster, Josep Fortiana, Torsten Liermann, Tatu -M\"{a}nnist\"{o}, Ian Perrigo, Giordano Pezzoli, Petr Smilauer, Neil Smith, -Kari Syst\"{a}, Jyrki Tuomi, Edward Zimmermann, Ian Brown, and many -others. +\section{Availability and location of wxWidgets}\label{where} + +\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}.} + +You can also buy a CD-ROM using the form on the Web site. + +\section{Acknowledgements}\label{acknowledgements} + +Thanks are due to AIAI for being willing to release the original version of +wxWidgets into the public domain, and to our patient partners. + +We would particularly like to thank the following 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 list. + +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, +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, +Harco de Hilster, Kevin Hock, Cord Hockemeyer, Markus Holzem, Olaf Klein, Leif Jensen, +Bart Jourquin, Guilhem Lavaux, Ron Lee, Jan Lessner, Nicholas Liebmann, +Torsten Liermann, Per Lindqvist, Thomas Runge, Tatu M\"{a}nnist\"{o}, +Scott Maxwell, Thomas Myers, Oliver Niedung, Stefan Neis, Ryan Norton, 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, 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. `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. -We also acknowledge the author of XFIG, the excellent UNIX drawing tool, +We also acknowledge the author of XFIG, the excellent Unix drawing tool, from the source of which we have borrowed some spline drawing code. His copyright is included below. @@ -240,18 +228,18 @@ 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.} -\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.h"}; this includes the most commonly -used modules of wxWindows. +The main include file is {\tt "wx/wx.h"}; this includes the most commonly +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 @@ -259,166 +247,86 @@ the following section before any other includes: \begin{verbatim} // For compilers that support precompilation, includes "wx.h". -#include "wx_prec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP -... include minimum set of files necessary here ... +// Include your minimal set of headers here, or wx.h +#include #endif ... now your other include files ... \end{verbatim} -The file {\tt "wx\_prec.h"} includes {\tt "wx.h"}. Although this incantation +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\_prec.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} - -Under UNIX, use the library libwx\_motif.a -(Motif). Under Windows, use the library wx.lib for stand-alone Windows -applications, or wxdll.lib for creating DLLs. - -\section{Configuration} - -The following lists the options configurable in the file -\rtfsp{\tt include/base/wx\_setup.h.} 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. - -\subsection{General features} - -\begin{twocollist}\itemsep=0pt -\twocolitem{USE\_CLIPBOARD}{If 1, clipboard code is compiled (Windows only).} -\twocolitem{USE\_CONSTRAINTS}{If 1, the constaint-based window layout system is compiled.} -\twocolitem{USE\_DOC\_VIEW\_ARCHITECTURE}{If 1, wxDocument, wxView and related classes are compiled.} -\twocolitem{USE\_DYNAMIC\_CLASSES}{If 1, the run-time class macros and classes are compiled. Recommended, -and necessary for the document/view framework.} -\twocolitem{USE\_EXTENDED\_STATICS}{If 1, wxStaticItem code is compiled for enhanced panel decorative items. -Not rigorously tested, and not documented.} -\twocolitem{USE\_HELP}{If 1, interface to help system is compiled.} -\twocolitem{USE\_GAUGE}{If 1, the wxGauge class compiled.} -\twocolitem{USE\_GLOBAL\_MEMORY\_OPERATORS}{If 1, redefines global new and delete operators to be compatible -with the extended arguments of the debugging wxObject new and delete operators. If this causes problems -for your compiler, set to 0.} -\twocolitem{USE\_GNU\_WXSTRING}{If 1, the enhanced GNU wxString and regular expression class are compiled -in place of the normal wxString class. See contrib/wxstring for details.} -\twocolitem{USE\_IMAGE\_LOADING\_IN\_MSW}{Use code to allow dynamic .BMP loading -under MS Windows.} -\twocolitem{USE\_IMAGE\_LOADING\_IN\_X}{Use code in utils/image to allow dynamic .BMP/.GIF loading -under X.} -\twocolitem{USE\_RESOURCE\_LOADING\_IN\_MSW}{Use code to allow dynamic .ICO/.CUR loading -under MS Windows.} -\twocolitem{USE\_IPC}{If 1, interprocess communication code is compiled.} -\twocolitem{USE\_MEMORY\_TRACING}{If 1, enables debugging versions of wxObject::new and wxObject::delete -if the value of DEBUG is defined to more than 0.} -\twocolitem{USE\_METAFILE}{If 1, Windows Metafile code is compiled.} -\twocolitem{USE\_PANEL\_IN\_PANEL}{If 1, experimental panel-in-panel code is used -for common dialog boxes. Not recommended, since tab traversal can suffer.} -\twocolitem{USE\_POSTSCRIPT}{If 1, PostScript code is compiled.} -\twocolitem{USE\_POSTSCRIPT\_ARCHITECTURE\_IN\_MSW}{Set to 1 to enable the printing architecture -to make use of either native Windows printing facilities, or the wxPostScriptDC class depending -on the wxApp::SetPrintMode setting.} -\twocolitem{USE\_PRINTING\_ARCHITECTURE}{If 1, wxPrinter, wxPrintout and related classes are compiled -for the print/preview framework.} -\twocolitem{USE\_RESOURCES}{If 1, win.ini or .Xdefaults-style resource read/write code is compiled.} -\twocolitem{USE\_SCROLLBAR}{If 1, wxScrollBar class is compiled. Not rigorously tested, and not documented.} -\twocolitem{USE\_SPLINES}{If 1, spline code is compiled.} -\twocolitem{USE\_TOOLBAR}{If 1, the wxToolBar class is compiled.} -\twocolitem{USE\_TYPEDEFS}{If 1, a typedef will be used for wxPoint instead of -a class declaration, to reduce overhead and avoid a Microsoft C++ memory bug.} -\twocolitem{USE\_VLBOX}{If 1, wxVirtListBox code is compiled for a virtual listbox item. -Not rigorously tested, and not documented.} -\twocolitem{USE\_WX\_RESOURCES}{If 1, wxWindows resource file (.WXR) code is compiled.} -\twocolitem{USE\_XFIG\_SPLINE\_CODE}{If 1, XFig-derived code is used for spline -drawing. If 0, AIAI code is used, which is slower.} -\twocolitem{USE\_XPM\_IN\_X}{If 1, XPM (colour pixmap) facilities will be compiled and used -in wxBitmap under X.} -\twocolitem{USE\_XPM\_IN\_MSW}{If 1, XPM (colour pixmap) facilities will be compiled and used -in wxBitmap under MS Windows.} -\end{twocollist} - -\subsection{X features} - -\begin{twocollist} -\twocolitem{DEFAULT\_FILE\_SELECTOR\_SIZE}{Let Motif choose the size of -XmFileSelectionBox. Otherwise, size is 500x600.} -\twocolitem{PIXEL0\_DISABLE}{Define to disallow allocation of pixel 0 (wxXOR problem).} -\twocolitem{USE\_GADGETS}{Use gadgets where possible rather than Widgets for items. -Default is to use Gadgets.} -\twocolitem{USE\_BUTTON\_GADGET}{Use gadgets for buttons. This can intefere with -default button selection, so the default is zero.} -\end{twocollist} - -\subsection{Windows and NT features} - -\begin{twocollist} -\twocolitem{CTL3D}{CTL3D should only be used for 16-bit Windows programs. -On Windows 95 and NT, native 3D effects are used. If you want to -use it and don't already have CTL3D installed, copy the files in -contrib/ctl3d to appropriate places (ctl3dv2.lib/ctl3d32.lib into your compiler lib -directory, ctl3d.h into an include directory, and ctl3dv2.dll into -windows/system). You may need to find a compiler-specific version of ctl3dv2.lib -or ctl3d32.lib. Define CTL3D to be 1 in wx\_setup.h and link your executables with ctl3dv2.lib -or ctl3d32.lib.} -\twocolitem{USE\_ITSY\_BITSY}{If 1, compiles in code to support tiny window titlebars.} -\twocolitem{USE\_ODBC}{If 1, compiles wxDatabase and wxRecordSet classes for ODBC -access. Requires sql.h, sqlext.h files if set to 1 (see topic on database support).} -\end{twocollist} - -\section{Makefiles} - -At the moment there is no attempt to make UNIX makefiles and -PC makefiles compatible, i.e. one makefile is required for -each environment. - -Sample makefiles for UNIX (suffix .UNX), MS C++ (suffix .DOS and .NT), Borland -C++ (.BCC) and Symantec C++ (.SC) are included for the library, demos -and utilities. The NT, Borland and Symantec makefiles cannot be -guaranteed to be up-to-date since the author does not have -these compilers. - -The controlling makefile for wxWindows is in the platform-specific -directory, such as {\tt src/msw} or {\tt src/x}. This makefile will -recursively execute the makefile in {\tt src/base}. - -\subsection{Windows makefiles} - -For Microsoft C++, normally it is only necessary to type {\tt nmake -f -makefile.dos} (or an alias or batch file which does this). By default, -binaries are made with debugging information, and no optimization. Use -FINAL=1 on the command line to remove debugging information (this only -really necessary at the link stage), and DLL=1 to make a DLL version of -the library, if building a library. - -\subsection{UNIX makefiles} - -TODO. - -Debugging information is included by default; you may add DEBUG= as an -argument to make to compile without it, or use the UNIX {\bf strip} -command to remove debugging information from an executable. - -\normalbox{{\it Important note:} Most compiler flags are kept centrally in -src/make.env, which is included by all other makefiles. This is the -file to edit to tailor wxWindows compilation to your environment.} - -\section{Windows-specific files} - -wxWindows application compilation under MS Windows requires at least two -extra files, resource and module definition files. +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. + +\section{Libraries}\label{libraries} + +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}\label{configuration} + +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. + +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}\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. + +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. + +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. + +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. + +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}\label{windowsfiles} + +wxWidgets application compilation under MS Windows requires at least one +extra file: a resource file. \subsection{Resource file}\label{resources} @@ -426,10 +334,10 @@ The least that must be defined in the Windows resource file (extension RC) is the following statement: \begin{verbatim} -rcinclude 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} @@ -443,86 +351,24 @@ the MS Windows SDK documentation. 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) 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{Memory models and memory allocation}\label{memorymodels} - -Under UNIX, memory allocation isn't a problem. Under Windows, the only -really viable way to go is to use the large model, which uses the global -heap instead of the local heap for memory allocation. Unless more than -one read-write data segment is used,% (see \helpref{large data}{largedata} -large model programs may still have multiple instances under MS -C/C++ 7. Microsoft give the following guidelines for producing -multiple-instance large model programs: - -\begin{itemize}\itemsep=0pt -\item Do not use {\tt /ND} to name extra data segments unless the segment is READONLY. -\item Use the .DEF file to mark extra data segments READONLY. -\item Do not use \_\_far or FAR to mark data items. -\item Use {\tt /PACKDATA} to combine data segments. -\item Use {\tt /Gt65500 /Gx} to force all data into the default data segment. -\end{itemize} - -Even with the single-instance limitation, the productivity benefit is -worth it in the majority of cases. Note that some other multi-platform -class libraries also have this restriction. (If more than one instance -really is required, create several copies of the program with different -names.) - -Having chosen the large model, just use C++ `new', `delete' (and if -necessary `malloc' and `free') in the normal way. The only restrictions -now encountered are a maximum of 64 KB for a single program segment and -for a single data item, unless huge model is selected. - -For Borland users, use the data threshold switch, and the following is -also recommended: - -\begin{itemize}\itemsep=0pt -\item Check ``Automatic Far Data Segments" -\item Check ``Put Constant Strings into Code Segment" -\end{itemize} - -See also the Frequently Asked Questions document for further details -on using Borland with wxWindows. - -\subsection{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, all of its children and descendants will be automatically deleted, so you don't need to delete these descendants explicitly. -Don't statically create a window unless you know that the window -cannot be deleted dynamically. Modal dialogs, such as those used -in the {\tt dialogs} sample, can usually be created statically, -if you know that the OK or Cancel button does not destroy the dialog. +When deleting a frame or dialog, use {\bf Destroy} rather than {\bf delete} so +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. -Most drawing objects, such as wxPen, wxBrush, wxFont, and wxBitmap, should be -created dynamically. They are cleaned up automatically on program exit. -wxColourMap is an exception to this rule (currently). In particular, -do not attempt to create these objects globally before OnInit() has a chance -to be called, because wxWindows might not have done essential internal initialisation -(including creation of lists containing all instances of wxPen, wxBrush etc.) +Don't create a window on the stack, because this will interfere +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 @@ -531,97 +377,76 @@ 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 -make calls like wxDC::SetPen(NULL) or wxDC::SelectObject(NULL) before deleting +make calls like wxDC::SetPen(wxNullPen) or wxDC::SelectObject(wxNullBitmap) before deleting 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{Dynamic Link Libraries} +\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). wxWidgets +defines types and macros that make it easy to write architecture independent +code. The types are: -wxWindows may be used to produce DLLs which run under MS Windows. Note that -this is not the same thing as having wxWindows as a DLL, which is not -currently possible. For Microsoft C++, use the makefile with the argument DLL=1 to produce -a version of the wxWindows library which may be used in a DLL application. -There is a bug in Microsoft C++ which makes the compiler complain about returned floats, -which goes away when the {\tt /Os} option is used, which is why that flag is -set in the makefile. +wxInt32, wxInt16, wxInt8, wxUint32, wxUint16 = wxWord, wxUint8 = wxByte -For making wxWindows as a Sun dynamic library, there are comments in the -UNIX makefile for the appropriate flags for AT\&T C++. Sorry, I haven't -investigated the flags needed for other compilers. +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). -\section{Conditional compilation} +The macros handling bit-swapping with respect to the applications endianness +are described in the \helpref{Byte order macros}{byteordermacros} section. -One of the purposes of wxWindows is to reduce the need for conditional +\section{Conditional compilation}\label{conditionalcompilation} + +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 following identifiers -may be used for this purpose, along with any user-supplied ones: - -\begin{itemize} -\item {\tt wx\_x} - for code which should work under any X toolkit -\item {\tt wx\_motif} - for code which should work under Motif only -\item {\tt wx\_msw} - for code which should work under Microsoft Windows only -\item {\tt wx\_xt} - for code which should work under Xt only -\end{itemize} +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. -For example: +\section{C++ issues}\label{cpp} -\begin{verbatim} - ... -#ifdef wx_x - (void)wxMessageBox("Sorry, metafiles not available under X."); -#endif -#ifdef wx_msw - wxMetaFileDC dc; - DrawIt(dc); - wxMetaFile *mf = dc.Close(); - mf->SetClipboard(); - delete mf; -#endif - ... -\end{verbatim} - -\section{Building on-line help} +The following documents some miscellaneous C++ issues. -wxWindows has its own help system from version 1.30: wxHelp. It can be -used to view the wxWindows class library reference, and also to provide -on-line help for your wxWindows applications. The API, made accessible -by including {\tt wx\_help.h}, allows you to load files and display -specific sections, using DDE to communicate between the application and -wxHelp. +\subsection{Templates}\label{templates} -wxHelp files can be marked up by hand from ASCII files within wxHelp, -or may be generated from other files, as is the case with the wxWindows -documentation. +wxWidgets does not use templates (except for some advanced features that +are switched off by default) since it is a notoriously unportable feature. -It is possible to use the platform-specific help -system (e.g. WinHelp) instead of wxHelp. +\subsection{RTTI}\label{rtti} -See {\tt install.txt}, the wxHelp documentation (in {\tt -utils/wxhelp/docs}) and \helpref{wxHelp}{wxhelp} for further details. +wxWidgets does not use C++ run-time type information since wxWidgets provides +its own run-time type information system, implemented using macros. -\section{C++ issues} +\subsection{Type of NULL}\label{null} -There are cases where a C++ program will compile and run fine under one -environment, and then fail to compile using a different compiler. Some -caveats are given below, from experience with the GNU C++ compiler (GCC) -and MS C/C++ compiler version 7. +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 +as -\subsection{Templates} +{\small +\begin{verbatim} + wxWindow *my_window = (wxWindow*) NULL; +\end{verbatim} +}% -wxWindows does not use templates for two main reasons: one, it is a -notoriously unportable feature, and two, the author is irrationally -suspicious of them and prefers to use casts. More compilers are -now implementing templates, and so it will probably be safe to use -them soon without fear of portability problems. +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 +recommended approach is to precompile {\tt "wx.h"}, using this +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. @@ -629,20 +454,19 @@ 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 -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 considerably. For this reason, you will find (in the common X and Windows parts of the library) conditional -compilation that under UNIX, includes a minimal set of headers; +compilation that under Unix, includes a minimal set of headers; and when using Visual C++, includes {\tt wx.h}. This should help provide the optimal compilation for each compiler, although it is -biassed towards the precompiled headers facility available +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 @@ -652,197 +476,162 @@ 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 FileNameFromPath} allows the application to +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 +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 +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 +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. -\chapter{Utilities supplied with wxWindows}\label{utilities} +\chapter{Utilities and libraries supplied with wxWidgets}\label{utilities} \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% \setfooter{\thepage}{}{}{}{}{\thepage}% -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 larger user-contributed packages, -see the directory /pub/packages/wxwin/contrib. - -\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 modelled 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. - -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} - -Tex2RTF is used for the wxWindows manuals and can be used independently +In addition to the core wxWidgets library, a number of further +libraries and utilities are supplied with each distribution. + +Some are under the 'contrib' hierarchy which mirrors the +structure of the main wxWidgets hierarchy. See also the 'utils' +hierarchy. The first place to look for documentation about +these tools and libraries is under the wxWidgets 'docs' hierarchy, +for example {\tt docs/htmlhelp/fl.chm}. + +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. - -\section{wxTreeLayout} - -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. - -Directed graphs may also be drawn using this library, if cycles are -removed before the nodes and arcs are passed to the algorithm. - -Tree displays are used in many applications: directory browsers, -hypertext systems, class browsers, and decision trees are a few -possibilities. - -See the separate manual and the directory utils/wxtree. - -\section{wxGraphLayout} - -The wxGraphLayout class is based on a tool called `graphplace' by Dr. -Jos T.J. van Eijndhoven of Eindhoven University of Technology. Given a -(possibly cyclic) directed graph, it does its best to lay out the nodes -in a sensible manner. There are many applications (such as diagramming) -where it is required to display a graph with no human intervention. Even -if manual repositioning is later required, this algorithm can make a good -first attempt. - -See the separate manual and the directory utils/wxgraph. - -\section{wxImage}\label{wximage} - -This is a collection of GIF/BMP/XBM bitmap loading and displaying -routines for X. - -\section{MFUTILS}\label{mfutils} - -A very modest step towards reading Windows metafiles on the -any platform. Julian Smart's ClockWorks program demonstrates -how extremely simple metafiles may be read and displayed (in this -case, to be used as clock hands). - -\section{Colours}\label{coloursampler} - -A colour sampler for viewing colours and their names on each -platform. - -% -\chapter{Tutorial}\label{tutorial} -\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% -\setfooter{\thepage}{}{}{}{}{\thepage}% - -To be written. +\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}. +\item[{\bf Configuration Tool}] +The wxWidgets Configuration Tool is a work in progress +intended to make it easier to configure wxWidgets +features in detail. It exports setup.h configurations and will +eventually generate makefile config files. Invoking compilers is +also on the cards. Since configurations are +handled one at a time, the tool is of limited used until further +development can be done. The program can be found in {\tt utils/configtool}. +\item[{\bf XRC resource system}] +This is the sizer-aware resource system, and uses +XML-based resource specifications that can be generated by tools +such as \urlref{wxDesigner}{http://www.roebling.de}. +You can find this in {\tt src/xrc}, {\tt include/wx/xrc}, {\tt samples/xrc}. +For more information, see the \helpref{XML-based resource system overview}{xrcoverview}. +\item[{\bf Object Graphics Library}] +OGL defines an API for applications that need to display objects connected by lines. +The objects can be moved around and interacted with. +You can find this in {\tt contrib/src/ogl}, {\tt contrib/include/wx/ogl}, and {\tt contrib/samples/ogl}. +\item[{\bf Frame Layout library}] +FL provides sophisticated pane dragging and docking facilities. +You can find this in {\tt contrib/src/fl}, {\tt contrib/include/wx/fl}, and {\tt contrib/samples/fl}. +\item[{\bf Gizmos library}] +Gizmos is a collection of useful widgets and other classes. Classes include wxLEDNumberCtrl, +wxEditableListBox, wxMultiCellCanvas. +You can find this in {\tt contrib/src/gizmos}, {\tt contrib/include/wx/gizmos}, and {\tt contrib/samples/gizmos}. +\item[{\bf Net library}] +Net is a collection of very simple mail and web related classes. Currently +there is only wxEmail, which makes it easy to send email messages via MAPI on Windows or sendmail on Unix. +You can find this in {\tt contrib/src/net} and {\tt contrib/include/wx/net}. +\item[{\bf Animate library}] +Animate allows you to load animated GIFs and play them on a window. The library can be extended +to use other animation formats. +You can find this in {\tt contrib/src/animate}, {\tt contrib/include/wx/animate}, and {\tt contrib/samples/animate}. +\item[{\bf MMedia library}] +Mmedia supports a variety of multimedia functionality. The status of this library is currently unclear. +You can find this in {\tt contrib/src/mmedia}, {\tt contrib/include/wx/mmedia}, and {\tt contrib/samples/mmedia}. +\item[{\bf Styled Text Control library}] +STC is a wrapper around Scintilla, a syntax-highlighting text editor. +You can find this in {\tt contrib/src/stc}, {\tt contrib/include/wx/stc}, and {\tt contrib/samples/stc}. +\item[{\bf Plot}] +Plot is a simple curve plotting library. +You can find this in {\tt contrib/src/plot}, {\tt contrib/include/wx/plot}, and {\tt contrib/samples/plot}. +\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 +Although I haven't done this myself within wxWidgets, 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 +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} +\subsection{Use wxString in preference to character arrays}\label{usewxstring} Using wxString can be much safer and more convenient than using char *. -Again, I haven't practised what I'm preaching, but I'm now trying to use +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's much more convenient to use the overloaded +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). 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 relative positioning or constraints}\label{userelativepositioning} 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. If you needs are simple, the default relative positioning -behaviour may be adequate (using default position values and wxPanel::NewLine). +can be complex to program. -Alternatively, you could use alternative .wrc (wxWindows resource files) on different +Alternatively, you could use alternative .wrc (wxWidgets resource files) on different platforms, with slightly different dimensions in each. Or space your panel items out to avoid problems. -\subsection{Use wxWindows resource files} +\subsection{Use wxWidgets resource files}\label{useresources} -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. -\section{Strategies for debugging} +\section{Strategies for debugging}\label{debugstrategies} -\subsection{Positive thinking} +\subsection{Positive thinking}\label{positivethinking} -It's common to blow up the problem in one's imagination, so that it seems to threaten +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: 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 @@ -854,7 +643,7 @@ 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. -\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 @@ -867,58 +656,33 @@ 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! -\subsection{Genetic mutation} +\subsection{Use a debugger}\label{usedebugger} -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. +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 a debugger} +\subsection{Use logging functions}\label{uselogging} -This sounds like facetious advice, but it's surprising how often people -don't use a debugger. Often it's an overhead to install or learn how to -use a debugger, but it really is essential for anything but the most -trivial programs. Some platforms don't allow for debugging, such -as WIN32s under Windows 3.x. In this case, you might be advised to -debug under 16-bit Windows and when you're confident, compile for -WIN32s. In fact WIN32s can be very strict about bad memory handling, -so testing out under WIN32s is a good thing to do even if you're -not going to distribute this version. (Unless you've got a good memory checking, -utility, of course!) Tracking bugs under WIN32s can involve a lot of debug message -insertion and relinking, so make sure your compiler has a fast linker -(e.g. Watcom, Symantec). - -\subsection{Use tracing code} - -You can use wxDebugMsg statements (or the wxDebugStreamBuf class) to -output to a debugging window such as DBWIN under Windows, or standard -error under X. If compiling in DEBUG mode, you can use TRACE statements -that will be compiled out of the final build of your application. +There is a variety of logging functions that you can use in your program: +see \helpref{Logging functions}{logfunctions}. 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). -\subsection{Use wxObject::Dump and the wxDebugContext class} - -It's good practice to implement the Dump member function for all -classes derived from wxObject. You can then make use of wxDebugContext -to dump out information on all objects in the program, if DEBUG is -defined to be more than zero. You can use wxDebugContext to check for -memory leaks and corrupt memory. See the debugging topic in the -reference manual for more information. - -\subsection{Check Windows debug messages} - -Under Windows, it's worth running your program with DBWIN running or -some other program that shows Windows-generated debug messages. It's -possible it'll 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's 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{Use the wxWidgets debugging facilities}\label{usedebuggingfacilities} + +You can use 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. + +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. +