Back to index

texmacs  1.0.7.15
attribute_widget.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : attribute_widget.cpp
00004 * DESCRIPTION: Abstract attribute widgets accept events for
00005 *              setting and retrieving attributes 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/attribute_widget.hpp"
00014 
00015 /******************************************************************************
00016 * Constructors for abstract attribute widgets
00017 ******************************************************************************/
00018 
00019 attribute_widget_rep::attribute_widget_rep (gravity grav):
00020   basic_widget_rep (grav) {}
00021 attribute_widget_rep::attribute_widget_rep (
00022   array<wk_widget> a, gravity grav):
00023     basic_widget_rep (a, grav) {}
00024 attribute_widget_rep::attribute_widget_rep (
00025   array<wk_widget> a, array<string> name, gravity grav):
00026     basic_widget_rep (a, name, grav) {}
00027 
00028 /******************************************************************************
00029 * Retrieving information from attribute widgets
00030 ******************************************************************************/
00031 
00032 void
00033 attribute_widget_rep::handle_get_integer (get_integer_event ev) {
00034   WK_FAILED ("could not get integer attribute " * ev->which);
00035 }
00036 
00037 void
00038 attribute_widget_rep::handle_get_double (get_double_event ev) {
00039   WK_FAILED ("could not get double attribute " * ev->which);
00040 }
00041 
00042 void
00043 attribute_widget_rep::handle_get_string (get_string_event ev) {
00044   WK_FAILED ("could not get string attribute " * ev->which);
00045 }
00046 
00047 void
00048 attribute_widget_rep::handle_get_coord1 (get_coord1_event ev) {
00049   WK_FAILED ("could not get coord1 attribute " * ev->which);
00050 }
00051 
00052 void
00053 attribute_widget_rep::handle_get_coord2 (get_coord2_event ev) {
00054   WK_FAILED ("could not get coord2 attribute " * ev->which);
00055 }
00056 
00057 void
00058 attribute_widget_rep::handle_get_coord3 (get_coord3_event ev) {
00059   WK_FAILED ("could not get coord3 attribute " * ev->which);
00060 }
00061 
00062 void
00063 attribute_widget_rep::handle_get_coord4 (get_coord4_event ev) {
00064   WK_FAILED ("could not get coord4 attribute " * ev->which);
00065 }
00066 
00067 /******************************************************************************
00068 * Setting attributes of attribute widgets
00069 ******************************************************************************/
00070 
00071 void
00072 attribute_widget_rep::handle_set_integer (set_integer_event ev) {
00073   WK_FAILED ("could not set integer attribute " * ev->which);
00074 }
00075 
00076 void
00077 attribute_widget_rep::handle_set_double (set_double_event ev) {
00078   WK_FAILED ("could not set double attribute " * ev->which);
00079 }
00080 
00081 void
00082 attribute_widget_rep::handle_set_string (set_string_event ev) {
00083   WK_FAILED ("could not set string attribute " * ev->which);
00084 }
00085 
00086 void
00087 attribute_widget_rep::handle_set_coord1 (set_coord1_event ev) {
00088   WK_FAILED ("could not set coord1 attribute " * ev->which);
00089 }
00090 
00091 void
00092 attribute_widget_rep::handle_set_coord2 (set_coord2_event ev) {
00093   WK_FAILED ("could not set coord2 attribute " * ev->which);
00094 }
00095 
00096 void
00097 attribute_widget_rep::handle_set_coord3 (set_coord3_event ev) {
00098   WK_FAILED ("could not set coord3 attribute " * ev->which);
00099 }
00100 
00101 void
00102 attribute_widget_rep::handle_set_coord4 (set_coord4_event ev) {
00103   WK_FAILED ("could not set coord4 attribute " * ev->which);
00104 }
00105 
00106 /******************************************************************************
00107 * The main event handler
00108 ******************************************************************************/
00109 
00110 bool
00111 is_extra_width_event (event ev) {
00112   if (ev->type == GET_COORD2_EVENT) {
00113     get_coord2_event e (ev);
00114     return e->which == "extra width";
00115   }
00116   if (ev->type == SET_COORD2_EVENT) {
00117     set_coord2_event e (ev);
00118     return e->which == "extra width";
00119   }
00120   return false;
00121 }
00122 
00123 bool
00124 attribute_widget_rep::handle (event ev) {
00125   if (!is_extra_width_event (ev))
00126     if (basic_widget_rep::handle (ev))
00127       return true;
00128   switch (ev->type) {
00129   case GET_INTEGER_EVENT:
00130     handle_get_integer (ev);
00131     return true;
00132   case GET_DOUBLE_EVENT:
00133     handle_get_double (ev);
00134     return true;
00135   case GET_STRING_EVENT:
00136     handle_get_string (ev);
00137     return true;
00138   case GET_COORD1_EVENT:
00139     handle_get_coord1 (ev);
00140     return true;
00141   case GET_COORD2_EVENT:
00142     handle_get_coord2 (ev);
00143     return true;
00144   case GET_COORD3_EVENT:
00145     handle_get_coord3 (ev);
00146     return true;
00147   case GET_COORD4_EVENT:
00148     handle_get_coord4 (ev);
00149     return true;
00150 
00151   case SET_INTEGER_EVENT:
00152     handle_set_integer (ev);
00153     return true;
00154   case SET_DOUBLE_EVENT:
00155     handle_set_double (ev);
00156     return true;
00157   case SET_STRING_EVENT:
00158     handle_set_string (ev);
00159     return true;
00160   case SET_COORD1_EVENT:
00161     handle_set_coord1 (ev);
00162     return true;
00163   case SET_COORD2_EVENT:
00164     handle_set_coord2 (ev);
00165     return true;
00166   case SET_COORD3_EVENT:
00167     handle_set_coord3 (ev);
00168     return true;
00169   case SET_COORD4_EVENT:
00170     handle_set_coord4 (ev);
00171     return true;
00172   }
00173   return false;
00174 }