5namespace Stroika::Frameworks::Led {
7#if qStroika_Frameworks_Led_SupportGDI
15 inline TextInteractor::SuppressCommandBreaksContext::SuppressCommandBreaksContext (TextInteractor& ti)
16 : fTextInteractor (ti)
17 , fOldVal (ti.fSuppressCommandBreaksContext)
19 ti.fSuppressCommandBreaksContext =
true;
21 inline TextInteractor::SuppressCommandBreaksContext::~SuppressCommandBreaksContext ()
23 fTextInteractor.fSuppressCommandBreaksContext = fOldVal;
27 inline TextInteractor::PreScrollInfo::PreScrollInfo ()
28 : fUpdateMode (eDefaultUpdate)
31 , fTryTodoScrollbits (false)
32 , fOldLastRowStart (0)
37 template <
typename TARGET_COMMAND_NUMBER>
38 CommandNumberMapping<TARGET_COMMAND_NUMBER>* CommandNumberMapping<TARGET_COMMAND_NUMBER>::sThe =
nullptr;
39 template <
typename TARGET_COMMAND_NUMBER>
40 CommandNumberMapping<TARGET_COMMAND_NUMBER>::CommandNumberMapping ()
44 Assert (sThe ==
nullptr);
47 template <
typename TARGET_COMMAND_NUMBER>
48 CommandNumberMapping<TARGET_COMMAND_NUMBER>::~CommandNumberMapping ()
50 Assert (sThe ==
this);
53 template <
typename TARGET_COMMAND_NUMBER>
54 inline CommandNumberMapping<TARGET_COMMAND_NUMBER>& CommandNumberMapping<TARGET_COMMAND_NUMBER>::Get ()
60 template <
typename TARGET_COMMAND_NUMBER>
61 inline void CommandNumberMapping<TARGET_COMMAND_NUMBER>::AddAssociation (TARGET_COMMAND_NUMBER externalCommandNumber, CommandNumber internalCommandNumber)
63 fMap.insert (MAP_TYPE::value_type (externalCommandNumber, internalCommandNumber));
65 template <
typename TARGET_COMMAND_NUMBER>
66 inline void CommandNumberMapping<TARGET_COMMAND_NUMBER>::AddRangeAssociation (TARGET_COMMAND_NUMBER externalRangeStart,
67 TARGET_COMMAND_NUMBER externalRangeEnd,
68 CommandNumber internalRangeStart, CommandNumber internalRangeEnd)
70 Require (
int (externalRangeEnd - externalRangeStart) ==
int (internalRangeEnd - internalRangeStart));
73 re.fExternalCmds.first = externalRangeStart;
74 re.fExternalCmds.second = externalRangeEnd;
75 re.fInternalCmds.first = internalRangeStart;
76 re.fInternalCmds.second = internalRangeEnd;
77 fRanges.push_back (re);
79 template <
typename TARGET_COMMAND_NUMBER>
80 TextInteractor::CommandNumber CommandNumberMapping<TARGET_COMMAND_NUMBER>::Lookup (TARGET_COMMAND_NUMBER externalCommandNumber)
const
82 typename MAP_TYPE::const_iterator i = fMap.find (externalCommandNumber);
83 if (i == fMap.end ()) {
84 for (
typename RANGE_VEC_TYPE::const_iterator j = fRanges.begin (); j != fRanges.end (); ++j) {
85 const RangeElt& re = *j;
86 if (re.fExternalCmds.first <= externalCommandNumber and externalCommandNumber <= re.fExternalCmds.second) {
87 TARGET_COMMAND_NUMBER offset = externalCommandNumber - re.fExternalCmds.first;
88 TextInteractor::CommandNumber cmdNum = re.fInternalCmds.first + offset;
89 Assert (cmdNum <= re.fInternalCmds.second);
93 return TextInteractor::kNoCommand_CmdID;
99 template <
typename TARGET_COMMAND_NUMBER>
100 TARGET_COMMAND_NUMBER CommandNumberMapping<TARGET_COMMAND_NUMBER>::ReverseLookup (CommandNumber cmdNum)
const
102 for (
typename MAP_TYPE::const_iterator i = fMap.begin (); i != fMap.end (); ++i) {
103 if ((*i).second == cmdNum) {
107 for (
auto j = fRanges.begin (); j != fRanges.end (); ++j) {
108 const RangeElt& re = *j;
109 if (re.fInternalCmds.first <= cmdNum and cmdNum <= re.fInternalCmds.second) {
110 size_t offset = cmdNum - re.fInternalCmds.first;
111 TARGET_COMMAND_NUMBER tarCmd =
static_cast<TARGET_COMMAND_NUMBER
> (re.fExternalCmds.first + offset);
112 Assert (tarCmd <= re.fExternalCmds.second);
121 inline SimpleCommandUpdater::SimpleCommandUpdater (CommandNumber cmdNum)
122 : fCommandNumber (cmdNum)
128 inline SimpleCommandUpdater::CommandNumber SimpleCommandUpdater::GetCmdID ()
const
130 return fCommandNumber;
132 inline bool SimpleCommandUpdater::GetEnabled ()
const
136 inline void SimpleCommandUpdater::SetEnabled (
bool enabled)
140 inline void SimpleCommandUpdater::SetChecked (
bool checked)
144 inline void SimpleCommandUpdater::SetText (
const SDKChar* text)
151 inline TextInteractor::InteractiveModeUpdater::InteractiveModeUpdater (TextInteractor& ti,
bool interactive)
152 : fTextInteractor (ti)
153 , fSavedMode (ti.GetInteractiveUpdateMode ())
155 InteractiveUpdadeMode newMode = interactive ? eInteractiveUpdateMode : eNonInteractiveUpdateMode;
156 if (ti.GetInteractiveUpdateMode () == eIndeterminateInteractiveUpdateMode) {
157 ti.SetInteractiveUpdateMode (newMode);
163 Assert (ti.GetInteractiveUpdateMode () == newMode);
166 inline TextInteractor::InteractiveModeUpdater::~InteractiveModeUpdater ()
168 fTextInteractor.SetInteractiveUpdateMode (fSavedMode);
172 inline TextInteractor::SmartCNPInfo::SmartCNPInfo ()
173 : fWordBreakAtSelStart (false)
174 , fWordBreakAtSelEnd (false)
184 inline CommandHandler* TextInteractor::GetCommandHandler ()
const
186 return fCommandHandler;
192 inline void TextInteractor::SetCommandHandler (CommandHandler* commandHandler)
194 fCommandHandler = commandHandler;
202 inline void TextInteractor::BreakInGroupedCommands ()
204 if (fCommandHandler !=
nullptr and not fSuppressCommandBreaksContext) {
205 fCommandHandler->BreakInGroupedCommands ();
214 inline void TextInteractor::BreakInGroupedCommandsIfDifferentCommand (
const SDKString& cmdName)
216 if (fCommandHandler !=
nullptr and not fSuppressCommandBreaksContext) {
217 fCommandHandler->BreakInGroupedCommandsIfDifferentCommand (cmdName);
224 inline TextInteractor::DialogSupport& TextInteractor::GetDialogSupport ()
226 if (sDialogSupport ==
nullptr) {
227 static DialogSupport sDefSup;
228 sDialogSupport = &sDefSup;
230 return *sDialogSupport;
236 inline void TextInteractor::SetDialogSupport (DialogSupport* ds)
250 inline const TextInteractor::CommandNames& TextInteractor::GetCommandNames ()
252 return sCommandNames;
258 inline void TextInteractor::SetCommandNames (
const TextInteractor::CommandNames& cmdNames)
260 sCommandNames = cmdNames;
267 inline SpellCheckEngine* TextInteractor::GetSpellCheckEngine ()
const
269 return fSpellCheckEngine;
280 inline void TextInteractor::SetSpellCheckEngine (SpellCheckEngine* spellCheckEngine)
282 fSpellCheckEngine = spellCheckEngine;
292 inline TextInteractor::UpdateMode TextInteractor::GetDefaultUpdateMode ()
const
294 Ensure (fDefaultUpdateMode != eDefaultUpdate);
295 return fDefaultUpdateMode;
303 inline TextInteractor::UpdateMode TextInteractor::RealUpdateMode (UpdateMode updateMode)
const
305 return updateMode == eDefaultUpdate ? GetDefaultUpdateMode () : updateMode;
317 inline bool TextInteractor::GetSmartCutAndPasteMode ()
const
319 return fSmartCutAndPasteMode;
325 inline void TextInteractor::SetSmartCutAndPasteMode (
bool smartCutAndPasteMode)
327 fSmartCutAndPasteMode = smartCutAndPasteMode;
335 inline unsigned TextInteractor::GetCurClickCount ()
const
344 inline void TextInteractor::SetCurClickCount (
unsigned curClickCount, Foundation::Time::TimePointSeconds lastClickAt)
346 fClickCount = curClickCount;
347 fLastClickedAt = lastClickAt;
354 inline void TextInteractor::IncrementCurClickCount (Foundation::Time::TimePointSeconds lastClickAt)
357 fLastClickedAt = lastClickAt;
384 inline bool TextInteractor::IsWholeWindowInvalid ()
const
386 return fWholeWindowInvalid;
394 inline void TextInteractor::NoteWholeWindowIsInvalid ()
396 fWholeWindowInvalid =
true;
405 inline void TextInteractor::NoteWindowPartiallyUpdated ()
407 fWholeWindowInvalid =
false;
416 inline void TextInteractor::Refresh (UpdateMode updateMode)
const
418 updateMode = RealUpdateMode (updateMode);
419 if (updateMode != eNoUpdate) {
420 if (updateMode == eDelayedUpdate and IsWholeWindowInvalid ()) {
423 RefreshWindowRect_ (GetWindowRect (), updateMode);
425 if (updateMode == eDelayedUpdate) {
426 const_cast<TextInteractor*
> (
this)->NoteWholeWindowIsInvalid ();
437 inline void TextInteractor::RefreshWindowRect (
const Led_Rect& windowRectArea, UpdateMode updateMode)
const
439 updateMode = RealUpdateMode (updateMode);
440 if (updateMode != eNoUpdate) {
441 if (updateMode == eDelayedUpdate and IsWholeWindowInvalid ()) {
444 RefreshWindowRect_ (windowRectArea, updateMode);
445 if (updateMode == eDelayedUpdate and windowRectArea.Contains (GetWindowRect ())) {
446 const_cast<TextInteractor*
> (
this)->NoteWholeWindowIsInvalid ();
454 inline void TextInteractor::Update (
bool ignoreCannotUpdateNowErrors)
const
457 UpdateWindowRect_ (GetWindowRect ());
459 catch (CannotUpdateNow&) {
460 if (not ignoreCannotUpdateNowErrors) {
474 inline void TextInteractor::UpdateWindowRect (
const Led_Rect& windowRectArea,
bool ignoreCannotUpdateNowErrors)
const
477 UpdateWindowRect_ (windowRectArea);
479 catch (CannotUpdateNow&) {
480 if (not ignoreCannotUpdateNowErrors) {
492 inline bool TextInteractor::GetUseSecondaryHilight ()
const
494 return fUseSecondaryHilight;
502 inline void TextInteractor::SetUseSecondaryHilight (
bool useSecondaryHilight)
504 if (fUseSecondaryHilight != useSecondaryHilight) {
506 fUseSecondaryHilight = useSecondaryHilight;
509 inline bool TextInteractor::GetUseBitmapScrollingOptimization ()
const
511 return fUseBitmapScrollingOptimization;
513 inline void TextInteractor::SetUseBitmapScrollingOptimization (
bool useBitmapScrollingOptimization)
515 fUseBitmapScrollingOptimization = useBitmapScrollingOptimization;
517 inline bool TextInteractor::GetSuppressTypedControlCharacters ()
const
519 return fSuppressTypedControlCharacters;
521 inline void TextInteractor::SetSuppressTypedControlCharacters (
bool suppressTypedControlCharacters)
523 fSuppressTypedControlCharacters = suppressTypedControlCharacters;
529 inline TextInteractor::InteractiveUpdadeMode TextInteractor::GetInteractiveUpdateMode ()
const
531 return fInteractiveUpdadeMode;
537 inline void TextInteractor::SetInteractiveUpdateMode (InteractiveUpdadeMode interactive)
539 fInteractiveUpdadeMode = interactive;
545 inline bool TextInteractor::CheckIfCurrentUpdateIsInteractive ()
const
548 return fInteractiveUpdadeMode == eInteractiveUpdateMode;
554 inline shared_ptr<FlavorPackageInternalizer> TextInteractor::GetInternalizer ()
const
556 return fInternalizer;
562 inline void TextInteractor::SetInternalizer (
const shared_ptr<FlavorPackageInternalizer>& i)
565 HookInternalizerChanged ();
571 inline shared_ptr<FlavorPackageExternalizer> TextInteractor::GetExternalizer ()
const
573 return fExternalizer;
579 inline void TextInteractor::SetExternalizer (
const shared_ptr<FlavorPackageExternalizer>& e)
582 HookExternalizerChanged ();
584 inline void TextInteractor::InvalidateScrollBarParameters_ ()
586 fScrollBarParamsValid =
false;
588 inline void TextInteractor::UpdateScrollBars_ ()
590 fScrollBarParamsValid =
true;
600 inline bool TextInteractor::GetCaretShown ()
const
602 return (fCaretShown);
631 inline bool TextInteractor::GetCaretShownAfterPos ()
const
633 return (fCaretShownAfterPos);
640 inline TextInteractor::ScrollBarType TextInteractor::GetScrollBarType (VHSelect vh)
const
642 return fScrollBarType[vh];
644 inline void TextInteractor::SetScrollBarType_ (VHSelect vh, ScrollBarType scrollBarType)
646 fScrollBarType[vh] = scrollBarType;
648 inline void TextInteractor::UpdateIfNoKeysPending ()
650 if (QueryInputKeyStrokesPending ()) {
663 inline TextInteractor::SearchParameters::SearchParameters ()
664 : fRecentFindStrings{}
669 inline TextInteractor::ReplaceParameters::ReplaceParameters ()
681 inline size_t TextInteractor::UndoableContextHelper::GetUndoRegionStart ()
const
689 inline size_t TextInteractor::UndoableContextHelper::GetUndoRegionEnd ()
const
697 inline bool TextInteractor::UndoableContextHelper::GetSimplePlainTextInsertOptimization ()
const
699 return fSimplePlainTextInsertOptimization;
709 inline void TextInteractor::UndoableContextHelper::SetSimplePlainTextInsertOptimization (
bool simplePlainTextInsertOptimizationFlag)
711 fSimplePlainTextInsertOptimization = simplePlainTextInsertOptimizationFlag;
715 inline TextInteractor::TemporarilySetUpdateMode::TemporarilySetUpdateMode (TextInteractor& ti, UpdateMode tmpUpdateMode)
716 : fTextInteractor (ti)
717 , fOldValue (ti.GetDefaultUpdateMode ())
719 fTextInteractor.SetDefaultUpdateMode (tmpUpdateMode);
721 inline TextInteractor::TemporarilySetUpdateMode::~TemporarilySetUpdateMode ()
723 fTextInteractor.SetDefaultUpdateMode (fOldValue);
#define RequireNotNull(p)