BN.com Gift Guide

Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications [NOOK Book]

Overview

Cross-Platform Development in C++ is the definitive guide to developing portable C/C++ application code that will run natively on Windows, Macintosh, and Linux/Unix platforms without compromising functionality, usability, or quality.

 

Long-time Mozilla and Netscape developer Syd Logan systematically addresses all the technical and management challenges associated with software portability from planning and design through coding, testing, and deployment. Drawing on his ...

See more details below
Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$22.99
BN.com price
(Save 42%)$39.99 List Price

Overview

Cross-Platform Development in C++ is the definitive guide to developing portable C/C++ application code that will run natively on Windows, Macintosh, and Linux/Unix platforms without compromising functionality, usability, or quality.

 

Long-time Mozilla and Netscape developer Syd Logan systematically addresses all the technical and management challenges associated with software portability from planning and design through coding, testing, and deployment. Drawing on his extensive experience with cross-platform development, Logan thoroughly covers issues ranging from the use of native APIs to the latest strategies for portable GUI development. Along the way, he demonstrates how to achieve feature parity while avoiding the problems inherent to traditional cross-platform development approaches.

 

This book will be an indispensable resource for every software professional and technical manager who is building new cross-platform software, porting existing C/C++ software, or planning software that may someday require cross-platform support.

 

Build Cross-Platform Applications without Compromise

 

Throughout the book, Logan illuminates his techniques with realistic scenarios and extensive, downloadable code examples, including a complete cross-platform GUI toolkit based on Mozilla’s XUL that you can download, modify, and learn from. Coverage includes 

  • Policies and procedures used by Netscape, enabling them to ship Web browsers to millions of users on Windows, Mac OS, and Linux
  • Delivering functionality and interfaces that are consistent on all platforms
  • Understanding key similarities and differences among leading platform-specific GUI APIs, including Win32/.NET, Cocoa, and Gtk+
  • Determining when and when not to use native IDEs and how to limit their impact on portability
  • Leveraging standards-based APIs, including POSIX and STL
  • Avoiding hidden portability pitfalls associated with floating point, char types, data serialization, and types in C++
  • Utilizing platform abstraction libraries such as the Netscape Portable Runtime (NSPR)
  • Establishing an effective cross-platform bug reporting and tracking system
  • Creating builds for multiple platforms and detecting build failures across platforms when they occur
  • Understanding the native runtime environment and its impact on installation
  • Utilizing wxWidgets to create multi-platform GUI applications from a single code base
  • Thoroughly testing application portability
  • Understanding cross-platform GUI toolkit design with Trixul
Read More Show Less

Product Details

  • ISBN-13: 9780132702188
  • Publisher: Pearson Education
  • Publication date: 12/11/2007
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 576
  • File size: 14 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Syd Logan is a software developer living and working in Southern California. A graduate of San Diego State University with B.S. and M.S. degrees in computer science, Syd was a member of the Netscape Client Product Development (CPD) team, where he held both engineering and management positions during the development of Netscape 6 and 7. After Netscape, Syd remained at AOL where he implemented VoIP and peer-to-peer video features as a member of the AOL Instant Messenger team. Syd’s previous publications include Developing Imaging Applications with XIELib and Gtk+ Programming in C (Prentice Hall, 1997 and 2001). His technical interests include machine learning, operating systems design, algorithms, and just about anything that has to do with C, C++, and Unix.

Read More Show Less

Read an Excerpt

PrefaceCross-Platform Development in C++Building Mac OS X, Linux, and Windows Applications

Syd Logan

Addison-WesleyPreface

During the ten or so years of my career prior to joining Netscape in 1998, I had the good fortune to work on a wide variety of projects, on an equally diverse set of platforms. I worked on an embedded kernel of my own design for a somewhat obscure CPU (the TMS34020). I obtained experience in Windows kernel development, writing file systems drivers for the Windows NT and Windows 98 kernels, to support the development of a Network File System (NFS) client. In user space, I mostly specialized in user interface development, initially developing Motif (Z-Mail) and OpenWindows applications for UNIX, eventually getting exposure to Win32 and the Microsoft Foundation Classes (MFC) toolkit on the Windows platform. I even had the chance to write code for the Classic Mac OS to support a project that would be shipped by Apple, using the Mac Toolbox application programming interface (API). All of this code was written in the C language, and all of it was highly nonportable, written only with a concern for the job, and platform, at hand.

