From: morgan@unix.SRI.COM (Morgan Kaufmann Publishers)
Newsgroups: comp.windows.x.motif,comp.windows.x
Subject: Announcement of Motif Application Design Book and Source Code
Keywords: Motif, book
Date: 29 Aug 92 02:53:24 GMT
Followup-To: poster
Organization: SRI International, Menlo Park, CA



ANNOUNCING THE AVAILABILITY OF NEW BOOK AND SOURCE CODE



DESIGNING X CLIENTS WITH XT/MOTIF


Jerry D. Smith
Iris Computing Laboratories

July 1992, paperback, approx. 350 pages
ISBN 1-55860-255-0
Price: $34.95 (US & Canada)
       $38.45 (Shipped to international addresses)


This book focuses on practical design and implementation issues
common to many X software development projects.  Its goal is to
introduce the reader to a number of important design issues in the
context of real-world software, such that each reader can consider
these ideas within his or her own approach to program design. The
book has two main themes: The first is that source code should be
separated along user interface (UI) and non-UI lines to gain
advantages in software readability, maintainability, and
reusability.  The second theme is that programmers should look for
higher order components in their software development projects. 
The book presents the advantages of using abstraction to develop
higher level modules, and it discusses tools and  techniques that
enhance the X toolkit's existing programming abstractions.  

In keeping with the author's belief that it is important to supply
the reader with real-world examples that illustrate the "big
picture" as well  as having on-going utility, the book provides
several reusable objects  including a dialog object that supports
modal and nonmodal dialogs.   It also presents two useful
applications "xfilter", an X interface to  UNIX filters, and
"xrolodex", a Motif rolodex.  The source code for these can be
downloaded from popular UNIX network sites.

DESIGNING X CLIENTS WITH XT/MOTIF should be of immediate interest
to  X programmers using the X toolkit with the Motif widget set to
construct real applications.  Given its emphasis on general design
principles it  should also be of interest to X programmers in
general, whether or not they are using Xlib or a toolkit.

CONTENTS


Preface                                                     xii

1    Introduction                                           1
1.1  The X Window System                                    1
1.2  Programming Abstractions                               2
1.3  Economy of Window System Primitives                    3
1.4  Mixing X and Operating System Primitives               4
1.5  X Motif and Unix                                       7
1.6  Event Handling from a Toolkit                          8
1.7  Application Design                                     10
1.8  Separation of UI and Non-UI Components                 10
1.9  Practical Xt Design Issues                             11
1.10 Objects versus Widgets                                 12

2    Xt Application Design                                  15
2.1  PC-style User Interfaces Considered Harmful            15
2.2  Modal versus Nonmodal Dialog Boxes                     16
2.3  X's Procedural Event-driven Style                      17
2.4  A Manageable Set of Tools                              20
2.5  Dynamic Widget Creation                                21
2.6  Callback Functions                                     23

3    "xfilter":  Overview of Simple Abstraction             25
3.1  "xfilter"                                              25
3.2  "xfilter's" User Interface                             26
3.3  Common UI Components                                   28
3.4  "xfilter's" Non-UI Operations                          30
3.5  "xfilter":  Source Module Breakdown                    31

4    Procedural Abstraction                                 33
4.1  Common Usages for a Menu Function                      33
4.2  Application Interface                                  34
4.3  Menu Implementation                                    37

5    File-level Abstraction                                 43
5.1  User Interface                                         43
5.2  Application Interface                                  44
5.3  Help System Implementation                             47
5.4  Dependencies Among Modules                             55
5.5  Alternative Implementations                            55

6    "xfilter.c":  Linking UI and Non-UI Modules            57
6.1  Overview of the User Interface                         57
6.2  Separation of UI and Non-UI Components                 60
6.3  Common Data Structures                                 62
6.4  Implementing the User Interface                        64
6.5  User Interface Drudgery                                68
6.6  Widget Instance Naming Conventions                     76
6.7  Application-neutral Callback Functions                 78
6.8  Application-specific Callback Functions                81
6.9  Dispatching Data Manipulations to "xfilter.sel.c"      84
6.10 Providing Help Text for "help.c"                       85

7    "xfilter.sel.c": Linking in Non-UI Functionality       87
7.1  Overview of "xfilter's" Data Manipulation Operations   87
7.2  Transferring Data via Window Properties                88
7.3  Application Interface:  Linking UI & Non-UI Modules    91
7.4  Retrieving Selections                                  95
7.5  Dispatching Filter-related Operations                  97
7.6  Managing the Clipboard Selection                       99
7.7  Applying the UNIX Filter                               102
7.8  Xlib's Convenience Functions for Cut-buffer 0          105
7.9  The "Motif" Clipboard                                  106
7.10 Possible Extensions                                    106

8    Multiply Instantiable Abstractions                     109
8.1  Introduction and Motivation                            109
8.2  "CtrlPanel":  A Control Panel Object                   111
8.3  "CtrlPanel" Resources                                  117
8.4  Objects versus Widgets                                 118
8.5  Encapsulation Issues                                   120
8.6  Motif Style Guide Considerations                       121
8.7  "testctrl":  A Simple "CtrlPanel" Application          122

9    "xrolodex":  Higher Level Abstractions                 125
9.1  "xrolodex"                                             125
9.2  "xrolodex's" User Interface                            126
9.3  Beyond the User Interface                              128
9.4  "xrolodex":  Source Module Breakdown                   130

