Home > Store

Cross-Platform GUI Programming with wxWidgets

Register your product to gain access to bonus material or receive a coupon.

Cross-Platform GUI Programming with wxWidgets

eBook (Watermarked)

  • Sorry, this book is no longer in print.
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Not for Sale

Description

  • Copyright 2006
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-265060-6
  • ISBN-13: 978-0-13-265060-1

"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

  • Build advanced cross-platform applications that support native look-and-feel on Windows, Linux, Unix, Mac OS X, and even Pocket PC

  • Master wxWidgets from start to finish—even if you've never built GUI applications before

  • Leverage advanced wxWidgets capabilities: networking, multithreading, streaming, and more

  • CD-ROM: library of development tools, source code, and sample applications

  • Foreword by Mitch Kapor, founder, Lotus Development and Open Source Application 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.

  • wxWidgets quickstart: event/input handling, window layouts, drawing, printing, dialogs, and more

  • Working with window classes, from simple to advanced

  • Memory management, debugging, error checking, internationalization, and other advanced topics

  • Includes extensive code samples for Windows, Linux (GTK+), and Mac OS X

About the CD-ROM

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.

Sample Content

Table of Contents

Foreword by Mitch Kapor.

Preface.

Acknowledgments.

About the Authors.

1. Introduction.

    What Is wxWidgets?

    Why Use wxWidgets?

    A Brief History of wxWidgets

    The wxWidgets Community

    wxWidgets and Object-Oriented Programming

    License Considerations

    The wxWidgets Architecture

      wxMSW

      wxGTK

      wxX11

      wxMotif

      wxMac

      wxCocoa

      wxWinCE

      wxPalmOS

      wxOS2

      wxMGL

      Internal Organization

    Summary

2. Getting Started.

    A Small wxWidgets Sample

    The Application Class

    The Frame Class

    The Event Handlers

    The Frame Constructor

    The Whole Program

    Compiling and Running the Program

    Program Flow

    Summary

3. Event Handling.

    Event-Driven Programming

    Event Tables and Handlers

    Skipping Events

    Pluggable Event Handlers

    Dynamic Event Handlers

    Window Identifiers

    Defining Custom Events

    Summary

4. Window Basics.

    Anatomy of a Window

      The Concept of a Window

      Client and Non-Client Areas

      Scrollbars

      Caret and Cursor

      Top-Level Windows

      Coordinate System

      Painting

      Color and Font

      Window Variant

      Sizing

      Input

      Idle Time Processing and UI Updates

      Window Creation and Deletion

      Window Styles

    A Quick Guide to the Window Classes

      Base Window Classes

      Top-Level Windows

      Container Windows

      Non-Static Controls

      Static Controls

      Menus

      Control Bars

    Base Window Classes

      wxWindow

      wxControl

    Top-Level Windows

      wxFrame

      wxMDIParentFrame

      wxMDIChildFrame

      wxDialog

      wxPopupWindow

    Container Windows

      wxPanel

      wxNotebook

      wxScrolledWindow

      wxSplitterWindow

    Non-Static Controls

      wxButton

      wxButton Labels

      wxBitmapButton

      wxChoice

      wxComboBox

      wxCheckBox

      wxListBox and wxCheckListBox

      wxRadioBox

      wxRadioButton

      wxScrollBar

      wxSpinButton

      wxSpinCtrl

      wxSlider

      wxTextCtrl

      wxToggleButton

    Static Controls

      wxGauge

      wxStaticText

      wxStaticBitmap

      wxStaticLine

      wxStaticBox

    Menus

      wxMenu

    Control Bars

      wxMenuBar

      wxToolBar

      wxStatusBar

    Summary

5. Drawing and Printing.

    Understanding Device Contexts

      Available Device Contexts

      Drawing on Windows with wxClientDC

      Erasing Window Backgrounds

      Drawing on Windows with wxPaintDC

      Drawing on Bitmaps with wxMemoryDC

      Creating Metafiles with wxMetafileDC

      Accessing the Screen with wxScreenDC

      Printing with wxPrinterDC and wxPostScriptDC

    Drawing Tools

      wxColour

      wxPen

      wxBrush

      wxFont

      wxPalette

    Device Context Drawing Functions

      Drawing Text

      Drawing Lines and Shapes

      Drawing Splines

      Drawing Bitmaps

      Filling Arbitrary Areas

      Logical Functions

    Using the Printing Framework

      More on wxPrintout

      Scaling for Printing and Previewing

      Printing under Unix with GTK+

    3D Graphics with wxGLCanvas

    Summary

