1
2
3
4
5
6 using System;
7 using System.Collections;
8
9 namespace System.Windows
10 {
11 public const uint WM_DESTROY = 0x2u;
12 public const uint WM_SIZE = 0x0005u;
13 public const uint WM_MOVE = 0x0003u;
14 public const uint WM_ACTIVATE = 0x0006u;
15 public const uint WM_SETFOCUS = 0x0007u;
16 public const uint WM_KILLFOCUS = 0x0008u;
17 public const uint WM_PAINT = 0x000Fu;
18 public const uint WM_CLOSE = 0x0010u;
19 public const uint WM_SHOWWINDOW = 0x0018u;
20 public const uint WM_DRAWITEM = 0x002bu;
21 public const uint WM_SETFONT = 0x0030u;
22 public const uint WM_GETFONT = 0x0031u;
23 public const uint WM_KEYDOWN = 0x0100u;
24 public const uint WM_KEYUP = 0x0101u;
25 public const uint WM_CHAR = 0x0102u;
26 public const uint WM_COMMAND = 0x0111u;
27 public const uint WM_SYSCOMMAND = 0x0112u;
28 public const uint WM_TIMER = 0x0113u;
29 public const uint WM_HSCROLL = 0x0114u;
30 public const uint WM_VSCROLL = 0x0115u;
31 public const uint WM_MOUSEMOVE = 0x0200u;
32 public const uint WM_LBUTTONDOWN = 0x0201u;
33 public const uint WM_LBUTTONUP = 0x0202u;
34 public const uint WM_LBUTTONDBLCLK = 0x0203u;
35 public const uint WM_RBUTTONDOWN = 0x204u;
36 public const uint WM_RBUTTONUP = 0x0205u;
37 public const uint WM_MOUSEWHEEL = 0x020au;
38 public const uint WM_MOUSELEAVE = 0x02a3u;
39 public const uint WM_CLIPBOARDUPDATE = 0x031du;
40 public const uint WM_USER = 0x0400u;
41
42 public const uint EM_SETSEL = 0x00b1u;
43 public const uint BM_SETSTYLE = 0x00f4u;
44 public const uint LB_GETCURSEL = 0x0188u;
45 public const uint LB_ADDSTRING = 0x0180u;
46 public const uint LB_DELETESTRING = 0x0182u;
47 public const uint LB_SETCURSEL = 0x0186u;
48 public const uint LB_INSERTSTRING = 0x0181u;
49 public const uint LB_GETTOPINDEX = 0x018eu;
50 public const uint LB_SETTOPINDEX = 0x0197u;
51 public const uint LB_GETCOUNT = 0x81bu;
52 public const uint LB_GETTEXTLEN = 0x018au;
53 public const uint LB_GETTEXT = 0x0189u;
54 public const uint BM_GETCHECK = 0x00f0u;
55 public const uint BM_SETCHECK = 0x00f1u;
56
57 public const ushort BN_CLICKED = 0u;
58 public const ushort BN_SETFOCUS = 6u;
59 public const ushort BN_KILLFOCUS = 7u;
60 public const ushort EN_CHANGE = 0x0300u;
61 public const ushort EN_SETFOCUS = 0x0100u;
62 public const ushort EN_KILLFOCUS = 0x0200u;
63 public const ushort LBN_SETFOCUS = 0x4u;
64 public const ushort LBN_KILLFOCUS = 0x5u;
65 public const ushort LBN_SELCHANGE = 0x1u;
66 public const ushort BST_CHECKED = 0x1u;
67 public const ushort BST_UNCHECKED = 0x0u;
68
69 public const uint SIZE_MAXIMIZED = 2u;
70 public const uint SIZE_MINIMIZED = 1u;
71 public const uint SIZE_RESTORED = 0u;
72
73 public const uint ODT_MENU = 1u;
74
75 public const uint HOVER_DEFAULT = cast<uint>(-1);
76 public const uint TME_LEAVE = 2u;
77
78 public const uint SC_KEYMENU = 0xF100u;
79 public const uint SC_CLOSE = 0xF060;
80
81 public const ushort SB_BOTTOM = 7u;
82 public const ushort SB_ENDSCROLL = 8u;
83 public const ushort SB_LINEDOWN = 1u;
84 public const ushort SB_LINEUP = 0u;
85 public const ushort SB_PAGEDOWN = 3u;
86 public const ushort SB_PAGEUP = 2u;
87 public const ushort SB_THUMBPOSITION = 4u;
88 public const ushort SB_THUMBTRACK = 5u;
89 public const ushort SB_TOP = 6u;
90 public const ushort SB_LEFT = 6u;
91 public const ushort SB_RIGHT = 7u;
92 public const ushort SB_LINELEFT = 0u;
93 public const ushort SB_LINERIGHT = 1u;
94 public const ushort SB_PAGELEFT = 2u;
95 public const ushort SB_PAGERIGHT = 3u;
96
97 public const uint CM_ENDMODAL = WM_USER + 1u;
98
99 public class PaintEventArgs
100 {
101 public nothrow PaintEventArgs(Graphics& graphics_, const Rect& clipRect_) : graphics(graphics_), clipRect(clipRect_)
102 {
103 }
104 public Graphics& graphics;
105 public Rect clipRect;
106 }
107
108 public enum MouseButtons : uint
109 {
110 none = 0x0u,
111 lbutton = 0x1u,
112 rbutton = 0x2u,
113 shift = 0x4u,
114 control = 0x8u,
115 mbutton = 0x10u,
116 xbutton1 = 0x20u,
117 xbutton2 = 0x40u
118 }
119
120 public class MouseEventArgs
121 {
122 public nothrow MouseEventArgs(const Point& location_, MouseButtons buttons_, int clicks_) : location(location_), buttons(buttons_), clicks(clicks_)
123 {
124 }
125 public Point location;
126 public MouseButtons buttons;
127 public int clicks;
128 }
129
130 public class MouseWheelEventArgs : MouseEventArgs
131 {
132 public nothrow MouseWheelEventArgs(const Point& location_, MouseButtons buttons_, short distance_) : base(location_, buttons_, 0), distance(distance_)
133 {
134 }
135 public short distance;
136 public bool handled;
137 }
138
139 public class KeyPressEventArgs
140 {
141 public nothrow KeyPressEventArgs(wchar keyChar_) : keyChar(keyChar_), handled(false)
142 {
143 }
144 public wchar keyChar;
145 public bool handled;
146 }
147
148 public class KeyEventArgs
149 {
150 public nothrow KeyEventArgs(Keys key_) : key(key_)
151 {
152 }
153 public Keys key;
154 public bool handled;
155 public bool suppressKeyPress;
156 }
157
158 public class TreeViewNodeMouseClickEventArgs
159 {
160 public nothrow TreeViewNodeMouseClickEventArgs(const Point& location_, MouseButtons buttons_, int clicks_, TreeViewNode* node_) :
161 location(location_), buttons(buttons_), clicks(clicks_), node(node_)
162 {
163 }
164 public Point location;
165 public MouseButtons buttons;
166 public int clicks;
167 public TreeViewNode* node;
168 }
169
170 public class TreeViewNodeEventArgs
171 {
172 public nothrow TreeViewNodeEventArgs(TreeViewNode* node_) : node(node_)
173 {
174 }
175 public TreeViewNode* node;
176 }
177
178 public class ControlEventArgs
179 {
180 public nothrow ControlEventArgs(Control* control_) : control(control_)
181 {
182 }
183 public Control* control;
184 }
185
186 public class SizeChangingEventArgs
187 {
188 public nothrow SizeChangingEventArgs(const Size& oldSize_, const Size& newSize_) : oldSize(oldSize_), newSize(newSize_) {}
189 public Size oldSize;
190 public Size newSize;
191 }
192
193 public class RightClickEventArgs
194 {
195 public nothrow RightClickEventArgs(Control* control_, const Point& location_) : control(control_), location(location_)
196 {
197 }
198 public Control* control;
199 public Point location;
200 }
201
202 public class ScrollEventArgs
203 {
204 public nothrow ScrollEventArgs(ushort request_) : request(request_)
205 {
206 }
207 public ushort request;
208 }
209
210 public class TimerEventArgs
211 {
212 public nothrow TimerEventArgs(uint timerId_) : timerId(timerId_)
213 {
214 }
215 public uint timerId;
216 }
217
218 public class Message
219 {
220 public nothrow Message(void* windowHandle_, uint msg_, uint wparam_, long lparam_, long result_) : windowHandle(windowHandle_), msg(msg_), wparam(wparam_), lparam(lparam_), result(result_)
221 {
222 }
223 public inline nothrow ushort WParamLoWord() const
224 {
225 return cast<ushort>(wparam & 0xFFFFu);
226 }
227 public inline nothrow ushort WParamHiWord() const
228 {
229 return cast<ushort>((wparam >> 16u) & 0xFFFFu);
230 }
231 public inline nothrow void* LParamHandle() const
232 {
233 return cast<void*>(cast<ulong>(lparam));
234 }
235 public inline nothrow uint LParamLoDWord() const
236 {
237 return cast<uint>(lparam);
238 }
239 public inline nothrow uint LParamHiDWord() const
240 {
241 return cast<uint>((lparam >> 32u) & 0xFFFFFFFFu);
242 }
243 public inline nothrow int LParamX() const
244 {
245 return cast<int>(cast<short>(LParamLoDWord()));
246 }
247 public inline nothrow int LParamY() const
248 {
249 return cast<int>(cast<short>(LParamLoDWord() >> 16u));
250 }
251 public inline nothrow Size LParamSize() const
252 {
253 uint s = LParamLoDWord();
254 ushort sw = cast<ushort>(s);
255 ushort sh = cast<ushort>(s >> 16u);
256 return Size(cast<int>(sw), cast<int>(sh));
257 }
258 public inline nothrow Point LParamLocation() const
259 {
260 uint s = LParamLoDWord();
261 ushort sx = cast<ushort>(s);
262 ushort sy = cast<ushort>(s >> 16u);
263 return Point(cast<int>(sx), cast<int>(sy));
264 }
265 public void* windowHandle;
266 public uint msg;
267 public uint wparam;
268 public long lparam;
269 public long result;
270 public void* originalWndProc;
271 }
272
273 public class MessageNameMap
274 {
275 static MessageNameMap() : instance(new MessageNameMap())
276 {
277 }
278 public static nothrow MessageNameMap& Instance()
279 {
280 return *instance;
281 }
282 public string GetMessageName(uint message) const
283 {
284 HashMap<uint, string>.ConstIterator it = map.CFind(message);
285 if (it != map.CEnd())
286 {
287 return it->second;
288 }
289 else
290 {
291 return "WM_" + ToHexString(message);
292 }
293 }
294 private MessageNameMap()
295 {
296 map[WM_DESTROY] = "WM_DESTROY";
297 map[WM_SIZE] = "WM_SIZE";
298 map[WM_MOVE] = "WM_MOVE";
299 map[WM_SETFOCUS] = "WM_SETFOCUS";
300 map[WM_KILLFOCUS] = "WM_KILLFOCUS";
301 map[WM_PAINT] = "WM_PAINT";
302 map[WM_CLOSE] = "WM_CLOSE";
303 map[WM_SHOWWINDOW] = "WM_SHOWWINDOW";
304 map[WM_DRAWITEM] = "WM_DRAWITEM";
305 map[WM_SETFONT] = "WM_SETFONT";
306 map[WM_GETFONT] = "WM_GETFONT";
307 map[WM_KEYDOWN] = "WM_KEYDOWN";
308 map[WM_KEYUP] = "WM_KEYUP";
309 map[WM_CHAR] = "WM_CHAR";
310 map[WM_COMMAND] = "WM_COMMAND";
311 map[WM_SYSCOMMAND] = "WM_SYSCOMMAND";
312 map[WM_TIMER] = "WM_TIMER";
313 map[WM_HSCROLL] = "WM_HSCROLL";
314 map[WM_VSCROLL] = "WM_VSCROLL";
315 map[WM_MOUSEMOVE] = "WM_MOUSEMOVE";
316 map[WM_LBUTTONDOWN] = "WM_LBUTTONDOWN";
317 map[WM_LBUTTONUP] = "WM_LBUTTONUP";
318 map[WM_LBUTTONDBLCLK] = "WM_LBUTTONDBLCLK";
319 map[WM_RBUTTONDOWN] = "WM_RBUTTONDOWN";
320 map[WM_RBUTTONUP] = "WM_RBUTTONUP";
321 map[WM_MOUSEWHEEL] = "WM_MOUSEWHEEL";
322 map[WM_MOUSELEAVE] = "WM_MOUSELEAVE";
323 map[WM_CLIPBOARDUPDATE] = "WM_CLIPBOARDUPDATE";
324 map[WM_USER] = "WM_USER";
325 }
326 private static UniquePtr<MessageNameMap> instance;
327 private HashMap<uint, string> map;
328 }
329 }