3
* $Xorg: editresP.h,v 1.4 2001/02/09 02:05:29 xorgcvs Exp $
5
Copyright 1989, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
27
* Author: Chris D. Peterson, MIT X Consortium
29
/* $XFree86: xc/programs/editres/editresP.h,v 1.7 2001/12/14 20:00:42 dawes Exp $ */
31
#include <X11/Xmu/EditresP.h>
32
#include <X11/Xresource.h>
37
# define CLIENT_TIME_OUT 60000 /* wait sixty seconds for the client. */
39
# define CLIENT_TIME_OUT 5000 /* wait five seconds for the client. */
42
#define PROTOCOL_VERSION_ONE_POINT_ONE 5 /* version 1.1 */
43
#define ONE_POINT_ONE_STRING "1.1"
44
#define PROTOCOL_VERSION_ONE_POINT_ZERO 4 /* version 1.0 */
45
#define ONE_POINT_ZERO_STRING "1.0" ONE_POINT_ONE_STRING
47
#define CURRENT_PROTOCOL_VERSION PROTOCOL_VERSION_ONE_POINT_ONE
48
#define CURRENT_PROTOCOL_VERSION_STRING ONE_POINT_ONE_STRING
50
#define FLASH_TIME 1000 /* Default flash time in microseconds */
51
#define NUM_FLASHES 3 /* Default number of flashes. */
53
#define NO_IDENT 0 /* an ident that will match nothing. */
55
#define NUM_INC 10 /* amount to increment allocators. */
57
#define ANY_RADIO_DATA ("the any widget")
58
#define RESOURCE_BOX ("resourceBox")
62
* Retrieving ResType and Boolean is the same as retrieving a Card8 except
63
* possibly for signedness.
66
#define _XEditResGetBoolean(_s, _r) _XEditResGet8((_s), (unsigned char *)(_r))
67
#define _XEditResGetResType _XEditResGet8
70
* Contexts to use with the X Context Manager.
73
#define NODE_INFO ((XContext) 42)
76
* Error codes for X Server errors.
82
typedef enum {LocalSendWidgetTree, LocalSetValues, LocalFindChild,
83
LocalFlashWidget, LocalGetGeometry, LocalGetResources,
84
LocalGetValues} ResCommand;
86
typedef enum {ClassLabel, NameLabel, IDLabel, WindowLabel,
87
ToggleLabel} LabelTypes;
88
typedef enum {SelectWidget, SelectAll, SelectNone, SelectInvert, SelectParent,
89
SelectChildren, SelectDescendants, SelectAncestors} SelectTypes;
91
typedef struct _NameInfo {
92
struct _NameInfo * next; /* Next element in the linked list. */
93
Widget sep_leader; /* The separator toggle group leader. */
94
Widget name_leader; /* The name toggle group leader. */
97
typedef struct _ResourceBoxInfo {
98
Widget value_wid; /* The string containing the value. */
99
Widget res_label; /* The label containing current resoruce. */
100
Widget shell; /* Shell widget containing resource box. */
101
Widget norm_list; /* The List widget for the normal list. */
102
Widget cons_list; /* The List widget for the
103
Constriaint Resources */
104
NameInfo * name_info; /* The info about the widgets for each
105
name and class in the instance heirarchy. */
108
typedef struct _WidgetResourceInfo {
109
char * name, * class, *type; /* Name, Class and Type of each resource. */
110
} WidgetResourceInfo;
112
typedef struct _WidgetResources {
113
int num_normal, num_constraint;
114
WidgetResourceInfo *normal, *constraint;
115
ResourceBoxInfo * res_box;
118
typedef struct _WNode {
121
unsigned long id, window;
122
struct _WNode * parent;
123
struct _WNode ** children;
124
struct _TreeInfo * tree_info;
125
Cardinal num_children, alloc_children;
127
WidgetResources * resources;
131
* Information for the Select any widget, toggle buttons in the resource
135
typedef struct _AnyInfo {
136
WNode * node; /* A Pointer off to the node corrsponding to
137
this resource box. */
138
Widget left_dot, left_star; /* The dot and star widgets to our left. */
139
Widget right_dot, right_star; /* The dot and star widgets to our right. */
140
int left_count, *right_count; /* If count > 0 then desensitize the left or
141
right dot and star widgets. */
145
* Information about the client we are currently working with.
148
typedef struct _CurrentClient {
149
ResCommand command; /* the command sent. */
151
ProtocolStream stream; /* protocol stream for this client. */
152
XtIntervalId timeout; /* timeout set in case he doesn't answer. */
153
Window window; /* window to communicate with. */
154
Atom atom; /* Atom used to communicate with this client.*/
158
* Information about a tree we can display.
161
typedef struct _TreeInfo {
162
Widget tree_widget; /* The Tree widget that contains all nodes */
163
WNode * top_node; /* The top node in the tree. */
164
WNode ** active_nodes; /* The currently active nodes. */
165
Cardinal num_nodes, alloc_nodes; /* number of active nodes, and space */
166
Widget * flash_widgets; /* list of widgets to flash on and off. */
167
Cardinal num_flash_widgets, alloc_flash_widgets; /* number of flash wids.*/
171
* Information specific to a give APPLICATION screen.
174
typedef struct _ScreenData {
175
Widget set_values_popup; /* The SetValues popup. */
176
Widget res_text; /* SetValues resource text widget. */
177
Widget val_text; /* SetValues value text widget. */
178
Widget info_label; /* The information label. */
181
typedef struct _AppResources {
182
Boolean debug; /* Is debugging on? */
183
int num_flashes, flash_time; /* Number and duration of flashes. */
184
Pixel flash_color; /* Color of flash window. */
185
char * save_resources_file; /* File to save the resources into. */
188
Boolean allocated_save_resources_file;
192
* Information needed to apply the resource string to all widgets.
195
typedef struct _ApplyResourcesInfo {
196
char * name, *class; /* name and class of this resource. */
197
unsigned short count;
198
ProtocolStream * stream;
199
XrmDatabase database;
200
} ApplyResourcesInfo;
203
* Information needed to get a resource string from a widget.
206
typedef struct _ObtainResourcesInfo {
207
char * name, *class; /* name and class of this resource. */
208
unsigned short count;
209
ProtocolStream * stream;
210
XrmDatabase database;
211
} ObtainResourcesInfo;
213
/************************************************************
215
* The Event Structures.
217
************************************************************/
219
typedef struct _AnyEvent {
223
typedef struct _WidgetTreeInfo {
227
unsigned long window;
230
typedef struct _SendWidgetTreeEvent {
233
unsigned short num_entries;
234
WidgetTreeInfo * info;
235
} SendWidgetTreeEvent;
237
typedef struct _SetValuesInfo {
242
typedef struct _SetValuesEvent {
244
unsigned short num_entries;
245
SetValuesInfo * info;
248
typedef struct _GetValuesInfo {
253
typedef struct _GetValuesEvent {
255
unsigned short num_entries;
256
GetValuesInfo * info;
259
typedef struct _ResourceInfo {
260
ResourceType res_type;
261
char * name, *class, *type;
264
typedef struct _GetResourcesInfo {
268
unsigned short num_resources;
269
ResourceInfo * res_info;
272
typedef struct _GetResourcesEvent {
274
unsigned short num_entries;
275
GetResourcesInfo * info;
278
typedef struct _GetGeomInfo {
285
unsigned short width, height, border_width;
288
typedef struct _GetGeomEvent {
290
unsigned short num_entries;
294
typedef struct _FindChildEvent {
299
typedef union _Event {
301
SendWidgetTreeEvent send_widget_tree_event;
302
SetValuesEvent set_values_event;
303
GetResourcesEvent get_resources_event;
304
GetGeomEvent get_geom_event;
305
FindChildEvent find_child_event;
306
GetValuesEvent get_values_event;
310
* number of application resource labels.
313
#define NUM_RES_LABELS 37
320
extern int global_effective_protocol_version;
321
extern char* global_effective_toolkit;
322
extern int global_error_code;
323
extern unsigned long global_serial_num;
324
extern int (*global_old_error_handler)(Display *, XErrorEvent *);
325
extern Boolean global_resource_box_up;
327
extern TreeInfo *global_tree_info;
328
extern CurrentClient global_client;
329
extern ScreenData global_screen_data;
330
extern Widget global_tree_parent;
331
extern Widget global_paned; /* named after toolkit */
332
extern Widget global_toplevel;
333
extern AppResources global_resources;
335
extern String res_labels[NUM_RES_LABELS];
342
#define streq(a, b) ( strcmp((a), (b)) == 0 )
344
/* number of entries in the command menu */
345
#define NUM_CM_ENTRIES 8
346
/* offset into CM entries for setting insensitive */
348
/* number of CM entries to make insensitive */
350
/* number of entries in the tree menu */
351
#define NUM_TM_ENTRIES 16
358
extern void ActivateResourceWidgets ( Widget w, XtPointer node_ptr, XtPointer junk );
359
extern void ActivateWidgetsAndSetResourceString ( Widget w, XtPointer node_ptr, XtPointer call_data );
360
extern void AddString ( char ** str, char *add );
361
extern void AddTreeNode ( Widget tree, WNode * top );
362
extern void AnyChosen ( Widget w, XtPointer any_info_ptr, XtPointer state_ptr );
363
extern void ApplyResource ( Widget w, XtPointer node_ptr, XtPointer junk );
364
extern void BuildVisualTree ( Widget tree_parent, Event * event );
365
extern void BuildWidgetTree ( Widget parent );
366
extern Boolean CheckDatabase ( XrmDatabase db, XrmQuarkList names, XrmQuarkList classes );
367
extern void CreateResourceBox ( WNode * node, char ** errors );
368
extern void CreateResourceBoxWidgets ( WNode * node, char **names, char **cons_names );
369
extern TreeInfo * CreateTree ( Event * event );
370
extern void DisplayChild ( Event * event );
371
extern void DumpTreeToFile ( Widget w, XtPointer junk, XtPointer garbage );
372
extern void ExecuteOverAllNodes ( WNode * top_node, void (*func)(WNode *, XtPointer), XtPointer data );
373
extern WNode * FindNode ( WNode *top_node, unsigned long * ids, Cardinal number );
374
extern void FindWidget ( Widget w, XtPointer client_data, XtPointer call_data );
375
extern WNode * FindWidgetFromWindow ( TreeInfo * tree_info, Window win );
376
extern void FlashActiveWidgets ( Widget w, XtPointer junk, XtPointer garbage );
377
extern void GetAllStrings ( char *in, char sep, char ***out, int * num );
378
extern Window GetClientWindow ( Widget w, int *x, int *y );
379
extern char * GetFailureMessage ( ProtocolStream * stream );
380
extern void GetNamesAndClasses ( WNode * node, char *** names, char ***classes );
381
extern ResIdent GetNewIdent ( void );
382
extern void GetResourceList ( Widget w, XtPointer junk, XtPointer garbage );
383
extern char * GetResourceValueForSetValues ( WNode * node, unsigned short * size );
384
extern char * HandleFlashWidget ( Event * event );
385
extern char * HandleGetResources ( Event * event );
386
extern int HandleXErrors ( Display * display, XErrorEvent * error );
387
extern void InitSetValues ( Widget w, XtPointer client_data, XtPointer call_data );
388
extern void InsertWidgetFromNode ( ProtocolStream * stream, WNode * node );
389
extern void InternAtoms ( Display * dpy );
390
extern void LayoutTree ( Widget tree );
391
extern int main ( int argc, char **argv );
392
extern void ModifySVEntry ( Widget w, XEvent *event, String * params, Cardinal * num_params );
393
extern void PannerCallback ( Widget w, XtPointer closure, XtPointer report_ptr );
394
extern void PerformTreeToFileDump ( WNode * node, int num_tabs, FILE * fp );
395
extern void PopdownResBox ( Widget w, XtPointer shell_ptr, XtPointer junk );
396
extern void PopupCentered ( XEvent * event, Widget w, XtGrabKind mode );
397
extern void PopupSetValues ( Widget parent, XEvent * event );
398
extern void PortholeCallback ( Widget w, XtPointer panner_ptr, XtPointer report_ptr );
399
extern void PrepareToLayoutTree ( Widget tree );
400
extern void PrintNodes ( WNode * top );
401
extern char * PrintSetValuesError ( Event * event );
402
extern char * ProtocolFailure ( ProtocolStream * stream );
403
extern XrmQuarkList Quarkify ( char ** list, char * ptr );
404
extern void Quit ( Widget w, XtPointer client_data, XtPointer call_data );
405
extern void RebuildMenusAndLabel ( String toolkit );
406
extern void ResourceListCallback ( Widget list, XtPointer node_ptr, XtPointer junk );
407
extern void SaveResource ( Widget w, XtPointer res_box_ptr, XtPointer junk );
408
extern void SendTree ( Widget w, XtPointer value, XtPointer call_data );
409
extern void SetAndCenterTreeNode ( WNode * node );
410
extern void SetApplicationActions ( XtAppContext app_con );
411
extern void SetCommand ( Widget w, ResCommand command, char * msg );
412
extern void SetEntriesSensitive ( Widget *entries, int num, Boolean sensitive );
413
extern void SetFile ( Widget w, XtPointer junk, XtPointer garbage );
414
extern void SetMessage ( Widget w, char * str );
415
extern void SetResourceString ( Widget w, XtPointer node_ptr, XtPointer junk );
416
extern void TreeRelabel ( Widget w, XtPointer client_data, XtPointer call_data );
417
extern void TreeSelect ( Widget w, XtPointer client_data, XtPointer call_data );
418
extern void TreeToggle ( Widget w, XtPointer node_ptr, XtPointer state_ptr );
419
extern void _DumpTreeToFile ( Widget w, XtPointer tree_ptr, XtPointer filename );
420
extern void _FindWidget ( Widget w );
421
extern void _FlashActiveWidgets ( TreeInfo * tree_info );
422
extern void _PopdownFileDialog ( Widget w, XtPointer client_data, XtPointer junk );
423
extern void _PopupFileDialog ( Widget w, String str, String default_value, XtCallbackProc func, XtPointer data );
424
extern void _TreeActivateNode ( WNode * node, SelectTypes type );
425
extern void _TreeRelabel ( TreeInfo * tree_info, LabelTypes type );
426
extern void _TreeRelabelNode ( WNode * node, LabelTypes type, Boolean recurse );
427
extern void _TreeSelect ( TreeInfo * tree_info, SelectTypes type );
428
extern void _TreeSelectNode ( WNode * node, SelectTypes type, Boolean recurse );