editresP.h revision 278eca22
1 2/* 3 * $Xorg: editresP.h,v 1.4 2001/02/09 02:05:29 xorgcvs Exp $ 4 * 5Copyright 1989, 1998 The Open Group 6 7Permission to use, copy, modify, distribute, and sell this software and its 8documentation for any purpose is hereby granted without fee, provided that 9the above copyright notice appear in all copies and that both that 10copyright notice and this permission notice appear in supporting 11documentation. 12 13The above copyright notice and this permission notice shall be included in 14all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of The Open Group shall not be 24used in advertising or otherwise to promote the sale, use or other dealings 25in this Software without prior written authorization from The Open Group. 26 * 27 * Author: Chris D. Peterson, MIT X Consortium 28 */ 29/* $XFree86: xc/programs/editres/editresP.h,v 1.6 2001/07/25 15:05:13 dawes Exp $ */ 30 31#include <X11/Xmu/EditresP.h> 32#include <X11/Xresource.h> 33 34#define DEBUG 35 36#ifdef DEBUG 37# define CLIENT_TIME_OUT 60000 /* wait sixty seconds for the client. */ 38#else 39# define CLIENT_TIME_OUT 5000 /* wait five seconds for the client. */ 40#endif /* DEBUG */ 41 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 46 47#define CURRENT_PROTOCOL_VERSION PROTOCOL_VERSION_ONE_POINT_ONE 48#define CURRENT_PROTOCOL_VERSION_STRING ONE_POINT_ONE_STRING 49 50#define FLASH_TIME 1000 /* Default flash time in microseconds */ 51#define NUM_FLASHES 3 /* Default number of flashes. */ 52 53#define NO_IDENT 0 /* an ident that will match nothing. */ 54 55#define NUM_INC 10 /* amount to increment allocators. */ 56 57#define ANY_RADIO_DATA ("the any widget") 58#define RESOURCE_BOX ("resourceBox") 59 60 61/* 62 * Retrieving ResType and Boolean is the same as retrieving a Card8 except 63 * possibly for signedness. 64 */ 65 66#define _XEditResGetBoolean(_s, _r) _XEditResGet8((_s), (unsigned char *)(_r)) 67#define _XEditResGetResType _XEditResGet8 68 69/* 70 * Contexts to use with the X Context Manager. 71 */ 72 73#define NODE_INFO ((XContext) 42) 74 75/* 76 * Error codes for X Server errors. 77 */ 78 79#define NO_ERROR 0 80#define NO_WINDOW 1 81 82typedef enum {LocalSendWidgetTree, LocalSetValues, LocalFindChild, 83 LocalFlashWidget, LocalGetGeometry, LocalGetResources, 84 LocalGetValues} ResCommand; 85 86typedef enum {ClassLabel, NameLabel, IDLabel, WindowLabel, 87 ToggleLabel} LabelTypes; 88typedef enum {SelectWidget, SelectAll, SelectNone, SelectInvert, SelectParent, 89 SelectChildren, SelectDescendants, SelectAncestors} SelectTypes; 90 91typedef 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. */ 95} NameInfo; 96 97typedef 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. */ 106} ResourceBoxInfo; 107 108typedef struct _WidgetResourceInfo { 109 char * name, * class, *type; /* Name, Class and Type of each resource. */ 110} WidgetResourceInfo; 111 112typedef struct _WidgetResources { 113 int num_normal, num_constraint; 114 WidgetResourceInfo *normal, *constraint; 115 ResourceBoxInfo * res_box; 116} WidgetResources; 117 118typedef struct _WNode { 119 char * name; 120 char * class; 121 unsigned long id, window; 122 struct _WNode * parent; 123 struct _WNode ** children; 124 struct _TreeInfo * tree_info; 125 Cardinal num_children, alloc_children; 126 Widget widget; 127 WidgetResources * resources; 128} WNode; 129 130/* 131 * Information for the Select any widget, toggle buttons in the resource 132 * boxes. 133 */ 134 135typedef 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. */ 142} AnyInfo; 143 144/* 145 * Information about the client we are currently working with. 146 */ 147 148typedef struct _CurrentClient { 149 ResCommand command; /* the command sent. */ 150 ResIdent ident; 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.*/ 155} CurrentClient; 156 157/* 158 * Information about a tree we can display. 159 */ 160 161typedef 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.*/ 168} TreeInfo; 169 170/* 171 * Information specific to a give APPLICATION screen. 172 */ 173 174typedef 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. */ 179} ScreenData; 180 181typedef 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. */ 186 187 /* Private state */ 188 Boolean allocated_save_resources_file; 189} AppResources; 190 191/* 192 * Information needed to apply the resource string to all widgets. 193 */ 194 195typedef struct _ApplyResourcesInfo { 196 char * name, *class; /* name and class of this resource. */ 197 unsigned short count; 198 ProtocolStream * stream; 199 XrmDatabase database; 200} ApplyResourcesInfo; 201 202/* 203 * Information needed to get a resource string from a widget. 204 */ 205 206typedef struct _ObtainResourcesInfo { 207 char * name, *class; /* name and class of this resource. */ 208 unsigned short count; 209 ProtocolStream * stream; 210 XrmDatabase database; 211} ObtainResourcesInfo; 212 213/************************************************************ 214 * 215 * The Event Structures. 216 * 217 ************************************************************/ 218 219typedef struct _AnyEvent { 220 EditresCommand type; 221} AnyEvent; 222 223typedef struct _WidgetTreeInfo { 224 WidgetInfo widgets; 225 char * name; 226 char * class; 227 unsigned long window; 228} WidgetTreeInfo; 229 230typedef struct _SendWidgetTreeEvent { 231 EditresCommand type; 232 char * toolkit; 233 unsigned short num_entries; 234 WidgetTreeInfo * info; 235} SendWidgetTreeEvent; 236 237typedef struct _SetValuesInfo { 238 WidgetInfo widgets; 239 char * message; 240} SetValuesInfo; 241 242typedef struct _SetValuesEvent { 243 EditresCommand type; 244 unsigned short num_entries; 245 SetValuesInfo * info; 246} SetValuesEvent; 247 248typedef struct _GetValuesInfo { 249 WidgetInfo widgets; 250 char * value; 251} GetValuesInfo; 252 253typedef struct _GetValuesEvent { 254 EditresCommand type; 255 unsigned short num_entries; 256 GetValuesInfo * info; 257} GetValuesEvent; 258 259typedef struct _ResourceInfo { 260 ResourceType res_type; 261 char * name, *class, *type; 262} ResourceInfo; 263 264typedef struct _GetResourcesInfo { 265 WidgetInfo widgets; 266 Boolean error; 267 char * message; 268 unsigned short num_resources; 269 ResourceInfo * res_info; 270} GetResourcesInfo; 271 272typedef struct _GetResourcesEvent { 273 EditresCommand type; 274 unsigned short num_entries; 275 GetResourcesInfo * info; 276} GetResourcesEvent; 277 278typedef struct _GetGeomInfo { 279 EditresCommand type; 280 WidgetInfo widgets; 281 Boolean error; 282 char * message; 283 Boolean visable; 284 short x, y; 285 unsigned short width, height, border_width; 286} GetGeomInfo; 287 288typedef struct _GetGeomEvent { 289 EditresCommand type; 290 unsigned short num_entries; 291 GetGeomInfo * info; 292} GetGeomEvent; 293 294typedef struct _FindChildEvent { 295 EditresCommand type; 296 WidgetInfo widgets; 297} FindChildEvent; 298 299typedef union _Event { 300 AnyEvent any_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; 307} Event; 308 309/* 310 * number of application resource labels. 311 */ 312 313#define NUM_RES_LABELS 37 314 315/* 316 * Global variables. 317 */ 318extern int global_effective_protocol_version; 319extern char* global_effective_toolkit; 320extern int global_error_code; 321extern unsigned long global_serial_num; 322extern int (*global_old_error_handler)(Display *, XErrorEvent *); 323extern Boolean global_resource_box_up; 324 325extern TreeInfo *global_tree_info; 326extern CurrentClient global_client; 327extern ScreenData global_screen_data; 328extern Widget global_tree_parent; 329extern Widget global_paned; /* named after toolkit */ 330extern Widget global_toplevel; 331extern AppResources global_resources; 332 333extern String res_labels[NUM_RES_LABELS]; 334 335extern Boolean do_get_values; 336extern Atom wm_delete_window; 337 338/* number of entries in the command menu */ 339#define NUM_CM_ENTRIES 8 340extern Widget CM_entries[NUM_CM_ENTRIES]; 341 342/* number of entries in the tree menu */ 343#define NUM_TM_ENTRIES 16 344extern Widget TM_entries[NUM_TM_ENTRIES]; 345 346/* 347 * Macros. 348 */ 349 350#define streq(a, b) ( strcmp((a), (b)) == 0 ) 351 352/* offset into CM entries for setting insensitive */ 353#define CM_OFFSET 1 354/* number of CM entries to make insensitive */ 355#define CM_NUM 5 356#define TM_OFFSET 0 357#define TM_NUM 16 358 359/* 360 * Prototypes 361 */ 362extern void ActivateResourceWidgets ( Widget w, XtPointer node_ptr, XtPointer junk ); 363extern void ActivateWidgetsAndSetResourceString ( Widget w, XtPointer node_ptr, XtPointer call_data ); 364extern void AddString ( char ** str, char *add ); 365extern void AddTreeNode ( Widget tree, WNode * top ); 366extern void AnyChosen ( Widget w, XtPointer any_info_ptr, XtPointer state_ptr ); 367extern void ApplyResource ( Widget w, XtPointer node_ptr, XtPointer junk ); 368extern void BuildVisualTree ( Widget tree_parent, Event * event ); 369extern void BuildWidgetTree ( Widget parent ); 370extern Boolean CheckDatabase ( XrmDatabase db, XrmQuarkList names, XrmQuarkList classes ); 371extern void CreateResourceBox ( WNode * node, char ** errors ); 372extern void CreateResourceBoxWidgets ( WNode * node, char **names, char **cons_names ); 373extern TreeInfo * CreateTree ( Event * event ); 374extern void DisplayChild ( Event * event ); 375extern void DumpTreeToFile ( Widget w, XtPointer junk, XtPointer garbage ); 376extern void ExecuteOverAllNodes ( WNode * top_node, void (*func)(WNode *, XtPointer), XtPointer data ); 377extern WNode * FindNode ( WNode *top_node, unsigned long * ids, Cardinal number ); 378extern void FindWidget ( Widget w, XtPointer client_data, XtPointer call_data ); 379extern WNode * FindWidgetFromWindow ( TreeInfo * tree_info, Window win ); 380extern void FlashActiveWidgets ( Widget w, XtPointer junk, XtPointer garbage ); 381extern void GetAllStrings ( char *in, char sep, char ***out, int * num ); 382extern Window GetClientWindow ( Widget w, int *x, int *y ); 383extern char * GetFailureMessage ( ProtocolStream * stream ); 384extern void GetNamesAndClasses ( WNode * node, char *** names, char ***classes ); 385extern ResIdent GetNewIdent ( void ); 386extern void GetResourceList ( Widget w, XtPointer junk, XtPointer garbage ); 387extern char * GetResourceValueForSetValues ( WNode * node, unsigned short * size ); 388extern char * HandleFlashWidget ( Event * event ); 389extern char * HandleGetResources ( Event * event ); 390extern int HandleXErrors ( Display * display, XErrorEvent * error ); 391extern void InitSetValues ( Widget w, XtPointer client_data, XtPointer call_data ); 392extern void InsertWidgetFromNode ( ProtocolStream * stream, WNode * node ); 393extern void InternAtoms ( Display * dpy ); 394extern void LayoutTree ( Widget tree ); 395extern int main ( int argc, char **argv ); 396extern void ModifySVEntry ( Widget w, XEvent *event, String * params, Cardinal * num_params ); 397extern void PannerCallback ( Widget w, XtPointer closure, XtPointer report_ptr ); 398extern void PerformTreeToFileDump ( WNode * node, int num_tabs, FILE * fp ); 399extern void PopdownResBox ( Widget w, XtPointer shell_ptr, XtPointer junk ); 400extern void PopupCentered ( XEvent * event, Widget w, XtGrabKind mode ); 401extern void PopupSetValues ( Widget parent, XEvent * event ); 402extern void PortholeCallback ( Widget w, XtPointer panner_ptr, XtPointer report_ptr ); 403extern void PrepareToLayoutTree ( Widget tree ); 404extern void PrintNodes ( WNode * top ); 405extern char * PrintSetValuesError ( Event * event ); 406extern char * ProtocolFailure ( ProtocolStream * stream ); 407extern XrmQuarkList Quarkify ( char ** list, char * ptr ); 408extern void Quit ( Widget w, XtPointer client_data, XtPointer call_data ); 409extern void RebuildMenusAndLabel ( String toolkit ); 410extern void ResourceListCallback ( Widget list, XtPointer node_ptr, XtPointer junk ); 411extern void SaveResource ( Widget w, XtPointer res_box_ptr, XtPointer junk ); 412extern void SendTree ( Widget w, XtPointer value, XtPointer call_data ); 413extern void SetAndCenterTreeNode ( WNode * node ); 414extern void SetApplicationActions ( XtAppContext app_con ); 415extern void SetCommand ( Widget w, ResCommand command, char * msg ); 416extern void SetEntriesSensitive ( Widget *entries, int num, Boolean sensitive ); 417extern void SetFile ( Widget w, XtPointer junk, XtPointer garbage ); 418extern void SetMessage ( Widget w, char * str ); 419extern void SetResourceString ( Widget w, XtPointer node_ptr, XtPointer junk ); 420extern void TreeRelabel ( Widget w, XtPointer client_data, XtPointer call_data ); 421extern void TreeSelect ( Widget w, XtPointer client_data, XtPointer call_data ); 422extern void TreeToggle ( Widget w, XtPointer node_ptr, XtPointer state_ptr ); 423extern void _DumpTreeToFile ( Widget w, XtPointer tree_ptr, XtPointer filename ); 424extern void _FindWidget ( Widget w ); 425extern void _FlashActiveWidgets ( TreeInfo * tree_info ); 426extern void _PopdownFileDialog ( Widget w, XtPointer client_data, XtPointer junk ); 427extern void _PopupFileDialog ( Widget w, String str, String default_value, XtCallbackProc func, XtPointer data ); 428extern void _TreeActivateNode ( WNode * node, SelectTypes type ); 429extern void _TreeRelabel ( TreeInfo * tree_info, LabelTypes type ); 430extern void _TreeRelabelNode ( WNode * node, LabelTypes type, Boolean recurse ); 431extern void _TreeSelect ( TreeInfo * tree_info, SelectTypes type ); 432extern void _TreeSelectNode ( WNode * node, SelectTypes type, Boolean recurse ); 433 434