6. Handling Input.

    Mouse Input

      Handling Button and Motion Events

      Handling Mouse Wheel Events

    Handling Keyboard Events

      An Example Character Event Handler

      Key Code Translation

      Modifier Key Variations

      Accelerators

    Handling Joystick Events

      wxJoystick Events

      wxJoystickEvent Member Functions

      wxJoystick Member Functions

    Summary

7. Window Layout Using Sizers.

    Layout Basics

    Sizers

      Common Features of Sizers

    Programming with Sizers

      Programming with wxBoxSizer

      Programming with wxStaticBoxSizer

      Programming with wxGridSizer

      Programming with wxFlexGridSizer

      Programming with wxGridBagSizer

    Further Layout Issues

      Dialog Units

      Platform-Adaptive Layouts

      Dynamic Layouts

    Summary

8. Using Standard Dialogs.

    Informative Dialogs

      wxMessageDialog

      wxProgressDialog

      wxProgressDialog Example

      wxBusyInfo

      wxShowTip

    File and Directory Dialogs

      wxFileDialog

      wxDirDialog

    Choice and Selection Dialogs

      wxColourDialog

      wxFontDialog

      wxSingleChoiceDialog

      wxMultiChoiceDialog

    Entry Dialogs

      wxNumberEntryDialog

      wxTextEntryDialog and wxPasswordEntryDialog

      wxFindReplaceDialog

    Printing Dialogs

      wxPageSetupDialog

      wxPrintDialog

    Summary

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

      The Complete Class

      Invoking the Dialog

    Adapting Dialogs for Small Devices

    Further Considerations in Dialog Design

      Keyboard Navigation

      Data and UI Separation

      Layout

      Aesthetics

      Alternatives to Dialogs

    Using wxWidgets Resource Files

      Loading Resources

      Using Binary and Embedded Resource Files

      Translating Resources

      The XRC Format

      Writing Resource Handlers

      Foreign Controls

    Summary

10. Programming with Images.

    Image Classes in wxWidgets

    Programming with wxBitmap

      Creating a wxBitmap

      Setting a wxMask

      The XPM Format

      Drawing with Bitmaps

      Packaging Bitmap Resources

    Programming with wxIcon

      Creating a wxIcon

      Using wxIcon

      Associating an Icon with an Application

    Programming with wxCursor

      Creating a wxCursor

      Using wxCursor

      Using wxSetCursorEvent

    Programming with wxImage

      Loading and Saving Images

      Transparency

      Transformations

      Color Reduction

      Manipulating wxImage Data Directly

    Image Lists and Icon Bundles

    Customizing Art in wxWidgets

    Summary

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

    Summary

12. Advanced Window Classes.

    wxTreeCtrl

      wxTreeCtrl Styles

      wxTreeCtrl Events

      wxTreeCtrl Member Functions

    wxListCtrl

      wxListCtrl Styles

      wxListCtrl Events

      wxListItem

      wxListCtrl Member Functions

      Using wxListCtrl

      Virtual List Controls

    wxWizard

      wxWizard Events

      wxWizard Member Functions

      wxWizard Example

    wxHtmlWindow

      wxHtmlWindow Styles

      wxHtmlWindow Member Functions

      Embedding Windows in HTML Pages

      HTML Printing

    wxGrid

      The wxGrid System of Classes

      wxGrid Events

      wxGrid Member Functions

    wxTaskBarIcon

      wxTaskBarIcon Events

      wxTaskBarIcon Member Functions

    Writing Your Own Controls

      The Custom Control Declaration

      Adding DoGetBestSize

      Defining a New Event Class

      Displaying Information on the Control

      Handling Input

      Defining Default Event Handlers

      Implementing Validators

      Implementing Resource Handlers

      Determining Control Appearance

      A More Complex Example: wxThumbnailCtrl

    Summary

