home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / clients / editres / editresP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-30  |  8.6 KB  |  296 lines

  1. /*
  2.  * $XConsortium: editresP.h,v 1.12 91/07/30 15:30:47 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Chris D. Peterson, MIT X Consortium
  24.  */
  25.  
  26. #include <X11/Xmu/EditresP.h>
  27. #include <X11/Xresource.h>
  28.  
  29. #define DEBUG
  30.  
  31. #ifdef DEBUG
  32. #  define CLIENT_TIME_OUT 60000    /* wait sixty seconds for the client. */
  33. #else
  34. #  define CLIENT_TIME_OUT 5000    /* wait five seconds for the client. */
  35. #endif /* DEBUG */
  36.  
  37. #define CURRENT_PROTOCOL_VERSION 4
  38.  
  39. #define FLASH_TIME  1000    /* Default flash time in microseconds */
  40. #define NUM_FLASHES 3        /* Default number of flashes. */
  41.  
  42. #define NO_IDENT 0        /* an ident that will match nothing. */
  43.  
  44. #define NUM_INC 10        /* amount to increment allocators. */
  45.  
  46. #define ANY_RADIO_DATA ("the any widget")
  47. #define RESOURCE_BOX ("resourceBox")
  48.  
  49. extern void exit();
  50.  
  51. /*
  52.  * Retrieving ResType and Boolean is the same as retrieving a Card8.
  53.  */
  54.  
  55. #define _XEditResGetBoolean _XEditResGet8
  56. #define _XEditResGetResType _XEditResGet8
  57.  
  58. /*
  59.  * Contexts to use with the X Context Manager.
  60.  */
  61.  
  62. #define NODE_INFO ((XContext) 42)
  63.  
  64. /*
  65.  * Error codes for X Server errors. 
  66.  */
  67.  
  68. #define NO_ERROR 0
  69. #define NO_WINDOW 1
  70.  
  71. typedef enum {LocalSendWidgetTree, LocalSetValues, LocalFindChild, 
  72.           LocalFlashWidget, LocalGetGeometry, LocalGetResources}ResCommand;
  73.  
  74. typedef enum {ClassLabel, NameLabel, IDLabel, WindowLabel,
  75.           ToggleLabel} LabelTypes;
  76. typedef enum {SelectWidget, SelectAll, SelectNone, SelectInvert, SelectParent, 
  77.           SelectChildren,  SelectDescendants, SelectAncestors} SelectTypes;
  78.  
  79. typedef struct _NameInfo {
  80.     struct _NameInfo * next;    /* Next element in the linked list. */
  81.     Widget sep_leader;        /* The separator toggle group leader. */
  82.     Widget name_leader;        /* The name toggle group leader. */
  83. } NameInfo;
  84.  
  85. typedef struct _ResourceBoxInfo {
  86.     Widget value_wid;        /* The string containing the value. */
  87.     Widget res_label;        /* The label containing current resoruce. */
  88.     Widget shell;        /* Shell widget containing resource box. */
  89.     Widget norm_list;        /* The List widget for the normal list. */
  90.     Widget cons_list;        /* The List widget for the 
  91.                    Constriaint Resources */
  92.     NameInfo * name_info;    /* The info about the widgets for each
  93.                    name and class in the instance heirarchy. */
  94. } ResourceBoxInfo;
  95.     
  96. typedef struct _WidgetResourceInfo {
  97.     char * name, * class, *type; /* Name, Class and Type of each resource. */
  98. } WidgetResourceInfo;
  99.     
  100. typedef struct _WidgetResources {
  101.     int num_normal, num_constraint;
  102.     WidgetResourceInfo *normal, *constraint;
  103.     ResourceBoxInfo * res_box;
  104. } WidgetResources;
  105.  
  106. typedef struct _WNode {
  107.     char * name;
  108.     char * class;
  109.     unsigned long id, window;
  110.     struct _WNode * parent;
  111.     struct _WNode ** children;
  112.     struct _TreeInfo * tree_info;
  113.     Cardinal num_children, alloc_children;
  114.     Widget widget;
  115.     WidgetResources * resources;
  116. } WNode;
  117.  
  118. /*
  119.  * Information for the Select any widget, toggle buttons in the resource
  120.  * boxes.
  121.  */
  122.  
  123. typedef struct _AnyInfo {
  124.     WNode * node;        /* A Pointer off to the node corrsponding to
  125.                    this resource box. */
  126.     Widget left_dot, left_star;    /* The dot and star widgets to our left. */
  127.     Widget right_dot, right_star; /* The dot and star widgets to our right. */
  128.     int left_count, *right_count; /* If count > 0 then desensitize the left or
  129.                     right dot and star widgets. */
  130. } AnyInfo;
  131.  
  132. /*
  133.  * Information about the client we are currently working with.
  134.  */
  135.  
  136. typedef struct _CurrentClient {
  137.     ResCommand command;        /* the command sent. */
  138.     ResIdent ident;
  139.     ProtocolStream stream;    /* protocol stream for this client. */
  140.     XtIntervalId timeout;    /* timeout set in case he doesn't answer. */
  141.     Window window;        /* window to communicate with. */
  142.     Atom atom;            /* Atom used to communicate with this client.*/
  143. } CurrentClient;
  144.  
  145. /*
  146.  * Information about a tree we can display.
  147.  */
  148.  
  149. typedef struct _TreeInfo {
  150.     Widget tree_widget;        /* The Tree widget that contains all nodes */
  151.     WNode * top_node;        /* The top node in the tree. */
  152.     WNode ** active_nodes;    /* The currently active nodes. */
  153.     Cardinal num_nodes, alloc_nodes; /* number of active nodes, and space */
  154.     Widget * flash_widgets;    /* list of widgets to flash on and off. */
  155.     Cardinal num_flash_widgets, alloc_flash_widgets; /* number of flash wids.*/
  156. } TreeInfo;
  157.  
  158. /*
  159.  * Information specific to a give APPLICATION screen.
  160.  */
  161.  
  162. typedef struct _ScreenData {
  163.     Widget set_values_popup;    /* The SetValues popup. */
  164.     Widget res_text;        /* SetValues resource text widget. */
  165.     Widget val_text;        /* SetValues value text widget. */
  166.     Widget info_label;            /* The information label. */
  167. } ScreenData;
  168.  
  169. typedef struct _AppResources {
  170.     Boolean debug;        /* Is debugging on? */
  171.     int num_flashes, flash_time; /* Number and duration of flashes. */
  172.     Pixel flash_color;        /* Color of flash window. */
  173.     char * save_resources_file;    /* File to save the resources into. */
  174.  
  175.     /* Private state */
  176.     Boolean allocated_save_resources_file;
  177. } AppResources;
  178.  
  179. /*
  180.  * Information needed to apply the resource string to all widgets.
  181.  */
  182.  
  183. typedef struct _ApplyResourcesInfo {
  184.     char * name, *class;    /* name and class  of this resource. */
  185.     unsigned short count;
  186.     ProtocolStream * stream;
  187.     XrmDatabase database;
  188. } ApplyResourcesInfo;
  189.     
  190.  
  191. /************************************************************
  192.  *
  193.  * The Event Structures.
  194.  *
  195.  ************************************************************/
  196.  
  197. typedef struct _AnyEvent {
  198.     EditresCommand type;
  199. } AnyEvent;
  200.  
  201. typedef struct _WidgetTreeInfo {
  202.     WidgetInfo widgets;
  203.     char * name;
  204.     char * class;
  205.     unsigned long window;
  206. } WidgetTreeInfo;
  207.  
  208. typedef struct _SendWidgetTreeEvent {
  209.     EditresCommand type;
  210.     unsigned short num_entries;
  211.     WidgetTreeInfo * info;
  212. } SendWidgetTreeEvent;
  213.  
  214. typedef struct _SetValuesInfo {
  215.     WidgetInfo widgets;
  216.     char * message;
  217. } SetValuesInfo;
  218.     
  219. typedef struct _SetValuesEvent {
  220.     EditresCommand type;
  221.     unsigned short num_entries;
  222.     SetValuesInfo * info;
  223. } SetValuesEvent;
  224.  
  225. typedef struct _ResourceInfo {
  226.     ResourceType res_type;
  227.     char * name, *class, *type;
  228. } ResourceInfo;
  229.  
  230. typedef struct _GetResourcesInfo {
  231.     WidgetInfo widgets;
  232.     Boolean error;
  233.     char * message;
  234.     unsigned short num_resources;
  235.     ResourceInfo * res_info;
  236. } GetResourcesInfo;
  237.  
  238. typedef struct _GetResourcesEvent {
  239.     EditresCommand type;
  240.     unsigned short num_entries;
  241.     GetResourcesInfo * info;
  242. } GetResourcesEvent;
  243.  
  244. typedef struct _GetGeomInfo {
  245.     EditresCommand type;
  246.     WidgetInfo widgets;
  247.     Boolean error;
  248.     char * message;
  249.     Boolean visable;
  250.     short x, y;
  251.     unsigned short width, height, border_width;
  252. } GetGeomInfo;
  253.  
  254. typedef struct _GetGeomEvent {
  255.     EditresCommand type;
  256.     unsigned short num_entries;
  257.     GetGeomInfo * info;
  258. } GetGeomEvent;
  259.  
  260. typedef struct _FindChildEvent {
  261.     EditresCommand type;
  262.     WidgetInfo widgets;
  263. } FindChildEvent;
  264.  
  265. typedef union _Event {
  266.     AnyEvent any_event;
  267.     SendWidgetTreeEvent send_widget_tree_event;
  268.     SetValuesEvent set_values_event;
  269.     GetResourcesEvent get_resources_event;
  270.     GetGeomEvent get_geom_event;
  271.     FindChildEvent find_child_event;
  272. } Event;
  273.     
  274. /*
  275.  * Global variables. 
  276.  */
  277.  
  278. #ifndef THIS_IS_MAIN
  279.     extern int global_error_code;
  280.     extern unsigned long global_serial_num;
  281.     extern int (*global_old_error_handler)();
  282.     extern Boolean global_resource_box_up;
  283.  
  284.     extern TreeInfo *global_tree_info;
  285.     extern CurrentClient global_client;
  286.     extern ScreenData global_screen_data;
  287.     extern Widget global_tree_parent;
  288.     extern AppResources global_resources;
  289. #endif
  290.  
  291. /*
  292.  * Macros.
  293.  */
  294.  
  295. #define streq(a, b)        ( strcmp((a), (b)) == 0 )
  296.