1 /* AbiSource Program Utilities
2  * Copyright (C) 1998 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 
21 
22 
23 #ifndef EV_EDITBITS_H
24 #define EV_EDITBITS_H
25 
26 #include "ut_types.h"
27 
28 /*****************************************************************
29 ******************************************************************
30 ** we compress virtual key code and mouse ops along with modifier
31 ** keys into a single long word in order to facilitate binding lookups.
32 ******************************************************************
33 *****************************************************************/
34 
35 
36 typedef UT_uint32 EV_EditMouseContext;								/* may not be ORed */
37 // NB: when adding new values, you have to also increase EV_COUNT_EMC
38 // defined at the bottom of this file -- if you dont you will spend
39 // hours trying to work out why your functions do not get called, as
40 // I did :) (Tomas)
41 //
42 // Foddex:	the values for the various contexts were bad. The EV_EMC_ToNumber
43 // 			define is used to make an index out of the context bits. It is
44 //			used assuming that it will never yield a value larger than or
45 //			equal to EV_COUNT_EMC. However, the original values were defined
46 //			in such a way that it often was bigger dan EV_COUNT_EMC. E.g.
47 //			0xe0000000 >> 27 = 28, which is bigger than EV_COUNT_EMC. I therefor
48 //			rearranged the values. I just hope noone ever was so stupid to use
49 //			hardcoded values...
50 #define EV_EMC__MASK__			((EV_EditMouseContext) 0xf8000000)
51 #define EV_EMC_UNKNOWN			((EV_EditMouseContext) 0x08000000)
52 #define EV_EMC_TEXT				((EV_EditMouseContext) 0x10000000)
53 #define EV_EMC_LEFTOFTEXT		((EV_EditMouseContext) 0x18000000)
54 #define EV_EMC_MISSPELLEDTEXT	((EV_EditMouseContext) 0x20000000)
55 #define EV_EMC_IMAGE			((EV_EditMouseContext) 0x28000000)
56 #define EV_EMC_IMAGESIZE		((EV_EditMouseContext) 0x30000000)
57 #define EV_EMC_FIELD			((EV_EditMouseContext) 0x38000000)
58 #define EV_EMC_HYPERLINK		((EV_EditMouseContext) 0x40000000)
59 #define EV_EMC_RIGHTOFTEXT		((EV_EditMouseContext) 0x48000000)
60 #define EV_EMC_REVISION		    ((EV_EditMouseContext) 0x50000000)
61 #define EV_EMC_VLINE            ((EV_EditMouseContext) 0x58000000)
62 #define EV_EMC_HLINE            ((EV_EditMouseContext) 0x60000000)
63 #define EV_EMC_FRAME            ((EV_EditMouseContext) 0x68000000)
64 #define EV_EMC_VISUALTEXTDRAG   ((EV_EditMouseContext) 0x70000000)
65 #define EV_EMC_TOPCELL          ((EV_EditMouseContext) 0x78000000)
66 #define EV_EMC_TOC              ((EV_EditMouseContext) 0x80000000)
67 #define EV_EMC_POSOBJECT        ((EV_EditMouseContext) 0x88000000)
68 #define EV_EMC_MATH             ((EV_EditMouseContext) 0x90000000)
69 #define EV_EMC_EMBED            ((EV_EditMouseContext) 0x98000000)
70 
71 // NB: the following two values are not included in EV_COUNT_EMC
72 // because they are not used in the bindings, and are, therefore,
73 // never processed by bet the mouse routines, consequently they
74 // do not have to follow the rules for EV_EMC ( and they dont so that
75 // they would not waste available values, which we will soon run
76 // out off); they are here so that contextHyperlink can create
77 // different menus in dependence on the nature of the text of
78 // the hyperlink
79 
80 #define EV_EMC_HYPERLINKTEXT      ((EV_EditMouseContext) 0x000000002)
81 #define EV_EMC_HYPERLINKMISSPELLED ((EV_EditMouseContext) 0x000000001)
82 // RIVERA
83 #define EV_EMC_ANNOTATIONTEXT      ((EV_EditMouseContext) 0x000000003)
84 #define EV_EMC_ANNOTATIONMISSPELLED ((EV_EditMouseContext) 0x000000004)
85 #define EV_EMC_RDFANCHORTEXT      ((EV_EditMouseContext) 0x000000005)
86 // dynamic values will be generated starting from EV_EMC_AVAIL, should
87 // be changed if needed.
88 #define EV_EMC_AVAIL			  ((EV_EditMouseContext) 0x000000007)
89 
90 #define EV_EMC_ToNumber(emc)			((((emc)&EV_EMC__MASK__)>>27)-1)
91 #define EV_EMC_FromNumber(n)			(((n+1)<<27)&EV_EMC__MASK__)
92 
93 typedef UT_uint32 EV_EditModifierState;								/* may be ORed */
94 #define EV_EMS__MASK__			((EV_EditModifierState) 0x07000000)
95 #define EV_EMS_SHIFT			((EV_EditModifierState) 0x01000000)
96 #define EV_EMS_CONTROL			((EV_EditModifierState) 0x02000000)
97 #define EV_EMS_ALT				((EV_EditModifierState) 0x04000000)
98 #define EV_EMS_ToNumber(ems)			(((ems)&EV_EMS__MASK__)>>24)
99 #define EV_EMS_ToNumberNoShift(ems)		(((ems)&EV_EMS__MASK__)>>25)	/* exclude shift */
100 #define EV_EMS_FromNumber(n)			((((n)<<24)&EV_EMS__MASK__))
101 #define EV_EMS_FromNumberNoShift(n)		((((n)<<25)&EV_EMS__MASK__))
102 
103 
104 typedef UT_uint32 EV_EditKeyPress;									/* may be ORed */
105 #define EV_EKP__MASK__			((EV_EditKeyPress)		0x00880000)
106 #define EV_EKP_PRESS			((EV_EditKeyPress)		0x00800000)
107 #define EV_EKP_NAMEDKEY			((EV_EditKeyPress)		0x00080000)
108 #define EV_NamedKey(xxxx)	(EV_EKP_NAMEDKEY | (xxxx))
109 
110 
111 typedef UT_uint32 EV_EditMouseButton;								/* may not be ORed */
112 #define EV_EMB__MASK__			((EV_EditMouseButton)	0x00700000)
113 #define EV_EMB_BUTTON0			((EV_EditMouseButton)	0x00100000)	/* no buttons down */
114 #define EV_EMB_BUTTON1			((EV_EditMouseButton)	0x00200000)
115 #define EV_EMB_BUTTON2			((EV_EditMouseButton)	0x00300000)
116 #define EV_EMB_BUTTON3			((EV_EditMouseButton)	0x00400000)
117 #define EV_EMB_BUTTON4			((EV_EditMouseButton)	0x00500000)
118 #define EV_EMB_BUTTON5			((EV_EditMouseButton)	0x00600000)
119 #define EV_EMB_ToNumber(emb)	(((emb)&EV_EMB__MASK__)>>20)
120 
121 
122 typedef UT_uint32 EV_EditMouseOp;									/* may not be ORed */
123 #define EV_EMO__MASK__			((EV_EditMouseOp)		0x00070000)
124 #define EV_EMO_SINGLECLICK		((EV_EditMouseOp)		0x00010000)
125 #define EV_EMO_DOUBLECLICK		((EV_EditMouseOp)		0x00020000)
126 #define EV_EMO_DRAG				((EV_EditMouseOp)		0x00030000)	/* drag */
127 #define EV_EMO_DOUBLEDRAG		((EV_EditMouseOp)		0x00040000)	/* drag following doubleclick */
128 #define EV_EMO_RELEASE			((EV_EditMouseOp)		0x00050000)	/* release following singleclick */
129 #define EV_EMO_DOUBLERELEASE	((EV_EditMouseOp)		0x00060000)	/* release following doubleclick */
130 #define EV_EMO_ToNumber(emb)	(((emb)&EV_EMO__MASK__)>>16)
131 #define EV_EMO_FromNumber(n)	((((n)<<16)&EV_EMO__MASK__))
132 
133 
134 typedef UT_uint32 EV_EditVirtualKey;								/* may not be ORed */
135 #define EV_EVK__MASK__			((EV_EditVirtualKey)	0x0000ffff)
136 #define EV_EVK_ToNumber(evk)	(((evk)&EV_EVK__MASK__))
137 #define EV_NVK_ToNumber(nvk)	(((nvk)&EV_EVK__MASK__))
138 
139 
140 typedef UT_uint32 EV_EditBits;	/* union of all the above bits */
141 
142 // the EV_COUNT_ give the number of unique combinations
143 // currently defined in the bits above.
144 
145 #define EV_COUNT_EMS			8		// combinations under 'OR' (including 0)
146 #define EV_COUNT_EMS_NoShift	(EV_COUNT_EMS/2)
147 
148 #define EV_COUNT_EMB			6		// simple count (not 'OR')
149 #define EV_COUNT_EMO			6		// simple count (not 'OR')
150 #define EV_COUNT_EMC			19		// simple count (not 'OR')
151 
152 #define EV_IsMouse(eb)			(((eb) & EV_EMO__MASK__))
153 #define EV_IsKeyboard(eb)		(((eb) & EV_EKP__MASK__))
154 
155 #endif /* EV_EDITBITS_H */
156