Volume Four X Toolkit Intrinsics Programming Manual Second Edition for X11, Release 4 by. Adrian Nye and Tim O'Reilly O'Reilly & Associates, Inc. 2.3.3 The Application-defaults File ....................................................................................... 38 2.3.4 To Hardcode or Not to Hardcode ................................................................................. 40 2.4 Connecting Widgets to Application Code .......................................................................... 41 2.4.1 Callbacks ........................................................................................................................ 42 2.4.2 Actions ........................................................................................................................... 45 2.4.2.1 The Actions Table ..................................................................................................... 48 2.4.2.2 Format of an Action Procedure ............................................................................... 48 2.4.2.3 The Translation ..................... 49 2.4.2.4 Hardcoding Translations .......................................................................................... 51 2.5 More About Resources ......................................................................................................... 52 2.5.1 Setting and Getting Resources from the Application ........................................... ...
Volume Four
X Toolkit Intrinsics
Programming Manual
Second Edition
for X11, Release 4
by. Adrian Nye and Tim O'Reilly
O'Reilly & Associates, Inc.
2.3.3 The Application-defaults
File ...........................................................................
............ 38
2.3.4 To Hardcode or Not to
Hardcode .......................................................................
.......... 40
2.4 Connecting Widgets to Application
Code ..........................................................................
41
2.4.1
Callbacks ......................................................................
.................................................. 42
2.4.2
Actions ........................................................................
................................................... 45
2.4.2.1 The Actions
Table ..........................................................................
........................... 48
2.4.2.2 Format of an Action
Procedure ......................................................................
......... 48
2.4.2.3 The Translation
..................... 49
2.4.2.4 Hardcoding
Translations ...................................................................
....................... 51
2.5 More About
Resources ......................................................................
................................... 52
2.5.1 Setting and Getting Resources from the
Application ................................................. 52
2.5.1.1 Setting Resources with the Varargs
Interfaces ....................................................... 53
2.5.1.2 Setting Resources with the ArgList
Interfaces ....................................................... 54
2.5.1.3 Getting a Resource
Value ..........................................................................
.............. 56
2.5.2 Core
Resources ......................................................................
........................................ 57
2.5.3 Other Inherited
...................... 59
3 More Techniques for Using
Widgets .................................................................... 65
3.1 Using Composite Widgets ........................................................................
........................... 65
3.1.1 Setting Resources for an Instance
Hierarchy .............................................................. 68
3.1.2 Geometry Management in
Practice .......................................................................
....... 69
3.2 Using Conslraint
............................ 72
3.3 Using Pop
Ups ............................................................................
.......................................... 75
3.4 More About
Callbacks ......................................................................
................................... 81
3.4.1 Passing Data to Callback
Functions ......................................................................
....... 81
3.4.2 Callback
Lists ..........................................................................
...................................... 84
3.5 Application
Resources ......................................................................
................................... 85
3.5.1 The Application Data
Structure ......................................................................
.............. 86
3.5.2 The Resource
List ...........................................................................
............................... 86
3.5.3 Getting the
Resources ......................................................................
............................. 90
3.6 Command-line
Options ........................................................................
................................ 91
3.6.1 Standard Command-line
......... 91
3.6.2 Defining Your Own Command-line
Options ............................................................... 93
3.7 Preventing User Customization of Widget
Resources ....................................................... 97
3.7.1 Using the Varargs
Interfaces .....................................................................
.................... 97
3.7.2 Using the Argument List
........ 99
3.7.2.1 Another Way to Set
Arguments ......................................................................
....... 100
3.7.2.2 Merging Argument
Lists ..........................................................................
.............. 102
3.8 More About Application
Contexts .......................................................................
............. 102
4 An Example
Application ....................................................................
...................... 105 4.1 xbitmapl: Bitmap Editor Using a BitmapEdit
Widget ................................................... 106
4.1.1 Widget Public
Functions ......................................................................
....................... 109
4.1.2 Application-defaults
File ...........................................................................
................. 109
4.2 xbitmap2: Adding Scrollbars to Handle Large
Bitmaps ................................................ 109
4.2.1 Overriding
Translations ...................................................................
........................... 114
4.2.2 Action Arguments in the Translation
Table ............................................................... 114
4.2.3 The resize_thumbs
Action .........................................................................
................. 115
4.2.4 Scrollbar
Callbacks ......................................................................
............................... 116
4.3 xbitmap3: Adding Graphics to Display the
Bitmap ........................................................ 118
4.3.1 Graphics from the
Application ....................................................................
............... 121
4.3.2 Writing a Bitmap
File ...........................................................................
....................... 124
4.4 xbitmap4: Bitmap Editor Without a BitmapEdit
Widget ............................................... 125
5 Inside a
Widget .........................................................................
.................................... 137
5.1 Widget Source File
Organization ...................................................................
................... 138
5.2 The Private Header File--
BitmapEdiP.h ...................................................................
...... 138
5.2.1 Parts and
Records ........................................................................
................................ 139
5.2.2 Class Part and Class
Record .........................................................................
.............. 140
5.2.3 Instance Part and Instance
.... 141
5.3 The Widget Implementation File--
BitmapEdit.c ........................................................... 143
5.3.1 Obligatory Include
Files ..........................................................................
................... 145
5.3.2 Defining the Resource
List ...........................................................................
.............. 145
5.3.3 The Translation Table and Actions
Table .................................................................. 148 5.3.4 Declaring
Methods ........................................................................
.............................. 150
5.3.5 Initializing the Class
Record .........................................................................
............. 151
5.3.5.1 The Core Class
Part ...........................................................................
..................... 151
5.3.5.2 Initializing the Core
Methods ........................................................................
........ 153
5.3.6 Description of Core
............. 155
5.3.7 Packaging the Class Record for Application
Use ..................................................... 157
5.3.8 A Sample
Method .........................................................................
............................... 157
5.4 The Public Header File--
BitmapEdit.h ...................................................................
........ 160
5.5 The Process of Widget
Writing ........................................................................
................. 163
5.6 Summary of
Conventions ....................................................................
............................... 164
6 Basic Widget
Methods ........................................................................
....................... 169
6.1 The X Graphics Model Inside
Widgets ........................................................................
..... 170
6.2 The initialize
Method .........................................................................
................................ 170
6.2.1 Creating
GCs ............................................................................
................................... 172
6.3 The expose
................................... 175
6.4 The set_values
Method .........................................................................
............................. 178
6.5 The resize
Method ........................................................................
...................................... 181
6.6 The query_geometry
................... 184
6.7 The destroy
................................... 187
6.8 Actions in the Widget
Framework ......................................................................
.............. 188 7 Events, Translations, and
Accelerators .............................................................. 193
7.1 Translation Table
Syntax .........................................................................
........................... 194
7.1.1 The
Direct