Back to index

texmacs  1.0.7.15
event.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : event.hpp
00004 * DESCRIPTION: Abstract events
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 EVENT_H
00013 #define EVENT_H
00014 #include "widget.hpp"
00015 
00016 class wk_widget;
00017 class rectangle;
00018 template<class T> class list;
00019 typedef list<rectangle> rectangles;
00020 
00021 enum gravity { north_west, north,  north_east,
00022               west,       center, east,
00023               south_west, south,  south_east };
00024 
00025 /******************************************************************************
00026 * The event class
00027 ******************************************************************************/
00028 
00029 #define __EVENT_CLASS_MASK 0xffff0000
00030 
00031 extern int event_count;
00032 struct event_rep: public abstract_struct {
00033   int     type;  // the event type
00034   inline  event_rep (int type2): type (type2) { TM_DEBUG(event_count++); }
00035   inline  virtual ~event_rep () { TM_DEBUG(event_count--); }
00036   virtual operator tree () = 0;   // for displaying events (debugging)
00037 };
00038 
00039 struct event {
00040 ABSTRACT(event);            
00041   inline operator tree () { return (tree) (*rep); }
00042   friend class event_ptr_base;
00043 };
00044 ABSTRACT_CODE(event);
00045 
00046 inline tm_ostream& operator << (tm_ostream& out, event ev) {
00047   return out << ((tree) ev); }
00048 
00049 /******************************************************************************
00050 * User interface
00051 ******************************************************************************/
00052 
00053 /*** basic events ***/
00054 event get_size (SI& w, SI& h, int mode=0);
00055 event get_widget (string which, wk_widget& w);
00056 event set_widget (string which, wk_widget w);
00057 event emit_attach_window (window win);
00058 event emit_reposition ();
00059 event emit_position (SI ox, SI oy, SI w, SI h, gravity grav=north_west);
00060 event emit_move ();
00061 event emit_resize ();
00062 event emit_destroy ();
00063 event emit_keypress (string key, time_t t);
00064 event emit_keyboard_focus (bool in_out_flag, time_t t=0);
00065 event emit_mouse (string type, SI x, SI y, int mods, time_t t);
00066 event emit_alarm (string message, time_t t);
00067 event emit_clear (SI x1, SI y1, SI x2, SI y2);
00068 event emit_repaint (SI x1, SI y1, SI x2, SI y2, bool& stop);
00069 event emit_update ();
00070 event emit_refresh ();
00071 event emit_invalidate_all ();
00072 event emit_invalidate (SI x1, SI y1, SI x2, SI y2);
00073 event emit_keyboard_grab (bool in_out_flag, time_t t=0);
00074 event emit_mouse_grab (bool in_out_flag, time_t t=0);
00075 event emit_request_alarm (event ev, time_t delay);
00076 event emit_find_child (SI x, SI y, int& which);
00077 
00078 /*** composite events ***/
00079 event emit_clean ();
00080 event emit_insert (string where, wk_widget wid);
00081 event emit_remove (string where);
00082 
00083 /*** attribute events ***/
00084 event get_integer (string which, int& i);
00085 event get_double  (string which, double& d);
00086 event get_string  (string which, string& s);
00087 event get_coord1  (string which, SI& c1);
00088 event get_coord2  (string which, SI& c1, SI& c2);
00089 event get_coord3  (string which, SI& c1, SI& c2, SI& c3);
00090 event get_coord4  (string which, SI& c1, SI& c2, SI& c3, SI& c4);
00091 event set_integer (string which, int i);
00092 event set_double  (string which, double d);
00093 event set_string  (string which, string s);
00094 event set_coord1  (string which, SI c1);
00095 event set_coord2  (string which, SI c1, SI c2);
00096 event set_coord3  (string which, SI c1, SI c2, SI c3);
00097 event set_coord4  (string which, SI c1, SI c2, SI c3, SI c4);
00098 
00099 /*** scroll events ***/
00100 event set_scrollable (wk_widget w);
00101 event set_extents    (SI x1, SI y1, SI x2, SI y2);
00102 event set_scroll_pos (SI x, SI y);
00103 event get_visible    (SI& x1, SI& y1, SI& x2, SI& y2);
00104 event get_extents    (SI& x1, SI& y1, SI& x2, SI& y2);
00105 event get_scroll_pos (SI& x, SI& y);
00106 
00107 /*** user input events ***/
00108 event set_input_string (string s);
00109 event get_input_string (string& s);
00110 
00111 #endif // defined EVENT_H