13. Data Structure Classes.

    Why Not STL?

    Strings

      Using wxString

      wxString, Characters, and String Literals

      Basic wxString to C Pointer Conversions

      Standard C String Functions

      Converting to and from Numbers

      wxStringTokenizer

      wxRegEx

    wxArray

      Array Types

      wxArrayString

      Array Construction, Destruction, and Memory Management

      Array Sample Code

    wxList and wxNode

    wxHashMap

    Storing and Processing Dates and Times

      wxDateTime

      wxDateTime Constructors and Modifiers

      wxDateTime Accessors

      Getting the Current Time

      Parsing and Formatting Dates

      Date Comparisons

      Date Arithmetic

    Helper Data Structures

      wxObject

      wxLongLong

      wxPoint and wxRealPoint

      wxRect

      wxRegion

      wxSize

      wxVariant

    Summary

14. Files and Streams.

    File Classes and Functions

      wxFile and wxFFile

      wxTextFile

      wxTempFile

      wxDir

      wxFileName

      File Functions

    Stream Classes

      File Streams

      Memory and String Streams

      Reading and Writing Data Types

      Socket Streams

      Filter Streams

      Zip Streams

      Virtual File Systems

    Summary

15. Memory Management, Debugging, and Error Checking.

    Memory Management Basics

      Creating 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

      wxMessageOutput Versus wxLog

    Providing Run-Time Type Information

    Using wxModule

    Loading Dynamic Libraries

    Exception Handling

    Debugging Tips

      Debugging X11 Errors

      Simplify the Problem

      Debugging a Release Build

    Summary

16. Writing International Applications.

    Introduction to Internationalization

    Providing Translations

      poEdit

      Step-by-Step Guide to Using Message Catalogs

      Using wxLocale

    Character Encodings and Unicode

      Converting Data

      wxEncodingConverter

      wxCSConv (wxMBConv)

      Converting Outside of a Temporary Buffer

      Help Files

    Numbers and Dates

    Other Media

    A Simple Sample

    Summary

17. Writing Multithreaded Applications.

    When to Use Threads, and When Not To

    Using wxThread

      Creation

      Specifying Stack Size

      Specifying Priority

      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

      Using wxTimer

      Idle Time Processing

      Yielding

    Summary

18. Programming with wxSocket.

    Socket Classes and Functionality Overview

    Introduction to Sockets and Basic Socket Processing

      The Client

      The Server

      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

      File Sending Thread

      File Receiving Thread

    Alternatives to wxSocket

    Summary

19. Working with Documents and Views.

    Document/View Basics

      Step 1: Choose an Interface Style

      Step 2: Create and Use Frame Classes

      Step 3: Define Your Document and View Classes

      Step 4: Define Your Window Classes

      Step 5: Use wxDocManager and wxDocTemplate

    Other Document/View Capabilities

      Standard Identifiers

      Printing and Previewing

      File History

      Explicit Document Creation

    Strategies for Implementing Undo/Redo

    Summary

20. Perfecting Your Application.

    Single Instance or Multiple Instances?

    Modifying Event Handling

    Reducing Flicker

    Implementing Online Help

      Using a Help Controller

      Extended wxWidgets HTML Help

      Authoring Help

      Other Ways to Provide Help

      Context-Sensitive Help and Tooltips

      Menu Help

    Parsing the Command Line

    Storing Application Resources

      Reducing the Number of Data Files

      Finding the Application Path

    Invoking Other Applications

      Running an Application

      Launching Documents

      Redirecting Process Input and Output

    Managing Application Settings

      Storing Settings

      Editing Settings

    Application Installation

      Installation on Windows

      Installation on Linux

      Installation on Mac OS X

    Following UI Design Guidelines

      Standard Buttons

      Menus

      Icons

      Fonts and Colors

      Application Termination Behavior

      Further Reading

    Summary

Appendix A. Installing wxWidgets.

Appendix B. Building Your Own wxWidgets Applications.

Appendix C. Creating Applications with DialogBlocks.

Appendix D. Other Features in wxWidgets.

Appendix E. Third-Party Tools for wxWidgets.

Appendix F. wxWidgets Application Showcase.

Appendix G. Using the CD-ROM.

Appendix H. How wxWidgets Processes Events.

Appendix I. Event Classes and Macros.

Appendix J. Code Listings.

Appendix K. Porting from MFC.

Glossary.

Index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020