Back to index

texmacs  1.0.7.15
scroll_widget.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : scroll_widget.hpp
00004 * DESCRIPTION: Scrollable 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 SCROLL_WIDGET_H
00013 #define SCROLL_WIDGET_H
00014 #include "Widkit/attribute_widget.hpp"
00015 #include "Widkit/Event/scroll_event.hpp"
00016 
00017 /******************************************************************************
00018 * Scroll widgets
00019 ******************************************************************************/
00020 
00021 class scroll_widget_rep: public attribute_widget_rep {
00022 public:
00023   scroll_widget_rep (array<wk_widget> a, gravity grav);
00024   virtual void handle_scroll (scroll_event ev) = 0;
00025   virtual bool handle (event ev);
00026 };
00027 
00028 /******************************************************************************
00029 * Scrollable widgets
00030 ******************************************************************************/
00031 
00032 class scrollable_widget_rep: public scroll_widget_rep {
00033   SI             scx, scy;    // scroll x,y position
00034   SI             ex1, ey1;    // extents of scrolled window lo-left
00035   SI             ex2, ey2;    // extents of scrolled window hi-right
00036   wk_widget_rep* hor;         // the horizontal scroll bar
00037   wk_widget_rep* ver;         // the vertical scroll bar
00038   gravity        backup;      // for a dirty bugfix
00039 
00040   void scroll_to (SI scx, SI scy);
00041   void set_extents (SI ex1, SI ey1, SI ex2, SI ey2);
00042   void scroll_event_hor (SI& x, SI& before, SI& after);
00043   void scroll_event_ver (SI& y, SI& before, SI& after);
00044 
00045 public:
00046   scrollable_widget_rep (wk_widget child, gravity grav);
00047   operator tree ();
00048 
00049   void handle_get_size   (get_size_event ev);
00050   void handle_position   (position_event ev);
00051   void handle_set_widget (set_widget_event ev);
00052   void handle_get_coord1 (get_coord1_event ev);
00053   void handle_get_coord2 (get_coord2_event ev);
00054   void handle_get_coord4 (get_coord4_event ev);
00055   void handle_set_coord2 (set_coord2_event ev);
00056   void handle_set_coord4 (set_coord4_event ev);
00057   void handle_scroll     (scroll_event ev);
00058 };
00059 
00060 /******************************************************************************
00061 * Abstract scrollbars
00062 ******************************************************************************/
00063 
00064 class scrollbar_rep: public scroll_widget_rep {
00065 protected:
00066   wk_widget_rep* ref;
00067   SI                 sc_min, sc_max, sc_pos, before, after;
00068   double             factor;
00069   bool               gripped;
00070   bool               scrolling;
00071   int                increment;
00072 
00073 public:
00074   scrollbar_rep (wk_widget ref);
00075 
00076   void handle_set_coord1 (set_coord1_event ev);
00077   void handle_set_coord2 (set_coord2_event ev);
00078 };
00079 
00080 /******************************************************************************
00081 * Horizontal scrollbars
00082 ******************************************************************************/
00083 
00084 class hor_scrollbar_widget_rep: public scrollbar_rep {
00085   void decode_position (SI& x1, SI& x2);
00086   SI   encode_position (SI x);
00087 
00088 public:
00089   hor_scrollbar_widget_rep (wk_widget ref);
00090   operator tree ();
00091 
00092   void handle_get_size (get_size_event ev);
00093   void handle_repaint (repaint_event ev);
00094   void handle_mouse (mouse_event ev);
00095   void handle_scroll (scroll_event ev);
00096   void handle_alarm (alarm_event ev);
00097 };
00098 
00099 /******************************************************************************
00100 * Vertical scrollbars
00101 ******************************************************************************/
00102 
00103 class ver_scrollbar_widget_rep: public scrollbar_rep {
00104   void decode_position (SI& y1, SI& y2);
00105   SI   encode_position (SI y);
00106 
00107 public:
00108   ver_scrollbar_widget_rep (wk_widget ref);
00109   operator tree ();
00110 
00111   void handle_get_size (get_size_event ev);
00112   void handle_repaint (repaint_event ev);
00113   void handle_mouse (mouse_event ev);
00114   void handle_scroll (scroll_event ev);
00115   void handle_alarm (alarm_event ev);
00116 };
00117 
00118 #endif // defined SCROLL_WIDGET_H