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