Back to index

texmacs  1.0.7.15
wk_widget.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : wk_widget.hpp
00004 * DESCRIPTION: Definition of abstract native widgets
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef WK_WIDGET_H
00013 #define WK_WIDGET_H
00014 #include "widget.hpp"
00015 #include "Widkit/event.hpp"
00016 
00017 /******************************************************************************
00018 * The abstract widkit implementation of widgets
00019 ******************************************************************************/
00020 
00021 class wk_widget;
00022 class wk_widget_rep: public widget_rep {
00023 public:
00024   window   win;             // underlying window
00025   SI       ox, oy;          // origin of widget in window
00026   SI       w, h;            // width and height of widget
00027   gravity  grav;            // position of the origin in the widget
00028   array<wk_widget>  a;      // children of widget
00029   array<string>     name;   // names for the children
00030 
00031   wk_widget_rep (array<wk_widget> a, array<string> name, gravity grav);
00032   ~wk_widget_rep ();
00033 
00034   void send (slot s, blackbox val);
00035   blackbox query (slot s, int type_id);
00036   void notify (slot s, blackbox new_val);
00037   widget read (slot s, blackbox index);
00038   void write (slot s, blackbox index, widget w);
00039 
00040   virtual operator tree () = 0;
00041   virtual tm_ostream& print (tm_ostream& out);
00042   virtual bool handle (event ev) = 0;
00043   virtual bool is_window_widget ();
00044 
00045   SI    x1 (); SI y1 (); // lower left window coordinates of widget
00046   SI    x2 (); SI y2 (); // upper right window coordinates of widget
00047   bool  attached ();
00048   void  wk_error (string message);
00049 
00050   friend class wk_widget;
00051 };
00052 
00053 class wk_widget {
00054 public:
00055 ABSTRACT_NULL(wk_widget);
00056   inline wk_widget operator [] (int i) { return rep->a[i]; }
00057   wk_widget operator [] (string s);
00058   inline operator tree () { return (tree) (*rep); }
00059   inline bool operator == (wk_widget w) { return rep == w.rep; }
00060   inline bool operator != (wk_widget w) { return rep != w.rep; }
00061 };
00062 ABSTRACT_NULL_CODE(wk_widget);
00063 
00064 inline widget abstract (wk_widget w) {
00065   return widget (w.rep); }
00066 inline wk_widget concrete (widget w) {
00067   return wk_widget ((wk_widget_rep*) w.rep); }
00068 array<widget> abstract (array<wk_widget> a);
00069 array<wk_widget> concrete (array<widget> a);
00070 
00071 tm_ostream& operator << (tm_ostream& out, wk_widget w);
00072 wk_widget operator << (wk_widget w, event ev);
00073 
00074 void wk_grab_pointer (wk_widget w);
00075 void wk_ungrab_pointer (wk_widget w);
00076 bool wk_has_pointer_grab (wk_widget w);
00077 
00078 SI decode_length (string s, wk_widget w, int style);
00079 
00080 #define WK_FAILED(msg) { wk_error (msg); FAILED ("widget_error"); }
00081 
00082 /******************************************************************************
00083 * Exported special widgets and window widget destruction
00084 ******************************************************************************/
00085 
00086 wk_widget extend (wk_widget w, array<wk_widget> a);
00087 wk_widget horizontal_list (array<wk_widget> a);
00088 wk_widget horizontal_list (array<wk_widget> a, array<string> name);
00089 wk_widget vertical_list (array<wk_widget> a);
00090 wk_widget vertical_list (array<wk_widget> a, array<string> name);
00091 wk_widget vertical_menu (array<wk_widget> a);
00092 wk_widget tile (array<wk_widget> a, int cols);
00093 wk_widget tile (array<wk_widget> a, int cols, array<string> name);
00094 wk_widget aligned_widget (array<wk_widget> lhs, array<wk_widget> rhs,
00095                        SI hsep= 3*PIXEL, SI vsep= 3*PIXEL,
00096                           SI lpad= 0, SI rpad= 0);
00097 wk_widget horizontal_array (array<wk_widget> a, int stretch_me= -1);
00098 wk_widget horizontal_array (array<wk_widget> a, array<string> s,
00099                          int stretch_me= -1);
00100 wk_widget tabs_widget (array<wk_widget> tabs, array<wk_widget> bodies);
00101 wk_widget switch_widget (array<wk_widget> a, array<string> name, int init= 0);
00102 wk_widget optional_widget (wk_widget w, bool on= true);
00103 wk_widget wrapped_widget (wk_widget w, command cmd);
00104 wk_widget glue_wk_widget (bool hx=true, bool vx=true, SI w=0, SI h=0);
00105 wk_widget glue_wk_widget (tree c, bool hx=true, bool vx=true, SI w=0, SI h=0);
00106 wk_widget separator_wk_widget (SI pre=0, SI post=0, bool vert=false);
00107 wk_widget text_wk_widget (string s, int style= 0, bool tsp= false);
00108 wk_widget menu_text_wk_widget (string s, int style, color col,
00109                             bool tsp=true, bool tt= false);
00110 wk_widget xpm_wk_widget (url file_name, bool transp= true);
00111 wk_widget minibar_widget (wk_widget w);
00112 wk_widget command_button (wk_widget w, command cmd, int style= 0);
00113 wk_widget command_button (wk_widget lw, wk_widget rw, command cmd, int st= 0);
00114 wk_widget command_button (wk_widget lw, wk_widget cw, wk_widget rw,
00115                        command c, int style= 0);
00116 wk_widget pulldown_button (wk_widget w, wk_widget m, int style= 0);
00117 wk_widget pullright_button (wk_widget w, wk_widget m, int style= 0);
00118 wk_widget pulldown_button (wk_widget w, promise<wk_widget> pw);
00119 wk_widget pullright_button (wk_widget w, promise<wk_widget> pw);
00120 wk_widget toggle_wk_widget (command cmd, bool on= false, int style= 0);
00121 wk_widget popup_widget (wk_widget w, gravity quit=center);
00122 wk_widget canvas_widget (wk_widget w, gravity grav=north_west, bool rf= false);
00123 wk_widget user_canvas_widget (wk_widget wid, int style= 0);
00124 wk_widget resize_widget (wk_widget w, int style, string w1, string h1,
00125                          string w2, string h2, string w3, string h3);
00126 wk_widget hsplit_widget (wk_widget l, wk_widget r);
00127 wk_widget vsplit_widget (wk_widget t, wk_widget b);
00128 wk_widget input_text_wk_widget (command cb,
00129                             int style= 0, string w= "1w", bool pf= true);
00130 wk_widget input_text_wk_widget (command cb, string type, array<string> def,
00131                             int style= 0, string w= "1w", bool pf= false);
00132 wk_widget inputs_list_wk_widget (command call_back, array<string> prompts);
00133 wk_widget enum_wk_widget (command cb, array<string> vals, string cur,
00134                           int style= 0, string w= "1w");
00135 wk_widget choice_wk_widget (command cb, array<string> vals, string val);
00136 wk_widget choice_wk_widget (command cb, array<string> vals, array<string> mc);
00137 wk_widget file_chooser_wk_widget (command cmd, string type);
00138 wk_widget color_picker_wk_widget (command cmd, bool bg, array<tree> proposals);
00139 wk_widget balloon_widget (wk_widget w, wk_widget help);
00140 wk_widget wait_wk_widget (SI w, SI h, string message);
00141 wk_widget ink_wk_widget (command cb);
00142 wk_widget refresh_wk_widget (string tmwid);
00143 wk_widget texmacs_wk_widget (int mask, command quit);
00144 wk_widget plain_window_widget (wk_widget wid, string s, command q= command ());
00145 wk_widget popup_window_widget (wk_widget wid, string s);
00146 void      destroy_window_widget (wk_widget w);
00147 
00148 #endif // defined WK_WIDGET_H