Systematic use of tm_ostream class instead of ostream (removing dependency on std)
[texmacs.git] / src / src / Plugins / Widkit / Basic / widkit_wrapper.cpp
blob5b7fe1546952e569e5fd9372343a663c0c945ffb
2 /******************************************************************************
3 * MODULE : widkit_wrapper.hpp
4 * DESCRIPTION: Conversions between widget and wk_widget
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 ******************************************************************************/
12 #include "promise.hpp"
13 #include "url.hpp"
14 #include "Widkit/wk_widget.hpp"
15 #include "message.hpp"
16 #include "window.hpp"
17 #include "dictionary.hpp"
19 #define THIS wk_widget (this)
21 static void noop () {}
22 widget box_widget (scheme_tree p, string s, color col, bool trans, bool ink);
24 /******************************************************************************
25 * Type conversions
26 ******************************************************************************/
28 array<widget>
29 abstract (array<wk_widget> a) {
30 int i, n= N(a);
31 array<widget> b (n);
32 for (i=0; i<n; i++) b[i]= abstract (a[i]);
33 return b;
36 array<wk_widget>
37 concrete (array<widget> a) {
38 int i, n= N(a);
39 array<wk_widget> b (n);
40 for (i=0; i<n; i++) b[i]= concrete (a[i]);
41 return b;
44 class abstract_promise_rep: public promise_rep<widget> {
45 promise<wk_widget> p;
46 public:
47 abstract_promise_rep (promise<wk_widget> p2): p (p2) {}
48 tm_ostream& print (tm_ostream& out) { return out << p; }
49 widget eval () { return abstract (p ()); }
52 promise<widget>
53 abstract (promise<wk_widget> pw) {
54 return tm_new<abstract_promise_rep> (pw);
57 class concrete_promise_rep: public promise_rep<wk_widget> {
58 promise<widget> p;
59 public:
60 concrete_promise_rep (promise<widget> p2): p (p2) {}
61 tm_ostream& print (tm_ostream& out) { return out << p; }
62 wk_widget eval () { return concrete (p ()); }
65 promise<wk_widget>
66 concrete (promise<widget> pw) {
67 return tm_new<concrete_promise_rep> (pw);
70 /******************************************************************************
71 * Exported special widgets
72 ******************************************************************************/
74 widget
75 horizontal_list (array<widget> a) {
76 return abstract (horizontal_list (concrete (a)));
79 widget
80 vertical_list (array<widget> a) {
81 return abstract (vertical_list (concrete (a)));
84 widget
85 horizontal_menu (array<widget> a) {
86 return abstract (horizontal_array (concrete (a), -1));
89 widget
90 vertical_menu (array<widget> a) {
91 return abstract (vertical_menu (concrete (a)));
94 widget
95 tile_menu (array<widget> a, int cols) {
96 return abstract (tile (concrete (a), cols));
99 widget
100 switch_widget (array<widget> a, array<string> name, int init) {
101 return abstract (switch_widget (concrete (a), name, init));
104 widget
105 optional_widget (widget w, bool on) {
106 return abstract (optional_widget (concrete (w), on));
109 widget
110 empty_widget () {
111 return abstract (glue_wk_widget (false, false, 0, 0));
114 widget
115 glue_widget (bool hx, bool vx, SI w, SI h) {
116 return abstract (glue_wk_widget (hx, vx, w, h));
119 widget
120 menu_separator (bool vert) {
121 return abstract (separator_wk_widget (2*PIXEL, 2*PIXEL, vert));
124 widget
125 text_widget (string s, bool tsp, string lan) {
126 return abstract (text_wk_widget (s, tsp, lan));
129 widget
130 menu_text_widget (string s, color col, bool tsp, string lan, bool tt) {
131 return abstract (menu_text_wk_widget (s, col, tsp, lan, tt));
134 widget
135 text_widget (string s, color col, bool tsp, string lan) {
136 return menu_text_widget (s, col, tsp, lan, false);
139 widget
140 xpm_widget (url file_name) {
141 return abstract (xpm_wk_widget (file_name, true));
144 widget
145 command_button (widget w, command cmd, bool button_flag) {
146 return abstract (command_button (concrete (w), cmd, button_flag));
149 widget
150 command_button (widget lw, widget cw, widget rw, command cmd, bool e, bool c) {
151 return abstract (command_button (concrete (lw), concrete (cw),
152 concrete (rw), cmd, e, c));
155 widget
156 menu_group (string name, string lan) {
157 widget lw= empty_widget ();
158 widget cw= text_widget (name, dark_grey, false, lan);
159 widget rw= empty_widget ();
160 return command_button (lw, cw, rw, noop, false, true);
163 widget
164 menu_button (widget w, command cmd, string pre, string ks, bool ok) {
165 if (pre == "" && ks == "") return command_button (w, cmd, false);
166 else {
167 color c = ok? black: dark_grey;
168 widget lw= empty_widget ();
169 widget rw= menu_text_widget (ks, c, true, "english", true);
170 if (pre != "") {
171 string s= "";
172 if (pre == "v") s= "<checked>";
173 if (pre == "o") s= "<circ>";
174 if (pre == "*") s= "<bullet>";
175 if (s != "") lw= box_widget (tree (TUPLE), s, c, true, false);
177 return command_button (lw, w, rw, cmd, ok, false);
181 widget
182 pulldown_button (widget w, promise<widget> pw) {
183 return abstract (pulldown_button (concrete (w), concrete (pw)));
186 widget
187 pullright_button (widget w, promise<widget> pw) {
188 return abstract (pullright_button (concrete (w), concrete (pw)));
191 widget
192 popup_widget (widget w) {
193 return abstract (popup_widget (concrete (w), center));
196 widget
197 canvas_widget (widget w) {
198 return abstract (canvas_widget (concrete (w), north_west));
201 widget
202 input_text_widget (command call_back, string type, array<string> def) {
203 return abstract (input_text_wk_widget (call_back, type, def));
206 widget
207 inputs_list_widget (command call_back, array<string> prompts) {
208 return abstract (inputs_list_wk_widget (call_back, prompts));
211 widget
212 file_chooser_widget (command cmd, string type, string mgn) {
213 return abstract (file_chooser_wk_widget (cmd, type, mgn));
216 widget
217 balloon_widget (widget w, widget help) {
218 return abstract (balloon_widget (concrete (w), concrete (help)));
221 widget
222 wait_widget (SI w, SI h, string message) {
223 return abstract (wait_wk_widget (w, h, message));
226 widget
227 texmacs_widget (int mask, command quit) {
228 return abstract (texmacs_wk_widget (mask, quit));
231 widget
232 plain_window_widget (widget wid, string s) {
233 return abstract (plain_window_widget (concrete (wid), s));
236 widget
237 popup_window_widget (widget wid, string s) {
238 return abstract (popup_window_widget (concrete (wid), s));
241 void
242 destroy_window_widget (widget w) {
243 destroy_window_widget (concrete (w));
246 /******************************************************************************
247 * Type checking
248 ******************************************************************************/
250 void
251 check_type_void (blackbox bb, string s) {
252 if (!is_nil (bb)) {
253 cerr << "\nslot type= " << s << "\n";
254 FAILED ("type mismatch");
258 template<class T> void
259 check_type (blackbox bb, string s) {
260 if (type_box (bb) != type_helper<T>::id) {
261 cerr << "\nslot type= " << s << "\n";
262 FAILED ("type mismatch");
266 template<class T1, class T2> inline void
267 check_type (blackbox bb, string s) {
268 check_type<pair<T1,T2> > (bb, s);
271 /******************************************************************************
272 * Widget geometry
273 ******************************************************************************/
275 SI get_dx (gravity grav, SI w);
276 SI get_dy (gravity grav, SI h);
278 void
279 principal_widget_check (wk_widget wid) {
280 // FIXME: Positions should really be computed relative to parent widgets.
281 // Currently, we only allow geometry access of the unique child of
282 // a window widget.
283 if (wid->win != NULL && wid != concrete (wid->win->get_widget ()) [0]) {
284 cerr << "Widget= " << wid << "\n";
285 FAILED ("invalid geometry access");
289 void
290 set_geometry (wk_widget wid, SI x, SI y, SI w, SI h) {
291 if (wid->is_window_widget ()) {
292 wid->win->set_position (x, y);
293 wid->win->set_size (w, h);
295 else {
296 principal_widget_check (wid); // FIXME: we should use parent's coordinates
297 wid << emit_position (x, y, w, h, north_west);
301 void
302 get_geometry (wk_widget wid, SI& x, SI& y, SI& w, SI& h) {
303 if (wid->is_window_widget ()) {
304 wid->win->get_position (x, y);
305 wid->win->get_size (w, h);
307 else {
308 principal_widget_check (wid); // FIXME: we should use parent's coordinates
309 x= wid->ox - get_dx (wid->grav, wid->w);
310 y= wid->oy - get_dy (wid->grav, wid->h);
311 w= wid->w;
312 h= wid->h;
316 /******************************************************************************
317 * Sending messages
318 ******************************************************************************/
320 void
321 send_bool (wk_widget w, string key, blackbox val) {
322 ASSERT (type_box (val) == type_helper<bool>::id, "type mismatch");
323 w << set_string (key, open_box<bool> (val)? string ("on"): string ("off"));
326 void
327 send_int (wk_widget w, string key, blackbox val) {
328 ASSERT (type_box (val) == type_helper<int>::id, "type mismatch");
329 w << set_integer (key, open_box<int> (val));
332 void
333 send_string (wk_widget w, string key, blackbox val) {
334 ASSERT (type_box (val) == type_helper<string>::id, "type mismatch");
335 w << set_string (key, open_box<string> (val));
338 void
339 send_coord2 (wk_widget w, string key, blackbox val) {
340 typedef pair<SI,SI> coord2;
341 ASSERT (type_box (val) == type_helper<coord2>::id, "type mismatch");
342 coord2 p= open_box<coord2> (val);
343 w << set_coord2 (key, p.x1, p.x2);
346 void
347 send_coord4 (wk_widget w, string key, blackbox val) {
348 typedef quartet<SI,SI,SI,SI> coord4;
349 ASSERT (type_box (val) == type_helper<coord4>::id, "type mismatch");
350 coord4 p= open_box<coord4> (val);
351 w << set_coord4 (key, p.x1, p.x2, p.x3, p.x4);
354 void
355 send_position (wk_widget w, blackbox val) {
356 typedef pair<SI,SI> coord2;
357 ASSERT (type_box (val) == type_helper<coord2>::id, "type mismatch");
358 coord2 p= open_box<coord2> (val);
359 if (w->is_window_widget ()) w->win->set_position (p.x1, p.x2);
360 else {
361 SI x, y, W, H;
362 get_geometry (w, x, y, W, H);
363 set_geometry (w, p.x1, p.x2, W, H);
367 void
368 send_size (wk_widget w, blackbox val) {
369 typedef pair<SI,SI> coord2;
370 ASSERT (type_box (val) == type_helper<coord2>::id, "type mismatch");
371 coord2 p= open_box<coord2> (val);
372 if (w->is_window_widget ()) w->win->set_size (p.x1, p.x2);
373 else {
374 SI x, y, W, H;
375 get_geometry (w, x, y, W, H);
376 set_geometry (w, x, y, p.x1, p.x2);
380 void
381 send_update (wk_widget w, blackbox val) {
382 ASSERT (is_nil (val), "type mismatch");
383 w << emit_update ();
386 void
387 send_keyboard (wk_widget w, blackbox val) {
388 typedef pair<string,time_t> keypress;
389 ASSERT (type_box (val) == type_helper<keypress>::id, "type mismatch");
390 keypress k= open_box<keypress> (val);
391 w << emit_keypress (k.x1, k.x2);
394 void
395 send_keyboard_focus (wk_widget w, blackbox val) {
396 ASSERT (type_box (val) == type_helper<bool>::id, "type mismatch");
397 w->win->set_keyboard_focus (abstract (w), open_box<bool> (val));
400 void
401 send_mouse (wk_widget w, blackbox val) {
402 typedef quintuple<string,SI,SI,int,time_t> mouse;
403 ASSERT (type_box (val) == type_helper<mouse>::id, "type mismatch");
404 mouse m= open_box<mouse> (val);
405 // FIXME: we should assume the position in the local coordinates
406 w << emit_mouse (m.x1, m.x2, m.x3, m.x4, m.x5);
409 void
410 send_mouse_grab (wk_widget w, blackbox val) {
411 ASSERT (type_box (val) == type_helper<bool>::id, "type mismatch");
412 w->win->set_mouse_grab (abstract (w), open_box<bool> (val));
415 void
416 send_mouse_pointer (wk_widget w, blackbox val) {
417 typedef pair<string,string> change_pointer;
418 ASSERT (type_box (val) == type_helper<change_pointer>::id, "type mismatch");
419 change_pointer cp= open_box<change_pointer> (val);
420 w->win->set_mouse_pointer (abstract (w), cp.x1, cp.x2);
423 void
424 send_invalidate (wk_widget w, blackbox val) {
425 typedef quartet<SI,SI,SI,SI> coord4;
426 ASSERT (type_box (val) == type_helper<coord4>::id, "type mismatch");
427 coord4 p= open_box<coord4> (val);
428 w << emit_invalidate (w->ox + p.x1, w->oy + p.x2,
429 w->ox + p.x3, w->oy + p.x4);
432 void
433 send_invalidate_all (wk_widget w, blackbox val) {
434 ASSERT (is_nil (val), "type mismatch");
435 w << emit_invalidate_all ();
438 void
439 send_repaint (wk_widget w, blackbox val) {
440 typedef quartet<SI,SI,SI,SI> repaint;
441 ASSERT (type_box (val) == type_helper<repaint>::id, "type mismatch");
442 repaint r= open_box<repaint> (val);
443 bool stop_flag= false;
444 // FIXME: we should assume local coordinates for repainting
445 w << emit_repaint (r.x1, r.x2, r.x3, r.x4, stop_flag);
448 void
449 send_delayed_message (wk_widget w, blackbox val) {
450 typedef pair<string,time_t> delayed;
451 ASSERT (type_box (val) == type_helper<delayed>::id, "type mismatch");
452 delayed dm= open_box<delayed> (val);
453 w << emit_alarm (dm.x1, dm.x2);
456 void
457 send_destroy (wk_widget w, blackbox val) {
458 ASSERT (is_nil (val), "type mismatch");
459 w << emit_destroy ();
462 void
463 wk_widget_rep::send (slot s, blackbox val) {
464 switch (s) {
465 case SLOT_IDENTIFIER:
466 check_type<int> (val, "SLOT_IDENTIFIER");
467 THIS << emit_attach_window (get_window (open_box<int> (val)));
468 break;
469 case SLOT_VISIBILITY:
470 check_type<bool> (val, "SLOT_VISIBILITY");
471 win->set_visibility (open_box<bool> (val));
472 break;
473 case SLOT_FULL_SCREEN:
474 check_type<bool> (val, "SLOT_FULL_SCREEN");
475 win->set_full_screen (open_box<bool> (val));
476 break;
477 case SLOT_NAME:
478 send_string (THIS, "window name", val);
479 break;
480 case SLOT_SIZE:
481 send_size (THIS, val);
482 break;
483 case SLOT_POSITION:
484 send_position (THIS, val);
485 break;
486 case SLOT_UPDATE:
487 send_update (THIS, val);
488 break;
489 case SLOT_KEYBOARD:
490 send_keyboard (THIS, val);
491 break;
492 case SLOT_KEYBOARD_FOCUS:
493 send_keyboard_focus (THIS, val);
494 break;
495 case SLOT_MOUSE:
496 send_mouse (THIS, val);
497 break;
498 case SLOT_MOUSE_GRAB:
499 send_mouse_grab (THIS, val);
500 break;
501 case SLOT_MOUSE_POINTER:
502 send_mouse_pointer (THIS, val);
503 break;
504 case SLOT_INVALIDATE:
505 send_invalidate (THIS, val);
506 break;
507 case SLOT_INVALIDATE_ALL:
508 send_invalidate_all (THIS, val);
509 break;
510 case SLOT_REPAINT:
511 send_repaint (THIS, val);
512 break;
513 case SLOT_DELAYED_MESSAGE:
514 send_delayed_message (THIS, val);
515 break;
516 case SLOT_DESTROY:
517 send_destroy (THIS, val);
518 break;
520 case SLOT_SHRINKING_FACTOR:
521 send_int (THIS, "shrinking factor", val);
522 break;
523 case SLOT_EXTENTS:
524 send_coord4 (THIS, "extents", val);
525 break;
526 case SLOT_SCROLLBARS_VISIBILITY:
527 send_int (THIS, "scrollbars", val);
528 break;
529 case SLOT_SCROLL_POSITION:
530 send_coord2 (THIS, "scroll position", val);
531 break;
533 case SLOT_HEADER_VISIBILITY:
534 send_bool (THIS, "header", val);
535 break;
536 case SLOT_MAIN_ICONS_VISIBILITY:
537 send_bool (THIS, "main icons", val);
538 break;
539 case SLOT_CONTEXT_ICONS_VISIBILITY:
540 send_bool (THIS, "context icons", val);
541 break;
542 case SLOT_USER_ICONS_VISIBILITY:
543 send_bool (THIS, "user icons", val);
544 break;
545 case SLOT_FOOTER_VISIBILITY:
546 send_bool (THIS, "footer flag", val);
547 break;
548 case SLOT_LEFT_FOOTER:
549 send_string (THIS, "left footer", val);
550 break;
551 case SLOT_RIGHT_FOOTER:
552 send_string (THIS, "right footer", val);
553 break;
554 case SLOT_INTERACTIVE_MODE:
555 send_bool (THIS, "interactive mode", val);
556 break;
558 case SLOT_STRING_INPUT:
559 send_string (THIS, "input", val);
560 break;
561 case SLOT_INPUT_TYPE:
562 send_string (THIS, "type", val);
563 break;
564 case SLOT_INPUT_PROPOSAL:
565 send_string (THIS, "default", val);
566 break;
567 case SLOT_FILE:
568 send_string (THIS, "file", val);
569 break;
570 case SLOT_DIRECTORY:
571 send_string (THIS, "directory", val);
572 break;
573 default:
574 FAILED ("cannot handle slot type");
578 /******************************************************************************
579 * Querying
580 ******************************************************************************/
582 blackbox
583 query_bool (wk_widget w, string key, int type_id) {
584 ASSERT (type_id == type_helper<bool>::id, "type mismatch");
585 string s;
586 w << get_string (key, s);
587 return close_box<bool> (s == "on");
590 blackbox
591 query_int (wk_widget w, string key, int type_id) {
592 ASSERT (type_id == type_helper<int>::id, "type mismatch");
593 int i;
594 w << get_integer (key, i);
595 return close_box<int> (i);
598 blackbox
599 query_string (wk_widget w, string key, int type_id) {
600 ASSERT (type_id == type_helper<string>::id, "type mismatch");
601 string s;
602 w << get_string (key, s);
603 return close_box<string> (s);
606 blackbox
607 query_coord2 (wk_widget w, string key, int type_id) {
608 typedef pair<SI,SI> coord2;
609 ASSERT (type_id == type_helper<coord2>::id, "type mismatch");
610 SI c1, c2;
611 w << get_coord2 (key, c1, c2);
612 return close_box<coord2> (coord2 (c1, c2));
615 blackbox
616 query_coord4 (wk_widget w, string key, int type_id) {
617 typedef quartet<SI,SI,SI,SI> coord4;
618 ASSERT (type_id == type_helper<coord4>::id, "type mismatch");
619 SI c1, c2, c3, c4;
620 w << get_coord4 (key, c1, c2, c3, c4);
621 return close_box<coord4> (coord4 (c1, c2, c3, c4));
624 blackbox
625 query_size (wk_widget w, int type_id) {
626 typedef pair<SI,SI> coord2;
627 ASSERT (type_id == type_helper<coord2>::id, "type mismatch");
628 SI x, y, W, H;
629 get_geometry (w, x, y, W, H);
630 return close_box<coord2> (coord2 (W, H));
633 blackbox
634 query_position (wk_widget w, int type_id) {
635 typedef pair<SI,SI> coord2;
636 ASSERT (type_id == type_helper<coord2>::id, "type mismatch");
637 SI x, y, W, H;
638 get_geometry (w, x, y, W, H);
639 return close_box<coord2> (coord2 (x, y));
642 blackbox
643 query_keyboard_focus (wk_widget w, int type_id) {
644 ASSERT (type_id == type_helper<bool>::id, "type mismatch");
645 return close_box<bool> (w->win->get_keyboard_focus (abstract (w)));
648 blackbox
649 query_mouse_grab (wk_widget w, int type_id) {
650 ASSERT (type_id == type_helper<bool>::id, "type mismatch");
651 return close_box<bool> (w->win->get_mouse_grab (abstract (w)));
654 blackbox
655 wk_widget_rep::query (slot s, int type_id) {
656 switch (s) {
657 case SLOT_IDENTIFIER:
658 ASSERT (type_id == type_helper<int>::id,
659 "int expected (SLOT_IDENTIFIER)");
660 return close_box<int> (get_identifier (win));
661 case SLOT_RENDERER:
662 ASSERT (type_id == type_helper<renderer>::id,
663 "renderer expected (SLOT_RENDERER)");
664 return close_box<renderer> (win->get_renderer ());
665 case SLOT_SIZE:
666 return query_size (THIS, type_id);
667 case SLOT_POSITION:
668 return query_position (THIS, type_id);
669 case SLOT_KEYBOARD_FOCUS:
670 return query_keyboard_focus (THIS, type_id);
671 case SLOT_MOUSE_GRAB:
672 return query_mouse_grab (THIS, type_id);
674 case SLOT_EXTENTS:
675 return query_coord4 (THIS, "extents", type_id);
676 case SLOT_VISIBLE_PART:
677 return query_coord4 (THIS, "visible", type_id);
678 case SLOT_SCROLLBARS_VISIBILITY:
679 return query_int (THIS, "scrollbars", type_id);
680 case SLOT_SCROLL_POSITION:
681 return query_coord2 (THIS, "scroll position", type_id);
683 case SLOT_HEADER_VISIBILITY:
684 return query_bool (THIS, "header", type_id);
685 case SLOT_MAIN_ICONS_VISIBILITY:
686 return query_bool (THIS, "main icons", type_id);
687 case SLOT_CONTEXT_ICONS_VISIBILITY:
688 return query_bool (THIS, "context icons", type_id);
689 case SLOT_USER_ICONS_VISIBILITY:
690 return query_bool (THIS, "user icons", type_id);
691 case SLOT_FOOTER_VISIBILITY:
692 return query_bool (THIS, "footer flag", type_id);
693 case SLOT_INTERACTIVE_MODE:
694 return query_bool (THIS, "interactive mode", type_id);
695 case SLOT_INTERACTIVE_INPUT:
696 return query_string (THIS, "interactive input", type_id);
698 case SLOT_STRING_INPUT:
699 return query_string (THIS, "input", type_id);
700 default:
701 FAILED ("cannot handle slot type");
702 return blackbox ();
706 /******************************************************************************
707 * Notification of state changes
708 ******************************************************************************/
710 void
711 notify_keyboard_focus (wk_widget w, blackbox val) {
712 ASSERT (type_box (val) == type_helper<bool>::id, "type mismatch");
713 w << emit_keyboard_focus (open_box<bool> (val));
716 void
717 notify_mouse_grab (wk_widget w, blackbox val) {
718 ASSERT (type_box (val) == type_helper<bool>::id, "type mismatch");
719 w << emit_mouse_grab (open_box<bool> (val));
722 void
723 wk_widget_rep::notify (slot s, blackbox new_val) {
724 switch (s) {
725 case SLOT_SIZE:
726 check_type<SI,SI> (new_val, "SLOT_SIZE");
727 THIS << emit_resize ();
728 if (is_window_widget ())
729 send_size (THIS [0], new_val);
730 break;
731 case SLOT_POSITION:
732 check_type<SI,SI> (new_val, "SLOT_POSITION");
733 THIS << emit_move ();
734 break;
735 case SLOT_KEYBOARD_FOCUS:
736 notify_keyboard_focus (THIS, new_val);
737 break;
738 case SLOT_MOUSE_GRAB:
739 notify_mouse_grab (THIS, new_val);
740 break;
741 default:
742 break;
744 widget_rep::notify (s, new_val);
747 /******************************************************************************
748 * Read and write access of subwidgets
749 ******************************************************************************/
751 widget
752 wk_widget_rep::read (slot s, blackbox index) {
753 switch (s) {
754 case SLOT_WINDOW:
755 check_type_void (index, "SLOT_WINDOW");
756 return win -> get_widget ();
757 case SLOT_FORM_FIELD:
758 check_type<int> (index, "SLOT_FORM_FIELD");
759 return abstract (THIS [0] ["inputs"] [open_box<int> (index)] ["input"]);
760 case SLOT_FILE:
761 check_type_void (index, "SLOT_FILE");
762 return abstract (THIS [0] ["file"] ["input"]);
763 case SLOT_DIRECTORY:
764 check_type_void (index, "SLOT_DIRECTORY");
765 return abstract (THIS [0] ["directory"] ["input"]);
766 default:
767 FAILED ("cannot handle slot type");
768 return widget ();
772 void
773 wk_widget_rep::write (slot s, blackbox index, widget w) {
774 switch (s) {
775 case SLOT_MAIN_MENU:
776 check_type_void (index, "SLOT_MAIN_MENU");
777 THIS << set_widget ("menu bar", concrete (w));
778 break;
779 case SLOT_MAIN_ICONS:
780 check_type_void (index, "SLOT_MAIN_ICONS");
781 THIS << set_widget ("main icons bar", concrete (w));
782 break;
783 case SLOT_CONTEXT_ICONS:
784 check_type_void (index, "SLOT_CONTEXT_ICONS");
785 THIS << set_widget ("context icons bar", concrete (w));
786 break;
787 case SLOT_USER_ICONS:
788 check_type_void (index, "SLOT_USER_ICONS");
789 THIS << set_widget ("user icons bar", concrete (w));
790 break;
791 case SLOT_CANVAS:
792 check_type_void (index, "SLOT_CANVAS");
793 THIS << set_widget ("scrollable", concrete (w));
794 break;
795 case SLOT_INTERACTIVE_PROMPT:
796 check_type_void (index, "SLOT_INTERACTIVE_PROMPT");
797 THIS << set_widget ("interactive prompt", concrete (w));
798 break;
799 case SLOT_INTERACTIVE_INPUT:
800 check_type_void (index, "SLOT_INTERACTIVE_INPUT");
801 THIS << set_widget ("interactive input", concrete (w));
802 break;
803 default:
804 FAILED ("cannot handle slot type");