]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/body.tex
made wxADJUST_MINSIZE default
[wxWidgets.git] / docs / latex / wx / body.tex
... / ...
CommitLineData
1\chapter{Introduction}\label{introduction}
2\pagenumbering{arabic}%
3\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
4\setfooter{\thepage}{}{}{}{}{\thepage}%
5
6\section{What is wxWindows?}
7
8wxWindows is a C++ framework providing GUI (Graphical User
9Interface) and other facilities on more than one platform. Version 2 currently
10supports all desktop versions of MS Windows, Unix with GTK+, Unix with Motif,
11and MacOS. An OS/2 port is in progress.
12
13wxWindows was originally developed at the Artificial Intelligence
14Applications Institute, University of Edinburgh, for internal use,
15and was first made publicly available in 1992.
16Version 2 is a vastly improved version written and maintained by
17Julian Smart, Robert Roebling, Vadim Zeitlin, Vaclav Slavik and many others.
18
19This manual contains a class reference and topic overviews.
20For a selection of wxWindows tutorials, please see the documentation page on the \urlref{wxWindows web site}{http://www.wxwindows.org}.
21
22Please note that in the following, ``MS Windows" often refers to all
23platforms related to Microsoft Windows, including 16-bit and 32-bit
24variants, unless otherwise stated. All trademarks are acknowledged.
25
26\section{Why another cross-platform development tool?}
27
28wxWindows was developed to provide a cheap and flexible way to maximize
29investment in GUI application development. While a number of commercial
30class libraries already existed for cross-platform development,
31none met all of the following criteria:
32
33\begin{enumerate}\itemsep=0pt
34\item low price;
35\item source availability;
36\item simplicity of programming;
37\item support for a wide range of compilers.
38\end{enumerate}
39
40Since wxWindows was started, several other free or almost-free
41GUI frameworks have emerged. However, none has the range of
42features, flexibility, documentation and the well-established
43development team that wxWindows has.
44
45As open source software, wxWindows has benefited from comments,
46ideas, bug fixes, enhancements and the sheer enthusiasm of
47users. This gives wxWindows a certain advantage over its
48commercial competitors (and over free libraries without an
49independent development team), plus a robustness against the
50transience of one individual or company. This openness and
51availability of source code is especially important when the
52future of thousands of lines of application code may depend upon
53the longevity of the underlying class library.
54
55Version 2 goes much further than previous versions in terms of
56generality and features, allowing applications to be produced
57that are often indistinguishable from those produced using
58single-platform toolkits such as Motif, GTK+ and MFC.
59
60The importance of using a platform-independent class library
61cannot be overstated, since GUI application development is very
62time-consuming, and sustained popularity of particular GUIs
63cannot be guaranteed. Code can very quickly become obsolete if
64it addresses the wrong platform or audience. wxWindows helps to
65insulate the programmer from these winds of change. Although
66wxWindows may not be suitable for every application (such as an
67OLE-intensive program), it provides access to most of the
68functionality a GUI program normally requires, plus many extras
69such as network programming, PostScript output, and HTML
70rendering; and it can of course be extended as needs dictate.
71As a bonus, it provides a far cleaner and easier programming
72interface than the native APIs. Programmers may find it
73worthwhile to use wxWindows even if they are developing on only
74one platform.
75
76It is impossible to sum up the functionality of wxWindows in a few paragraphs, but
77here are some of the benefits:
78
79\begin{itemize}\itemsep=0pt
80\item Low cost (free, in fact!)
81\item You get the source.
82\item Available on a variety of popular platforms.
83\item Works with almost all popular C++ compilers and Python.
84\item Over 50 example programs.
85\item Over 1000 pages of printable and on-line documentation.
86\item Includes Tex2RTF, to allow you to produce your own documentation
87in Windows Help, HTML and Word RTF formats.
88\item Simple-to-use, object-oriented API.
89\item Flexible event system.
90\item Graphics calls include lines, rounded rectangles, splines, polylines, etc.
91\item Constraint-based and sizer-based layouts.
92\item Print/preview and document/view architectures.
93\item Toolbar, notebook, tree control, advanced list control classes.
94\item PostScript generation under Unix, normal MS Windows printing on the PC.
95\item MDI (Multiple Document Interface) support.
96\item Can be used to create DLLs under Windows, dynamic libraries on Unix.
97\item Common dialogs for file browsing, printing, colour selection, etc.
98\item Under MS Windows, support for creating metafiles and copying
99them to the clipboard.
100\item An API for invoking help from applications.
101\item Ready-to-use HTML window (supporting a subset of HTML).
102\item Network support via a family of socket and protocol classes.
103\item Support for platform independent image processing.
104\item Built-in support for many file formats (BMP, PNG, JPEG, GIF, XPM, PNM, PCX).
105\end{itemize}
106
107\begin{comment}
108\section{Changes from version 2.0}\label{versionchanges20}
109
110These are a few of the differences between versions 2.0 and 2.2.
111
112Removals:
113
114\begin{itemize}\itemsep=0pt
115\item GTK 1.0 no longer supported.
116\end{itemize}
117
118Additions and changes:
119
120\begin{itemize}\itemsep=0pt
121\item Corrected many classes to conform better to documented behaviour.
122\item Added handlers for more image formats (Now GIF, JPEG, PCX, BMP, XPM, PNG, PNM).
123\item Improved support for socket and network functions.
124\item Support for different national font encodings.
125\item Sizer based layout system.
126\item HTML widget and help system.
127\item Added some controls (e.g. wxSpinCtrl) and supplemented many.
128\item Many optical improvements to GTK port.
129\item Support for menu accelerators in GTK port.
130\item Enhanced and improved support for scrolling, including child windows.
131\item Complete rewrite of clipboard and drag and drop classes.
132\item Improved support for ODBC databases.
133\item Improved tab traversal in dialogs.
134\end{itemize}
135\end{comment}
136
137\section{wxWindows requirements}\label{requirements}
138
139To make use of wxWindows, you currently need one of the following setups.
140
141(a) MS-Windows:
142
143\begin{enumerate}\itemsep=0pt
144\item A 486 or higher PC running MS Windows.
145\item A Windows compiler: most are supported, but please see {\tt install.txt} for
146details. Supported compilers include Microsoft Visual C++ 4.0 or higher, Borland C++, Cygwin,
147MinGW, Metrowerks CodeWarrior.
148\item At least 60 MB of disk space.
149\end{enumerate}
150
151(b) Unix:
152
153\begin{enumerate}\itemsep=0pt
154\item Almost any C++ compiler, including GNU C++ (EGCS 1.1.1 or above).
155\item Almost any Unix workstation, and one of: GTK+ 1.2, GTK+ 2.0, Motif 1.2 or higher, Lesstif.
156If using the wxX11 port, no such widget set is required.
157\item At least 60 MB of disk space.
158\end{enumerate}
159
160(c) Mac OS/Mac OS X:
161
162\begin{enumerate}\itemsep=0pt
163\item A PowerPC Mac running Mac OS 8.6/9.x (eg. Classic) or Mac OS X 10.x.
164\item CodeWarrior 5.3, 6 or 7 for Classic Mac OS.
165\item The Apple Developer Tools (eg. GNU C++) or CodeWarrior 7 for Mac OS X.
166\item At least 60 MB of disk space.
167\end{enumerate}
168
169\section{Availability and location of wxWindows}
170
171\winhelponly{wxWindows is available by anonymous FTP and World Wide Web
172from ftp://biolpc22.york.ac.uk/pub and/or http://www.wxwindows.org.}
173\winhelpignore{wxWindows is available by anonymous FTP and World Wide Web
174from \urlref{ftp://biolpc22.york.ac.uk/pub}{ftp://biolpc22.york.ac.uk/pub}
175and/or \urlref{http://www.wxwindows.org}{http://www.wxwindows.org}.}
176
177You can also buy a CD-ROM using the form on the Web site.
178
179\section{Acknowledgements}
180
181Thanks are due to AIAI for being willing to release the original version of
182wxWindows into the public domain, and to our patient partners.
183
184We would particularly like to thank the following for their contributions to wxWindows, and the many others who have been involved in
185the project over the years. Apologies for any unintentional omissions from this list.
186
187Yiorgos Adamopoulos, Jamshid Afshar, Alejandro Aguilar-Sierra, AIAI, Patrick Albert, Karsten Ballueder, Michael Bedward, Kai Bendorf, Yura Bidus, Keith
188Gary Boyce, Chris Breeze, Pete Britton, Ian Brown, C. Buckley, Dmitri Chubraev, Robin Corbet, Cecil Coupe, Andrew Davison, Neil Dudman, Robin
189Dunn, Hermann Dunkel, Jos van Eijndhoven, Tom Felici, Thomas Fettig, Matthew Flatt, Pasquale Foggia, Josep Fortiana, Todd Fries, Dominic Gallagher,
190Guillermo Rodriguez Garcia, Wolfram Gloger, Norbert Grotz, Stefan Gunter, Bill Hale, Patrick Halke, Stefan Hammes, Guillaume Helle, Harco de Hilster, Cord Hockemeyer, Markus
191Holzem, Olaf Klein, Leif Jensen, Bart Jourquin, Guilhem Lavaux, Jan Lessner, Nicholas Liebmann, Torsten Liermann, Per Lindqvist, Thomas Runge, Tatu
192M\"{a}nnist\"{o}, Scott Maxwell, Thomas Myers, Oliver Niedung, Stefan Neis, Hernan Otero, Ian Perrigo, Timothy Peters, Giordano Pezzoli, Harri Pasanen, Thomaso Paoletti,
193Garrett Potts, Marcel Rasche, Robert Roebling, Dino Scaringella, Jobst Schmalenbach, Arthur Seaton, Paul Shirley, Vaclav Slavik, Stein Somers, Petr Smilauer, Neil Smith,
194Kari Syst\"{a}, Arthur Tetzlaff-Deas, Jonathan Tonberg, Jyrki Tuomi, David Webster, Janos Vegh, Andrea Venturoli, Vadim Zeitlin, Xiaokun Zhu, Edward Zimmermann.
195
196`Graphplace', the basis for the wxGraphLayout library, is copyright Dr. Jos
197T.J. van Eijndhoven of Eindhoven University of Technology. The code has
198been used in wxGraphLayout with his permission.
199
200We also acknowledge the author of XFIG, the excellent Unix drawing tool,
201from the source of which we have borrowed some spline drawing code.
202His copyright is included below.
203
204{\it XFig2.1 is copyright (c) 1985 by Supoj Sutanthavibul. Permission to
205use, copy, modify, distribute, and sell this software and its
206documentation for any purpose is hereby granted without fee, provided
207that the above copyright notice appear in all copies and that both that
208copyright notice and this permission notice appear in supporting
209documentation, and that the name of M.I.T. not be used in advertising or
210publicity pertaining to distribution of the software without specific,
211written prior permission. M.I.T. makes no representations about the
212suitability of this software for any purpose. It is provided ``as is''
213without express or implied warranty.}
214
215\chapter{Multi-platform development with wxWindows}\label{multiplat}
216\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
217\setfooter{\thepage}{}{}{}{}{\thepage}%
218
219This chapter describes the practical details of using wxWindows. Please
220see the file install.txt for up-to-date installation instructions, and
221changes.txt for differences between versions.
222
223\section{Include files}
224
225The main include file is {\tt "wx/wx.h"}; this includes the most commonly
226used modules of wxWindows.
227
228To save on compilation time, include only those header files relevant to the
229source file. If you are using precompiled headers, you should include
230the following section before any other includes:
231
232\begin{verbatim}
233// For compilers that support precompilation, includes "wx.h".
234#include <wx/wxprec.h>
235
236#ifdef __BORLANDC__
237#pragma hdrstop
238#endif
239
240#ifndef WX_PRECOMP
241// Include your minimal set of headers here, or wx.h
242#include <wx/wx.h>
243#endif
244
245... now your other include files ...
246\end{verbatim}
247
248The file {\tt "wx/wxprec.h"} includes {\tt "wx/wx.h"}. Although this incantation
249may seem quirky, it is in fact the end result of a lot of experimentation,
250and several Windows compilers to use precompilation (those tested are Microsoft Visual C++, Borland C++
251and Watcom C++).
252
253Borland precompilation is largely automatic. Visual C++ requires specification of {\tt "wx/wxprec.h"} as
254the file to use for precompilation. Watcom C++ is automatic apart from the specification of
255the .pch file. Watcom C++ is strange in requiring the precompiled header to be used only for
256object files compiled in the same directory as that in which the precompiled header was created.
257Therefore, the wxWindows Watcom C++ makefiles go through hoops deleting and recreating
258a single precompiled header file for each module, thus preventing an accumulation of many
259multi-megabyte .pch files.
260
261\section{Libraries}
262
263Most ports of wxWindows can create either a static library or a shared
264library. wxWindows can also be built in multilib and monolithic variants.
265See the \helpref{libraries list}{librarieslist} for more
266information on these.
267
268\section{Configuration}
269
270When using project files and makefiles directly to build wxWindows,
271options are configurable in the file
272\rtfsp{\tt "wx/XXX/setup.h"} where XXX is the required platform (such as msw, motif, gtk, mac). Some
273settings are a matter of taste, some help with platform-specific problems, and
274others can be set to minimize the size of the library. Please see the setup.h file
275and {\tt install.txt} files for details on configuration.
276
277When using the 'configure' script to configure wxWindows (on Unix and other platforms where
278configure is available), the corresponding setup.h files are generated automatically
279along with suitable makefiles. When using the RPM packages
280for installing wxWindows on Linux, a correct setup.h is shipped in the package and
281this must not be changed.
282
283\section{Makefiles}
284
285On Microsoft Windows, wxWindows has a different set of makefiles for each
286compiler, because each compiler's 'make' tool is slightly different.
287Popular Windows compilers that we cater for, and the corresponding makefile
288extensions, include: Microsoft Visual C++ (.vc), Borland C++ (.bcc),
289OpenWatcom C++ (.wat) and MinGW/Cygwin (.gcc). Makefiles are provided
290for the wxWindows library itself, samples, demos, and utilities.
291
292On Linux, Mac and OS/2, you use the 'configure' command to
293generate the necessary makefiles. You should also use this method when
294building with MinGW/Cygwin on Windows.
295
296We also provide project files for some compilers, such as
297Microsoft VC++. However, we recommend using makefiles
298to build the wxWindows library itself, because makefiles
299can be more powerful and less manual intervention is required.
300
301On Windows using a compiler other than MinGW/Cygwin, you would
302build the wxWindows library from the build/msw directory
303which contains the relevant makefiles.
304
305On Windows using MinGW/Cygwin, and on Unix, MacOS X and OS/2, you invoke
306'configure' (found in the top-level of the wxWindows source hierarchy),
307from within a suitable empty directory for containing makefiles, object files and
308libraries.
309
310For details on using makefiles, configure, and project files,
311please see docs/xxx/install.txt in your distribution, where
312xxx is the platform of interest, such as msw, gtk, x11, mac.
313
314\section{Windows-specific files}
315
316wxWindows application compilation under MS Windows requires at least two
317extra files, resource and module definition files.
318
319\subsection{Resource file}\label{resources}
320
321The least that must be defined in the Windows resource file (extension RC)
322is the following statement:
323
324\begin{verbatim}
325#include "wx/msw/wx.rc"
326\end{verbatim}
327
328which includes essential internal wxWindows definitions. The resource script
329may also contain references to icons, cursors, etc., for example:
330
331\begin{verbatim}
332wxicon icon wx.ico
333\end{verbatim}
334
335The icon can then be referenced by name when creating a frame icon. See
336the MS Windows SDK documentation.
337
338\normalbox{Note: include wx.rc {\it after} any ICON statements
339so programs that search your executable for icons (such
340as the Program Manager) find your application icon first.}
341
342\section{Allocating and deleting wxWindows objects}
343
344In general, classes derived from wxWindow must dynamically allocated
345with {\it new} and deleted with {\it delete}. If you delete a window,
346all of its children and descendants will be automatically deleted,
347so you don't need to delete these descendants explicitly.
348
349When deleting a frame or dialog, use {\bf Destroy} rather than {\bf delete} so
350that the wxWindows delayed deletion can take effect. This waits until idle time
351(when all messages have been processed) to actually delete the window, to avoid
352problems associated with the GUI sending events to deleted windows.
353
354Don't create a window on the stack, because this will interfere
355with delayed deletion.
356
357If you decide to allocate a C++ array of objects (such as wxBitmap) that may
358be cleaned up by wxWindows, make sure you delete the array explicitly
359before wxWindows has a chance to do so on exit, since calling {\it delete} on
360array members will cause memory problems.
361
362wxColour can be created statically: it is not automatically cleaned
363up and is unlikely to be shared between other objects; it is lightweight
364enough for copies to be made.
365
366Beware of deleting objects such as a wxPen or wxBitmap if they are still in use.
367Windows is particularly sensitive to this: so make sure you
368make calls like wxDC::SetPen(wxNullPen) or wxDC::SelectObject(wxNullBitmap) before deleting
369a drawing object that may be in use. Code that doesn't do this will probably work
370fine on some platforms, and then fail under Windows.
371
372\section{Architecture dependency}
373
374A problem which sometimes arises from writing multi-platform programs is that
375the basic C types are not defined the same on all platforms. This holds true
376for both the length in bits of the standard types (such as int and long) as
377well as their byte order, which might be little endian (typically
378on Intel computers) or big endian (typically on some Unix workstations). wxWindows
379defines types and macros that make it easy to write architecture independent
380code. The types are:
381
382wxInt32, wxInt16, wxInt8, wxUint32, wxUint16 = wxWord, wxUint8 = wxByte
383
384where wxInt32 stands for a 32-bit signed integer type etc. You can also check
385which architecture the program is compiled on using the wxBYTE\_ORDER define
386which is either wxBIG\_ENDIAN or wxLITTLE\_ENDIAN (in the future maybe wxPDP\_ENDIAN
387as well).
388
389The macros handling bit-swapping with respect to the applications endianness
390are described in the \helpref{Byte order macros}{byteordermacros} section.
391
392\section{Conditional compilation}
393
394One of the purposes of wxWindows is to reduce the need for conditional
395compilation in source code, which can be messy and confusing to follow.
396However, sometimes it is necessary to incorporate platform-specific
397features (such as metafile use under MS Windows). The symbols
398listed in the file {\tt symbols.txt} may be used for this purpose,
399along with any user-supplied ones.
400
401\section{C++ issues}
402
403The following documents some miscellaneous C++ issues.
404
405\subsection{Templates}
406
407wxWindows does not use templates (except for some advanced features that
408are switched off by default) since it is a notoriously unportable feature.
409
410\subsection{RTTI}
411
412wxWindows does not use C++ run-time type information since wxWindows provides
413its own run-time type information system, implemented using macros.
414
415\subsection{Type of NULL}
416
417Some compilers (e.g. the native IRIX cc) define NULL to be 0L so that
418no conversion to pointers is allowed. Because of that, all these
419occurrences of NULL in the GTK+ port use an explicit conversion such
420as
421
422{\small
423\begin{verbatim}
424 wxWindow *my_window = (wxWindow*) NULL;
425\end{verbatim}
426}%
427
428It is recommended to adhere to this in all code using wxWindows as
429this make the code (a bit) more portable.
430
431\subsection{Precompiled headers}
432
433Some compilers, such as Borland C++ and Microsoft C++, support
434precompiled headers. This can save a great deal of compiling time. The
435recommended approach is to precompile {\tt "wx.h"}, using this
436precompiled header for compiling both wxWindows itself and any
437wxWindows applications. For Windows compilers, two dummy source files
438are provided (one for normal applications and one for creating DLLs)
439to allow initial creation of the precompiled header.
440
441However, there are several downsides to using precompiled headers. One
442is that to take advantage of the facility, you often need to include
443more header files than would normally be the case. This means that
444changing a header file will cause more recompilations (in the case of
445wxWindows, everything needs to be recompiled since everything includes {\tt "wx.h"}!)
446
447A related problem is that for compilers that don't have precompiled
448headers, including a lot of header files slows down compilation
449considerably. For this reason, you will find (in the common
450X and Windows parts of the library) conditional
451compilation that under Unix, includes a minimal set of headers;
452and when using Visual C++, includes {\tt wx.h}. This should help provide
453the optimal compilation for each compiler, although it is
454biased towards the precompiled headers facility available
455in Microsoft C++.
456
457\section{File handling}
458
459When building an application which may be used under different
460environments, one difficulty is coping with documents which may be
461moved to different directories on other machines. Saving a file which
462has pointers to full pathnames is going to be inherently unportable. One
463approach is to store filenames on their own, with no directory
464information. The application searches through a number of locally
465defined directories to find the file. To support this, the class {\bf
466wxPathList} makes adding directories and searching for files easy, and
467the global function {\bf wxFileNameFromPath} allows the application to
468strip off the filename from the path if the filename must be stored.
469This has undesirable ramifications for people who have documents of the
470same name in different directories.
471
472As regards the limitations of DOS 8+3 single-case filenames versus
473unrestricted Unix filenames, the best solution is to use DOS filenames
474for your application, and also for document filenames {\it if} the user
475is likely to be switching platforms regularly. Obviously this latter
476choice is up to the application user to decide. Some programs (such as
477YACC and LEX) generate filenames incompatible with DOS; the best
478solution here is to have your Unix makefile rename the generated files
479to something more compatible before transferring the source to DOS.
480Transferring DOS files to Unix is no problem, of course, apart from EOL
481conversion for which there should be a utility available (such as
482dos2unix).
483
484See also the File Functions section of the reference manual for
485descriptions of miscellaneous file handling functions.
486
487\chapter{Utilities and libraries supplied with wxWindows}\label{utilities}
488\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
489\setfooter{\thepage}{}{}{}{}{\thepage}%
490
491In addition to the core wxWindows library, a number of further
492libraries and utilities are supplied with each distribution.
493
494Some are under the 'contrib' hierarchy which mirrors the
495structure of the main wxWindows hierarchy. See also the 'utils'
496hierarchy. The first place to look for documentation about
497these tools and libraries is under the wxWindows 'docs' hierarchy,
498for example {\tt docs/htmlhelp/fl.chm}.
499
500For other user-contributed packages, please see the Contributions page
501on the \urlref{wxWindows Web site}{http://www.wxwindows.org}.
502
503\begin{description}\itemsep=0pt
504\item[{\bf Helpview}]
505Helpview is a program for displaying wxWindows HTML
506Help files. In many cases, you may wish to use the wxWindows HTML
507Help classes from within your application, but this provides a
508handy stand-alone viewer. See \helpref{wxHTML Notes}{wxhtml} for more details.
509You can find it in {\tt samples/html/helpview}.
510\item[{\bf Tex2RTF}]
511Supplied with wxWindows is a utility called Tex2RTF for converting\rtfsp
512\LaTeX\ manuals HTML, MS HTML Help, wxHTML Help, RTF, and Windows
513Help RTF formats. Tex2RTF is used for the wxWindows manuals and can be used independently
514by authors wishing to create on-line and printed manuals from the same\rtfsp
515\LaTeX\ source. Please see the separate documentation for Tex2RTF.
516You can find it under {\tt utils/tex2rtf}.
517\item[{\bf Helpgen}]
518Helpgen takes C++ header files and generates a Tex2RTF-compatible
519documentation file for each class it finds, using comments as appropriate.
520This is a good way to start a reference for a set of classes.
521Helpgen can be found in {\tt utils/HelpGen}.
522\item[{\bf Emulator}]
523Xnest-based display emulator for X11-based PDA applications. On some
524systems, the Xnest window does not synchronise with the
525'skin' window. This program can be found in {\tt utils/emulator}.
526\item[{\bf Configuration Tool}]
527The wxWindows Configuration Tool is a work in progress
528intended to make it easier to configure wxWindows
529features in detail. It exports setup.h configurations and will
530eventually generate makefile config files. Invoking compilers is
531also on the cards. Since configurations are
532handled one at a time, the tool is of limited used until further
533development can be done. The program can be found in {\tt utils/configtool}.
534\item[{\bf XRC resource system}]
535This is the sizer-aware resource system, and uses
536XML-based resource specifications that can be generated by tools
537such as \urlref{wxDesigner}{http://www.roebling.de} and XRC's own wxrcedit.
538You can find this in {\tt contrib/src/xrc}, {\tt contrib/include/wx/xrc}, {\tt contrib/samples/xrc}, and {\tt contrib/utils/wxrcedit}.
539For more information, see the \helpref{XML-based resource system overview}{xrcoverview}.
540\item[{\bf Object Graphics Library}]
541OGL defines an API for applications that need to display objects connected by lines.
542The objects can be moved around and interacted with.
543You can find this in {\tt contrib/src/ogl}, {\tt contrib/include/wx/ogl}, and {\tt contrib/samples/ogl}.
544\item[{\bf Frame Layout library}]
545FL provides sophisticated pane dragging and docking facilities.
546You can find this in {\tt contrib/src/fl}, {\tt contrib/include/wx/fl}, and {\tt contrib/samples/fl}.
547\item[{\bf Gizmos library}]
548Gizmos is a collection of useful widgets and other classes. Classes include wxLEDNumberCtrl,
549wxEditableListBox, wxMultiCellCanvas.
550You can find this in {\tt contrib/src/gizmos}, {\tt contrib/include/wx/gizmos}, and {\tt contrib/samples/gizmos}.
551\item[{\bf Net library}]
552Net is a collection of very simple mail and web related classes. Currently
553there is only wxEmail, which makes it easy to send email messages via MAPI on Windows or sendmail on Unix.
554You can find this in {\tt contrib/src/net} and {\tt contrib/include/wx/net}.
555\item[{\bf Animate library}]
556Animate allows you to load animated GIFs and play them on a window. The library can be extended
557to use other animation formats.
558You can find this in {\tt contrib/src/animate}, {\tt contrib/include/wx/animate}, and {\tt contrib/samples/animate}.
559\item[{\bf MMedia library}]
560Mmedia supports a variety of multimedia functionality. The status of this library is currently unclear.
561You can find this in {\tt contrib/src/mmedia}, {\tt contrib/include/wx/mmedia}, and {\tt contrib/samples/mmedia}.
562\item[{\bf Styled Text Control library}]
563STC is a wrapper around Scintilla, a syntax-highlighting text editor.
564You can find this in {\tt contrib/src/stc}, {\tt contrib/include/wx/stc}, and {\tt contrib/samples/stc}.
565\item[{\bf Plot}]
566Plot is a simple curve plotting library.
567You can find this in {\tt contrib/src/plot}, {\tt contrib/include/wx/plot}, and {\tt contrib/samples/plot}.
568\end{description}
569
570\chapter{Programming strategies}\label{strategies}
571\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
572\setfooter{\thepage}{}{}{}{}{\thepage}%
573
574This chapter is intended to list strategies that may be useful when
575writing and debugging wxWindows programs. If you have any good tips,
576please submit them for inclusion here.
577
578\section{Strategies for reducing programming errors}
579
580\subsection{Use ASSERT}
581
582Although I haven't done this myself within wxWindows, it is good
583practice to use ASSERT statements liberally, that check for conditions that
584should or should not hold, and print out appropriate error messages.
585These can be compiled out of a non-debugging version of wxWindows
586and your application. Using ASSERT is an example of `defensive programming':
587it can alert you to problems later on.
588
589\subsection{Use wxString in preference to character arrays}
590
591Using wxString can be much safer and more convenient than using char *.
592Again, I haven't practiced what I'm preaching, but I'm now trying to use
593wxString wherever possible. You can reduce the possibility of memory
594leaks substantially, and it is much more convenient to use the overloaded
595operators than functions such as strcmp. wxString won't add a significant
596overhead to your program; the overhead is compensated for by easier
597manipulation (which means less code).
598
599The same goes for other data types: use classes wherever possible.
600
601\section{Strategies for portability}
602
603\subsection{Use relative positioning or constraints}
604
605Don't use absolute panel item positioning if you can avoid it. Different GUIs have
606very differently sized panel items. Consider using the constraint system, although this
607can be complex to program.
608
609Alternatively, you could use alternative .wrc (wxWindows resource files) on different
610platforms, with slightly different dimensions in each. Or space your panel items out
611to avoid problems.
612
613\subsection{Use wxWindows resource files}
614
615Use .xrc (wxWindows resource files) where possible, because they can be easily changed
616independently of source code.
617
618\section{Strategies for debugging}\label{debugstrategies}
619
620\subsection{Positive thinking}
621
622It is common to blow up the problem in one's imagination, so that it seems to threaten
623weeks, months or even years of work. The problem you face may seem insurmountable:
624but almost never is. Once you have been programming for some time, you will be able
625to remember similar incidents that threw you into the depths of despair. But
626remember, you always solved the problem, somehow!
627
628Perseverance is often the key, even though a seemingly trivial problem
629can take an apparently inordinate amount of time to solve. In the end,
630you will probably wonder why you worried so much. That's not to say it
631isn't painful at the time. Try not to worry -- there are many more important
632things in life.
633
634\subsection{Simplify the problem}
635
636Reduce the code exhibiting the problem to the smallest program possible
637that exhibits the problem. If it is not possible to reduce a large and
638complex program to a very small program, then try to ensure your code
639doesn't hide the problem (you may have attempted to minimize the problem
640in some way: but now you want to expose it).
641
642With luck, you can add a small amount of code that causes the program
643to go from functioning to non-functioning state. This should give a clue
644to the problem. In some cases though, such as memory leaks or wrong
645deallocation, this can still give totally spurious results!
646
647\subsection{Use a debugger}
648
649This sounds like facetious advice, but it is surprising how often people
650don't use a debugger. Often it is an overhead to install or learn how to
651use a debugger, but it really is essential for anything but the most
652trivial programs.
653
654\subsection{Use logging functions}
655
656There is a variety of logging functions that you can use in your program:
657see \helpref{Logging functions}{logfunctions}.
658
659Using tracing statements may be more convenient than using the debugger
660in some circumstances (such as when your debugger doesn't support a lot
661of debugging code, or you wish to print a bunch of variables).
662
663\subsection{Use the wxWindows debugging facilities}
664
665You can use wxDebugContext to check for
666memory leaks and corrupt memory: in fact in debugging mode, wxWindows will
667automatically check for memory leaks at the end of the program if wxWindows is suitably
668configured. Depending on the operating system and compiler, more or less
669specific information about the problem will be logged.
670
671You should also use \helpref{debug macros}{debugmacros} as part of a `defensive programming' strategy,
672scattering wxASSERTs liberally to test for problems in your code as early as possible. Forward thinking
673will save a surprising amount of time in the long run.
674
675See the \helpref{debugging overview}{debuggingoverview} for further information.
676