ComboBoxP.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: ComboBoxP.h /main/3 1995/10/26 09:29:58 rswiston $ */
  24. /*
  25. * DtWidget/ComboBoxP.h
  26. */
  27. /*
  28. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  29. * (c) Copyright 1993, 1994 International Business Machines Corp.
  30. * (c) Copyright 1993, 1994 Novell, Inc.
  31. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  32. */
  33. /***********************************************************
  34. Copyright 1993 Interleaf, Inc.
  35. Permission to use, copy, modify, and distribute this software
  36. and its documentation for any purpose without fee is granted,
  37. provided that the above copyright notice appear in all copies
  38. and that both copyright notice and this permission notice appear
  39. in supporting documentation, and that the name of Interleaf not
  40. be used in advertising or publicly pertaining to distribution of
  41. the software without specific written prior permission.
  42. Interleaf makes no representation about the suitability of this
  43. software for any purpose. It is provided "AS IS" without any
  44. express or implied warranty.
  45. ******************************************************************/
  46. /*
  47. * (C) Copyright 1991,1992, 1993
  48. * Interleaf, Inc.
  49. * Nine Hillside Avenue, Waltham, MA 02154
  50. *
  51. * ComboBoxP.h:
  52. *
  53. * Private header file for DtComboBoxWidget.
  54. */
  55. #ifndef _ComboBoxP_h
  56. #define _ComboBoxP_h
  57. #include <X11/IntrinsicP.h>
  58. #include <X11/ShellP.h>
  59. #include <Xm/DrawnB.h>
  60. #include <Xm/ArrowB.h>
  61. #undef USE_XFT
  62. #include <Xm/TextFP.h>
  63. #include <Xm/Label.h>
  64. #include <Xm/Frame.h>
  65. #include <Xm/ListP.h>
  66. #include <Xm/Separator.h>
  67. #include <Xm/ScrolledWP.h>
  68. #include <Xm/ScrollBarP.h>
  69. #include <Xm/ManagerP.h>
  70. #include "ComboBox.h"
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. /*
  75. * External definitions of syn_resources for our list widget.
  76. */
  77. #define SYN_RESOURCE_AA (Widget w, int resource_offset, XtArgVal *value)
  78. extern void _DtComboBoxGetArrowSize SYN_RESOURCE_AA;
  79. extern void _DtComboBoxGetLabelString SYN_RESOURCE_AA;
  80. extern void _DtComboBoxGetListItemCount SYN_RESOURCE_AA;
  81. extern void _DtComboBoxGetListItems SYN_RESOURCE_AA;
  82. extern void _DtComboBoxGetListFontList SYN_RESOURCE_AA;
  83. extern void _DtComboBoxGetListMarginHeight SYN_RESOURCE_AA;
  84. extern void _DtComboBoxGetListMarginWidth SYN_RESOURCE_AA;
  85. extern void _DtComboBoxGetListSpacing SYN_RESOURCE_AA;
  86. extern void _DtComboBoxGetListTopItemPosition SYN_RESOURCE_AA;
  87. extern void _DtComboBoxGetListVisibleItemCount SYN_RESOURCE_AA;
  88. #define ARROW_MULT .45
  89. #define ARROW_MIN 13
  90. #define MARGIN 2
  91. #define LABEL_PADDING 2
  92. #define LABEL_SHADOW 2
  93. #define TEXT_FIELD_SHADOW 1
  94. #define TEXT_CONTEXT_MARGIN 4
  95. /****************************************************************
  96. *
  97. * Message Defines
  98. *
  99. ****************************************************************/
  100. #define CB_ALIGNMENT DTWIDGET_GETMESSAGE( \
  101. MS_ComboBox, COMBO_ALIGNMENT, _DtMsgComboBox_0000)
  102. #define CB_MARGIN_HEIGHT DTWIDGET_GETMESSAGE( \
  103. MS_ComboBox, COMBO_MARGIN_HEIGHT, _DtMsgComboBox_0001)
  104. #define CB_MARGIN_WIDTH DTWIDGET_GETMESSAGE( \
  105. MS_ComboBox, COMBO_MARGIN_WIDTH, _DtMsgComboBox_0002)
  106. #define CB_HORIZONTAL_SPACING DTWIDGET_GETMESSAGE( \
  107. MS_ComboBox, COMBO_HORIZONTAL_SPACING, _DtMsgComboBox_0003)
  108. #define CB_VERTICAL_SPACING DTWIDGET_GETMESSAGE( \
  109. MS_ComboBox, COMBO_VERTICAL_SPACING, _DtMsgComboBox_0004)
  110. #define CB_ORIENTATION DTWIDGET_GETMESSAGE( \
  111. MS_ComboBox, COMBO_ORIENTATION, _DtMsgComboBox_0005)
  112. #define CB_ITEM_COUNT DTWIDGET_GETMESSAGE( \
  113. MS_ComboBox, COMBO_ITEM_COUNT, _DtMsgComboBox_0006)
  114. #define CB_VISIBLE_ITEM DTWIDGET_GETMESSAGE( \
  115. MS_ComboBox, COMBO_VISIBLE_ITEM, _DtMsgComboBox_0007)
  116. #define CB_TEXT DTWIDGET_GETMESSAGE( \
  117. MS_ComboBox, COMBO_TEXT, _DtMsgComboBox_0008)
  118. #define CB_SET_ITEM DTWIDGET_GETMESSAGE( \
  119. MS_ComboBox, COMBO_SET_ITEM, _DtMsgComboBox_0009)
  120. #define CB_SELECT_ITEM DTWIDGET_GETMESSAGE( \
  121. MS_ComboBox, COMBO_SELECT_ITEM, _DtMsgComboBox_0010)
  122. #define CB_RESIZE DTWIDGET_GETMESSAGE( \
  123. MS_ComboBox, COMBO_RESIZE, _DtMsgComboBox_0011)
  124. #define CB_LABEL DTWIDGET_GETMESSAGE( \
  125. MS_ComboBox, COMBO_LABEL, _DtMsgComboBox_0012)
  126. #define CB_CVTSTRING DTWIDGET_GETMESSAGE( \
  127. MS_ComboBox, COMBO_CVTSTRING, _DtMsgComboBox_0013)
  128. #define CB_DEL_POS DTWIDGET_GETMESSAGE( \
  129. MS_ComboBox, COMBO_DEL_POS, _DtMsgComboBox_0014)
  130. /*
  131. * Class Records
  132. */
  133. typedef struct {
  134. Boolean junk; /* Need something */
  135. } DtComboBoxClassPart;
  136. typedef struct _DtComboBoxClassRec {
  137. CoreClassPart core_class;
  138. CompositeClassPart composite_class;
  139. ConstraintClassPart constraint_class;
  140. XmManagerClassPart manager_class;
  141. DtComboBoxClassPart combo_box_class;
  142. } DtComboBoxClassRec;
  143. extern DtComboBoxClassRec dtComboBoxClassRec;
  144. /*
  145. * Instance Record.
  146. */
  147. typedef struct _DtComboBoxPart {
  148. /* Private data */
  149. Widget arrow;
  150. Widget shell;
  151. Widget frame;
  152. Widget label;
  153. Widget sep;
  154. Dimension old_width;
  155. Dimension old_height;
  156. Dimension label_max_length;
  157. Dimension label_max_height;
  158. /*
  159. * max_shell_width is the width that is needed to hold the
  160. * list if the longest item was visible. We then use this
  161. * width to figure out if the shell is not wide enough,
  162. * when it gets popped on the screen. This is needed in case the
  163. * combo-box resizes, or if items changes (list will resize).
  164. * Sometimes we change the size of the shell to fit on the screen, or
  165. * to make it at least as large as the combo_box. The next time we pop
  166. * the shell up the size may be different; therefore, we set the shell
  167. * size to the maximum everytime it gets popped up, then we will
  168. * make adjustments, only if needed.
  169. * This value gets saved every time the user updates DtNitems.
  170. */
  171. Dimension max_shell_width;
  172. Dimension max_shell_height;
  173. /* ComboBox specific public resources */
  174. Dimension margin_height;
  175. Dimension margin_width;
  176. XmString selected_item;
  177. int selected_position;
  178. XtCallbackList selection_callback;
  179. unsigned char type;
  180. Dimension arrow_spacing;
  181. /* ComboBox specific private resources */
  182. Dimension arrow_size;
  183. XtCallbackList activate_callback;
  184. unsigned char alignment;
  185. unsigned char arrow_type;
  186. short text_columns;
  187. XtCallbackList focus_callback;
  188. Dimension horizontal_spacing;
  189. int item_count;
  190. XmStringTable items;
  191. XmStringTable list_items;
  192. XmString label_string;
  193. Widget list;
  194. XmFontList list_font_list;
  195. Dimension list_margin_height;
  196. Dimension list_margin_width;
  197. Dimension list_spacing;
  198. XtCallbackList losing_focus_callback;
  199. unsigned int text_max_length;
  200. XtCallbackList menu_post_callback;
  201. unsigned char orientation;
  202. Boolean popped_up;
  203. Boolean recompute_size;
  204. Widget text;
  205. int top_item_position;
  206. Boolean update_label;
  207. Dimension vertical_spacing;
  208. int visible_item_count;
  209. } DtComboBoxPart;
  210. typedef struct _DtComboBoxRec {
  211. CorePart core;
  212. CompositePart composite;
  213. ConstraintPart constraint;
  214. XmManagerPart manager;
  215. DtComboBoxPart combo_box;
  216. } DtComboBoxRec;
  217. #ifdef __cplusplus
  218. } /* Close scope of 'extern "C"' declaration which encloses file. */
  219. #endif
  220. #endif /* _XmComboBoxP_h */