But then I joined Netscape, as a UNIX expert of sorts. Initially, I was assigned the task of working on bugs in the 4.x Netscape browser, specifically handling defects filed against a port of the browser to IBM's Advanced Interactive eXecutive (AIX) platform. Netscape had a contract with IBM to ensure that bugs filed against the AIX version of the Netscape browser, or bugs that IBM considered important, were fixed in a timely fashion, and this contract funded my hiring. Similar deals were cut with SGI,Hewlett-Packard, and Sun, and perhaps others, and these deals funded additional Netscape staff. Two or three of us were assigned to deal with AIX, specifically.

During this time, portability had not yet been perfected at Netscape. Although much of the codebase of Netscape was portable, the project did not have a unified build system, and the user interface code was completely platform specific. Many bugs had a decidedly platform-specific nature to them (hence the need to have separate teams to support individual platforms). Code that worked flawlessly on the Windows version of Netscape ran horribly on less well-supported platforms. Not all platforms had the same set of features, and features varied from platform to platform.

Within a year of joining Netscape and fixing AIX bugs, I somehow earned my way onto the Netscape Instant Messenger team, and work on the new codebase based on the open source Mozilla platform. This team, which consisted of three engineers, was tasked with porting the AOL Instant Messenger client to the Netscape browser. The Netscape IM team was hastily formed right after AOL acquired Netscape, to try to bring AOL-based functionality into the application. (The other major AOL property integrated into Netscape was support for AOL Mail).

The new Netscape client, in development at that time, was, as mentioned previously, based on the open source codebase named Mozilla. This codebase, at the time, was largely the product of Netscape engineers located in offices located in San Diego, and Mountain View, but contributions from the open source community were on the rise. (I refer to the project as Netscape/Mozilla in the remainder of this Preface).

Netscape was in fierce competition with Microsoft for the browser market at this time, which meant the browser of course had to work well, and ship on time on the Windows platform. Netscape also generated significant advertising revenue through the Netscape portal, and clicks there were highest when a new version of the browser was released, and tens of millions of users visited the portal to download a fresh copy of Netscape. Supporting Netscape not only on Windows but also on Mac OS and Linux helped keep the number of visits high and generate revenue. So, Linux and Mac OS were treated as equals with Windows within the Netscape culture, not only because it was the morally right thing to do (as many of us believed), but also because every visit to the Netscape portal was important to the bottom line of the company.