10   "ListShell":  A Scrollable List in a Shell             133
10.1 Encapsulation                                          133
10.2 Overview of "ListShell"                                134
10.3 Application Interface                                  135
10.4 Creating and Initializing a "ListShell" Object         137
10.5 Private Support Functions                              145
10.6 Public Support Functions                               146
10.7 Managing Secondary Windows                             149
10.8 "testlist":  A Simple "ListShell"  Application         150

11   "Editor":  A Search and Replace Editor Object          155
11.1 Overview of "Editor"                                   155
11.2 Application Interface                                  159
11.3 Implementing the "Editor" Object                       162
11.4 "Editor's" Access Functions                            174
11.5 Callback Functions for Clipboard Operations            176
11.6 Callback Functions fur Search and Replace Operations   180
11.7 Event Handlers                                         182
11.8 "testedit":  A Simple "Editor" Application             183

12   "Dialog":  A Modal or Nonmodal Dialog Object           185
12.1 Objects versus Convenience Functions in Dialog Design  185
12.2 Overview of "Dialog"                                   186
12.3 Application Interface                                  187
12.4 Implementation of the "Dialog" Object                  191
12.5 "Dialog" Activation                                    201
12.6 Modifying and Querying the State of a 
          "Dialog" Instance                                 205
12.7 Private Support Functions                              207
12.8 Modal Dialogs and Window Manager "Close" Functionality 210
12.9 "testdialog":  Testing Three "Dialog" Configurations   211
12.10 Design Issues                                         218

13   "StreamDB":  A Stream Database Object                  221
13.1 Overview of "StreamDB"                                 221
13.2 Programming Interface                                  222
13.3 "streamdbP.h":  The Instance Record                    224
13.4 "streamdb.c": Overview of "StreamDB's" Implementation  226
13.5 Overview of "StreamDB's" Access Functions              228
13.6 Miscellaneous "StreamDB" Functions                     233

14   "xrolo.c": Coordinating UI and Database Operations     237
14.1 "xrolodex": Overview of User Interface Components      238
14.2 Dialog Box Design                                      241
14.3 Separation of UI and Non-UI Components                 242
14.4 Initialization-related Issues                          244
14.5 Application versus Fallback Resources                  246
14.6 Creating the User Interface                            250
14.7 Designing Callback Functions                           264
14.8 Independent Callback Functions                         265
14.9 Laissez-faire Callback Functions                       268
14.10 Terminating the Application Gracefully                274
14.11 Application Logic in Callback Functions               275
14.12 Miscellaneous Callback Functions                      277
14.13 Miscellaneous Support Functions                       280
14.14 Reusability                                           282

15   "xrolo.db.c":  The Role of Indirection                 285
15.1 "xrolodex's" Database Design Policy                    285
15.2 "xrolo.db.h":  The Programming Interface               286
15.3 Encapsulating the Rolodex File                         287
15.4 Indirection:  Maintaining Distance Between Specific
          and General Modules                               288
15.5 Functions Returning "EntryDB" Values                   293
15.6 UI-independent Insertion & Deletion of 
          Database Entries                                  294
15.7 "xrolo.db.c's" UI-independent Index-related Services   297
15.8 "xrolo.index.c's" UI-dependent Index-related Services  299
15.9 Separation of UI and Non-UI Components                 301

Appendix A     Quick Reference for "motif.c"                303

Appendix B     Quick Reference for "help.c"                 305

Appendix C     Quick Reference for "ctrlpanel.c"            307

Appendix D     Quick Reference for "listshell.c"            309

Appendix E     Quick Reference for "editor.c"               313

Appendix F     Quick Reference for "dialog.c"               319

Appendix G     Quick Reference for "streamdb.c"             323

References                                                  329

Index                                                       331 
_________________________________________________________________

Ordering Information:

     
The book is available now at better technical bookstores or by
ordering directly from the publisher at: 

     Morgan Kaufmann Publishers
     Dept. XT
     2929 Campus Drive, Suite 260
     San Mateo, CA 
     94403
     USA
     
     Phone: (800)745-READ, (415) 578-9911
     Fax: (415) 578-0672
     
     For shipping, please add: 

          $3.50 for the first book and $2.50 for each additional
          for book rate shipping to the U.S. and Canada (2-3
          weeks); 

          $6.50 for the first book and $3.50 for each additional
          for surface shipping to all other areas.  (4-8 weeks)

     Call or fax for quotations on other shipping methods.

     Master Card, Visa, American Express and personal checks
     drawn on US banks accepted.

     California residents please add sales tax appropriate to
     your county.

Source Code: 

     The source code for the book is available for a small
     distribution fee on floppy diskettes ($30) or QIC-24 cartridge
     tape ($60) payable only be check or money order in US funds,
     drawn on a US bank from:

          Motif Source Offer
          Iris Computing Laboratories
          2801 Rodeo Road, Suite B-622
          Santa Fe, NM 87505 

     Please specify diskette format: 5.25" DOS diskettes, 3.5" DOS
     diskettes, or SunOS 4.X/5.X tar (1) format.  (The DOS
     diskettes include Unix format text files).

     Alternatively, the source code is available by uucp or ftp
     access as a compressed tar file from UUNET Technologies in the
     following subdirectory:

     uunet!~/published/books (or: ftp.uu.net:/published/books/)

     or by anonymous ftp from MIT's public archive for X software
     in the following subdirectory:

     export.lcs.mit.edu:contrib/

     The filename for the archive is smith.motif.tar.Z

Newsgroups: comp.windows.x.motif