1
2 /******************************************************************************
3 * MODULE : message.hpp
4 * DESCRIPTION: Messages to and between widgets
5 * COPYRIGHT : (C) 2007 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12 #ifndef MESSAGE_H
13 #define MESSAGE_H
14 #include "renderer.hpp"
15 #include "widget.hpp"
16 #include "ntuple.hpp"
17 #include "rectangles.hpp"
18
19 /******************************************************************************
20 * C++ stupidity does not allow forward declaration of enums.
21 * Slots should really be defined in message.hpp
22 ******************************************************************************/
23
24 enum slot_id {
25 SLOT_IDENTIFIER,
26 SLOT_WINDOW,
27 SLOT_VISIBILITY,
28 SLOT_FULL_SCREEN,
29 SLOT_NAME,
30 SLOT_MODIFIED,
31 SLOT_SIZE,
32 SLOT_POSITION,
33 SLOT_UPDATE,
34 SLOT_REFRESH,
35 SLOT_KEYBOARD,
36 SLOT_KEYBOARD_FOCUS,
37 SLOT_KEYBOARD_FOCUS_ON,
38 SLOT_MOUSE,
39 SLOT_MOUSE_GRAB,
40 SLOT_MOUSE_POINTER,
41 SLOT_INVALIDATE,
42 SLOT_INVALIDATE_ALL,
43 SLOT_INVALID,
44 SLOT_REPAINT,
45 SLOT_DELAYED_MESSAGE,
46 SLOT_DESTROY,
47
48 SLOT_ZOOM_FACTOR,
49 SLOT_EXTENTS,
50 SLOT_VISIBLE_PART,
51 SLOT_SCROLLBARS_VISIBILITY,
52 SLOT_SCROLL_POSITION,
53 SLOT_CANVAS,
54 SLOT_SCROLLABLE,
55 SLOT_CURSOR,
56
57 SLOT_HEADER_VISIBILITY,
58 SLOT_MAIN_MENU,
59 SLOT_MAIN_ICONS_VISIBILITY,
60 SLOT_MAIN_ICONS,
61 SLOT_MODE_ICONS_VISIBILITY,
62 SLOT_MODE_ICONS,
63 SLOT_FOCUS_ICONS_VISIBILITY,
64 SLOT_FOCUS_ICONS,
65 SLOT_USER_ICONS_VISIBILITY,
66 SLOT_USER_ICONS,
67 SLOT_SIDE_TOOLS_VISIBILITY,
68 SLOT_SIDE_TOOLS,
69 SLOT_BOTTOM_TOOLS_VISIBILITY,
70 SLOT_BOTTOM_TOOLS,
71 SLOT_FOOTER_VISIBILITY,
72 SLOT_LEFT_FOOTER,
73 SLOT_RIGHT_FOOTER,
74 SLOT_INTERACTIVE_MODE,
75 SLOT_INTERACTIVE_PROMPT,
76 SLOT_INTERACTIVE_INPUT,
77
78 SLOT_FORM_FIELD,
79 SLOT_STRING_INPUT,
80 SLOT_INPUT_TYPE,
81 SLOT_INPUT_PROPOSAL,
82 SLOT_FILE,
83 SLOT_DIRECTORY,
84
85 slot_id__LAST // Please leave last and don't assign integer values to members
86 };
87
88 class slot {
89 public:
90 slot_id sid;
slot(slot_id sid2)91 inline slot (slot_id sid2): sid (sid2) {}
slot(const slot & s)92 inline slot (const slot& s): sid (s.sid) {}
operator =(slot s)93 inline slot& operator = (slot s) { sid= s.sid; return *this; }
operator slot_id()94 inline operator slot_id () { return sid; }
operator ==(slot_id sid2)95 inline bool operator == (slot_id sid2) { return sid == sid2; }
operator !=(slot_id sid2)96 inline bool operator != (slot_id sid2) { return sid != sid2; }
operator ==(slot s)97 inline bool operator == (slot s) { return sid == s.sid; }
operator !=(slot s)98 inline bool operator != (slot s) { return sid != s.sid; }
operator <<(tm_ostream & out,slot s)99 inline friend tm_ostream& operator << (tm_ostream& out, slot s) {
100 return out << s.sid; }
101 };
102
103 const char * slot_name (const slot s);
104
105 //extern bool* slot_state_table;
106 //inline bool is_state_slot (slot s) { return slots_state_table[s]; }
107
108 /******************************************************************************
109 * Helper templates for sending messages
110 ******************************************************************************/
111
112 inline void
send(widget w,slot s)113 send (widget w, slot s) {
114 w->send (s, blackbox ());
115 }
116
117 template<class T1> inline void
send(widget w,slot s,T1 val)118 send (widget w, slot s, T1 val) {
119 w->send (s, close_box (val));
120 }
121
122 template<class T1, class T2> void
send(widget w,slot s,T1 val1,T2 val2)123 send (widget w, slot s, T1 val1, T2 val2) {
124 typedef pair<T1,T2> T;
125 w->send (s, close_box<T> (T (val1, val2)));
126 }
127
128 template<class T1, class T2, class T3> void
send(widget w,slot s,T1 val1,T2 val2,T3 val3)129 send (widget w, slot s, T1 val1, T2 val2, T3 val3) {
130 typedef triple<T1,T2,T3> T;
131 w->send (s, close_box<T> (T (val1, val2, val3)));
132 }
133
134 template<class T1, class T2, class T3, class T4> void
send(widget w,slot s,T1 val1,T2 val2,T3 val3,T4 val4)135 send (widget w, slot s, T1 val1, T2 val2, T3 val3, T4 val4) {
136 typedef quartet<T1,T2,T3,T4> T;
137 w->send (s, close_box<T> (T (val1, val2, val3, val4)));
138 }
139
140 template<class T1, class T2, class T3, class T4, class T5> void
send(widget w,slot s,T1 val1,T2 val2,T3 val3,T4 val4,T5 val5)141 send (widget w, slot s, T1 val1, T2 val2, T3 val3, T4 val4, T5 val5) {
142 typedef quintuple<T1,T2,T3,T4,T5> T;
143 w->send (s, close_box<T> (T (val1, val2, val3, val4, val5)));
144 }
145
146 template<class T1> inline T1
query(widget w,slot s)147 query (widget w, slot s) {
148 return open_box<T1> (w->query (s, type_helper<T1>::id));
149 }
150
151 template<class T1, class T2> void
query(widget w,slot s,T1 & val1,T2 & val2)152 query (widget w, slot s, T1& val1, T2& val2) {
153 typedef pair<T1,T2> T;
154 T p= open_box<T> (w->query (s, type_helper<T>::id));
155 val1= p.x1; val2= p.x2;
156 }
157
158 template<class T1, class T2, class T3> void
query(widget w,slot s,T1 & val1,T2 & val2,T3 & val3)159 query (widget w, slot s, T1& val1, T2& val2, T3& val3) {
160 typedef triple<T1,T2,T3> T;
161 T t= open_box<T> (w->query (s, type_helper<T>::id));
162 val1= t.x1; val2= t.x2; val3= t.x3;
163 }
164
165 template<class T1, class T2, class T3, class T4> void
query(widget w,slot s,T1 & val1,T2 & val2,T3 & val3,T4 & val4)166 query (widget w, slot s, T1& val1, T2& val2, T3& val3, T4& val4) {
167 typedef quartet<T1,T2,T3,T4> T;
168 T q= open_box<T> (w->query (s, type_helper<T>::id));
169 val1= q.x1; val2= q.x2; val3= q.x3; val4= q.x4;
170 }
171
172 template<class T1, class T2, class T3, class T4, class T5> void
query(widget w,slot s,T1 & val1,T2 & val2,T3 & val3,T4 & val4,T5 & val5)173 query (widget w, slot s, T1& val1, T2& val2, T3& val3, T4& val4, T5& val5) {
174 typedef quintuple<T1,T2,T3,T4,T5> T;
175 T q= open_box<T> (w->query (s, type_helper<T>::id));
176 val1= q.x1; val2= q.x2; val3= q.x3; val4= q.x4; val5= q.x5;
177 }
178
179 inline void
notify(widget w,slot s)180 notify (widget w, slot s) {
181 w->notify (s, blackbox ());
182 }
183
184 template<class T1> inline void
notify(widget w,slot s,T1 val)185 notify (widget w, slot s, T1 val) {
186 w->notify (s, close_box (val));
187 }
188
189 template<class T1, class T2> void
notify(widget w,slot s,T1 val1,T2 val2)190 notify (widget w, slot s, T1 val1, T2 val2) {
191 typedef pair<T1,T2> T;
192 w->notify (s, close_box<T> (T (val1, val2)));
193 }
194
195 inline widget
read(widget w,slot s)196 read (widget w, slot s) {
197 return w->read (s, blackbox ());
198 }
199
200 template<class T1> inline widget
read(widget w,slot s,T1 i1)201 read (widget w, slot s, T1 i1) {
202 return w->read (s, close_box (i1));
203 }
204
205 inline void
write(widget w,slot s,widget val)206 write (widget w, slot s, widget val) {
207 w->write (s, blackbox (), val);
208 }
209
210 template<class T1> inline void
write(widget w,slot s,T1 i1,widget val)211 write (widget w, slot s, T1 i1, widget val) {
212 w->write (s, close_box (i1), val);
213 }
214
215 inline void
connect(widget w1,slot s1,widget w2,slot s2)216 connect (widget w1, slot s1, widget w2, slot s2) {
217 w1->connect (s1, w2, s2);
218 }
219
220 inline void
deconnect(widget w1,slot s1,widget w2,slot s2)221 deconnect (widget w1, slot s1, widget w2, slot s2) {
222 w1->deconnect (s1, w2, s2);
223 }
224
225 /******************************************************************************
226 * Standard messages
227 ******************************************************************************/
228
229 inline int
get_identifier(widget w)230 get_identifier (widget w) {
231 // get low-level handle for the widget's window, as used by the OS
232 // widgets which have not been attached to a window have a zero identifier
233 return query<int> (w, SLOT_IDENTIFIER);
234 }
235
236 inline bool
is_attached(widget w)237 is_attached (widget w) {
238 // is the widget attached to some window?
239 return get_identifier (w) != 0;
240 }
241
242 inline void
set_identifier(widget w,int id)243 set_identifier (widget w, int id) {
244 // attach a widget w to the window given by its low-level identifier id
245 // if id=0, then the widget is detached from its underlying window
246 return send<int> (w, SLOT_IDENTIFIER, id);
247 }
248
249 inline widget
get_window(widget w)250 get_window (widget w) {
251 // get the top-level window widget in which the widget is embedded
252 return read (w, SLOT_WINDOW);
253 }
254
255 inline void
set_visibility(widget w,bool flag)256 set_visibility (widget w, bool flag) {
257 // map or unmap a window widget
258 send<bool> (w, SLOT_VISIBILITY, flag);
259 }
260
261 inline void
set_full_screen(widget w,bool flag)262 set_full_screen (widget w, bool flag) {
263 // set or reset full screen mode for a window widget
264 send<bool> (w, SLOT_FULL_SCREEN, flag);
265 }
266
267 inline void
set_name(widget w,string s)268 set_name (widget w, string s) {
269 // set the name of a widget (usually a window)
270 send<string> (w, SLOT_NAME, s);
271 }
272
273 inline void
set_modified(widget w,bool flag)274 set_modified (widget w, bool flag) {
275 // set the modified flag for a widget (usually a window)
276 send<bool> (w, SLOT_MODIFIED, flag);
277 }
278
279 inline void
set_size(widget w,SI width,SI height)280 set_size (widget w, SI width, SI height) {
281 // set the current size of the widget
282 send<SI,SI> (w, SLOT_SIZE, width, height);
283 }
284
285 inline void
get_size(widget w,SI & width,SI & height)286 get_size (widget w, SI& width, SI& height) {
287 // get the current size of the widget
288 query<SI,SI> (w, SLOT_SIZE, width, height);
289 }
290
291 inline void
notify_size(widget w,SI new_width,SI new_height)292 notify_size (widget w, SI new_width, SI new_height) {
293 // notify a size change for the widget
294 notify<SI,SI> (w, SLOT_SIZE, new_width, new_height);
295 }
296
297 inline void
set_position(widget w,SI x,SI y)298 set_position (widget w, SI x, SI y) {
299 // set the position of the top left corner of the widget w
300 // w.r.t. the top left of its parent widget
301 send<SI,SI> (w, SLOT_POSITION, x, y);
302 }
303
304 inline void
get_position(widget w,SI & x,SI & y)305 get_position (widget w, SI& x, SI& y) {
306 // get the position of the top left corner of the widget w
307 // w.r.t. the top left of its parent widget
308 query<SI,SI> (w, SLOT_POSITION, x, y);
309 }
310
311 inline void
notify_position(widget w,SI new_x,SI new_y)312 notify_position (widget w, SI new_x, SI new_y) {
313 // notify a change in the position of the widget
314 notify<SI,SI> (w, SLOT_POSITION, new_x, new_y);
315 }
316
317 inline void
send_update(widget w)318 send_update (widget w) {
319 // this message is issued if the contents of w or a subwidget of w
320 // has changed in such a way that the geometries of w and its subwidgets
321 // may need to be adjusted. Example: a change of the current output language
322 send (w, SLOT_UPDATE);
323 }
324
325 inline void
send_refresh(widget w,string kind)326 send_refresh (widget w, string kind) {
327 // this message is issued if the contents of one of the dynamic
328 // subwidgets (as constructed using refresh_widget) of w
329 // may have changed and needs to be recomputed
330 send<string> (w, SLOT_REFRESH, kind);
331 }
332
333 inline void
send_keyboard(widget w,string key,time_t t=0)334 send_keyboard (widget w, string key, time_t t= 0) {
335 // send a key press event
336 send<string,time_t> (w, SLOT_KEYBOARD, key, t);
337 }
338
339 inline void
send_keyboard_focus(widget w,bool get_focus=true)340 send_keyboard_focus (widget w, bool get_focus= true) {
341 // request the keyboard focus for a widget
342 send<bool> (w, SLOT_KEYBOARD_FOCUS, get_focus);
343 }
344
345 inline void
notify_keyboard_focus(widget w,bool has_focus)346 notify_keyboard_focus (widget w, bool has_focus) {
347 // notify that the widget got or lost keyboard focus
348 notify<bool> (w, SLOT_KEYBOARD_FOCUS, has_focus);
349 }
350
351 inline bool
query_keyboard_focus(widget w)352 query_keyboard_focus (widget w) {
353 // does this widget have the keyboard focus?
354 return query<bool> (w, SLOT_KEYBOARD_FOCUS);
355 }
356
357 inline void
send_keyboard_focus_on(widget w,string field)358 send_keyboard_focus_on (widget w, string field) {
359 // request the keyboard focus for field inside a widget
360 send<string> (w, SLOT_KEYBOARD_FOCUS_ON, field);
361 }
362
363 inline void
send_mouse(widget w,string kind,SI x,SI y,int mods,time_t t)364 send_mouse (widget w, string kind, SI x, SI y, int mods, time_t t) {
365 // send a mouse event of a given kind at position (x, y) and time t
366 // mods corresponds to active buttons and keyboard modifiers at time t
367 // the position is specified w.r.t. the top left corner of w
368 send<string,SI,SI,int,time_t> (w, SLOT_MOUSE, kind, x, y, mods, t);
369 }
370
371 inline void
send_mouse_grab(widget w,bool get_grab)372 send_mouse_grab (widget w, bool get_grab) {
373 // request a mouse grab for the widget
374 send<bool> (w, SLOT_MOUSE_GRAB, get_grab);
375 }
376
377 inline void
notify_mouse_grab(widget w,bool has_grab)378 notify_mouse_grab (widget w, bool has_grab) {
379 // notify that the widget got or lost the mouse grab
380 notify<bool> (w, SLOT_MOUSE_GRAB, has_grab);
381 }
382
383 inline bool
query_mouse_grab(widget w)384 query_mouse_grab (widget w) {
385 // does this widget have the mouse grab?
386 return query<bool> (w, SLOT_MOUSE_GRAB);
387 }
388
389 inline void
send_mouse_pointer(widget w,string name,string mask_name="")390 send_mouse_pointer (widget w, string name, string mask_name= "") {
391 // request a permanent change for the mouse pointer
392 send<string,string> (w, SLOT_MOUSE_POINTER, name, mask_name);
393 }
394
395 inline void
send_invalidate_all(widget w)396 send_invalidate_all (widget w) {
397 // invalidate the widget so that it will be repaint at a next iteration
398 send (w, SLOT_INVALIDATE_ALL);
399 }
400
401 inline void
send_invalidate(widget w,SI x1,SI y1,SI x2,SI y2)402 send_invalidate (widget w, SI x1, SI y1, SI x2, SI y2) {
403 // invalidate a region so that it will be repaint at a next iteration;
404 // the region is specified w.r.t. the top left corner of w
405 send<SI,SI,SI,SI> (w, SLOT_INVALIDATE, x1, y1, x2, y2);
406 }
407
408 inline bool
query_invalid(widget w)409 query_invalid (widget w) {
410 // does this widget has invalid regions
411 return query<bool> (w, SLOT_INVALID);
412 }
413
414
415 inline void
send_repaint(widget w,renderer ren,SI x1,SI y1,SI x2,SI y2)416 send_repaint (widget w, renderer ren, SI x1, SI y1, SI x2, SI y2) {
417 // request widget to repaint a region;
418 // the region is specified w.r.t. the top left corner of w
419 send<renderer,SI,SI,SI,SI> (w, SLOT_REPAINT, ren, x1, y1, x2, y2);
420 }
421
422 inline void
send_delayed_message(widget w,string message,time_t delay)423 send_delayed_message (widget w, string message, time_t delay) {
424 // send a message to w which will only be received after a given delay
425 send<string,time_t> (w, SLOT_DELAYED_MESSAGE, message, delay);
426 }
427
428 inline void
send_destroy(widget w)429 send_destroy (widget w) {
430 // request a widget to be destroyed
431 send (w, SLOT_DESTROY);
432 }
433
434 /******************************************************************************
435 * Canvas related messages
436 ******************************************************************************/
437
438 inline void
set_zoom_factor(widget w,double zoom)439 set_zoom_factor (widget w, double zoom) {
440 // set zoom factor for canvas
441 send<double> (w, SLOT_ZOOM_FACTOR, zoom);
442 }
443
444 inline void
set_extents(widget w,SI x1,SI y1,SI x2,SI y2)445 set_extents (widget w, SI x1, SI y1, SI x2, SI y2) {
446 // set extents of a canvas
447 send<SI,SI,SI,SI> (w, SLOT_EXTENTS, x1, y1, x2, y2);
448 }
449
450 inline void
get_extents(widget w,SI & x1,SI & y1,SI & x2,SI & y2)451 get_extents (widget w, SI& x1, SI& y1, SI& x2, SI& y2) {
452 // get extents of a canvas
453 query<SI,SI,SI,SI> (w, SLOT_EXTENTS, x1, y1, x2, y2);
454 }
455
456 inline void
get_visible_part(widget w,SI & x1,SI & y1,SI & x2,SI & y2)457 get_visible_part (widget w, SI& x1, SI& y1, SI& x2, SI& y2) {
458 // get visible part of a canvas
459 query<SI,SI,SI,SI> (w, SLOT_VISIBLE_PART, x1, y1, x2, y2);
460 }
461
462 inline void
set_scrollbars_visibility(widget w,int sb)463 set_scrollbars_visibility (widget w, int sb) {
464 // set visibility of scrollbars
465 send<int> (w, SLOT_SCROLLBARS_VISIBILITY, sb);
466 }
467
468 inline void
set_scroll_position(widget w,SI x,SI y)469 set_scroll_position (widget w, SI x, SI y) {
470 // set scroll position in a canvas
471 send<SI,SI> (w, SLOT_SCROLL_POSITION, x, y);
472 }
473
474 inline void
get_scroll_position(widget w,SI & x,SI & y)475 get_scroll_position (widget w, SI& x, SI& y) {
476 // get scroll position in a canvas
477 query<SI,SI> (w, SLOT_SCROLL_POSITION, x, y);
478 }
479
480 inline void
set_scrollable(widget w,widget cv)481 set_scrollable (widget w, widget cv) {
482 // set the scrollable canvas itself
483 write (w, SLOT_SCROLLABLE, cv);
484 }
485
486 inline widget
get_canvas(widget w)487 get_canvas (widget w) {
488 // get the scrollable canvas itself
489 return read (w, SLOT_CANVAS);
490 }
491
492 inline void
send_cursor(widget w,SI x1,SI y1)493 send_cursor (widget w, SI x1, SI y1) {
494 // send current cursor coordinates
495 send<SI,SI> (w, SLOT_CURSOR, x1, y1);
496 }
497
498 /******************************************************************************
499 * Top-level window related messages (also behaves as a canvas)
500 ******************************************************************************/
501
502 inline void
set_header_visibility(widget w,bool visible)503 set_header_visibility (widget w, bool visible) {
504 // set visibility of header (menu and icon bars)
505 send<bool> (w, SLOT_HEADER_VISIBILITY, visible);
506 }
507
508 inline bool
get_header_visibility(widget w)509 get_header_visibility (widget w) {
510 // get visibility of header (menu and icon bars)
511 return query<bool> (w, SLOT_HEADER_VISIBILITY);
512 }
513
514 inline void
set_main_menu(widget w,widget bar)515 set_main_menu (widget w, widget bar) {
516 // set main menu bar
517 write (w, SLOT_MAIN_MENU, bar);
518 }
519
520 inline void
set_main_icons_visibility(widget w,bool visible)521 set_main_icons_visibility (widget w, bool visible) {
522 // set visibility of main icons bar
523 send<bool> (w, SLOT_MAIN_ICONS_VISIBILITY, visible);
524 }
525
526 inline bool
get_main_icons_visibility(widget w)527 get_main_icons_visibility (widget w) {
528 // get visibility of main icons bar
529 return query<bool> (w, SLOT_MAIN_ICONS_VISIBILITY);
530 }
531
532 inline void
set_main_icons(widget w,widget bar)533 set_main_icons (widget w, widget bar) {
534 // set main icons bar
535 write (w, SLOT_MAIN_ICONS, bar);
536 }
537
538 inline void
set_mode_icons_visibility(widget w,bool visible)539 set_mode_icons_visibility (widget w, bool visible) {
540 // set visibility of mode dependent icons bar
541 send<bool> (w, SLOT_MODE_ICONS_VISIBILITY, visible);
542 }
543
544 inline bool
get_mode_icons_visibility(widget w)545 get_mode_icons_visibility (widget w) {
546 // get visibility of mode dependent icons bar
547 return query<bool> (w, SLOT_MODE_ICONS_VISIBILITY);
548 }
549
550 inline void
set_mode_icons(widget w,widget bar)551 set_mode_icons (widget w, widget bar) {
552 // set mode dependent icons bar
553 write (w, SLOT_MODE_ICONS, bar);
554 }
555
556 inline void
set_focus_icons_visibility(widget w,bool visible)557 set_focus_icons_visibility (widget w, bool visible) {
558 // set visibility of focus dependent icons bar
559 send<bool> (w, SLOT_FOCUS_ICONS_VISIBILITY, visible);
560 }
561
562 inline bool
get_focus_icons_visibility(widget w)563 get_focus_icons_visibility (widget w) {
564 // get visibility of focus dependent icons bar
565 return query<bool> (w, SLOT_FOCUS_ICONS_VISIBILITY);
566 }
567
568 inline void
set_focus_icons(widget w,widget bar)569 set_focus_icons (widget w, widget bar) {
570 // set focus dependent icons bar
571 write (w, SLOT_FOCUS_ICONS, bar);
572 }
573
574 inline void
set_user_icons_visibility(widget w,bool visible)575 set_user_icons_visibility (widget w, bool visible) {
576 // set visibility of user icons bar
577 send<bool> (w, SLOT_USER_ICONS_VISIBILITY, visible);
578 }
579
580 inline bool
get_user_icons_visibility(widget w)581 get_user_icons_visibility (widget w) {
582 // get visibility of user icons bar
583 return query<bool> (w, SLOT_USER_ICONS_VISIBILITY);
584 }
585
586 inline void
set_user_icons(widget w,widget bar)587 set_user_icons (widget w, widget bar) {
588 // set user icons bar
589 write (w, SLOT_USER_ICONS, bar);
590 }
591
592 inline void
set_side_tools_visibility(widget w,bool visible)593 set_side_tools_visibility (widget w, bool visible) {
594 // set visibility of side tools
595 send<bool> (w, SLOT_SIDE_TOOLS_VISIBILITY, visible);
596 }
597
598 inline bool
get_side_tools_visibility(widget w)599 get_side_tools_visibility (widget w) {
600 // get visibility of side tools
601 return query<bool> (w, SLOT_SIDE_TOOLS_VISIBILITY);
602 }
603
604 inline void
set_side_tools(widget w,widget bar)605 set_side_tools (widget w, widget bar) {
606 // set side tools
607 write (w, SLOT_SIDE_TOOLS, bar);
608 }
609
610 inline void
set_bottom_tools_visibility(widget w,bool visible)611 set_bottom_tools_visibility (widget w, bool visible) {
612 // set visibility of bottom tools
613 send<bool> (w, SLOT_BOTTOM_TOOLS_VISIBILITY, visible);
614 }
615
616 inline bool
get_bottom_tools_visibility(widget w)617 get_bottom_tools_visibility (widget w) {
618 // get visibility of bottom tools
619 return query<bool> (w, SLOT_BOTTOM_TOOLS_VISIBILITY);
620 }
621
622 inline void
set_bottom_tools(widget w,widget bar)623 set_bottom_tools (widget w, widget bar) {
624 // set bottom tools
625 write (w, SLOT_BOTTOM_TOOLS, bar);
626 }
627
628 inline void
set_footer_visibility(widget w,bool visible)629 set_footer_visibility (widget w, bool visible) {
630 // set visibility of footer
631 send<bool> (w, SLOT_FOOTER_VISIBILITY, visible);
632 }
633
634 inline bool
get_footer_visibility(widget w)635 get_footer_visibility (widget w) {
636 // get visibility of footer
637 return query<bool> (w, SLOT_FOOTER_VISIBILITY);
638 }
639
640 inline void
set_left_footer(widget w,string s)641 set_left_footer (widget w, string s) {
642 // set left footer
643 send<string> (w, SLOT_LEFT_FOOTER, s);
644 }
645
646 inline void
set_right_footer(widget w,string s)647 set_right_footer (widget w, string s) {
648 // set right footer
649 send<string> (w, SLOT_RIGHT_FOOTER, s);
650 }
651
652 inline void
set_interactive_mode(widget w,bool on)653 set_interactive_mode (widget w, bool on) {
654 // set interactive mode, allowing users to input text on footer
655 send<bool> (w, SLOT_INTERACTIVE_MODE, on);
656 }
657
658 inline bool
get_interactive_mode(widget w)659 get_interactive_mode (widget w) {
660 // check whether footer is in interactive mode
661 return query<bool> (w, SLOT_INTERACTIVE_MODE);
662 }
663
664 inline void
set_interactive_prompt(widget w,widget prompt)665 set_interactive_prompt (widget w, widget prompt) {
666 // set prompt for interactive input
667 write (w, SLOT_INTERACTIVE_PROMPT, prompt);
668 }
669
670 inline void
set_interactive_input(widget w,widget input)671 set_interactive_input (widget w, widget input) {
672 // set interactive input widget
673 write (w, SLOT_INTERACTIVE_INPUT, input);
674 }
675
676 inline string
get_interactive_input(widget w)677 get_interactive_input (widget w) {
678 // set interactive input widget
679 return query<string> (w, SLOT_INTERACTIVE_INPUT);
680 }
681
682 /******************************************************************************
683 * Dialogue windows
684 ******************************************************************************/
685
686 inline widget
get_form_field(widget w,int i)687 get_form_field (widget w, int i) {
688 // get the i-th input widget from a dialogue widget
689 return read<int> (w, SLOT_FORM_FIELD, i);
690 }
691
692 inline string
get_string_input(widget w)693 get_string_input (widget w) {
694 // get input string from input widget
695 return query<string> (w, SLOT_STRING_INPUT);
696 }
697
698 inline void
set_string_input(widget w,string s)699 set_string_input (widget w, string s) {
700 // set default input string of input widget
701 send<string> (w, SLOT_STRING_INPUT, s);
702 }
703
704 inline void
set_input_type(widget w,string s)705 set_input_type (widget w, string s) {
706 // set the type of an input field
707 send<string> (w, SLOT_INPUT_TYPE, s);
708 }
709
710 inline void
add_input_proposal(widget w,string s)711 add_input_proposal (widget w, string s) {
712 // add an extra proposal for input widget (e.g. from history)
713 send<string> (w, SLOT_INPUT_PROPOSAL, s);
714 }
715
716 inline void
set_file(widget w,string s)717 set_file (widget w, string s) {
718 // set current file of file chooser widget or texmacs window
719 send<string> (w, SLOT_FILE, s);
720 }
721
722 inline widget
get_file(widget w)723 get_file (widget w) {
724 // get file input widget
725 return read (w, SLOT_FILE);
726 }
727
728 inline void
set_directory(widget w,string s)729 set_directory (widget w, string s) {
730 // set current directory of directory chooser widget
731 send<string> (w, SLOT_DIRECTORY, s);
732 }
733
734 inline widget
get_directory(widget w)735 get_directory (widget w) {
736 // get directory input widget
737 return read (w, SLOT_DIRECTORY);
738 }
739
740 #endif // defined MESSAGE_H
741