Home > Store

Object Oriented Programming with C++ and OSF/Motif, 2nd Edition

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

Object Oriented Programming with C++ and OSF/Motif, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • part I introduces the mechanics of using C++ and Motif with an emphasis on object-oriented techniques.
  • part II explores additional ideas for using Motif and C++, while developing a small library of useful classes that support applications based on Motif.

Description

  • Copyright 1995
  • Dimensions: 7" x 9-1/4"
  • Pages: 464
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-209255-7
  • ISBN-13: 978-0-13-209255-5

Completely updated to cover Motif Release 1.2 and 2.0, this second edition shows how to design reusable user interface components based on Motif, and how C++ and Motif can be used together effectively. KEY TOPICS: Part I introduces the mechanics of using C++ and Motif with an emphasis on object- oriented techniques. Part II explores additional ideas for using Motif and C++, while developing a small library of useful classes that support applications based on Motif. MARKET: For application programmers.

Downloads

Source Code

Source Code is available at: ftp://ftp.x.org/

Sample Content

Table of Contents

I. INTRODUCTION TO C++ AND MOTIF 1.

1. An X/Motif Tutorial Using C++ 7.

The X/Motif Architecture 7. Mixing C and C++ 12. Programming with Motif and the Xt Intrinsics 15. The Motif Widget Set 31. Customization and Resources 50. Summary 53.

2. C++ Classes and Widgets 54.

User Interface Components 56. Encapsulation and Class Design 69. Supporting Components with Base Classes 74. The UIComponent Class 95. User Interface Component Guidelines 111. Writing Components vs. Writing Widgets 112. C++ Tricks and Techniques 113. Summary 118.

3. Designing with Objects 119.

Object-oriented Design and Development 120. CRC: Classes/Responsibilities/Collaborators 123. A Design Notation 127. Designing for Reusability 136. Summary 145.

4. TicTacToe: Design 146.

Defining the Problem 147. Finding the Objects 147. Developing Initial Class Cards 149. Finalizing the Design 153. Designing the TicTacToe User Interface 161. Summary 167.

5. TicTacToe: Implementation 168.

The TicTacToe Class 169. The GameBoard Class 174. The Message Class 186. The Command Class 188. The Engine Subsystem 192. Putting It All Together 205. Summary 208.

II. APPLICATION FRAMEWORKS 210.

6. The MotifApp Application Framework 21.

An Overview 215. A Simple List Template 219. The Application Class 221. The MainWindow Class 229. The MotifApp main() Function 234. The MotifApp Library 235. Using the Application Framework 236. Summary 240.

7. Dialogs 241.

Using Dialogs 241. The DialogManager Class 248. The InfoDialogManager Class 256. The QuestionDialogManager Class 261. Summary 265.

8. Command Classes 266.

The Cmd Class 267. The CmdInterface Class 278. The NoUndoCmd Class 281. The UndoCmd Class 282. The AskFirstCmd Class 284. The WarnNoUndoCmd Class 286. Summary 289.

9. A Simple Menu System 290.

The ButtonInterface Class 291. The MenuBar Class 292. The MenuWindow Class 295. A MenuBar Example 297. Summary 310.

10. Lengthy Tasks 311.

Strategies for Busy Applications 312. The WorkingDialogManager Class 317. The InterruptibleCmd Class 330. An Example Program 337. Summary 357.

11. A Color Chooser 358.

Models and Views 358. A ColorChooser Dialog 361. Summary 391.

12. A MotifApp Application 393.

An Overview of Bounce 393. The Stage Class 396. Driving the Animation 402. The Control Panel 409. Actors 417. The AddBallCmd Class 424. The BounceWindow Class 425. Building and Running Bounce 430. Summary 433.

Bibliography 435.
Getting Source Code 437.
Index 439.

Preface

This book grew out of a simple question: "How do I use the Motif user interface toolkit when programming in C++?"

The most direct answer to this question, one that provides only the mechanics of the solution, is fairly simple. But fully addres sing all the surrounding issues is a more complex task. In particular, a complete answer must include ways to coordinate the programming model supported by X and Motif with the C++ object-oriented programming model. This is the central topic of this book.This revised edition updates and expands the material presented in the original book to take into account current versions of X and Motif, with their increasing level of C++ support. However, the material in this book is largely independent of a ny specific version of X or Motif.

While most Motif books necessarily dwell on explanations of how to use the features of individual widgets, this book concentrates on how Motif can be used within the context of an object-oriented architecture. This includes not only the mechanics of using C++ with Motif, but also includes stylistic and design issues. These issues tend to remain the same from version to version of Motif.

This book has another underlying theme that is at least as important as how to use Motif with C++. In the past few years there has been a fundamental shift in the type of software programmers develop. The textbooks we study in school often focus on algorithms and basic data structures. While no one would dispute that data st ructures and algorithms are the heart of any application, most modern programs cannot be considered complete without additional elements. For most applications written today, choosing appropriate data structures and determining the right algorithms a re only the beginning. Much of the emphasis in contemporary applications is on interactive user interfaces based on window systems such as the X Window System, the Macintosh Toolbox, Microsoft Windows, NeXTStep, and others.

