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