|2020ok Directory of FREE Online Books and FREE eBooks|
Cross-Platform GUI Programming with wxWidgets
by Julian Smart, Kevin Hock, and Stefan Csomor
(Respecting the intellectual property of others is utmost important to us, we make every effort to make sure we only link to legitimate sites, such as those sites owned by authors and publishers. If you have any questions about these links, please contact us.)
Unlike other cross-platform GUI toolkits (Tcl/Tk, Qt, AWT) wxWidgets
supports the native look-and-feel of the local OS. And unlike Qt, wxWidgets is
truly Open Source. It also works with virtually every standard C++ compiler.
It is a perfect solution for organizations interested in porting Windows
applications to Linux and other platforms. And with Mac OS X and Linux
gaining marketshare daily, many organizations -- including Xerox, Advanced
Micro Devices, AOL, Lockheed Martin, NASA--have adopted wxWidgets in
order to support Windows, Linux, OS X, and Unix for their applications. See
And wxWidgets is HOT. Mitch Kapor's OSAF is using wxWidgets for its
Chandler PIM. Bram Cohen uses wxWidgets for BitTorrent. Borland has
added enormous credibility to wxWidgets by incorporating it into its newest
C++ IDE: C++ BuilderX. wxWidgets is Borland's cross-platform
From the Back Cover
"This book is the best way for beginning developers to learn wxWidgets programming in C++. It is a must-have for programmers thinking of using wxWidgets and those already using it."
âMitch Kapor, founder of Lotus Software and the Open Source Applications Foundation
wxWidgets is an easy-to-use, open source C++ API for writing GUI applications that run on Windows, Linux, Unix, Mac OS X, and even Pocket PCâsupporting each platform's native look and feel with virtually no additional coding. Now, its creator and two leading developers teach you all you need to know to write robust cross-platform software with wxWidgets. This book covers everything from dialog boxes to drag-and-drop, from networking to multithreading. It includes all the tools and code you need to get great results, fast. From AMD to AOL, Lockheed Martin to Xerox, world-class developers are using wxWidgets to save money, increase efficiency, and reach new markets. With this book, you can, too.
The CD-ROM contains all of the source code from the book; wxWidgets distributions for Windows, Linux, Unix, Mac OS X, and other platforms; the wxWidgets reference guide; and development tools including the OpenWatcom C++ compiler, the poEdit translation helper, and the DialogBlocks user interface builder.
Â© Copyright Pearson Education. All rights reserved.
About the Author
Julian Smart has degrees from the University of St. Andrews and the University of Dundee. After working on model-based reasoning at the Scottish Crop Research Institute, he moved to the Artificial Intelligence Applications Institute at the University of Edinburgh, where he founded the wxWidgets project in 1992. Since starting Anthemion Software in 1996, Julian has been helping other companies deploy wxWidgets, and he sells tools for programmers, including DialogBlocks and HelpBlocks. He has worked as a consultant for various companies including Borland and was a member of Red Hat's eCos team, writing GUI tools to support the embedded operating system. In 2004, Julian and his wife Harriet launched a consumer product for fiction writers called Writer's CafÃ©, written with wxWidgets. Julian and Harriet live in Edinburgh with their daughter Toni.
Kevin Hock has degrees from Miami University (Oxford, Ohio) in Computer Science and Accounting and has taught courses at Miami in both Java and client-server systems. In 2002, he started work on an instant messaging system and founded BitWise Communications, LLC, in 2003, offering both professional and personal instant messaging. During the course of developing BitWise using wxWidgets, Kevin became a wxWidgets developer and has provided enhancements to all platforms. Kevin lives in Oxford, Ohio.
Stefan Csomor is director and owner of Advanced Concepts AG, a company that specializes in cross-platform development and consulting. In addition to being a qualified medical doctor, he has more than 15 years of experience in object-oriented programming and has been writing software for 25 years. Stefan is the main author of the Mac OS port of wxWidgets.
Â© Copyright Pearson Education. All rights reserved.
Excerpt. © Reprinted by permission. All rights reserved.
Who This Book Is For
This book is a guide to using wxWidgets, an open-source construction kit for writing sophisticated C++ applications targeting a variety of platforms, including Windows, Linux, Mac OS X, and Pocket PC. With help from this book, a competent programmer can create multi-platform applications with confidence. Developers already familiar with wxWidgets should also find it useful for brushing up their knowledge.
This book is accessible to developers with a variety of experience and backgrounds. You may come from a Windows or Unix perspective; you may previously have experience in MFC, OWL, Win32, Mac OS, Motif, or console-mode Unix programming. Or perhaps you have come from a different career entirely and are looking for a way to get up to speed on multiple platforms. The book can't specifically cover the details of the C++ language, but it's common for people to successfully learn C++ and wxWidgets at the same time, and the straightforward nature of the wxWidgets API makes this process easier. The reader does not need to know more advanced C++ techniques like templates, streams, and exceptions. However, wxWidgets does not prevent you from using these techniques.
Managers will find the book useful in discovering what wxWidgets can do for them, particularly in Chapter 1, "Introduction." The combination of the book and the resources on the accompanying CD-ROM will give your staff all they need for getting started on cross-platform programming projects. You'll see how wxWidgets puts tools of tremendous power into your hands, with benefits that include:
We focus on three popular desktop platforms: Microsoft Windows, Linux using GTK+, and Mac OS X. However, most of the book also applies to other platforms supported by wxWidgets. In particular, wxWidgets can be used with most Unix variants.
The CD-ROM contains example code from the book, the wxWidgets 2.6 distribution for Windows, Linux, Mac OS X, and other platforms, and several tools to help you use wxWidgets, including the translation tool poEdit. For Windows users, we supply three free compilers you can use with wxWidgets: MinGW, Digital Mars C++, and OpenWatcom C++.
In addition, we provide you with DialogBlocks Personal Edition, a sophisticated rapid application development (RAD) tool for you to create complex windows with very little manual coding. You can use it to compile and run samples that accompany the book as well as to create your own applications for personal use, and it also provides convenient access to the wxWidgets reference manual.
Updates to the book and CD-ROM can be obtained from this site:
How to Use This Book
It's advisable to read at least Chapters 1 through 10 in order, but you can skip to other chapters if you need to complete a particular task. If you haven't installed wxWidgets before, you may want to look at Appendix A, "Installing wxWidgets," early on. MFC programmers will find it useful to read Appendix K, "Porting from MFC," as a point of reference.
Because this book is not a complete API reference, you'll find it useful to keep the wxWidgets reference manual open. The reference manual is available in a number of formats, including Windows HTML Help and PDF, and it should be in your wxWidgets distribution; if not, it can be downloaded from the wxWidgets web site. You can also refer to the many samples in the wxWidgets distribution to supplement the examples given in this book.
Note that the book is intended to be used in conjunction with wxWidgets 2.6 or later. The majority of the book will apply to earlier versions, but be aware that some functionality will be missing, and in a small number of cases, the behavior may be different. In particular, sizer behavior changed somewhat between 2.4 and 2.5. For details, please see the topic "Changes Since 2.4.x" in the wxWidgets reference manual.
For code examples, we mostly follow the wxWidgets style guidelines, for example:
You can find more about the wxWidgets style guidelines at http://www.wxwidgets.org/standard.htm.
Sometimes we'll also use comments that can be parsed by the documentation tool Doxygen, such as:
/// A function description
Classes, functions, identifiers, variables, and standard wxWidgets objects are marked with a teletype font in the text. User interface commands, such as menu and button labels, are marked in italics.
Chapter 1: Introduction
What 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 Handling
Event tables and handlers; how a button click is processed; skipping events; pluggable and dynamic event handlers; defining custom events; window identifiers.
Chapter 4: Window Basics
The 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 Printing
Device 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 Input
Handling mouse and mouse wheel events; handling keyboard events; keycodes; modifier key variations; accelerators; handling joystick events.
Chapter 7: Window Layout Using Sizers
Layout basics; sizers introduced; common features of sizers; programming with sizers. Further layout issues: dialog units; platform-adaptive layouts; dynamic layouts.
Chapter 8: Using Standard Dialogs
Informative 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 Dialogs
Steps 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 Images
Image 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 Drop
Data 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 Classes
wxTreeCtrl; 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 Classes
Why not STL? wxString; wxStringTokenizer; wxRegEx; wxArray; wxList; wxHashMap; wxDateTime; wxObject; wxLongLong; wxPoint and wxRealPoint; wxRect; wxRegion; wxSize; wxVariant.
Chapter 14: Files and Streams
wxFile 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.
Related Free eBooks