2 * $Id: mouse.c,v 1.21 2015/05/13 20:56:28 tom Exp $
4 * mouse.c -- mouse support for dialog
6 * Copyright 2002-2012,2015 Thomas E. Dickey
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License, version 2.1
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to
19 * Free Software Foundation, Inc.
20 * 51 Franklin St., Fifth Floor
21 * Boston, MA 02110, USA.
29 static int basex
, basey
, basecode
;
31 static mseRegion
*regionList
= NULL
;
33 /*=========== region related functions =============*/
36 find_region_by_code(int code
)
40 for (butPtr
= regionList
; butPtr
; butPtr
= butPtr
->next
) {
41 if (code
== butPtr
->code
)
48 dlg_mouse_setbase(int x
, int y
)
55 dlg_mouse_setcode(int code
)
61 dlg_mouse_mkbigregion(int y
, int x
,
62 int height
, int width
,
64 int step_y
, int step_x
,
67 mseRegion
*butPtr
= dlg_mouse_mkregion(y
, x
, height
, width
, -DLGK_MOUSE(code
));
69 butPtr
->step_x
= MAX(1, step_x
);
70 butPtr
->step_y
= MAX(1, step_y
);
74 dlg_mouse_free_regions(void)
76 while (regionList
!= 0) {
77 mseRegion
*butPtr
= regionList
->next
;
84 dlg_mouse_mkregion(int y
, int x
, int height
, int width
, int code
)
88 if ((butPtr
= find_region_by_code(basecode
+ code
)) == 0) {
89 butPtr
= dlg_malloc(mseRegion
, 1);
90 assert_ptr(butPtr
, "dlg_mouse_mkregion");
91 butPtr
->next
= regionList
;
98 butPtr
->y
= basey
+ y
;
99 butPtr
->Y
= basey
+ y
+ height
;
100 butPtr
->x
= basex
+ x
;
101 butPtr
->X
= basex
+ x
+ width
;
102 butPtr
->code
= basecode
+ code
;
107 /* retrieve the frame under the pointer */
109 any_mouse_region(int y
, int x
, int small
)
113 for (butPtr
= regionList
; butPtr
; butPtr
= butPtr
->next
) {
114 if (small
^ (butPtr
->code
>= 0)) {
117 if (y
< butPtr
->y
|| y
>= butPtr
->Y
) {
120 if (x
< butPtr
->x
|| x
>= butPtr
->X
) {
128 /* retrieve the frame under the pointer */
130 dlg_mouse_region(int y
, int x
)
132 return any_mouse_region(y
, x
, TRUE
);
135 /* retrieve the bigframe under the pointer */
137 dlg_mouse_bigregion(int y
, int x
)
139 return any_mouse_region(y
, x
, FALSE
);
143 void mouse_dummy(void);
148 #endif /* USE_MOUSE */