PageRenderTime 51ms CodeModel.GetById 21ms app.highlight 25ms RepoModel.GetById 1ms app.codeStats 0ms

/TeXmacs-1.0.7.11-src/src/Plugins/Widkit/Attribute/attribute_widget.cpp

#
C++ | 174 lines | 128 code | 24 blank | 22 comment | 9 complexity | b99d8345518b55d7ab16ae36664cd4d3 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception
  1
  2/******************************************************************************
  3* MODULE     : attribute_widget.cpp
  4* DESCRIPTION: Abstract attribute widgets accept events for
  5*              setting and retrieving attributes of a widget
  6* COPYRIGHT  : (C) 1999  Joris van der Hoeven
  7*******************************************************************************
  8* This software falls under the GNU general public license version 3 or later.
  9* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 10* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
 11******************************************************************************/
 12
 13#include "Widkit/attribute_widget.hpp"
 14
 15/******************************************************************************
 16* Constructors for abstract attribute widgets
 17******************************************************************************/
 18
 19attribute_widget_rep::attribute_widget_rep (gravity grav):
 20  basic_widget_rep (grav) {}
 21attribute_widget_rep::attribute_widget_rep (
 22  array<wk_widget> a, gravity grav):
 23    basic_widget_rep (a, grav) {}
 24attribute_widget_rep::attribute_widget_rep (
 25  array<wk_widget> a, array<string> name, gravity grav):
 26    basic_widget_rep (a, name, grav) {}
 27
 28/******************************************************************************
 29* Retrieving information from attribute widgets
 30******************************************************************************/
 31
 32void
 33attribute_widget_rep::handle_get_integer (get_integer_event ev) {
 34  WK_FAILED ("could not get integer attribute " * ev->which);
 35}
 36
 37void
 38attribute_widget_rep::handle_get_double (get_double_event ev) {
 39  WK_FAILED ("could not get double attribute " * ev->which);
 40}
 41
 42void
 43attribute_widget_rep::handle_get_string (get_string_event ev) {
 44  WK_FAILED ("could not get string attribute " * ev->which);
 45}
 46
 47void
 48attribute_widget_rep::handle_get_coord1 (get_coord1_event ev) {
 49  WK_FAILED ("could not get coord1 attribute " * ev->which);
 50}
 51
 52void
 53attribute_widget_rep::handle_get_coord2 (get_coord2_event ev) {
 54  WK_FAILED ("could not get coord2 attribute " * ev->which);
 55}
 56
 57void
 58attribute_widget_rep::handle_get_coord3 (get_coord3_event ev) {
 59  WK_FAILED ("could not get coord3 attribute " * ev->which);
 60}
 61
 62void
 63attribute_widget_rep::handle_get_coord4 (get_coord4_event ev) {
 64  WK_FAILED ("could not get coord4 attribute " * ev->which);
 65}
 66
 67/******************************************************************************
 68* Setting attributes of attribute widgets
 69******************************************************************************/
 70
 71void
 72attribute_widget_rep::handle_set_integer (set_integer_event ev) {
 73  WK_FAILED ("could not set integer attribute " * ev->which);
 74}
 75
 76void
 77attribute_widget_rep::handle_set_double (set_double_event ev) {
 78  WK_FAILED ("could not set double attribute " * ev->which);
 79}
 80
 81void
 82attribute_widget_rep::handle_set_string (set_string_event ev) {
 83  WK_FAILED ("could not set string attribute " * ev->which);
 84}
 85
 86void
 87attribute_widget_rep::handle_set_coord1 (set_coord1_event ev) {
 88  WK_FAILED ("could not set coord1 attribute " * ev->which);
 89}
 90
 91void
 92attribute_widget_rep::handle_set_coord2 (set_coord2_event ev) {
 93  WK_FAILED ("could not set coord2 attribute " * ev->which);
 94}
 95
 96void
 97attribute_widget_rep::handle_set_coord3 (set_coord3_event ev) {
 98  WK_FAILED ("could not set coord3 attribute " * ev->which);
 99}
100
101void
102attribute_widget_rep::handle_set_coord4 (set_coord4_event ev) {
103  WK_FAILED ("could not set coord4 attribute " * ev->which);
104}
105
106/******************************************************************************
107* The main event handler
108******************************************************************************/
109
110bool
111is_extra_width_event (event ev) {
112  if (ev->type == GET_COORD2_EVENT) {
113    get_coord2_event e (ev);
114    return e->which == "extra width";
115  }
116  if (ev->type == SET_COORD2_EVENT) {
117    set_coord2_event e (ev);
118    return e->which == "extra width";
119  }
120  return false;
121}
122
123bool
124attribute_widget_rep::handle (event ev) {
125  if (!is_extra_width_event (ev))
126    if (basic_widget_rep::handle (ev))
127      return true;
128  switch (ev->type) {
129  case GET_INTEGER_EVENT:
130    handle_get_integer (ev);
131    return true;
132  case GET_DOUBLE_EVENT:
133    handle_get_double (ev);
134    return true;
135  case GET_STRING_EVENT:
136    handle_get_string (ev);
137    return true;
138  case GET_COORD1_EVENT:
139    handle_get_coord1 (ev);
140    return true;
141  case GET_COORD2_EVENT:
142    handle_get_coord2 (ev);
143    return true;
144  case GET_COORD3_EVENT:
145    handle_get_coord3 (ev);
146    return true;
147  case GET_COORD4_EVENT:
148    handle_get_coord4 (ev);
149    return true;
150
151  case SET_INTEGER_EVENT:
152    handle_set_integer (ev);
153    return true;
154  case SET_DOUBLE_EVENT:
155    handle_set_double (ev);
156    return true;
157  case SET_STRING_EVENT:
158    handle_set_string (ev);
159    return true;
160  case SET_COORD1_EVENT:
161    handle_set_coord1 (ev);
162    return true;
163  case SET_COORD2_EVENT:
164    handle_set_coord2 (ev);
165    return true;
166  case SET_COORD3_EVENT:
167    handle_set_coord3 (ev);
168    return true;
169  case SET_COORD4_EVENT:
170    handle_set_coord4 (ev);
171    return true;
172  }
173  return false;
174}