source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/eventcore/WindowsMessageType.java @ 2215

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