Netscape/Mozilla was a complete departure from anything that I had ever seen or worked on before. First of all, this new version of Netscape was not just a browser, it was a platform, capable of hosting applications. (The primary examples shipped with Netscape were AIM, the Mail/News client, a WYSIWYG HTML editor named Composer, the Chatzilla IRC client, and the browser itself. Extensions, such as those available for Firefox today, are closely related). Instead of building the graphical user interface (GUI) for these applications in C or C++, using APIs provided by a native platform GUI toolkit such as MFC or Gtk+, Netscape/Mozilla-developed technologies were used instead. Static Extensible Markup Language (

The impact of the work done to support portability in the Netscape/Mozilla architecture was not, quite frankly, immediately apparent to me. But, over time, I came to appreciate the power of such an approach. The positive effects of the decisions of those who came up with the architecture are indisputable; during its heyday, Netscape was shipping tens of millions of browsers to users, not just for Windows, Mac, and Linux, but for SunOS, AIX, HP-UX, SGI Irix, and a host of other UNIX-based platforms. The "tier-1" platforms (Mac OS, Linux, and Windows) literally shipped at the same time. Each of these ports had, for the most part, the same feature set, and mostly shared the same set of bugs and quirks. To achieve portability at such a grand scale required a very special architecture, and it is one of the goals of this book to give you a good understanding (if not an appreciation) for how the Netscape/Mozilla architecture directly impacted the portability of the codebase.

However, it was not just the architecture of Netscape/Mozilla that made the browser and related applications (AIM, Mail, Composer) portable. To pull this sort of thing off, one needs not only a solid architecture, but also a culture of policies and procedures that put cross-platform development high on their lists of priorities—as well as large doses of discipline to ensure these best practices were followed. Tools, such as Tinderbox and Bugzilla, both which are described in this book, were invested in heavily by Netscape and Mozilla, and the investment paid off in spades. Engineers were forced to consider other platforms, not just their own, and a regression found during daily testing on just one platform could halt development on all platforms, not just the one affected, because Netscape and Mozilla realized that the only true way to achieve portability was to deal with the issues in the here and now. A good chunk of this book steps away from the code, and describes these best practices, because no matter how good your architecture is in supporting cross-platform, you have to work all the platforms you plan to support with the level of care and devotion to detail if they are going to make it to the finish line with the same levels of quality.

Similar to the way that the programs we write are made up of data structures and algorithms, portability, in my opinion, consists largely of architecture and process, and this conviction is at the foundation of the book that you now hold in your hands.How This Book Is Organized

This book is organized as a series of themed chapters. Most of these chapters consist of a set of items, with each item covering a specific topic supporting the chapter's overall theme. Early in the book, you will find sections that contain items presenting best practices that must be communicated to the entire development organization, including management, development, and testing. Later chapters cover software-engineering topics that management should be aware of, but these chapters have been written primarily for readers who will be implementing the code. In all, there are 23 items presented in these initial chapters.

The implementation of a user interface is a major concern in the development of cross-platform desktop applications. Item 23 serves to introduce the topic. The final two chapters of the book are therefore devoted to cross-platform GUI-related topics. The first of these chapters provides a comprehensive introduction and tutorial to the wxWidgets cross-platform GUI toolkit. After reading my introduction to wxWidgets, you may want to check out Prentice Hall's detailed treatment on the subject, Cross-Platform GUI Programming with wxWidgets, by Julian Smart, et al. wxWidgets is not the only cross-platform GUI toolkit available for use in your projects. Another capable, and very popular cross-platform GUI toolkit, Qt, is not covered in this book. However, if you are interested in Qt, a few books are currently available that cover the subject in great detail, perhaps most notably C++ GUI Programming with Qt 4, by Jasmin Blanchette and Mark Summerfield, also published by Prentice Hall (see also their Qt 3-specific book).

The last chapter of this book, Chapter 9, "Developing a Cross-Platform GUI Toolkit in C++," starts with an introduction to the cross-platform GUI toolkit, XPToolkit, which is a major component of Netscape and Mozilla's cross-platform browser suite. It then goes on to detail the implementation of a toolkit I created especially for this book, Trixul. Trixul has many of the same attributes that made up the Mozilla/Netscape XPToolkit we used at Netscape to construct cross-platform GUIs. Both XPToolkit and Trixul, for example, allow you to describe the user interface of an application in

The chapters, for the most part, have been written such that they can be read in any order. If you are in technical management, I recommend that you read the following chapters carefully:

  • Chapter 1, "Policy and Management"
  • Chapter 2, "Build System/Toolchain"
  • Chapter 3, "Software Configuration Management"

Technical managers who are so inclined should consider at least scanning through the following sections:

  • Chapter 4, "Installation and Deployment"
  • Chapter 5, "Operating System Interfaces and Libraries"
  • Chapter 6, "Miscellaneous Portability Issues"
  • Chapter 7, "User Interface"

Developers should plan to read the entire book, although you might want to invert the recommendations made here for technical managers, and skim what they are supposed to read carefully, and read carefully what they are supposed to skim. If your focus is user interface development, I recommend reading Items 22 and 23, and Chapter 8, "wxWidgets." If you are interested in GUI toolkit internals, or plan to help out with the development of Trixul (described in the following section), you will definitely want to read Chapter 9, "Developing a Cross Platform GUI Toolkit in C++."A Word about Trixul

Trixul is an open source project that I put together specifically to aid me in the writing of this book. In part, I had the same intentions of the original authors of the Gtk+, to learn by doing. However, the more relevant goal behind Trixul was to develop a simple, cross-platform toolkit, the architecture and design of which could be easily described in fewer than 100 pages, and understood by mere mortals without the need to read huge globs of code. The design is heavily inspired by Netscape/Mozilla (the Document Object Model DOM, the Gecko layout engine, XUL, XPConnect, and XPCOM are all Netscape/Mozilla technologies that have analogs in Trixul); and although the details differ, I am certain that much of what you learn about Trixul's architecture will help you to understand Netscape/Mozilla. Not everyone will want, or need, to write his own GUI toolkit, but Netscape did, and so did America Online (a not-so-portable effort named Boxely was developed in the years following Netscape's demise), and perhaps it makes sense for your company, too. The story of Mozilla/Netscape's portability is not at all complete without a discussion of the way in which the user interface problem was solved, and Trixul is, in my opinion, the best way to get the idea across in a reasonable number of pages.

However, Trixul isn't just for learning. It is my sincere hope that Trixul will take on a life of its own as a viable, next-generation desktop GUI toolkit. The project, at the time of writing this book, is in its infancy. If you like what you read about Trixul and are interested in contributing to its development, or work on a port, I certainly want to hear from you. You can learn more by visiting http://www.trixul.com or the project page at http://sourceforge.net/projects/trixul.References

