2 /***************************************************************************
4 ****************************************************************************
5 * ncurses is copyright (C) 1992-1995 *
7 * zmbenhal@netcom.com *
9 * esr@snark.thyrsus.com *
11 * Permission is hereby granted to reproduce and distribute ncurses *
12 * by any means and for any fee, whether alone or as part of a *
13 * larger distribution, in source or in binary form, PROVIDED *
14 * this notice is included with any such distribution, and is not *
15 * removed from any of its header files. Mention of ncurses in any *
16 * applications linked with it is highly appreciated. *
18 * ncurses comes AS IS with no warranty, implied or expressed. *
20 ***************************************************************************/
25 ** Some small wrappers to ease the implementation of an Ada95
26 ** binding. Especially functionalities only available as macros
27 ** in (n)curses are wrapped here by functions.
28 ** See the documentation and copyright notices in the ../Ada95
31 #include "curses.priv.h"
33 /* In (n)curses are a few functionalities that can't be expressed as
34 // functions, because for historic reasons they use as macro argument
35 // variable names that are "out" parameters. For those macros we provide
39 /* Prototypes for the functions in this module */
40 int _nc_ada_getmaxyx (WINDOW *win, int *y, int *x);
41 int _nc_ada_getbegyx (WINDOW *win, int *y, int *x);
42 int _nc_ada_getyx (WINDOW *win, int *y, int *x);
43 int _nc_ada_getparyx (WINDOW *win, int *y, int *x);
44 int _nc_ada_isscroll (WINDOW *win);
45 int _nc_ada_coord_transform (WINDOW *win, int *Y, int *X, int dir);
46 void _nc_ada_mouse_event (mmask_t m, int *b, int *s);
47 int _nc_ada_mouse_mask (int button, int state, mmask_t *mask);
48 void _nc_ada_unregister_mouse (void);
51 int _nc_ada_getmaxyx (WINDOW *win, int *y, int *x)
62 int _nc_ada_getbegyx (WINDOW *win, int *y, int *x)
73 int _nc_ada_getyx (WINDOW *win, int *y, int *x)
84 int _nc_ada_getparyx (WINDOW *win, int *y, int *x)
95 int _nc_ada_isscroll (WINDOW *win)
97 return win ? (win->_scroll ? TRUE : FALSE) : ERR;
100 int _nc_ada_coord_transform( WINDOW *win, int *Y, int *X, int dir)
104 int y = *Y; int x = *X;
106 { /* to screen coordinates */
110 if (!wenclose(win,y,x))
114 { /* from screen coordinates */
115 if (!wenclose(win,y,x))
128 #define BUTTON1_EVENTS (BUTTON1_RELEASED |\
131 BUTTON1_DOUBLE_CLICKED |\
132 BUTTON1_TRIPLE_CLICKED |\
133 BUTTON1_RESERVED_EVENT )
135 #define BUTTON2_EVENTS (BUTTON2_RELEASED |\
138 BUTTON2_DOUBLE_CLICKED |\
139 BUTTON2_TRIPLE_CLICKED |\
140 BUTTON2_RESERVED_EVENT )
142 #define BUTTON3_EVENTS (BUTTON3_RELEASED |\
145 BUTTON3_DOUBLE_CLICKED |\
146 BUTTON3_TRIPLE_CLICKED |\
147 BUTTON3_RESERVED_EVENT )
149 #define BUTTON4_EVENTS (BUTTON4_RELEASED |\
152 BUTTON4_DOUBLE_CLICKED |\
153 BUTTON4_TRIPLE_CLICKED |\
154 BUTTON4_RESERVED_EVENT )
156 void _nc_ada_mouse_event( mmask_t m, int *b, int *s )
160 if ( m & BUTTON1_EVENTS)
164 else if ( m & BUTTON2_EVENTS)
168 else if ( m & BUTTON3_EVENTS)
172 else if ( m & BUTTON4_EVENTS)
180 if (BUTTON_RELEASE(m,k)) *s = 0;
181 else if (BUTTON_PRESS(m,k)) *s = 1;
182 else if (BUTTON_CLICK(m,k)) *s = 2;
183 else if (BUTTON_DOUBLE_CLICK(m,k)) *s = 3;
184 else if (BUTTON_TRIPLE_CLICK(m,k)) *s = 4;
185 else if (BUTTON_RESERVED_EVENT(m,k)) *s = 5;
194 if (m & BUTTON_CTRL) *b = 4;
195 else if (m & BUTTON_SHIFT) *b = 5;
196 else if (m & BUTTON_ALT) *b = 6;
204 int _nc_ada_mouse_mask ( int button, int state, mmask_t *mask )
206 mmask_t b = (button<4) ? ((1<<button) << (6 * state)) :
207 (BUTTON_CTRL << (button-4));
209 if (button>=4 && state!=1)
216 void _nc_ada_unregister_mouse (void)