1 |
|
---|
2 | package de.ugoe.cs.autoquest.plugin.mfc.eventcore;
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * <p>
|
---|
6 | * Enumeration to deal with MFC message types.
|
---|
7 | * </p>
|
---|
8 | *
|
---|
9 | * @version 1.0
|
---|
10 | * @author Patrick Harms, Steffen Herbold
|
---|
11 | */
|
---|
12 | public enum WindowsMessageType {
|
---|
13 |
|
---|
14 | WM_NULL(0), WM_CREATE(1), WM_DESTROY(2), WM_MOVE(3), WM_SIZE(5), WM_ACTIVATE(6),
|
---|
15 | WM_SETFOCUS(7), WM_KILLFOCUS(8), WM_ENABLE(10), WM_SETREDRAW(11), WM_SETTEXT(12),
|
---|
16 | WM_GETTEXT(13), WM_GETTEXTLENGTH(14), WM_PAINT(15), WM_CLOSE(16), WM_QUERYENDSESSION(17),
|
---|
17 | WM_QUIT(18), WM_QUERYOPEN(19), WM_ERASEBKGND(20), WM_SYSCOLORCHANGE(21), WM_ENDSESSION(22),
|
---|
18 | WM_SHOWWINDOW(24), WM_CTLCOLOR(25), WM_WININICHANGE(26), WM_DEVMODECHANGE(27), WM_ACTIVATEAPP(
|
---|
19 | 28), WM_FONTCHANGE(29), WM_TIMECHANGE(30), WM_CANCELMODE(31), WM_SETCURSOR(32),
|
---|
20 | WM_MOUSEACTIVATE(33), WM_CHILDACTIVATE(34), WM_QUEUESYNC(35), WM_GETMINMAXINFO(36),
|
---|
21 | WM_PAINTICON(38), WM_ICONERASEBKGND(39), WM_NEXTDLGCTL(40), WM_SPOOLERSTATUS(42), WM_DRAWITEM(
|
---|
22 | 43), WM_MEASUREITEM(44), WM_DELETEITEM(45), WM_VKEYTOITEM(46), WM_CHARTOITEM(47),
|
---|
23 | WM_SETFONT(48), WM_GETFONT(49), WM_SETHOTKEY(50), WM_GETHOTKEY(51), WM_QUERYDRAGICON(55),
|
---|
24 | WM_COMPAREITEM(57), WM_GETOBJECT(61), WM_COMPACTING(65), WM_COMMNOTIFY(68),
|
---|
25 | WM_WINDOWPOSCHANGING(70), WM_WINDOWPOSCHANGED(71), WM_POWER(72), WM_COPYDATA(74),
|
---|
26 | WM_CANCELJOURNAL(75), WM_NOTIFY(78), WM_INPUTLANGCHANGEREQUEST(80), WM_INPUTLANGCHANGE(81),
|
---|
27 | WM_TCARD(82), WM_HELP(83), WM_USERCHANGED(84), WM_NOTIFYFORMAT(85), WM_CONTEXTMENU(123),
|
---|
28 | WM_STYLECHANGING(124), WM_STYLECHANGED(125), WM_DISPLAYCHANGE(126), WM_GETICON(127),
|
---|
29 | WM_SETICON(128), WM_NCCREATE(129), WM_NCDESTROY(130), WM_NCCALCSIZE(131), WM_NCHITTEST(132),
|
---|
30 | WM_NCPAINT(133), WM_NCACTIVATE(134), WM_GETDLGCODE(135), WM_SYNCPAINT(136),
|
---|
31 | WM_NCMOUSEMOVE(160), WM_NCLBUTTONDOWN(161), WM_NCLBUTTONUP(162), WM_NCLBUTTONDBLCLK(163),
|
---|
32 | WM_NCRBUTTONDOWN(164), WM_NCRBUTTONUP(165), WM_NCRBUTTONDBLCLK(166), WM_NCMBUTTONDOWN(167),
|
---|
33 | WM_NCMBUTTONUP(168), WM_NCMBUTTONDBLCLK(169), WM_NCXBUTTONDOWN(171), WM_NCXBUTTONUP(172),
|
---|
34 | WM_NCXBUTTONDBLCLK(173), SBM_SETPOS(224), BM_CLICK(245), WM_INPUT(255), WM_KEYDOWN(256),
|
---|
35 | WM_KEYFIRST(256), WM_KEYUP(257), WM_CHAR(258), WM_DEADCHAR(259), WM_SYSKEYDOWN(260),
|
---|
36 | WM_SYSKEYUP(261), WM_SYSCHAR(262), WM_SYSDEADCHAR(263), WM_KEYLAST(264),
|
---|
37 | WM_WNT_CONVERTREQUESTEX(265), WM_CONVERTREQUEST(266), WM_CONVERTRESULT(267), WM_INTERIM(268),
|
---|
38 | WM_IME_STARTCOMPOSITION(269), WM_IME_ENDCOMPOSITION(270), WM_IME_COMPOSITION(271),
|
---|
39 | WM_IME_KEYLAST(271), WM_INITDIALOG(272), WM_COMMAND(273), WM_SYSCOMMAND(274), WM_TIMER(275),
|
---|
40 | WM_HSCROLL(276), WM_VSCROLL(277), WM_INITMENU(278), WM_INITMENUPOPUP(279), WM_MENUSELECT(287),
|
---|
41 | WM_MENUCHAR(288), WM_ENTERIDLE(289), WM_MENURBUTTONUP(290), WM_MENUDRAG(291), WM_MENUGETOBJECT(
|
---|
42 | 292), WM_UNINTMENUPOPUP(293), WM_MENUCOMMAND(294), WM_CHANGEUISTATE(295), WM_UPDATEUISTATE(
|
---|
43 | 296), WM_QUERYUISTATE(297), WM_CTLCOLORMSGBOX(306), WM_CTLCOLOREDIT(307),
|
---|
44 | WM_CTLCOLORLISTBOX(308), WM_CTLCOLORBTN(309), WM_CTLCOLORDLG(310), WM_CTLCOLORSCROLLBAR(311),
|
---|
45 | WM_CTLCOLORSTATIC(312), CB_SHOWDROPDOWN(335), LB_SETCURSEL(390), WM_MOUSEFIRST(512),
|
---|
46 | WM_MOUSEMOVE(512), WM_LBUTTONDOWN(513), WM_LBUTTONUP(514), WM_LBUTTONDBLCLK(515),
|
---|
47 | WM_RBUTTONDOWN(516), WM_RBUTTONUP(517), WM_RBUTTONDBLCLK(518), WM_MBUTTONDOWN(519),
|
---|
48 | WM_MBUTTONUP(520), WM_MBUTTONDBLCLK(521), WM_MOUSELAST(521), WM_MOUSEWHEEL(522),
|
---|
49 | WM_XBUTTONDOWN(523), WM_XBUTTONUP(524), WM_XBUTTONDBLCLK(525), WM_USER(1024),
|
---|
50 | CB_SETCURSEL(334), TBM_SETPOS(1029), UDM_SETRANGE(1125), TCM_SETCURSEL(4876);
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * <p>
|
---|
54 | * Numerical representation of the message type.
|
---|
55 | * </p>
|
---|
56 | */
|
---|
57 | private int mNumber;
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * <p>
|
---|
61 | * Constructor. Creates a new WindowsMessageType.
|
---|
62 | * </p>
|
---|
63 | *
|
---|
64 | * @param number
|
---|
65 | * numerical representation of the message type
|
---|
66 | */
|
---|
67 | WindowsMessageType(int number) {
|
---|
68 | mNumber = number;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * <p>
|
---|
73 | * Returns the numerical representation of the message type.
|
---|
74 | * </p>
|
---|
75 | *
|
---|
76 | * @return the numerical representation
|
---|
77 | */
|
---|
78 | public int getNumber() {
|
---|
79 | return mNumber;
|
---|
80 | }
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * <p>
|
---|
84 | * Checks if the type of a message generated is a keyboard interaction.
|
---|
85 | * </p>
|
---|
86 | *
|
---|
87 | * @param msgType
|
---|
88 | * type of the message
|
---|
89 | * @return true if it is a keyboard interaction; false otherwise
|
---|
90 | */
|
---|
91 | public boolean isKeyMessage() {
|
---|
92 | boolean isKeyMsg = false;
|
---|
93 | switch (this)
|
---|
94 | {
|
---|
95 | case WM_KEYDOWN:
|
---|
96 | case WM_KEYUP:
|
---|
97 | case WM_SYSKEYDOWN:
|
---|
98 | case WM_SYSKEYUP:
|
---|
99 | isKeyMsg = true;
|
---|
100 | break;
|
---|
101 | default:
|
---|
102 | break;
|
---|
103 | }
|
---|
104 | return isKeyMsg;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * <p>
|
---|
109 | * Checks if the type of a message indicates that the mouse has been pressed down.
|
---|
110 | * </p>
|
---|
111 | *
|
---|
112 | * @param msgType
|
---|
113 | * type of the message
|
---|
114 | * @return true if it is mouse-down message; false otherwise
|
---|
115 | */
|
---|
116 | public boolean isDownMessage() {
|
---|
117 | boolean isDownMsg = false;
|
---|
118 | switch (this)
|
---|
119 | {
|
---|
120 | case WM_LBUTTONDOWN:
|
---|
121 | case WM_RBUTTONDOWN:
|
---|
122 | case WM_MBUTTONDOWN:
|
---|
123 | case WM_XBUTTONDOWN:
|
---|
124 | case WM_NCLBUTTONDOWN:
|
---|
125 | case WM_NCRBUTTONDOWN:
|
---|
126 | case WM_NCMBUTTONDOWN:
|
---|
127 | case WM_NCXBUTTONDOWN:
|
---|
128 | isDownMsg = true;
|
---|
129 | break;
|
---|
130 | default:
|
---|
131 | break;
|
---|
132 | }
|
---|
133 | return isDownMsg;
|
---|
134 | }
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * <p>
|
---|
138 | * Checks if the type of a message indicates that a double click has been performed.
|
---|
139 | * </p>
|
---|
140 | *
|
---|
141 | * @param msgType
|
---|
142 | * type of the message
|
---|
143 | * @return true if it is a double click message; false otherwise
|
---|
144 | */
|
---|
145 | public boolean isDblclkMessage() {
|
---|
146 | boolean isDblclkMsg = false;
|
---|
147 | switch (this)
|
---|
148 | {
|
---|
149 | case WM_LBUTTONDBLCLK:
|
---|
150 | case WM_RBUTTONDBLCLK:
|
---|
151 | case WM_MBUTTONDBLCLK:
|
---|
152 | case WM_XBUTTONDBLCLK:
|
---|
153 | case WM_NCLBUTTONDBLCLK:
|
---|
154 | case WM_NCRBUTTONDBLCLK:
|
---|
155 | case WM_NCMBUTTONDBLCLK:
|
---|
156 | case WM_NCXBUTTONDBLCLK:
|
---|
157 | isDblclkMsg = true;
|
---|
158 | break;
|
---|
159 | default:
|
---|
160 | break;
|
---|
161 | }
|
---|
162 | return isDblclkMsg;
|
---|
163 | }
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * <p>
|
---|
167 | * Checks if the type of a message indicates that the mouse has been released.
|
---|
168 | * </p>
|
---|
169 | *
|
---|
170 | * @param msgType
|
---|
171 | * type of the message
|
---|
172 | * @return true if it is mouse-up message; false otherwise
|
---|
173 | */
|
---|
174 | public boolean isUpMessage() {
|
---|
175 | boolean isUpMsg = false;
|
---|
176 | switch (this)
|
---|
177 | {
|
---|
178 | case WM_LBUTTONUP:
|
---|
179 | case WM_RBUTTONUP:
|
---|
180 | case WM_MBUTTONUP:
|
---|
181 | case WM_XBUTTONUP:
|
---|
182 | case WM_NCLBUTTONUP:
|
---|
183 | case WM_NCRBUTTONUP:
|
---|
184 | case WM_NCMBUTTONUP:
|
---|
185 | case WM_NCXBUTTONUP:
|
---|
186 | isUpMsg = true;
|
---|
187 | break;
|
---|
188 | default:
|
---|
189 | break;
|
---|
190 | }
|
---|
191 | return isUpMsg;
|
---|
192 | }
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * <p>
|
---|
196 | * Parses an {@link String} and returns the respective WindowsMessageType if possible.
|
---|
197 | * </p>
|
---|
198 | *
|
---|
199 | * @param numberString
|
---|
200 | * String representation of the event type
|
---|
201 | * @return created WindowsMessageType
|
---|
202 | * @throws IllegalArgumentException
|
---|
203 | * thrown if there is no WindowsMessageType that correlates to numberString
|
---|
204 | */
|
---|
205 | public static WindowsMessageType parseMessageType(String numberString)
|
---|
206 | throws IllegalArgumentException
|
---|
207 | {
|
---|
208 | try {
|
---|
209 | int number = Integer.parseInt(numberString);
|
---|
210 | return valueOf(number);
|
---|
211 | }
|
---|
212 | catch (NumberFormatException e) {
|
---|
213 | return WindowsMessageType.valueOf(WindowsMessageType.class, numberString);
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * <p>
|
---|
219 | * Returns the WindowsMessageType associated with an integer.
|
---|
220 | * </p>
|
---|
221 | *
|
---|
222 | * @param number
|
---|
223 | * integer to which the according WindowsMessageType is returned
|
---|
224 | * @return the WindowsMessageType
|
---|
225 | * @throws IllegalArgumentException
|
---|
226 | * thrown if there is no WindowsMessageType that correlates to number
|
---|
227 | */
|
---|
228 | public static WindowsMessageType valueOf(int number) throws IllegalArgumentException {
|
---|
229 | for (WindowsMessageType type : WindowsMessageType.values()) {
|
---|
230 | if (type.mNumber == number) {
|
---|
231 | return type;
|
---|
232 | }
|
---|
233 | }
|
---|
234 |
|
---|
235 | throw new IllegalArgumentException("there is no message type with number " + number);
|
---|
236 | }
|
---|
237 | }
|
---|