Back to index

texmacs  1.0.7.15
minibar_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : minibar_widget.cpp
00004 * DESCRIPTION: Simple transparent buttons
00005 * COPYRIGHT  : (C) 2010  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 "window.hpp"
00013 #include "Widkit/attribute_widget.hpp"
00014 #include "Widkit/layout.hpp"
00015 
00016 /******************************************************************************
00017 * Balloon widgets
00018 ******************************************************************************/
00019 
00020 class minibar_widget_rep: public attribute_widget_rep {
00021 public:
00022   minibar_widget_rep (wk_widget w);
00023   operator tree ();
00024   void handle_get_size (get_size_event ev);
00025   void handle_position (position_event ev);
00026   void handle_repaint (repaint_event ev);
00027   bool handle (event ev);
00028 };
00029 
00030 /******************************************************************************
00031 * Implementation of balloon widgets
00032 ******************************************************************************/
00033 
00034 minibar_widget_rep::minibar_widget_rep (wk_widget w):
00035   attribute_widget_rep (1, south_west)
00036 {
00037   a[0]= w;
00038 }
00039 
00040 minibar_widget_rep::operator tree () {
00041   return tree (TUPLE, "transparent button", (tree) a[0]);
00042 }
00043 
00044 void
00045 minibar_widget_rep::handle_get_size (get_size_event ev) {
00046   attribute_widget_rep::handle_get_size (ev);
00047   ev->w += 2*PIXEL;
00048   ev->h += 2*PIXEL;
00049 }
00050 
00051 void
00052 minibar_widget_rep::handle_position (position_event ev) {
00053   (event) ev;
00054   SI ww= w-2*PIXEL;
00055   SI hh= h-2*PIXEL;
00056   a[0] << emit_position (PIXEL, PIXEL, ww, hh, south_west);
00057 }
00058 
00059 void
00060 minibar_widget_rep::handle_repaint (repaint_event ev) {
00061   (void) ev;
00062   renderer ren= win->get_renderer ();
00063   layout_higher (ren, 0, 0, w, h);
00064 }
00065 
00066 bool
00067 minibar_widget_rep::handle (event ev) {
00068   switch (ev->type) {
00069   case MOUSE_EVENT:
00070   case GET_SIZE_EVENT:
00071   case SET_WIDGET_EVENT:
00072   case ATTACH_WINDOW_EVENT:
00073   case POSITION_EVENT:
00074   case UPDATE_EVENT:
00075   case INVALIDATE_EVENT:
00076   case REPAINT_EVENT:
00077   case FIND_CHILD_EVENT:
00078     return attribute_widget_rep::handle (ev);
00079   default:
00080     a[0] << ev;
00081     return true;
00082   }
00083 }
00084 
00085 /******************************************************************************
00086 * exported routines
00087 ******************************************************************************/
00088 
00089 wk_widget
00090 minibar_widget (wk_widget w) {
00091   return tm_new<minibar_widget_rep> (w);
00092 }