Estimates of the effort required to develop the user interface portion of a window-based application range from 50 to 90 percent of the total effort, which leaves only a small remainder to the task of developing the computational portion of the program. This does not diminish the importance of algorithms, it simply provides one measure of the additional complexity introduced by the interface component of contemporary interactive software.

Programmers sometimes find it difficult to develop these new types of programs, partly because developing a good interactive interface is inherently difficult, but also because interactive programs require a different type of architecture than many programmers are accustomed to.

Programmers who have never developed interactive applications before may be unsure where to begin. The type of algorithm usually studied in school generally involves a single function that takes some data as input and returns other data as output. Interactive programs are different.

First, modern interactive programs are real-time applications. In addition, modern applications are often expected to coordinate the presentation of data in multiple areas of the screen, recover from errors in a user-friendly way, provide an appropriate interface for both expert and novice users, and much more. One of the goals of this book is to help the reader understand how to structure applications to address some of these issues and how using C++ can help. Simply understanding how to display and manipulate user interface components such as Motif widgets is only the beginning.

It is also necessary to understand the subtle constraints X and Motif impose on an application's architecture as well as the way an object-oriented approach affects an application's design and implementation. Object- oriented programming matches the needs of modern interactive systems very well. Using C++ to implement Motif applications provides tools for structuring programs in a way that would be very difficult to do in C. However, object-oriented programming also requires programmers to alter the way they think about developing software. In object- oriented programming, much of the emphasis is on structure.

Programmers who use object-oriented techniques are generally more co ncerned with defining interfaces and relationships between objects than developing algorithms. Programmers usually find that they need to approach such programs with a completely different mindset. One of the goals of this book is to demonstrate an o bject-oriented approach within the context of interactive Motif applications. Someone is sure to ask, "Why should I use an Xt-based toolkit like Motif with C++ in the first place? If I am writing an object-oriented program, shouldn't I use a `true' ob ject-oriented toolkit?" There are many X-based, object-oriented user interface toolkits available to those who feel that object-oriented software must use nothing but pure object- oriented libraries. For example, the Interviews toolkit and its success or, Fresco, as well as the OI toolkit developed by Solbourne are all written in C++. Each of these toolkits has strong points and may be useful to C++ programmers. Some may have promising futures.

But for now, none of these have Xt's and Motif's mome ntum, support, and wide acceptance by both programmers and users. There are some who will maintain that it is sacrilege to use a C-based toolkit like Motif with C++. If you fall into that camp, I can only say that this book is not written for you. Th ere are literally hundreds of user interface toolkits available today, supporting a variety of languages and programming styles. You must decide which toolkit you want to use, based on your needs and the merits of each. There is much more to consider than the implementation language used internally by a toolkit.

Issues such as present and future availability, acceptance by users and programmers, support, reliability, and so on must be considered. You must also consider the environment in which your application will be used and whether the user interface style supported by any given toolkit will be compatible with other applications in that environment. In many cases, or perhaps even most cases, these issues will be the most critical factors in your decision. This book is written for those who decide to use Motif and would also like to take advantage of the object-oriented facilities offered by C++. For those who choose C++ and Motif, I hope this book is useful.All software in this book was tested on a Silicon Graphics Indy workstation running IRIX 5.3. The examples were compiled using Silicon Graphic's native C++ compiler. All examples were tested with the X11R6 Xlib and Xt Intrinsics and Motif 1.2.3. The examples are designed to be self- sufficient and depend on nothing but standard UNIX and C++ libraries, X, and Motif. Notice that self-sufficiency places some limitations on the design of any software. For example, many of the classes described in this book could be improved or simplified by using a good library of general-purpose data structures. For those examples that could use such generic data structures, my available choices were to diverge from the central topic of the book to implement the necessary classes, to use a library that might not be available to the reader, or to implement the examples without the benefit of such classes. Because the topic of reusable classes that implement common data structures could be a book in itself, I chose the last approach in most cases.

For the purposes of this book, the internal implementation of any individual class is of less interest than the external behavior of each class and the collective architecture of all classes in a system. Writing a book is very much lik e developing a large piece of software. In both cases, the idea that one can ever find the "last bug" is an illusion. I have tried to make this book as error-free as possible, and I am grateful for the assistance of many people, mentioned below, who helped in that effort. However, I have no doubt that errors and deficiencies remain, in spite of my best efforts.

Readers, of course, have an uncanny knack for immediately spotting errors that the author has overlooked repeatedly! My primary goal has been to produce a book that conveys useful information. I hope this book achieves that goal in spite of any errors you encounter.

Acknowledgments

I would like to thank the many people who helped me with this book. Jolly Chen, Jean-Daniel Fekete, Ken F ischer, Steve Friedl, Oliver Jones, Rick Kelly, David Lewis, Howard Look, Anil Pal, Michael Portuesi, Kim Rachmeler, and Rebecca Wirfs-Brock helped by reviewing early drafts. Their suggestions were invaluable in defining the final form of this book. My wife, Teresa, helped by copy-editing at all stages. I owe a special thanks to Shiz Kobara, who provided the visual design of the TicTacToe game described in Chapter 4. The portions of Chapters 4 and 5 that address the interface design of TicTacToe are based on his work and our discussions. This revised edition also reflects the feedback of readers who shared their ideas and experiences with me as they applied the ideas in this book to develop object-oriented systems using C++ and Motif.

Douglas A. Young

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