Motif Programming Manual
15 Text Widgets
15.2.5 Output−only Text.....................................................................................................................396
15.3 Text Clipboard Functions........................................................................................................................399
15.3.1 Getting the Selection................................................................................................................403
15.3.2 Modifying the Selection Mechanisms.....................................................................................403
15.4 A Text Editor...........................................................................................................................................404
15.5 Text Callbacks.........................................................................................................................................412
15.5.1 The Activation Callback..........................................................................................................412
15.5.2 Text Modification Callbacks....................................................................................................415
15.5.3 The Cursor Movement Callback..............................................................................................423
15.5.4 Focus Callbacks.......................................................................................................................425
15.6 Text Widget Internationalization.............................................................................................................425
15.6.1 Text Representation.................................................................................................................425
15.6.2 Text Output..............................................................................................................................427
15.6.3 Text Input.................................................................................................................................427
15.7 Summary..................................................................................................................................................430
15.8 Exercises..................................................................................................................................................430
16 Menus......................................................................................................................................................................431
16.1 Menu Types.............................................................................................................................................431
16.2 Creating Simple Menus............................................................................................................................434
16.2.1 Popup Menus...........................................................................................................................434
16.2.2 Cascading Menus.....................................................................................................................437
16.2.3 Option Menus..........................................................................................................................440
16.3 Designing Menu Systems........................................................................................................................442
16.3.1 Menu Titles..............................................................................................................................444
16.3.2 Menu Items..............................................................................................................................445
16.3.3 Mnemonics...............................................................................................................................445
16.3.4 Accelerators.............................................................................................................................446
16.3.5 The Help Menu........................................................................................................................447
16.3.6 Sensitivity................................................................................................................................448
16.3.7 Tear−Off Menus......................................................................................................................450
16.4 General Menu Creation Techniques........................................................................................................452
16.4.1 Building Pulldown Menus.......................................................................................................452
16.4.2 Building Cascading Menus......................................................................................................455
16.4.3 Building Popup Menus............................................................................................................459
16.4.4 Building Option Menus...........................................................................................................466
16.5 Summary..................................................................................................................................................470
16.6 Exercises..................................................................................................................................................470
17 Interacting With the Window Manager...............................................................................................................471
17.1 Interclient Communication......................................................................................................................471
17.2 Shell Resources........................................................................................................................................472
17.2.1 Shell Positions..........................................................................................................................473
17.2.2 Shell Sizes................................................................................................................................473
17.2.3 The Shell's Icon........................................................................................................................477
17.3 VendorShell Resources............................................................................................................................479
17.3.1 Window Manager Decorations................................................................................................479
17.3.2 Window Menu Functions.........................................................................................................481
17.4 Handling Window Manager Messages....................................................................................................482
vi
Motif Programming Manual
17 Interacting With the Window Manager
17.4.1 Adding New Protocols.............................................................................................................485
17.4.2 Saving Application State.........................................................................................................486
17.5 Customized Protocols..............................................................................................................................488
17.6 Summary..................................................................................................................................................491
17.7 Exercises..................................................................................................................................................491
18 The Clipboard........................................................................................................................................................493
18.1 Simple Clipboard Copy and Retrieval.....................................................................................................494
18.1.1 Copying Data...........................................................................................................................497
18.1.2 Retrieving Data........................................................................................................................498
18.1.3 Querying the Clipboard for Data Size.....................................................................................501
18.2 Copy by Name.........................................................................................................................................502
18.3 Clipboard Data Formats...........................................................................................................................507
18.4 The Primary Selection and the Clipboard................................................................................................508
18.4.1 Clipboard Functions With Text Widgets.................................................................................509
18.4.2 The Owner of the Selection.....................................................................................................510
18.5 Implementation Issues.............................................................................................................................511
18.6 Summary..................................................................................................................................................512
19 Drag and Drop........................................................................................................................................................513
19.1 Using Drag and Drop...............................................................................................................................513
19.2 The Drag and Drop Model.......................................................................................................................515
19.2.1 The Drag Source......................................................................................................................516
19.2.2 The Drop Site...........................................................................................................................518
19.2.3 The Drag Icon..........................................................................................................................519
19.2.4 Protocols..................................................................................................................................521
19.2.5 The Programming Model.........................................................................................................522
19.3 Customizing Built−in Drag and Drop......................................................................................................524
19.3.1 Specifying the Drag Protocol...................................................................................................525
19.3.2 Turning Off Drag and Drop Functionality...............................................................................527
19.3.3 Modifying the Visual Effects...................................................................................................528
19.4 Working With Drag Sources....................................................................................................................529
19.4.1 Creating a Drag Source............................................................................................................536
19.4.2 Starting the Drag......................................................................................................................537
19.4.3 Converting the Data.................................................................................................................538
19.4.4 Modifying an Existing Drag Source........................................................................................539
19.4.5 Providing Custom Drag−over Visuals.....................................................................................542
19.4.6 Cleaning Up.............................................................................................................................544
19.5 Working With Drop Sites........................................................................................................................545
19.5.1 Creating a Drop Site.................................................................................................................552
19.5.2 Modifying an Existing Drop Site.............................................................................................553
19.5.3 Handling the Drop....................................................................................................................554
19.5.4 Providing Help.........................................................................................................................556
19.5.5 Providing Custom Drag−under Visuals...................................................................................560
19.6 Summary..................................................................................................................................................561
20 Compound Strings.................................................................................................................................................563
20.1 Internationalized Text Output..................................................................................................................563
20.2 Creating Compound Strings.....................................................................................................................564
vii
Motif Programming Manual
20 Compound Strings
20.2.1 The Simple Case......................................................................................................................564
20.2.2 Font List Tags..........................................................................................................................566
20.2.3 Compound String Segments....................................................................................................570
20.2.4 Multiple−font Strings...............................................................................................................573
20.3 Manipulating Compound Strings.............................................................................................................575
20.3.1 Compound String Functions....................................................................................................575
20.3.2 Compound String Retrieval.....................................................................................................577
20.3.3 Compound String Conversion.................................................................................................577
20.4 Working With Font Lists.........................................................................................................................579
20.4.1 Creating Font Lists...................................................................................................................579
20.4.2 Retrieving Font Lists...............................................................................................................583
20.4.3 Querying Font Lists.................................................................................................................583
20.5 Rendering Compound Strings..................................................................................................................584
20.6 Summary..................................................................................................................................................586
21 Signal Handling......................................................................................................................................................587
21.1 Handling Signals in Xlib..........................................................................................................................588
21.2 Handling Signals in Xt.............................................................................................................................590
21.3 An Example.............................................................................................................................................592
21.4 Additional Issues......................................................................................................................................597
21.5 Summary..................................................................................................................................................598
22 Advanced Dialog Programming...........................................................................................................................599
22.1 Help Systems...........................................................................................................................................599
22.1.1 Multi−level Help......................................................................................................................603
22.1.2 Context−sensitive Help............................................................................................................606
22.2 Working Dialogs......................................................................................................................................607
22.2.1 Using Work Procedures...........................................................................................................609
22.2.2 Using Timers............................................................................................................................613
22.2.3 Processing Events....................................................................................................................613
22.2.4 Updating the Display...............................................................................................................619
22.2.5 Avoiding Forks........................................................................................................................620
22.3 Dynamic Message Symbols.....................................................................................................................622
22.4 Summary..................................................................................................................................................627
23 Introduction to UIL...............................................................................................................................................628
23.1 Overview of UIL and Mrm......................................................................................................................628
23.1.1 Using UIL and Mrm.................................................................................................................628
23.1.2 Advantages and Disadvantages of UIL....................................................................................629
23.2 The...........................................................................................................................................................630
23.3 Describing an Interface With UIL...........................................................................................................631
23.3.1 Starting and Ending a Module.................................................................................................633
23.3.2 Specifying Module−wide Options...........................................................................................635
23.3.3 Include Files.............................................................................................................................636
23.3.4 Adding Comments...................................................................................................................636
23.3.5 Overview of UIL Language Syntax.........................................................................................636
23.3.6 Sections of a UIL Module........................................................................................................638
23.4 Compiling the UIL Module.....................................................................................................................640
23.5 Structure of an Mrm Application.............................................................................................................640
viii
Motif Programming Manual
23 Introduction to UIL
23.5.1 Initializing the Application......................................................................................................643
23.5.2 Creating the Interface...............................................................................................................646
23.5.3 Displaying the Interface...........................................................................................................647
23.6 Summary..................................................................................................................................................648
24 Using the UIL Compiler........................................................................................................................................649
24.1 Compiler Options.....................................................................................................................................649
24.1.1 Output File...............................................................................................................................649
24.1.2 Include Path.............................................................................................................................649
24.1.3 Generate Listing.......................................................................................................................650
24.1.4 Set Locale.................................................................................................................................650
24.1.5 Suppress Warnings...................................................................................................................651
24.1.6 Machine Listing.......................................................................................................................651
24.1.7 Use WML Description.............................................................................................................651
24.2 Errors, Warnings, and Informational Messages.......................................................................................651
24.2.1 Severe Error Messages.............................................................................................................651
24.2.2 Regular Error Messages...........................................................................................................651
24.2.3 Warning Messages...................................................................................................................652
24.2.4 Informational Messages...........................................................................................................653
24.3 Summary..................................................................................................................................................654
25 Creating a User Interface With UIL....................................................................................................................655
25.1 Viewing UIL Examples...........................................................................................................................655
25.2 Defining and Creating Widgets...............................................................................................................658
25.2.1 Specifying Widget Attributes..................................................................................................659
25.2.2 Sharing Widgets Among Modules...........................................................................................665
25.2.3 The Widget Creation Process...................................................................................................667
25.3 Defining and Fetching Values.................................................................................................................670
25.3.1 Sharing Values Between Modules...........................................................................................670
25.3.2 Fetching Values.......................................................................................................................671
25.3.3 Numeric Values.......................................................................................................................674
25.3.4 Text−related Values.................................................................................................................676
25.3.5 Colors.......................................................................................................................................684
25.3.6 Pixmaps....................................................................................................................................686
25.3.7 Widget Classes.........................................................................................................................690
25.3.8 Keysyms...................................................................................................................................690
25.3.9 Translation Tables....................................................................................................................691
25.4 Working With Callbacks..........................................................................................................................691
25.5 Using Lists...............................................................................................................................................692
25.6 Exporting Application Data.....................................................................................................................696
25.6.1 Declaring Identifiers in UIL.....................................................................................................696
25.6.2 Exporting Identifiers From Application Code.........................................................................696
25.7 Summary..................................................................................................................................................697
26 Building an Application With UIL.......................................................................................................................699
26.1 Defining the User Interface......................................................................................................................699
26.1.1 The Main Application Window...............................................................................................700
26.1.2 The Menu System....................................................................................................................703
26.1.3 Dialog Boxes............................................................................................................................706
ix
Motif Programming Manual
26 Building an Application With UIL
26.2 Creating the Application..........................................................................................................................708
26.2.1 Widget IDs...............................................................................................................................714
26.2.2 Callbacks..................................................................................................................................715
26.2.3 The Error Dialog......................................................................................................................715
26.3 Summary..................................................................................................................................................716
27 Advanced UIL Programming...............................................................................................................................717
27.1 Using Non−Motif Widgets......................................................................................................................717
27.1.1 The Widget Creation Procedure...............................................................................................717
27.1.2 Widget Include Files................................................................................................................720
27.1.3 Creating User−defined Widgets...............................................................................................721
27.2 Organizing UIL Modules.........................................................................................................................724
27.2.1 Using Separate Modules..........................................................................................................725
27.2.2 Organizing Within a Module...................................................................................................725
27.2.3 Supporting Internationalization...............................................................................................725
27.2.4 Organizing With Include Files.................................................................................................727
27.2.5 Creating Reusable Components...............................................................................................727
27.3 Specifying Resource Values....................................................................................................................728
27.3.1 Resource Name Checking........................................................................................................728
27.3.2 Resource Type Checking.........................................................................................................728
27.3.3 Resource Type Support............................................................................................................729
27.3.4 Callback Specifications............................................................................................................729
27.3.5 Wildcard Specification.............................................................................................................729
27.3.6 User Customization..................................................................................................................730
27.3.7 Dynamic Updating...................................................................................................................730
27.3.8 Guidelines for Setting Resources.............................................................................................730
27.4 Using Lists Effectively............................................................................................................................731
27.4.1 Specifying Common Resources...............................................................................................731
27.4.2 Reusing Components...............................................................................................................732
27.5 Prototyping an Interface With UIL..........................................................................................................736
27.5.1 Managing Widgets...................................................................................................................736
27.5.2 Creating Widgets.....................................................................................................................738
27.6 Summary..................................................................................................................................................741
28 Additional Example Programs.............................................................................................................................742
28.1 A Postcard Interface for Mail..................................................................................................................742
28.2 A Bitmap Display Utility.........................................................................................................................750
28.3 A Memo Calendar....................................................................................................................................759
x

Get Volume 6A: Motif Programming Manual now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.