0
|
1 #ifndef LWLIB_H
|
|
2 #define LWLIB_H
|
|
3
|
|
4 #include <X11/Intrinsic.h>
|
|
5
|
|
6 /* To eliminate use of `const' in the lwlib sources, define CONST_IS_LOSING. */
|
|
7 #undef CONST
|
|
8 #ifdef CONST_IS_LOSING
|
|
9 # define CONST
|
|
10 #else
|
|
11 # define CONST const
|
|
12 #endif
|
|
13
|
|
14 #if defined (MENUBARS_LUCID) || defined (MENUBARS_MOTIF) || defined (MENUBARS_ATHENA)
|
|
15 #define NEED_MENUBARS
|
|
16 #endif
|
|
17 #if defined (SCROLLBARS_LUCID) || defined (SCROLLBARS_MOTIF) || defined (SCROLLBARS_ATHENA)
|
|
18 #define NEED_SCROLLBARS
|
|
19 #endif
|
|
20 #if defined (DIALOGS_LUCID) || defined (DIALOGS_MOTIF) || defined (DIALOGS_ATHENA)
|
|
21 #define NEED_DIALOGS
|
|
22 #endif
|
|
23
|
|
24 /*
|
|
25 ** Widget values depend on the Widget type:
|
|
26 **
|
|
27 ** widget: (name value key enabled data contents/selected)
|
|
28 **
|
|
29 ** label: ("name" "string" NULL NULL NULL NULL)
|
|
30 ** BUTTON: ("name" "string" "key" T/F data <default-button-p>)
|
|
31 ** CASCADE (button w/menu):
|
|
32 ** ("name" "string" "key" T/F data (label|button|button w/menu...))
|
|
33 ** INCREMENTAL (button w/menu construction callback):
|
|
34 ** ("name" "string" NULL T/F <opaque pointer>)
|
|
35 ** menubar: ("name" NULL NULL T/F data (button w/menu))
|
|
36 ** scrollbar:("name" NULL NULL T/F NULL NULL)
|
|
37 ** selectable thing:
|
|
38 ** ("name" "string" "key" T/F data T/F)
|
|
39 ** checkbox: selectable thing
|
|
40 ** radio: ("name" NULL NULL T/F data (selectable thing...))
|
|
41 ** strings: ("name" NULL NULL T/F data (selectable thing...))
|
|
42 ** TEXT: ("name" "string" <ign> T/F data)
|
|
43 **
|
|
44 ** Note that the above is EXTREMELY bogus. The "type" of the various entities
|
|
45 ** that a widget_value structure can represent is implicit in the contents of
|
|
46 ** half a dozen slots, instead of there simply being a type field. This
|
|
47 ** should all be rethunk. I've added a type field, but for now it's only used
|
|
48 ** by the new xlwmenu code.
|
|
49 */
|
|
50
|
|
51 typedef unsigned long LWLIB_ID;
|
|
52
|
|
53 typedef enum _change_type
|
|
54 {
|
|
55 NO_CHANGE = 0,
|
|
56 INVISIBLE_CHANGE = 1,
|
|
57 VISIBLE_CHANGE = 2,
|
|
58 STRUCTURAL_CHANGE = 3
|
|
59 } change_type;
|
|
60
|
|
61 typedef enum _widget_value_type
|
|
62 {
|
|
63 UNSPECIFIED_TYPE = 0,
|
|
64 BUTTON_TYPE = 1,
|
|
65 TOGGLE_TYPE = 2,
|
|
66 RADIO_TYPE = 3,
|
|
67 TEXT_TYPE = 4,
|
|
68 SEPARATOR_TYPE = 5,
|
|
69 CASCADE_TYPE = 6,
|
|
70 PUSHRIGHT_TYPE = 7,
|
|
71 INCREMENTAL_TYPE = 8
|
|
72 } widget_value_type;
|
|
73
|
|
74 typedef enum _scroll_action
|
|
75 {
|
|
76 SCROLLBAR_LINE_UP = 0,
|
|
77 SCROLLBAR_LINE_DOWN = 1,
|
|
78 SCROLLBAR_PAGE_UP = 2,
|
|
79 SCROLLBAR_PAGE_DOWN = 3,
|
|
80 SCROLLBAR_DRAG = 4,
|
|
81 SCROLLBAR_CHANGE = 5,
|
|
82 SCROLLBAR_TOP = 6,
|
|
83 SCROLLBAR_BOTTOM = 7
|
|
84 } scroll_action;
|
|
85
|
|
86 typedef struct _scroll_event
|
|
87 {
|
|
88 scroll_action action;
|
|
89 int slider_value;
|
|
90 Time time;
|
|
91 } scroll_event;
|
|
92
|
|
93 typedef struct _scrollbar_values
|
|
94 {
|
|
95 int line_increment;
|
|
96 int page_increment;
|
|
97
|
|
98 int minimum;
|
|
99 int maximum;
|
|
100
|
|
101 int slider_size;
|
|
102 int slider_position;
|
|
103
|
|
104 int scrollbar_width, scrollbar_height;
|
|
105 int scrollbar_x, scrollbar_y;
|
|
106 } scrollbar_values;
|
|
107
|
|
108 typedef struct _widget_value
|
|
109 {
|
|
110 /* This slot is only partially utilized right now. */
|
|
111 widget_value_type type;
|
|
112
|
|
113 /* name of widget */
|
|
114 char* name;
|
|
115 /* value (meaning BOGUSLY depend on widget type) */
|
|
116 char* value;
|
|
117 /* keyboard equivalent. no implications for XtTranslations */
|
|
118 char* key;
|
|
119 /* true if enabled */
|
|
120 Boolean enabled;
|
|
121 /* true if selected */
|
|
122 Boolean selected;
|
|
123 /* true if was edited (maintained by get_value) */
|
|
124 Boolean edited;
|
|
125 /* true if has changed (maintained by lw library) */
|
|
126 change_type change;
|
|
127 /* Contents of the sub-widgets, also selected slot for checkbox */
|
|
128 struct _widget_value* contents;
|
|
129 /* data passed to callback */
|
|
130 XtPointer call_data;
|
|
131 /* next one in the list */
|
|
132 struct _widget_value* next;
|
|
133 /* slot for the toolkit dependent part. Always initialize to NULL. */
|
|
134 void* toolkit_data;
|
|
135 /* tell us if we should free the toolkit data slot when freeing the
|
|
136 widget_value itself. */
|
|
137 Boolean free_toolkit_data;
|
|
138
|
|
139 /* data defining a scrollbar; only valid if type == "scrollbar" */
|
|
140 scrollbar_values *scrollbar_data;
|
|
141
|
|
142 /* we resource the widget_value structures; this points to the next
|
|
143 one on the free list if this one has been deallocated.
|
|
144 */
|
|
145 struct _widget_value *free_list;
|
|
146 } widget_value;
|
|
147
|
|
148
|
|
149 typedef void (*lw_callback) (Widget w, LWLIB_ID id, XtPointer data);
|
|
150
|
|
151 void lw_register_widget (CONST char* type, CONST char* name, LWLIB_ID id,
|
|
152 widget_value* val, lw_callback pre_activate_cb,
|
|
153 lw_callback selection_cb,
|
|
154 lw_callback post_activate_cb);
|
|
155 Widget lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
|
|
156 Widget lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
|
|
157 Widget lw_create_widget (CONST char* type, CONST char* name, LWLIB_ID id,
|
|
158 widget_value* val, Widget parent, Boolean pop_up_p,
|
|
159 lw_callback pre_activate_cb,
|
|
160 lw_callback selection_cb,
|
|
161 lw_callback post_activate_cb);
|
|
162 LWLIB_ID lw_get_widget_id (Widget w);
|
|
163 int lw_map_widget_values (LWLIB_ID id, int (*mapfunc) (widget_value *value,
|
|
164 void *closure),
|
|
165 void *closure);
|
|
166 void lw_modify_all_widgets (LWLIB_ID id, widget_value* val, Boolean deep_p);
|
|
167 void lw_destroy_widget (Widget w);
|
|
168 void lw_destroy_all_widgets (LWLIB_ID id);
|
|
169 void lw_destroy_everything (void);
|
|
170 void lw_destroy_all_pop_ups (void);
|
|
171 Widget lw_raise_all_pop_up_widgets (void);
|
|
172 widget_value* lw_get_all_values (LWLIB_ID id);
|
|
173 Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
|
|
174 void lw_pop_up_all_widgets (LWLIB_ID id);
|
|
175 void lw_pop_down_all_widgets (LWLIB_ID id);
|
|
176
|
|
177 widget_value *malloc_widget_value (void);
|
|
178 void free_widget_value (widget_value *);
|
|
179 widget_value *replace_widget_value_tree (widget_value*, widget_value*);
|
|
180
|
|
181 void lw_popup_menu (Widget, XEvent *);
|
|
182
|
|
183 /* Toolkit independent way of focusing on a Widget at the Xt level. */
|
|
184 void lw_set_keyboard_focus (Widget parent, Widget w);
|
|
185
|
|
186 /* Silly Energize hack to invert the "sheet" button */
|
|
187 void lw_show_busy (Widget w, Boolean busy);
|
|
188
|
|
189 #endif /* LWLIB_H */
|