Back to index

texmacs  1.0.7.15
composite_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : composite_widget.cpp
00004 * DESCRIPTION: abstract composite widgets accept events for
00005 *              modifying the composite structure of a widget.
00006 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00007 *******************************************************************************
00008 * This software falls under the GNU general public license version 3 or later.
00009 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00010 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00011 ******************************************************************************/
00012 
00013 #include "Widkit/layout.hpp"
00014 #include "Widkit/composite_widget.hpp"
00015 
00016 /******************************************************************************
00017 * Routines for abstract composite widgets
00018 ******************************************************************************/
00019 
00020 composite_widget_rep::composite_widget_rep (gravity grav):
00021   basic_widget_rep (grav) {}
00022 composite_widget_rep::composite_widget_rep (
00023   array<wk_widget> a, gravity grav):
00024     basic_widget_rep (a, grav) {}
00025 composite_widget_rep::composite_widget_rep (
00026   array<wk_widget> a, array<string> name, gravity grav):
00027     basic_widget_rep (a, name, grav) {}
00028 
00029 void
00030 composite_widget_rep::handle_clean (clean_event ev) { (void) ev;
00031   a->resize (0);
00032   name->resize (0);
00033 }
00034 
00035 void
00036 composite_widget_rep::handle_insert (insert_event ev) {
00037   a << ev->w;
00038   name << ev->s;
00039 }
00040 
00041 void
00042 composite_widget_rep::handle_remove (remove_event ev) {
00043   int i, j, n= N(a);
00044   for (i=0; i<n; i++)
00045     if (name[i] == ev->s) {
00046       for (j=i; j<n-1; j++) {
00047        a[j]= a[j+1];
00048        name[j]= name[j+1];
00049       }
00050       a->resize (n-1);
00051       name->resize (n-1);
00052       return;
00053     }
00054 }
00055 
00056 bool
00057 composite_widget_rep::handle (event ev) {
00058   switch (ev->type) {
00059   case CLEAN_EVENT:
00060     handle_clean (ev);
00061     return true;
00062   case INSERT_EVENT:
00063     handle_insert (ev);
00064     return true;
00065   case REMOVE_EVENT:
00066     handle_remove (ev);
00067     return true;
00068   }
00069   return basic_widget_rep::handle (ev);
00070 }