1 | #ifndef AW_WINDOW_XM_HXX |
---|
2 | #define AW_WINDOW_XM_HXX |
---|
3 | |
---|
4 | #ifndef AW_DEVICE_HXX |
---|
5 | #include <aw_device.hxx> |
---|
6 | #endif |
---|
7 | #ifndef AW_KEYSYM_HXX |
---|
8 | #include <aw_keysym.hxx> |
---|
9 | #endif |
---|
10 | #ifndef _Xm_h |
---|
11 | #include <Xm/Xm.h> |
---|
12 | #endif |
---|
13 | #ifndef CB_H |
---|
14 | #include <cb.h> |
---|
15 | #endif |
---|
16 | #ifndef AW_SCALAR_HXX |
---|
17 | #include "aw_scalar.hxx" |
---|
18 | #endif |
---|
19 | |
---|
20 | // macro definitions |
---|
21 | #define p_r prvt |
---|
22 | #define p_global (root->prvt) |
---|
23 | #define p_aww(aww) (aww->p_w) |
---|
24 | |
---|
25 | #define MAP_ARAM(ar) p_w->areas[ar] |
---|
26 | |
---|
27 | #define INFO_WIDGET p_w->areas[AW_INFO_AREA]->get_area() |
---|
28 | #define INFO_FORM p_w->areas[AW_INFO_AREA]->get_form() |
---|
29 | #define MIDDLE_WIDGET p_w->areas[AW_MIDDLE_AREA]->get_area() |
---|
30 | #define BOTTOM_WIDGET p_w->areas[AW_BOTTOM_AREA]->get_area() |
---|
31 | |
---|
32 | #define AW_SCROLL_MAX 100 |
---|
33 | #define AW_MAX_MENU_DEEP 10 |
---|
34 | |
---|
35 | #define RES_CONVERT(res_name, res_value) \ |
---|
36 | XtVaTypedArg, (res_name), XmRString, (res_value), strlen(res_value) + 1 |
---|
37 | |
---|
38 | #define AW_MOTIF_LABEL |
---|
39 | |
---|
40 | #define RES_LABEL_CONVERT_AWW(str,aww) \ |
---|
41 | XmNlabelType, (str[0]=='#') ? XmPIXMAP : XmSTRING, \ |
---|
42 | XtVaTypedArg, (str[0]=='#') ? XmNlabelPixmap : XmNlabelString, \ |
---|
43 | XmRString, \ |
---|
44 | aw_str_2_label(str, aww), \ |
---|
45 | strlen(aw_str_2_label(str, aww))+1 |
---|
46 | |
---|
47 | #define RES_LABEL_CONVERT(str) RES_LABEL_CONVERT_AWW(str, this) |
---|
48 | |
---|
49 | #define AW_JUSTIFY_LABEL(widget, corr) \ |
---|
50 | switch (corr) { \ |
---|
51 | case 1: XtVaSetValues(widget, XmNalignment, XmALIGNMENT_CENTER, NULL); break; \ |
---|
52 | case 2: XtVaSetValues(widget, XmNalignment, XmALIGNMENT_END, NULL); break; \ |
---|
53 | default: break; \ |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | struct AW_buttons_struct : virtual Noncopyable { |
---|
58 | AW_buttons_struct(AW_active maski, Widget w, AW_buttons_struct *next); |
---|
59 | ~AW_buttons_struct(); |
---|
60 | |
---|
61 | AW_active mask; |
---|
62 | Widget button; |
---|
63 | AW_buttons_struct *next; |
---|
64 | }; |
---|
65 | |
---|
66 | struct AW_widget_value_pair : virtual Noncopyable { |
---|
67 | template<typename T> explicit AW_widget_value_pair(T t, Widget w) : value(t), widget(w), next(NULL) {} |
---|
68 | ~AW_widget_value_pair() { aw_assert(!next); } // has to be unlinked from list BEFORE calling dtor |
---|
69 | |
---|
70 | AW_scalar value; |
---|
71 | Widget widget; |
---|
72 | |
---|
73 | AW_widget_value_pair *next; |
---|
74 | }; |
---|
75 | |
---|
76 | struct AW_option_menu_struct { |
---|
77 | AW_option_menu_struct(int numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct); |
---|
78 | |
---|
79 | int option_menu_number; |
---|
80 | char *variable_name; |
---|
81 | AW_VARIABLE_TYPE variable_type; |
---|
82 | Widget label_widget; |
---|
83 | Widget menu_widget; |
---|
84 | |
---|
85 | AW_widget_value_pair *first_choice; |
---|
86 | AW_widget_value_pair *last_choice; |
---|
87 | AW_widget_value_pair *default_choice; |
---|
88 | |
---|
89 | AW_pos x; |
---|
90 | AW_pos y; |
---|
91 | int correct_for_at_center_intern; // needed for centered and right justified menus (former member of AW_at) |
---|
92 | |
---|
93 | AW_option_menu_struct *next; |
---|
94 | }; |
---|
95 | |
---|
96 | |
---|
97 | struct AW_toggle_field_struct { |
---|
98 | AW_toggle_field_struct(int toggle_field_numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, int correct); |
---|
99 | |
---|
100 | int toggle_field_number; |
---|
101 | char *variable_name; |
---|
102 | AW_VARIABLE_TYPE variable_type; |
---|
103 | Widget label_widget; |
---|
104 | |
---|
105 | AW_widget_value_pair *first_toggle; |
---|
106 | AW_widget_value_pair *last_toggle; |
---|
107 | AW_widget_value_pair *default_toggle; |
---|
108 | |
---|
109 | int correct_for_at_center_intern; // needed for centered and right justified toggle fields (former member of AW_at) |
---|
110 | |
---|
111 | AW_toggle_field_struct *next; |
---|
112 | }; |
---|
113 | |
---|
114 | |
---|
115 | // ------------------------------------------- |
---|
116 | // area management: devices callbacks |
---|
117 | |
---|
118 | class AW_common_Xm; |
---|
119 | class AW_device_Xm; |
---|
120 | class AW_cb_struct; |
---|
121 | |
---|
122 | class AW_area_management { |
---|
123 | Widget form; // for resizing |
---|
124 | Widget area; // for displaying additional information |
---|
125 | |
---|
126 | AW_common_Xm *common; |
---|
127 | |
---|
128 | AW_device_Xm *device; |
---|
129 | AW_device_size *size_device; |
---|
130 | AW_device_print *print_device; |
---|
131 | AW_device_click *click_device; |
---|
132 | |
---|
133 | AW_cb_struct *expose_cb; |
---|
134 | AW_cb_struct *resize_cb; |
---|
135 | AW_cb_struct *double_click_cb; |
---|
136 | |
---|
137 | long click_time; |
---|
138 | |
---|
139 | public: |
---|
140 | AW_area_management(AW_root *awr, Widget form, Widget widget); |
---|
141 | |
---|
142 | Widget get_form() const { return form; } |
---|
143 | Widget get_area() const { return area; } |
---|
144 | |
---|
145 | AW_common_Xm *get_common() const { return common; } |
---|
146 | |
---|
147 | AW_device_Xm *get_screen_device(); |
---|
148 | AW_device_size *get_size_device(); |
---|
149 | AW_device_print *get_print_device(); |
---|
150 | AW_device_click *get_click_device(); |
---|
151 | |
---|
152 | void create_devices(AW_window *aww, AW_area ar); |
---|
153 | |
---|
154 | void set_expose_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL), AW_CL cd1, AW_CL cd2); |
---|
155 | void set_resize_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL), AW_CL cd1, AW_CL cd2); |
---|
156 | void set_input_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL), AW_CL cd1, AW_CL cd2); |
---|
157 | void set_double_click_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL), AW_CL cd1, AW_CL cd2); |
---|
158 | void set_motion_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL), AW_CL cd1, AW_CL cd2); |
---|
159 | |
---|
160 | bool is_expose_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL)); |
---|
161 | bool is_resize_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL)); |
---|
162 | bool is_input_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL)); |
---|
163 | bool is_double_click_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL)); |
---|
164 | bool is_motion_callback(AW_window *aww, void (*f)(AW_window*, AW_CL, AW_CL)); |
---|
165 | |
---|
166 | void run_expose_callback(); |
---|
167 | void run_resize_callback(); |
---|
168 | |
---|
169 | AW_cb_struct *get_double_click_cb() { return double_click_cb; } |
---|
170 | long get_click_time() const { return click_time; } |
---|
171 | void set_click_time(long click_time_) { click_time = click_time_; } |
---|
172 | }; |
---|
173 | |
---|
174 | class AW_selection_list; |
---|
175 | |
---|
176 | class AW_root_Motif : virtual Noncopyable { |
---|
177 | Widget last_widget; // last created (sensitive) widget |
---|
178 | public: |
---|
179 | Display *display; |
---|
180 | XtAppContext context; |
---|
181 | Widget toplevel_widget; |
---|
182 | Widget main_widget; |
---|
183 | class AW_window *main_aww; |
---|
184 | Widget message_shell; |
---|
185 | |
---|
186 | Pixel foreground; |
---|
187 | Pixel background; |
---|
188 | |
---|
189 | XmFontList fontlist; |
---|
190 | |
---|
191 | AW_option_menu_struct *option_menu_list; |
---|
192 | AW_option_menu_struct *last_option_menu; |
---|
193 | AW_option_menu_struct *current_option_menu; |
---|
194 | |
---|
195 | AW_toggle_field_struct *toggle_field_list; |
---|
196 | AW_toggle_field_struct *last_toggle_field; |
---|
197 | |
---|
198 | AW_selection_list *selection_list; |
---|
199 | AW_selection_list *last_selection_list; |
---|
200 | |
---|
201 | int screen_depth; |
---|
202 | AW_rgb *color_table; |
---|
203 | Colormap colormap; |
---|
204 | |
---|
205 | int help_active; |
---|
206 | Cursor clock_cursor; |
---|
207 | Cursor question_cursor; |
---|
208 | Display *old_cursor_display; |
---|
209 | Window old_cursor_window; |
---|
210 | bool no_exit; |
---|
211 | |
---|
212 | GB_HASH *action_hash; |
---|
213 | |
---|
214 | AW_root_Motif(); |
---|
215 | ~AW_root_Motif(); |
---|
216 | |
---|
217 | Widget get_last_widget() const { return last_widget; } |
---|
218 | void set_last_widget(Widget w) { last_widget = w; } |
---|
219 | |
---|
220 | void set_cursor(Display *d, Window w, Cursor c); |
---|
221 | void normal_cursor(); |
---|
222 | }; |
---|
223 | |
---|
224 | const int AW_NUMBER_OF_F_KEYS = 20; |
---|
225 | #define AW_CALC_OFFSET_ON_EXPOSE -12345 |
---|
226 | |
---|
227 | class AW_window_Motif : virtual Noncopyable { |
---|
228 | public: |
---|
229 | |
---|
230 | Widget shell; // for show, hide |
---|
231 | Widget scroll_bar_vertical; // for scrolling the |
---|
232 | Widget scroll_bar_horizontal; // draw area |
---|
233 | Widget menu_bar[AW_MAX_MENU_DEEP]; // for inserting topics to menu bar |
---|
234 | int menu_deep; |
---|
235 | Widget help_pull_down; // for inserting subtopics to the help pull_down |
---|
236 | Widget mode_area; // for inserting buttons to the mode area |
---|
237 | short number_of_modes; // holds number of mode buttons in window |
---|
238 | |
---|
239 | // ********** local modifiers ********** |
---|
240 | |
---|
241 | AW_cb_struct **modes_f_callbacks; |
---|
242 | Widget *modes_widgets; |
---|
243 | int selected_mode; |
---|
244 | AW_cb_struct *popup_cb; |
---|
245 | Widget frame; |
---|
246 | |
---|
247 | Widget toggle_field; |
---|
248 | Widget toggle_label; |
---|
249 | char *toggle_field_var_name; |
---|
250 | AW_VARIABLE_TYPE toggle_field_var_type; |
---|
251 | AW_key_mod keymodifier; |
---|
252 | |
---|
253 | AW_area_management *areas[AW_MAX_AREA]; |
---|
254 | |
---|
255 | int WM_top_offset; // correction between position set and position reported ( = size of window frame - in most cases!) |
---|
256 | int WM_left_offset; |
---|
257 | |
---|
258 | bool knows_WM_offset() const { return WM_top_offset != AW_CALC_OFFSET_ON_EXPOSE; } |
---|
259 | |
---|
260 | AW_window_Motif(); |
---|
261 | ~AW_window_Motif() {}; |
---|
262 | }; |
---|
263 | |
---|
264 | |
---|
265 | void aw_root_init_font(Display *tool_d); |
---|
266 | const char *aw_str_2_label(const char *str, AW_window *aww); |
---|
267 | void AW_label_in_awar_list(AW_window *aww, Widget widget, const char *str); |
---|
268 | void AW_server_callback(Widget wgt, XtPointer aw_cb_struct, XtPointer call_data); |
---|
269 | |
---|
270 | // ------------------------------------------------------------ |
---|
271 | // do not use the following functions |
---|
272 | void message_cb(AW_window *aw, AW_CL cd1); |
---|
273 | void input_cb(AW_window *aw, AW_CL cd1); |
---|
274 | void input_history_cb(AW_window *aw, AW_CL cl_mode); |
---|
275 | void file_selection_cb(AW_window *aw, AW_CL cd1); |
---|
276 | // ------------------------------------------------------------ |
---|
277 | |
---|
278 | Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy); |
---|
279 | void aw_realize_widget(AW_window *aww); |
---|
280 | void aw_insert_default_help_entries(AW_window *aww); |
---|
281 | |
---|
282 | #else |
---|
283 | #error aw_window_Xm.hxx included twice |
---|
284 | #endif |
---|
285 | |
---|
286 | |
---|