4#ifndef _Stroika_Frameworks_Led_Platform_Windows_h_
5#define _Stroika_Frameworks_Led_Platform_Windows_h_ 1
7#include "Stroika/Frameworks/StroikaPreComp.h"
14#include "Stroika/Foundation/Characters/LineEndings.h"
19#include "Stroika/Frameworks/Led/TextInteractor.h"
29namespace Stroika::Frameworks::Led::Platform {
43#ifndef qSupportWindowsSDKCallbacks
44#define qSupportWindowsSDKCallbacks 0
51#ifdef qSupportFunnyMSPageUpDownAdjustSelectionBehavior
52#error "This flag is OBSOLETE. Use Led_Win32_Helper<BASE_INTERACTOR>::SetFunnyMSPageUpDownAdjustSelectionBehavior instead".
61#ifndef qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
62#define qStroika_Frameworks_Led_ScrollTextDuringThumbTracking 1
72 class FunnyMSPageUpDownAdjustSelectionHelper {
74 FunnyMSPageUpDownAdjustSelectionHelper ();
77 nonvirtual
void CaptureInfo (TextInteractor& ti);
78 nonvirtual
void CompleteAdjustment (TextInteractor& ti);
84 DISABLE_COMPILER_MSC_WARNING_START (4250)
90 template <typename BASE_INTERACTOR = TextInteractor>
91 class Led_Win32_Helper : public virtual BASE_INTERACTOR {
93 using inherited = BASE_INTERACTOR;
96 using UpdateMode = TextInteractor::UpdateMode;
97 using UpdateInfo = MarkerOwner::UpdateInfo;
103 virtual ~Led_Win32_Helper ();
107 virtual HWND GetHWND ()
const = 0;
110 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam);
114 virtual LRESULT OnCreate_Msg (LPCREATESTRUCT createStruct);
115 virtual void OnPaint_Msg ();
116 virtual void OnSize_Msg ();
117 virtual void OnChar_Msg (UINT nChar, LPARAM lKeyData);
118 virtual LRESULT OnUniChar_Msg (WPARAM nChar, LPARAM lParam);
119 virtual void OnKeyDown_Msg (UINT nChar, LPARAM lKeyData);
120 virtual bool OnSetCursor_Msg (HWND hWnd, UINT nHitTest, UINT message);
121 virtual UINT OnGetDlgCode_Msg ();
122 virtual void OnSetFocus_Msg (HWND oldWnd);
123 virtual void OnKillFocus_Msg (HWND newWnd);
124 virtual bool OnEraseBkgnd_Msg (HDC hDC);
125 virtual void OnTimer_Msg (UINT_PTR nEventID, TIMERPROC* proc);
126 virtual void OnLButtonDown_Msg (UINT nFlags,
int x,
int y);
127 virtual void OnLButtonUp_Msg (UINT nFlags,
int x,
int y);
128 virtual void OnLButtonDblClk_Msg (UINT nFlags,
int x,
int y);
129 virtual void OnMouseMove_Msg (UINT nFlags,
int x,
int y);
130 virtual void OnVScroll_Msg (UINT nSBCode, UINT nPos, HWND hScrollBar);
131 virtual void OnHScroll_Msg (UINT nSBCode, UINT nPos, HWND hScrollBar);
132 virtual bool OnMouseWheel_Msg (WPARAM wParam, LPARAM lParam);
133 virtual void OnEnable_Msg (
bool enable);
136 short fAccumulatedWheelDelta;
139 nonvirtual TWIPS_Rect GetDefaultWindowMargins ()
const;
140 nonvirtual
void SetDefaultWindowMargins (
const TWIPS_Rect& defaultWindowMargins);
143 TWIPS_Rect fDefaultWindowMargins;
146 nonvirtual
bool GetControlArrowsScroll ()
const;
147 nonvirtual
void SetControlArrowsScroll (
bool controlArrowsScroll);
150 bool fControlArrowsScroll;
153 nonvirtual
bool GetFunnyMSPageUpDownAdjustSelectionBehavior ()
const;
154 nonvirtual
void SetFunnyMSPageUpDownAdjustSelectionBehavior (
bool funnyMSPageUpDownAdjustSelectionBehavior);
157 bool fFunnyMSPageUpDownAdjustSelectionBehavior;
161 nonvirtual
void OnSize_ ();
167 virtual void RefreshWindowRect_ (
const Led_Rect& windowRectArea, UpdateMode updateMode)
const override;
168 virtual void UpdateWindowRect_ (
const Led_Rect& windowRectArea)
const override;
169 virtual bool QueryInputKeyStrokesPending ()
const override;
180 class TemporarilyUseTablet {
182 enum DoTextMetricsChangedCall {
183 eDoTextMetricsChangedCall,
184 eDontDoTextMetricsChangedCall
186 TemporarilyUseTablet (Led_Win32_Helper<BASE_INTERACTOR>& editor, Tablet* t, DoTextMetricsChangedCall tmChanged = eDoTextMetricsChangedCall);
187 ~TemporarilyUseTablet ();
190 Led_Win32_Helper<BASE_INTERACTOR>& fEditor;
192 DoTextMetricsChangedCall fDoTextMetricsChangedCall;
196 friend class TemporarilyUseTablet;
199 virtual Tablet* AcquireTablet ()
const override;
200 virtual void ReleaseTablet (Tablet* tablet)
const override;
203 Tablet* fUpdateTablet;
204 mutable Tablet fAllocatedTablet;
206 mutable size_t fAcquireCount;
209 virtual void WindowDrawHelper (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing);
212 virtual void EraseBackground (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
override;
216 nonvirtual
bool CheckIfDraggingBeepAndReturn ();
219 virtual void HandleTabCharacterTyped ();
222 virtual void AboutToUpdateText (
const UpdateInfo& updateInfo)
override;
223 virtual void DidUpdateText (
const UpdateInfo& updateInfo)
noexcept override;
226 nonvirtual
void DidUpdateText_ (
const UpdateInfo& updateInfo)
noexcept;
230 Led_Point fMouseTrackingLastPoint;
235#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
236 bool fSBarThumbTracking;
240 nonvirtual
void OnNormalLButtonDown (UINT nFlags,
const Led_Point& at);
244 nonvirtual
void StartAutoscrollTimer ();
245 nonvirtual
void StopAutoscrollTimer ();
249 eAutoscrollingTimerEventID = 434
251 UINT_PTR fAutoScrollTimerID;
255 using ScrollBarType = TextInteractor::ScrollBarType;
256 using VHSelect = TextInteractor::VHSelect;
259 virtual void SetScrollBarType (VHSelect vh, ScrollBarType scrollBarType)
override;
262 virtual bool ShouldUpdateHScrollBar ()
const;
263 virtual bool ShouldUpdateVScrollBar ()
const;
264 virtual bool TypeAndScrollInfoSBVisible (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo)
const;
265 virtual SCROLLINFO GetHScrollInfo (UINT nMask = SIF_ALL)
const;
266 virtual void SetHScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw =
true);
267 nonvirtual
void SetHScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw =
true);
268 virtual SCROLLINFO GetVScrollInfo (UINT nMask = SIF_ALL)
const;
269 virtual void SetVScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw =
true);
270 nonvirtual
void SetVScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw =
true);
273 virtual void InvalidateScrollBarParameters ()
override;
276 nonvirtual
void InvalidateScrollBarParameters_ ();
279 virtual void InvalidateCaretState ()
override;
280 nonvirtual
void UpdateCaretState_ ();
283 virtual void UpdateScrollBars ()
override;
287 virtual bool OnCopyCommand_Before ()
override;
288 virtual void OnCopyCommand_After ()
override;
289 virtual bool OnPasteCommand_Before ()
override;
290 virtual void OnPasteCommand_After ()
override;
293 nonvirtual DWORD GetStyle ()
const;
297 nonvirtual
int GetWindowID ()
const;
300 nonvirtual HWND GetValidatedHWND ()
const;
302 DISABLE_COMPILER_MSC_WARNING_END (4250)
304 DISABLE_COMPILER_MSC_WARNING_START (4250)
312 template <typename BASECLASS>
313 class Led_Win32_Win32SDKMessageMimicHelper : public BASECLASS {
315 using inherited = BASECLASS;
318 Led_Win32_Win32SDKMessageMimicHelper ();
321 virtual bool HandleMessage (UINT message, WPARAM wParam, LPARAM lParam, LRESULT* result);
324 virtual LRESULT OnMsgGetText (WPARAM wParam, LPARAM lParam);
325 virtual LRESULT OnMsgSetText (WPARAM , LPARAM lParam);
326 virtual LRESULT OnMsgGetTextLength (WPARAM , LPARAM );
327 virtual LRESULT OnMsgGetSel (WPARAM wParam, LPARAM lParam);
328 virtual LRESULT OnMsgSetReadOnly (WPARAM wParam, LPARAM lParam);
329 virtual LRESULT OnMsgGetFirstVisibleLine (WPARAM wParam, LPARAM lParam);
330 virtual LRESULT OnMsgLineIndex (WPARAM wParam, LPARAM lParam);
331 virtual LRESULT OnMsgLineCount (WPARAM wParam, LPARAM lParam);
332 virtual LRESULT OnMsgCanUndo (WPARAM wParam, LPARAM lParam);
333 virtual LRESULT OnMsgUndo (WPARAM wParam, LPARAM lParam);
334 virtual LRESULT OnMsgEmptyUndoBuffer (WPARAM wParam, LPARAM lParam);
335 virtual LRESULT OnMsgClear (WPARAM wParam, LPARAM lParam);
336 virtual LRESULT OnMsgCut (WPARAM wParam, LPARAM lParam);
337 virtual LRESULT OnMsgCopy (WPARAM wParam, LPARAM lParam);
338 virtual LRESULT OnMsgPaste (WPARAM wParam, LPARAM lParam);
339 virtual LRESULT OnMsgLineFromChar (WPARAM wParam, LPARAM lParam);
340 virtual LRESULT OnMsgLineLength (WPARAM wParam, LPARAM lParam);
341 virtual LRESULT OnMsgLineScroll (WPARAM wParam, LPARAM lParam);
342 virtual LRESULT OnMsgReplaceSel (WPARAM wParam, LPARAM lParam);
343 virtual LRESULT OnMsgSetSel (WPARAM wParam, LPARAM lParam);
344 virtual LRESULT OnMsgScrollCaret (WPARAM wParam, LPARAM lParam);
345 virtual LRESULT OnMsgGetFont (WPARAM wParam, LPARAM lParam);
346 virtual LRESULT OnMsgSetFont (WPARAM wParam, LPARAM lParam);
349 FontObject fDefaultFontCache;
351 DISABLE_COMPILER_MSC_WARNING_END (4250)
359 class SimpleWin32WndProcHelper {
361 SimpleWin32WndProcHelper ();
364 nonvirtual HWND GetHWND ()
const;
365 nonvirtual
void SetHWND (HWND hWnd);
366 nonvirtual HWND GetValidatedHWND ()
const;
372 nonvirtual
void Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
373 HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
374 nonvirtual
void Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
375 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
378 nonvirtual
bool SubclassWindow (HWND hWnd);
379 nonvirtual
bool SubclassWindowW (HWND hWnd);
382 WNDPROC fSuperWindowProc;
385 nonvirtual LRESULT SendMessage (UINT msg, WPARAM wParam, LPARAM lParam);
388 nonvirtual
bool IsWindowRealized ()
const;
389 nonvirtual
void Assert_Window_Realized ()
const;
392 nonvirtual
void Require_Window_Realized ()
const;
395 nonvirtual
bool IsWindowUNICODE ()
const;
398 nonvirtual
bool IsWindowShown ()
const;
399 nonvirtual
void SetWindowVisible (
bool shown =
true);
402 static LRESULT CALLBACK StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
405 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam);
408 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam);
411 DISABLE_COMPILER_MSC_WARNING_START (4250)
419 template <typename BASE_WIN32_HELPER = Led_Win32_Helper<>>
420 class Led_Win32_SimpleWndProc_Helper : public BASE_WIN32_HELPER {
422 using inherited = BASE_WIN32_HELPER;
425 Led_Win32_SimpleWndProc_Helper ();
428 virtual ~Led_Win32_SimpleWndProc_Helper ();
431 nonvirtual
void Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
432 HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
433 nonvirtual
void Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
434 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
437 nonvirtual
void SetHWND (HWND hWnd);
444 virtual HWND GetHWND ()
const override;
447 virtual void OnNCDestroy_Msg ();
450 nonvirtual
bool SubclassWindow (HWND hWnd);
451 nonvirtual
bool ReplaceWindow (HWND hWnd);
454 virtual void HookSubclassWindow ();
457 WNDPROC fSuperWindowProc;
460 static LRESULT CALLBACK StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
463 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam);
466 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
override;
468 DISABLE_COMPILER_MSC_WARNING_END (4250)
470 DISABLE_COMPILER_MSC_WARNING_START (4250)
476 template <typename BASE_CLASS>
477 class Led_Win32_SimpleWndProc_HelperWithSDKMessages : public Led_Win32_SimpleWndProc_Helper<Led_Win32_Win32SDKMessageMimicHelper<BASE_CLASS>> {
479 using inherited = Led_Win32_SimpleWndProc_Helper<Led_Win32_Win32SDKMessageMimicHelper<BASE_CLASS>>;
482 Led_Win32_SimpleWndProc_HelperWithSDKMessages ();
485 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam)
override;
487 DISABLE_COMPILER_MSC_WARNING_END (4250)
499 struct IdleMangerLinkerSupport {
500 IdleMangerLinkerSupport ();
502 static IdleMangerLinkerSupport sIdleMangerLinkerSupport;
506 template <
typename BASE_INTERACTOR>
507 Led_Win32_Helper<BASE_INTERACTOR>::Led_Win32_Helper ()
508 : fAccumulatedWheelDelta (0)
509 , fDefaultWindowMargins ()
510 , fControlArrowsScroll (false)
511 , fFunnyMSPageUpDownAdjustSelectionBehavior (true)
512 , fUpdateTablet (nullptr)
513 , fAllocatedTablet ()
515 , fMouseTrackingLastPoint ()
517#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
518 , fSBarThumbTracking (false)
520 , fAutoScrollTimerID (0)
522 fDefaultWindowMargins.top = TWIPS (2 * TWIPS::kPoint);
523 fDefaultWindowMargins.left = TWIPS (2 * TWIPS::kPoint);
524 fDefaultWindowMargins.bottom = TWIPS (2 * TWIPS::kPoint);
525 fDefaultWindowMargins.right = TWIPS (2 * TWIPS::kPoint);
527 template <
typename BASE_INTERACTOR>
528 Led_Win32_Helper<BASE_INTERACTOR>::~Led_Win32_Helper ()
530 Assert (fUpdateTablet ==
nullptr);
531 Assert (fAllocatedTablet.m_hDC ==
nullptr);
532 Assert (fAllocatedTablet.m_hAttribDC ==
nullptr);
533 Assert (fAcquireCount == 0);
534 Assert (fAutoScrollTimerID == 0);
536 template <
typename BASE_INTERACTOR>
537 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
539 return ::DefWindowProc (this->GetValidatedHWND (), message, wParam, lParam);
541 template <
typename BASE_INTERACTOR>
542 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::OnCreate_Msg (LPCREATESTRUCT createStruct)
545 if ((createStruct->style & WS_VSCROLL) and this->GetScrollBarType (TextInteractor::v) == TextInteractor::eScrollBarNever) {
546 this->SetScrollBarType (TextInteractor::v, TextInteractor::eScrollBarAlways);
548 if ((createStruct->style & WS_HSCROLL) and this->GetScrollBarType (TextInteractor::h) == TextInteractor::eScrollBarNever) {
549 this->SetScrollBarType (TextInteractor::h, TextInteractor::eScrollBarAlways);
551 return this->DefWindowProc (WM_CREATE, 0,
reinterpret_cast<LPARAM
> (createStruct));
553 template <
typename BASE_INTERACTOR>
554 void Led_Win32_Helper<BASE_INTERACTOR>::OnPaint_Msg ()
556 HWND hWnd = this->GetValidatedHWND ();
558 HDC hdc = ::BeginPaint (hWnd, &ps);
559 if (hdc !=
nullptr) {
561 Verify (::GetClipBox (hdc, &boundsRect) != ERROR);
562 Tablet tablet (hdc, Tablet::eDoesntOwnDC);
564 this->WindowDrawHelper (&tablet, AsLedRect (boundsRect),
false);
567 ::EndPaint (hWnd, &ps);
570 ::EndPaint (hWnd, &ps);
573 template <
typename BASE_INTERACTOR>
574 void Led_Win32_Helper<BASE_INTERACTOR>::OnSize_Msg ()
578 template <
typename BASE_INTERACTOR>
584 void Led_Win32_Helper<BASE_INTERACTOR>::OnChar_Msg (UINT nChar, LPARAM )
586#if !qStroika_Foundation_Characters_SDKUseswchar_t
588 CodePage useCodePage = Characters::Platform::Windows::Win32PrimaryLangIDToCodePage (LOWORD (::GetKeyboardLayout (
nullptr)));
591 int xx = ::MultiByteToWideChar (useCodePage, 0, &ccc, 1, &outC, 1);
598 if (nChar == VK_ESCAPE) {
603 if (this->CheckIfDraggingBeepAndReturn ()) {
608 this->HandleTabCharacterTyped ();
615 if ((nChar == 0x7f) and (::GetKeyState (VK_CONTROL) & 0x8000)) {
619 this->OnTypedNormalCharacter (
static_cast<Led_tChar
> (nChar),
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
620 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
622#if qSupportWindowsSDKCallbacks
623 HWND hWnd = this->GetValidatedHWND ();
624 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
627 template <
typename BASE_INTERACTOR>
633 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::OnUniChar_Msg (WPARAM nChar, LPARAM )
635 if (nChar == UNICODE_NOCHAR) {
639 if (nChar == VK_ESCAPE) {
644 if (CheckIfDraggingBeepAndReturn ()) {
649 HandleTabCharacterTyped ();
656 if ((nChar == 0x7f) and (::GetKeyState (VK_CONTROL) & 0x8000)) {
660 this->OnTypedNormalCharacter (
static_cast<Led_tChar
> (nChar),
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
661 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
663#if qSupportWindowsSDKCallbacks
664 HWND hWnd = this->GetValidatedHWND ();
665 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
669 template <
typename BASE_INTERACTOR>
675 void Led_Win32_Helper<BASE_INTERACTOR>::OnKeyDown_Msg (UINT nChar, LPARAM )
677 bool shiftPressed = !!(::GetKeyState (VK_SHIFT) & 0x8000);
678 bool controlPressed = !!(::GetKeyState (VK_CONTROL) & 0x8000);
680 using TextInteractor::eDefaultUpdate;
681 using TextInteractor::eImmediateUpdate;
683 using TextInteractor::eCursorBack;
684 using TextInteractor::eCursorByBuffer;
685 using TextInteractor::eCursorByChar;
686 using TextInteractor::eCursorByLine;
687 using TextInteractor::eCursorByRow;
688 using TextInteractor::eCursorByWord;
689 using TextInteractor::eCursorExtendingSelection;
690 using TextInteractor::eCursorForward;
691 using TextInteractor::eCursorMoving;
692 using TextInteractor::eCursorToEnd;
693 using TextInteractor::eCursorToStart;
716 if (CheckIfDraggingBeepAndReturn ()) {
719 this->BreakInGroupedCommands ();
721 if (controlPressed) {
722 this->SetSelection (this->GetMarkerPositionOfStartOfWindow (), this->GetMarkerPositionOfStartOfWindow ());
725 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
726 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
728 selectionAdjuster.CaptureInfo (*
this);
733 this->ScrollByIfRoom (-(
int)this->GetTotalRowsInWindow ());
736 selectionAdjuster.CompleteAdjustment (*
this);
739#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
740 this->UpdateIfNoKeysPending ();
745 if (this->CheckIfDraggingBeepAndReturn ()) {
748 this->BreakInGroupedCommands ();
750 if (controlPressed) {
751 this->SetSelection (this->GetMarkerPositionOfEndOfWindow (), this->GetMarkerPositionOfEndOfWindow ());
754 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
755 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
757 selectionAdjuster.CaptureInfo (*
this);
760 this->ScrollByIfRoom (this->GetTotalRowsInWindow ());
763 selectionAdjuster.CompleteAdjustment (*
this);
766#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
767 this->UpdateIfNoKeysPending ();
772 if (this->CheckIfDraggingBeepAndReturn ()) {
775 this->BreakInGroupedCommands ();
776 this->DoSingleCharCursorEdit (eCursorToEnd, controlPressed ? eCursorByBuffer : eCursorByRow,
777 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
778 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
779#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
780 this->UpdateIfNoKeysPending ();
785 if (this->CheckIfDraggingBeepAndReturn ()) {
788 this->BreakInGroupedCommands ();
789 this->DoSingleCharCursorEdit (eCursorToStart, controlPressed ? eCursorByBuffer : eCursorByRow,
790 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
791 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
792#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
793 this->UpdateIfNoKeysPending ();
798 if (this->CheckIfDraggingBeepAndReturn ()) {
801 this->BreakInGroupedCommands ();
802 this->DoSingleCharCursorEdit (eCursorBack, controlPressed ? eCursorByWord : eCursorByChar,
803 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
804 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
805#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
806 this->UpdateIfNoKeysPending ();
811 if (this->CheckIfDraggingBeepAndReturn ()) {
814 this->BreakInGroupedCommands ();
815 if (controlPressed) {
816 if (this->GetControlArrowsScroll ()) {
817 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
818 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
820 selectionAdjuster.CaptureInfo (*
this);
822 this->ScrollByIfRoom (-1);
824 selectionAdjuster.CompleteAdjustment (*
this);
828 this->DoSingleCharCursorEdit (eCursorToStart, eCursorByLine, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
829 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
833 this->DoSingleCharCursorEdit (eCursorBack, eCursorByRow, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
834 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
836#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
837 this->UpdateIfNoKeysPending ();
842 if (this->CheckIfDraggingBeepAndReturn ()) {
845 this->BreakInGroupedCommands ();
846 this->DoSingleCharCursorEdit (eCursorForward, controlPressed ? eCursorByWord : eCursorByChar,
847 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
848 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
849#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
850 this->UpdateIfNoKeysPending ();
855 if (this->CheckIfDraggingBeepAndReturn ()) {
858 this->BreakInGroupedCommands ();
859 if (controlPressed) {
860 if (this->GetControlArrowsScroll ()) {
861 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
862 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
864 selectionAdjuster.CaptureInfo (*
this);
866 this->ScrollByIfRoom (1);
868 selectionAdjuster.CompleteAdjustment (*
this);
872 this->DoSingleCharCursorEdit (eCursorToEnd, eCursorByLine, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
873 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
877 this->DoSingleCharCursorEdit (eCursorForward, eCursorByRow, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
878 qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
880#if qStroika_Frameworks_Led_PeekForMoreCharsOnUserTyping
881 this->UpdateIfNoKeysPending ();
901 if (this->CheckIfDraggingBeepAndReturn ()) {
905 this->BreakInGroupedCommands ();
911 if (this->GetSelectionStart () == this->GetSelectionEnd ()) {
917 this->SetSelection (this->GetSelectionStart (), this->FindNextCharacter (this->GetSelectionStart ()), eDefaultUpdate);
918 this->InteractiveReplace (LED_TCHAR_OF (
""), 0);
921 this->OnPerformCommand (TextInteractor::kClear_CmdID);
923 this->ScrollToSelection ();
925#if qSupportWindowsSDKCallbacks
927 HWND hWnd = this->GetValidatedHWND ();
928 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
940 template <
typename BASE_INTERACTOR>
946 bool Led_Win32_Helper<BASE_INTERACTOR>::OnSetCursor_Msg (HWND hWnd, UINT nHitTest, UINT message)
948 if (nHitTest == HTCLIENT and hWnd == this->GetValidatedHWND ()) {
964 if (this->GetSelectionStart () != this->GetSelectionEnd ()) {
966 this->GetSelectionWindowRegion (&r, this->GetSelectionStart (), this->GetSelectionEnd ());
967 if (r.PtInRegion (AsPOINT (fMouseTrackingLastPoint))) {
968 ::SetCursor (::LoadCursor (
nullptr, IDC_ARROW));
973 ::SetCursor (::LoadCursor (
nullptr, IDC_IBEAM));
978 return !!this->DefWindowProc (WM_SETCURSOR, WPARAM (hWnd), MAKELPARAM (nHitTest, message));
981 template <
typename BASE_INTERACTOR>
987 UINT Led_Win32_Helper<BASE_INTERACTOR>::OnGetDlgCode_Msg ()
989 DWORD style = GetStyle ();
990 UINT dlogCode = DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTCHARS;
991 if ((style & ES_MULTILINE) and (style & ES_WANTRETURN)) {
992 dlogCode |= DLGC_WANTALLKEYS;
996 template <
typename BASE_INTERACTOR>
1001 void Led_Win32_Helper<BASE_INTERACTOR>::OnSetFocus_Msg (HWND )
1003#if qStroika_Frameworks_Led_ProvideIMESupport
1004 IME::Get ().ForgetPosition ();
1005 IME::Get ().Enable ();
1008 this->SetCaretShown (
true);
1009 this->SetSelectionShown (
true);
1011#if qSupportWindowsSDKCallbacks
1013 HWND hWnd = this->GetValidatedHWND ();
1014 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, (WPARAM)MAKELONG (GetWindowID (), EN_SETFOCUS), (LPARAM)(hWnd));
1017 template <
typename BASE_INTERACTOR>
1022 void Led_Win32_Helper<BASE_INTERACTOR>::OnKillFocus_Msg (HWND )
1024 if (this->PeekAtTextStore () ==
nullptr) {
1032 this->BreakInGroupedCommands ();
1034 this->SetCaretShown (
false);
1035 this->SetSelectionShown (
false);
1037#if qSupportWindowsSDKCallbacks
1039 HWND hWnd = this->GetValidatedHWND ();
1040 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, (WPARAM)MAKELONG (GetWindowID (), EN_KILLFOCUS), (LPARAM)(hWnd));
1043 template <
typename BASE_INTERACTOR>
1044 bool Led_Win32_Helper<BASE_INTERACTOR>::OnEraseBkgnd_Msg ([[maybe_unused]] HDC hDC)
1050 template <
typename BASE_INTERACTOR>
1051 void Led_Win32_Helper<BASE_INTERACTOR>::OnTimer_Msg (UINT_PTR nEventID, TIMERPROC* proc)
1053 HWND hWnd = this->GetValidatedHWND ();
1054 if (nEventID == eAutoscrollingTimerEventID) {
1055 if (::GetCapture () == hWnd) {
1058 this->WhileSimpleMouseTracking (fMouseTrackingLastPoint, fDragAnchor);
1061 this->StopAutoscrollTimer ();
1065 this->DefWindowProc (WM_TIMER, nEventID, LPARAM (proc));
1068 template <
typename BASE_INTERACTOR>
1069 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonDown_Msg (UINT nFlags,
int x,
int y)
1071 this->UpdateClickCount (Foundation::Time::GetTickCount (), Led_Point (y, x));
1072 this->OnNormalLButtonDown (nFlags, Led_Point (y, x));
1074 template <
typename BASE_INTERACTOR>
1075 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonUp_Msg (UINT ,
int x,
int y)
1077 HWND hWnd = this->GetValidatedHWND ();
1079 if (::GetCapture () == hWnd) {
1080 this->StopAutoscrollTimer ();
1081 Verify (::ReleaseCapture ());
1082 this->WhileSimpleMouseTracking (Led_Point (y, x), fDragAnchor);
1085 template <
typename BASE_INTERACTOR>
1086 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonDblClk_Msg (UINT ,
int x,
int y)
1088 this->IncrementCurClickCount (Foundation::Time::GetTickCount ());
1090 bool extendSelection = !!(::GetKeyState (VK_SHIFT) & 0x8000);
1091 if (not this->ProcessSimpleClick (Led_Point (y, x), this->GetCurClickCount (), extendSelection, &fDragAnchor)) {
1095 HWND hWnd = this->GetValidatedHWND ();
1096 (void)::SetCapture (hWnd);
1099 this->StartAutoscrollTimer ();
1101 template <
typename BASE_INTERACTOR>
1102 void Led_Win32_Helper<BASE_INTERACTOR>::OnMouseMove_Msg (UINT ,
int x,
int y)
1104 HWND hWnd = this->GetValidatedHWND ();
1105 fMouseTrackingLastPoint = Led_Point (y, x);
1106 if (::GetCapture () == hWnd) {
1107 this->WhileSimpleMouseTracking (Led_Point (y, x), fDragAnchor);
1110 template <
typename BASE_INTERACTOR>
1111 void Led_Win32_Helper<BASE_INTERACTOR>::OnVScroll_Msg (UINT nSBCode, UINT , HWND )
1113 using namespace Characters::Literals;
1114 DbgTrace (
"Led_Win32_Helper<BASE_INTERACTOR>::OnVScroll_Msg (nSBCode={},...)"_f, nSBCode);
1116 using TextInteractor::eDefaultUpdate;
1117 using TextInteractor::eImmediateUpdate;
1123 if (nSBCode == SB_LINEDOWN or nSBCode == SB_LINEUP or nSBCode == SB_PAGEDOWN or nSBCode == SB_PAGEUP) {
1124 if (not this->DelaySomeForScrollBarClick ()) {
1129#if qStroika_Frameworks_Led_DynamiclyChooseAutoScrollIncrement
1130 Foundation::Time::TimePointSeconds now = Foundation::Time::GetTickCount ();
1131 static Foundation::Time::TimePointSeconds sLastTimeThrough{};
1132 const Foundation::Time::DurationSeconds kClickThreshold = Led_GetDoubleClickTime () / 3;
1133 bool firstClick = (now - sLastTimeThrough > kClickThreshold);
1135 int increment = firstClick ? 1 : 2;
1137 const int increment = 1;
1140#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1141 fSBarThumbTracking = (nSBCode == SB_THUMBTRACK);
1145 this->ScrollSoShowing (this->GetLength ());
1148 case SB_ENDSCROLL: {
1153 this->ScrollByIfRoom (increment, eImmediateUpdate);
1157 this->ScrollByIfRoom (-increment, eImmediateUpdate);
1161 this->ScrollByIfRoom (this->GetTotalRowsInWindow ());
1165 this->ScrollByIfRoom (-(
int)this->GetTotalRowsInWindow ());
1169#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1174 case SB_THUMBPOSITION: {
1183 SCROLLINFO scrollInfo = this->GetVScrollInfo ();
1184#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1185 newPos = scrollInfo.nTrackPos;
1187 newPos = scrollInfo.nPos;
1189 newPos = min (newPos, this->GetLength ());
1195 if (newPos + scrollInfo.nPage >=
static_cast<UINT
> (scrollInfo.nMax)) {
1196 newPos = this->GetLength ();
1199#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1201 scrollInfo.cbSize =
sizeof (scrollInfo);
1202 scrollInfo.fMask = SIF_POS;
1203 scrollInfo.nPos =
static_cast<UINT
> (newPos);
1204 SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo);
1208#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1209 this->InvalidateScrollBarParameters ();
1213 this->SetTopRowInWindowByMarkerPosition (newPos);
1217 this->ScrollSoShowing (0);
1226#if qStroika_Frameworks_Led_DynamiclyChooseAutoScrollIncrement
1227 sLastTimeThrough = now;
1230 template <
typename BASE_INTERACTOR>
1231 void Led_Win32_Helper<BASE_INTERACTOR>::OnHScroll_Msg (UINT nSBCode, UINT , HWND )
1237 if (nSBCode == SB_LINEDOWN or nSBCode == SB_LINEUP or nSBCode == SB_PAGEDOWN or nSBCode == SB_PAGEUP) {
1238 if (not this->DelaySomeForScrollBarClick ()) {
1243#if qStroika_Frameworks_Led_DynamiclyChooseAutoScrollIncrement
1244 Foundation::Time::TimePointSeconds now = Foundation::Time::GetTickCount ();
1245 static Foundation::Time::TimePointSeconds sLastTimeThrough{};
1246 const Foundation::Time::DurationSeconds kClickThreshold = Led_GetDoubleClickTime ();
1247 bool firstClick = (now - sLastTimeThrough > kClickThreshold);
1249 int increment = firstClick ? 1 : 10;
1251 const int increment = 1;
1256 this->SetHScrollPos (this->ComputeMaxHScrollPos ());
1259 case SB_ENDSCROLL: {
1264 this->SetHScrollPos (min<CoordinateType> (this->GetHScrollPos () + increment, this->ComputeMaxHScrollPos ()));
1268 if (this->GetHScrollPos () > 0) {
1269 this->SetHScrollPos (max<CoordinateType> (0,
int (this->GetHScrollPos ()) - increment));
1274 const CoordinateType kPixelsAtATime = this->GetWindowRect ().GetWidth () / 2;
1275 this->SetHScrollPos (min<CoordinateType> (this->GetHScrollPos () + kPixelsAtATime, this->ComputeMaxHScrollPos ()));
1279 const CoordinateType kPixelsAtATime = this->GetWindowRect ().GetWidth () / 2;
1280 if (this->GetHScrollPos () > kPixelsAtATime) {
1281 this->SetHScrollPos (this->GetHScrollPos () - kPixelsAtATime);
1284 this->SetHScrollPos (0);
1289#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1294 case SB_THUMBPOSITION: {
1295#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1296 fSBarThumbTracking = (nSBCode == SB_THUMBTRACK);
1304 SCROLLINFO scrollInfo = this->GetHScrollInfo ();
1305#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1306 size_t newPos = scrollInfo.nTrackPos;
1308 size_t newPos = scrollInfo.nPos;
1311#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1313 scrollInfo.cbSize =
sizeof (scrollInfo);
1314 scrollInfo.fMask = SIF_POS;
1315 scrollInfo.nPos =
static_cast<int> (newPos);
1316 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo);
1319#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1320 this->InvalidateScrollBarParameters ();
1324 this->SetHScrollPos (min<CoordinateType> (
static_cast<CoordinateType
> (newPos), this->ComputeMaxHScrollPos ()));
1328 this->SetHScrollPos (0);
1337#if qStroika_Frameworks_Led_DynamiclyChooseAutoScrollIncrement
1338 sLastTimeThrough = now;
1341 template <
typename BASE_INTERACTOR>
1342 bool Led_Win32_Helper<BASE_INTERACTOR>::OnMouseWheel_Msg (WPARAM wParam, LPARAM lParam)
1344 using TextInteractor::eImmediateUpdate;
1345#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
1346 UINT keyState = LOWORD (wParam);
1349 if (keyState & (MK_SHIFT | MK_CONTROL)) {
1350 return !!this->DefWindowProc (WM_MOUSEWHEEL, wParam, lParam);
1353 short zDelta = (short)HIWORD (wParam);
1354 if ((zDelta >= 0) != (fAccumulatedWheelDelta >= 0)) {
1355 fAccumulatedWheelDelta = 0;
1357 fAccumulatedWheelDelta += zDelta;
1359 int nTicks = fAccumulatedWheelDelta / WHEEL_DELTA;
1361 fAccumulatedWheelDelta %= WHEEL_DELTA;
1363 int scrollLines = 3;
1364 Verify (::SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0));
1368 int totalRowsInWindow =
static_cast<int> (this->GetTotalRowsInWindow ());
1369 scrollLines = min (scrollLines, totalRowsInWindow);
1371 this->ScrollByIfRoom (-nTicks * scrollLines, eImmediateUpdate);
1375 template <
typename BASE_INTERACTOR>
1381 inline TWIPS_Rect Led_Win32_Helper<BASE_INTERACTOR>::GetDefaultWindowMargins ()
const
1383 return fDefaultWindowMargins;
1385 template <
typename BASE_INTERACTOR>
1397 void Led_Win32_Helper<BASE_INTERACTOR>::SetDefaultWindowMargins (
const TWIPS_Rect& defaultWindowMargins)
1399 if (fDefaultWindowMargins != defaultWindowMargins) {
1400 fDefaultWindowMargins = defaultWindowMargins;
1401 if (this->GetHWND () !=
nullptr) {
1406 template <
typename BASE_INTERACTOR>
1411 inline bool Led_Win32_Helper<BASE_INTERACTOR>::GetControlArrowsScroll ()
const
1413 return fControlArrowsScroll;
1415 template <
typename BASE_INTERACTOR>
1424 void Led_Win32_Helper<BASE_INTERACTOR>::SetControlArrowsScroll (
bool controlArrowsScroll)
1426 fControlArrowsScroll = controlArrowsScroll;
1428 template <
typename BASE_INTERACTOR>
1433 inline bool Led_Win32_Helper<BASE_INTERACTOR>::GetFunnyMSPageUpDownAdjustSelectionBehavior ()
const
1435 return fFunnyMSPageUpDownAdjustSelectionBehavior;
1437 template <
typename BASE_INTERACTOR>
1450 void Led_Win32_Helper<BASE_INTERACTOR>::SetFunnyMSPageUpDownAdjustSelectionBehavior (
bool funnyMSPageUpDownAdjustSelectionBehavior)
1452 fFunnyMSPageUpDownAdjustSelectionBehavior = funnyMSPageUpDownAdjustSelectionBehavior;
1454 template <
typename BASE_INTERACTOR>
1455 void Led_Win32_Helper<BASE_INTERACTOR>::OnEnable_Msg (
bool )
1459 template <
typename BASE_INTERACTOR>
1460 void Led_Win32_Helper<BASE_INTERACTOR>::OnSize_ ()
1462 using namespace Characters::Literals;
1463 this->InvalidateScrollBarParameters ();
1467 HWND hWnd = this->GetValidatedHWND ();
1468 Verify (::GetClientRect (hWnd, &cr));
1472 TextInteractor::Tablet_Acquirer tablet (
this);
1473 Led_Rect wmr = tablet->CvtFromTWIPS (GetDefaultWindowMargins ());
1474 r.top += wmr.GetTop ();
1475 r.left += wmr.GetLeft ();
1476 r.bottom -= wmr.GetBottom ();
1477 r.right -= wmr.GetRight ();
1483 if (r.top >= r.bottom) {
1484 r.bottom = r.top + 1;
1486 if (r.left >= r.right) {
1487 r.right = r.left + 1;
1489 DbgTrace (
"Led_Win32_Helper<>::OnSize_ (clientRect=(%d,%d,%d,%d), windowRect <= (%d,%d,%d,%d))"_f, cr.top, cr.left, cr.bottom,
1490 cr.right, r.top, r.left, r.bottom, r.right);
1491 this->SetWindowRect (r);
1493 template <
typename BASE_INTERACTOR>
1494 void Led_Win32_Helper<BASE_INTERACTOR>::RefreshWindowRect_ (
const Led_Rect& windowRectArea, UpdateMode updateMode)
const
1496 HWND hWnd = GetHWND ();
1497 if (hWnd !=
nullptr) {
1498 Assert (::IsWindow (hWnd));
1499 updateMode = this->RealUpdateMode (updateMode);
1500 switch (updateMode) {
1501 case TextInteractor::eDelayedUpdate: {
1502 if (not windowRectArea.IsEmpty ()) {
1503 RECT tmp = AsRECT (windowRectArea);
1504 Verify (::InvalidateRect (hWnd, &tmp,
true));
1507 case TextInteractor::eImmediateUpdate: {
1508 if (not windowRectArea.IsEmpty ()) {
1509 RECT tmp = AsRECT (windowRectArea);
1510 Verify (::RedrawWindow (hWnd, &tmp,
nullptr, RDW_INVALIDATE | RDW_UPDATENOW));
1516 template <
typename BASE_INTERACTOR>
1517 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateWindowRect_ (
const Led_Rect& windowRectArea)
const
1519 if (not windowRectArea.IsEmpty ()) {
1521 RECT tmp = AsRECT (windowRectArea);
1522 HWND hWnd = GetHWND ();
1523 if (hWnd !=
nullptr) {
1524 Assert (::IsWindow (hWnd));
1525 Verify (::RedrawWindow (hWnd, &tmp,
nullptr, RDW_UPDATENOW));
1529 template <
typename BASE_INTERACTOR>
1530 bool Led_Win32_Helper<BASE_INTERACTOR>::QueryInputKeyStrokesPending ()
const
1533 return (!!::PeekMessage (&msg, GetValidatedHWND (), WM_KEYDOWN, WM_KEYDOWN, PM_NOREMOVE));
1535 template <
typename BASE_INTERACTOR>
1536 Tablet* Led_Win32_Helper<BASE_INTERACTOR>::AcquireTablet ()
const
1538 Require (fAcquireCount < 100);
1540 if (fUpdateTablet !=
nullptr) {
1542 return fUpdateTablet;
1550 if (fAcquireCount == 0) {
1551 Assert (fAllocatedTablet.m_hDC ==
nullptr);
1552 Assert (fAllocatedTablet.m_hAttribDC ==
nullptr);
1553 HWND hWnd = GetHWND ();
1554 if (hWnd ==
nullptr) {
1555 throw TextInteractor::NoTabletAvailable ();
1557 Assert (::IsWindow (hWnd));
1558 HDC hdc = ::GetWindowDC (hWnd);
1560 Verify (fAllocatedTablet.Attach (hdc));
1562 Assert (fAllocatedTablet.m_hDC !=
nullptr);
1563 Assert (fAllocatedTablet.m_hAttribDC !=
nullptr);
1565 return (&fAllocatedTablet);
1567 template <
typename BASE_INTERACTOR>
1568 void Led_Win32_Helper<BASE_INTERACTOR>::ReleaseTablet (Tablet* tablet)
const
1571 Assert (fAcquireCount > 0);
1573 Assert (tablet == fUpdateTablet or tablet == &fAllocatedTablet);
1574 if (fAcquireCount == 0 and tablet == &fAllocatedTablet) {
1575 Verify (::ReleaseDC (GetValidatedHWND (), fAllocatedTablet.Detach ()));
1578 template <
typename BASE_INTERACTOR>
1584 void Led_Win32_Helper<BASE_INTERACTOR>::WindowDrawHelper (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
1586 using namespace Characters::Literals;
1587 DbgTrace (
"Led_Win32_Helper<>::WindowDrawHelper (subsetToDraw= (%d, %d, %d, %d))"_f, subsetToDraw.top, subsetToDraw.left,
1588 subsetToDraw.bottom, subsetToDraw.right);
1589 TemporarilyUseTablet tmpUseTablet{*
this, tablet, TemporarilyUseTablet::eDontDoTextMetricsChangedCall};
1590 this->Draw (subsetToDraw, printing);
1596 Led_Rect wr = this->GetWindowRect ();
1597 TWIPS_Rect wm = this->GetDefaultWindowMargins ();
1598 if (wm.GetTop () != 0 or wm.GetLeft () != 0 or wm.GetBottom () != 0 or wm.GetRight () != 0) {
1599 Led_Rect wmr = tablet->CvtFromTWIPS (wm);
1602 Led_Rect barRect = subsetToDraw;
1603 barRect.bottom = wr.top;
1604 if (not barRect.IsEmpty ()) {
1605 this->EraseBackground (tablet, barRect,
false);
1610 Led_Rect barRect = subsetToDraw;
1611 barRect.right = wr.left;
1612 if (not barRect.IsEmpty ()) {
1613 this->EraseBackground (tablet, barRect,
false);
1618 Led_Rect barRect = subsetToDraw;
1619 barRect.top = wr.bottom;
1620 if (not barRect.IsEmpty ()) {
1621 this->EraseBackground (tablet, barRect,
false);
1626 Led_Rect barRect = subsetToDraw;
1627 barRect.left = wr.right;
1628 if (not barRect.IsEmpty ()) {
1629 this->EraseBackground (tablet, barRect,
false);
1634 this->UpdateCaretState_ ();
1636 template <
typename BASE_INTERACTOR>
1641 void Led_Win32_Helper<BASE_INTERACTOR>::EraseBackground (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
1643 DWORD dwStyle = GetStyle ();
1644 if (((dwStyle & WS_DISABLED) or (dwStyle & ES_READONLY)) and (not printing)) {
1647 const Color kReadOnlyBackground = Color (::GetSysColor (COLOR_BTNFACE));
1648 tablet->EraseBackground_SolidHelper (subsetToDraw, kReadOnlyBackground);
1651 inherited::EraseBackground (tablet, subsetToDraw, printing);
1654 template <
typename BASE_INTERACTOR>
1655 bool Led_Win32_Helper<BASE_INTERACTOR>::CheckIfDraggingBeepAndReturn ()
1657 HWND hWnd = GetHWND ();
1658 if (hWnd !=
nullptr and ::GetCapture () == hWnd) {
1671 template <
typename BASE_INTERACTOR>
1680 void Led_Win32_Helper<BASE_INTERACTOR>::HandleTabCharacterTyped ()
1682 HWND hWnd = this->GetValidatedHWND ();
1683 if (this->GetStyle () & WS_TABSTOP) {
1684 HWND parent = ::GetParent (hWnd);
1685 if (parent !=
nullptr) {
1686 bool shiftPressed = !!(::GetKeyState (VK_SHIFT) & 0x8000);
1688 ::PostMessage (parent, WM_NEXTDLGCTL, 1,
false);
1691 ::PostMessage (parent, WM_NEXTDLGCTL, 0,
false);
1696 this->OnTypedNormalCharacter (
'\t',
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
1697 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
1698#if qSupportWindowsSDKCallbacks
1699 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
1703 template <
typename BASE_INTERACTOR>
1708 void Led_Win32_Helper<BASE_INTERACTOR>::AboutToUpdateText (
const UpdateInfo& updateInfo)
1710 if (GetHWND () !=
nullptr and this->CheckIfCurrentUpdateIsInteractive () and updateInfo.fRealContentUpdate) {
1714 DWORD dwStyle = this->GetStyle ();
1715 if (dwStyle & WS_DISABLED || dwStyle & ES_READONLY) {
1716 this->OnBadUserInput ();
1719 inherited::AboutToUpdateText (updateInfo);
1721 template <
typename BASE_INTERACTOR>
1726 void Led_Win32_Helper<BASE_INTERACTOR>::DidUpdateText (
const UpdateInfo& updateInfo)
noexcept
1728 inherited::DidUpdateText (updateInfo);
1729 this->DidUpdateText_ (updateInfo);
1731 template <
typename BASE_INTERACTOR>
1737 inline void Led_Win32_Helper<BASE_INTERACTOR>::DidUpdateText_ (
const UpdateInfo& updateInfo)
noexcept
1739 if (updateInfo.fTextModified) {
1740 this->SetCurClickCount (0, Foundation::Time::GetTickCount ());
1742 fDragAnchor = min (fDragAnchor, this->GetEnd ());
1745 template <
typename BASE_INTERACTOR>
1746 void Led_Win32_Helper<BASE_INTERACTOR>::SetScrollBarType (VHSelect vh, ScrollBarType scrollBarType)
1748 if (this->GetScrollBarType (vh) != scrollBarType) {
1749 inherited::SetScrollBarType (vh, scrollBarType);
1750 HWND hWnd = this->GetHWND ();
1751 if (hWnd !=
nullptr) {
1752 ::InvalidateRect (hWnd,
nullptr,
true);
1756 template <
typename BASE_INTERACTOR>
1764 bool Led_Win32_Helper<BASE_INTERACTOR>::ShouldUpdateHScrollBar ()
const
1767 return this->GetScrollBarType (TextInteractor::h) != TextInteractor::eScrollBarNever or (this->GetStyle () & WS_HSCROLL);
1769 template <
typename BASE_INTERACTOR>
1774 bool Led_Win32_Helper<BASE_INTERACTOR>::ShouldUpdateVScrollBar ()
const
1777 return this->GetScrollBarType (TextInteractor::v) != TextInteractor::eScrollBarNever or (GetStyle () & WS_VSCROLL);
1779 template <
typename BASE_INTERACTOR>
1786 bool Led_Win32_Helper<BASE_INTERACTOR>::TypeAndScrollInfoSBVisible (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo)
const
1788 return (scrollbarAppears == TextInteractor::eScrollBarAlways) or
1789 (scrollbarAppears == TextInteractor::eScrollBarAsNeeded and
1790 scrollInfo.nMin +
static_cast<int> (scrollInfo.nPage) <= scrollInfo.nMax);
1792 template <
typename BASE_INTERACTOR>
1802 SCROLLINFO Led_Win32_Helper<BASE_INTERACTOR>::GetHScrollInfo (UINT nMask)
const
1804 ::SCROLLINFO scrollInfo{};
1805 scrollInfo.cbSize =
sizeof (scrollInfo);
1806 scrollInfo.fMask = nMask;
1807 Verify (::GetScrollInfo (this->GetValidatedHWND (), SB_HORZ, &scrollInfo));
1810 template <
typename BASE_INTERACTOR>
1815 void Led_Win32_Helper<BASE_INTERACTOR>::SetHScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw)
1817 using namespace Characters::Literals;
1818 bool showBar = TypeAndScrollInfoSBVisible (scrollbarAppears, scrollInfo);
1820 DbgTrace (
"Led_Win32_Helper<>::SetHScrollInfo (scrollbarAppears={}, smin={}, smax={}, nPage={}, nPos={}) ==> showBar={})"_f,
1821 static_cast<int> (scrollbarAppears), scrollInfo.nMin, scrollInfo.nMax, scrollInfo.nPage, scrollInfo.nPos, showBar);
1828 ::ShowScrollBar (this->GetValidatedHWND (), SB_HORZ, showBar);
1829 SCROLLINFO si = scrollInfo;
1831 si.fMask |= SIF_DISABLENOSCROLL;
1834 si.fMask &= ~SIF_DISABLENOSCROLL;
1836 (void)::SetScrollInfo (this->GetValidatedHWND (), SB_HORZ, &si, redraw);
1838 template <
typename BASE_INTERACTOR>
1839 void Led_Win32_Helper<BASE_INTERACTOR>::SetHScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw)
1841 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo, redraw);
1843 template <
typename BASE_INTERACTOR>
1848 SCROLLINFO Led_Win32_Helper<BASE_INTERACTOR>::GetVScrollInfo (UINT nMask)
const
1850 ::SCROLLINFO scrollInfo{};
1851 scrollInfo.cbSize =
sizeof (scrollInfo);
1852 scrollInfo.fMask = nMask;
1853 Verify (::GetScrollInfo (this->GetValidatedHWND (), SB_VERT, &scrollInfo));
1856 template <
typename BASE_INTERACTOR>
1861 void Led_Win32_Helper<BASE_INTERACTOR>::SetVScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw)
1863 using namespace Characters::Literals;
1864 bool showBar = TypeAndScrollInfoSBVisible (scrollbarAppears, scrollInfo);
1865 DbgTrace (
"Led_Win32_Helper<>::SetVScrollInfo (scrollbarAppears={}, smin={}, smax={}, nPage={}, nPos={}) ==> showBar={})"_f,
1866 static_cast<int> (scrollbarAppears), scrollInfo.nMin, scrollInfo.nMax, scrollInfo.nPage, scrollInfo.nPos, showBar);
1873 ::ShowScrollBar (this->GetValidatedHWND (), SB_VERT, showBar);
1874 SCROLLINFO si = scrollInfo;
1876 si.fMask |= SIF_DISABLENOSCROLL;
1879 si.fMask &= ~SIF_DISABLENOSCROLL;
1881 (void)::SetScrollInfo (this->GetValidatedHWND (), SB_VERT, &si, redraw);
1883 template <
typename BASE_INTERACTOR>
1884 void Led_Win32_Helper<BASE_INTERACTOR>::SetVScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw)
1886 this->SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo, redraw);
1888 template <
typename BASE_INTERACTOR>
1889 void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateScrollBarParameters ()
1891 HWND hWnd = this->GetHWND ();
1892 if (hWnd !=
nullptr) {
1893 Assert (::IsWindow (hWnd));
1894 inherited::InvalidateScrollBarParameters_ ();
1895 this->InvalidateScrollBarParameters_ ();
1898 template <
typename BASE_INTERACTOR>
1899 inline void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateScrollBarParameters_ ()
1901 this->InvalidateCaretState ();
1903 template <
typename BASE_INTERACTOR>
1904 void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateCaretState ()
1916 HWND hWnd = this->GetHWND ();
1917 if (hWnd !=
nullptr) {
1918 Assert (::IsWindow (hWnd));
1921 inherited::InvalidateCaretState ();
1923 template <
typename BASE_INTERACTOR>
1924 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateCaretState_ ()
1926 HWND hWnd = this->GetHWND ();
1927 if (hWnd !=
nullptr) {
1928 if (this->GetCaretShown () and this->GetCaretShownSituation () and ::GetFocus () == hWnd) {
1933 Led_Rect caretRect = this->CalculateCaretRect ();
1935 if (caretRect.IsEmpty ()) {
1936#if qStroika_Frameworks_Led_ProvideIMESupport
1939 Led_Rect wr = this->GetWindowRect ();
1940 IME::Get ().NotifyPosition (hWnd, (SHORT)wr.GetLeft (), (SHORT)wr.GetBottom () + 1000);
1949 ::CreateCaret (hWnd, (HBITMAP)0, caretRect.GetWidth (), caretRect.GetHeight ());
1958 Assert (::IsWindow (hWnd));
1961 while (not ::ShowCaret (hWnd)) {
1964 ::SetCaretPos (caretRect.GetLeft (), caretRect.GetTop ());
1967#if qStroika_Frameworks_Led_ProvideIMESupport
1968 IME::Get ().NotifyPosition (hWnd, (SHORT)caretRect.GetLeft (), (SHORT)caretRect.GetTop ());
1977 template <
typename BASE_INTERACTOR>
1983 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateScrollBars ()
1985 using namespace Characters::Literals;
1986 DbgTrace (
"Led_Win32_Helper<>::UpdateScrollBars () with winStart={}, winEnd={})"_f, this->GetMarkerPositionOfStartOfWindow (),
1987 this->GetMarkerPositionOfEndOfWindow ());
1997#if qStroika_Frameworks_Led_ScrollTextDuringThumbTracking
1998 if (fSBarThumbTracking) {
2003 inherited::UpdateScrollBars_ ();
2005 HWND hWnd = this->GetHWND ();
2006 if (hWnd !=
nullptr) {
2008#if qSupportWindowsSDKCallbacks
2009 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_VSCROLL), (LPARAM)hWnd);
2012 if (this->ShouldUpdateHScrollBar ()) {
2013 ::SCROLLINFO scrollInfo{};
2014 scrollInfo.cbSize =
sizeof (scrollInfo);
2015 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
2017 scrollInfo.nMin = 0;
2018 scrollInfo.nPage = this->GetWindowRect ().GetWidth ();
2019 scrollInfo.nMax = scrollInfo.nPage + this->ComputeMaxHScrollPos ();
2020 scrollInfo.nPos = this->GetHScrollPos ();
2027 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo);
2029 if (this->ShouldUpdateVScrollBar ()) {
2030 size_t startOfWindow = this->GetMarkerPositionOfStartOfWindow ();
2031 size_t endOfWindow = this->GetMarkerPositionOfEndOfWindow ();
2032 size_t verticalWindowSpan = endOfWindow - startOfWindow;
2034 ::SCROLLINFO scrollInfo;
2035 (void)::memset (&scrollInfo, 0,
sizeof (scrollInfo));
2036 scrollInfo.cbSize =
sizeof (scrollInfo);
2037 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
2039 scrollInfo.nMin = 0;
2040 scrollInfo.nMax =
static_cast<int> (this->GetLength ());
2041 scrollInfo.nPage =
static_cast<UINT
> (verticalWindowSpan);
2042 scrollInfo.nPos =
static_cast<int> (startOfWindow);
2049 this->SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo);
2053 template <
typename BASE_INTERACTOR>
2054 void Led_Win32_Helper<BASE_INTERACTOR>::OnNormalLButtonDown (UINT ,
const Led_Point& at)
2056 this->BreakInGroupedCommands ();
2057 fMouseTrackingLastPoint = at;
2058 if (not(this->GetStyle () & WS_DISABLED)) {
2059 HWND hWnd = this->GetValidatedHWND ();
2061 if (::GetFocus () != hWnd) {
2062 (void)::SetFocus (hWnd);
2065 bool extendSelection = !!(::GetKeyState (VK_SHIFT) & 0x8000);
2067 if (not this->ProcessSimpleClick (at, this->GetCurClickCount (), extendSelection, &fDragAnchor)) {
2081 (void)::SetCapture (hWnd);
2084 this->StartAutoscrollTimer ();
2086 Assert (fDragAnchor <= this->GetEnd ());
2093 template <
typename BASE_INTERACTOR>
2094 void Led_Win32_Helper<BASE_INTERACTOR>::StartAutoscrollTimer ()
2099 Assert (fAutoScrollTimerID == 0);
2101 if (fAutoScrollTimerID == 0) {
2102 const int kTimeout = 20;
2104 Verify ((fAutoScrollTimerID = ::SetTimer (this->GetValidatedHWND (), eAutoscrollingTimerEventID, kTimeout,
nullptr)) != 0);
2107 template <
typename BASE_INTERACTOR>
2108 void Led_Win32_Helper<BASE_INTERACTOR>::StopAutoscrollTimer ()
2110 if (fAutoScrollTimerID != 0) {
2111 Verify (::KillTimer (this->GetValidatedHWND (), eAutoscrollingTimerEventID));
2112 fAutoScrollTimerID = 0;
2115 template <
typename BASE_INTERACTOR>
2116 bool Led_Win32_Helper<BASE_INTERACTOR>::OnCopyCommand_Before ()
2118 if (not ::OpenClipboard (this->GetValidatedHWND ())) {
2119 this->OnBadUserInput ();
2122 (void)::EmptyClipboard ();
2123 bool result = inherited::OnCopyCommand_Before ();
2125 Verify (::CloseClipboard ());
2130 template <
typename BASE_INTERACTOR>
2131 void Led_Win32_Helper<BASE_INTERACTOR>::OnCopyCommand_After ()
2133 inherited::OnCopyCommand_After ();
2134 if (not ::CloseClipboard ()) {
2135 this->OnBadUserInput ();
2138 template <
typename BASE_INTERACTOR>
2139 bool Led_Win32_Helper<BASE_INTERACTOR>::OnPasteCommand_Before ()
2141 if (not ::OpenClipboard (this->GetValidatedHWND ())) {
2142 this->OnBadUserInput ();
2145 bool result = inherited::OnPasteCommand_Before ();
2147 Verify (::CloseClipboard ());
2152 template <
typename BASE_INTERACTOR>
2153 void Led_Win32_Helper<BASE_INTERACTOR>::OnPasteCommand_After ()
2155 inherited::OnPasteCommand_After ();
2156 if (not ::CloseClipboard ()) {
2157 this->OnBadUserInput ();
2160 template <
typename BASE_INTERACTOR>
2166 nonvirtual DWORD Led_Win32_Helper<BASE_INTERACTOR>::GetStyle ()
const
2168 HWND hWnd = GetHWND ();
2169 if (hWnd ==
nullptr) {
2173 Assert (::IsWindow (hWnd));
2174 return (DWORD)::GetWindowLong (hWnd, GWL_STYLE);
2177 template <
typename BASE_INTERACTOR>
2178 inline int Led_Win32_Helper<BASE_INTERACTOR>::GetWindowID ()
const
2180 return (::GetWindowLong (this->GetValidatedHWND (), GWL_ID));
2182 template <
typename BASE_INTERACTOR>
2183 inline HWND Led_Win32_Helper<BASE_INTERACTOR>::GetValidatedHWND ()
const
2185 HWND hWnd = GetHWND ();
2187 Assert (::IsWindow (hWnd));
2192 template <
typename BASE_INTERACTOR>
2193 inline Led_Win32_Helper<BASE_INTERACTOR>::TemporarilyUseTablet::TemporarilyUseTablet (Led_Win32_Helper<BASE_INTERACTOR>& editor,
2194 Tablet* t, DoTextMetricsChangedCall tmChanged)
2196 , fOldTablet{editor.fUpdateTablet}
2197 , fDoTextMetricsChangedCall{tmChanged}
2199 editor.fUpdateTablet = t;
2200 if (tmChanged == eDoTextMetricsChangedCall) {
2201 editor.TabletChangedMetrics ();
2204 template <
typename BASE_INTERACTOR>
2205 inline Led_Win32_Helper<BASE_INTERACTOR>::TemporarilyUseTablet::~TemporarilyUseTablet ()
2207 fEditor.fUpdateTablet = fOldTablet;
2208 if (fDoTextMetricsChangedCall == eDoTextMetricsChangedCall) {
2209 fEditor.TabletChangedMetrics ();
2214 template <
typename BASECLASS>
2215 Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::Led_Win32_Win32SDKMessageMimicHelper ()
2219 template <
typename BASECLASS>
2225 bool Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::HandleMessage (UINT message, WPARAM wParam, LPARAM lParam, LRESULT* result)
2230 *result = this->OnMsgSetText (wParam, lParam);
2233 *result = this->OnMsgGetText (wParam, lParam);
2235 case WM_GETTEXTLENGTH:
2236 *result = this->OnMsgGetTextLength (wParam, lParam);
2239 *result = this->OnMsgGetSel (wParam, lParam);
2241 case EM_SETREADONLY:
2242 *result = this->OnMsgSetReadOnly (wParam, lParam);
2244 case EM_GETFIRSTVISIBLELINE:
2245 *result = this->OnMsgGetFirstVisibleLine (wParam, lParam);
2248 *result = this->OnMsgLineIndex (wParam, lParam);
2250 case EM_GETLINECOUNT:
2251 *result = this->OnMsgLineCount (wParam, lParam);
2254 *result = this->OnMsgCanUndo (wParam, lParam);
2257 *result = this->OnMsgUndo (wParam, lParam);
2259 case EM_EMPTYUNDOBUFFER:
2260 *result = this->OnMsgEmptyUndoBuffer (wParam, lParam);
2263 *result = this->OnMsgClear (wParam, lParam);
2266 *result = this->OnMsgCut (wParam, lParam);
2269 *result = this->OnMsgCopy (wParam, lParam);
2272 *result = this->OnMsgPaste (wParam, lParam);
2274 case EM_LINEFROMCHAR:
2275 *result = this->OnMsgLineFromChar (wParam, lParam);
2278 *result = this->OnMsgLineLength (wParam, lParam);
2281 *result = this->OnMsgLineScroll (wParam, lParam);
2284 *result = this->OnMsgReplaceSel (wParam, lParam);
2287 *result = this->OnMsgSetSel (wParam, lParam);
2289 case EM_SCROLLCARET:
2290 *result = this->OnMsgScrollCaret (wParam, lParam);
2293 *result = this->OnMsgGetFont (wParam, lParam);
2296 *result = this->OnMsgSetFont (wParam, lParam);
2302 template <
typename BASECLASS>
2303 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetText (WPARAM wParam, LPARAM lParam)
2306 int cchTextMax = (int)wParam;
2307 LPSTR lpText = (LPSTR)lParam;
2308 Require (cchTextMax > 0);
2310 size_t len = this->GetLength ();
2312 this->CopyOut (0, len, buf.data ());
2313 size_t len2 = 2 * len;
2315 len2 = Characters::NLToNative<Led_tChar> (buf.data (), len, buf2.data (), len2);
2317 int nChars = ::WideCharToMultiByte (CP_ACP, 0, buf2.data (),
static_cast<int> (len2), lpText, cchTextMax - 1,
nullptr,
nullptr);
2318 lpText[nChars] =
'\0';
2321 template <
typename BASECLASS>
2322 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetText (WPARAM , LPARAM lParam)
2325 LPSTR lpText = (LPSTR)lParam;
2333 this->Replace (0, this->GetEnd (), LED_TCHAR_OF (
""), 0);
2334 if (lpText !=
nullptr) {
2335 size_t len = ::strlen (lpText);
2338 len =
static_cast<size_t> (::MultiByteToWideChar (CP_ACP, 0, lpText,
static_cast<int> (len), buf.data (),
static_cast<int> (len)));
2339 len = Characters::NormalizeTextToNL<Led_tChar> (buf.data (), len, buf.data (), len);
2340 this->Replace (0, 0, buf.data (), len);
2345 template <
typename BASECLASS>
2346 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetTextLength (WPARAM , LPARAM )
2349 return (4 * this->GetLength ());
2351 template <
typename BASECLASS>
2352 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetSel (WPARAM wParam, LPARAM lParam)
2354 DWORD iSelStart =
static_cast<DWORD
> (this->GetSelectionStart ());
2355 DWORD iSelEnd =
static_cast<DWORD
> (this->GetSelectionEnd ());
2357 *
reinterpret_cast<DWORD*
> (wParam) = iSelStart;
2360 *
reinterpret_cast<DWORD*
> (lParam) = iSelEnd;
2362 DWORD dw = (((WORD)iSelStart) << 16) | ((WORD)iSelEnd);
2365 template <
typename BASECLASS>
2366 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetFirstVisibleLine (WPARAM , LPARAM )
2368 Assert (this->GetTopRowInWindow () >= 0);
2369 return this->GetTopRowInWindow ();
2371 template <
typename BASECLASS>
2372 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetReadOnly (WPARAM wParam, LPARAM )
2374 HWND hWnd = this->GetValidatedHWND ();
2375 DWORD dwStyle = this->GetStyle ();
2376 bool readOnly = !!wParam;
2378 dwStyle |= ES_READONLY;
2381 dwStyle &= ~ES_READONLY;
2383 DWORD dwStyle1 = ::GetWindowLong (hWnd, GWL_STYLE);
2384 if (dwStyle != dwStyle1) {
2385 ::SetWindowLong (hWnd, GWL_STYLE, dwStyle);
2387 TextInteractor* ti =
this;
2390 if (this->GetCommandHandler () !=
nullptr) {
2391 this->GetCommandHandler ()->Commit ();
2396 template <
typename BASECLASS>
2397 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineIndex (WPARAM wParam, LPARAM )
2399 size_t row = (int (wParam) == -1) ? this->GetRowContainingPosition (this->GetSelectionEnd ()) : (size_t (wParam));
2403 row = min (row, this->GetRowCount () - 1);
2404 return (this->GetStartOfRow (row));
2406 template <
typename BASECLASS>
2407 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineCount (WPARAM , LPARAM )
2409 return this->GetRowCount ();
2411 template <
typename BASECLASS>
2412 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCanUndo (WPARAM , LPARAM )
2414 CommandHandler* ch = this->GetCommandHandler ();
2415 return ch !=
nullptr and ch->CanUndo ();
2417 template <
typename BASECLASS>
2418 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgUndo (WPARAM , LPARAM )
2420 CommandHandler* ch = this->GetCommandHandler ();
2421 if (ch !=
nullptr and ch->CanUndo ()) {
2422 this->OnUndoCommand ();
2427 template <
typename BASECLASS>
2428 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgEmptyUndoBuffer (WPARAM , LPARAM )
2430 CommandHandler* ch = this->GetCommandHandler ();
2431 if (ch !=
nullptr) {
2436 template <
typename BASECLASS>
2437 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgClear (WPARAM , LPARAM )
2439 this->OnClearCommand ();
2440#if qSupportWindowsSDKCallbacks
2441 HWND hWnd = this->GetValidatedHWND ();
2442 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2446 template <
typename BASECLASS>
2447 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCut (WPARAM , LPARAM )
2449 this->OnCutCommand ();
2450#if qSupportWindowsSDKCallbacks
2451 HWND hWnd = this->GetValidatedHWND ();
2452 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2456 template <
typename BASECLASS>
2457 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCopy (WPARAM , LPARAM )
2459 this->OnCopyCommand ();
2462 template <
typename BASECLASS>
2463 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgPaste (WPARAM , LPARAM )
2465 this->OnPasteCommand ();
2466#if qSupportWindowsSDKCallbacks
2467 HWND hWnd = this->GetValidatedHWND ();
2468 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2472 template <
typename BASECLASS>
2473 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineFromChar (WPARAM wParam, LPARAM )
2475 ptrdiff_t nIndex = ptrdiff_t (wParam);
2477 nIndex =
static_cast<ptrdiff_t
> (this->GetSelectionStart ());
2482 Assert (nIndex >= 0);
2483 if (
size_t (nIndex) > this->GetEnd ()) {
2484 nIndex = this->GetEnd ();
2486 return this->GetRowContainingPosition (nIndex);
2488 template <
typename BASECLASS>
2489 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineLength (WPARAM wParam, LPARAM )
2491 size_t row = (int (wParam) == -1) ? this->GetRowContainingPosition (this->GetSelectionEnd ()) : (size_t (wParam));
2495 if (row > this->GetRowCount () - 1) {
2496 row = this->GetRowCount () - 1;
2498 return this->GetEndOfRow (row) - this->GetStartOfRow (row);
2500 template <
typename BASECLASS>
2501 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineScroll (WPARAM wParam, LPARAM lParam)
2503 [[maybe_unused]]
int nChars = int (wParam);
2505 int nLines = int (lParam);
2506 this->ScrollByIfRoom (nLines);
2507 return !!(this->GetStyle () & ES_MULTILINE);
2509 template <
typename BASECLASS>
2510 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgReplaceSel ([[maybe_unused]] WPARAM wParam, LPARAM lParam)
2513 Assert (wParam == 0);
2514 LPCTSTR text = (LPCTSTR)lParam;
2516 size_t len = ::_tcslen (text);
2519#if qStroika_Foundation_Characters_SDKUseswchar_t
2521 (void)::memcpy (buf.begin (), text, (len + 1) *
sizeof (text[0]));
2523 len = ::MultiByteToWideChar (CP_ACP, 0, text, len, buf, len);
2525 size_t nLen = Characters::NormalizeTextToNL<Led_tChar> (buf.data (), len, buf.data (), len);
2526 Assert (ValidateTextForCharsetConformance (buf.data (), nLen));
2527 this->Replace (this->GetSelectionStart (), this->GetSelectionEnd (), buf.data (), nLen);
2530 template <
typename BASECLASS>
2531 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetSel (WPARAM wParam, LPARAM lParam)
2536 ptrdiff_t nStart = ptrdiff_t (wParam);
2537 ptrdiff_t nEnd = ptrdiff_t (lParam);
2539 nEnd = this->GetLength ();
2547 if (
size_t (nEnd) > this->GetEnd ()) {
2548 nEnd =
static_cast<ptrdiff_t
> (this->GetEnd ());
2550 if (nStart > nEnd) {
2551 swap (nStart, nEnd);
2553 this->SetSelection (
static_cast<ptrdiff_t
> (nStart),
static_cast<ptrdiff_t
> (nEnd));
2556 template <
typename BASECLASS>
2557 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgScrollCaret (WPARAM , LPARAM )
2559 this->ScrollToSelection ();
2562 template <
typename BASECLASS>
2563 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetFont (WPARAM , LPARAM )
2578 FontSpecification defaultFont = this->GetDefaultSelectionFont ();
2579 LOGFONT defaultFontLF;
2580 defaultFont.GetOSRep (&defaultFontLF);
2582 if (fDefaultFontCache.m_hObject !=
nullptr) {
2583 FontObject tmpHackToTestFont;
2584 Verify (tmpHackToTestFont.CreateFontIndirect (&defaultFontLF));
2586 ::LOGFONT tmpHackToTestFontLF{};
2587 Verify (tmpHackToTestFont.GetObject (sizeof (tmpHackToTestFontLF), &tmpHackToTestFontLF));
2589 ::LOGFONT currentLF{};
2590 Verify (fDefaultFontCache.GetObject (sizeof (currentLF), ¤tLF));
2592 if (::memcmp (¤tLF, &tmpHackToTestFontLF,
sizeof (currentLF)) != 0) {
2593 fDefaultFontCache.DeleteObject ();
2594 Assert (fDefaultFontCache.m_hObject ==
nullptr);
2598 if (fDefaultFontCache.m_hObject ==
nullptr) {
2599 fDefaultFontCache.CreateFontIndirect (&defaultFontLF);
2601 return (LRESULT)fDefaultFontCache.m_hObject;
2603 template <
typename BASECLASS>
2604 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetFont (WPARAM wParam, LPARAM lParam)
2606 IncrementalFontSpecification fontSpec;
2608 HFONT fontToUse =
reinterpret_cast<HFONT
> (wParam);
2609 if (fontToUse ==
nullptr) {
2610 fontToUse =
reinterpret_cast<HFONT
> (::GetStockObject (DEFAULT_GUI_FONT));
2613 ::GetObject (fontToUse,
sizeof (lf), &lf);
2614 fontSpec.SetOSRep (lf);
2616 this->SetDefaultFont (fontSpec, lParam ? TextInteractor::eDefaultUpdate : TextInteractor::eNoUpdate);
2621 inline SimpleWin32WndProcHelper::SimpleWin32WndProcHelper ()
2623 , fSuperWindowProc{nullptr}
2626 inline HWND SimpleWin32WndProcHelper::GetHWND ()
const
2630 inline void SimpleWin32WndProcHelper::SetHWND (HWND hWnd)
2632 if (fHWnd !=
nullptr) {
2633 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA, 0);
2636 if (fHWnd !=
nullptr) {
2637 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA,
reinterpret_cast<DWORD_PTR
> (
this));
2640 inline HWND SimpleWin32WndProcHelper::GetValidatedHWND ()
const
2642 HWND hWnd = this->GetHWND ();
2644 Assert (::IsWindow (hWnd));
2647 inline void SimpleWin32WndProcHelper::Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
2648 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance)
2650 Create (0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance);
2652 inline LRESULT SimpleWin32WndProcHelper::SendMessage (UINT msg, WPARAM wParam, LPARAM lParam)
2654#if !qStroika_Foundation_Characters_SDKUseswchar_t
2655 if (IsWindowUNICODE ()) {
2656 return ::SendMessageW (this->GetValidatedHWND (), msg, wParam, lParam);
2659 return ::SendMessage (this->GetValidatedHWND (), msg, wParam, lParam);
2661 inline bool SimpleWin32WndProcHelper::IsWindowRealized ()
const
2663 return this->GetHWND () !=
nullptr;
2665 inline void SimpleWin32WndProcHelper::Assert_Window_Realized ()
const
2667 Assert (this->IsWindowRealized ());
2669 inline void SimpleWin32WndProcHelper::Require_Window_Realized ()
const
2671 Require (this->IsWindowRealized ());
2673 inline bool SimpleWin32WndProcHelper::IsWindowUNICODE ()
const
2675 Require_Window_Realized ();
2676 return !!::IsWindowUnicode (GetHWND ());
2678 inline bool SimpleWin32WndProcHelper::IsWindowShown ()
const
2680 Require_Window_Realized ();
2681 return !!::IsWindowVisible (GetHWND ());
2683 inline void SimpleWin32WndProcHelper::SetWindowVisible (
bool shown)
2685 Require_Window_Realized ();
2686 (void)::ShowWindow (GetHWND (), shown ? SW_SHOW : SW_HIDE);
2692 inline bool SimpleWin32WndProcHelper::SubclassWindow (HWND hWnd)
2694 Require (fSuperWindowProc ==
nullptr);
2695 Require (fHWnd ==
nullptr);
2697 Require (::IsWindow (hWnd));
2698 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLongPtr (hWnd, GWLP_WNDPROC,
reinterpret_cast<DWORD_PTR
> (StaticWndProc)));
2699 if (fSuperWindowProc ==
nullptr) {
2709 inline bool SimpleWin32WndProcHelper::SubclassWindowW (HWND hWnd)
2711 Require (fSuperWindowProc ==
nullptr);
2712 Require (fHWnd ==
nullptr);
2714 Require (::IsWindow (hWnd));
2715 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLongPtr (hWnd, GWLP_WNDPROC,
reinterpret_cast<DWORD_PTR
> (StaticWndProc)));
2716 if (fSuperWindowProc ==
nullptr) {
2722 inline LRESULT SimpleWin32WndProcHelper::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
2724 return this->DefWindowProc (message, wParam, lParam);
2726 inline LRESULT SimpleWin32WndProcHelper::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
2728#if !qStroika_Foundation_Characters_SDKUseswchar_t
2729 if (IsWindowUNICODE ()) {
2730 if (fSuperWindowProc ==
nullptr) {
2731 return ::DefWindowProcW (this->GetValidatedHWND (), message, wParam, lParam);
2734 return ::CallWindowProcW (fSuperWindowProc, this->GetValidatedHWND (), message, wParam, lParam);
2738 if (fSuperWindowProc ==
nullptr) {
2739 return ::DefWindowProc (this->GetValidatedHWND (), message, wParam, lParam);
2742 return ::CallWindowProc (fSuperWindowProc, this->GetValidatedHWND (), message, wParam, lParam);
2747 template <
typename BASE_WIN32_HELPER>
2748 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Led_Win32_SimpleWndProc_Helper ()
2749 : BASE_WIN32_HELPER{}
2751 , fSuperWindowProc{nullptr}
2754 template <
typename BASE_WIN32_HELPER>
2755 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::~Led_Win32_SimpleWndProc_Helper ()
2757 if (GetHWND () !=
nullptr) {
2758 ::DestroyWindow (GetHWND ());
2761 template <
typename BASE_WIN32_HELPER>
2762 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
2763 int nWidth,
int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance)
2765 Create (0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance);
2767 template <
typename BASE_WIN32_HELPER>
2776 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
2777 DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight, HWND hWndParent,
2778 HMENU hMenu, HINSTANCE hInstance)
2781 if (lpClassName ==
nullptr) {
2782 tmpClassName = Foundation::Characters::CString::Format (_T(
"Led_Win32_SimpleWndProc_Helper<>-%d-%p"), ::GetCurrentProcessId (), &StaticWndProc);
2783 lpClassName = tmpClassName.c_str ();
2785 static bool sRegistered =
false;
2786 if (not sRegistered) {
2788 memset (&wcex, 0,
sizeof (wcex));
2789 wcex.cbSize =
sizeof (WNDCLASSEX);
2790 wcex.lpfnWndProc = (WNDPROC)StaticWndProc;
2791 wcex.lpszClassName = lpClassName;
2792 ATOM regResult = ::RegisterClassEx (&wcex);
2793 if (regResult == 0) {
2794 DWORD lastErr = ::GetLastError ();
2795 if (lastErr == ERROR_CLASS_ALREADY_EXISTS) {
2806 [[maybe_unused]] HWND hWnd =
2807 ::CreateWindowEx (dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance,
this);
2808 Assert (hWnd == this->GetValidatedHWND ());
2810 template <
typename BASE_WIN32_HELPER>
2811 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::SetHWND (HWND hWnd)
2813 if (fHWnd !=
nullptr) {
2814 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA, 0);
2817 if (fHWnd !=
nullptr) {
2818 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA,
reinterpret_cast<DWORD_PTR
> (
this));
2821 template <
typename BASE_WIN32_HELPER>
2822 HWND Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::GetHWND ()
const
2826 template <
typename BASE_INTERACTOR>
2827 void Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::OnNCDestroy_Msg ()
2829 (void)DefWindowProc (WM_NCDESTROY, 0, 0);
2832 template <
typename BASE_INTERACTOR>
2840 bool Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::SubclassWindow (HWND hWnd)
2842 Require (fSuperWindowProc ==
nullptr);
2843 Require (fHWnd ==
nullptr);
2845 Require (::IsWindow (hWnd));
2846 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLong (hWnd, GWLP_WNDPROC,
reinterpret_cast<LONG
> (StaticWndProc)));
2847 if (fSuperWindowProc ==
nullptr) {
2851 HookSubclassWindow ();
2854 template <
typename BASE_INTERACTOR>
2868 bool Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::ReplaceWindow (HWND hWnd)
2870 Require (fSuperWindowProc ==
nullptr);
2871 Require (fHWnd ==
nullptr);
2873 Require (::IsWindow (hWnd));
2875 HWND parent = ::GetParent (hWnd);
2876 if (parent ==
nullptr) {
2879 int id = ::GetWindowLong (hWnd, GWL_ID);
2881 Assert (hWnd == ::GetDlgItem (parent,
id));
2883 DWORD dwStyle = ::GetWindowLong (hWnd, GWL_STYLE);
2884 DWORD exStyle = ::GetWindowLong (hWnd, GWL_EXSTYLE);
2888 memset (&wp, 0,
sizeof (wp));
2889 wp.length =
sizeof (wp);
2890 Verify (::GetWindowPlacement (hWnd, &wp));
2893 bool justUseSystemFont =
true;
2895 HFONT hFont =
nullptr;
2896 if ((hFont = (HFONT)::SendMessage (hWnd, WM_GETFONT, 0, 0L)) !=
nullptr) {
2897 if (::GetObject (hFont,
sizeof (LOGFONT), &useFont)) {
2898 justUseSystemFont =
false;
2904 ::DestroyWindow (hWnd);
2905 DISABLE_COMPILER_MSC_WARNING_START (4312)
2906 Create (exStyle,
nullptr,
nullptr, dwStyle | WS_CHILD, wp.rcNormalPosition.left, wp.rcNormalPosition.top,
2907 wp.rcNormalPosition.right - wp.rcNormalPosition.left, wp.rcNormalPosition.bottom - wp.rcNormalPosition.top, parent, (HMENU)
id,
nullptr);
2908 DISABLE_COMPILER_MSC_WARNING_END (4312)
2914 FontObject fontToUse;
2915 if (not justUseSystemFont) {
2916 Verify (fontToUse.CreateFontIndirect (&useFont));
2918 bool redrawFlag =
true;
2919 (void)::SendMessage (this->GetValidatedHWND (), WM_SETFONT,
2920 justUseSystemFont ? NULL :
reinterpret_cast<WPARAM
> (
static_cast<HFONT
> (fontToUse)), redrawFlag);
2924 template <
typename BASE_INTERACTOR>
2925 void Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::HookSubclassWindow ()
2927 HWND hWnd = this->GetValidatedHWND ();
2928 DWORD dwStyle = ::GetWindowLong (hWnd, GWL_STYLE);
2929 if ((dwStyle & WS_VSCROLL) and this->GetScrollBarType (TextInteractor::v) == TextInteractor::eScrollBarNever) {
2930 this->SetScrollBarType (TextInteractor::v, TextInteractor::eScrollBarAlways);
2932 if ((dwStyle & WS_HSCROLL) and this->GetScrollBarType (TextInteractor::h) == TextInteractor::eScrollBarNever) {
2933 this->SetScrollBarType (TextInteractor::h, TextInteractor::eScrollBarAlways);
2935 this->OnSize_Msg ();
2937 template <
typename BASE_WIN32_HELPER>
2938 LRESULT CALLBACK Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
2940 if (message == WM_CREATE) {
2941 ::LPCREATESTRUCT lpcs = (::LPCREATESTRUCT)lParam;
2943 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>* pThis =
2944 reinterpret_cast<Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>*
> (lpcs->lpCreateParams);
2945 Assert (pThis->GetHWND () ==
nullptr);
2946 pThis->SetHWND (hWnd);
2949 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>* pThis =
2950 reinterpret_cast<Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>*
> (::GetWindowLongPtr (hWnd, GWLP_USERDATA));
2952 if (pThis ==
nullptr) {
2959 Assert (message == WM_GETMINMAXINFO or message == WM_NCCREATE or message == WM_NCCALCSIZE or message == 0x0093 or
2960 message == 0x0094 or message == WM_NCMOUSELEAVE);
2961 return ::DefWindowProc (hWnd, message, wParam, lParam);
2964 Assert (pThis !=
nullptr);
2965 Assert (pThis->GetHWND () == hWnd);
2966 return pThis->WndProc (message, wParam, lParam);
2968 template <
typename BASE_WIN32_HELPER>
2969 LRESULT Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
2971#define MY_GET_X_LPARAM(lp) ((int)(short)LOWORD (lp))
2972#define MY_GET_Y_LPARAM(lp) ((int)(short)HIWORD (lp))
2975 return this->OnCreate_Msg (
reinterpret_cast<::LPCREATESTRUCT
> (lParam));
2977 this->OnPaint_Msg ();
2980 this->OnSize_Msg ();
2983 this->OnChar_Msg (
static_cast<UINT
> (wParam), lParam);
2986 return this->OnUniChar_Msg (wParam, lParam);
2989 this->OnKeyDown_Msg (
static_cast<UINT
> (wParam), lParam);
2992 return this->OnSetCursor_Msg ((HWND)wParam, LOWORD (lParam), HIWORD (lParam));
2994 return this->OnGetDlgCode_Msg ();
2996 this->OnSetFocus_Msg (HWND (wParam));
2999 this->OnKillFocus_Msg (HWND (wParam));
3002 return this->OnEraseBkgnd_Msg (HDC (wParam));
3004 this->OnTimer_Msg (wParam,
reinterpret_cast<::TIMERPROC*
> (lParam));
3006 case WM_LBUTTONDOWN:
3007 this->OnLButtonDown_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3010 this->OnLButtonUp_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3012 case WM_LBUTTONDBLCLK:
3013 this->OnLButtonDblClk_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3016 this->OnMouseMove_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3019 this->OnVScroll_Msg (LOWORD (wParam), (
short)HIWORD (wParam), HWND (lParam));
3022 this->OnHScroll_Msg (LOWORD (wParam), (
short)HIWORD (wParam), HWND (lParam));
3024#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
3026 return this->OnMouseWheel_Msg (wParam, lParam);
3029 this->OnEnable_Msg (!!wParam);
3032 this->OnNCDestroy_Msg ();
3035 return this->DefWindowProc (message, wParam, lParam);
3037#undef MY_GET_X_LPARAM
3038#undef MY_GET_Y_LPARAM
3041 template <
typename BASE_WIN32_HELPER>
3042 LRESULT Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
3044 if (fSuperWindowProc ==
nullptr) {
3045 return inherited::DefWindowProc (message, wParam, lParam);
3048 return (*fSuperWindowProc) (this->GetValidatedHWND (), message, wParam, lParam);
3053 template <
typename BASE_CLASS>
3054 inline Led_Win32_SimpleWndProc_HelperWithSDKMessages<BASE_CLASS>::Led_Win32_SimpleWndProc_HelperWithSDKMessages ()
3058 template <
typename BASE_CLASS>
3059 LRESULT Led_Win32_SimpleWndProc_HelperWithSDKMessages<BASE_CLASS>::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
3062 if (this->HandleMessage (message, wParam, lParam, &result)) {
3066 return inherited::WndProc (message, wParam, lParam);
#define RequireNotNull(p)
#define CompileTimeFlagChecker_HEADER(NS_PREFIX, NAME, VALUE)
CompileTimeFlagChecker_HEADER () will generate a LINK ERROR if you ever compile a header with one val...
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
basic_string< SDKChar > SDKString