1 SmartMessageBox Widget 2----------------------------------------------------------------------------- 3 4This is the xmSmartMessageBoxWidget. The basic idea is that I decided 5that dialogs should be simpler in Motif programs, ie, you shouldn't have 6to unmanage unwanted widgets just to have a dialog. Plus, the Template 7dialog is more voodoo than anything else. The SmartMessagBox widget 8manages whatever you tell it to in 4 different ways: as a label, as 9a control widget, as a separator, or as an action widget. You can 10have up to 1 label, up to 1 control, up to 1 separator, and as many action widgets 11as you'd like. This is all handled throught constraint resources. 12 13The basic setup is: 14 15 ------------------------------------ 16 - Label | - 17 - | Control - 18 -----------| Area - 19 - | _ 20 - separator - 21 ------------------------------------ 22 - Action - 23 - Area - 24 ------------------------------------ 25 26Although you don't need to have all of the different areas. 27 28 When you create a child of a SmartMessageBoxWidget, it's 29constraint resource XmNchildType defaults to XmCHILD_ACTION, which 30means for it to be managed in the action area. You can change 31this resource so that it is managed in any of the 4 fields above. 32A basic dialog box would then look like: 33 34 smb = XtCreateManagedWidget("SmartMessageBox", xmSmartMessageBoxWidgetClass, 35 toplevel, NULL, 0); 36 37 n = 0; 38 XtSetArg(warg[n], XmNchildType, XmCHILD_LABEL); n++; 39 XtCreateManagedWidget("Label", xmLabelWidgetClass, smb, warg, n); 40 41 n = 0; 42 XtSetArg(warg[n], XmNchildType, XmCHILD_SEPARATOR); n++; 43 XtCreateManagedWidget("Separator", xmSeparatorWidgetClass, smb, warg, n); 44 45 n = 0; 46 XtSetArg(warg[n], XmNchildType, XmCHILD_CONTROL); n++; 47 XtCreateManagedWidget("MessageLabel", xmLabelWidgetClass, smb, warg, n); 48 49/* 50** These default to the action area. 51*/ 52 53 defButton = XtCreateManagedWidget("OK", xmPushButtonWidgetClass, smb, warg, n); 54 XtCreateManagedWidget("Help", xmPushButtonWidgetClass, smb, NULL, 0); 55 56 n = 0; 57 XtSetArg(warg[n], XmNdefaultButton, defButton); n++; 58 XtSetValues(smb, warg, n); 59 60 The other resources are: 61 62 XmNminimizeButtons: (Boolean) make all the widgets in the action 63 area the smallest possible 64 65 XmNdialogType: (XmDIALOG_INFORMATION, etc.) adds the appropriate 66 bitmap to the dialog as a label automatically 67 68 XmNdialogPositioning: positions the dialog on popups to 69 70XmDIALOG_POSITIONING_LEAVE_ALONE: let the window manager do whatever 71 72XmDIALOG_POSITIONING_INITIAL_CENTER: first time it pops up centered in 73 the screen, afterwards it pops up wherever it was left 74 75XmDIALOG_POSITIONING_ALWAYS_CENTER: always pops up in the center of 76 the screen 77 78XmDIALOG_POSITIONING_DEFAULT_AT_POINTER: positions the dialog up so that the 79 default button is centered on the pointer 80 81XmDIALOG_POSITIONING_CENTER_AT_POINTER: positions the dialog up so that the 82 dialog is centered on the pointer 83 84 85 86 To build the SmartMessageBoxWidget you will need Motif 1.2. Plus 87if you have a version < 1.2.3 you will need to #define NEED_BBCONSTRAINT 1 88since the Motif headers didn't have the Bulletin board constraint part like 89they should have. 90 91 That's about it. Let me know what you think, and if I get encouraged 92then maybe I'll write some more...See copyright or source files for 93distribution info... 94 95 John L. Cwikla 96 cwikla@wri.com 97 98 Furthering "open software" into reality... 99 100