1 /* $Id: vibmouse.h,v 6.2 2004/04/01 13:43:09 lavr Exp $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information (NCBI) 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government do not place any restriction on its use or reproduction. 13 * We would, however, appreciate having the NCBI and the author cited in 14 * any work or product based on this material 15 * 16 * Although all reasonable efforts have been taken to ensure the accuracy 17 * and reliability of the software and data, the NLM and the U.S. 18 * Government do not and cannot warrant the performance or results that 19 * may be obtained by using this software or data. The NLM and the U.S. 20 * Government disclaim all warranties, express or implied, including 21 * warranties of performance, merchantability or fitness for any particular 22 * purpose. 23 * 24 * =========================================================================== 25 * 26 * Author: Denis Vakatov 27 * 28 * File Description: 29 * menu-driven interface to manage mouse-event callbacks 30 * program interface to describe groups of mouse-event callbacks 31 * 32 * ========================================================================== 33 * $Log: vibmouse.h,v $ 34 * Revision 6.2 2004/04/01 13:43:09 lavr 35 * Spell "occurred", "occurrence", and "occurring" 36 * 37 * Revision 6.1 1999/04/06 14:23:26 lewisg 38 * add opengl replacement for viewer3d 39 * 40 * Revision 6.0 1997/08/25 18:57:23 madden 41 * Revision changed to 6.0 42 * 43 * Revision 1.1 1997/03/20 16:23:48 vakatov 44 * Initial revision 45 * 46 * 47 * ========================================================================== 48 */ 49 50 #ifndef VIBMOUSE_H 51 #define VIBMOUSE_H 52 53 /* #include <vibrant.h> lyg */ 54 #include <vibtypes.h> 55 #include <vibprocs.h> 56 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 63 /* The mouse action callback types and modifiers(enumerated) 64 */ 65 typedef enum 66 { 67 MK_Normal = 0, 68 MK_Shift, 69 MK_Ctrl, 70 71 /* this one must not be used by the user -- for internal affairs only! */ 72 /* (in internals, it means that presently there is no action "in progress" */ 73 MK_Default 74 } 75 enumMKey; 76 77 78 typedef enum 79 { 80 MA_Click = 0, 81 MA_Press, 82 MA_DClick, 83 MA_Hold, 84 MA_Drag, 85 MA_Release, 86 MA_Cancel, 87 88 /* insensitive to the modifier keys */ 89 MA_Init, 90 MA_Done, 91 92 /* this one must not be used by the user -- for internal affairs only! */ 93 MA_Default 94 } enumMAction; 95 96 97 /*---[ MA_Create ]---------------------------------------- 98 * Create new set of the MA(Mouse-Action) controls; 99 * settle these as a system of pulldown menus attached 100 * to the menu(s) "group_menu" and/or "action_menu"; 101 * the latter two can be NULL and can be the same menu or submenu. 102 * (If "menu" == NULL then just do not create an interface.) 103 * Return handler of the created MA. 104 */ 105 struct _MA; 106 typedef struct _MA PNTR MAPtr; 107 108 extern MAPtr MA_Create(Nlm_MenU group_menu, Nlm_MenU action_menu); 109 110 111 /*---[ MA_AddAction ]---------------------------------------------------- 112 * For MA controls "ma": register new mouse action of type "type", 113 * having the callback function "func", user data "data"(may be NULL) 114 * and name "name"(may be NULL). 115 */ 116 struct _MAction; 117 typedef struct _MAction PNTR MActionPtr; 118 119 typedef struct 120 { 121 Nlm_PoinT start; 122 Nlm_PoinT end; 123 } 124 MA_Trace, PNTR MA_TracePtr; 125 126 /* Type of the user-defined callback function 127 */ 128 typedef void (*MA_Func) PROTO ( 129 ( 130 MAPtr ma, /* handle of the MA controls */ 131 MA_TracePtr trace, /* aux. memory area(unique for each MA) */ 132 Nlm_PoinT point, /* present coordinates of the mouse */ 133 VoidPtr extra /* extra data(specified by user in MA_AddAction()) */ 134 ) 135 ); 136 137 extern MActionPtr MA_AddAction(MAPtr ma, 138 enumMKey mod_key, 139 enumMAction type, 140 MA_Func func, 141 VoidPtr data, 142 const Char PNTR name); 143 144 /* Dummy callback to use in MA_AddAction() -- just for user's convenience */ 145 extern void DoNothingMA(MAPtr ma, MA_TracePtr trace, Nlm_PoinT point, 146 VoidPtr extra); 147 148 149 /*---[ MA_SetAction ]---------------------------------------------------- 150 * Set the "action". 151 * If the action of this type is marked as "only" then: 152 * if "can_unset_group" is TRUE then the relevant group will be unset, 153 * else do nothing and return FALSE. 154 * NOTE: The "action" must not be NULL 155 */ 156 extern Boolean MA_SetAction(MActionPtr action, Boolean can_unset_group); 157 158 159 /*---[ MA_UnsetAll ]---------------------------------------------------- 160 * Disable all currently set mouse actions. 161 */ 162 extern Boolean MA_UnsetAll(MAPtr ma); 163 164 165 /*---[ MA_AddGroup ]----------------------------------------------------- 166 * Register new mouse action group. 167 * The "name" must not be NULL and different groups must have different names; 168 * all enlisted mouse actions must be registered by the moment by the means of 169 * "Nlm_AddAction()" and must have different types(in the sense of the 170 * ("enumMKey", "enumMAction") unique pair). 171 * "only" == MA_ONLY means that the relevant "action" cannot be later changed 172 * without unsetting the whole group. 173 * NOTE: The last argument *must* be NULL! 174 */ 175 struct _MA_Group; 176 typedef struct _MA_Group PNTR MA_GroupPtr; 177 178 179 #define MA_SHARED ((long)0) 180 #define MA_ONLY ((long)1) 181 extern MA_GroupPtr MA_AddGroup(MAPtr ma, const Char PNTR name, 182 MActionPtr action, long only, 183 /* and more pairs: <action>, <only>; */ 184 /* then, the last arg. must be NULL! */ 185 ...); 186 187 188 /*---[ MA_SetGroup ]----------------------------------------------------- 189 * Set the "group"'s mouse actions. 190 * The "only"-actions of this group will replace any currently active 191 * actions; if one of these replaces an "only" action of another 192 * (presently active) group then the whole latter group will be unset. 193 * The non-"only"-actions will replace any presently active non-"only" 194 * actions. 195 * NOTE: The "group" must not be NULL 196 */ 197 extern Boolean MA_SetGroup(MA_GroupPtr group); 198 199 200 /*---[ MA_SetGroup ]----------------------------------------------------- 201 * Unset the group of mouse actions. 202 * Only "only" actions of the group will be disabled. 203 * NOTE: "group" must not be NULL 204 */ 205 extern Boolean MA_UnsetGroup(MA_GroupPtr group); 206 207 208 /*---[ MA_LinkPanel ]---------------------------------------------------- 209 * Wrap the control over the "panel"' mouse events into the "ma"; 210 * NOTE: Previously specified mouse-event handlers and first 211 * sizeof(MAPtr) bytes of 'extra' data of the "panel" will be 212 * overwritten and then used by the MA internals! (Thus, the 213 * panel's extra data must have size at least sizeof(MAPtr).) 214 */ 215 extern Boolean MA_LinkPanel(MAPtr ma, Nlm_PaneL panel); 216 217 218 /*---[ MA_GetPanel ]----------------------------------------------------- 219 * Get handle of the panel presently linked to the "ma" 220 */ 221 extern Nlm_PaneL MA_GetPanel(MAPtr ma); 222 223 224 /*---[ MA_UnlinkPanel ]-------------------------------------------------- 225 * Give away the control over the mouse events occurred in the 226 * panel(if any) presently wrapped by "ma"; disable all mouse handlers 227 * previously set for this panel 228 */ 229 extern void MA_UnlinkPanel(MAPtr ma); 230 231 232 /*---[ MA_[Set/Get]Visible ]--------------------------------------------- 233 * Set/Get visibility of the MA controls referenced by "ma" 234 */ 235 extern Boolean MA_SetVisible(MAPtr ma, Boolean visibility); 236 extern Boolean MA_GetVisible(MAPtr ma); 237 238 239 /*---[ MA_[Set/Get]Extra ]----------------------------------------------- 240 * Set/Get extra data pointer of the MA controls referenced by "ma" 241 */ 242 extern void MA_SetExtra(MAPtr ma, VoidPtr extra); 243 extern VoidPtr MA_GetExtra(MAPtr ma); 244 245 246 /*---[ MA_Reset ]-------------------------------------------------------- 247 * Reset the MA internals and interface to the "just born" state -- i.e. 248 * as if it was just created by the MA_Create() function 249 * (extra & panel will be reset as well!) 250 */ 251 extern void MA_Reset(MAPtr ma); 252 253 254 /*---[ MA_Destroy ]------------------------------------------------------ 255 * Destroy the MA internal structures and user interface controls 256 */ 257 extern void MA_Destroy(MAPtr ma); 258 259 260 #ifdef __cplusplus 261 } 262 #endif 263 264 #endif /* VIBMOUSE_H */ 265 266