1 | #ifndef AW_WINDOW_HXX |
---|
2 | #define AW_WINDOW_HXX |
---|
3 | |
---|
4 | #ifndef AW_BASE_HXX |
---|
5 | #include "aw_base.hxx" |
---|
6 | #endif |
---|
7 | #ifndef ARBDB_BASE_H |
---|
8 | #include <arbdb_base.h> |
---|
9 | #endif |
---|
10 | #ifndef ARB_ASSERT_H |
---|
11 | #include <arb_assert.h> |
---|
12 | #endif |
---|
13 | #ifndef AW_KEYSYM_HXX |
---|
14 | #include "aw_keysym.hxx" |
---|
15 | #endif |
---|
16 | #ifndef ARBTOOLS_H |
---|
17 | #include <arbtools.h> |
---|
18 | #endif |
---|
19 | #ifndef CB_H |
---|
20 | #include <cb.h> |
---|
21 | #endif |
---|
22 | |
---|
23 | class AW_window; |
---|
24 | class AW_xfig; |
---|
25 | class AW_device; |
---|
26 | struct AW_screen_area; |
---|
27 | struct GB_HASH; |
---|
28 | class AW_device_click; |
---|
29 | class AW_device_print; |
---|
30 | class AW_device_size; |
---|
31 | class AW_common; |
---|
32 | |
---|
33 | // -------------------------------------------------------------------------------- |
---|
34 | |
---|
35 | #define AW_MESSAGE_TIME 2000 |
---|
36 | #define AW_HEADER_MAIN extern "C" { int XtAppInitialize(); } void aw_never_called_main() { XtAppInitialize(); } |
---|
37 | |
---|
38 | // ======= Used in Tune background function ================================= |
---|
39 | #define TUNE_BUTTON 8 |
---|
40 | #define TUNE_INPUT (-TUNE_BUTTON) |
---|
41 | #define TUNE_SUBMENU 0 |
---|
42 | #define TUNE_MENUTOPIC (-12) |
---|
43 | #define TUNE_BRIGHT (256+30) |
---|
44 | #define TUNE_DARK (-TUNE_BRIGHT) |
---|
45 | // ========================================================================== |
---|
46 | |
---|
47 | #ifndef AW_AT_HXX |
---|
48 | class AW_at; |
---|
49 | #endif |
---|
50 | |
---|
51 | enum AW_orientation { AW_HORIZONTAL, AW_VERTICAL }; |
---|
52 | |
---|
53 | typedef const char *AW_label; // label for buttons menus etc |
---|
54 | // "fsdf" simple label // no '/' symbol !!! |
---|
55 | // "awarname/asdf" // awar name (any '/' in string) |
---|
56 | // "#file.xpm" // pixmap in $ARBHOME/lib/pixmaps/file.xpm |
---|
57 | |
---|
58 | const char *AW_get_pixmapPath(const char *pixmapName); |
---|
59 | |
---|
60 | void AW_POPDOWN(AW_window *); |
---|
61 | |
---|
62 | enum AW_event_type { |
---|
63 | AW_Keyboard_Press = 1, |
---|
64 | AW_Keyboard_Release = 2, |
---|
65 | AW_Mouse_Press = 3, |
---|
66 | AW_Mouse_Release = 4, |
---|
67 | AW_Mouse_Drag = 5 |
---|
68 | }; |
---|
69 | |
---|
70 | enum AW_MouseButton { |
---|
71 | AW_BUTTON_NONE = 0, |
---|
72 | AW_BUTTON_LEFT = 1, |
---|
73 | AW_BUTTON_MIDDLE = 2, |
---|
74 | AW_BUTTON_RIGHT = 3, |
---|
75 | AW_WHEEL_UP = 4, |
---|
76 | AW_WHEEL_DOWN = 5, |
---|
77 | }; |
---|
78 | |
---|
79 | struct AW_event { |
---|
80 | // fields always valid |
---|
81 | AW_event_type type; // AW_Keyboard or AW_Mouse |
---|
82 | unsigned long time; // time in msec, when event occurred |
---|
83 | AW_key_mod keymodifier; // control, alt/meta (shift only for type == AW_Mouse) |
---|
84 | |
---|
85 | // fields valid for type == AW_Mouse |
---|
86 | AW_MouseButton button; |
---|
87 | int x, y; // pointer x,y coordinates in the event window |
---|
88 | |
---|
89 | // fields valid for type == AW_Keyboard |
---|
90 | AW_key_code keycode; // which key type was pressed |
---|
91 | char character; // the c character |
---|
92 | |
---|
93 | AW_event() |
---|
94 | : type(AW_event_type(0)), |
---|
95 | time(0), |
---|
96 | keymodifier(AW_KEYMODE_NONE), |
---|
97 | button(AW_BUTTON_NONE), |
---|
98 | x(0), |
---|
99 | y(0), |
---|
100 | keycode(AW_KEY_NONE), |
---|
101 | character(0) |
---|
102 | {} |
---|
103 | }; |
---|
104 | |
---|
105 | void AW_help_popup(UNFIXED, const char *help_file); |
---|
106 | inline WindowCallback makeHelpCallback(const char *helpfile) { return makeWindowCallback(AW_help_popup, helpfile); } |
---|
107 | |
---|
108 | void AW_help_entry_pressed(AW_window *); |
---|
109 | void AW_clock_cursor(AW_root *); |
---|
110 | void AW_normal_cursor(AW_root *); |
---|
111 | |
---|
112 | void AW_openURL(AW_root *aw_root, const char *url); |
---|
113 | |
---|
114 | typedef void (*AW_cb_struct_guard)(); |
---|
115 | typedef WindowCallbackSimple AnyWinCB; // used to check whether function is contained in callback-list (does not check parameters!) |
---|
116 | |
---|
117 | class AW_cb : virtual Noncopyable { |
---|
118 | WindowCallback cb; |
---|
119 | |
---|
120 | AW_cb *next; |
---|
121 | |
---|
122 | static AW_cb_struct_guard guard_before; |
---|
123 | static AW_cb_struct_guard guard_after; |
---|
124 | static AW_postcb_cb postcb; // called after each cb triggered via interface |
---|
125 | |
---|
126 | public: |
---|
127 | // private (read-only): |
---|
128 | AW_window *aw; |
---|
129 | const char *help_text; |
---|
130 | char *id; |
---|
131 | |
---|
132 | // real public section: |
---|
133 | AW_cb(AW_window *awi, |
---|
134 | const WindowCallback& wcb, |
---|
135 | const char *help_texti = NULp, |
---|
136 | AW_cb *next = NULp); |
---|
137 | |
---|
138 | ~AW_cb() { |
---|
139 | delete next; next = NULp; |
---|
140 | free(id); |
---|
141 | } |
---|
142 | |
---|
143 | void run_callbacks(); // runs the whole list |
---|
144 | bool contains(AnyWinCB g); // test if contained in list |
---|
145 | bool is_equal(const AW_cb& other) const; |
---|
146 | |
---|
147 | int compare(const AW_cb& other) const { return cb<other.cb ? -1 : (other.cb<cb ? 1 : 0); } |
---|
148 | |
---|
149 | #if defined(ASSERTION_USED) |
---|
150 | AW_CL get_cd1() const { return cb.inspect_CD1(); } |
---|
151 | AW_CL get_cd2() const { return cb.inspect_CD2(); } |
---|
152 | #endif // DEBUG |
---|
153 | |
---|
154 | static void set_AW_cb_guards(AW_cb_struct_guard before, AW_cb_struct_guard after) { |
---|
155 | guard_before = before; |
---|
156 | guard_after = after; |
---|
157 | } |
---|
158 | static void set_AW_postcb_cb(AW_postcb_cb postcb_cb) { |
---|
159 | postcb = postcb_cb; |
---|
160 | } |
---|
161 | |
---|
162 | static void useraction_init() { |
---|
163 | if (guard_before) guard_before(); |
---|
164 | } |
---|
165 | static void useraction_done(AW_window *aw) { |
---|
166 | if (guard_after) guard_after(); |
---|
167 | if (postcb) postcb(aw); |
---|
168 | } |
---|
169 | }; |
---|
170 | |
---|
171 | |
---|
172 | enum { |
---|
173 | AWM_DISABLED = 0, // disabled items (used for dynamically dis-/enabled items) |
---|
174 | AWM_BASIC = 1, |
---|
175 | AWM_EXP = 2, |
---|
176 | AWM_ALL = AWM_BASIC|AWM_EXP |
---|
177 | }; |
---|
178 | |
---|
179 | enum { |
---|
180 | AWM_MASK_UNKNOWN = AWM_DISABLED, |
---|
181 | AWM_MASK_DEFAULT = AWM_BASIC, |
---|
182 | AWM_MASK_EXPERT = AWM_ALL |
---|
183 | }; |
---|
184 | |
---|
185 | typedef char *AW_pixmap; |
---|
186 | |
---|
187 | class AW_window_Motif; |
---|
188 | class AW_selection_list_entry; |
---|
189 | class AW_selection_list; |
---|
190 | struct AW_option_menu_struct; |
---|
191 | struct aw_toggle_data; |
---|
192 | |
---|
193 | enum AW_at_storage_type { |
---|
194 | AW_AT_SIZE_AND_ATTACH, |
---|
195 | AW_AT_AUTO, |
---|
196 | AW_AT_MAXSIZE, |
---|
197 | }; |
---|
198 | struct AW_at_storage { |
---|
199 | //! store/restore some properties from/to AW_at |
---|
200 | virtual ~AW_at_storage() {} |
---|
201 | |
---|
202 | // will be called via AW_window |
---|
203 | virtual void store(const AW_at& at) = 0; |
---|
204 | virtual void restore(AW_at& at) const = 0; |
---|
205 | |
---|
206 | static AW_at_storage *make(AW_window *aww, AW_at_storage_type type); // factory |
---|
207 | }; |
---|
208 | |
---|
209 | enum AW_SizeRecalc { |
---|
210 | AW_KEEP_SIZE = 0, // do not resize |
---|
211 | AW_RESIZE_DEFAULT = 1, // do resize to default size |
---|
212 | AW_RESIZE_USER = 2, // do resize to user size (or default size if that is bigger) |
---|
213 | AW_RESIZE_ANY = 3 // keep AW_RESIZE_USER or set AW_RESIZE_DEFAULT |
---|
214 | }; |
---|
215 | |
---|
216 | enum AW_PosRecalc { |
---|
217 | AW_KEEP_POS = 0, // do not change position on show |
---|
218 | AW_REPOS_TO_CENTER = 1, // center the window on show (unused atm) |
---|
219 | AW_REPOS_TO_MOUSE = 2, // move the window under the current mouse position |
---|
220 | AW_REPOS_TO_MOUSE_ONCE = 3, // like AW_REPOS_TO_MOUSE, but only done once! |
---|
221 | }; |
---|
222 | |
---|
223 | enum AW_ScalerType { |
---|
224 | AW_SCALER_LINEAR, |
---|
225 | AW_SCALER_EXP_LOWER, // fine-tuned at lower border, big steps at upper border |
---|
226 | AW_SCALER_EXP_UPPER, // fine-tuned at upper border, big steps at lower border |
---|
227 | AW_SCALER_EXP_CENTER, // fine-tuned at center, big steps at borders |
---|
228 | AW_SCALER_EXP_BORDER, // fine-tuned at borders, big steps at center |
---|
229 | }; |
---|
230 | |
---|
231 | class AW_ScalerTransformer { |
---|
232 | AW_ScalerType type; |
---|
233 | public: |
---|
234 | AW_ScalerTransformer(AW_ScalerType type_) : type(type_) {} |
---|
235 | |
---|
236 | float scaler2awar(float scaler, AW_awar *awar); // [0..1] -> awar-range |
---|
237 | float awar2scaler(AW_awar *awar); // returns [0..1] |
---|
238 | }; |
---|
239 | |
---|
240 | class AW_window : virtual Noncopyable { |
---|
241 | AW_SizeRecalc recalc_size_at_show; |
---|
242 | AW_PosRecalc recalc_pos_at_show; |
---|
243 | |
---|
244 | WindowCallback *hide_cb; |
---|
245 | bool expose_callback_added; |
---|
246 | |
---|
247 | AW_cb *focus_cb; |
---|
248 | |
---|
249 | AW_xfig *xfig_data; |
---|
250 | AW_at *_at; /** < Defines the next position at which something will be inserted into the window. */ |
---|
251 | |
---|
252 | int left_indent_of_horizontal_scrollbar; |
---|
253 | int top_indent_of_vertical_scrollbar; |
---|
254 | |
---|
255 | void all_menus_created() const; |
---|
256 | void create_toggle(const char *var_name, aw_toggle_data *tdata); |
---|
257 | |
---|
258 | int calculate_string_width(int columns) const; |
---|
259 | int calculate_string_height(int columns, int offset) const; |
---|
260 | char *align_string(const char *label_text, int columns); |
---|
261 | void calculate_label_size(int *width, int *height, bool in_pixel, const char *non_at_label); |
---|
262 | |
---|
263 | protected: |
---|
264 | AW_root *root; |
---|
265 | |
---|
266 | void create_devices(); |
---|
267 | void set_background(const char *colorname, Widget w); |
---|
268 | |
---|
269 | void wm_activate(); // un-minimize window and give it the focus (use show_and_activate()) |
---|
270 | |
---|
271 | public: |
---|
272 | |
---|
273 | // ---------------------------------------- [start read-only section] @@@ should go private |
---|
274 | |
---|
275 | AW_event event; |
---|
276 | unsigned long click_time; |
---|
277 | long color_table_size; |
---|
278 | AW_rgb *color_table; |
---|
279 | int number_of_timed_title_changes; |
---|
280 | AW_window_Motif *p_w; |
---|
281 | AW_cb *_callback; |
---|
282 | AW_cb *_d_callback; |
---|
283 | |
---|
284 | // ---------------------------------------- [end read-only section] |
---|
285 | |
---|
286 | #if defined(IN_ARB_WINDOW) |
---|
287 | // only used internal and in motif (alternative would be to move a bunch of code into AW_window) |
---|
288 | const AW_at& get_at() const { return *_at; } |
---|
289 | AW_at& get_at() { return *_at; } |
---|
290 | #endif |
---|
291 | |
---|
292 | AW_window(); |
---|
293 | virtual ~AW_window(); |
---|
294 | |
---|
295 | const char *window_local_awarname(const char *localname, bool tmp = true); |
---|
296 | class AW_awar *window_local_awar(const char *localname, bool tmp = true); |
---|
297 | void create_window_variables(); |
---|
298 | |
---|
299 | void recalc_pos_atShow(AW_PosRecalc pr); |
---|
300 | void recalc_size_atShow(enum AW_SizeRecalc sr); |
---|
301 | AW_PosRecalc get_recalc_pos_atShow() const; |
---|
302 | |
---|
303 | void allow_delete_window(bool allow_close); |
---|
304 | void on_hide(const WindowCallback& call_on_hide); |
---|
305 | void on_hide(WindowCallbackSimple call_on_hide) { on_hide(makeWindowCallback(call_on_hide)); } |
---|
306 | |
---|
307 | |
---|
308 | void run_focus_callback(); |
---|
309 | void run_popup_callbacks(); |
---|
310 | void show_modal(); |
---|
311 | void set_window_title_intern(char *title); |
---|
312 | |
---|
313 | void update_label(Widget widget, const char *var_value); |
---|
314 | void update_toggle(Widget widget, const char *var_value, AW_CL cd); |
---|
315 | void update_input_field(Widget widget, const char *var_value); |
---|
316 | void update_text_field(Widget widget, const char *var_value); |
---|
317 | void update_scaler(Widget widget, AW_awar *awar, AW_ScalerType scalerType); |
---|
318 | |
---|
319 | void create_invisible(int columns); |
---|
320 | void *_create_option_entry(AW_VARIABLE_TYPE type, const char *name, const char *mnemonic, const char *name_of_color); |
---|
321 | void refresh_toggle_field(int toggle_field_number); |
---|
322 | void _set_activate_callback(void *widget); |
---|
323 | void increment_at_commands(int width, int height); |
---|
324 | |
---|
325 | |
---|
326 | AW_color_idx alloc_named_data_color(int colnum, const char *colorname); |
---|
327 | |
---|
328 | // special for EDIT4 |
---|
329 | void _get_area_size(AW_area area, AW_screen_area *square); |
---|
330 | |
---|
331 | int label_widget(void *wgt, AW_label str, char *mnemonic = NULp, int width = 0, int alignment = 0); |
---|
332 | |
---|
333 | // ------------------------------ |
---|
334 | // The read only section |
---|
335 | |
---|
336 | char *window_name; //! window title |
---|
337 | char *window_defaults_name; //! window id |
---|
338 | |
---|
339 | int slider_pos_vertical; //! current position of the vertical slider |
---|
340 | int slider_pos_horizontal; //! current position of the horizontal slider |
---|
341 | |
---|
342 | bool window_is_shown; |
---|
343 | |
---|
344 | AW_screen_area *picture; // the result of tell scrolled picture size |
---|
345 | |
---|
346 | // -------------------------------- |
---|
347 | // The real public section |
---|
348 | |
---|
349 | AW_root *get_root() { return root; } |
---|
350 | // ******************* Global layout functions ********************** |
---|
351 | |
---|
352 | void show(); // show newly created window or unhide hidden window (aka closed window) |
---|
353 | void hide(); // hide (don't destroy) a window (<->show) |
---|
354 | |
---|
355 | void activate() { show(); wm_activate(); } // make_visible, pop window to front and give it the focus |
---|
356 | |
---|
357 | bool is_shown() const; // is window visible (== true) or hidden (== false). ? |
---|
358 | |
---|
359 | void hide_or_notify(const char *error); |
---|
360 | |
---|
361 | void message(char *title, int ms); // Set for ms milliseconds the title of the window |
---|
362 | void set_window_title(const char *title); // Set the window title forever |
---|
363 | |
---|
364 | const char *get_window_title() const; // Get the window's title |
---|
365 | const char *get_window_id() const { return window_defaults_name; } // Get the window's internal name |
---|
366 | |
---|
367 | const char *local_id(const char *id) const; |
---|
368 | |
---|
369 | void set_info_area_height(int height); |
---|
370 | void set_bottom_area_height(int height); |
---|
371 | |
---|
372 | // ******************* Input and Motion Events ********************** |
---|
373 | |
---|
374 | void set_popup_callback(const WindowCallback& wcb); |
---|
375 | void set_focus_callback(const WindowCallback& wcb); |
---|
376 | bool is_focus_callback(AnyWinCB f); |
---|
377 | |
---|
378 | void set_expose_callback(AW_area area, const WindowCallback& wcb); |
---|
379 | void set_resize_callback(AW_area area, const WindowCallback& wcb); |
---|
380 | |
---|
381 | private: |
---|
382 | // motif relicts: |
---|
383 | void set_expose_callback(AW_area area, WindowCallbackSimple cb) { set_expose_callback(area, makeWindowCallback(cb)); } |
---|
384 | void set_resize_callback(AW_area area, WindowCallbackSimple cb) { set_resize_callback(area, makeWindowCallback(cb)); } |
---|
385 | public: |
---|
386 | |
---|
387 | void set_input_callback(AW_area area, const WindowCallback& wcb); |
---|
388 | void set_motion_callback(AW_area area, const WindowCallback& wcb); |
---|
389 | |
---|
390 | void set_double_click_callback(AW_area area, const WindowCallback& wcb); |
---|
391 | |
---|
392 | bool is_expose_callback(AW_area area, AnyWinCB f); |
---|
393 | bool is_resize_callback(AW_area area, AnyWinCB f); |
---|
394 | |
---|
395 | void get_event(AW_event *eventi) const; // In an event callback get the events info |
---|
396 | |
---|
397 | void force_expose(); // forces the window to expose instantly |
---|
398 | |
---|
399 | // ******************* Get the devices ********************** |
---|
400 | AW_device *get_device(AW_area area); |
---|
401 | AW_device_click *get_click_device(AW_area area, int mousex, int mousey, int max_distance); |
---|
402 | AW_device_size *get_size_device(AW_area area); |
---|
403 | AW_device_print *get_print_device(AW_area area); |
---|
404 | |
---|
405 | AW_common *get_common(AW_area area); |
---|
406 | |
---|
407 | // ************** Create the menu buttons ********* |
---|
408 | |
---|
409 | /** |
---|
410 | * Creates a new top level menu. |
---|
411 | * @param name Name of the menu. |
---|
412 | * @param mnemonic Shortcut (optional) |
---|
413 | * @param mask Experts only? |
---|
414 | */ |
---|
415 | void create_menu(const char *name, const char *mnemonic, AW_active mask = AWM_ALL); |
---|
416 | |
---|
417 | /** |
---|
418 | * Insert a sub menu into the last created menu. |
---|
419 | * @param name Name of the sub menu. |
---|
420 | * @param mnemonic Shortcut (optional) |
---|
421 | * @param mask Experts only? |
---|
422 | */ |
---|
423 | void insert_sub_menu(const char *name, const char *mnemonic, AW_active mask = AWM_ALL); |
---|
424 | |
---|
425 | /** |
---|
426 | * Insert a menu item into the last created menu or sub menu. |
---|
427 | * @param id Unique id (for macros) |
---|
428 | * @param name Name of the item. |
---|
429 | * @param mnemonic Shortcut (optional) |
---|
430 | * @param help_text_ Name of helpfile (optional) |
---|
431 | * @param mask Experts only? |
---|
432 | * @param wcb Callback that should be called when the item is activated. |
---|
433 | */ |
---|
434 | void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback& wcb); |
---|
435 | |
---|
436 | void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const CreateWindowCallback& cwcb) { insert_menu_topic(id, name, mnemonic, help_text_, mask, makeWindowPopper(cwcb)); } |
---|
437 | void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, WindowCallbackSimple cb) { insert_menu_topic(id, name, mnemonic, help_text_, mask, makeWindowCallback(cb)); } |
---|
438 | void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, CreateWindowCallbackSimple cb) { insert_menu_topic(id, name, mnemonic, help_text_, mask, makeCreateWindowCallback(cb)); } |
---|
439 | |
---|
440 | void sep______________(); |
---|
441 | void close_sub_menu(); |
---|
442 | |
---|
443 | void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, const WindowCallback& cb); |
---|
444 | void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, WindowCallbackSimple cb) { insert_help_topic(labeli, mnemonic, helpText, mask, makeWindowCallback(cb)); } |
---|
445 | |
---|
446 | // ************** Create modes on the left side ****************** |
---|
447 | int create_mode(const char *pixmap, const char *help_text_, AW_active mask, const WindowCallback& cb); |
---|
448 | void select_mode(int mode); |
---|
449 | |
---|
450 | // ************** Control the size of the main drawing area + scrollbars ********* |
---|
451 | void tell_scrolled_picture_size(AW_screen_area rectangle); |
---|
452 | void tell_scrolled_picture_size(AW_world rectangle); |
---|
453 | AW_pos get_scrolled_picture_width() const; |
---|
454 | AW_pos get_scrolled_picture_height() const; |
---|
455 | void reset_scrolled_picture_size(); |
---|
456 | |
---|
457 | void get_scrollarea_size(AW_screen_area *square); |
---|
458 | |
---|
459 | void calculate_scrollbars(); |
---|
460 | void set_vertical_scrollbar_position(int position); |
---|
461 | void set_horizontal_scrollbar_position(int position); |
---|
462 | |
---|
463 | void set_vertical_change_callback(const WindowCallback& wcb); |
---|
464 | void set_horizontal_change_callback(const WindowCallback& wcb); |
---|
465 | void set_vertical_scrollbar_top_indent(int indent); |
---|
466 | void set_horizontal_scrollbar_left_indent(int indent); |
---|
467 | |
---|
468 | |
---|
469 | void update_scrollbar_settings_from_awars(AW_orientation orientation); |
---|
470 | |
---|
471 | void create_user_geometry_awars(int posx, int posy, int width, int height); |
---|
472 | |
---|
473 | // ************** Control window size ********* |
---|
474 | #if defined(IN_ARB_WINDOW) |
---|
475 | void set_window_size(int width, int height); |
---|
476 | #endif |
---|
477 | void get_window_size(int& width, int& height); |
---|
478 | void window_fit(); // Recalculate the size of a window with buttons |
---|
479 | |
---|
480 | #if defined(IN_ARB_WINDOW) |
---|
481 | void store_size_in_awars(int width, int height); |
---|
482 | void get_size_from_awars(int& width, int& height); |
---|
483 | |
---|
484 | // ************** Control window position ********* |
---|
485 | void set_window_frame_pos(int xpos, int ypos); |
---|
486 | void get_window_content_pos(int& xpos, int& ypos); |
---|
487 | |
---|
488 | void store_pos_in_awars(int xpos, int ypos); |
---|
489 | void get_pos_from_awars(int& xpos, int& ypos); |
---|
490 | |
---|
491 | void reset_geometry_awars(); |
---|
492 | |
---|
493 | // ***************** |
---|
494 | void get_screen_size(int& width, int& height); |
---|
495 | bool get_mouse_pos(int& x, int& y); |
---|
496 | void set_focus_policy(bool follow_mouse); |
---|
497 | void get_font_size(int& w, int& h); |
---|
498 | #endif |
---|
499 | |
---|
500 | // ************** ******************************************************************** ********* |
---|
501 | // ************** Create buttons: First set modify flags and finally create the button ********* |
---|
502 | // ************** ******************************************************************** ********* |
---|
503 | |
---|
504 | // *** global modifier: **** |
---|
505 | void load_xfig(const char *file, bool resize=true); // Loads the background graphic |
---|
506 | void draw_line(int x1, int y1, int x2, int y2, int width, bool resize); // draws a line on the background |
---|
507 | |
---|
508 | void label_length(int length); // Justifies all following labels |
---|
509 | void button_length(int length); // Sets the width of all following buttons (in chars) |
---|
510 | void button_height(int height); // Sets the height of all following buttons (in lines) |
---|
511 | int get_button_length() const; // returns the current width of buttons |
---|
512 | void highlight(); // Creates a frame around the button |
---|
513 | void auto_increment(int dx, int dy); // enable automatic placement of buttons |
---|
514 | // dx is the horizontal distance between the left |
---|
515 | // borders of two buttons |
---|
516 | void auto_space(int xspace, int yspace); // enable automatic placement of buttons |
---|
517 | // xspace is the horizontal space between 2 buttons |
---|
518 | |
---|
519 | void shadow_width (int shadow_thickness); // set the shadow_thickness of buttons |
---|
520 | |
---|
521 | void TuneBackground(Widget w, int modStrength); |
---|
522 | void TuneOrSetBackground(Widget w, const char *color, int modStrength); |
---|
523 | |
---|
524 | // *** local modifiers: ******** |
---|
525 | void at(int x, int y); // abs pos of a button (>10,10) |
---|
526 | void at_x(int x); // abs x pos |
---|
527 | void at_y(int y); // abs y pos |
---|
528 | void at_shift(int x, int y); // rel pos of a button |
---|
529 | void at_newline(); // in auto_space mode only: newline |
---|
530 | |
---|
531 | void at(const char *id); /* place the button at the position set in the .fig |
---|
532 | * file (loaded with load_xfig) by the string $id */ |
---|
533 | bool at_ifdef(const char *id); // check whether 'id' is an element if the .fig file |
---|
534 | |
---|
535 | void label(const char *label); // Create a label before the button |
---|
536 | |
---|
537 | void get_at_position(int *x, int *y) const; |
---|
538 | int get_at_xposition() const; |
---|
539 | int get_at_yposition() const; |
---|
540 | |
---|
541 | void dump_at_position(const char *debug_label) const; // for debugging (uses printf) |
---|
542 | |
---|
543 | void at_attach(int x, int y); // set "XY:noid" manually (use negative rel. position to attach) |
---|
544 | void at_attach_to(bool attach_x, bool attach_y, int xoff, int yoff); // set "to:XY:noid" manually |
---|
545 | void at_unattach(); // unset effects of at_attach() and/or at_attach_to() |
---|
546 | |
---|
547 | void unset_at_commands(); |
---|
548 | |
---|
549 | void store_at_to(AW_at_storage& storage) { storage.store(*_at); } |
---|
550 | void restore_at_from(const AW_at_storage& stored) { stored.restore(*_at); } |
---|
551 | |
---|
552 | void sens_mask(AW_active mask); // Set the sensitivity mask used for following widgets (Note: reset by next at()-command) |
---|
553 | void help_text(const char *id); // Set the help text of a button |
---|
554 | |
---|
555 | private: |
---|
556 | static void popper(AW_window *, CreateWindowCallback *windowMaker); |
---|
557 | static void replacer(AW_window *aww, CreateWindowCallback *windowMaker); |
---|
558 | static void destroyCreateWindowCallback(CreateWindowCallback *windowMaker); |
---|
559 | public: |
---|
560 | static WindowCallback makeWindowPopper(const CreateWindowCallback& cwcb) { |
---|
561 | return makeWindowCallback(popper, destroyCreateWindowCallback, new CreateWindowCallback(cwcb)); |
---|
562 | } |
---|
563 | static WindowCallback makeWindowReplacer(const CreateWindowCallback& cwcb) { |
---|
564 | return makeWindowCallback(replacer, destroyCreateWindowCallback, new CreateWindowCallback(cwcb)); |
---|
565 | } |
---|
566 | |
---|
567 | // normal callbacks |
---|
568 | void callback(const WindowCallback& cb); |
---|
569 | |
---|
570 | void callback(const CreateWindowCallback& cwcb) { callback(makeWindowPopper(cwcb)); } |
---|
571 | void callback(CreateWindowCallbackSimple cb) { callback(makeCreateWindowCallback(cb)); } |
---|
572 | void callback(WindowCallbackSimple cb) { callback(makeWindowCallback(cb)); } |
---|
573 | |
---|
574 | void d_callback(const WindowCallback& cb); // secondary callback (called for 'double click into selection list' and 'text field hit ENTER') |
---|
575 | |
---|
576 | // *** create the buttons ******** |
---|
577 | void create_button(const char *macro_name, AW_label label, const char *mnemonic = NULp, const char *color = NULp); // simple button; shadow only when callback |
---|
578 | void create_autosize_button(const char *macro_name, AW_label label, const char *mnemonic = NULp, unsigned xtraSpace = 1); // as above, but ignores button_length |
---|
579 | Widget get_last_widget() const; |
---|
580 | |
---|
581 | void create_toggle(const char *awar_name); // int 0/1 string yes/no float undef |
---|
582 | void create_inverse_toggle(const char *awar_name); // like create_toggle, but displays inverted toggle value |
---|
583 | |
---|
584 | void create_toggle(const char *awar_name, const char *nobitmap, const char *yesbitmap, int buttonWidth = 0); |
---|
585 | void create_text_toggle(const char *var_name, const char *noText, const char *yesText, int buttonWidth = 0); |
---|
586 | |
---|
587 | void create_input_field(const char *awar_name, int columns = 0); // One line textfield |
---|
588 | void create_text_field(const char *awar_name, int columns = 20, int rows = 4); // Multi line textfield with scrollbars |
---|
589 | void create_input_field_with_scaler(const char *awar_name, int textcolumns = 4, int scaler_length = 250, AW_ScalerType scalerType = AW_SCALER_LINEAR); |
---|
590 | |
---|
591 | |
---|
592 | // ***** option_menu is a menu where only one selection is visible at a time |
---|
593 | AW_option_menu_struct *create_option_menu(const char *awar_name, bool fallback2default); |
---|
594 | void clear_option_menu(AW_option_menu_struct *oms); // used to redefine available options |
---|
595 | |
---|
596 | private: |
---|
597 | void insert_option_internal(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color, bool default_option); |
---|
598 | void insert_option_internal(AW_label choice_label, const char *mnemonic, int var_value, const char *name_of_color, bool default_option); |
---|
599 | void insert_option_internal(AW_label choice_label, const char *mnemonic, float var_value, const char *name_of_color, bool default_option); |
---|
600 | |
---|
601 | void insert_toggle_internal(AW_label toggle_label, const char *mnemonic, const char *var_value, bool default_toggle); |
---|
602 | void insert_toggle_internal(AW_label toggle_label, const char *mnemonic, int var_value, bool default_toggle); |
---|
603 | void insert_toggle_internal(AW_label toggle_label, const char *mnemonic, float var_value, bool default_toggle); |
---|
604 | public: |
---|
605 | |
---|
606 | // for string |
---|
607 | void insert_option (AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color = NULp); // for string |
---|
608 | void insert_default_option (AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color = NULp); |
---|
609 | // for int |
---|
610 | void insert_option (AW_label choice_label, const char *mnemonic, int var_value, const char *name_of_color = NULp); // for int |
---|
611 | void insert_default_option (AW_label choice_label, const char *mnemonic, int var_value, const char *name_of_color = NULp); |
---|
612 | // for float |
---|
613 | void insert_option (AW_label choice_label, const char *mnemonic, float var_value, const char *name_of_color = NULp); // for float |
---|
614 | void insert_default_option (AW_label choice_label, const char *mnemonic, float var_value, const char *name_of_color = NULp); |
---|
615 | |
---|
616 | void update_option_menu(); |
---|
617 | void refresh_option_menu(AW_option_menu_struct *); // don't use this |
---|
618 | |
---|
619 | |
---|
620 | // ***** toggle_field is a static menu (all items are visible and only one is selected) |
---|
621 | void create_toggle_field(const char *awar_name, AW_label label, const char *mnemonic); |
---|
622 | void create_toggle_field(const char *awar_name, int orientation = 0); // 1 = horizontal |
---|
623 | // for string |
---|
624 | void insert_toggle(AW_label toggle_label, const char *mnemonic, const char *var_value); |
---|
625 | void insert_default_toggle(AW_label toggle_label, const char *mnemonic, const char *var_value); |
---|
626 | // for int |
---|
627 | void insert_toggle(AW_label toggle_label, const char *mnemonic, int var_value); |
---|
628 | void insert_default_toggle(AW_label toggle_label, const char *mnemonic, int var_value); |
---|
629 | // for float |
---|
630 | void insert_toggle(AW_label toggle_label, const char *mnemonic, float var_value); |
---|
631 | void insert_default_toggle(AW_label toggle_label, const char *mnemonic, float var_value); |
---|
632 | void update_toggle_field(); |
---|
633 | |
---|
634 | // ***** selection list is a redefinable scrolled list of items |
---|
635 | |
---|
636 | AW_selection_list *create_selection_list(const char *awar_name, int columns, int rows, bool fallback2default); |
---|
637 | AW_selection_list *create_selection_list(const char *awar_name, bool fallback2default) { return create_selection_list(awar_name, 4, 4, fallback2default); } |
---|
638 | }; |
---|
639 | |
---|
640 | |
---|
641 | class AW_window_menu_modes : public AW_window { // derived from a Noncopyable |
---|
642 | void *AW_window_menu_modes_private; // Do not use !!! |
---|
643 | |
---|
644 | public: |
---|
645 | AW_window_menu_modes(); |
---|
646 | ~AW_window_menu_modes(); |
---|
647 | void init(AW_root *root, const char *wid, const char *windowname, int width, int height); |
---|
648 | PREPARE_MARK_NONFINAL_CLASS(AW_window_menu_modes); |
---|
649 | }; |
---|
650 | MARK_NONFINAL_CLASS(AW_window_menu_modes); |
---|
651 | |
---|
652 | class AW_window_menu : public AW_window { |
---|
653 | private: |
---|
654 | public: |
---|
655 | AW_window_menu(); |
---|
656 | ~AW_window_menu(); |
---|
657 | void init(AW_root *root, const char *wid, const char *windowname, int width, int height); |
---|
658 | }; |
---|
659 | |
---|
660 | class AW_window_simple_menu : public AW_window { |
---|
661 | private: |
---|
662 | public: |
---|
663 | AW_window_simple_menu(); |
---|
664 | ~AW_window_simple_menu(); |
---|
665 | void init(AW_root *root, const char *wid, const char *windowname); |
---|
666 | }; |
---|
667 | |
---|
668 | |
---|
669 | class AW_window_simple FINAL_TYPE : public AW_window { |
---|
670 | private: |
---|
671 | public: |
---|
672 | AW_window_simple(); |
---|
673 | ~AW_window_simple(); |
---|
674 | void init(AW_root *root, const char *wid, const char *windowname); |
---|
675 | }; |
---|
676 | |
---|
677 | |
---|
678 | class AW_window_message : public AW_window { |
---|
679 | private: |
---|
680 | public: |
---|
681 | AW_window_message(); |
---|
682 | ~AW_window_message(); |
---|
683 | void init(AW_root *root_in, const char *wid, const char *windowname, bool allow_close); |
---|
684 | void init(AW_root *root_in, const char *windowname, bool allow_close); // auto-generates window id from title |
---|
685 | }; |
---|
686 | |
---|
687 | class AW_gc_manager; |
---|
688 | |
---|
689 | #else |
---|
690 | #error aw_window.hxx included twice |
---|
691 | #endif |
---|