util.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. /* util.h 1.5 - Fujitsu source for CDEnext 96/09/18 13:59:22 */
  24. /* $XConsortium: util.h /main/5 1996/09/19 19:42:11 cde-fuj $ */
  25. /*
  26. * (c) Copyright 1995 FUJITSU LIMITED
  27. * This is source code modified by FUJITSU LIMITED under the Joint
  28. * Development Agreement for the CDEnext PST.
  29. * This is unpublished proprietary source code of FUJITSU LIMITED
  30. */
  31. #include <Xm/Xm.h>
  32. #include <Xm/XmStrDefs.h>
  33. #define MarginWidth 4
  34. #define RowMarginWidth 11
  35. #define MarginHeight 11
  36. #define HeightSpace 4
  37. #define MinimumSpace 4
  38. /***** Exclusive Set *****/
  39. typedef struct _ToggleButt {
  40. Widget w;
  41. char * label;
  42. XtPointer clientdata;
  43. String name;
  44. XtArgVal sensitive;
  45. XtCallbackProc cb;
  46. XtArgVal set;
  47. } ToggleButt;
  48. #define EXARGS( clientdata, name, sensitive, cb, set ){ \
  49. NULL, \
  50. (char *) "", \
  51. (XtPointer) clientdata, \
  52. name, \
  53. (XtArgVal) sensitive, \
  54. (XtCallbackProc) cb, \
  55. (XtArgVal) set \
  56. }
  57. typedef struct _RadioButt {
  58. String label;
  59. ToggleButt *items;
  60. int items_cnt;
  61. String name;
  62. Widget w;
  63. XtPointer udata;
  64. } RadioButt;
  65. #define EXCLUSIVE(a) { 0, a, XtNumber(a), 0, 0, 0 }
  66. #define ExclusiveItems ToggleButt
  67. #define Exclusive RadioButt
  68. #define SetItemLabel(b,n,l) (b)->items[(n)].label = (l)
  69. /***** PushButton Set *****/
  70. typedef struct _ButtonItems {
  71. char * label;
  72. XtCallbackProc cb;
  73. XtPointer clientdata;
  74. XtArgVal mnemonic;
  75. XtArgVal sensitive;
  76. XtArgVal deflt;
  77. } ButtonItems;
  78. #define BTNARGS( cb, clientdata, mnumonic, sensitive, deflt ) { \
  79. (char *) "", \
  80. (XtCallbackProc) cb, \
  81. (XtPointer) clientdata, \
  82. (XtArgVal) mnumonic, \
  83. (XtArgVal) sensitive, \
  84. (XtArgVal) deflt \
  85. }
  86. typedef struct _Button {
  87. Widget *w;
  88. ButtonItems *items;
  89. int itemcnt;
  90. } Button;
  91. #define BUTTONS( items ) { 0, items, XtNumber(items) }
  92. /***** MenuButton Set *****/
  93. typedef struct _menuButtonItems {
  94. char *label;
  95. char mnemonic;
  96. Widget menu;
  97. } menuButtonItems;
  98. #define MENUBTNARGS( mnumonic ) { \
  99. "", \
  100. mnumonic, \
  101. NULL, \
  102. }
  103. typedef struct _MButton {
  104. menuButtonItems *items;
  105. int itemcnt;
  106. } MButton;
  107. #define MBUTTONS(items) {items,XtNumber((items))}
  108. /***** NoticeButton Set *****/
  109. typedef struct _NoticeButton {
  110. char *label;
  111. void (*cb)();
  112. } NoticeButton;
  113. #define NBTNARGS( cb, clientdata, mnumonic, sensitive, deflt) { \
  114. "", \
  115. cb, \
  116. }
  117. typedef struct _NButton {
  118. NoticeButton *items;
  119. int itemcnt;
  120. } NButton;
  121. #define NBUTTONS(items) {items,XtNumber((items))}
  122. /***** TextField Set *****/
  123. typedef struct _TextField {
  124. Widget w1;
  125. Widget w2;
  126. String label;
  127. } TextField;
  128. /***** Function Type *****/
  129. #define D_WARNING XmDIALOG_WARNING
  130. #define D_QUESTION XmDIALOG_QUESTION
  131. #define D_ERROR XmDIALOG_ERROR
  132. #define D_TEMPLATE XmDIALOG_TEMPLATE
  133. #define L_VERTICAL XmVERTICAL
  134. #define L_HORIZONTAL XmHORIZONTAL
  135. #ifdef USE_MACRO
  136. #define AddLeftAttachWidget( w, ref, offset ) XtVaSetValues( w, \
  137. XmNleftAttachment, XmATTACH_WIDGET, \
  138. XmNleftWidget, ref, \
  139. XmNleftOffset, offset, \
  140. 0)
  141. #define AddLeftAttachForm( w, offset ) XtVaSetValues( w, \
  142. XmNleftAttachment, XmATTACH_FORM, \
  143. XmNleftOffset, offset, \
  144. 0)
  145. #define AddTopAttachWidget( w, ref, offset ) XtVaSetValues( w, \
  146. XmNtopAttachment, XmATTACH_WIDGET, \
  147. XmNtopWidget, ref, \
  148. XmNtopOffset, offset, \
  149. 0)
  150. #define AddTopAttachForm( w, offset ) XtVaSetValues( w, \
  151. XmNtopAttachment, XmATTACH_FORM, \
  152. XmNtopOffset, offset, \
  153. 0)
  154. #define AddRightAttachWidget( w, ref, offset ) XtVaSetValues( w, \
  155. XmNrightAttachment, XmATTACH_WIDGET, \
  156. XmNrightWidget, ref, \
  157. XmNrightOffset, offset, \
  158. 0)
  159. #define AddRightAttachForm( w, offset ) XtVaSetValues( w, \
  160. XmNrightAttachment, XmATTACH_FORM, \
  161. XmNrightOffset, offset, \
  162. 0)
  163. #define AddBottomAttachForm( w, offset ) XtVaSetValues( w, \
  164. XmNbottomAttachment, XmATTACH_FORM, \
  165. XmNbottomOffset, offset, \
  166. 0)
  167. #endif /* USE_MACRO */
  168. extern Widget CreateDrawingArea(Widget owner,
  169. String name,
  170. int width,
  171. int height,
  172. void (*proc)(),
  173. int val);
  174. extern Widget CreateDialogAndButtons(Widget owner,
  175. String name,
  176. void (*delcb)(),
  177. Button *btns,
  178. int btns_cnt,
  179. Widget *pop);
  180. extern String GetTextFieldValue(TextField *textf);
  181. extern Widget CreateTemplateDialog(Widget w,
  182. char *message,
  183. unsigned char type,
  184. NButton *button,
  185. String title,
  186. Widget *pop);
  187. extern Widget CreateScrollBase(Widget owner,
  188. String name,
  189. int min,
  190. int max,
  191. int val,
  192. int vcnt,
  193. void (*sbproc)());
  194. Widget CreateCaptionFrame(Widget owner,
  195. String name,
  196. String labelstr,
  197. int type,
  198. int thickness);
  199. void CreateTextField(Widget owner,
  200. String name,
  201. String labelstr,
  202. TextField *data,
  203. int maxlength);
  204. void CreateMenuButtons(Widget owner, Button *buttons, int buttons_cnt);
  205. Widget GuiInitialize(XtAppContext *app,
  206. String class_name,
  207. int *ac,
  208. String av[]);
  209. void AddLeftAttachWidget(Widget w, Widget ref, int offset);
  210. void AddLeftAttachForm(Widget w, int offset);
  211. void AddTopAttachWidget(Widget w, Widget ref, int offset);
  212. void AddTopAttachForm(Widget w, int offset);
  213. void AddRightAttachWidget(Widget w, Widget ref, int offset);
  214. void AddRightAttachForm(Widget w, int offset);
  215. void AddBottomAttachForm(Widget w, int offset);
  216. void PopupDialog(Widget w);
  217. void PopdownDialog(Widget w);
  218. void ForcePopdownDialog(Widget w);
  219. void SetLabelString(Widget w, String str);
  220. void SetFooterString(Widget w, String str);
  221. void PopupNotice(Widget owner,
  222. char *message,
  223. unsigned char type,
  224. NButton *button,
  225. Boolean do_format,
  226. String title);
  227. void AddDeleteProc(Widget w, void (*delcb)());
  228. Widget CreateMenuBarAndFooterMessageForm(Widget owner,
  229. String name,
  230. MButton *buttons,
  231. int bcnt,
  232. Widget *pop,
  233. Widget *footer);
  234. Widget GetMenuWidget(MButton *buttons, int buttons_num);
  235. Widget CreateForm(Widget owner, String name);
  236. Widget CreateLabel(Widget owner, String name, String str);
  237. Widget CreateFrame(Widget owner,
  238. String name,
  239. int type,
  240. int thickness);
  241. Widget CreateRowColumn(Widget owner,
  242. String name,
  243. int layout,
  244. int space,
  245. int marginw,
  246. int marginh);
  247. Widget CreateScrollBar(Widget owner,
  248. String name,
  249. int height,
  250. int val,
  251. int min,
  252. int max,
  253. void (*proc)());