2 * $Id: mouse.c,v 1.18 2007/02/22 21:51:38 tom Exp $
4 * mouse.c -- mouse support for dialog
6 * Copyright 2002-2006,2007 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;
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_mkbigregion(int y, int x,
56 int height, int width,
58 int step_y, int step_x,
61 mseRegion *butPtr = dlg_mouse_mkregion(y, x, height, width, -DLGK_MOUSE(code));
63 butPtr->step_x = MAX(1, step_x);
64 butPtr->step_y = MAX(1, step_y);
68 dlg_mouse_free_regions(void)
70 while (regionList != 0) {
71 mseRegion *butPtr = regionList->next;
78 dlg_mouse_mkregion(int y, int x, int height, int width, int code)
82 if ((butPtr = find_region_by_code(code)) == 0) {
83 butPtr = dlg_malloc(mseRegion, 1);
84 assert_ptr(butPtr, "dlg_mouse_mkregion");
85 butPtr->next = regionList;
92 butPtr->y = basey + y;
93 butPtr->Y = basey + y + height;
94 butPtr->x = basex + x;
95 butPtr->X = basex + x + width;
101 /* retrieve the frame under the pointer */
103 any_mouse_region(int y, int x, int small)
107 for (butPtr = regionList; butPtr; butPtr = butPtr->next) {
108 if (small ^ (butPtr->code >= 0))
110 if (y < butPtr->y || y >= butPtr->Y)
112 if (x < butPtr->x || x >= butPtr->X)
119 /* retrieve the frame under the pointer */
121 dlg_mouse_region(int y, int x)
123 return any_mouse_region(y, x, TRUE);
126 /* retrieve the bigframe under the pointer */
128 dlg_mouse_bigregion(int y, int x)
130 return any_mouse_region(y, x, FALSE);
134 void mouse_dummy(void);
139 #endif /* USE_MOUSE */