The following is a short list of books that are either mentioned directly in the text, or have influenced in some way the content of this book:

Andrei Alexandrescu, Modern C++ Design: Generic Programming and Design Patterns Applied (Reading, MA: Addison-Wesley, 2001).

Jasmine Blanchette and Mark Summerfield, C++ GUI Programming with Qt 3 (Upper Saddle River, NJ: Prentice Hall, 2004).

Randal E. Bryant and David O'Hallaron, Computer Systems A Programmer's Perspective (Upper Saddle River, NJ: Prentice Hall, 2003).

David R. Butenhof, Programming with POSIX Threads (Upper Saddle River, NJ: Prentice Hall, 1997).

Paul Dubois, Software Portability with imake (Sebastopol, CA: O'Reilly Media, Inc., 1996).

Erich Gamma, et al., Design Patterns (Reading, MA: Addison-Wesley, 1995).

Simson Garfinkel and Michael K. Mahoney, Building Cocoa Applications: A Step-by-Step Guide (Sebastopol, CA: O'Reilly Media, Inc., 2002).

Ian Griffiths, et al., .NET Windows Forms in a Nutshell (Sebastopol, CA: O'Reilly Media, Inc., 2003).

Greg Lehey, Porting UNIX Software (Sebastopol, CA: O'Reilly Media, Inc., 1995).

Syd Logan, Developing Gtk+ Applications in C (Upper Saddle River, NJ: Prentice Hall, 2001).

Scott Meyers, Effective C++ (Reading, MA: Addison-Wesley, 2005).

Andrew Oram and Steve Talbot, Managing Projects with make (Sebastopol, CA: O'Reilly Media, Inc., 1993).

Eric S. Raymond, The Art of UNIX Programming (Reading, MA: Addison-Wesley, 2003).

Julian Smart, et al., Cross-Platform GUI Programming with wxWidgets (Upper Saddle River, NJ: Prentice Hall, 2006).

Bjarne Stroustrup, The C++ Programming Language (Reading, MA: Addison-Wesley, 2000).


© Copyright Pearson Education. All rights reserved.

Read More Show Less

Table of Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

Areas That Can Affect Software Portability . . . . . . . . . . . . . . . . . . . 3

The Role of Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1 Policy and Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Item 1: Make All of Your Platforms a Priority . . . . . . . . . . . . . . . . . 17

Item 2: Code from a Common Codebase . . . . . . . . . . . . . . . . . . . . 22

Platform Factory Implementations . . . . . . . . . . . . . . . . . . . . . . . 29

Implementation Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Platform-Specific ProcessesImpl Classes . . . . . . . . . . . . . . . . . . . 32

Creating the Instance Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . 42

Organizing the Project in CVS or SVN . . . . . . . . . . . . . . . . . . . 45

Makefiles and Building the Code . . . . . . . . . . . . . . . . . . . . . . . . . 49

Item 3: Require Developers to Compile Their Code

with Different Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Item 4: Require Developers to Build Their Code on

Multiple Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Item 5: Test Builds on Each Supported Platform . . . . . . . . . . . . . . . 60

Item 6: Pay Attention to Compiler Warnings . . . . . . . . . . . . . . . . . . 61

GNU Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Microsoft Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

2 Build System/Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Item 7: Use Whatever Compiler Makes the Most Sense

for a Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Item 8: Use Native IDEs When Appropriate . . . . . . . . . . . . . . . . . . 67

Item 9: Install and Use Cygwin on Windows . . . . . . . . . . . . . . . . . . 71

Item 10: Use a Cross-Platform Make System . . . . . . . . . . . . . . . . . . 76

Make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Building on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Autoconf/Automake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Imake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Installing on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Installing on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Using Imake, an Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Imakefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Building a Complete Program from Multiple Sources . . . . . . . . . 95

Overriding Defaults with site.def . . . . . . . . . . . . . . . . . . . . . . . . 99

Eliminating #ifdefs in Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Files Used by Imake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Building Projects with Subdirectories . . . . . . . . . . . . . . . . . . . . 108

Building Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

3 Software Configuration Management . . . . . . . . . . . . . . . . . . 131

Item 11: Use a Cross-Platform Bug Reporting and

Tracking System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Ability to Track Platform-Specific Bugs . . . . . . . . . . . . . . . . . . 133

Bugzilla . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Item 12: Set Up a Tinderbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

Item 13: Use CVS or Subversion to Manage Source Code . . . . . . . 147

Setting Up and Using CVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Item 14: Use Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

Patch Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Dealing with Rejects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

Patch and Cross-Platform Development . . . . . . . . . . . . . . . . . . 163

4 Installation and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 165

Item 15: Provide Support for Native Installers . . . . . . . . . . . . . . . 165

XPInstall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Platform Installs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

5 Operating System Interfaces and Libraries . . . . . . . . . . . . . . . 221

Item 16: Use Standards-Based APIs (For Example, POSIX) . . . . . . 222

POSIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

Support for POSIX, SVID, XPG, and BSD . . . . . . . . . . . . . . . 226

Using Standards Support in GCC . . . . . . . . . . . . . . . . . . . . . . . 227

Microsoft Runtime Library Support for POSIX . . . . . . . . . . . . 231

Using GCC on Microsoft Windows . . . . . . . . . . . . . . . . . . . . . 234

Deciding Which Standards to Support . . . . . . . . . . . . . . . . . . . 240

Item 17: Consider Using a Platform Abstraction Library

Such as NSPR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

Why NSPR? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

NSPR Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

Additional NSPR Functionality . . . . . . . . . . . . . . . . . . . . . . . . 260

6 Miscellaneous Portability Topics . . . . . . . . . . . . . . . . . . . . . . . 273

Item 18: Take Care When Using Floating Point . . . . . . . . . . . . . . . 274

Don’t Serialize Floating-Point Values as Binary . . . . . . . . . . . . 276

Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

Item 19: Be Explicit Regarding the Sign of Char Types . . . . . . . . . 278

Item 20: Avoid the Serialization of Binary Data . . . . . . . . . . . . . . 280

Item 21: Avoid Problems Related to the Size and

Organization of Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

Size of Integer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

NSPR and Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

Sizes and Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

Integer Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

Struct Alignment and Ordering . . . . . . . . . . . . . . . . . . . . . . . . . 299

7 User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

Item 22: Separate the User Interface from the Model . . . . . . . . . . 304

Separating the User Interface and Application Logic

with Model/View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

Using Publish/Subscribe to Communicate between

the View and the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

Item 23: Develop a Cross-Platform User Interface Strategy . . . . . . 323

Issues Affecting Portable Cross-Platform GUI

Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

Choosing a GUI Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

8 wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

Installing wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

A Simple Example: Hello wxWidgets . . . . . . . . . . . . . . . . . . . . 335

Creating the Application User Interface . . . . . . . . . . . . . . . . . . 337

Building wxWidgets Applications . . . . . . . . . . . . . . . . . . . . . . . 345

Controls and Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

Container Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

Composite Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

Internationalization and Localization . . . . . . . . . . . . . . . . . . . . 410

9 Developing a Cross-Platform GUI Toolkit in C++ . . . . . . . . . . . 427

What is XUL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

DHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

Scripting Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433

The Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . 434

Style Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

XUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

Windows and Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

Other Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

Programming with XUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

Adding Logic to the UI with JavaScript . . . . . . . . . . . . . . . . . . 443

Interfacing JavaScript and C/C++ Code with XPCOM

and XPConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444

Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

Widget Support in Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

Basic Operation of Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448

Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449

Implementation Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

Creating Widget Implementation Objects . . . . . . . . . . . . . . . . . 459

Widget Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

Application Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

Steps Taken by Trixul to Create a User Interface . . . . . . . . . . . . 471

Documents, Elements, and the DOM . . . . . . . . . . . . . . . . . . . . 472

Widget Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477

Scrolled Windows and Layout . . . . . . . . . . . . . . . . . . . . . . . . . 484

Integration with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485

Integrating with C++ Components . . . . . . . . . . . . . . . . . . . . . . 496

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted December 21, 2007

    A reviewer

    Logan tackles a lot of grubby little complications that are the bane and reality of programmers writing multiplatform C++. This is not a book about learning C++ from scratch. Conceptually, it helps to think of this book as about 1 level above writing C++ code. For example, it discusses compiling, linking and running, where needed libraries might be missing. The book describes 3 platforms. Microsoft Windows, Macintosh and unix/linux. Strictly, the Macintosh is nowadays using a unix variant. But it's done differently enough, and the Mac is popular enough, that Logan stands it separate from other unix/linux environments. Perhaps the best recommendation of the book is to use a platform abstraction library. So that you can far more easily maintain a common code base. The suggested choice of library is NSPR. One simple way that it helps is in how it makes explicit the byte lengths of various C/C++ variables. This legacy C ambiguity is still with us, and causes much porting pain. It is no accident that newer languages like Java and C# make these definitions explicit. But many of us still have to write in C and C++.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)