1
2
3
4
5
6 using System;
7 using System.Collections;
8 using System.Windows.API;
9
10 namespace System.Windows
11 {
12 public class delegate void PaintEventHandler(PaintEventArgs& paintEventArgs);
13 public class delegate void MouseEnterEventHandler();
14 public class delegate void MouseEventHandler(MouseEventArgs& mouseEventargs);
15 public class delegate void MouseLeaveEventHandler();
16 public class delegate void MouseWheelEventHandler(MouseWheelEventArgs& mouseWheelEventArgs);
17 public class delegate void KeyPressEventHandler(KeyPressEventArgs& keyPressEventArgs);
18 public class delegate void KeyEventHandler(KeyEventArgs& keyEventArgs);
19 public class delegate void ClickEventHandler();
20 public class delegate void CreatedEventHandler();
21 public class delegate void DestroyedEventHandler();
22 public class delegate void ShownEventHandler();
23 public class delegate void EnabledChangedEventHandler();
24 public class delegate void VisibleChangedEventHandler();
25 public class delegate void SizeChangedEventHandler(uint windowState);
26 public class delegate void SizeChangingEventHandler(SizeChangingEventArgs& args);
27 public class delegate void ChildSizeChangedEventHandler(ControlEventArgs& controlEventArgs);
28 public class delegate void LocationChangedEventHandler();
29 public class delegate void ContentChangedEventHandler();
30 public class delegate void ChildContentChangedEventHandler(ControlEventArgs& controlEventArgs);
31 public class delegate void ContentLocationChangedEventHandler();
32 public class delegate void ChildContentLocationChangedEventHandler(ControlEventArgs& controlEventArgs);
33 public class delegate void ContentSizeChangedEventHandler();
34 public class delegate void ChildContentSizeChangedEventHandler(ControlEventArgs& controlEventArgs);
35 public class delegate void TextChangedEventHandler();
36 public class delegate void HScrollEventHandler(ScrollEventArgs& scrollEventArgs);
37 public class delegate void VScrollEventHandler(ScrollEventArgs& scrollEventArgs);
38 public class delegate void TimerEventHandler(TimerEventArgs& timerEventArgs);
39 public class delegate void GotFocusEventHandler();
40 public class delegate void LostFocusEventHandler();
41 public class delegate void ChildGotFocusEventHandler(ControlEventArgs& controlEventArgs);
42 public class delegate void ChildLostFocusEventHandler(ControlEventArgs& controlEventArgs);
43 public class delegate void ControlEventHandler(ControlEventArgs& args);
44 public class delegate void RightClickEventHandler(RightClickEventArgs& args);
45 public class delegate void ClipboardUpdateEventHandler();
46
47 public inline nothrow WindowClassStyle DefaultWindowClassStyle()
48 {
49 return WindowClassStyle.CS_DEFAULT;
50 }
51
52 public inline nothrow WindowClassStyle DoubleClickWindowClassStyle()
53 {
54 return WindowClassStyle.CS_DBLCLKS;
55 }
56
57 public inline nothrow WindowStyle DefaultChildWindowStyle()
58 {
59 return cast<WindowStyle>(WindowStyle.WS_CHILD | WindowStyle.WS_VISIBLE | WindowStyle.WS_CLIPSIBLINGS);
60 }
61
62 public inline nothrow WindowStyle HiddenChildWindowStyle()
63 {
64 return cast<WindowStyle>(WindowStyle.WS_CHILD | WindowStyle.WS_CLIPSIBLINGS);
65 }
66
67 public inline nothrow WindowStyle DialogWindowStyle()
68 {
69 return cast<WindowStyle>(WindowStyle.WS_CAPTION | WindowStyle.WS_DLGFRAME | WindowStyle.WS_CLIPSIBLINGS);
70 }
71
72 public inline nothrow ExtendedWindowStyle DefaultExtendedWindowStyle()
73 {
74 return ExtendedWindowStyle.WS_EX_DEFAULT;
75 }
76
77 public inline nothrow SystemColor DefaultWindowClassBackgroundColor()
78 {
79 return SystemColor.COLOR_WINDOW;
80 }
81
82 public nothrow Color DefaultControlBackgroundColor()
83 {
84 return GetSystemColor(SystemColor.COLOR_MENU);
85 }
86
87 public const uint mouseHoverTimerId = 2u;
88
89 public nothrow uint DefaultMouseHoverMs()
90 {
91 return 300u;
92 }
93
94 public nothrow Size DefaultMouseHoverRectSize()
95 {
96 return Size(8, 8);
97 }
98
99 public class ControlCreateParams
100 {
101 public nothrow ControlCreateParams() :
102 windowClassName(),
103 windowClassStyle(DefaultWindowClassStyle()),
104 windowStyle(DefaultChildWindowStyle()),
105 extendedWindowStyle(DefaultExtendedWindowStyle()),
106 windowClassBackgroundColor(DefaultWindowClassBackgroundColor()),
107 backgroundColor(DefaultControlBackgroundColor()),
108 text(),
109 location(),
110 size(),
111 anchors(cast<Anchors>(Anchors.left | Anchors.top)),
112 dock(Dock.none)
113 {
114 }
115 public nothrow ControlCreateParams& Defaults()
116 {
117 return *this;
118 }
119 public nothrow ControlCreateParams& SetWindowClassName(const string& windowClassName_)
120 {
121 windowClassName = windowClassName_;
122 return *this;
123 }
124 public nothrow ControlCreateParams& SetWindowClassStyle(WindowClassStyle windowClassStyle_)
125 {
126 windowClassStyle = windowClassStyle_;
127 return *this;
128 }
129 public nothrow ControlCreateParams& SetWindowStyle(WindowStyle windowStyle_)
130 {
131 windowStyle = windowStyle_;
132 return *this;
133 }
134 public nothrow ControlCreateParams& SetExtendedWindowStyle(ExtendedWindowStyle extendedWindowStyle_)
135 {
136 extendedWindowStyle = extendedWindowStyle_;
137 return *this;
138 }
139 public nothrow ControlCreateParams& SetWindowClassBackgroundColor(SystemColor systemColor)
140 {
141 windowClassBackgroundColor = systemColor;
142 return *this;
143 }
144 public nothrow ControlCreateParams& SetBackgroundColor(const Color& backgroundColor_)
145 {
146 backgroundColor = backgroundColor_;
147 return *this;
148 }
149 public nothrow ControlCreateParams& SetText(const string& text_)
150 {
151 text = text_;
152 return *this;
153 }
154 public nothrow ControlCreateParams& SetLocation(const Point& location_)
155 {
156 location = location_;
157 return *this;
158 }
159 public nothrow ControlCreateParams& SetSize(const Size& size_)
160 {
161 size = size_;
162 return *this;
163 }
164 public nothrow ControlCreateParams& SetDock(Dock dock_)
165 {
166 dock = dock_;
167 return *this;
168 }
169 public nothrow ControlCreateParams& SetAnchors(Anchors anchors_)
170 {
171 anchors = anchors_;
172 return *this;
173 }
174 public string windowClassName;
175 public WindowClassStyle windowClassStyle;
176 public WindowStyle windowStyle;
177 public ExtendedWindowStyle extendedWindowStyle;
178 public SystemColor windowClassBackgroundColor;
179 public Color backgroundColor;
180 public string text;
181 public Point location;
182 public Size size;
183 public Dock dock;
184 public Anchors anchors;
185 }
186
187 public abstract class Control : Component
188 {
189 private enum Flags : short
190 {
191 none = 0, mouseInClient = 1 << 0, lbuttonPressed = 1 << 1, menuWantsKeys = 1 << 2, keyDownHandled = 1 << 3, focused = 1 << 4,
192 caretCreated = 1 << 5, caretShown = 1 << 6, disabled = 1 << 7, hidden = 1 << 8, tabStop = 1 << 9, baseOnCreatedCalled = 1 << 10,
193 mouseHoverTimerStarted = 1 << 11, doubleBuffered = 1 << 12, scrollSubject = 1 << 13
194 }
195 public Control(const string& windowClassName_, WindowClassStyle windowClassStyle_, WindowStyle style_, ExtendedWindowStyle exStyle_,
196 const Color& backgroundColor_, const string& text_, const Point& location_, const Size& size_, Dock dock_, Anchors anchors_) :
197 windowClassName(windowClassName_), windowClassStyle(windowClassStyle_), style(style_), exStyle(exStyle_),
198 windowClassBackgroundColor(DefaultWindowClassBackgroundColor()), backgroundColor(backgroundColor_), handle(null), text(text_),
199 location(location_), size(size_), contentLocation(0, 0), contentSize(), dock(dock_), anchors(anchors_), flags(Flags.none),
200 arrowCursor(LoadStandardCursor(StandardCursorId.IDC_ARROW)), caretShowCount(0), font(null), fontHandle(null), originalWndProc(null),
201 mouseHoverMs(0u), mouseHoverRectSize(DefaultMouseHoverRectSize())
202 {
203 Init();
204 }
205 public Control(ControlCreateParams& createParams) :
206 windowClassName(createParams.windowClassName), windowClassStyle(createParams.windowClassStyle), style(createParams.windowStyle),
207 exStyle(createParams.extendedWindowStyle), windowClassBackgroundColor(createParams.windowClassBackgroundColor),
208 backgroundColor(createParams.backgroundColor), handle(null), text(createParams.text), location(createParams.location),
209 size(createParams.size), contentLocation(0, 0), contentSize(), dock(createParams.dock), anchors(createParams.anchors), flags(Flags.none),
210 arrowCursor(LoadStandardCursor(StandardCursorId.IDC_ARROW)), caretShowCount(0), font(null), fontHandle(null), originalWndProc(null),
211 mouseHoverMs(0u), mouseHoverRectSize(DefaultMouseHoverRectSize())
212 {
213 Init();
214 }
215 private void Init()
216 {
217 if ((style & WindowStyle.WS_DISABLED) != 0)
218 {
219 SetDisabled();
220 }
221 if ((style & WindowStyle.WS_VISIBLE) == 0)
222 {
223 SetHidden();
224 }
225 if ((style & WindowStyle.WS_TABSTOP) != 0)
226 {
227 SetTabStop();
228 }
229 Application.Init();
230 if ((style & WindowStyle.WS_CHILD) == 0)
231 {
232 CreateWindow();
233 }
234 SetScrollUnits(10, 10);
235 }
236 public ~Control()
237 {
238 if (handle != null)
239 {
240 Application.GetWindowManager().RemoveWindow(this);
241 WinDestroyWindow(handle);
242 }
243 }
244 protected void CreateWindow()
245 {
246 CreateWindowInternal();
247 }
248 public nothrow Control* ParentControl() const
249 {
250 Control* parentControl = null;
251 Container* container = GetContainer();
252 if (container != null)
253 {
254 Component* parent = container->Parent();
255 if (parent != null && (parent is Control*))
256 {
257 parentControl = cast<Control*>(parent);
258 }
259 }
260 return parentControl;
261 }
262 public nothrow string ParentText() const
263 {
264 string parentText;
265 Control* parentControl = ParentControl();
266 if (parentControl != null)
267 {
268 parentText = "parent:" + string(typename(*parentControl)) + "." + parentControl->Text() + ".parentHandle=" +
269 ToHexString(cast<ulong>(parentControl->Handle()));
270 }
271 return parentText;
272 }
273 internal nothrow void SetWindowCreateStyleFromFlags()
274 {
275 if (IsDisabled())
276 {
277 style = cast<WindowStyle>(style | WindowStyle.WS_DISABLED);
278 }
279 else
280 {
281 style = cast<WindowStyle>(style & ~WindowStyle.WS_DISABLED);
282 }
283 if (Hidden())
284 {
285 style = cast<WindowStyle>(style & ~WindowStyle.WS_VISIBLE);
286 }
287 else
288 {
289 style = cast<WindowStyle>(style | WindowStyle.WS_VISIBLE);
290 }
291 }
292 internal void CreateWindowInternal()
293 {
294 if (handle != null) return;
295 Control* parentControl = ParentControl();
296 SetWindowCreateStyleFromFlags();
297 if (Application.GetWindowManager().IsSystemClassName(windowClassName.Chars()))
298 {
299 handle = CreateWindowByClassName(windowClassName.Chars(), text.Chars(), style, exStyle, location, size, parentControl);
300 }
301 else
302 {
303 ushort windowClass = Application.GetWindowManager().RegisterWindowClass(
304 windowClassName.Chars(), windowClassStyle, windowClassBackgroundColor);
305 handle = CreateWindowByClassAtom(windowClass, text.Chars(), style, exStyle, location, size, parentControl);
306 }
307 if (!createList.IsEmpty())
308 {
309 for (Control* childControl : createList)
310 {
311 childControl->CreateWindowInternal();
312 }
313 createList.Clear();
314 }
315 Application.GetWindowManager().AddWindow(this);
316 OnCreated();
317 WinRect clientRect = GetClientRect();
318 if ((style & WindowStyle.WS_CHILD) == 0)
319 {
320 WinRect windowRect = GetWindowRect();
321 location.x = windowRect.left;
322 location.y = windowRect.top;
323 }
324 size.w = clientRect.right - clientRect.left;
325 size.h = clientRect.bottom - clientRect.top;
326 if (parentControl != null && parentControl->createList.IsEmpty())
327 {
328 DockWindow();
329 }
330 }
331 internal void AddChildVisual(Control* child)
332 {
333 if (handle != null)
334 {
335 if (child->Handle() == null)
336 {
337 child->CreateWindowInternal();
338 }
339 else
340 {
341 child->SetParentWindow(this);
342 }
343 if ((child->GetWindowStyle() & WindowStyle.WS_VISIBLE) != 0)
344 {
345 child->Show();
346 child->Update();
347 }
348 }
349 else
350 {
351 createList.Add(child);
352 }
353 }
354 public virtual nothrow ContainerControl* GetContainerControl() const
355 {
356 Control* parentControl = ParentControl();
357 if (parentControl != null)
358 {
359 return parentControl->GetContainerControl();
360 }
361 return null;
362 }
363 public Window* GetWindow() const
364 {
365 Control* thisControl = this;
366 if (thisControl is Window*)
367 {
368 return cast<Window*>(this);
369 }
370 Container* container = GetContainer();
371 if (container != null)
372 {
373 Component* parent = container->Parent();
374 if (parent != null)
375 {
376 if (parent is Window*)
377 {
378 return cast<Window*>(parent);
379 }
380 else if (parent is Control*)
381 {
382 Control* control = cast<Control*>(parent);
383 return control->GetWindow();
384 }
385 }
386 }
387 return null;
388 }
389 internal void SetParentWindow(Control* parentWindow)
390 {
391 SetParentWindow(handle, parentWindow->handle);
392 DockWindow();
393 }
394 public inline nothrow bool IsEnabled() const
395 {
396 return !IsDisabled();
397 }
398 public void Enable()
399 {
400 if (IsDisabled())
401 {
402 ResetDisabled();
403 style = cast<WindowStyle>(style & ~WindowStyle.WS_DISABLED);
404 if (handle != null)
405 {
406 EnableWindow(true);
407 }
408 OnEnabledChanged();
409 }
410 }
411 public void Disable()
412 {
413 if (!IsDisabled())
414 {
415 SetDisabled();
416 style = cast<WindowStyle>(style | WindowStyle.WS_DISABLED);
417 if (handle != null)
418 {
419 EnableWindow(false);
420 }
421 OnEnabledChanged();
422 }
423 }
424 protected virtual void OnEnabledChanged()
425 {
426 enabledChangedEvent.Fire();
427 }
428 internal void EnableWindow(bool enable)
429 {
430 WinEnableWindow(handle, enable);
431 }
432 public void BringToFront()
433 {
434 BringWindowToTop(handle);
435 }
436 public Control* TopControl() const
437 {
438 void* topWindowHandle = GetTopWindow(handle);
439 if (topWindowHandle != null)
440 {
441 return Application.GetWindowManager().GetWindow(topWindowHandle);
442 }
443 else
444 {
445 return null;
446 }
447 }
448 public inline nothrow bool IsVisible() const
449 {
450 return !Hidden();
451 }
452 public void Show()
453 {
454 if (Hidden())
455 {
456 ResetHidden();
457 style = cast<WindowStyle>(style | WindowStyle.WS_VISIBLE);
458 OnVisibleChanged();
459 }
460 if (handle != null)
461 {
462 ShowWindow(ShowCommand.SW_SHOW);
463 }
464 }
465 public void Hide()
466 {
467 if (handle != null)
468 {
469 ShowWindow(ShowCommand.SW_HIDE);
470 }
471 if (!Hidden())
472 {
473 SetHidden();
474 style = cast<WindowStyle>(style & ~WindowStyle.WS_VISIBLE);
475 OnVisibleChanged();
476 }
477 }
478 public void ShowWindow(ShowCommand showCommand)
479 {
480 WinShowWindow(handle, showCommand);
481 if (showCommand == ShowCommand.SW_HIDE)
482 {
483 if (!Hidden())
484 {
485 SetHidden();
486 style = cast<WindowStyle>(style & ~WindowStyle.WS_VISIBLE);
487 OnVisibleChanged();
488 }
489 }
490 }
491 protected virtual void OnVisibleChanged()
492 {
493 visibleChangedEvent.Fire();
494 }
495 public void Update()
496 {
497 WinUpdateWindow(handle);
498 }
499 internal virtual nothrow Control* GetFirstEnabledTabStopControl() const
500 {
501 if (IsTabStop() && IsEnabled())
502 {
503 return this;
504 }
505 else
506 {
507 return null;
508 }
509 }
510 internal virtual nothrow Control* GetLastEnabledTabStopControl() const
511 {
512 if (IsTabStop() && IsEnabled())
513 {
514 return this;
515 }
516 else
517 {
518 return null;
519 }
520 }
521 public void SetFocus()
522 {
523 Control* focusedControl = Application.GetFocusedControl();
524 if (focusedControl != null)
525 {
526 currentModifierKeys = focusedControl->currentModifierKeys;
527 Keys emptyModifierKeys;
528 focusedControl->currentModifierKeys = emptyModifierKeys;
529 }
530 WinSetFocus(Handle());
531 Window* window = GetWindow();
532 if (window != null)
533 {
534 window->SetFocusedControl(this);
535 }
536 }
537 public nothrow const string& Text() const
538 {
539 return text;
540 }
541 public void SetText(const string& text_)
542 {
543 if (text != text_)
544 {
545 text = text_;
546 SetWindowText(handle, text);
547 OnTextChanged();
548 }
549 }
550 internal void SetTextInternal(const string& text_)
551 {
552 if (text != text_)
553 {
554 text = text_;
555 OnTextChanged();
556 }
557 }
558 public int GetWindowTextLength() const
559 {
560 return GetWindowTextLength(handle);
561 }
562 public string GetWindowText()
563 {
564 return GetWindowText(handle);
565 }
566 protected virtual void OnTextChanged()
567 {
568 textChangedEvent.Fire();
569 }
570 public const Point& Location()
571 {
572 if ((style & WindowStyle.WS_CHILD) == 0)
573 {
574 WinRect windowRect = GetWindowRect();
575 location.x = windowRect.left;
576 location.y = windowRect.top;
577 }
578 return location;
579 }
580 public void SetLocation(const Point& loc)
581 {
582 if (location != loc)
583 {
584 location = loc;
585 if (handle != null)
586 {
587 MoveWindow(handle, location, size, true);
588 }
589 OnLocationChanged();
590 }
591 }
592 internal void SetLocationInternal(const Point& loc)
593 {
594 if (location != loc)
595 {
596 location = loc;
597 OnLocationChanged();
598 }
599 }
600 protected virtual void OnLocationChanged()
601 {
602 locationChangedEvent.Fire();
603 }
604 public nothrow const Size& GetSize() const
605 {
606 return size;
607 }
608 internal nothrow void SetSizeInternal(const Size& sz, uint windowState)
609 {
610 if (size != sz)
611 {
612 size = sz;
613 OnSizeChanged(windowState);
614 }
615 }
616 public void SetSize(const Size& sz)
617 {
618 if (size != sz)
619 {
620 SizeChangingEventArgs sizeChangingArgs(size, sz);
621 OnSizeChanging(sizeChangingArgs);
622 SetSizeInternal(sz, SIZE_RESTORED);
623 if (handle != null)
624 {
625 MoveWindow(handle, location, size, true);
626 }
627 if (IsScrollSubject())
628 {
629 Control* parentControl = ParentControl();
630 if (parentControl != null)
631 {
632 ControlEventArgs args(this);
633 parentControl->OnChildSizeChanged(args);
634 }
635 }
636 }
637 }
638 public void SendSetFontMessage(const FontHandle& fontHandle)
639 {
640 if (Handle() != null)
641 {
642 WinSendMessage(Handle(), WM_SETFONT, cast<uint>(cast<ulong>(fontHandle.HFont())), 0);
643 }
644 }
645 protected virtual void OnSizeChanged(uint windowState)
646 {
647 sizeChangedEvent.Fire(windowState);
648 }
649 protected virtual void OnSizeChanging(SizeChangingEventArgs& args)
650 {
651 sizeChangingEvent.Fire(args);
652 }
653 public void FireChildSizeChanged(ControlEventArgs& args)
654 {
655 OnChildSizeChanged(args);
656 }
657 protected virtual void OnChildSizeChanged(ControlEventArgs& args)
658 {
659 childSizeChangedEvent.Fire(args);
660 }
661 public void SetContentChanged()
662 {
663 OnContentChanged();
664 Control* parentControl = ParentControl();
665 if (parentControl != null)
666 {
667 ControlEventArgs args(this);
668 parentControl->OnChildContentChanged(args);
669 }
670 }
671 protected virtual void OnContentChanged()
672 {
673 contentChangedEvent.Fire();
674 }
675 protected virtual void OnChildContentChanged(ControlEventArgs& args)
676 {
677 childContentChangedEvent.Fire(args);
678 }
679 public inline nothrow const Point& ContentLocation() const
680 {
681 return contentLocation;
682 }
683 internal virtual nothrow void SetContentLocationInternal(const Point& contentLocation_)
684 {
685 contentLocation = contentLocation_;
686 OnContentLocationChanged();
687 }
688 public void SetContentLocation(const Point& contentLocation_)
689 {
690 if (contentLocation != contentLocation_)
691 {
692 contentLocation = contentLocation_;
693 OnContentLocationChanged();
694 Control* parentControl = ParentControl();
695 if (parentControl != null)
696 {
697 ControlEventArgs args(this);
698 parentControl->OnChildContentLocationChanged(args);
699 }
700 }
701 }
702 protected virtual void OnContentLocationChanged()
703 {
704 contentLocationChangedEvent.Fire();
705 }
706 protected virtual void OnChildContentLocationChanged(ControlEventArgs& args)
707 {
708 childContentLocationChangedEvent.Fire(args);
709 }
710 public inline nothrow const Size& ContentSize() const
711 {
712 return contentSize;
713 }
714 public void SetContentSize(const Size& contentSize_)
715 {
716 if (contentSize != contentSize_)
717 {
718 contentSize = contentSize_;
719 OnContentSizeChanged();
720 Control* parentControl = ParentControl();
721 if (parentControl != null)
722 {
723 ControlEventArgs args(this);
724 parentControl->OnChildContentSizeChanged(args);
725 }
726 }
727 }
728 protected virtual void OnContentSizeChanged()
729 {
730 contentSizeChangedEvent.Fire();
731 }
732 protected virtual void OnChildContentSizeChanged(ControlEventArgs& args)
733 {
734 childContentSizeChangedEvent.Fire(args);
735 }
736 public nothrow void SetScrollUnits(int verticalScrollUnit_, int horizontalScrollUnit_)
737 {
738 verticalScrollUnit = verticalScrollUnit_;
739 horizontalScrollUnit = horizontalScrollUnit_;
740 }
741 public nothrow Pair<int, int> GetScrollUnits() const
742 {
743 return MakePair(verticalScrollUnit, horizontalScrollUnit);
744 }
745 protected virtual void SetCaretLocation()
746 {
747 SetCaretPos(Point(0, 0));
748 }
749 public inline nothrow Dock GetDock() const
750 {
751 return dock;
752 }
753 public void SetDock(Dock dock_)
754 {
755 dock = dock_;
756 if (dock != Dock.none)
757 {
758 DockWindow();
759 }
760 }
761 public void DockWindow()
762 {
763 Control* parentControl = ParentControl();
764 if (parentControl != null)
765 {
766 if (parentControl is ContainerControl*)
767 {
768 ContainerControl* containerParent = cast<ContainerControl*>(parentControl);
769 containerParent->DockChildren();
770 }
771 }
772 }
773 internal void DockWindow(Rect& parentRect)
774 {
775 if (dock == Dock.none) return;
776 if (handle == null) return;
777 LogView* logView = Application.GetLogView();
778 Point parentLoc = parentRect.location;
779 Size parentSize = parentRect.size;
780 Point newLocation = location;
781 Size newSize = size;
782 switch (dock)
783 {
784 case Dock.left:
785 {
786 newLocation = parentLoc;
787 newSize.h = parentSize.h;
788 parentRect.location = Point(parentLoc.x + size.w, parentLoc.y);
789 parentRect.size = Size(parentSize.w - size.w, parentSize.h);
790 if (Debug.Docking())
791 {
792 if (logView != null)
793 {
794 logView->WriteLine("Dock.left " + text + ": [" + Rect(newLocation, newSize).ToString() + "], [" + parentRect.ToString() + "]");
795 }
796 }
797 break;
798 }
799 case Dock.top:
800 {
801 newLocation = parentLoc;
802 newSize.w = parentSize.w;
803 parentRect.location = Point(parentLoc.x, parentLoc.y + size.h);
804 parentRect.size = Size(parentSize.w, parentSize.h - size.h);
805 if (Debug.Docking())
806 {
807 if (logView != null)
808 {
809 logView->WriteLine("Dock.top " + text + ": [" + Rect(newLocation, newSize).ToString() + "], [" + parentRect.ToString() + "]");
810 }
811 }
812 break;
813 }
814 case Dock.right:
815 {
816 newLocation = Point(parentLoc.x + parentSize.w - size.w, parentLoc.y);
817 newSize.h = parentSize.h;
818 parentRect.size = Size(parentSize.w - size.w, parentSize.h);
819 if (Debug.Docking())
820 {
821 if (logView != null)
822 {
823 logView->WriteLine("Dock.right " + text + ": [" + Rect(newLocation, newSize).ToString() + "], [" + parentRect.ToString() + "]");
824 }
825 }
826 break;
827 }
828 case Dock.bottom:
829 {
830 newLocation = Point(parentLoc.x, parentLoc.y + parentSize.h - size.h);
831 newSize.w = parentSize.w;
832 parentRect.size = Size(parentSize.w, parentSize.h - size.h);
833 if (Debug.Docking())
834 {
835 if (logView != null)
836 {
837 logView->WriteLine("Dock.bottom " + text + ": [" + Rect(newLocation, newSize).ToString() + "], [" + parentRect.ToString() + "]");
838 }
839 }
840 break;
841 }
842 case Dock.fill:
843 {
844 newLocation = parentLoc;
845 newSize = parentSize;
846 parentRect.location = Point();
847 parentRect.size = Size();
848 if (Debug.Docking())
849 {
850 if (logView != null)
851 {
852 logView->WriteLine("Dock.fill " + text + ": [" + Rect(newLocation, newSize).ToString() + "], [" + parentRect.ToString() + "]");
853 }
854 }
855 break;
856 }
857 }
858 if (location != newLocation || size != newSize)
859 {
860 SetLocation(newLocation);
861 SetSize(newSize);
862 MoveWindow(handle, location, size, true);
863 }
864 }
865 internal void MoveWindow(int dx, int dy)
866 {
867 Point newLocation = location;
868 Size newSize = size;
869 bool leftAnchored = cast<Anchors>(anchors & Anchors.left) != Anchors.none;
870 bool rightAnchored = cast<Anchors>(anchors & Anchors.right) != Anchors.none;
871 if (!leftAnchored)
872 {
873 newLocation.x = newLocation.x + dx;
874 }
875 else if (rightAnchored)
876 {
877 newSize.w = newSize.w + dx;
878 }
879 bool topAnchored = cast<Anchors>(anchors & Anchors.top) != Anchors.none;
880 bool bottomAnchored = cast<Anchors>(anchors & Anchors.bottom) != Anchors.none;
881 if (!topAnchored)
882 {
883 newLocation.y = newLocation.y + dy;
884 }
885 else if (bottomAnchored)
886 {
887 newSize.h = newSize.h + dy;
888 }
889 if (location != newLocation || size != newSize)
890 {
891 SetLocation(newLocation);
892 SetSize(newSize);
893 MoveWindow(handle, location, size, true);
894 }
895 }
896 public inline nothrow Anchors GetAnchors() const
897 {
898 return anchors;
899 }
900 public inline nothrow void SetAnchors(Anchors anchors_)
901 {
902 anchors = anchors_;
903 }
904 public virtual nothrow Padding DefaultPadding() const
905 {
906 return Padding();
907 }
908 public WinRect GetClientRect() const
909 {
910 return GetClientRect(handle);
911 }
912 public WinRect GetWindowRect() const
913 {
914 return GetWindowRect(handle);
915 }
916 public Point ClientToScreen(const Point& point) const
917 {
918 return ClientToScreen(handle, point);
919 }
920 public Point ScreenToClient(const Point& point) const
921 {
922 return ScreenToClient(handle, point);
923 }
924 internal bool ProcessMessageInternal(Message& message)
925 {
926 return ProcessMessage(message);
927 }
928 public virtual void PrintWindowTree(int level)
929 {
930 LogView* log = Application.GetLogView();
931 if (log != null)
932 {
933 log->WriteLine(string(' ', level) + "Control." + Text() + ".handle=" + ToHexString(cast<ulong>(Handle())) + " " + ParentText() + "[" + Rect(Point(), GetSize()).ToString() + "]");
934 }
935 }
936 public virtual void ScrollLineDown()
937 {
938 Control* parent = ParentControl();
939 if (parent != null)
940 {
941 parent->ScrollLineDown();
942 }
943 }
944 public virtual void ScrollLineUp()
945 {
946 Control* parent = ParentControl();
947 if (parent != null)
948 {
949 parent->ScrollLineUp();
950 }
951 }
952 protected void SubClassCommandWndProc()
953 {
954 if (originalWndProc == null && handle != null)
955 {
956 originalWndProc = WinSubClassCommandWndProc(handle);
957 }
958 }
959 protected virtual bool ProcessMessage(Message& message)
960 {
961 if (originalWndProc != null)
962 {
963
964
965 if (message.originalWndProc == null)
966 {
967 message.originalWndProc = originalWndProc;
968 }
969
970
971 if (message.msg != WM_COMMAND && message.msg != WM_DESTROY)
972 {
973 return false;
974 }
975
976 }
977 switch (message.msg)
978 {
979 case WM_PAINT:
980 {
981 DoPaint();
982 message.result = 0;
983 return true;
984 }
985 case WM_MOUSEMOVE:
986 {
987 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam), 0);
988 DoMouseMove(args);
989 message.result = 0;
990 return true;
991 }
992 case WM_MOUSELEAVE:
993 {
994 DoMouseLeave();
995 message.result = 0;
996 return true;
997 }
998 case WM_LBUTTONDOWN:
999 {
1000 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam | MouseButtons.lbutton), 1);
1001 DoMouseDown(args);
1002 message.result = 0;
1003 return true;
1004 }
1005 case WM_LBUTTONUP:
1006 {
1007 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam | MouseButtons.lbutton), 1);
1008 DoMouseUp(args);
1009 message.result = 0;
1010 return true;
1011 }
1012 case WM_LBUTTONDBLCLK:
1013 {
1014 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam | MouseButtons.lbutton), 2);
1015 DoMouseDoubleClick(args);
1016 message.result = 0;
1017 return true;
1018 }
1019 case WM_RBUTTONDOWN:
1020 {
1021 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam | MouseButtons.rbutton), 1);
1022 DoMouseDown(args);
1023 message.result = 0;
1024 return true;
1025 }
1026 case WM_RBUTTONUP:
1027 {
1028 MouseEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(message.wparam | MouseButtons.rbutton), 1);
1029 DoMouseUp(args);
1030 message.result = 0;
1031 return true;
1032 }
1033 case WM_CHAR:
1034 {
1035 wchar ch = cast<wchar>(message.wparam);
1036 KeyPressEventArgs args(ch);
1037 DoKeyPress(args);
1038 if (args.handled)
1039 {
1040 message.result = 0;
1041 return true;
1042 }
1043 break;
1044 }
1045 case WM_KEYDOWN:
1046 {
1047 int virtualKeyCode = cast<int>(message.wparam);
1048 if (DoKeyDown(virtualKeyCode))
1049 {
1050 message.result = 0;
1051 return true;
1052 }
1053 break;
1054 }
1055 case WM_KEYUP:
1056 {
1057 int virtualKeyCode = cast<int>(message.wparam);
1058 if (DoKeyUp(virtualKeyCode))
1059 {
1060 message.result = 0;
1061 return true;
1062 }
1063 break;
1064 }
1065 case WM_SYSCOMMAND:
1066 {
1067 if (DoSysCommand(message.wparam, message.lparam))
1068 {
1069 message.result = 0;
1070 return true;
1071 }
1072 break;
1073 }
1074 case WM_HSCROLL:
1075 {
1076 ushort request = message.WParamLoWord();
1077 DoHScroll(request);
1078 message.result = 0;
1079 return true;
1080 }
1081 case WM_VSCROLL:
1082 {
1083 ushort request = message.WParamLoWord();
1084 DoVScroll(request);
1085 message.result = 0;
1086 return true;
1087 }
1088 case WM_MOUSEWHEEL:
1089 {
1090 MouseWheelEventArgs args(Point(message.LParamX(), message.LParamY()), cast<MouseButtons>(cast<uint>(cast<ushort>(message.wparam))), cast<short>(message.wparam >> 16u));
1091 DoMouseWheel(args);
1092 if (args.handled)
1093 {
1094 message.result = 0;
1095 return true;
1096 }
1097 break;
1098 }
1099 case WM_SETFOCUS:
1100 {
1101 DoSetFocus();
1102 message.result = 0;
1103 return true;
1104 }
1105 case WM_KILLFOCUS:
1106 {
1107 DoKillFocus();
1108 message.result = 0;
1109 return true;
1110 }
1111 case WM_SHOWWINDOW:
1112 {
1113 if (message.wparam == 1)
1114 {
1115 OnShown();
1116 }
1117 message.result = 0;
1118 return true;
1119 }
1120 case WM_TIMER:
1121 {
1122 DoTimer(message.wparam);
1123 message.result = 0;
1124 return true;
1125 }
1126 case WM_DESTROY:
1127 {
1128 DoDestroy();
1129 message.result = 0;
1130 return true;
1131 }
1132 case WM_CLIPBOARDUPDATE:
1133 {
1134 DoClipboardUpdate();
1135 message.result = 0;
1136 return true;
1137 }
1138 case WM_MOVE:
1139 {
1140 Point newLocation = message.LParamLocation();
1141 Point oldLocation = Location();
1142 if (newLocation != oldLocation)
1143 {
1144 SetLocationInternal(newLocation);
1145 }
1146 message.result = 0;
1147 return true;
1148 }
1149 case WM_SIZE:
1150 {
1151 Size newSize = message.LParamSize();
1152 Size oldSize = GetSize();
1153 uint windowState = message.wparam;
1154 if (newSize != oldSize)
1155 {
1156 SetSizeInternal(newSize, windowState);
1157 }
1158 message.result = 0;
1159 return true;
1160 }
1161 case WM_COMMAND:
1162 {
1163 void* childWindowHandle = message.LParamHandle();
1164 ushort notificationCode = message.WParamHiWord();
1165 ushort controlId = message.WParamLoWord();
1166 Control* child = Application.GetWindowManager().GetWindow(childWindowHandle);
1167 if (child != null)
1168 {
1169 switch (notificationCode)
1170 {
1171 case BN_CLICKED:
1172 {
1173 child->OnClick();
1174 message.result = 0;
1175 return true;
1176 }
1177 case BN_SETFOCUS:
1178 {
1179 child->DoGotFocus();
1180 message.result = 0;
1181 return true;
1182 }
1183 case BN_KILLFOCUS:
1184 {
1185 child->DoLostFocus();
1186 message.result = 0;
1187 return true;
1188 }
1189 case EN_CHANGE:
1190 {
1191 child->SetTextInternal(child->GetWindowText());
1192 message.result = 0;
1193 return true;
1194 }
1195 case EN_SETFOCUS:
1196 {
1197 child->DoGotFocus();
1198 message.result = 0;
1199 return true;
1200 }
1201 case EN_KILLFOCUS:
1202 {
1203 child->DoLostFocus();
1204 message.result = 0;
1205 return true;
1206 }
1207 case LBN_SETFOCUS:
1208 {
1209 child->DoGotFocus();
1210 message.result = 0;
1211 return true;
1212 }
1213 case LBN_KILLFOCUS:
1214 {
1215 child->DoLostFocus();
1216 message.result = 0;
1217 return true;
1218 }
1219 case LBN_SELCHANGE:
1220 {
1221 if (child is ListBox*)
1222 {
1223 ListBox* listBox = cast<ListBox*>(child);
1224 listBox->SelectedIndexChangedInternal();
1225 }
1226 message.result = 0;
1227 return true;
1228 }
1229 }
1230 }
1231 break;
1232 }
1233 }
1234 return false;
1235 }
1236 private void DoDestroy()
1237 {
1238 OnDestroyed();
1239 if (originalWndProc != null)
1240 {
1241 WinRestoreOriginalWndProc(handle, originalWndProc);
1242 }
1243 }
1244 private void DoClipboardUpdate()
1245 {
1246 OnClipboardUpdate();
1247 }
1248 protected virtual void OnClipboardUpdate()
1249 {
1250 clipboardUpdateEvent.Fire();
1251 }
1252 private bool DoSysCommand(uint wparam, long lparam)
1253 {
1254 switch (wparam)
1255 {
1256 case SC_KEYMENU:
1257 {
1258 wchar accessKey = cast<wchar>(ToUpper(cast<uchar>(cast<wchar>(lparam))));
1259 if (DoMenu(accessKey, Keys.none))
1260 {
1261 return true;
1262 }
1263 else
1264 {
1265 if (lparam == VK_F10)
1266 {
1267 if (DoKeyDown(cast<int>(lparam)))
1268 {
1269 return true;
1270 }
1271 }
1272 else
1273 {
1274 currentModifierKeys = cast<Keys>(currentModifierKeys | Keys.altModifier);
1275 }
1276 if (DoKeyDown(cast<int>(accessKey)))
1277 {
1278 currentModifierKeys = cast<Keys>(currentModifierKeys & ~Keys.altModifier);
1279 return true;
1280 }
1281 currentModifierKeys = cast<Keys>(currentModifierKeys & ~Keys.altModifier);
1282 }
1283 break;
1284 }
1285 case SC_CLOSE:
1286 {
1287 KeyEventArgs args(cast<Keys>(Keys.f4 | Keys.altModifier));
1288 DoMenu(args);
1289 if (args.handled)
1290 {
1291 return true;
1292 }
1293 break;
1294 }
1295 }
1296 return false;
1297 }
1298 public nothrow void ResetModifierKeys()
1299 {
1300 currentModifierKeys = Keys.none;
1301 }
1302 private bool DoKeyDown(int virtualKeyCode)
1303 {
1304 LogView* logView = Application.GetLogView();
1305 if (logView != null)
1306 {
1307 string s = "DoKeyDown: " + ToString(cast<Keys>(virtualKeyCode)) + " " + ToHexString(cast<uint>(virtualKeyCode));
1308 logView->WriteLine(s);
1309 }
1310 ResetKeyDownHandled();
1311 if (MenuWantsKeys())
1312 {
1313 if (DoMenu('\0', cast<Keys>(virtualKeyCode)))
1314 {
1315 SetKeyDownHandled();
1316 return true;
1317 }
1318 }
1319 Keys key = cast<Keys>(virtualKeyCode);
1320 if (WinKeyPressed(VK_SHIFT))
1321 {
1322 key = cast<Keys>(key | Keys.shiftModifier);
1323 }
1324 if (WinKeyPressed(VK_CONTROL))
1325 {
1326 key = cast<Keys>(key | Keys.controlModifier);
1327 }
1328 if (WinKeyPressed(VK_MENU))
1329 {
1330 key = cast<Keys>(key | Keys.altModifier);
1331 }
1332 KeyEventArgs args(key);
1333 DoMenu(args);
1334 if (args.handled)
1335 {
1336 SetKeyDownHandled();
1337 return true;
1338 }
1339 else
1340 {
1341 DispatchKeyDown(args);
1342 if (args.handled)
1343 {
1344 SetKeyDownHandled();
1345 return true;
1346 }
1347 }
1348 return false;
1349 }
1350 private bool DoKeyUp(int virtualKeyCode)
1351 {
1352 LogView* logView = Application.GetLogView();
1353 if (logView != null)
1354 {
1355 string s = "DoKeyUp: " + ToString(cast<Keys>(virtualKeyCode)) + " " + ToHexString(cast<uint>(virtualKeyCode));
1356 logView->WriteLine(s);
1357 }
1358 Keys key = cast<Keys>(virtualKeyCode);
1359 if (KeyDownHandled() || MenuWantsKeys())
1360 {
1361 return KeyDownHandled();
1362 }
1363 KeyEventArgs args(key);
1364 DispatchKeyUp(args);
1365 if (args.handled)
1366 {
1367 return true;
1368 }
1369 return false;
1370 }
1371 private void DoKeyPress(KeyPressEventArgs& args)
1372 {
1373 LogView* logView = Application.GetLogView();
1374 if (logView != null)
1375 {
1376 string s = "DoKeyPress: " + ToString(args.keyChar) + " " + ToHexString(cast<uint>(args.keyChar));
1377 logView->WriteLine(s);
1378 }
1379 if (KeyDownHandled() || MenuWantsKeys())
1380 {
1381 args.handled = KeyDownHandled();
1382 return;
1383 }
1384 ResetModifierKeys();
1385 DispatchKeyPress(args);
1386 }
1387 private void DispatchKeyPress(KeyPressEventArgs& args)
1388 {
1389 OnKeyPress(args);
1390 if (!args.handled)
1391 {
1392 Control* parent = ParentControl();
1393 if (parent != null)
1394 {
1395 parent->DispatchKeyPress(args);
1396 }
1397 }
1398 }
1399 private void DispatchKeyDown(KeyEventArgs& args)
1400 {
1401 OnKeyDown(args);
1402 if (!args.handled)
1403 {
1404 Control* parent = ParentControl();
1405 if (parent != null)
1406 {
1407 parent->DispatchKeyDown(args);
1408 }
1409 }
1410 }
1411 private void DispatchKeyUp(KeyEventArgs& args)
1412 {
1413 OnKeyUp(args);
1414 if (!args.handled)
1415 {
1416 Control* parent = ParentControl();
1417 if (parent != null)
1418 {
1419 parent->DispatchKeyUp(args);
1420 }
1421 }
1422 }
1423 private bool DoMenu(wchar accessKey, Keys keyCode)
1424 {
1425 ResetKeyDownHandled();
1426 LogView* logView = Application.GetLogView();
1427 if (logView != null)
1428 {
1429 string s = "MENU: " + ToString(accessKey) + " " + ToHexString(cast<ushort>(accessKey));
1430 logView->WriteLine(s);
1431 }
1432 Window* window = GetWindow();
1433 if (window != null)
1434 {
1435 MenuBar* menuBar = window->GetMenuBar();
1436 if (menuBar != null)
1437 {
1438 bool menuWantsKeys = false;
1439 bool handled = menuBar->HandleAccessKey(accessKey, keyCode, menuWantsKeys);
1440 if (handled)
1441 {
1442 SetKeyDownHandled();
1443 }
1444 if (menuWantsKeys)
1445 {
1446 SetMenuWantsKeys();
1447 }
1448 else
1449 {
1450 ResetMenuWantsKeys();
1451 }
1452 return handled;
1453 }
1454 }
1455 return false;
1456 }
1457 private void DoMenu(KeyEventArgs& args)
1458 {
1459 Window* window = GetWindow();
1460 if (window != null)
1461 {
1462 MenuBar* menuBar = window->GetMenuBar();
1463 if (menuBar != null)
1464 {
1465 menuBar->DoKeyDown(args);
1466 }
1467 }
1468 }
1469 private void DoVScroll(ushort request)
1470 {
1471 OnVScroll(request);
1472 }
1473 private void DoHScroll(ushort request)
1474 {
1475 OnHScroll(request);
1476 }
1477 private void DoMouseWheel(MouseWheelEventArgs& args)
1478 {
1479 OnMouseWheel(args);
1480 }
1481 private void DoSetFocus()
1482 {
1483 if (this is Window*)
1484 {
1485 Window* thisWindow = cast<Window*>(this);
1486 if (thisWindow->IsMainWindow())
1487 {
1488 OnGotFocus();
1489 return;
1490 }
1491 }
1492 SetFocused();
1493 DoGotFocus();
1494 DoCreateAndShowCaret();
1495 }
1496 private void DoGotFocus()
1497 {
1498 OnGotFocus();
1499 Control* parentControl = ParentControl();
1500 if (parentControl != null)
1501 {
1502 ControlEventArgs args(this);
1503 parentControl->OnChildGotFocus(args);
1504 }
1505 }
1506 protected virtual void OnGotFocus()
1507 {
1508 gotFocusEvent.Fire();
1509 }
1510 protected virtual void OnChildGotFocus(ControlEventArgs& args)
1511 {
1512 childGotFocusEvent.Fire(args);
1513 }
1514 private void DoKillFocus()
1515 {
1516 ResetFocused();
1517 DoLostFocus();
1518 DoDestroyCaret();
1519 }
1520 private void DoLostFocus()
1521 {
1522 OnLostFocus();
1523 Control* parentControl = ParentControl();
1524 if (parentControl != null)
1525 {
1526 ControlEventArgs args(this);
1527 parentControl->OnChildLostFocus(args);
1528 }
1529 }
1530 protected virtual void OnLostFocus()
1531 {
1532 lostFocusEvent.Fire();
1533 }
1534 protected virtual void OnChildLostFocus(ControlEventArgs& args)
1535 {
1536 childLostFocusEvent.Fire(args);
1537 }
1538 protected virtual nothrow bool IsDecoratorControl() const
1539 {
1540 return false;
1541 }
1542 protected virtual void TranslateChildGraphics(Graphics& graphics)
1543 {
1544 Control* parentControl = ParentControl();
1545 if (parentControl != null)
1546 {
1547 parentControl->TranslateChildGraphics(graphics);
1548 }
1549 }
1550 protected virtual void TranslateMousePos(Point& location)
1551 {
1552 Control* parentControl = ParentControl();
1553 if (parentControl != null)
1554 {
1555 parentControl->TranslateMousePos(location);
1556 }
1557 }
1558 protected virtual void TranslateContentLocation(Point& location)
1559 {
1560 Control* parentControl = ParentControl();
1561 if (parentControl != null)
1562 {
1563 parentControl->TranslateContentLocation(location);
1564 }
1565 }
1566 private void DoPaint()
1567 {
1568 try
1569 {
1570 void* paintStruct = null;
1571 void* hdc = BeginPaint(handle, paintStruct);
1572 Rect clipRect;
1573 WinGetClipRect(paintStruct, clipRect.location.x, clipRect.location.y, clipRect.size.w, clipRect.size.h);
1574 PaintGuard paintGuard(hdc, paintStruct);
1575 Graphics graphics(hdc);
1576 PaintEventArgs args(graphics, clipRect);
1577 PaintEventArgs* argsPtr = &args;
1578 if (!IsDecoratorControl())
1579 {
1580 TranslateChildGraphics(graphics);
1581 }
1582 if (Focused())
1583 {
1584 --caretShowCount;
1585 }
1586 UniquePtr<PaintEventArgs> bufferPaintArgs;
1587 if (IsDoubleBuffered())
1588 {
1589 if (buffer.IsNull() || buffer->GetSize() != GetSize())
1590 {
1591 buffer.Reset(new Buffer(GetSize(), graphics));
1592 }
1593 buffer->BitmapGraphics().Clear(BackgroundColor());
1594 bufferPaintArgs.Reset(new PaintEventArgs(buffer->BitmapGraphics(), clipRect));
1595 argsPtr = bufferPaintArgs.Get();
1596 Matrix matrix;
1597 graphics.GetTransformChecked(matrix);
1598 buffer->BitmapGraphics().SetTransformChecked(matrix);
1599 }
1600 OnPaint(*argsPtr);
1601 if (IsDoubleBuffered())
1602 {
1603 Graphics windowGraphics(hdc);
1604 buffer->Draw(windowGraphics);
1605 }
1606 if (Focused() && CaretCreated())
1607 {
1608 ShowCaret();
1609 }
1610 }
1611 catch (const Exception& ex)
1612 {
1613 MessageBox.Show(ex.Message());
1614 }
1615 }
1616 protected virtual void OnPaint(PaintEventArgs& args)
1617 {
1618 paintEvent.Fire(args);
1619 }
1620 internal virtual void PaintAll(PaintEventArgs& args, bool skipMenuBar)
1621 {
1622 try
1623 {
1624 OnPaint(args);
1625 }
1626 catch (const Exception& ex)
1627 {
1628 MessageBox.Show(ex.Message());
1629 }
1630 }
1631 private void DoCreateAndShowCaret()
1632 {
1633 if (Focused())
1634 {
1635 CreateCaret();
1636 SetCaretCreated();
1637 SetCaretLocation();
1638 ShowCaret();
1639 }
1640 }
1641 public virtual void CreateCaret()
1642 {
1643 System.Windows.API.CreateCaret(Handle(), null, 1, 15);
1644 }
1645 private void DoDestroyCaret()
1646 {
1647 if (CaretCreated())
1648 {
1649 HideCaret();
1650 ResetCaretCreated();
1651 DestroyCaret();
1652 }
1653 }
1654 public virtual void DestroyCaret()
1655 {
1656 System.Windows.API.DestroyCaret();
1657 caretShowCount = 0;
1658 }
1659 public void ShowCaret()
1660 {
1661 System.Windows.API.ShowCaret(Handle());
1662 ++caretShowCount;
1663 }
1664 public void HideCaret()
1665 {
1666 System.Windows.API.HideCaret(Handle());
1667 --caretShowCount;
1668 }
1669 public inline nothrow int CaretShowCount() const
1670 {
1671 return caretShowCount;
1672 }
1673 public Point GetCaretPos() const
1674 {
1675 return System.Windows.API.GetCaretPos();
1676 }
1677 public void SetCaretPos(const Point& caretPos)
1678 {
1679 if (CaretCreated())
1680 {
1681 System.Windows.API.SetCaretPos(caretPos);
1682 }
1683 }
1684 private void DoMouseMove(MouseEventArgs& args)
1685 {
1686 if (!MouseInClient())
1687 {
1688 SetMouseInClient();
1689 SetCursor();
1690 OnMouseEnter();
1691 WinTrackMouseEvent(handle, TME_LEAVE, HOVER_DEFAULT);
1692 }
1693 else
1694 {
1695 if (!IsDecoratorControl())
1696 {
1697 TranslateMousePos(args.location);
1698 }
1699 SetCursor();
1700 OnMouseMove(args);
1701 }
1702 if (mouseHoverMs != 0u && !MouseHoverTimerStarted())
1703 {
1704 Point pt = args.location;
1705 int dx = Abs(mouseHoverLocation.x - pt.x);
1706 int dy = Abs(mouseHoverLocation.y - pt.y);
1707 if (dx > mouseHoverRectSize.w || dy > mouseHoverRectSize.h)
1708 {
1709 SetMouseHoverTimerStarted();
1710 mouseHoverLocation = pt;
1711 SetTimer(mouseHoverTimerId, mouseHoverMs);
1712 }
1713 }
1714 }
1715 public nothrow void SetMouseHoverMs(uint mouseHoverMs_)
1716 {
1717 mouseHoverMs = mouseHoverMs_;
1718 }
1719 public nothrow uint MouseHoverMs() const
1720 {
1721 return mouseHoverMs;
1722 }
1723 public nothrow void SetMouseHoverRectSize(const Size& mouseHoverRectSize_)
1724 {
1725 mouseHoverRectSize = mouseHoverRectSize_;
1726 }
1727 public nothrow const Size& MouseHoverRectSize() const
1728 {
1729 return mouseHoverRectSize;
1730 }
1731 private void DoMouseHover()
1732 {
1733 ResetMouseHoverTimerStarted();
1734 KillTimer(mouseHoverTimerId);
1735 Point pt;
1736 GetCursorPos(pt.x, pt.y);
1737 pt = ScreenToClient(pt);
1738 if (!IsDecoratorControl())
1739 {
1740 TranslateMousePos(pt);
1741 }
1742 int dx = Abs(mouseHoverLocation.x - pt.x);
1743 int dy = Abs(mouseHoverLocation.y - pt.y);
1744 if (dx <= mouseHoverRectSize.w && dy <= mouseHoverRectSize.h)
1745 {
1746 MouseEventArgs args;
1747 args.location = pt;
1748 OnMouseHover(args);
1749 }
1750 }
1751 private void DoMouseLeave()
1752 {
1753 ResetMouseInClient();
1754 ResetLButtonPressed();
1755 OnMouseLeave();
1756 }
1757 private void DoMouseDown(MouseEventArgs& args)
1758 {
1759 if (!IsDecoratorControl())
1760 {
1761 TranslateMousePos(args.location);
1762 }
1763 OnMouseDown(args);
1764 if ((args.buttons & MouseButtons.lbutton) != 0)
1765 {
1766 SetLButtonPressed();
1767 }
1768 }
1769 private void DoMouseUp(MouseEventArgs& args)
1770 {
1771 if (!IsDecoratorControl())
1772 {
1773 TranslateMousePos(args.location);
1774 }
1775 OnMouseUp(args);
1776 if ((args.buttons & MouseButtons.lbutton) != 0)
1777 {
1778 if (LButtonPressed())
1779 {
1780 ResetLButtonPressed();
1781 this->OnClick();
1782 }
1783 }
1784 Window* mainWindow = Application.MainWindow();
1785 if (mainWindow != null)
1786 {
1787 mainWindow->MouseUpNotificationInternal(args);
1788 }
1789 }
1790 private void DoMouseDoubleClick(MouseEventArgs& args)
1791 {
1792 if (!IsDecoratorControl())
1793 {
1794 TranslateMousePos(args.location);
1795 }
1796 OnMouseDoubleClick(args);
1797 }
1798 public void SetTimer(uint timerId, uint elapseMs)
1799 {
1800 SetTimer(Handle(), timerId, elapseMs);
1801 }
1802 public void KillTimer(uint timerId)
1803 {
1804 KillTimer(Handle(), timerId);
1805 }
1806 private void DoTimer(uint timerId)
1807 {
1808 TimerEventArgs timerEventArgs(timerId);
1809 OnTimer(timerEventArgs);
1810 }
1811 protected virtual void OnTimer(TimerEventArgs& args)
1812 {
1813 if (args.timerId == mouseHoverTimerId)
1814 {
1815 DoMouseHover();
1816 }
1817 else
1818 {
1819 timerEvent.Fire(args);
1820 }
1821 }
1822 protected virtual void SetCursor()
1823 {
1824 SetCursor(arrowCursor);
1825 }
1826 protected virtual void OnMouseEnter()
1827 {
1828 mouseEnterEvent.Fire();
1829 }
1830 protected virtual void OnMouseMove(MouseEventArgs& args)
1831 {
1832 mouseMoveEvent.Fire(args);
1833 }
1834 protected virtual void OnMouseHover(MouseEventArgs& args)
1835 {
1836 mouseHoverEvent.Fire(args);
1837 }
1838 protected virtual void OnMouseLeave()
1839 {
1840 mouseLeaveEvent.Fire();
1841 }
1842 protected virtual void OnMouseDown(MouseEventArgs& args)
1843 {
1844 mouseDownEvent.Fire(args);
1845 if (!(this is MenuItem*) && !(this is MenuControl*))
1846 {
1847 Window* window = GetWindow();
1848 if (window != null)
1849 {
1850 MenuBar* menuBar = window->GetMenuBar();
1851 if (menuBar != null)
1852 {
1853 menuBar->CloseMenu();
1854 }
1855 }
1856 }
1857 }
1858 protected virtual void OnMouseUp(MouseEventArgs& args)
1859 {
1860 mouseUpEvent.Fire(args);
1861 }
1862 protected virtual void OnMouseDoubleClick(MouseEventArgs& args)
1863 {
1864 mouseDoubleClickEvent.Fire(args);
1865 }
1866 protected virtual void OnKeyPress(KeyPressEventArgs& args)
1867 {
1868 keyPressEvent.Fire(args);
1869 }
1870 protected virtual void OnKeyDown(KeyEventArgs& args)
1871 {
1872 keyDownEvent.Fire(args);
1873 }
1874 protected virtual void OnKeyUp(KeyEventArgs& args)
1875 {
1876 keyUpEvent.Fire(args);
1877 }
1878 protected virtual void OnClick()
1879 {
1880 clickEvent.Fire();
1881 }
1882 protected virtual void OnRightClick(RightClickEventArgs& args)
1883 {
1884 rightClickEvent.Fire(args);
1885 }
1886 protected virtual void OnCreated()
1887 {
1888 SetBaseOnCreatedCalled();
1889 createdEvent.Fire();
1890 }
1891 protected virtual void OnDestroyed()
1892 {
1893 destroyedEvent.Fire();
1894 }
1895 protected virtual void OnShown()
1896 {
1897 shownEvent.Fire();
1898 }
1899 protected virtual void OnHScroll(ScrollEventArgs& args)
1900 {
1901 hscrollEvent.Fire(args);
1902 }
1903 protected virtual void OnVScroll(ScrollEventArgs& args)
1904 {
1905 vscrollEvent.Fire(args);
1906 }
1907 protected virtual void OnMouseWheel(MouseWheelEventArgs& args)
1908 {
1909 mouseWheelEvent.Fire(args);
1910 }
1911 protected virtual void OnControlAdded(ControlEventArgs& args)
1912 {
1913 controlAddedEvent.Fire(args);
1914 }
1915 public virtual void OnControlRemoved(ControlEventArgs& args)
1916 {
1917 controlRemovedEvent.Fire(args);
1918 }
1919 public void* GetDC()
1920 {
1921 return GetDC(handle);
1922 }
1923 public void Invalidate()
1924 {
1925 InvalidateRect(handle, null, false);
1926 }
1927 public void Invalidate(const WinRect& rect)
1928 {
1929 InvalidateRect(handle, &rect, false);
1930 }
1931 public void Invalidate(const WinRect& rect, bool eraseBackground)
1932 {
1933 InvalidateRect(handle, &rect, eraseBackground);
1934 }
1935 public void Invalidate(const Rect& rect)
1936 {
1937 Invalidate(rect.ToWinRect());
1938 }
1939 public void Invalidate(const Rect& rect, bool eraseBackground)
1940 {
1941 Invalidate(rect.ToWinRect(), eraseBackground);
1942 }
1943 public inline nothrow const Color& BackgroundColor() const
1944 {
1945 return backgroundColor;
1946 }
1947 public void SetBackgroundColor(const Color& backgroundColor_)
1948 {
1949 backgroundColor = backgroundColor_;
1950 Invalidate();
1951 }
1952 public nothrow const Font& GetFont() const
1953 {
1954 if (!font.IsNull())
1955 {
1956 return font;
1957 }
1958 else
1959 {
1960 Control* parent = ParentControl();
1961 if (parent != null)
1962 {
1963 return parent->GetFont();
1964 }
1965 else
1966 {
1967 return font;
1968 }
1969 }
1970 }
1971 public void SetFont(const Font& font_)
1972 {
1973 font = font_;
1974 }
1975 public nothrow void SetFont(Font&& font_)
1976 {
1977 font = Rvalue(font_);
1978 }
1979 public const FontHandle& GetFontHandle(Graphics& graphics)
1980 {
1981 if (!fontHandle.IsNull())
1982 {
1983 return fontHandle;
1984 }
1985 if (!font.IsNull())
1986 {
1987 fontHandle = font.ToHFontChecked(graphics);
1988 return fontHandle;
1989 }
1990 Control* parent = ParentControl();
1991 if (parent != null)
1992 {
1993 return parent->GetFontHandle(graphics);
1994 }
1995 else
1996 {
1997 return fontHandle;
1998 }
1999 }
2000 public inline nothrow void* Handle() const
2001 {
2002 return handle;
2003 }
2004 public inline nothrow WindowStyle GetWindowStyle() const
2005 {
2006 return style;
2007 }
2008 public inline nothrow ExtendedWindowStyle GetExtendedWindowStyle() const
2009 {
2010 return exStyle;
2011 }
2012 public nothrow Event<PaintEventHandler, PaintEventArgs>& PaintEvent()
2013 {
2014 return paintEvent;
2015 }
2016 public nothrow Event<MouseEnterEventHandler>& MouseEnterEvent() const
2017 {
2018 return mouseEnterEvent;
2019 }
2020 public nothrow Event<MouseEventHandler, MouseEventArgs>& MouseMoveEvent() const
2021 {
2022 return mouseMoveEvent;
2023 }
2024 public nothrow Event<MouseEventHandler, MouseEventArgs>& MouseHoverEvent() const
2025 {
2026 return mouseHoverEvent;
2027 }
2028 public nothrow Event<MouseLeaveEventHandler>& MouseLeaveEvent() const
2029 {
2030 return mouseLeaveEvent;
2031 }
2032 public nothrow Event<MouseEventHandler, MouseEventArgs>& MouseDownEvent() const
2033 {
2034 return mouseDownEvent;
2035 }
2036 public nothrow Event<MouseEventHandler, MouseEventArgs>& MouseUpEvent() const
2037 {
2038 return mouseUpEvent;
2039 }
2040 public nothrow Event<MouseEventHandler, MouseEventArgs>& MouseDoubleClickEvent() const
2041 {
2042 return mouseDoubleClickEvent;
2043 }
2044 public nothrow Event<KeyPressEventHandler, KeyPressEventArgs>& KeyPressEvent() const
2045 {
2046 return keyPressEvent;
2047 }
2048 public nothrow Event<KeyEventHandler, KeyEventArgs>& KeyDownEvent() const
2049 {
2050 return keyDownEvent;
2051 }
2052 public nothrow Event<KeyEventHandler, KeyEventArgs>& KeyUpEvent() const
2053 {
2054 return keyUpEvent;
2055 }
2056 public nothrow Event<CreatedEventHandler>& CreatedEvent() const
2057 {
2058 return createdEvent;
2059 }
2060 public nothrow Event<DestroyedEventHandler>& DestroyedEvent() const
2061 {
2062 return destroyedEvent;
2063 }
2064 public nothrow Event<ShownEventHandler>& ShownEvent() const
2065 {
2066 return shownEvent;
2067 }
2068 public nothrow Event<EnabledChangedEventHandler>& EnabledChangedEvent() const
2069 {
2070 return enabledChangedEvent;
2071 }
2072 public nothrow Event<VisibleChangedEventHandler>& VisibleChangedEvent() const
2073 {
2074 return visibleChangedEvent;
2075 }
2076 public nothrow Event<ClickEventHandler>& ClickEvent() const
2077 {
2078 return clickEvent;
2079 }
2080 public nothrow Event<SizeChangedEventHandler, uint>& SizeChangedEvent() const
2081 {
2082 return sizeChangedEvent;
2083 }
2084 public nothrow Event<SizeChangingEventHandler, SizeChangingEventArgs> SizeChangingEvent() const
2085 {
2086 return sizeChangingEvent;
2087 }
2088 public nothrow Event<ChildSizeChangedEventHandler, ControlEventArgs>& ChildSizeChangedEvent() const
2089 {
2090 return childSizeChangedEvent;
2091 }
2092 public nothrow Event<LocationChangedEventHandler>& LocationChangedEvent() const
2093 {
2094 return locationChangedEvent;
2095 }
2096 public nothrow Event<ContentChangedEventHandler>& ContentChangedEvent() const
2097 {
2098 return contentChangedEvent;
2099 }
2100 public nothrow Event<ChildContentChangedEventHandler, ControlEventArgs>& ChildContentChangedEvent() const
2101 {
2102 return childContentChangedEvent;
2103 }
2104 public nothrow Event<ContentLocationChangedEventHandler>& ContentLocationChangedEvent() const
2105 {
2106 return contentLocationChangedEvent;
2107 }
2108 public nothrow Event<ChildContentLocationChangedEventHandler, ControlEventArgs>& ChildContentLocationChangedEvent() const
2109 {
2110 return childContentLocationChangedEvent;
2111 }
2112 public nothrow Event<ContentSizeChangedEventHandler>& ContentSizeChangedEvent() const
2113 {
2114 return contentSizeChangedEvent;
2115 }
2116 public nothrow Event<ChildContentSizeChangedEventHandler, ControlEventArgs>& ChildContentSizeChangedEvent() const
2117 {
2118 return childContentSizeChangedEvent;
2119 }
2120 public nothrow Event<TextChangedEventHandler>& TextChangedEvent() const
2121 {
2122 return textChangedEvent;
2123 }
2124 public nothrow Event<HScrollEventHandler, ScrollEventArgs>& HScrollEvent() const
2125 {
2126 return hscrollEvent;
2127 }
2128 public nothrow Event<VScrollEventHandler, ScrollEventArgs>& VScrollEvent() const
2129 {
2130 return vscrollEvent;
2131 }
2132 public nothrow Event<MouseWheelEventHandler, MouseWheelEventArgs>& MouseWheelEvent() const
2133 {
2134 return mouseWheelEvent;
2135 }
2136 public nothrow Event<TimerEventHandler, TimerEventArgs>& TimerEvent() const
2137 {
2138 return timerEvent;
2139 }
2140 public nothrow Event<GotFocusEventHandler>& GotFocusEvent() const
2141 {
2142 return gotFocusEvent;
2143 }
2144 public nothrow Event<LostFocusEventHandler>& LostFocusEvent() const
2145 {
2146 return lostFocusEvent;
2147 }
2148 public nothrow Event<ControlEventHandler, ControlEventArgs>& ControlAddedEvent() const
2149 {
2150 return controlAddedEvent;
2151 }
2152 public nothrow Event<ControlEventHandler, ControlEventArgs>& ControlRemovedEvent() const
2153 {
2154 return controlRemovedEvent;
2155 }
2156 public nothrow Event<RightClickEventHandler, RightClickEventArgs>& RightClickEvent() const
2157 {
2158 return rightClickEvent;
2159 }
2160 public nothrow Event<ClipboardUpdateEventHandler>& ClipboadUpdateEvent() const
2161 {
2162 return clipboardUpdateEvent;
2163 }
2164 private inline nothrow bool MouseInClient() const
2165 {
2166 return (flags & Flags.mouseInClient) != 0;
2167 }
2168 private inline nothrow void SetMouseInClient()
2169 {
2170 flags = cast<Flags>(flags | Flags.mouseInClient);
2171 }
2172 private inline nothrow void ResetMouseInClient()
2173 {
2174 flags = cast<Flags>(flags & ~Flags.mouseInClient);
2175 }
2176 private inline nothrow bool LButtonPressed() const
2177 {
2178 return (flags & flags.lbuttonPressed) != 0;
2179 }
2180 private inline nothrow void SetLButtonPressed()
2181 {
2182 flags = cast<Flags>(flags | Flags.lbuttonPressed);
2183 }
2184 private inline nothrow void ResetLButtonPressed()
2185 {
2186 flags = cast<Flags>(flags & ~Flags.lbuttonPressed);
2187 }
2188 private inline nothrow bool MenuWantsKeys() const
2189 {
2190 return (flags & flags.menuWantsKeys) != 0;
2191 }
2192 private inline nothrow void SetMenuWantsKeys()
2193 {
2194 flags = cast<Flags>(flags | Flags.menuWantsKeys);
2195 }
2196 private inline nothrow void ResetMenuWantsKeys()
2197 {
2198 flags = cast<Flags>(flags & ~Flags.menuWantsKeys);
2199 }
2200 private inline nothrow bool KeyDownHandled() const
2201 {
2202 return (flags & Flags.keyDownHandled) != 0;
2203 }
2204 private inline nothrow void SetKeyDownHandled()
2205 {
2206 flags = cast<Flags>(flags | Flags.keyDownHandled);
2207 }
2208 private inline nothrow void ResetKeyDownHandled()
2209 {
2210 flags = cast<Flags>(flags & ~Flags.keyDownHandled);
2211 }
2212 public inline nothrow bool Focused() const
2213 {
2214 return (flags & Flags.focused) != 0;
2215 }
2216 private inline nothrow void SetFocused()
2217 {
2218 flags = cast<Flags>(flags | Flags.focused);
2219 }
2220 private inline nothrow void ResetFocused()
2221 {
2222 flags = cast<Flags>(flags & ~Flags.focused);
2223 }
2224 public inline nothrow bool CaretCreated() const
2225 {
2226 return (flags & Flags.caretCreated) != 0;
2227 }
2228 private inline nothrow void SetCaretCreated()
2229 {
2230 flags = cast<Flags>(flags | Flags.caretCreated);
2231 }
2232 private inline nothrow void ResetCaretCreated()
2233 {
2234 flags = cast<Flags>(flags & ~Flags.caretCreated);
2235 }
2236 private inline nothrow bool CaretShown() const
2237 {
2238 return (flags & Flags.caretShown) != 0;
2239 }
2240 private inline nothrow void SetCaretShown()
2241 {
2242 flags = cast<Flags>(flags | Flags.caretShown);
2243 }
2244 private inline nothrow void ResetCaretShown()
2245 {
2246 flags = cast<Flags>(flags & ~Flags.caretShown);
2247 }
2248 public inline nothrow bool IsDisabled() const
2249 {
2250 return (flags & Flags.disabled) != 0;
2251 }
2252 private inline nothrow void SetDisabled()
2253 {
2254 flags = cast<Flags>(flags | Flags.disabled);
2255 }
2256 private inline nothrow void ResetDisabled()
2257 {
2258 flags = cast<Flags>(flags & ~Flags.disabled);
2259 }
2260 private inline nothrow bool Hidden() const
2261 {
2262 return (flags & Flags.hidden) != 0;
2263 }
2264 private inline nothrow void SetHidden()
2265 {
2266 flags = cast<Flags>(flags | Flags.hidden);
2267 }
2268 private inline nothrow void ResetHidden()
2269 {
2270 flags = cast<Flags>(flags & ~Flags.hidden);
2271 }
2272 public inline nothrow bool IsTabStop() const
2273 {
2274 return (flags & Flags.tabStop) != Flags.none;
2275 }
2276 public inline nothrow void SetTabStop()
2277 {
2278 flags = cast<Flags>(flags | Flags.tabStop);
2279 }
2280 public inline nothrow void ResetTabStop()
2281 {
2282 flags = cast<Flags>(flags & ~Flags.tabStop);
2283 }
2284 internal inline nothrow bool BaseOnCreatedCalled() const
2285 {
2286 return (flags & Flags.baseOnCreatedCalled) != Flags.none;
2287 }
2288 internal inline nothrow void SetBaseOnCreatedCalled()
2289 {
2290 flags = cast<Flags>(flags | Flags.baseOnCreatedCalled);
2291 }
2292 private inline nothrow void ResetBaseOnCreatedCalled()
2293 {
2294 flags = cast<Flags>(flags & ~Flags.baseOnCreatedCalled);
2295 }
2296 private inline nothrow bool MouseHoverTimerStarted() const
2297 {
2298 return (flags & Flags.mouseHoverTimerStarted) != Flags.none;
2299 }
2300 private inline nothrow void SetMouseHoverTimerStarted()
2301 {
2302 flags = cast<Flags>(flags | Flags.mouseHoverTimerStarted);
2303 }
2304 private inline nothrow void ResetMouseHoverTimerStarted()
2305 {
2306 flags = cast<Flags>(flags & ~Flags.mouseHoverTimerStarted);
2307 }
2308 public inline nothrow bool IsDoubleBuffered() const
2309 {
2310 return (flags & Flags.doubleBuffered) != Flags.none;
2311 }
2312 public inline nothrow void SetDoubleBuffered()
2313 {
2314 flags = cast<Flags>(flags | Flags.doubleBuffered);
2315 }
2316 public inline nothrow void ResetDoubleBuffered()
2317 {
2318 flags = cast<Flags>(flags & ~Flags.doubleBuffered);
2319 }
2320 public inline nothrow bool IsScrollSubject() const
2321 {
2322 return (flags & Flags.scrollSubject) != Flags.none;
2323 }
2324 public inline nothrow void SetScrollSubject()
2325 {
2326 flags = cast<Flags>(flags | Flags.scrollSubject);
2327 }
2328 public inline nothrow void ResetScrollSubject()
2329 {
2330 flags = cast<Flags>(flags & ~Flags.scrollSubject);
2331 }
2332 private string windowClassName;
2333 private int windowClassBackgroundColor;
2334 private WindowClassStyle windowClassStyle;
2335 private Color backgroundColor;
2336 private WindowStyle style;
2337 private ExtendedWindowStyle exStyle;
2338 private void* handle;
2339 private string text;
2340 private Point location;
2341 private Size size;
2342 private Point contentLocation;
2343 private Size contentSize;
2344 private int verticalScrollUnit;
2345 private int horizontalScrollUnit;
2346 private Dock dock;
2347 private Anchors anchors;
2348 private Flags flags;
2349 private Keys currentModifierKeys;
2350 private List<Control*> createList;
2351 private Cursor arrowCursor;
2352 private int caretShowCount;
2353 private Font font;
2354 private FontHandle fontHandle;
2355 private void* originalWndProc;
2356 private Size mouseHoverRectSize;
2357 private uint mouseHoverMs;
2358 private Point mouseHoverLocation;
2359 private UniquePtr<Buffer> buffer;
2360 private Event<PaintEventHandler, PaintEventArgs> paintEvent;
2361 private Event<MouseEnterEventHandler> mouseEnterEvent;
2362 private Event<MouseEventHandler, MouseEventArgs> mouseMoveEvent;
2363 private Event<MouseEventHandler, MouseEventArgs> mouseHoverEvent;
2364 private Event<MouseLeaveEventHandler> mouseLeaveEvent;
2365 private Event<MouseEventHandler, MouseEventArgs> mouseDownEvent;
2366 private Event<MouseEventHandler, MouseEventArgs> mouseUpEvent;
2367 private Event<MouseEventHandler, MouseEventArgs> mouseDoubleClickEvent;
2368 private Event<KeyPressEventHandler, KeyPressEventArgs> keyPressEvent;
2369 private Event<KeyEventHandler, KeyEventArgs> keyDownEvent;
2370 private Event<KeyEventHandler, KeyEventArgs> keyUpEvent;
2371 private Event<ClickEventHandler> clickEvent;
2372 private Event<CreatedEventHandler> createdEvent;
2373 private Event<DestroyedEventHandler> destroyedEvent;
2374 private Event<ShownEventHandler> shownEvent;
2375 private Event<EnabledChangedEventHandler> enabledChangedEvent;
2376 private Event<VisibleChangedEventHandler> visibleChangedEvent;
2377 private Event<SizeChangedEventHandler, uint> sizeChangedEvent;
2378 private Event<SizeChangingEventHandler, SizeChangingEventArgs> sizeChangingEvent;
2379 private Event<ChildSizeChangedEventHandler, ControlEventArgs> childSizeChangedEvent;
2380 private Event<LocationChangedEventHandler> locationChangedEvent;
2381 private Event<ContentChangedEventHandler> contentChangedEvent;
2382 private Event<ChildContentChangedEventHandler, ControlEventArgs> childContentChangedEvent;
2383 private Event<ContentLocationChangedEventHandler> contentLocationChangedEvent;
2384 private Event<ChildContentLocationChangedEventHandler, ControlEventArgs> childContentLocationChangedEvent;
2385 private Event<ContentSizeChangedEventHandler> contentSizeChangedEvent;
2386 private Event<ChildContentSizeChangedEventHandler, ControlEventArgs> childContentSizeChangedEvent;
2387 private Event<TextChangedEventHandler> textChangedEvent;
2388 private Event<HScrollEventHandler, ScrollEventArgs> hscrollEvent;
2389 private Event<VScrollEventHandler, ScrollEventArgs> vscrollEvent;
2390 private Event<MouseWheelEventHandler, MouseWheelEventArgs> mouseWheelEvent;
2391 private Event<TimerEventHandler, TimerEventArgs> timerEvent;
2392 private Event<GotFocusEventHandler> gotFocusEvent;
2393 private Event<LostFocusEventHandler> lostFocusEvent;
2394 private Event<ChildGotFocusEventHandler, ControlEventArgs> childGotFocusEvent;
2395 private Event<ChildLostFocusEventHandler, ControlEventArgs> childLostFocusEvent;
2396 private Event<ControlEventHandler, ControlEventArgs> controlAddedEvent;
2397 private Event<ControlEventHandler, ControlEventArgs> controlRemovedEvent;
2398 private Event<RightClickEventHandler, RightClickEventArgs> rightClickEvent;
2399 private Event<ClipboardUpdateEventHandler> clipboardUpdateEvent;
2400 }
2401 }