The m_ prefix denotes a member variable, s_ denotes a static variable, g_ denotes a global variable; local variables generally start with a lowercase letter, for example textCtrl.User interface commands, such as menu and button labels, are marked in italics.
Chapter SummaryChapter 1: IntroductionWhat is wxWidgets, and why use it? A brief history; the wxWidgets community; the license; wxWidgets ports and architecture explained.
Chapter 2: Getting Started A small wxWidgets sample: the application class; the main window; the event table; an outline of program flow.
Chapter 3: Event HandlingEvent tables and handlers; how a button click is processed; skipping events; pluggable and dynamic event handlers; defining custom events; window identifiers.
Chapter 4: Window BasicsThe main features of a window explained; a quick guide to the commonest window classes; base window classes such as wxWindow; top-level windows; container windows; non-static controls; static controls; menus; control bars.
Chapter 5: Drawing and PrintingDevice context principles; the main device context classes described; buffered drawing; drawing tools; device context drawing functions; using the printing framework; 3D graphics with wxGLCanvas.
Chapter 6: Handling InputHandling mouse and mouse wheel events; handling keyboard events; keycodes; modifier key variations; accelerators; handling joystick events.
Chapter 7: Window Layout Using SizersLayout basics; sizers introduced; common features of sizers; programming with sizers. Further layout issues: dialog units; platform-adaptive layouts; dynamic layouts.
Chapter 8: Using Standard DialogsInformative dialogs such as wxMessageBox and wxProgressDialog; file and directory dialogs such as wxFileDialog; choice and selection dialogs such as wxColourDialog and wxFontDialog; entry dialogs such as wxTextEntryDialog and wxFindReplaceDialog; printing dialogs: wxPageSetupDialog and wxPrintDialog.
Chapter 9: Writing Custom DialogsSteps in creating a custom dialog; an example: PersonalRecordDialog; deriving a new class; designing data storage; coding the controls and layout; data transfer and validation; handling events; handling UI updates; adding help; adapting dialogs for small devices; further considerations in dialog design; using wxWidgets resource files; loading resources; using binary and embedded resource files; translating resources; the XRC format; writing resource handlers; foreign controls.
Chapter 10: Programming with ImagesImage classes in wxWidgets; programming with wxBitmap; programming with wxIcon; programming with wxCursor; programming with wxImage; image lists and icon bundles; customizing wxWidgets graphics with wxArtProvider.
Chapter 11: Clipboard and Drag and DropData objects; data source duties; data target duties; using the clipboard; implementing drag and drop; implementing a drag source; implementing a drop target; using standard drop targets; creating a custom drop target; more on wxDataObject; drag and drop helpers in wxWidgets.
Chapter 12: Advanced Window ClasseswxTreeCtrl; wxListCtrl; wxWizard; wxHtmlWindow; wxGrid; wxTaskBarIcon; writing your own controls; the control declaration; defining a new event class; displaying information; handling input; defining default event handlers; implementing validators; implementing resource handlers; determining control appearance.
Chapter 13: Data Structure ClassesWhy not STL? wxString; wxStringTokenizer; wxRegEx; wxArray; wxList; wxHashMap; wxDateTime; wxObject; wxLongLong; wxPoint and wxRealPoint; wxRect; wxRegion; wxSize; wxVariant.
Chapter 14: Files and StreamswxFile and wxFFile; wxTextFile; wxTempFile; wxDir; wxFileName; file functions; file streams; memory and string streams; data streams; socket streams; filter streams; zip streams; virtual file systems.
Chapter 15: Memory Management, Debugging, and Error CheckingCreating and deleting window objects; creating and copying drawing objects; initializing your application object; cleaning up your application; detecting memory leaks and other errors; facilities for defensive programming; error reporting; providing run-time type information; using wxModule; loading dynamic libraries; exception handling; debugging tips.
Chapter 16: Writing International ApplicationsIntroduction to internationalization; providing translations; using message catalogs; using wxLocale; character encodings and Unicode; converting data; help files; numbers and dates; other media; an example.
Chapter 17: Writing Multithreaded ApplicationsWhen to use threads, and when not to; using wxThread; thread creation; starting the thread; how to pause a thread or wait for an external condition; termination; synchronization objects; wxMutex; deadlocks; wxCriticalSection; wxCondition; wxSemaphore; the wxWidgets thread sample; alternatives to multithreading: wxTimer, idle time processing, and yielding.
Chapter 18: Programming with wxSocketSocket classes and functionality overview; introduction to sockets and basic socket processing; connecting to a server; socket events; socket status and error notifications; sending and receiving socket data; creating a server; socket event recap; socket flags; blocking and non-blocking sockets in wxWidgets; how flags affect socket behavior; using wxSocket as a standard socket; using socket streams; alternatives to wxSocket.
Chapter 19: Working with Documents and ViewsDocument/view basics; choosing an interface style; creating and using frame classes; defining your document and view classes; defining your window classes; using wxDocManager and wxDocTemplate; other document/view capabilities; standard identifiers; printing and previewing; file history; explicit document creation; strategies for implementing undo/redo.
Chapter 20: Perfecting Your ApplicationSingle instance versus multiple instances; modifying event handling; reducing flicker; using a help controller; extended wxWidgets HTML help; authoring help; other ways to provide help; parsing the command line; storing application resources; invoking other applications; launching documents; redirecting process input and output; managing application settings; application installation on Windows, Linux and Mac OS X; following UI design guidelines.
Appendix A: Installing wxWidgetsDownloading and unpacking wxWidgets; configuration/build options; WindowsMicrosoft Visual Studio and VC++ command-line; WindowsBorland C++; WindowsMinGW with and without MSYS; Unix/Linux and Mac OS XGCC; customizing setup.h; rebuilding after updating wxWidgets files; using contrib libraries.
Appendix B: Building Your Own wxWidgets ApplicationsWindowsMicrosoft Visual Studio; LinuxKDevelop; Mac OS XXcode; makefiles; cross-platform builds using Bakefile; wxWidgets symbols and headers; using wx-config.
Appendix C: Creating Applications with DialogBlocksWhat is DialogBlocks? Installing and upgrading DialogBlocks; the DialogBlocks interface; the sample project; compiling the sample; creating a new project; creating a dialog; creating a frame; creating an application object; debugging your application.
Appendix D: Other Features in wxWidgetsFurther window classes; ODBC classes; MIME types manager; network functionality; multimedia classes; embedded web browsers; accessibility; OLE automation; renderer classes; event loops.
Appendix E: Third-Party Tools for wxWidgetsLanguage bindings such as wxPython and wxPerl; tools such as wxDesigner, DialogBlocks and poEdit; add-on libraries such as wxMozilla, wxCURL, wxPropertyGrid.
Appendix F: wxWidgets Application ShowcaseDescriptions of notable wxWidgets applications, such as AOL Communicator and Audacity.
Appendix G: Using the CD-ROMBrowsing the CD-ROM; the CD-ROM contents.
Appendix H: How wxWidgets Processes EventsAn illustrated description of how event processing works.
Appendix I: Event Classes and MacrosA summary of the important event classes and macros.
Appendix J: Code ListingsCode listings for the PersonalRecordDialog and the wxWizard examples.
Appendix K: Porting from MFCGeneral observations; application initialization; message maps; converting dialogs and other resources; documents and views; printing; string handling and translation; database access; configurable control bars; equivalent functionality by macros and classes.
AcknowledgmentswxWidgets owes its success to the hard work of many talented people. We would like to thank them all, with special consideration for that essential support network: our long-suffering families and partners. wxWidgets supporters and contributors include the following (apologies for any unintentional omissions):
Yiorgos Adamopoulos, Jamshid Afshar, Alejandro Aguilar-Sierra, Patrick Albert, Bruneau Babet, Mitchell Baker, Mattia Barbon, Nerijus Baliunas, Karsten Ballueder, Jonathan Bayer, Michael Bedward, Kai Bendorf, Yura Bidus, Jorgen Bodde, Borland, Keith Gary Boyce, Chris Breeze, Sylvain Bougnoux, Wade Brainerd, Pete Britton, Ian Brown, C. Buckley, Doug Card, Marco Cavallini, Dmitri Chubraev, Robin Corbet, Cecil Coupe, Stefan Csomor, Andrew Davison, Gilles Depeyrot, Duane Doran, Neil Dudman, Robin Dunn, Hermann Dunkel, Jos van Eijndhoven, Chris Elliott, David Elliott, David Falkinder, Rob Farnum, Joel Farley, Tom Felici, Thomas Fettig, Matthew Flatt, Pasquale Foggia, Josep Fortiana, Todd Fries, Dominic Gallagher, Roger Gammans, Guillermo Rodriguez Garcia, Brian Gavin, Wolfram Gloger, Aleksandras Gluchovas, Markus Greither, Norbert Grotz, Stephane Gully, Stefan Gunter, Bill Hale, Patrick Halke, Stefan Hammes, Guillaume Helle, Harco de Hilster, Kevin Hock, Cord Hockemeyer, Klaas Holwerda, Markus Holzem, Ove Kaaven, Mitch Kapor, Matt Kimball, Hajo Kirchoff, Olaf Klein, Jacob Jansen, Leif Jensen, Mark Johnson, Bart Jourquin, John Labenski, Guilhem Lavaux, Ron Lee, Hans Van Leemputten, Peter Lenhard, Jan Lessner, Nicholas Liebmann, Torsten Liermann, Per Lindqvist, Jesse Lovelace, Tatu Männistö, Lindsay Mathieson, Scott Maxwell, Bob Mitchell, Thomas Myers, Oliver Niedung, Stefan Neis, Ryan Norton, Robert O'Connor, Jeffrey Ollie, Kevin Ollivier, William Osborne, Hernan Otero, Ian Perrigo, Timothy Peters, Giordano Pezzoli, Harri Pasanen, Thomaso Paoletti, Garrett Potts, Robert Rae, Marcel Rasche, Mart Raudsepp, Andy Robinson, Robert Roebling, Alec Ross, Gunnar Roth, Thomas Runge, Tom Ryan, Dino Scaringella, Jobst Schmalenbach, Dimitri Schoolwerth, Arthur Seaton, Paul Shirley, Wlodzimierz Skiba, John Skiff, Vaclav Slavik, Brian Smith, Neil Smith, Stein Somers, Petr Smilauer, Kari Systä, George Tasker, Austin Tate, Arthur Tetzlaff-Deas, Paul Thiessen, Jonathan Tonberg, Jyrki Tuomi, Janos Vegh, Andrea Venturoli, David Webster, Michael Wetherell, Otto Wyss, Vadim Zeitlin, Xiaokun Zhu, Zbigniew Zagórski, Edward Zimmermann. Thanks also to Dotsrc.org and SourceForge for hosting project services.
Thanks are due in particular to Vadim Zeitlin, Vaclav Slavik, Robert Roebling, Stefan Csomor, and Robin Dunn for permission to adapt some of their contributions to the wxWidgets reference manual.
Special thanks go to Stefan Csomor who contributed Chapter 16 and Chapter 17, and to Kevin Ollivier who wrote the Bakefile tutorial in Appendix B. We would also like to thank Mitch Kapor for writing the foreword.
We are very grateful to Mark Taub for his patience and advice throughout. A big thank you goes to Marita Allwood, Harriet Smart, Antonia Smart, Clayton Hock, and Ethel Hock for all their love, support, and encouragement. A debt is also owed to all those who have reviewed and suggested improvements to the book, including: Stefan Csomor, Dimitri Schoolwerth, Robin Dunn, Carl Godkin, Bob Paddock, Chris Elliott, Michalis Kabrianis, Marc-Andre Lureau, Jonas Karlsson, Arnout Engelen, Erik van der Wal, Greg Smith, and Alexander Stigsen.
Finally, we hope that you enjoy reading this book and, most importantly, have fun using wxWidgets to build great-looking, multi-platform applications!
Julian Smart and Kevin Hock
June 2005
© Copyright Pearson Education. All rights reserved.