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 qScrollTextDuringThumbTracking
62#define qScrollTextDuringThumbTracking 1
95#ifndef qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
96#define qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug (!qTargetPlatformSDKUseswchar_t)
106 class FunnyMSPageUpDownAdjustSelectionHelper {
108 FunnyMSPageUpDownAdjustSelectionHelper ();
111 nonvirtual
void CaptureInfo (TextInteractor& ti);
112 nonvirtual
void CompleteAdjustment (TextInteractor& ti);
118 DISABLE_COMPILER_MSC_WARNING_START (4250)
124 template <typename BASE_INTERACTOR = TextInteractor>
125 class Led_Win32_Helper : public virtual BASE_INTERACTOR {
127 using inherited = BASE_INTERACTOR;
130 using UpdateMode = TextInteractor::UpdateMode;
131 using UpdateInfo = MarkerOwner::UpdateInfo;
137 virtual ~Led_Win32_Helper ();
141 virtual HWND GetHWND ()
const = 0;
144 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam);
148 virtual LRESULT OnCreate_Msg (LPCREATESTRUCT createStruct);
149 virtual void OnPaint_Msg ();
150 virtual void OnSize_Msg ();
151 virtual void OnChar_Msg (UINT nChar, LPARAM lKeyData);
152 virtual LRESULT OnUniChar_Msg (WPARAM nChar, LPARAM lParam);
153#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
154 virtual LONG OnIMEChar_Msg (WPARAM wParam, LPARAM lParam);
155 virtual LONG OnIME_COMPOSITION_Msg (WPARAM wParam, LPARAM lParam);
156 virtual LONG OnIME_ENDCOMPOSITION_Msg (WPARAM wParam, LPARAM lParam);
158 virtual void OnKeyDown_Msg (UINT nChar, LPARAM lKeyData);
159 virtual bool OnSetCursor_Msg (HWND hWnd, UINT nHitTest, UINT message);
160 virtual UINT OnGetDlgCode_Msg ();
161 virtual void OnSetFocus_Msg (HWND oldWnd);
162 virtual void OnKillFocus_Msg (HWND newWnd);
163 virtual bool OnEraseBkgnd_Msg (HDC hDC);
164 virtual void OnTimer_Msg (UINT_PTR nEventID, TIMERPROC* proc);
165 virtual void OnLButtonDown_Msg (UINT nFlags,
int x,
int y);
166 virtual void OnLButtonUp_Msg (UINT nFlags,
int x,
int y);
167 virtual void OnLButtonDblClk_Msg (UINT nFlags,
int x,
int y);
168 virtual void OnMouseMove_Msg (UINT nFlags,
int x,
int y);
169 virtual void OnVScroll_Msg (UINT nSBCode, UINT nPos, HWND hScrollBar);
170 virtual void OnHScroll_Msg (UINT nSBCode, UINT nPos, HWND hScrollBar);
171 virtual bool OnMouseWheel_Msg (WPARAM wParam, LPARAM lParam);
172 virtual void OnEnable_Msg (
bool enable);
175 short fAccumulatedWheelDelta;
178 nonvirtual TWIPS_Rect GetDefaultWindowMargins ()
const;
179 nonvirtual
void SetDefaultWindowMargins (
const TWIPS_Rect& defaultWindowMargins);
182 TWIPS_Rect fDefaultWindowMargins;
185 nonvirtual
bool GetControlArrowsScroll ()
const;
186 nonvirtual
void SetControlArrowsScroll (
bool controlArrowsScroll);
189 bool fControlArrowsScroll;
192 nonvirtual
bool GetFunnyMSPageUpDownAdjustSelectionBehavior ()
const;
193 nonvirtual
void SetFunnyMSPageUpDownAdjustSelectionBehavior (
bool funnyMSPageUpDownAdjustSelectionBehavior);
196 bool fFunnyMSPageUpDownAdjustSelectionBehavior;
198#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
200 size_t fIMECurCharIdx;
205 nonvirtual
void OnSize_ ();
211 virtual void RefreshWindowRect_ (
const Led_Rect& windowRectArea, UpdateMode updateMode)
const override;
212 virtual void UpdateWindowRect_ (
const Led_Rect& windowRectArea)
const override;
213 virtual bool QueryInputKeyStrokesPending ()
const override;
224 class TemporarilyUseTablet {
226 enum DoTextMetricsChangedCall {
227 eDoTextMetricsChangedCall,
228 eDontDoTextMetricsChangedCall
230 TemporarilyUseTablet (Led_Win32_Helper<BASE_INTERACTOR>& editor, Tablet* t, DoTextMetricsChangedCall tmChanged = eDoTextMetricsChangedCall);
231 ~TemporarilyUseTablet ();
234 Led_Win32_Helper<BASE_INTERACTOR>& fEditor;
236 DoTextMetricsChangedCall fDoTextMetricsChangedCall;
240 friend class TemporarilyUseTablet;
243 virtual Tablet* AcquireTablet ()
const override;
244 virtual void ReleaseTablet (Tablet* tablet)
const override;
247 Tablet* fUpdateTablet;
248 mutable Tablet fAllocatedTablet;
250 mutable size_t fAcquireCount;
253 virtual void WindowDrawHelper (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing);
256 virtual void EraseBackground (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
override;
260 nonvirtual
bool CheckIfDraggingBeepAndReturn ();
263 virtual void HandleTabCharacterTyped ();
266 virtual void AboutToUpdateText (
const UpdateInfo& updateInfo)
override;
267 virtual void DidUpdateText (
const UpdateInfo& updateInfo)
noexcept override;
270 nonvirtual
void DidUpdateText_ (
const UpdateInfo& updateInfo)
noexcept;
274 Led_Point fMouseTrackingLastPoint;
279#if qScrollTextDuringThumbTracking
280 bool fSBarThumbTracking;
284 nonvirtual
void OnNormalLButtonDown (UINT nFlags,
const Led_Point& at);
288 nonvirtual
void StartAutoscrollTimer ();
289 nonvirtual
void StopAutoscrollTimer ();
293 eAutoscrollingTimerEventID = 434
295 UINT_PTR fAutoScrollTimerID;
299 using ScrollBarType = TextInteractor::ScrollBarType;
300 using VHSelect = TextInteractor::VHSelect;
303 virtual void SetScrollBarType (VHSelect vh, ScrollBarType scrollBarType)
override;
306 virtual bool ShouldUpdateHScrollBar ()
const;
307 virtual bool ShouldUpdateVScrollBar ()
const;
308 virtual bool TypeAndScrollInfoSBVisible (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo)
const;
309 virtual SCROLLINFO GetHScrollInfo (UINT nMask = SIF_ALL)
const;
310 virtual void SetHScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw =
true);
311 nonvirtual
void SetHScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw =
true);
312 virtual SCROLLINFO GetVScrollInfo (UINT nMask = SIF_ALL)
const;
313 virtual void SetVScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw =
true);
314 nonvirtual
void SetVScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw =
true);
317 virtual void InvalidateScrollBarParameters ()
override;
320 nonvirtual
void InvalidateScrollBarParameters_ ();
323 virtual void InvalidateCaretState ()
override;
324 nonvirtual
void UpdateCaretState_ ();
327 virtual void UpdateScrollBars ()
override;
331 virtual bool OnCopyCommand_Before ()
override;
332 virtual void OnCopyCommand_After ()
override;
333 virtual bool OnPasteCommand_Before ()
override;
334 virtual void OnPasteCommand_After ()
override;
337 nonvirtual DWORD GetStyle ()
const;
341 nonvirtual
int GetWindowID ()
const;
344 nonvirtual HWND GetValidatedHWND ()
const;
346 DISABLE_COMPILER_MSC_WARNING_END (4250)
348 DISABLE_COMPILER_MSC_WARNING_START (4250)
356 template <typename BASECLASS>
357 class Led_Win32_Win32SDKMessageMimicHelper : public BASECLASS {
359 using inherited = BASECLASS;
362 Led_Win32_Win32SDKMessageMimicHelper ();
365 virtual bool HandleMessage (UINT message, WPARAM wParam, LPARAM lParam, LRESULT* result);
368 virtual LRESULT OnMsgGetText (WPARAM wParam, LPARAM lParam);
369 virtual LRESULT OnMsgSetText (WPARAM , LPARAM lParam);
370 virtual LRESULT OnMsgGetTextLength (WPARAM , LPARAM );
371 virtual LRESULT OnMsgGetSel (WPARAM wParam, LPARAM lParam);
372 virtual LRESULT OnMsgSetReadOnly (WPARAM wParam, LPARAM lParam);
373 virtual LRESULT OnMsgGetFirstVisibleLine (WPARAM wParam, LPARAM lParam);
374 virtual LRESULT OnMsgLineIndex (WPARAM wParam, LPARAM lParam);
375 virtual LRESULT OnMsgLineCount (WPARAM wParam, LPARAM lParam);
376 virtual LRESULT OnMsgCanUndo (WPARAM wParam, LPARAM lParam);
377 virtual LRESULT OnMsgUndo (WPARAM wParam, LPARAM lParam);
378 virtual LRESULT OnMsgEmptyUndoBuffer (WPARAM wParam, LPARAM lParam);
379 virtual LRESULT OnMsgClear (WPARAM wParam, LPARAM lParam);
380 virtual LRESULT OnMsgCut (WPARAM wParam, LPARAM lParam);
381 virtual LRESULT OnMsgCopy (WPARAM wParam, LPARAM lParam);
382 virtual LRESULT OnMsgPaste (WPARAM wParam, LPARAM lParam);
383 virtual LRESULT OnMsgLineFromChar (WPARAM wParam, LPARAM lParam);
384 virtual LRESULT OnMsgLineLength (WPARAM wParam, LPARAM lParam);
385 virtual LRESULT OnMsgLineScroll (WPARAM wParam, LPARAM lParam);
386 virtual LRESULT OnMsgReplaceSel (WPARAM wParam, LPARAM lParam);
387 virtual LRESULT OnMsgSetSel (WPARAM wParam, LPARAM lParam);
388 virtual LRESULT OnMsgScrollCaret (WPARAM wParam, LPARAM lParam);
389 virtual LRESULT OnMsgGetFont (WPARAM wParam, LPARAM lParam);
390 virtual LRESULT OnMsgSetFont (WPARAM wParam, LPARAM lParam);
393 FontObject fDefaultFontCache;
395 DISABLE_COMPILER_MSC_WARNING_END (4250)
403 class SimpleWin32WndProcHelper {
405 SimpleWin32WndProcHelper ();
408 nonvirtual HWND GetHWND ()
const;
409 nonvirtual
void SetHWND (HWND hWnd);
410 nonvirtual HWND GetValidatedHWND ()
const;
416 nonvirtual
void Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
417 HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
418 nonvirtual
void Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
419 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
422 nonvirtual
bool SubclassWindow (HWND hWnd);
423 nonvirtual
bool SubclassWindowW (HWND hWnd);
426 WNDPROC fSuperWindowProc;
429 nonvirtual LRESULT SendMessage (UINT msg, WPARAM wParam, LPARAM lParam);
432 nonvirtual
bool IsWindowRealized ()
const;
433 nonvirtual
void Assert_Window_Realized ()
const;
436 nonvirtual
void Require_Window_Realized ()
const;
439 nonvirtual
bool IsWindowUNICODE ()
const;
442 nonvirtual
bool IsWindowShown ()
const;
443 nonvirtual
void SetWindowVisible (
bool shown =
true);
446 static LRESULT CALLBACK StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
449 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam);
452 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam);
455 DISABLE_COMPILER_MSC_WARNING_START (4250)
463 template <typename BASE_WIN32_HELPER = Led_Win32_Helper<>>
464 class Led_Win32_SimpleWndProc_Helper : public BASE_WIN32_HELPER {
466 using inherited = BASE_WIN32_HELPER;
469 Led_Win32_SimpleWndProc_Helper ();
472 virtual ~Led_Win32_SimpleWndProc_Helper ();
475 nonvirtual
void Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
476 HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
477 nonvirtual
void Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
478 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance);
481 nonvirtual
void SetHWND (HWND hWnd);
488 virtual HWND GetHWND ()
const override;
491 virtual void OnNCDestroy_Msg ();
494 nonvirtual
bool SubclassWindow (HWND hWnd);
495 nonvirtual
bool ReplaceWindow (HWND hWnd);
498 virtual void HookSubclassWindow ();
501 WNDPROC fSuperWindowProc;
504 static LRESULT CALLBACK StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
507 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam);
510 virtual LRESULT DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
override;
512 DISABLE_COMPILER_MSC_WARNING_END (4250)
514 DISABLE_COMPILER_MSC_WARNING_START (4250)
520 template <typename BASE_CLASS>
521 class Led_Win32_SimpleWndProc_HelperWithSDKMessages : public Led_Win32_SimpleWndProc_Helper<Led_Win32_Win32SDKMessageMimicHelper<BASE_CLASS>> {
523 using inherited = Led_Win32_SimpleWndProc_Helper<Led_Win32_Win32SDKMessageMimicHelper<BASE_CLASS>>;
526 Led_Win32_SimpleWndProc_HelperWithSDKMessages ();
529 virtual LRESULT WndProc (UINT message, WPARAM wParam, LPARAM lParam)
override;
531 DISABLE_COMPILER_MSC_WARNING_END (4250)
538#if (_WIN32_WINNT < 0x0501)
542#define WM_UNICHAR 0x0109
544#ifndef UNICODE_NOCHAR
545#define UNICODE_NOCHAR 0xFFFF
554 struct IdleMangerLinkerSupport {
555 IdleMangerLinkerSupport ();
557 static IdleMangerLinkerSupport sIdleMangerLinkerSupport;
561 template <
typename BASE_INTERACTOR>
562 Led_Win32_Helper<BASE_INTERACTOR>::Led_Win32_Helper ()
563 : fAccumulatedWheelDelta (0)
564 , fDefaultWindowMargins ()
565 , fControlArrowsScroll (false)
566 , fFunnyMSPageUpDownAdjustSelectionBehavior (true)
567#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
570 , fUpdateTablet (nullptr)
571 , fAllocatedTablet ()
573 , fMouseTrackingLastPoint ()
575#if qScrollTextDuringThumbTracking
576 , fSBarThumbTracking (false)
578 , fAutoScrollTimerID (0)
580 fDefaultWindowMargins.top = TWIPS (2 * TWIPS::kPoint);
581 fDefaultWindowMargins.left = TWIPS (2 * TWIPS::kPoint);
582 fDefaultWindowMargins.bottom = TWIPS (2 * TWIPS::kPoint);
583 fDefaultWindowMargins.right = TWIPS (2 * TWIPS::kPoint);
585 template <
typename BASE_INTERACTOR>
586 Led_Win32_Helper<BASE_INTERACTOR>::~Led_Win32_Helper ()
588 Assert (fUpdateTablet ==
nullptr);
589 Assert (fAllocatedTablet.m_hDC ==
nullptr);
590 Assert (fAllocatedTablet.m_hAttribDC ==
nullptr);
591 Assert (fAcquireCount == 0);
592 Assert (fAutoScrollTimerID == 0);
594 template <
typename BASE_INTERACTOR>
595 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
597 return ::DefWindowProc (this->GetValidatedHWND (), message, wParam, lParam);
599 template <
typename BASE_INTERACTOR>
600 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::OnCreate_Msg (LPCREATESTRUCT createStruct)
603 if ((createStruct->style & WS_VSCROLL) and this->GetScrollBarType (TextInteractor::v) == TextInteractor::eScrollBarNever) {
604 this->SetScrollBarType (TextInteractor::v, TextInteractor::eScrollBarAlways);
606 if ((createStruct->style & WS_HSCROLL) and this->GetScrollBarType (TextInteractor::h) == TextInteractor::eScrollBarNever) {
607 this->SetScrollBarType (TextInteractor::h, TextInteractor::eScrollBarAlways);
609 return this->DefWindowProc (WM_CREATE, 0,
reinterpret_cast<LPARAM
> (createStruct));
611 template <
typename BASE_INTERACTOR>
612 void Led_Win32_Helper<BASE_INTERACTOR>::OnPaint_Msg ()
614 HWND hWnd = this->GetValidatedHWND ();
616 HDC hdc = ::BeginPaint (hWnd, &ps);
617 if (hdc !=
nullptr) {
619 Verify (::GetClipBox (hdc, &boundsRect) != ERROR);
620 Tablet tablet (hdc, Tablet::eDoesntOwnDC);
622 this->WindowDrawHelper (&tablet, AsLedRect (boundsRect),
false);
625 ::EndPaint (hWnd, &ps);
628 ::EndPaint (hWnd, &ps);
631 template <
typename BASE_INTERACTOR>
632 void Led_Win32_Helper<BASE_INTERACTOR>::OnSize_Msg ()
636 template <
typename BASE_INTERACTOR>
642 void Led_Win32_Helper<BASE_INTERACTOR>::OnChar_Msg (UINT nChar, LPARAM )
644#if !qTargetPlatformSDKUseswchar_t
646 CodePage useCodePage = Characters::Platform::Windows::Win32PrimaryLangIDToCodePage (LOWORD (::GetKeyboardLayout (
nullptr)));
649 int xx = ::MultiByteToWideChar (useCodePage, 0, &ccc, 1, &outC, 1);
656 if (nChar == VK_ESCAPE) {
661 if (this->CheckIfDraggingBeepAndReturn ()) {
666 this->HandleTabCharacterTyped ();
673 if ((nChar == 0x7f) and (::GetKeyState (VK_CONTROL) & 0x8000)) {
677 this->OnTypedNormalCharacter (
static_cast<Led_tChar
> (nChar),
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
678 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
680#if qSupportWindowsSDKCallbacks
681 HWND hWnd = this->GetValidatedHWND ();
682 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
685 template <
typename BASE_INTERACTOR>
691 LRESULT Led_Win32_Helper<BASE_INTERACTOR>::OnUniChar_Msg (WPARAM nChar, LPARAM )
693 if (nChar == UNICODE_NOCHAR) {
697 if (nChar == VK_ESCAPE) {
702 if (CheckIfDraggingBeepAndReturn ()) {
707 HandleTabCharacterTyped ();
714 if ((nChar == 0x7f) and (::GetKeyState (VK_CONTROL) & 0x8000)) {
718 this->OnTypedNormalCharacter (
static_cast<Led_tChar
> (nChar),
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
719 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
721#if qSupportWindowsSDKCallbacks
722 HWND hWnd = this->GetValidatedHWND ();
723 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
727#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
728 template <
typename BASE_INTERACTOR>
733 LONG Led_Win32_Helper<BASE_INTERACTOR>::OnIMEChar_Msg (WPARAM wParam, LPARAM lParam)
739 if (nChar == VK_ESCAPE) {
744 HandleTabCharacterTyped ();
748 if (CheckIfDraggingBeepAndReturn ()) {
756 if (qTargetPlatformSDKUseswchar_t || ::IsWindowUnicode (this->GetValidatedHWND ())) {
762#if !qTargetPlatformSDKUseswchar_t
764 wstring tmpIMEBugWorkaroundCompString = IME::Get ().GetCompositionResultStringW (this->GetValidatedHWND ());
765 if (fIMECurCharIdx < tmpIMEBugWorkaroundCompString.length ()) {
766 nChar = tmpIMEBugWorkaroundCompString[fIMECurCharIdx];
775 wchar_t convertedChars[2];
776 memset (&convertedChars, 0,
sizeof (convertedChars));
777 int nWideChars = ::MultiByteToWideChar (CP_ACP, 0,
reinterpret_cast<char*
> (&nChar), 2, convertedChars, 2);
778 wchar_t convertedChar = convertedChars[0];
779 if (nWideChars == 0) {
783 nChar = convertedChar;
788 OnTypedNormalCharacter (nChar,
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false, !!(::GetKeyState (VK_CONTROL) & 0x8000),
789 !!(::GetKeyState (VK_MENU) & 0x8000));
791#if qSupportWindowsSDKCallbacks
792 HWND hWnd = this->GetValidatedHWND ();
793 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
797 template <
typename BASE_INTERACTOR>
802 LONG Led_Win32_Helper<BASE_INTERACTOR>::OnIME_COMPOSITION_Msg (WPARAM wParam, LPARAM lParam)
805 return DefWindowProc (WM_IME_COMPOSITION, wParam, lParam);
807 template <
typename BASE_INTERACTOR>
812 LONG Led_Win32_Helper<BASE_INTERACTOR>::OnIME_ENDCOMPOSITION_Msg (WPARAM wParam, LPARAM lParam)
815 return DefWindowProc (WM_IME_ENDCOMPOSITION, wParam, lParam);
818 template <
typename BASE_INTERACTOR>
824 void Led_Win32_Helper<BASE_INTERACTOR>::OnKeyDown_Msg (UINT nChar, LPARAM )
826 bool shiftPressed = !!(::GetKeyState (VK_SHIFT) & 0x8000);
827 bool controlPressed = !!(::GetKeyState (VK_CONTROL) & 0x8000);
829 using TextInteractor::eDefaultUpdate;
830 using TextInteractor::eImmediateUpdate;
832 using TextInteractor::eCursorBack;
833 using TextInteractor::eCursorByBuffer;
834 using TextInteractor::eCursorByChar;
835 using TextInteractor::eCursorByLine;
836 using TextInteractor::eCursorByRow;
837 using TextInteractor::eCursorByWord;
838 using TextInteractor::eCursorExtendingSelection;
839 using TextInteractor::eCursorForward;
840 using TextInteractor::eCursorMoving;
841 using TextInteractor::eCursorToEnd;
842 using TextInteractor::eCursorToStart;
865 if (CheckIfDraggingBeepAndReturn ()) {
868 this->BreakInGroupedCommands ();
870 if (controlPressed) {
871 this->SetSelection (this->GetMarkerPositionOfStartOfWindow (), this->GetMarkerPositionOfStartOfWindow ());
874 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
875 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
877 selectionAdjuster.CaptureInfo (*
this);
882 this->ScrollByIfRoom (-(
int)this->GetTotalRowsInWindow ());
885 selectionAdjuster.CompleteAdjustment (*
this);
888#if qPeekForMoreCharsOnUserTyping
889 this->UpdateIfNoKeysPending ();
894 if (this->CheckIfDraggingBeepAndReturn ()) {
897 this->BreakInGroupedCommands ();
899 if (controlPressed) {
900 this->SetSelection (this->GetMarkerPositionOfEndOfWindow (), this->GetMarkerPositionOfEndOfWindow ());
903 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
904 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
906 selectionAdjuster.CaptureInfo (*
this);
909 this->ScrollByIfRoom (this->GetTotalRowsInWindow ());
912 selectionAdjuster.CompleteAdjustment (*
this);
915#if qPeekForMoreCharsOnUserTyping
916 this->UpdateIfNoKeysPending ();
921 if (this->CheckIfDraggingBeepAndReturn ()) {
924 this->BreakInGroupedCommands ();
925 this->DoSingleCharCursorEdit (eCursorToEnd, controlPressed ? eCursorByBuffer : eCursorByRow,
926 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
927 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
928#if qPeekForMoreCharsOnUserTyping
929 this->UpdateIfNoKeysPending ();
934 if (this->CheckIfDraggingBeepAndReturn ()) {
937 this->BreakInGroupedCommands ();
938 this->DoSingleCharCursorEdit (eCursorToStart, controlPressed ? eCursorByBuffer : eCursorByRow,
939 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
940 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
941#if qPeekForMoreCharsOnUserTyping
942 this->UpdateIfNoKeysPending ();
947 if (this->CheckIfDraggingBeepAndReturn ()) {
950 this->BreakInGroupedCommands ();
951 this->DoSingleCharCursorEdit (eCursorBack, controlPressed ? eCursorByWord : eCursorByChar,
952 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
953 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
954#if qPeekForMoreCharsOnUserTyping
955 this->UpdateIfNoKeysPending ();
960 if (this->CheckIfDraggingBeepAndReturn ()) {
963 this->BreakInGroupedCommands ();
964 if (controlPressed) {
965 if (this->GetControlArrowsScroll ()) {
966 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
967 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
969 selectionAdjuster.CaptureInfo (*
this);
971 this->ScrollByIfRoom (-1);
973 selectionAdjuster.CompleteAdjustment (*
this);
977 this->DoSingleCharCursorEdit (eCursorToStart, eCursorByLine, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
978 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
982 this->DoSingleCharCursorEdit (eCursorBack, eCursorByRow, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
983 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
985#if qPeekForMoreCharsOnUserTyping
986 this->UpdateIfNoKeysPending ();
991 if (this->CheckIfDraggingBeepAndReturn ()) {
994 this->BreakInGroupedCommands ();
995 this->DoSingleCharCursorEdit (eCursorForward, controlPressed ? eCursorByWord : eCursorByChar,
996 shiftPressed ? eCursorExtendingSelection : eCursorMoving,
997 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
998#if qPeekForMoreCharsOnUserTyping
999 this->UpdateIfNoKeysPending ();
1004 if (this->CheckIfDraggingBeepAndReturn ()) {
1007 this->BreakInGroupedCommands ();
1008 if (controlPressed) {
1009 if (this->GetControlArrowsScroll ()) {
1010 FunnyMSPageUpDownAdjustSelectionHelper selectionAdjuster;
1011 bool doFunny = this->GetFunnyMSPageUpDownAdjustSelectionBehavior ();
1013 selectionAdjuster.CaptureInfo (*
this);
1015 this->ScrollByIfRoom (1);
1017 selectionAdjuster.CompleteAdjustment (*
this);
1021 this->DoSingleCharCursorEdit (eCursorToEnd, eCursorByLine, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
1022 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
1026 this->DoSingleCharCursorEdit (eCursorForward, eCursorByRow, shiftPressed ? eCursorExtendingSelection : eCursorMoving,
1027 qPeekForMoreCharsOnUserTyping ? eDefaultUpdate : eImmediateUpdate);
1029#if qPeekForMoreCharsOnUserTyping
1030 this->UpdateIfNoKeysPending ();
1050 if (this->CheckIfDraggingBeepAndReturn ()) {
1054 this->BreakInGroupedCommands ();
1060 if (this->GetSelectionStart () == this->GetSelectionEnd ()) {
1066 this->SetSelection (this->GetSelectionStart (), this->FindNextCharacter (this->GetSelectionStart ()), eDefaultUpdate);
1067 this->InteractiveReplace (LED_TCHAR_OF (
""), 0);
1070 this->OnPerformCommand (TextInteractor::kClear_CmdID);
1072 this->ScrollToSelection ();
1074#if qSupportWindowsSDKCallbacks
1076 HWND hWnd = this->GetValidatedHWND ();
1077 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
1089 template <
typename BASE_INTERACTOR>
1095 bool Led_Win32_Helper<BASE_INTERACTOR>::OnSetCursor_Msg (HWND hWnd, UINT nHitTest, UINT message)
1097 if (nHitTest == HTCLIENT and hWnd == this->GetValidatedHWND ()) {
1105 BOOL result =
false;
1113 if (this->GetSelectionStart () != this->GetSelectionEnd ()) {
1115 this->GetSelectionWindowRegion (&r, this->GetSelectionStart (), this->GetSelectionEnd ());
1116 if (r.PtInRegion (AsPOINT (fMouseTrackingLastPoint))) {
1117 ::SetCursor (::LoadCursor (
nullptr, IDC_ARROW));
1122 ::SetCursor (::LoadCursor (
nullptr, IDC_IBEAM));
1127 return !!this->DefWindowProc (WM_SETCURSOR, WPARAM (hWnd), MAKELPARAM (nHitTest, message));
1130 template <
typename BASE_INTERACTOR>
1136 UINT Led_Win32_Helper<BASE_INTERACTOR>::OnGetDlgCode_Msg ()
1138 DWORD style = GetStyle ();
1139 UINT dlogCode = DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTCHARS;
1140 if ((style & ES_MULTILINE) and (style & ES_WANTRETURN)) {
1141 dlogCode |= DLGC_WANTALLKEYS;
1145 template <
typename BASE_INTERACTOR>
1150 void Led_Win32_Helper<BASE_INTERACTOR>::OnSetFocus_Msg (HWND )
1152#if qStroika_Frameworks_Led_ProvideIMESupport
1153 IME::Get ().ForgetPosition ();
1154 IME::Get ().Enable ();
1157 this->SetCaretShown (
true);
1158 this->SetSelectionShown (
true);
1160#if qSupportWindowsSDKCallbacks
1162 HWND hWnd = this->GetValidatedHWND ();
1163 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, (WPARAM)MAKELONG (GetWindowID (), EN_SETFOCUS), (LPARAM)(hWnd));
1166 template <
typename BASE_INTERACTOR>
1171 void Led_Win32_Helper<BASE_INTERACTOR>::OnKillFocus_Msg (HWND )
1173 if (this->PeekAtTextStore () ==
nullptr) {
1181 this->BreakInGroupedCommands ();
1183 this->SetCaretShown (
false);
1184 this->SetSelectionShown (
false);
1186#if qSupportWindowsSDKCallbacks
1188 HWND hWnd = this->GetValidatedHWND ();
1189 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, (WPARAM)MAKELONG (GetWindowID (), EN_KILLFOCUS), (LPARAM)(hWnd));
1192 template <
typename BASE_INTERACTOR>
1193 bool Led_Win32_Helper<BASE_INTERACTOR>::OnEraseBkgnd_Msg ([[maybe_unused]] HDC hDC)
1199 template <
typename BASE_INTERACTOR>
1200 void Led_Win32_Helper<BASE_INTERACTOR>::OnTimer_Msg (UINT_PTR nEventID, TIMERPROC* proc)
1202 HWND hWnd = this->GetValidatedHWND ();
1203 if (nEventID == eAutoscrollingTimerEventID) {
1204 if (::GetCapture () == hWnd) {
1207 this->WhileSimpleMouseTracking (fMouseTrackingLastPoint, fDragAnchor);
1210 this->StopAutoscrollTimer ();
1214 this->DefWindowProc (WM_TIMER, nEventID, LPARAM (proc));
1217 template <
typename BASE_INTERACTOR>
1218 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonDown_Msg (UINT nFlags,
int x,
int y)
1220 this->UpdateClickCount (Foundation::Time::GetTickCount (), Led_Point (y, x));
1221 this->OnNormalLButtonDown (nFlags, Led_Point (y, x));
1223 template <
typename BASE_INTERACTOR>
1224 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonUp_Msg (UINT ,
int x,
int y)
1226 HWND hWnd = this->GetValidatedHWND ();
1228 if (::GetCapture () == hWnd) {
1229 this->StopAutoscrollTimer ();
1230 Verify (::ReleaseCapture ());
1231 this->WhileSimpleMouseTracking (Led_Point (y, x), fDragAnchor);
1234 template <
typename BASE_INTERACTOR>
1235 void Led_Win32_Helper<BASE_INTERACTOR>::OnLButtonDblClk_Msg (UINT ,
int x,
int y)
1237 this->IncrementCurClickCount (Foundation::Time::GetTickCount ());
1239 bool extendSelection = !!(::GetKeyState (VK_SHIFT) & 0x8000);
1240 if (not this->ProcessSimpleClick (Led_Point (y, x), this->GetCurClickCount (), extendSelection, &fDragAnchor)) {
1244 HWND hWnd = this->GetValidatedHWND ();
1245 (void)::SetCapture (hWnd);
1248 this->StartAutoscrollTimer ();
1250 template <
typename BASE_INTERACTOR>
1251 void Led_Win32_Helper<BASE_INTERACTOR>::OnMouseMove_Msg (UINT ,
int x,
int y)
1253 HWND hWnd = this->GetValidatedHWND ();
1254 fMouseTrackingLastPoint = Led_Point (y, x);
1255 if (::GetCapture () == hWnd) {
1256 this->WhileSimpleMouseTracking (Led_Point (y, x), fDragAnchor);
1259 template <
typename BASE_INTERACTOR>
1260 void Led_Win32_Helper<BASE_INTERACTOR>::OnVScroll_Msg (UINT nSBCode, UINT , HWND )
1262 using namespace Characters::Literals;
1263 DbgTrace (
"Led_Win32_Helper<BASE_INTERACTOR>::OnVScroll_Msg (nSBCode={},...)"_f, nSBCode);
1265 using TextInteractor::eDefaultUpdate;
1266 using TextInteractor::eImmediateUpdate;
1272 if (nSBCode == SB_LINEDOWN or nSBCode == SB_LINEUP or nSBCode == SB_PAGEDOWN or nSBCode == SB_PAGEUP) {
1273 if (not this->DelaySomeForScrollBarClick ()) {
1278#if qDynamiclyChooseAutoScrollIncrement
1279 Foundation::Time::TimePointSeconds now = Foundation::Time::GetTickCount ();
1280 static Foundation::Time::TimePointSeconds sLastTimeThrough{};
1281 const Foundation::Time::DurationSeconds kClickThreshold = Led_GetDoubleClickTime () / 3;
1282 bool firstClick = (now - sLastTimeThrough > kClickThreshold);
1284 int increment = firstClick ? 1 : 2;
1286 const int increment = 1;
1289#if qScrollTextDuringThumbTracking
1290 fSBarThumbTracking = (nSBCode == SB_THUMBTRACK);
1294 this->ScrollSoShowing (this->GetLength ());
1297 case SB_ENDSCROLL: {
1302 this->ScrollByIfRoom (increment, eImmediateUpdate);
1306 this->ScrollByIfRoom (-increment, eImmediateUpdate);
1310 this->ScrollByIfRoom (this->GetTotalRowsInWindow ());
1314 this->ScrollByIfRoom (-(
int)this->GetTotalRowsInWindow ());
1318#if qScrollTextDuringThumbTracking
1323 case SB_THUMBPOSITION: {
1332 SCROLLINFO scrollInfo = this->GetVScrollInfo ();
1333#if qScrollTextDuringThumbTracking
1334 newPos = scrollInfo.nTrackPos;
1336 newPos = scrollInfo.nPos;
1338 newPos = min (newPos, this->GetLength ());
1344 if (newPos + scrollInfo.nPage >=
static_cast<UINT
> (scrollInfo.nMax)) {
1345 newPos = this->GetLength ();
1348#if qScrollTextDuringThumbTracking
1350 scrollInfo.cbSize =
sizeof (scrollInfo);
1351 scrollInfo.fMask = SIF_POS;
1352 scrollInfo.nPos =
static_cast<UINT
> (newPos);
1353 SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo);
1357#if qScrollTextDuringThumbTracking
1358 this->InvalidateScrollBarParameters ();
1362 this->SetTopRowInWindowByMarkerPosition (newPos);
1366 this->ScrollSoShowing (0);
1375#if qDynamiclyChooseAutoScrollIncrement
1376 sLastTimeThrough = now;
1379 template <
typename BASE_INTERACTOR>
1380 void Led_Win32_Helper<BASE_INTERACTOR>::OnHScroll_Msg (UINT nSBCode, UINT , HWND )
1386 if (nSBCode == SB_LINEDOWN or nSBCode == SB_LINEUP or nSBCode == SB_PAGEDOWN or nSBCode == SB_PAGEUP) {
1387 if (not this->DelaySomeForScrollBarClick ()) {
1392#if qDynamiclyChooseAutoScrollIncrement
1393 Foundation::Time::TimePointSeconds now = Foundation::Time::GetTickCount ();
1394 static Foundation::Time::TimePointSeconds sLastTimeThrough{};
1395 const Foundation::Time::DurationSeconds kClickThreshold = Led_GetDoubleClickTime ();
1396 bool firstClick = (now - sLastTimeThrough > kClickThreshold);
1398 int increment = firstClick ? 1 : 10;
1400 const int increment = 1;
1405 this->SetHScrollPos (this->ComputeMaxHScrollPos ());
1408 case SB_ENDSCROLL: {
1413 this->SetHScrollPos (min<CoordinateType> (this->GetHScrollPos () + increment, this->ComputeMaxHScrollPos ()));
1417 if (this->GetHScrollPos () > 0) {
1418 this->SetHScrollPos (max<CoordinateType> (0,
int (this->GetHScrollPos ()) - increment));
1423 const CoordinateType kPixelsAtATime = this->GetWindowRect ().GetWidth () / 2;
1424 this->SetHScrollPos (min<CoordinateType> (this->GetHScrollPos () + kPixelsAtATime, this->ComputeMaxHScrollPos ()));
1428 const CoordinateType kPixelsAtATime = this->GetWindowRect ().GetWidth () / 2;
1429 if (this->GetHScrollPos () > kPixelsAtATime) {
1430 this->SetHScrollPos (this->GetHScrollPos () - kPixelsAtATime);
1433 this->SetHScrollPos (0);
1438#if qScrollTextDuringThumbTracking
1443 case SB_THUMBPOSITION: {
1444#if qScrollTextDuringThumbTracking
1445 fSBarThumbTracking = (nSBCode == SB_THUMBTRACK);
1453 SCROLLINFO scrollInfo = this->GetHScrollInfo ();
1454#if qScrollTextDuringThumbTracking
1455 size_t newPos = scrollInfo.nTrackPos;
1457 size_t newPos = scrollInfo.nPos;
1460#if qScrollTextDuringThumbTracking
1462 scrollInfo.cbSize =
sizeof (scrollInfo);
1463 scrollInfo.fMask = SIF_POS;
1464 scrollInfo.nPos =
static_cast<int> (newPos);
1465 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo);
1468#if qScrollTextDuringThumbTracking
1469 this->InvalidateScrollBarParameters ();
1473 this->SetHScrollPos (min<CoordinateType> (
static_cast<CoordinateType
> (newPos), this->ComputeMaxHScrollPos ()));
1477 this->SetHScrollPos (0);
1486#if qDynamiclyChooseAutoScrollIncrement
1487 sLastTimeThrough = now;
1490 template <
typename BASE_INTERACTOR>
1491 bool Led_Win32_Helper<BASE_INTERACTOR>::OnMouseWheel_Msg (WPARAM wParam, LPARAM lParam)
1493 using TextInteractor::eImmediateUpdate;
1494#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
1495 UINT keyState = LOWORD (wParam);
1498 if (keyState & (MK_SHIFT | MK_CONTROL)) {
1499 return !!this->DefWindowProc (WM_MOUSEWHEEL, wParam, lParam);
1502 short zDelta = (short)HIWORD (wParam);
1503 if ((zDelta >= 0) != (fAccumulatedWheelDelta >= 0)) {
1504 fAccumulatedWheelDelta = 0;
1506 fAccumulatedWheelDelta += zDelta;
1508 int nTicks = fAccumulatedWheelDelta / WHEEL_DELTA;
1510 fAccumulatedWheelDelta %= WHEEL_DELTA;
1512 int scrollLines = 3;
1513 Verify (::SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0));
1517 int totalRowsInWindow =
static_cast<int> (this->GetTotalRowsInWindow ());
1518 scrollLines = min (scrollLines, totalRowsInWindow);
1520 this->ScrollByIfRoom (-nTicks * scrollLines, eImmediateUpdate);
1524 template <
typename BASE_INTERACTOR>
1530 inline TWIPS_Rect Led_Win32_Helper<BASE_INTERACTOR>::GetDefaultWindowMargins ()
const
1532 return fDefaultWindowMargins;
1534 template <
typename BASE_INTERACTOR>
1546 void Led_Win32_Helper<BASE_INTERACTOR>::SetDefaultWindowMargins (
const TWIPS_Rect& defaultWindowMargins)
1548 if (fDefaultWindowMargins != defaultWindowMargins) {
1549 fDefaultWindowMargins = defaultWindowMargins;
1550 if (this->GetHWND () !=
nullptr) {
1555 template <
typename BASE_INTERACTOR>
1560 inline bool Led_Win32_Helper<BASE_INTERACTOR>::GetControlArrowsScroll ()
const
1562 return fControlArrowsScroll;
1564 template <
typename BASE_INTERACTOR>
1573 void Led_Win32_Helper<BASE_INTERACTOR>::SetControlArrowsScroll (
bool controlArrowsScroll)
1575 fControlArrowsScroll = controlArrowsScroll;
1577 template <
typename BASE_INTERACTOR>
1582 inline bool Led_Win32_Helper<BASE_INTERACTOR>::GetFunnyMSPageUpDownAdjustSelectionBehavior ()
const
1584 return fFunnyMSPageUpDownAdjustSelectionBehavior;
1586 template <
typename BASE_INTERACTOR>
1599 void Led_Win32_Helper<BASE_INTERACTOR>::SetFunnyMSPageUpDownAdjustSelectionBehavior (
bool funnyMSPageUpDownAdjustSelectionBehavior)
1601 fFunnyMSPageUpDownAdjustSelectionBehavior = funnyMSPageUpDownAdjustSelectionBehavior;
1603 template <
typename BASE_INTERACTOR>
1604 void Led_Win32_Helper<BASE_INTERACTOR>::OnEnable_Msg (
bool )
1608 template <
typename BASE_INTERACTOR>
1609 void Led_Win32_Helper<BASE_INTERACTOR>::OnSize_ ()
1611 using namespace Characters::Literals;
1612 this->InvalidateScrollBarParameters ();
1616 HWND hWnd = this->GetValidatedHWND ();
1617 Verify (::GetClientRect (hWnd, &cr));
1621 TextInteractor::Tablet_Acquirer tablet (
this);
1622 Led_Rect wmr = tablet->CvtFromTWIPS (GetDefaultWindowMargins ());
1623 r.top += wmr.GetTop ();
1624 r.left += wmr.GetLeft ();
1625 r.bottom -= wmr.GetBottom ();
1626 r.right -= wmr.GetRight ();
1632 if (r.top >= r.bottom) {
1633 r.bottom = r.top + 1;
1635 if (r.left >= r.right) {
1636 r.right = r.left + 1;
1638 DbgTrace (
"Led_Win32_Helper<>::OnSize_ (clientRect=(%d,%d,%d,%d), windowRect <= (%d,%d,%d,%d))"_f, cr.top, cr.left, cr.bottom,
1639 cr.right, r.top, r.left, r.bottom, r.right);
1640 this->SetWindowRect (r);
1642 template <
typename BASE_INTERACTOR>
1643 void Led_Win32_Helper<BASE_INTERACTOR>::RefreshWindowRect_ (
const Led_Rect& windowRectArea, UpdateMode updateMode)
const
1645 HWND hWnd = GetHWND ();
1646 if (hWnd !=
nullptr) {
1647 Assert (::IsWindow (hWnd));
1648 updateMode = this->RealUpdateMode (updateMode);
1649 switch (updateMode) {
1650 case TextInteractor::eDelayedUpdate: {
1651 if (not windowRectArea.IsEmpty ()) {
1652 RECT tmp = AsRECT (windowRectArea);
1653 Verify (::InvalidateRect (hWnd, &tmp,
true));
1656 case TextInteractor::eImmediateUpdate: {
1657 if (not windowRectArea.IsEmpty ()) {
1658 RECT tmp = AsRECT (windowRectArea);
1659 Verify (::RedrawWindow (hWnd, &tmp,
nullptr, RDW_INVALIDATE | RDW_UPDATENOW));
1665 template <
typename BASE_INTERACTOR>
1666 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateWindowRect_ (
const Led_Rect& windowRectArea)
const
1668 if (not windowRectArea.IsEmpty ()) {
1670 RECT tmp = AsRECT (windowRectArea);
1671 HWND hWnd = GetHWND ();
1672 if (hWnd !=
nullptr) {
1673 Assert (::IsWindow (hWnd));
1674 Verify (::RedrawWindow (hWnd, &tmp,
nullptr, RDW_UPDATENOW));
1678 template <
typename BASE_INTERACTOR>
1679 bool Led_Win32_Helper<BASE_INTERACTOR>::QueryInputKeyStrokesPending ()
const
1682 return (!!::PeekMessage (&msg, GetValidatedHWND (), WM_KEYDOWN, WM_KEYDOWN, PM_NOREMOVE));
1684 template <
typename BASE_INTERACTOR>
1685 Tablet* Led_Win32_Helper<BASE_INTERACTOR>::AcquireTablet ()
const
1687 Require (fAcquireCount < 100);
1689 if (fUpdateTablet !=
nullptr) {
1691 return fUpdateTablet;
1699 if (fAcquireCount == 0) {
1700 Assert (fAllocatedTablet.m_hDC ==
nullptr);
1701 Assert (fAllocatedTablet.m_hAttribDC ==
nullptr);
1702 HWND hWnd = GetHWND ();
1703 if (hWnd ==
nullptr) {
1704 throw TextInteractor::NoTabletAvailable ();
1706 Assert (::IsWindow (hWnd));
1707 HDC hdc = ::GetWindowDC (hWnd);
1709 Verify (fAllocatedTablet.Attach (hdc));
1711 Assert (fAllocatedTablet.m_hDC !=
nullptr);
1712 Assert (fAllocatedTablet.m_hAttribDC !=
nullptr);
1714 return (&fAllocatedTablet);
1716 template <
typename BASE_INTERACTOR>
1717 void Led_Win32_Helper<BASE_INTERACTOR>::ReleaseTablet (Tablet* tablet)
const
1720 Assert (fAcquireCount > 0);
1722 Assert (tablet == fUpdateTablet or tablet == &fAllocatedTablet);
1723 if (fAcquireCount == 0 and tablet == &fAllocatedTablet) {
1724 Verify (::ReleaseDC (GetValidatedHWND (), fAllocatedTablet.Detach ()));
1727 template <
typename BASE_INTERACTOR>
1733 void Led_Win32_Helper<BASE_INTERACTOR>::WindowDrawHelper (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
1735 using namespace Characters::Literals;
1736 DbgTrace (
"Led_Win32_Helper<>::WindowDrawHelper (subsetToDraw= (%d, %d, %d, %d))"_f, subsetToDraw.top, subsetToDraw.left,
1737 subsetToDraw.bottom, subsetToDraw.right);
1738 TemporarilyUseTablet tmpUseTablet{*
this, tablet, TemporarilyUseTablet::eDontDoTextMetricsChangedCall};
1739 this->Draw (subsetToDraw, printing);
1745 Led_Rect wr = this->GetWindowRect ();
1746 TWIPS_Rect wm = this->GetDefaultWindowMargins ();
1747 if (wm.GetTop () != 0 or wm.GetLeft () != 0 or wm.GetBottom () != 0 or wm.GetRight () != 0) {
1748 Led_Rect wmr = tablet->CvtFromTWIPS (wm);
1751 Led_Rect barRect = subsetToDraw;
1752 barRect.bottom = wr.top;
1753 if (not barRect.IsEmpty ()) {
1754 this->EraseBackground (tablet, barRect,
false);
1759 Led_Rect barRect = subsetToDraw;
1760 barRect.right = wr.left;
1761 if (not barRect.IsEmpty ()) {
1762 this->EraseBackground (tablet, barRect,
false);
1767 Led_Rect barRect = subsetToDraw;
1768 barRect.top = wr.bottom;
1769 if (not barRect.IsEmpty ()) {
1770 this->EraseBackground (tablet, barRect,
false);
1775 Led_Rect barRect = subsetToDraw;
1776 barRect.left = wr.right;
1777 if (not barRect.IsEmpty ()) {
1778 this->EraseBackground (tablet, barRect,
false);
1783 this->UpdateCaretState_ ();
1785 template <
typename BASE_INTERACTOR>
1790 void Led_Win32_Helper<BASE_INTERACTOR>::EraseBackground (Tablet* tablet,
const Led_Rect& subsetToDraw,
bool printing)
1792 DWORD dwStyle = GetStyle ();
1793 if (((dwStyle & WS_DISABLED) or (dwStyle & ES_READONLY)) and (not printing)) {
1796 const Color kReadOnlyBackground = Color (::GetSysColor (COLOR_BTNFACE));
1797 tablet->EraseBackground_SolidHelper (subsetToDraw, kReadOnlyBackground);
1800 inherited::EraseBackground (tablet, subsetToDraw, printing);
1803 template <
typename BASE_INTERACTOR>
1804 bool Led_Win32_Helper<BASE_INTERACTOR>::CheckIfDraggingBeepAndReturn ()
1806 HWND hWnd = GetHWND ();
1807 if (hWnd !=
nullptr and ::GetCapture () == hWnd) {
1820 template <
typename BASE_INTERACTOR>
1829 void Led_Win32_Helper<BASE_INTERACTOR>::HandleTabCharacterTyped ()
1831 HWND hWnd = this->GetValidatedHWND ();
1832 if (this->GetStyle () & WS_TABSTOP) {
1833 HWND parent = ::GetParent (hWnd);
1834 if (parent !=
nullptr) {
1835 bool shiftPressed = !!(::GetKeyState (VK_SHIFT) & 0x8000);
1837 ::PostMessage (parent, WM_NEXTDLGCTL, 1,
false);
1840 ::PostMessage (parent, WM_NEXTDLGCTL, 0,
false);
1845 this->OnTypedNormalCharacter (
'\t',
false, !!(::GetKeyState (VK_SHIFT) & 0x8000),
false,
1846 !!(::GetKeyState (VK_CONTROL) & 0x8000), !!(::GetKeyState (VK_MENU) & 0x8000));
1847#if qSupportWindowsSDKCallbacks
1848 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_CHANGE), (LPARAM)hWnd);
1852 template <
typename BASE_INTERACTOR>
1857 void Led_Win32_Helper<BASE_INTERACTOR>::AboutToUpdateText (
const UpdateInfo& updateInfo)
1859 if (GetHWND () !=
nullptr and this->CheckIfCurrentUpdateIsInteractive () and updateInfo.fRealContentUpdate) {
1863 DWORD dwStyle = this->GetStyle ();
1864 if (dwStyle & WS_DISABLED || dwStyle & ES_READONLY) {
1865 this->OnBadUserInput ();
1868 inherited::AboutToUpdateText (updateInfo);
1870 template <
typename BASE_INTERACTOR>
1875 void Led_Win32_Helper<BASE_INTERACTOR>::DidUpdateText (
const UpdateInfo& updateInfo)
noexcept
1877 inherited::DidUpdateText (updateInfo);
1878 this->DidUpdateText_ (updateInfo);
1880 template <
typename BASE_INTERACTOR>
1886 inline void Led_Win32_Helper<BASE_INTERACTOR>::DidUpdateText_ (
const UpdateInfo& updateInfo)
noexcept
1888 if (updateInfo.fTextModified) {
1889 this->SetCurClickCount (0, Foundation::Time::GetTickCount ());
1891 fDragAnchor = min (fDragAnchor, this->GetEnd ());
1894 template <
typename BASE_INTERACTOR>
1895 void Led_Win32_Helper<BASE_INTERACTOR>::SetScrollBarType (VHSelect vh, ScrollBarType scrollBarType)
1897 if (this->GetScrollBarType (vh) != scrollBarType) {
1898 inherited::SetScrollBarType (vh, scrollBarType);
1899 HWND hWnd = this->GetHWND ();
1900 if (hWnd !=
nullptr) {
1901 ::InvalidateRect (hWnd,
nullptr,
true);
1905 template <
typename BASE_INTERACTOR>
1913 bool Led_Win32_Helper<BASE_INTERACTOR>::ShouldUpdateHScrollBar ()
const
1916 return this->GetScrollBarType (TextInteractor::h) != TextInteractor::eScrollBarNever or (this->GetStyle () & WS_HSCROLL);
1918 template <
typename BASE_INTERACTOR>
1923 bool Led_Win32_Helper<BASE_INTERACTOR>::ShouldUpdateVScrollBar ()
const
1926 return this->GetScrollBarType (TextInteractor::v) != TextInteractor::eScrollBarNever or (GetStyle () & WS_VSCROLL);
1928 template <
typename BASE_INTERACTOR>
1935 bool Led_Win32_Helper<BASE_INTERACTOR>::TypeAndScrollInfoSBVisible (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo)
const
1937 return (scrollbarAppears == TextInteractor::eScrollBarAlways) or
1938 (scrollbarAppears == TextInteractor::eScrollBarAsNeeded and
1939 scrollInfo.nMin +
static_cast<int> (scrollInfo.nPage) <= scrollInfo.nMax);
1941 template <
typename BASE_INTERACTOR>
1951 SCROLLINFO Led_Win32_Helper<BASE_INTERACTOR>::GetHScrollInfo (UINT nMask)
const
1953 ::SCROLLINFO scrollInfo{};
1954 scrollInfo.cbSize =
sizeof (scrollInfo);
1955 scrollInfo.fMask = nMask;
1956 Verify (::GetScrollInfo (this->GetValidatedHWND (), SB_HORZ, &scrollInfo));
1959 template <
typename BASE_INTERACTOR>
1964 void Led_Win32_Helper<BASE_INTERACTOR>::SetHScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw)
1966 using namespace Characters::Literals;
1967 bool showBar = TypeAndScrollInfoSBVisible (scrollbarAppears, scrollInfo);
1969 DbgTrace (
"Led_Win32_Helper<>::SetHScrollInfo (scrollbarAppears={}, smin={}, smax={}, nPage={}, nPos={}) ==> showBar={})"_f,
1970 static_cast<int> (scrollbarAppears), scrollInfo.nMin, scrollInfo.nMax, scrollInfo.nPage, scrollInfo.nPos, showBar);
1977 ::ShowScrollBar (this->GetValidatedHWND (), SB_HORZ, showBar);
1978 SCROLLINFO si = scrollInfo;
1980 si.fMask |= SIF_DISABLENOSCROLL;
1983 si.fMask &= ~SIF_DISABLENOSCROLL;
1985 (void)::SetScrollInfo (this->GetValidatedHWND (), SB_HORZ, &si, redraw);
1987 template <
typename BASE_INTERACTOR>
1988 void Led_Win32_Helper<BASE_INTERACTOR>::SetHScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw)
1990 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo, redraw);
1992 template <
typename BASE_INTERACTOR>
1997 SCROLLINFO Led_Win32_Helper<BASE_INTERACTOR>::GetVScrollInfo (UINT nMask)
const
1999 ::SCROLLINFO scrollInfo{};
2000 scrollInfo.cbSize =
sizeof (scrollInfo);
2001 scrollInfo.fMask = nMask;
2002 Verify (::GetScrollInfo (this->GetValidatedHWND (), SB_VERT, &scrollInfo));
2005 template <
typename BASE_INTERACTOR>
2010 void Led_Win32_Helper<BASE_INTERACTOR>::SetVScrollInfo (ScrollBarType scrollbarAppears,
const SCROLLINFO& scrollInfo,
bool redraw)
2012 using namespace Characters::Literals;
2013 bool showBar = TypeAndScrollInfoSBVisible (scrollbarAppears, scrollInfo);
2014 DbgTrace (
"Led_Win32_Helper<>::SetVScrollInfo (scrollbarAppears={}, smin={}, smax={}, nPage={}, nPos={}) ==> showBar={})"_f,
2015 static_cast<int> (scrollbarAppears), scrollInfo.nMin, scrollInfo.nMax, scrollInfo.nPage, scrollInfo.nPos, showBar);
2022 ::ShowScrollBar (this->GetValidatedHWND (), SB_VERT, showBar);
2023 SCROLLINFO si = scrollInfo;
2025 si.fMask |= SIF_DISABLENOSCROLL;
2028 si.fMask &= ~SIF_DISABLENOSCROLL;
2030 (void)::SetScrollInfo (this->GetValidatedHWND (), SB_VERT, &si, redraw);
2032 template <
typename BASE_INTERACTOR>
2033 void Led_Win32_Helper<BASE_INTERACTOR>::SetVScrollInfo (
const SCROLLINFO& scrollInfo,
bool redraw)
2035 this->SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo, redraw);
2037 template <
typename BASE_INTERACTOR>
2038 void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateScrollBarParameters ()
2040 HWND hWnd = this->GetHWND ();
2041 if (hWnd !=
nullptr) {
2042 Assert (::IsWindow (hWnd));
2043 inherited::InvalidateScrollBarParameters_ ();
2044 this->InvalidateScrollBarParameters_ ();
2047 template <
typename BASE_INTERACTOR>
2048 inline void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateScrollBarParameters_ ()
2050 this->InvalidateCaretState ();
2052 template <
typename BASE_INTERACTOR>
2053 void Led_Win32_Helper<BASE_INTERACTOR>::InvalidateCaretState ()
2065 HWND hWnd = this->GetHWND ();
2066 if (hWnd !=
nullptr) {
2067 Assert (::IsWindow (hWnd));
2070 inherited::InvalidateCaretState ();
2072 template <
typename BASE_INTERACTOR>
2073 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateCaretState_ ()
2075 HWND hWnd = this->GetHWND ();
2076 if (hWnd !=
nullptr) {
2077 if (this->GetCaretShown () and this->GetCaretShownSituation () and ::GetFocus () == hWnd) {
2082 Led_Rect caretRect = this->CalculateCaretRect ();
2084 if (caretRect.IsEmpty ()) {
2085#if qStroika_Frameworks_Led_ProvideIMESupport
2088 Led_Rect wr = this->GetWindowRect ();
2089 IME::Get ().NotifyPosition (hWnd, (SHORT)wr.GetLeft (), (SHORT)wr.GetBottom () + 1000);
2098 ::CreateCaret (hWnd, (HBITMAP)0, caretRect.GetWidth (), caretRect.GetHeight ());
2107 Assert (::IsWindow (hWnd));
2110 while (not::ShowCaret (hWnd)) {
2113 ::SetCaretPos (caretRect.GetLeft (), caretRect.GetTop ());
2116#if qStroika_Frameworks_Led_ProvideIMESupport
2117 IME::Get ().NotifyPosition (hWnd, (SHORT)caretRect.GetLeft (), (SHORT)caretRect.GetTop ());
2126 template <
typename BASE_INTERACTOR>
2132 void Led_Win32_Helper<BASE_INTERACTOR>::UpdateScrollBars ()
2134 using namespace Characters::Literals;
2135 DbgTrace (
"Led_Win32_Helper<>::UpdateScrollBars () with winStart={}, winEnd={})"_f, this->GetMarkerPositionOfStartOfWindow (),
2136 this->GetMarkerPositionOfEndOfWindow ());
2146#if qScrollTextDuringThumbTracking
2147 if (fSBarThumbTracking) {
2152 inherited::UpdateScrollBars_ ();
2154 HWND hWnd = this->GetHWND ();
2155 if (hWnd !=
nullptr) {
2157#if qSupportWindowsSDKCallbacks
2158 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (GetWindowID (), EN_VSCROLL), (LPARAM)hWnd);
2161 if (this->ShouldUpdateHScrollBar ()) {
2162 ::SCROLLINFO scrollInfo;
2163 (void)::memset (&scrollInfo, 0,
sizeof (scrollInfo));
2164 scrollInfo.cbSize =
sizeof (scrollInfo);
2165 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
2167 scrollInfo.nMin = 0;
2168 scrollInfo.nPage = this->GetWindowRect ().GetWidth ();
2169 scrollInfo.nMax = scrollInfo.nPage + this->ComputeMaxHScrollPos ();
2170 scrollInfo.nPos = this->GetHScrollPos ();
2177 this->SetHScrollInfo (this->GetScrollBarType (TextInteractor::h), scrollInfo);
2179 if (this->ShouldUpdateVScrollBar ()) {
2180 size_t startOfWindow = this->GetMarkerPositionOfStartOfWindow ();
2181 size_t endOfWindow = this->GetMarkerPositionOfEndOfWindow ();
2182 size_t verticalWindowSpan = endOfWindow - startOfWindow;
2184 ::SCROLLINFO scrollInfo;
2185 (void)::memset (&scrollInfo, 0,
sizeof (scrollInfo));
2186 scrollInfo.cbSize =
sizeof (scrollInfo);
2187 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
2189 scrollInfo.nMin = 0;
2190 scrollInfo.nMax =
static_cast<int> (this->GetLength ());
2191 scrollInfo.nPage =
static_cast<UINT
> (verticalWindowSpan);
2192 scrollInfo.nPos =
static_cast<int> (startOfWindow);
2199 this->SetVScrollInfo (this->GetScrollBarType (TextInteractor::v), scrollInfo);
2203 template <
typename BASE_INTERACTOR>
2204 void Led_Win32_Helper<BASE_INTERACTOR>::OnNormalLButtonDown (UINT ,
const Led_Point& at)
2206 this->BreakInGroupedCommands ();
2207 fMouseTrackingLastPoint = at;
2208 if (not(this->GetStyle () & WS_DISABLED)) {
2209 HWND hWnd = this->GetValidatedHWND ();
2211 if (::GetFocus () != hWnd) {
2212 (void)::SetFocus (hWnd);
2215 bool extendSelection = !!(::GetKeyState (VK_SHIFT) & 0x8000);
2217 if (not this->ProcessSimpleClick (at, this->GetCurClickCount (), extendSelection, &fDragAnchor)) {
2231 (void)::SetCapture (hWnd);
2234 this->StartAutoscrollTimer ();
2236 Assert (fDragAnchor <= this->GetEnd ());
2243 template <
typename BASE_INTERACTOR>
2244 void Led_Win32_Helper<BASE_INTERACTOR>::StartAutoscrollTimer ()
2249 Assert (fAutoScrollTimerID == 0);
2251 if (fAutoScrollTimerID == 0) {
2252 const int kTimeout = 20;
2254 Verify ((fAutoScrollTimerID = ::SetTimer (this->GetValidatedHWND (), eAutoscrollingTimerEventID, kTimeout,
nullptr)) != 0);
2257 template <
typename BASE_INTERACTOR>
2258 void Led_Win32_Helper<BASE_INTERACTOR>::StopAutoscrollTimer ()
2260 if (fAutoScrollTimerID != 0) {
2261 Verify (::KillTimer (this->GetValidatedHWND (), eAutoscrollingTimerEventID));
2262 fAutoScrollTimerID = 0;
2265 template <
typename BASE_INTERACTOR>
2266 bool Led_Win32_Helper<BASE_INTERACTOR>::OnCopyCommand_Before ()
2268 if (not::OpenClipboard (this->GetValidatedHWND ())) {
2269 this->OnBadUserInput ();
2272 (void)::EmptyClipboard ();
2273 bool result = inherited::OnCopyCommand_Before ();
2275 Verify (::CloseClipboard ());
2280 template <
typename BASE_INTERACTOR>
2281 void Led_Win32_Helper<BASE_INTERACTOR>::OnCopyCommand_After ()
2283 inherited::OnCopyCommand_After ();
2284 if (not::CloseClipboard ()) {
2285 this->OnBadUserInput ();
2288 template <
typename BASE_INTERACTOR>
2289 bool Led_Win32_Helper<BASE_INTERACTOR>::OnPasteCommand_Before ()
2291 if (not::OpenClipboard (this->GetValidatedHWND ())) {
2292 this->OnBadUserInput ();
2295 bool result = inherited::OnPasteCommand_Before ();
2297 Verify (::CloseClipboard ());
2302 template <
typename BASE_INTERACTOR>
2303 void Led_Win32_Helper<BASE_INTERACTOR>::OnPasteCommand_After ()
2305 inherited::OnPasteCommand_After ();
2306 if (not::CloseClipboard ()) {
2307 this->OnBadUserInput ();
2310 template <
typename BASE_INTERACTOR>
2316 nonvirtual DWORD Led_Win32_Helper<BASE_INTERACTOR>::GetStyle ()
const
2318 HWND hWnd = GetHWND ();
2319 if (hWnd ==
nullptr) {
2323 Assert (::IsWindow (hWnd));
2324 return (DWORD)::GetWindowLong (hWnd, GWL_STYLE);
2327 template <
typename BASE_INTERACTOR>
2328 inline int Led_Win32_Helper<BASE_INTERACTOR>::GetWindowID ()
const
2330 return (::GetWindowLong (this->GetValidatedHWND (), GWL_ID));
2332 template <
typename BASE_INTERACTOR>
2333 inline HWND Led_Win32_Helper<BASE_INTERACTOR>::GetValidatedHWND ()
const
2335 HWND hWnd = GetHWND ();
2337 Assert (::IsWindow (hWnd));
2342#if !qNestedClassesInTemplateClassesDontExpandCompilerBug
2343 template <
typename BASE_INTERACTOR>
2344 inline Led_Win32_Helper<BASE_INTERACTOR>::TemporarilyUseTablet::TemporarilyUseTablet (Led_Win32_Helper<BASE_INTERACTOR>& editor,
2345 Tablet* t, DoTextMetricsChangedCall tmChanged)
2347 , fOldTablet{editor.fUpdateTablet}
2348 , fDoTextMetricsChangedCall{tmChanged}
2350 editor.fUpdateTablet = t;
2351 if (tmChanged == eDoTextMetricsChangedCall) {
2352 editor.TabletChangedMetrics ();
2355 template <
typename BASE_INTERACTOR>
2356 inline Led_Win32_Helper<BASE_INTERACTOR>::TemporarilyUseTablet::~TemporarilyUseTablet ()
2358 fEditor.fUpdateTablet = fOldTablet;
2359 if (fDoTextMetricsChangedCall == eDoTextMetricsChangedCall) {
2360 fEditor.TabletChangedMetrics ();
2366 template <
typename BASECLASS>
2367 Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::Led_Win32_Win32SDKMessageMimicHelper ()
2371 template <
typename BASECLASS>
2377 bool Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::HandleMessage (UINT message, WPARAM wParam, LPARAM lParam, LRESULT* result)
2382 *result = this->OnMsgSetText (wParam, lParam);
2385 *result = this->OnMsgGetText (wParam, lParam);
2387 case WM_GETTEXTLENGTH:
2388 *result = this->OnMsgGetTextLength (wParam, lParam);
2391 *result = this->OnMsgGetSel (wParam, lParam);
2393 case EM_SETREADONLY:
2394 *result = this->OnMsgSetReadOnly (wParam, lParam);
2396 case EM_GETFIRSTVISIBLELINE:
2397 *result = this->OnMsgGetFirstVisibleLine (wParam, lParam);
2400 *result = this->OnMsgLineIndex (wParam, lParam);
2402 case EM_GETLINECOUNT:
2403 *result = this->OnMsgLineCount (wParam, lParam);
2406 *result = this->OnMsgCanUndo (wParam, lParam);
2409 *result = this->OnMsgUndo (wParam, lParam);
2411 case EM_EMPTYUNDOBUFFER:
2412 *result = this->OnMsgEmptyUndoBuffer (wParam, lParam);
2415 *result = this->OnMsgClear (wParam, lParam);
2418 *result = this->OnMsgCut (wParam, lParam);
2421 *result = this->OnMsgCopy (wParam, lParam);
2424 *result = this->OnMsgPaste (wParam, lParam);
2426 case EM_LINEFROMCHAR:
2427 *result = this->OnMsgLineFromChar (wParam, lParam);
2430 *result = this->OnMsgLineLength (wParam, lParam);
2433 *result = this->OnMsgLineScroll (wParam, lParam);
2436 *result = this->OnMsgReplaceSel (wParam, lParam);
2439 *result = this->OnMsgSetSel (wParam, lParam);
2441 case EM_SCROLLCARET:
2442 *result = this->OnMsgScrollCaret (wParam, lParam);
2445 *result = this->OnMsgGetFont (wParam, lParam);
2448 *result = this->OnMsgSetFont (wParam, lParam);
2454 template <
typename BASECLASS>
2455 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetText (WPARAM wParam, LPARAM lParam)
2458 int cchTextMax = (int)wParam;
2459 LPSTR lpText = (LPSTR)lParam;
2460 Require (cchTextMax > 0);
2462 size_t len = this->GetLength ();
2464 this->CopyOut (0, len, buf.data ());
2465 size_t len2 = 2 * len;
2467 len2 = Characters::NLToNative<Led_tChar> (buf.data (), len, buf2.data (), len2);
2469 int nChars = ::WideCharToMultiByte (CP_ACP, 0, buf2.data (),
static_cast<int> (len2), lpText, cchTextMax - 1,
nullptr,
nullptr);
2470 lpText[nChars] =
'\0';
2473 template <
typename BASECLASS>
2474 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetText (WPARAM , LPARAM lParam)
2477 LPSTR lpText = (LPSTR)lParam;
2485 this->Replace (0, this->GetEnd (), LED_TCHAR_OF (
""), 0);
2486 if (lpText !=
nullptr) {
2487 size_t len = ::strlen (lpText);
2490 len =
static_cast<size_t> (::MultiByteToWideChar (CP_ACP, 0, lpText,
static_cast<int> (len), buf.data (),
static_cast<int> (len)));
2491 len = Characters::NormalizeTextToNL<Led_tChar> (buf.data (), len, buf.data (), len);
2492 this->Replace (0, 0, buf.data (), len);
2497 template <
typename BASECLASS>
2498 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetTextLength (WPARAM , LPARAM )
2501 return (4 * this->GetLength ());
2503 template <
typename BASECLASS>
2504 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetSel (WPARAM wParam, LPARAM lParam)
2506 DWORD iSelStart =
static_cast<DWORD
> (this->GetSelectionStart ());
2507 DWORD iSelEnd =
static_cast<DWORD
> (this->GetSelectionEnd ());
2509 *
reinterpret_cast<DWORD*
> (wParam) = iSelStart;
2512 *
reinterpret_cast<DWORD*
> (lParam) = iSelEnd;
2514 DWORD dw = (((WORD)iSelStart) << 16) | ((WORD)iSelEnd);
2517 template <
typename BASECLASS>
2518 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetFirstVisibleLine (WPARAM , LPARAM )
2520 Assert (this->GetTopRowInWindow () >= 0);
2521 return this->GetTopRowInWindow ();
2523 template <
typename BASECLASS>
2524 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetReadOnly (WPARAM wParam, LPARAM )
2526 HWND hWnd = this->GetValidatedHWND ();
2527 DWORD dwStyle = this->GetStyle ();
2528 bool readOnly = !!wParam;
2530 dwStyle |= ES_READONLY;
2533 dwStyle &= ~ES_READONLY;
2535 DWORD dwStyle1 = ::GetWindowLong (hWnd, GWL_STYLE);
2536 if (dwStyle != dwStyle1) {
2537 ::SetWindowLong (hWnd, GWL_STYLE, dwStyle);
2539 TextInteractor* ti =
this;
2542 if (this->GetCommandHandler () !=
nullptr) {
2543 this->GetCommandHandler ()->Commit ();
2548 template <
typename BASECLASS>
2549 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineIndex (WPARAM wParam, LPARAM )
2551 size_t row = (int (wParam) == -1) ? this->GetRowContainingPosition (this->GetSelectionEnd ()) : (size_t (wParam));
2555 row = min (row, this->GetRowCount () - 1);
2556 return (this->GetStartOfRow (row));
2558 template <
typename BASECLASS>
2559 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineCount (WPARAM , LPARAM )
2561 return this->GetRowCount ();
2563 template <
typename BASECLASS>
2564 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCanUndo (WPARAM , LPARAM )
2566 CommandHandler* ch = this->GetCommandHandler ();
2567 return ch !=
nullptr and ch->CanUndo ();
2569 template <
typename BASECLASS>
2570 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgUndo (WPARAM , LPARAM )
2572 CommandHandler* ch = this->GetCommandHandler ();
2573 if (ch !=
nullptr and ch->CanUndo ()) {
2574 this->OnUndoCommand ();
2579 template <
typename BASECLASS>
2580 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgEmptyUndoBuffer (WPARAM , LPARAM )
2582 CommandHandler* ch = this->GetCommandHandler ();
2583 if (ch !=
nullptr) {
2588 template <
typename BASECLASS>
2589 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgClear (WPARAM , LPARAM )
2591 this->OnClearCommand ();
2592#if qSupportWindowsSDKCallbacks
2593 HWND hWnd = this->GetValidatedHWND ();
2594 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2598 template <
typename BASECLASS>
2599 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCut (WPARAM , LPARAM )
2601 this->OnCutCommand ();
2602#if qSupportWindowsSDKCallbacks
2603 HWND hWnd = this->GetValidatedHWND ();
2604 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2608 template <
typename BASECLASS>
2609 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgCopy (WPARAM , LPARAM )
2611 this->OnCopyCommand ();
2614 template <
typename BASECLASS>
2615 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgPaste (WPARAM , LPARAM )
2617 this->OnPasteCommand ();
2618#if qSupportWindowsSDKCallbacks
2619 HWND hWnd = this->GetValidatedHWND ();
2620 (void)::SendMessage (::GetParent (hWnd), WM_COMMAND, MAKELONG (::GetWindowLong (hWnd, GWL_ID), EN_CHANGE), (LPARAM)hWnd);
2624 template <
typename BASECLASS>
2625 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineFromChar (WPARAM wParam, LPARAM )
2627 ptrdiff_t nIndex = ptrdiff_t (wParam);
2629 nIndex =
static_cast<ptrdiff_t
> (this->GetSelectionStart ());
2634 Assert (nIndex >= 0);
2635 if (
size_t (nIndex) > this->GetEnd ()) {
2636 nIndex = this->GetEnd ();
2638 return this->GetRowContainingPosition (nIndex);
2640 template <
typename BASECLASS>
2641 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineLength (WPARAM wParam, LPARAM )
2643 size_t row = (int (wParam) == -1) ? this->GetRowContainingPosition (this->GetSelectionEnd ()) : (size_t (wParam));
2647 if (row > this->GetRowCount () - 1) {
2648 row = this->GetRowCount () - 1;
2650 return this->GetEndOfRow (row) - this->GetStartOfRow (row);
2652 template <
typename BASECLASS>
2653 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgLineScroll (WPARAM wParam, LPARAM lParam)
2655 [[maybe_unused]]
int nChars = int (wParam);
2657 int nLines = int (lParam);
2658 this->ScrollByIfRoom (nLines);
2659 return !!(this->GetStyle () & ES_MULTILINE);
2661 template <
typename BASECLASS>
2662 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgReplaceSel ([[maybe_unused]] WPARAM wParam, LPARAM lParam)
2665 Assert (wParam == 0);
2666 LPCTSTR text = (LPCTSTR)lParam;
2668 size_t len = ::_tcslen (text);
2671#if qTargetPlatformSDKUseswchar_t
2673 (void)::memcpy (buf.begin (), text, (len + 1) *
sizeof (text[0]));
2675 len = ::MultiByteToWideChar (CP_ACP, 0, text, len, buf, len);
2677 size_t nLen = Characters::NormalizeTextToNL<Led_tChar> (buf.data (), len, buf.data (), len);
2678 Assert (ValidateTextForCharsetConformance (buf.data (), nLen));
2679 this->Replace (this->GetSelectionStart (), this->GetSelectionEnd (), buf.data (), nLen);
2682 template <
typename BASECLASS>
2683 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetSel (WPARAM wParam, LPARAM lParam)
2688 ptrdiff_t nStart = ptrdiff_t (wParam);
2689 ptrdiff_t nEnd = ptrdiff_t (lParam);
2691 nEnd = this->GetLength ();
2699 if (
size_t (nEnd) > this->GetEnd ()) {
2700 nEnd =
static_cast<ptrdiff_t
> (this->GetEnd ());
2702 if (nStart > nEnd) {
2703 swap (nStart, nEnd);
2705 this->SetSelection (
static_cast<ptrdiff_t
> (nStart),
static_cast<ptrdiff_t
> (nEnd));
2708 template <
typename BASECLASS>
2709 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgScrollCaret (WPARAM , LPARAM )
2711 this->ScrollToSelection ();
2714 template <
typename BASECLASS>
2715 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgGetFont (WPARAM , LPARAM )
2730 FontSpecification defaultFont = this->GetDefaultSelectionFont ();
2731 LOGFONT defaultFontLF;
2732 defaultFont.GetOSRep (&defaultFontLF);
2734 if (fDefaultFontCache.m_hObject !=
nullptr) {
2735 FontObject tmpHackToTestFont;
2736 Verify (tmpHackToTestFont.CreateFontIndirect (&defaultFontLF));
2738 ::LOGFONT tmpHackToTestFontLF{};
2739 Verify (tmpHackToTestFont.GetObject (sizeof (tmpHackToTestFontLF), &tmpHackToTestFontLF));
2741 ::LOGFONT currentLF{};
2742 Verify (fDefaultFontCache.GetObject (sizeof (currentLF), ¤tLF));
2744 if (::memcmp (¤tLF, &tmpHackToTestFontLF,
sizeof (currentLF)) != 0) {
2745 fDefaultFontCache.DeleteObject ();
2746 Assert (fDefaultFontCache.m_hObject ==
nullptr);
2750 if (fDefaultFontCache.m_hObject ==
nullptr) {
2751 fDefaultFontCache.CreateFontIndirect (&defaultFontLF);
2753 return (LRESULT)fDefaultFontCache.m_hObject;
2755 template <
typename BASECLASS>
2756 LRESULT Led_Win32_Win32SDKMessageMimicHelper<BASECLASS>::OnMsgSetFont (WPARAM wParam, LPARAM lParam)
2758 IncrementalFontSpecification fontSpec;
2760 HFONT fontToUse =
reinterpret_cast<HFONT
> (wParam);
2761 if (fontToUse ==
nullptr) {
2762 fontToUse =
reinterpret_cast<HFONT
> (::GetStockObject (DEFAULT_GUI_FONT));
2765 ::GetObject (fontToUse,
sizeof (lf), &lf);
2766 fontSpec.SetOSRep (lf);
2768 this->SetDefaultFont (fontSpec, lParam ? TextInteractor::eDefaultUpdate : TextInteractor::eNoUpdate);
2773 inline SimpleWin32WndProcHelper::SimpleWin32WndProcHelper ()
2775 , fSuperWindowProc{nullptr}
2778 inline HWND SimpleWin32WndProcHelper::GetHWND ()
const
2782 inline void SimpleWin32WndProcHelper::SetHWND (HWND hWnd)
2784 if (fHWnd !=
nullptr) {
2785 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA, 0);
2788 if (fHWnd !=
nullptr) {
2789 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA,
reinterpret_cast<DWORD_PTR
> (
this));
2792 inline HWND SimpleWin32WndProcHelper::GetValidatedHWND ()
const
2794 HWND hWnd = this->GetHWND ();
2796 Assert (::IsWindow (hWnd));
2799 inline void SimpleWin32WndProcHelper::Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
int nWidth,
2800 int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance)
2802 Create (0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance);
2804 inline LRESULT SimpleWin32WndProcHelper::SendMessage (UINT msg, WPARAM wParam, LPARAM lParam)
2806#if !qTargetPlatformSDKUseswchar_t
2807 if (IsWindowUNICODE ()) {
2808 return ::SendMessageW (this->GetValidatedHWND (), msg, wParam, lParam);
2811 return ::SendMessage (this->GetValidatedHWND (), msg, wParam, lParam);
2813 inline bool SimpleWin32WndProcHelper::IsWindowRealized ()
const
2815 return this->GetHWND () !=
nullptr;
2817 inline void SimpleWin32WndProcHelper::Assert_Window_Realized ()
const
2819 Assert (this->IsWindowRealized ());
2821 inline void SimpleWin32WndProcHelper::Require_Window_Realized ()
const
2823 Require (this->IsWindowRealized ());
2825 inline bool SimpleWin32WndProcHelper::IsWindowUNICODE ()
const
2827 Require_Window_Realized ();
2828 return !!::IsWindowUnicode (GetHWND ());
2830 inline bool SimpleWin32WndProcHelper::IsWindowShown ()
const
2832 Require_Window_Realized ();
2833 return !!::IsWindowVisible (GetHWND ());
2835 inline void SimpleWin32WndProcHelper::SetWindowVisible (
bool shown)
2837 Require_Window_Realized ();
2838 (void)::ShowWindow (GetHWND (), shown ? SW_SHOW : SW_HIDE);
2844 inline bool SimpleWin32WndProcHelper::SubclassWindow (HWND hWnd)
2846 Require (fSuperWindowProc ==
nullptr);
2847 Require (fHWnd ==
nullptr);
2849 Require (::IsWindow (hWnd));
2850 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLongPtr (hWnd, GWLP_WNDPROC,
reinterpret_cast<DWORD_PTR
> (StaticWndProc)));
2851 if (fSuperWindowProc ==
nullptr) {
2861 inline bool SimpleWin32WndProcHelper::SubclassWindowW (HWND hWnd)
2863 Require (fSuperWindowProc ==
nullptr);
2864 Require (fHWnd ==
nullptr);
2866 Require (::IsWindow (hWnd));
2867 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLongPtr (hWnd, GWLP_WNDPROC,
reinterpret_cast<DWORD_PTR
> (StaticWndProc)));
2868 if (fSuperWindowProc ==
nullptr) {
2874 inline LRESULT SimpleWin32WndProcHelper::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
2876 return this->DefWindowProc (message, wParam, lParam);
2878 inline LRESULT SimpleWin32WndProcHelper::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
2880#if !qTargetPlatformSDKUseswchar_t
2881 if (IsWindowUNICODE ()) {
2882 if (fSuperWindowProc ==
nullptr) {
2883 return ::DefWindowProcW (this->GetValidatedHWND (), message, wParam, lParam);
2886 return ::CallWindowProcW (fSuperWindowProc, this->GetValidatedHWND (), message, wParam, lParam);
2890 if (fSuperWindowProc ==
nullptr) {
2891 return ::DefWindowProc (this->GetValidatedHWND (), message, wParam, lParam);
2894 return ::CallWindowProc (fSuperWindowProc, this->GetValidatedHWND (), message, wParam, lParam);
2899 template <
typename BASE_WIN32_HELPER>
2900 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Led_Win32_SimpleWndProc_Helper ()
2901 : BASE_WIN32_HELPER{}
2903 , fSuperWindowProc{nullptr}
2906 template <
typename BASE_WIN32_HELPER>
2907 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::~Led_Win32_SimpleWndProc_Helper ()
2909 if (GetHWND () !=
nullptr) {
2910 ::DestroyWindow (GetHWND ());
2913 template <
typename BASE_WIN32_HELPER>
2914 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Create (LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle,
int x,
int y,
2915 int nWidth,
int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance)
2917 Create (0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance);
2919 template <
typename BASE_WIN32_HELPER>
2928 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::Create (DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
2929 DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight, HWND hWndParent,
2930 HMENU hMenu, HINSTANCE hInstance)
2933 if (lpClassName ==
nullptr) {
2934 tmpClassName = Foundation::Characters::CString::Format (_T(
"Led_Win32_SimpleWndProc_Helper<>-%d-%p"), ::GetCurrentProcessId (), &StaticWndProc);
2935 lpClassName = tmpClassName.c_str ();
2937 static bool sRegistered =
false;
2938 if (not sRegistered) {
2940 memset (&wcex, 0,
sizeof (wcex));
2941 wcex.cbSize =
sizeof (WNDCLASSEX);
2942 wcex.lpfnWndProc = (WNDPROC)StaticWndProc;
2943 wcex.lpszClassName = lpClassName;
2944 ATOM regResult = ::RegisterClassEx (&wcex);
2945 if (regResult == 0) {
2946 DWORD lastErr = ::GetLastError ();
2947 if (lastErr == ERROR_CLASS_ALREADY_EXISTS) {
2958 [[maybe_unused]] HWND hWnd =
2959 ::CreateWindowEx (dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance,
this);
2960 Assert (hWnd == this->GetValidatedHWND ());
2962 template <
typename BASE_WIN32_HELPER>
2963 void Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::SetHWND (HWND hWnd)
2965 if (fHWnd !=
nullptr) {
2966 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA, 0);
2969 if (fHWnd !=
nullptr) {
2970 ::SetWindowLongPtr (fHWnd, GWLP_USERDATA,
reinterpret_cast<DWORD_PTR
> (
this));
2973 template <
typename BASE_WIN32_HELPER>
2974 HWND Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::GetHWND ()
const
2978 template <
typename BASE_INTERACTOR>
2979 void Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::OnNCDestroy_Msg ()
2981 (void)DefWindowProc (WM_NCDESTROY, 0, 0);
2984 template <
typename BASE_INTERACTOR>
2992 bool Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::SubclassWindow (HWND hWnd)
2994 Require (fSuperWindowProc ==
nullptr);
2995 Require (fHWnd ==
nullptr);
2997 Require (::IsWindow (hWnd));
2998 fSuperWindowProc =
reinterpret_cast<WNDPROC
> (::SetWindowLong (hWnd, GWLP_WNDPROC,
reinterpret_cast<LONG
> (StaticWndProc)));
2999 if (fSuperWindowProc ==
nullptr) {
3003 HookSubclassWindow ();
3006 template <
typename BASE_INTERACTOR>
3020 bool Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::ReplaceWindow (HWND hWnd)
3022 Require (fSuperWindowProc ==
nullptr);
3023 Require (fHWnd ==
nullptr);
3025 Require (::IsWindow (hWnd));
3027 HWND parent = ::GetParent (hWnd);
3028 if (parent ==
nullptr) {
3031 int id = ::GetWindowLong (hWnd, GWL_ID);
3033 Assert (hWnd == ::GetDlgItem (parent,
id));
3035 DWORD dwStyle = ::GetWindowLong (hWnd, GWL_STYLE);
3036 DWORD exStyle = ::GetWindowLong (hWnd, GWL_EXSTYLE);
3040 memset (&wp, 0,
sizeof (wp));
3041 wp.length =
sizeof (wp);
3042 Verify (::GetWindowPlacement (hWnd, &wp));
3045 bool justUseSystemFont =
true;
3047 HFONT hFont =
nullptr;
3048 if ((hFont = (HFONT)::SendMessage (hWnd, WM_GETFONT, 0, 0L)) !=
nullptr) {
3049 if (::GetObject (hFont,
sizeof (LOGFONT), &useFont)) {
3050 justUseSystemFont =
false;
3056 ::DestroyWindow (hWnd);
3057 DISABLE_COMPILER_MSC_WARNING_START (4312)
3058 Create (exStyle,
nullptr,
nullptr, dwStyle | WS_CHILD, wp.rcNormalPosition.left, wp.rcNormalPosition.top,
3059 wp.rcNormalPosition.right - wp.rcNormalPosition.left, wp.rcNormalPosition.bottom - wp.rcNormalPosition.top, parent, (HMENU)
id,
nullptr);
3060 DISABLE_COMPILER_MSC_WARNING_END (4312)
3066 FontObject fontToUse;
3067 if (not justUseSystemFont) {
3068 Verify (fontToUse.CreateFontIndirect (&useFont));
3070 bool redrawFlag =
true;
3071 (void)::SendMessage (this->GetValidatedHWND (), WM_SETFONT,
3072 justUseSystemFont ? NULL :
reinterpret_cast<WPARAM
> (
static_cast<HFONT
> (fontToUse)), redrawFlag);
3076 template <
typename BASE_INTERACTOR>
3077 void Led_Win32_SimpleWndProc_Helper<BASE_INTERACTOR>::HookSubclassWindow ()
3079 HWND hWnd = this->GetValidatedHWND ();
3080 DWORD dwStyle = ::GetWindowLong (hWnd, GWL_STYLE);
3081 if ((dwStyle & WS_VSCROLL) and this->GetScrollBarType (TextInteractor::v) == TextInteractor::eScrollBarNever) {
3082 this->SetScrollBarType (TextInteractor::v, TextInteractor::eScrollBarAlways);
3084 if ((dwStyle & WS_HSCROLL) and this->GetScrollBarType (TextInteractor::h) == TextInteractor::eScrollBarNever) {
3085 this->SetScrollBarType (TextInteractor::h, TextInteractor::eScrollBarAlways);
3087 this->OnSize_Msg ();
3089 template <
typename BASE_WIN32_HELPER>
3090 LRESULT CALLBACK Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::StaticWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
3092 if (message == WM_CREATE) {
3093 ::LPCREATESTRUCT lpcs = (::LPCREATESTRUCT)lParam;
3095 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>* pThis =
3096 reinterpret_cast<Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>*
> (lpcs->lpCreateParams);
3097 Assert (pThis->GetHWND () ==
nullptr);
3098 pThis->SetHWND (hWnd);
3101 Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>* pThis =
3102 reinterpret_cast<Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>*
> (::GetWindowLongPtr (hWnd, GWLP_USERDATA));
3104 if (pThis ==
nullptr) {
3111 Assert (message == WM_GETMINMAXINFO or message == WM_NCCREATE or message == WM_NCCALCSIZE or message == 0x0093 or
3112 message == 0x0094 or message == WM_NCMOUSELEAVE);
3113 return ::DefWindowProc (hWnd, message, wParam, lParam);
3116 Assert (pThis !=
nullptr);
3117 Assert (pThis->GetHWND () == hWnd);
3118 return pThis->WndProc (message, wParam, lParam);
3120 template <
typename BASE_WIN32_HELPER>
3121 LRESULT Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
3123#define MY_GET_X_LPARAM(lp) ((int)(short)LOWORD (lp))
3124#define MY_GET_Y_LPARAM(lp) ((int)(short)HIWORD (lp))
3127 return this->OnCreate_Msg (
reinterpret_cast<::LPCREATESTRUCT
> (lParam));
3129 this->OnPaint_Msg ();
3132 this->OnSize_Msg ();
3135 this->OnChar_Msg (
static_cast<UINT
> (wParam), lParam);
3138 return this->OnUniChar_Msg (wParam, lParam);
3140#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
3142 return this->OnIMEChar_Msg (wParam, lParam);
3143 case WM_IME_COMPOSITION:
3144 return this->OnIME_COMPOSITION_Msg (wParam, lParam);
3145 case WM_IME_ENDCOMPOSITION:
3146 return this->OnIME_ENDCOMPOSITION_Msg (wParam, lParam);
3149 this->OnKeyDown_Msg (
static_cast<UINT
> (wParam), lParam);
3152 return this->OnSetCursor_Msg ((HWND)wParam, LOWORD (lParam), HIWORD (lParam));
3154 return this->OnGetDlgCode_Msg ();
3156 this->OnSetFocus_Msg (HWND (wParam));
3159 this->OnKillFocus_Msg (HWND (wParam));
3162 return this->OnEraseBkgnd_Msg (HDC (wParam));
3164 this->OnTimer_Msg (wParam,
reinterpret_cast<::TIMERPROC*
> (lParam));
3166 case WM_LBUTTONDOWN:
3167 this->OnLButtonDown_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3170 this->OnLButtonUp_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3172 case WM_LBUTTONDBLCLK:
3173 this->OnLButtonDblClk_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3176 this->OnMouseMove_Msg (
static_cast<UINT
> (wParam), MY_GET_X_LPARAM (lParam), MY_GET_Y_LPARAM (lParam));
3179 this->OnVScroll_Msg (LOWORD (wParam), (
short)HIWORD (wParam), HWND (lParam));
3182 this->OnHScroll_Msg (LOWORD (wParam), (
short)HIWORD (wParam), HWND (lParam));
3184#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
3186 return this->OnMouseWheel_Msg (wParam, lParam);
3189 this->OnEnable_Msg (!!wParam);
3192 this->OnNCDestroy_Msg ();
3195 return this->DefWindowProc (message, wParam, lParam);
3197#undef MY_GET_X_LPARAM
3198#undef MY_GET_Y_LPARAM
3201 template <
typename BASE_WIN32_HELPER>
3202 LRESULT Led_Win32_SimpleWndProc_Helper<BASE_WIN32_HELPER>::DefWindowProc (UINT message, WPARAM wParam, LPARAM lParam)
3204 if (fSuperWindowProc ==
nullptr) {
3205 return inherited::DefWindowProc (message, wParam, lParam);
3208 return (*fSuperWindowProc) (this->GetValidatedHWND (), message, wParam, lParam);
3213 template <
typename BASE_CLASS>
3214 inline Led_Win32_SimpleWndProc_HelperWithSDKMessages<BASE_CLASS>::Led_Win32_SimpleWndProc_HelperWithSDKMessages ()
3218 template <
typename BASE_CLASS>
3219 LRESULT Led_Win32_SimpleWndProc_HelperWithSDKMessages<BASE_CLASS>::WndProc (UINT message, WPARAM wParam, LPARAM lParam)
3222 if (this->HandleMessage (message, wParam, lParam, &result)) {
3226 return inherited::WndProc (message, wParam, lParam);
3233#if qHookIMEEndCompositionMessageToWorkAroundWin2KIMEForNonUNICODEBug
#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