lwlib.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. Copyright (C) 1992, 1993 Lucid, Inc.
  3. Copyright (C) 1994, 1999-2012 Free Software Foundation, Inc.
  4. This file is part of the Lucid Widget Library.
  5. The Lucid Widget Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 1, or (at your option)
  8. any later version.
  9. The Lucid Widget Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Emacs; see the file COPYING. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. #ifndef LWLIB_H
  18. #define LWLIB_H
  19. #include <X11/Intrinsic.h>
  20. /*
  21. ** Widget values depend on the Widget type:
  22. **
  23. ** widget: (name value key enabled data contents/selected)
  24. **
  25. ** label: ("name" "string" NULL NULL NULL NULL)
  26. ** button: ("name" "string" "key" T/F data <default-button-p>)
  27. ** button w/menu:
  28. ** ("name" "string" "key" T/F data (label|button|button w/menu...))
  29. ** menubar: ("name" NULL NULL T/F data (button w/menu))
  30. ** selectable thing:
  31. ** ("name" "string" "key" T/F data T/F)
  32. ** checkbox: selectable thing
  33. ** radio: ("name" NULL NULL T/F data (selectable thing...))
  34. ** strings: ("name" NULL NULL T/F data (selectable thing...))
  35. ** text: ("name" "string" <ign> T/F data)
  36. ** main: ("name")
  37. */
  38. typedef unsigned long LWLIB_ID;
  39. typedef enum _change_type
  40. {
  41. NO_CHANGE = 0,
  42. INVISIBLE_CHANGE = 1,
  43. VISIBLE_CHANGE = 2,
  44. STRUCTURAL_CHANGE = 3
  45. } change_type;
  46. enum button_type
  47. {
  48. BUTTON_TYPE_NONE,
  49. BUTTON_TYPE_TOGGLE,
  50. BUTTON_TYPE_RADIO
  51. };
  52. /* Menu separator types. */
  53. enum menu_separator
  54. {
  55. /* These values are Motif compatible. */
  56. SEPARATOR_NO_LINE,
  57. SEPARATOR_SINGLE_LINE,
  58. SEPARATOR_DOUBLE_LINE,
  59. SEPARATOR_SINGLE_DASHED_LINE,
  60. SEPARATOR_DOUBLE_DASHED_LINE,
  61. SEPARATOR_SHADOW_ETCHED_IN,
  62. SEPARATOR_SHADOW_ETCHED_OUT,
  63. SEPARATOR_SHADOW_ETCHED_IN_DASH,
  64. SEPARATOR_SHADOW_ETCHED_OUT_DASH,
  65. /* The following are supported by Lucid menus. */
  66. SEPARATOR_SHADOW_DOUBLE_ETCHED_IN,
  67. SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT,
  68. SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH,
  69. SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH
  70. };
  71. typedef struct _widget_value
  72. {
  73. /* name of widget */
  74. Lisp_Object lname;
  75. char* name;
  76. /* value (meaning depend on widget type) */
  77. char* value;
  78. /* keyboard equivalent. no implications for XtTranslations */
  79. Lisp_Object lkey;
  80. char* key;
  81. /* Help string or nil if none.
  82. GC finds this string through the frame's menu_bar_vector
  83. or through menu_items. */
  84. Lisp_Object help;
  85. /* true if enabled */
  86. Boolean enabled;
  87. /* true if selected */
  88. Boolean selected;
  89. /* true if was edited (maintained by get_value) */
  90. Boolean edited;
  91. /* The type of a button. */
  92. enum button_type button_type;
  93. /* true if has changed (maintained by lw library) */
  94. change_type change;
  95. /* true if this widget itself has changed,
  96. but not counting the other widgets found in the `next' field. */
  97. change_type this_one_change;
  98. /* Contents of the sub-widgets, also selected slot for checkbox */
  99. struct _widget_value* contents;
  100. /* data passed to callback */
  101. XtPointer call_data;
  102. /* next one in the list */
  103. struct _widget_value* next;
  104. /* slot for the toolkit dependent part. Always initialize to NULL. */
  105. void* toolkit_data;
  106. /* tell us if we should free the toolkit data slot when freeing the
  107. widget_value itself. */
  108. Boolean free_toolkit_data;
  109. /* we resource the widget_value structures; this points to the next
  110. one on the free list if this one has been deallocated.
  111. */
  112. struct _widget_value *free_list;
  113. } widget_value;
  114. typedef void (*lw_callback) (Widget w, LWLIB_ID id, void* data);
  115. void lw_register_widget (const char* type, const char* name, LWLIB_ID id,
  116. widget_value* val, lw_callback pre_activate_cb,
  117. lw_callback selection_cb,
  118. lw_callback post_activate_cb,
  119. lw_callback highlight_cb);
  120. Widget lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
  121. Widget lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
  122. Widget lw_create_widget (const char* type, const char* name, LWLIB_ID id,
  123. widget_value* val, Widget parent, Boolean pop_up_p,
  124. lw_callback pre_activate_cb,
  125. lw_callback selection_cb,
  126. lw_callback post_activate_cb,
  127. lw_callback highlight_cb);
  128. LWLIB_ID lw_get_widget_id (Widget w);
  129. int lw_modify_all_widgets (LWLIB_ID id, widget_value* val, Boolean deep_p);
  130. void lw_destroy_widget (Widget w);
  131. void lw_destroy_all_widgets (LWLIB_ID id);
  132. void lw_destroy_everything (void);
  133. void lw_destroy_all_pop_ups (void);
  134. Widget lw_raise_all_pop_up_widgets (void);
  135. widget_value* lw_get_all_values (LWLIB_ID id);
  136. Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
  137. void lw_pop_up_all_widgets (LWLIB_ID id);
  138. void lw_pop_down_all_widgets (LWLIB_ID id);
  139. widget_value *malloc_widget_value (void);
  140. void free_widget_value (widget_value *);
  141. void lw_popup_menu (Widget, XEvent *);
  142. /* Toolkit independent way of focusing on a Widget at the Xt level. */
  143. void lw_set_keyboard_focus (Widget parent, Widget w);
  144. /* Silly Energize hack to invert the "sheet" button */
  145. void lw_show_busy (Widget w, Boolean busy);
  146. /* Silly hack to assist with Lucid/Athena geometry management. */
  147. void lw_refigure_widget (Widget w, Boolean doit);
  148. /* Toolkit independent way of determining if an event occurred on a
  149. menubar. */
  150. Boolean lw_window_is_in_menubar (Window win, Widget menubar_widget);
  151. /* Manage resizing: TRUE permits resizing widget w; FALSE disallows it. */
  152. void lw_allow_resizing (Widget w, Boolean flag);
  153. /* Set up the main window. */
  154. void lw_set_main_areas (Widget parent,
  155. Widget menubar,
  156. Widget work_area);
  157. /* Value is non-zero if LABEL is a menu separator. If it is, *TYPE is
  158. set to an appropriate enumerator of type enum menu_separator.
  159. MOTIF_P non-zero means map separator types not supported by Motif
  160. to similar ones that are supported. */
  161. int lw_separator_p (const char *label, enum menu_separator *type,
  162. int motif_p);
  163. #endif /* LWLIB_H */