stdwin.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*
  2. * This file provides a description of the interface to the version
  3. * of "StdWin" used with CSL. Some of this is taken from the StdWin
  4. * source. Used with permission.
  5. *
  6. * Copyright 1988-1995 by Stichting Mathematisch Centrum, Amsterdam, The
  7. * Netherlands.
  8. *
  9. * All Rights Reserved
  10. */
  11. /*
  12. * Here is the full statement from the StdWin 1.0 archive.
  13. Copyright 1988-1995 by Stichting Mathematisch Centrum, Amsterdam, The
  14. Netherlands.
  15. All Rights Reserved
  16. Permission to use, copy, modify, and distribute this software and its
  17. documentation for any purpose and without fee is hereby granted,
  18. provided that the above copyright notice appear in all copies and that
  19. both that copyright notice and this permission notice appear in
  20. supporting documentation, and that the names of Stichting Mathematisch
  21. Centrum or CWI not be used in advertising or publicity pertaining to
  22. distribution of the software without specific, written prior permission.
  23. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  24. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  25. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  26. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  28. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  29. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. */
  31. /* Signature: 22275e7f 27-Mar-2002 */
  32. #ifndef __STDWIN_H__ /* Guard against multiple inclusion */
  33. #define __STDWIN_H__
  34. #include "_ARGS.h" /* Definition of _ARGS() macro */
  35. /***********************************/
  36. /* Section 1. Types and constants */
  37. /***********************************/
  38. /* These structs are implementation-dependent, the user only sees
  39. pointers to them */
  40. #define WINDOW struct _window
  41. #define MENU struct _menu
  42. #define CURSOR struct _cursor
  43. #define BITMAP struct _bitmap
  44. /* Fake window type used by the wgettag() and wsettag() macros */
  45. struct _fakewindow {
  46. short tag;
  47. };
  48. #define _FAKEWINDOW struct _fakewindow
  49. /* EVENT struct */
  50. struct _event {
  51. int type;
  52. WINDOW *window;
  53. union {
  54. /* case WE_CHAR: */
  55. int character;
  56. /* case WE_COMMAND: */
  57. int command;
  58. /* case WE_MENU: */
  59. struct { int id; int item; } m;
  60. /* case WE_DRAW: */
  61. struct { int left, top, right, bottom; } area;
  62. /* case WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP: */
  63. struct {
  64. int h;
  65. int v;
  66. int clicks;
  67. int button;
  68. int mask;
  69. } where;
  70. /* case WE_LOST_SEL: */
  71. int sel;
  72. /* case WE_KEY: */
  73. struct { int code; int mask; } key;
  74. } u;
  75. };
  76. #define EVENT struct _event
  77. /* Event types */
  78. /* XXX Should be reordered */
  79. #define WE_NULL 0 /* (Used internally) */
  80. #define WE_ACTIVATE 1 /* Window became active */
  81. #define WE_CHAR 2 /* Character typed at keyboard */
  82. #define WE_COMMAND 3 /* Special command, function key etc. */
  83. #define WE_MOUSE_DOWN 4 /* Mouse button pressed */
  84. #define WE_MOUSE_MOVE 5 /* Mouse moved with button down */
  85. #define WE_MOUSE_UP 6 /* Mouse button released */
  86. #define WE_MENU 7 /* Menu item selected */
  87. #define WE_SIZE 8 /* Window size changed */
  88. #define WE_MOVE 9 /* Window moved (reserved) */
  89. #define WE_DRAW 10 /* Request to redraw part of window */
  90. #define WE_TIMER 11 /* Window's timer went off */
  91. #define WE_DEACTIVATE 12 /* Window became inactive */
  92. #define WE_EXTERN 13 /* Externally generated event (Amoeba) */
  93. #define WE_KEY 14 /* Non-ASCII key event */
  94. #define WE_LOST_SEL 15 /* Lost selection */
  95. #define WE_CLOSE 16 /* User wants to close window */
  96. /* Special keys reported by WE_COMMAND */
  97. /* XXX Should become key events */
  98. #define WC_CLOSE 1 /* Obsolete */
  99. /* The following four are arrow keys */
  100. #define WC_LEFT 2
  101. #define WC_RIGHT 3
  102. #define WC_UP 4
  103. #define WC_DOWN 5
  104. /* ASCII keys */
  105. #define WC_CANCEL 6
  106. #define WC_BACKSPACE 7
  107. #define WC_TAB 8
  108. #define WC_RETURN 9
  109. /* IBM-PC keys -- not in all implementations */
  110. /* XXX Should be done differently */
  111. #define WC_HOME 10
  112. #define WC_END 11
  113. #define WC_CLEAR 12
  114. #define WC_INS 13
  115. #define WC_DEL 14
  116. #define WC_PAGE_UP 15
  117. #define WC_PAGE_DOWN 16
  118. #define WC_META_LEFT 17
  119. #define WC_META_RIGHT 18
  120. #define WC_META_HOME 19
  121. #define WC_META_END 20
  122. #define WC_META_PAGE_UP 21
  123. #define WC_META_PAGE_DOWN 22
  124. /* XXX Should have entries for Alt-letter and F1-F10 etc. ? */
  125. /* Codes for selections (e.u.sel for WE_LOST_SEL) */
  126. #define WS_CLIPBOARD 0
  127. #define WS_PRIMARY 1
  128. #define WS_SECONDARY 2
  129. /* Masks for EVENT->u.where.mask and EVENT->u.key.mask.
  130. Some of these happen to be the same as the X11 masks (which are cast
  131. in stone for eternity); the implementation relies on that.
  132. (It is merely a convention that Meta is bit 3, and Option/Num aren't
  133. normally used in X11.) */
  134. #define WM_SHIFT (1 << 0)
  135. #define WM_LOCK (1 << 1)
  136. #define WM_CONTROL (1 << 2)
  137. #define WM_META (1 << 3)
  138. #define WM_OPTION (1 << 4)
  139. #define WM_NUM (1 << 5)
  140. #define WM_BUTTON1 (1 << 8)
  141. #define WM_BUTTON2 (1 << 9)
  142. #define WM_BUTTON3 (1 << 10)
  143. #define WM_BUTTON4 (1 << 11)
  144. #define WM_BUTTON5 (1 << 12)
  145. /* TEXTATTR struct */
  146. /* The contents of a text attributes struct are disclosed here because
  147. the interface allows the programmer to declare objects of this type.
  148. (I'm not so sure anymore that this is the right thing to do!) */
  149. struct _textattr {
  150. short font;
  151. unsigned char size;
  152. unsigned char style;
  153. };
  154. #define TEXTATTR struct _textattr
  155. /* Color */
  156. #define COLOR long
  157. #define BADCOLOR ((COLOR)(-1))
  158. /* Point type for wdrawpoly and wfillpoly -- compatible with X */
  159. struct _point {
  160. short h, v;
  161. };
  162. #define POINT struct _point
  163. /*************************************/
  164. /* Section 2. Function declarations */
  165. /*************************************/
  166. void wargs _ARGS((int *pargc, char ***pargv));
  167. void winit _ARGS((void));
  168. void winitargs _ARGS((int *pargc, char ***pargv));
  169. void wdone _ARGS((void));
  170. void wgetscrsize _ARGS((int *pwidth, int *pheight));
  171. void wgetscrmm _ARGS((int *pmmwidth, int *pmmheight));
  172. int wgetmouseconfig _ARGS((void));
  173. void wsetmaxwinsize _ARGS((int width, int height));
  174. void wsetdefwinsize _ARGS((int width, int height));
  175. void wgetdefwinsize _ARGS((int *pwidth, int *pheight));
  176. void wsetdefwinpos _ARGS((int h, int v));
  177. void wgetdefwinpos _ARGS((int *ph, int *pv));
  178. void wsetdefscrollbars _ARGS((/*bool*/int hbar, /*bool*/int vbar));
  179. void wgetdefscrollbars _ARGS((/*bool*/int *phbar, /*bool*/int *pvbar));
  180. WINDOW *wopen _ARGS((char *title,
  181. void (*drawproc)(/*WINDOW *win,
  182. int left, int top, int right, int bottom*/)));
  183. void wclose _ARGS((WINDOW *win));
  184. #define wgettag(win) (((_FAKEWINDOW *)(win)) -> tag)
  185. #define wsettag(win, newtag) (((_FAKEWINDOW *)(win)) -> tag = (newtag))
  186. void wsetactive _ARGS((WINDOW *win));
  187. WINDOW *wgetactive _ARGS((void));
  188. void wgetwinsize _ARGS((WINDOW *win, int *width, int *height));
  189. void wsetwinsize _ARGS((WINDOW *win, int width, int height));
  190. void wgetwinpos _ARGS((WINDOW *win, int *h, int *v));
  191. void wsetwinpos _ARGS((WINDOW *win, int h, int v));
  192. void wsetdocsize _ARGS((WINDOW *win, int width, int height));
  193. void wgetdocsize _ARGS((WINDOW *win, int *width, int *height));
  194. void wsettitle _ARGS((WINDOW *win, char *title));
  195. char *wgettitle _ARGS((WINDOW *win)); /* Returns pointer to static data */
  196. void wsetorigin _ARGS((WINDOW *win, int h, int v));
  197. void wgetorigin _ARGS((WINDOW *win, int *h, int *v));
  198. void wshow _ARGS((WINDOW *win, int left, int top, int right, int bottom));
  199. void wchange _ARGS((WINDOW *win, int left, int top, int right, int bottom));
  200. void wscroll _ARGS((WINDOW *win, int left, int top, int right, int bottom,
  201. int dh, int dv));
  202. void wfleep _ARGS((void));
  203. void wmessage _ARGS((char *str));
  204. void wperror _ARGS((char *name));
  205. /*bool*/int waskstr _ARGS((char *prompt, char *buf, int buflen));
  206. int waskync _ARGS((char *question, int dflt));
  207. /*bool*/int waskfile _ARGS((char *prompt, char *buf, int buflen,
  208. /*bool*/int newfile));
  209. void wsetcaret _ARGS((WINDOW *win, int h, int v));
  210. void wnocaret _ARGS((WINDOW *win));
  211. void wsettimer _ARGS((WINDOW *win, int deciseconds));
  212. MENU *wmenucreate _ARGS((int id, char *title));
  213. void wmenudelete _ARGS((MENU *mp));
  214. int wmenuadditem _ARGS((MENU *mp, char *text, int shortcut));
  215. void wmenusetitem _ARGS((MENU *mp, int i, char *text));
  216. void wmenusetdeflocal _ARGS((/*bool*/int local));
  217. void wmenuattach _ARGS((WINDOW *win, MENU *mp));
  218. void wmenudetach _ARGS((WINDOW *win, MENU *mp));
  219. void wmenuenable _ARGS((MENU *mp, int item, int flag));
  220. void wmenucheck _ARGS((MENU *mp, int item, int flag));
  221. /* The following is only available in termcap stdwin: */
  222. void wsetshortcut _ARGS((int id, int item, char *keys));
  223. void wgetevent _ARGS((EVENT *ep));
  224. /*bool*/int wpollevent _ARGS((EVENT *ep));
  225. void wungetevent _ARGS((EVENT *ep));
  226. void wupdate _ARGS((WINDOW *win));
  227. void wbegindrawing _ARGS((WINDOW *win));
  228. void wenddrawing _ARGS((WINDOW *win));
  229. void wflush _ARGS((void));
  230. void wdrawline _ARGS((int h1, int v1, int h2, int v2));
  231. void wxorline _ARGS((int h1, int v1, int h2, int v2));
  232. void wdrawbox _ARGS((int left, int top, int right, int bottom));
  233. void wpaint _ARGS((int left, int top, int right, int bottom));
  234. void winvert _ARGS((int left, int top, int right, int bottom));
  235. void werase _ARGS((int left, int top, int right, int bottom));
  236. void wshade _ARGS((int left, int top, int right, int bottom, int percent));
  237. void wdrawcircle _ARGS((int h, int v, int radius));
  238. void wfillcircle _ARGS((int h, int v, int radius));
  239. void wxorcircle _ARGS((int h, int v, int radius));
  240. void wdrawelarc _ARGS((int h, int v, int hrad, int vrad, int ang1, int ang2));
  241. void wfillelarc _ARGS((int h, int v, int hrad, int vrad, int ang1, int ang2));
  242. void wxorelarc _ARGS((int h, int v, int hrad, int vrad, int ang1, int ang2));
  243. void wdrawpoly _ARGS((int n, POINT points[]));
  244. void wfillpoly _ARGS((int n, POINT points[]));
  245. void wxorpoly _ARGS((int n, POINT points[]));
  246. void wcliprect _ARGS((int left, int top, int right, int bottom));
  247. void wnoclip _ARGS((void));
  248. void wdrawtext _ARGS((int h, int v, char *str, int len));
  249. void wdrawchar _ARGS((int h, int v, int c));
  250. int wlineheight _ARGS((void));
  251. int wbaseline _ARGS((void));
  252. int wtextwidth _ARGS((char *str, int len));
  253. int wcharwidth _ARGS((int c));
  254. int wtextbreak _ARGS((char *str, int len, int width));
  255. void wgettextattr _ARGS((TEXTATTR *attr));
  256. void wsettextattr _ARGS((TEXTATTR *attr));
  257. void wgetwintextattr _ARGS((WINDOW *win, TEXTATTR *attr));
  258. void wsetwintextattr _ARGS((WINDOW *win, TEXTATTR *attr));
  259. void wsetplain _ARGS((void));
  260. void wsethilite _ARGS((void));
  261. void wsetinverse _ARGS((void));
  262. void wsetitalic _ARGS((void));
  263. void wsetbold _ARGS((void));
  264. void wsetbolditalic _ARGS((void));
  265. void wsetunderline _ARGS((void));
  266. char **wlistfontnames _ARGS((char *, int *));
  267. int wsetfont _ARGS((char *fontname));
  268. void wsetsize _ARGS((int pointsize));
  269. /* Colors */
  270. COLOR wfetchcolor _ARGS((char *colorname));
  271. void wsetfgcolor _ARGS((COLOR color));
  272. COLOR wgetfgcolor _ARGS((void));
  273. void wsetbgcolor _ARGS((COLOR color));
  274. COLOR wgetbgcolor _ARGS((void));
  275. /* Setting the mouse cursor for a window */
  276. CURSOR *wfetchcursor _ARGS((char *name));
  277. void wsetwincursor _ARGS((WINDOW *win, CURSOR *cursor));
  278. /* X11 Selection interface */
  279. /*bool*/int wsetselection _ARGS((WINDOW *, int, char *, int));
  280. void wresetselection _ARGS((int));
  281. char *wgetselection _ARGS((int, int *));
  282. /* Cut buffer interface */
  283. void wsetcutbuffer _ARGS((int, char *, int));
  284. char *wgetcutbuffer _ARGS((int, int *));
  285. void wrotatecutbuffers _ARGS((int));
  286. void wsetclip _ARGS((char *, int));
  287. char *wgetclip _ARGS((void));
  288. /* Bitmap operations */
  289. BITMAP *wnewbitmap _ARGS((int width, int height));
  290. void wfreebitmap _ARGS((BITMAP *bp));
  291. void wgetbitmapsize _ARGS((BITMAP *bp, int *p_width, int *p_height));
  292. void wsetbit _ARGS((BITMAP *bp, int h, int v, int bit));
  293. int wgetbit _ARGS((BITMAP *bp, int h, int v));
  294. void wdrawbitmap _ARGS((int h, int v, BITMAP *bp, BITMAP *maskp));
  295. #define ALLBITS ((BITMAP *)NULL)
  296. /* Pull in definitions for TEXTEDIT package */
  297. #include "stdwtext.h"
  298. #endif /* __STDWIN_H__ */