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