564e208f98bf0adb964e634dbd12480ab86a9c27
[openafs.git] / src / gtx / gtxobjects.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __gator_objects_h
11 #define __gator_objects_h  1
12
13 /*--------------------------------------------------------------------------------
14  * objects.h
15  *
16  * Constants and data structures defining the basis for a gator object.
17  *--------------------------------------------------------------------------------*/
18
19 #include "gtxwindows.h"         /*Standard window defs & ops */
20
21 /*Max number of chars in an object name*/
22 #define GATOR_OBJNAMELEN 128
23
24 /*
25  * The onode is the focus of all gator display activity.  There is a unique
26  * onode for each gator object.
27  */
28 struct onode {
29     int o_type;                 /*Object type */
30     char o_name[GATOR_OBJNAMELEN];      /*Object's string name */
31     int o_x, o_y;               /*X and Y coordinates */
32     int o_width, o_height;      /*Width & height in pixels */
33     int o_changed;              /*Changed since last refresh? */
34     short o_refcount;           /*Reference count */
35     struct gwin *o_window;      /*Object's associated graphical window */
36     struct onodeops *o_op;      /*Object's operations */
37     struct onode *o_home;       /*Ptr to home object */
38     struct onode *o_help;       /*Ptr to help object, if any */
39     struct onode *o_nextobj;    /*Ptr to next queued object, if any */
40     struct onode *o_upobj;      /*Ptr to parent (up) object, if any */
41     struct onode *o_downobj;    /*Ptr to child (down) object, if any */
42     int *o_data;                /*Ptr to object's private data region */
43 };
44
45 /*
46  * Operations on individual onodes.  A pointer to this function array is
47  * attached to each onode.  In reality, this array is different for each
48  * object type, holding additional operations specific to that object.
49  * However, every object must implement these functions in these first
50  * slots.
51  */
52 struct onodeops {
53     int (*on_destroy) (struct onode *); /*Destroy an onode */
54     int (*on_display) (struct onode *); /*Display an onode */
55     int (*on_release) (struct onode *); /*Decrement an onode ref count */
56 };
57
58 /*
59  * Macros facilitating the use of onode functions.
60  */
61 #define OOP_DESTROY(ONP)        (ONP)->o_op->on_destroy(ONP);
62 #define OOP_DISPLAY(ONP)        (ONP)->o_op->on_display(ONP);
63 #define OOP_RELEASE(ONP)        (ONP)->o_op->on_release(ONP);
64
65 /*
66  * Initialization parameters for an onode.
67  */
68 struct onode_initparams {
69     int i_debug;                /*Turn debugging on? */
70     struct gwin_initparams *i_gwparams; /*Ptr to window init params */
71 };
72
73 /*
74  * Creation parameters for an onode.
75  */
76 struct onode_createparams {
77     int cr_type;                /*Type of onode */
78     char cr_name[GATOR_OBJNAMELEN];     /*Object name */
79     int cr_x, cr_y;             /*X and Y coordinates */
80     int cr_width, cr_height;    /*Width & height in pixels */
81     struct gwin *cr_window;     /*Graphical window to use */
82     struct onode *cr_home_obj;  /*Home object */
83     struct onode *cr_prev_obj;  /*Object having this one as next */
84     struct onode *cr_parent_obj;        /*This object's parent */
85     char *cr_helpstring;        /*Ptr to object's help text */
86 };
87
88 /*
89   * Is debugging output enabled?
90   */
91 extern int objects_debug;
92
93 extern int gator_objects_init(struct onode_initparams *);
94     /*
95      * Summary:
96      *    Initialize the gator object package.
97      *
98      * Args:
99      *    struct onode_initparams *params: Initialization parameters.
100      *
101      * Returns:
102      *    0 on success,
103      *    Error value otherwise.
104      */
105
106 extern struct onode *gator_objects_create(struct onode_createparams *params);
107     /*
108      * Summary:
109      *    Create an onode of the given type.
110      *
111      * Args:
112      *    struct onode_createparams *params: Ptr to creation params.
113      *
114      * Returns:
115      *    Ptr to newly-created onode if successful,
116      *    Null pointer otherwise.
117      */
118
119 extern struct onode *gator_objects_lookup(char *);
120     /*
121      * Summary:
122      *    Look up a gator onode by name.
123      *
124      * Args:
125      *    char *onode_name: Onode string name to find.
126      *
127      * Returns:
128      *    Ptr to onode matching the given name if one exists,
129      *    Null pointer otherwise.
130      */
131
132 #endif /* __gator_objects_h */