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