Back to index

texmacs  1.0.7.15
separator_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : separator_widget.cpp
00004 * DESCRIPTION: Widgets for filling up space between a group of 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 #include "gui.hpp"
00013 #include "renderer.hpp"
00014 #include "window.hpp"
00015 #include "Widkit/attribute_widget.hpp"
00016 #include "Widkit/layout.hpp"
00017 
00018 /******************************************************************************
00019 * Glue widgets
00020 ******************************************************************************/
00021 
00022 class separator_widget_rep: public attribute_widget_rep {
00023   SI   pre, post;
00024   bool vert;
00025 
00026 public:
00027   separator_widget_rep (SI pre, SI post, bool vert);
00028   operator tree ();
00029 
00030   void handle_get_size (get_size_event ev);
00031   void handle_repaint (repaint_event ev);
00032   void handle_get_coord2 (get_coord2_event ev);
00033   void handle_set_coord2 (set_coord2_event ev);
00034 };
00035 
00036 separator_widget_rep::separator_widget_rep (
00037   SI pre2, SI post2, bool vert2):
00038     attribute_widget_rep (), pre (pre2), post (post2), vert (vert2) {}
00039 
00040 separator_widget_rep::operator tree () {
00041   return "separator";
00042 }
00043 
00044 void
00045 separator_widget_rep::handle_get_size (get_size_event ev) {
00046   if (vert) {
00047     if (ev->mode==1) gui_maximal_extents (ev->w, ev->h);
00048     ev->w= 2*PIXEL+ pre+ post;
00049     ev->h= 0;
00050   }
00051   else {
00052     if (ev->mode==-1) ev->w= 0;
00053     if (ev->mode==1) gui_maximal_extents (ev->w, ev->h);
00054     ev->h= 2*PIXEL+ pre+ post;
00055   }
00056 }
00057 
00058 void
00059 separator_widget_rep::handle_repaint (repaint_event ev) {
00060   renderer ren= win->get_renderer ();
00061   layout_default (ren, ev->x1, ev->y1, ev->x2, ev->y2);
00062   ren->set_color (layout_dark (ren));
00063   ren->set_line_style (PIXEL);
00064   if (vert) ren->line (pre+PIXEL, ev->y1, pre+PIXEL, ev->y2);
00065   else ren->line (ev->x1, -pre-PIXEL, ev->x2, -pre-PIXEL);
00066   ren->set_color (white);
00067   ren->set_line_style (PIXEL);
00068   if (vert) ren->line (pre+2*PIXEL, ev->y1, pre+2*PIXEL, ev->y2);
00069   else ren->line (ev->x1, -pre-2*PIXEL, ev->x2, -pre-2*PIXEL);
00070 }
00071 
00072 void
00073 separator_widget_rep::handle_get_coord2 (get_coord2_event ev) {
00074   if (ev->which != "extra width") attribute_widget_rep::handle_get_coord2 (ev);
00075   else { ev->c1= 0; ev->c2= 0; }
00076 }
00077 
00078 void
00079 separator_widget_rep::handle_set_coord2 (set_coord2_event ev) {
00080   if (ev->which != "extra width") attribute_widget_rep::handle_set_coord2 (ev);
00081 }
00082 
00083 /******************************************************************************
00084 * Interface
00085 ******************************************************************************/
00086 
00087 wk_widget
00088 separator_wk_widget (SI pre, SI post, bool vert) {
00089   return tm_new<separator_widget_rep> (pre, post, vert);
00090 }