Home > Store > Programming > General Programming/Other Languages

larger cover

Add To My Wish List

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

Cross-Platform GUI Programming with wxWidgets

Best Value Purchase

Book + eBook Bundle

  • Your Price: $53.99
  • List Price: $89.98
  • Includes EPUB, MOBI, 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.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

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

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

Individual Purchases

Book

  • Your Price: $39.99
  • List Price: $49.99
  • Usually ships in 24 hours.

eBook (Watermarked)

  • Your Price: $31.99
  • List Price: $39.99
  • Includes EPUB, MOBI, 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.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

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

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

  • Description
  • Downloads
  • Extras
  • Sample Content
  • Updates
  • Copyright 2006
  • Dimensions: 7x9-1/4
  • Pages: 744
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-147381-6
  • ISBN-13: 978-0-13-147381-2

"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.

Online Sample Chapter

Drawing and Printing in C++ with wxWidgets

Downloadable Sample Chapter

Untitled Document Download the Sample Chapter file related to this title.

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.

Preface

Untitled Document

WHO THIS BOOK IS FOR

This book is a guide to using wxWidgets: an open-source construction kit to help you write sophisticated C++ applications for 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 it 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. 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:

  • Cost savings from writing code once that will compile on Windows, Unix, Mac OS X and other platforms.

  • Customer satisfaction from delivering stable, fast, attractive applications with a native look and feel .

  • Increased productivity from the wide variety of classes that wxWidgets provides, both for creating great GUIs and for general application development.

  • Increased market share due to support for platforms you may not have previously considered, and the ability to internationalize your applications.

  • Support from a large, active wxWidgets community that answers questions helpfully and provides prompt bug-fixing. The sample of third-party add-ons listed in Appendix E is evidence of a thriving ecosystem.

  • Access to the source , for enhancement and trouble-shooting.

This is a guide to writing wxWidgets application with C++, but you can use a variety of other languages such as Python, Perl, a BASIC variant, Lua, Eiffel™, JavaScript, Java™, Ruby, Haskell and C#™. Some of these bindings are more advanced than others. For more information, please see Appendix E and the wxWidgets web site at:

http://www.wxwidgets.org

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

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 two free compilers you can use with wxWidgets: MinGW and Digital Mars 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 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:

http://www.wxwidgets.org/book

HOW TO USE THIS BOOK

It's advisable to read at least Chapters 1 through 10 in order, but otherwise you'll probably read the chapters you need to complete a particular task. If you haven't installed wxWidgets before, you may wish 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 is either in your wxWidgets distribution or 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.

Conventions

For code examples, we mostly follow the wxWidgets style guidelines, for example:

  • Words within class names and functions have an initial capital, for example MyFunkyClass .

  • The "m_" prefix denotes a member variable, "s_" denotes a static variable, "g_" denotes a global variable; local variables start with a lower case letter, for example textCtrl .

You can find more about the wxWidgets style guidelines here:

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 and standard wxWidgets objects are marked with a teletype font in the text, and variables are italicised . User interface commands, such as menu and button labels, are also italicised.

Chapter summary

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: Creating 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 ; dates and times; 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.

Chapter 15: Memory management, debugging and error checking

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; providing run-time type information; using wxModule ; loading dynamic libraries; exception handling; debugging tips.

Chapter 16: Writing international applications

Introduction 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 applications

When 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 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; alternatives to wxSocket .

Chapter 19: Working with documents and views

Document/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 application

Single 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 wxWidgets

Downloading and unpacking wxWidgets; configuration/build options; Windows – Microsoft Visual Studio and VC++ command-line; Windows – Borland C++; Windows – MinGW with and without MSYS; Unix/Linux and Mac OS X – GCC; customizing setup.h ; rebuilding after updating wxWidgets files; using "contrib" libraries.

Appendix B: Building your own wxWidgets applications

Windows – Microsoft Visual Studio; Linux – KDevelop; Mac OS X – Xcode; makefiles; cross-platform builds using Bakefile; wxWidgets symbols and headers; using wx-config .

Appendix C: Creating applications with DialogBlocks

What 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 wxWidgets

Further 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 wxWidgets

Language 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 showcase

Descriptions of notable wxWidgets applications, such as AOL Communicator and Audacity.

Appendix G: Using the CD-ROM

Browsing the CD-ROM; the CD-ROM contents.

Appendix H: How wxWidgets processes events

An illustrated description of how event processing works.

Appendix I: Event classes and macros

A summary of the important event classes and macros.

Appendix J: Code Listings

Code listings for the PersonalRecordDialog and the wxWizard examples.

Appendix K: Porting from MFC

General 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.

ABOUT THE AUTHORS

Julian Smart

Julian 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 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

Kevin 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.

Stefan Csomor

Stefan 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 fifteen years experience in object-oriented programming and has been writing software for twenty-five years. Stefan is the main author of the Mac OS port of wxWidgets.

ACKNOWLEDGEMENTS

wxWidgets 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 SunSite Denmark 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 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, and Antonia Smart 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, March 2005


© Copyright Pearson Education. All rights reserved.

Foreword

Untitled Document Download the Foreword file related to this title.

Index

Untitled Document Download the Index file related to this title.

FREE

ONE MONTH ACCESS!

WITH PURCHASE


Get unlimited 30-day access to thousands of Books & Training Videos about technology, professional development and digital media If you continue your subscription after your 30-day trial, you can receive 30% off a monthly subscription to the Safari Library for up to 12 months.