Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
HiddenText.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5namespace Stroika::Frameworks::Led {
6
7 /*
8 ********************************************************************************
9 ***************************** HidableTextMarkerOwner ***************************
10 ********************************************************************************
11 */
12 inline shared_ptr<FlavorPackageInternalizer> HidableTextMarkerOwner::GetInternalizer () const
13 {
14 return fInternalizer;
15 }
16 inline shared_ptr<FlavorPackageExternalizer> HidableTextMarkerOwner::GetExternalizer () const
17 {
18 return fExternalizer;
19 }
20 inline void HidableTextMarkerOwner::Invariant () const
21 {
22#if qStroika_Foundation_Debug_AssertionsChecked
23 Invariant_ ();
24#endif
25 }
26
27 /*
28 ********************************************************************************
29 ******************* HidableTextMarkerOwner::HidableTextMarker ******************
30 ********************************************************************************
31 */
32 inline HidableTextMarkerOwner::HidableTextMarker::HidableTextMarker ()
33 : inherited ()
34 , fShown (true)
35 {
36 }
37 inline HidableTextMarkerOwner& HidableTextMarkerOwner::HidableTextMarker::GetOwner () const
38 {
39 MarkerOwner* mo = inherited::GetOwner ();
40 HidableTextMarkerOwner* hmo = dynamic_cast<HidableTextMarkerOwner*> (mo);
41 EnsureNotNull (hmo);
42 return *hmo;
43 }
44 inline void HidableTextMarkerOwner::HidableTextMarker::Hide ()
45 {
46 if (fShown) {
47 GetOwner ().CollapseMarker (this);
48 }
49 Ensure (not fShown);
50 }
51 inline void HidableTextMarkerOwner::HidableTextMarker::Show ()
52 {
53 if (not fShown) {
54 GetOwner ().ReifyMarker (this);
55 }
56 Ensure (fShown);
57 }
58 inline bool HidableTextMarkerOwner::HidableTextMarker::IsShown () const
59 {
60 return fShown;
61 }
62
63 /*
64 ********************************************************************************
65 ********************* HidableTextMarkerHelper<BASECLASS> ***********************
66 ********************************************************************************
67 */
68 template <typename BASECLASS>
69 int HidableTextMarkerHelper<BASECLASS>::GetPriority () const
70 {
71 // simpleembedings are priorty 100 - maybe should use ENUM CONST? return 100; // large enough to override most other markers (esp StyledTextImager::StyleMarker which we know how to aggregate).
72 return 200; // large enough to override most other markers (esp StyledTextImager::StyleMarker which we know how to aggregate).
73 }
74#if qStroika_Frameworks_Led_SupportGDI
75 template <typename BASECLASS>
76 void HidableTextMarkerHelper<BASECLASS>::DrawSegment (const StyledTextImager* imager, const StyleRunElement& runElement, Tablet* tablet,
77 size_t from, size_t to, const TextLayoutBlock& text, const Led_Rect& drawInto,
78 const Led_Rect& invalidRect, CoordinateType useBaseLine, DistanceType* pixelsDrawn)
79 {
80 if (this->IsShown ()) {
81 inherited::DrawSegment (imager, runElement, tablet, from, to, text, drawInto, invalidRect, useBaseLine, pixelsDrawn);
82 }
83 else {
84 *pixelsDrawn = 0;
85 }
86 }
87 template <typename BASECLASS>
88 void HidableTextMarkerHelper<BASECLASS>::MeasureSegmentWidth (const StyledTextImager* imager, const StyleRunElement& runElement, size_t from,
89 size_t to, const Led_tChar* text, DistanceType* distanceResults) const
90 {
91 if (this->IsShown ()) {
92 inherited::MeasureSegmentWidth (imager, runElement, from, to, text, distanceResults);
93 }
94 else {
95 size_t len = to - from;
96 for (size_t i = 0; i < len; ++i) {
97 distanceResults[i] = 0;
98 }
99 }
100 }
101 template <typename BASECLASS>
102 DistanceType HidableTextMarkerHelper<BASECLASS>::MeasureSegmentHeight (const StyledTextImager* imager,
103 const StyleRunElement& runElement, size_t from, size_t to) const
104 {
105 if (this->IsShown ()) {
106 return inherited::MeasureSegmentHeight (imager, runElement, from, to);
107 }
108 else {
109 return 0;
110 }
111 }
112 template <typename BASECLASS>
113 DistanceType HidableTextMarkerHelper<BASECLASS>::MeasureSegmentBaseLine (const StyledTextImager* imager,
114 const StyleRunElement& runElement, size_t from, size_t to) const
115 {
116 if (this->IsShown ()) {
117 return inherited::MeasureSegmentBaseLine (imager, runElement, from, to);
118 }
119 else {
120 return 0;
121 }
122 }
123#endif
124
125 /*
126 ********************************************************************************
127 *************** HidableTextMarkerOwner::FontSpecHidableTextMarker **************
128 ********************************************************************************
129 */
130 inline HidableTextMarkerOwner::FontSpecHidableTextMarker::FontSpecHidableTextMarker (const IncrementalFontSpecification& styleInfo)
131 : inherited{}
132 , fFontSpecification{styleInfo}
133 {
134 }
135
136 /*
137 ********************************************************************************
138 ************************ UniformHidableTextMarkerOwner *************************
139 ********************************************************************************
140 */
141 inline bool UniformHidableTextMarkerOwner::IsHidden () const
142 {
143 return fHidden;
144 }
145
146 /*
147 ********************************************************************************
148 ************************ ColoredUniformHidableTextMarkerOwner ******************
149 ********************************************************************************
150 */
151 inline ColoredUniformHidableTextMarkerOwner::ColoredUniformHidableTextMarkerOwner (TextStore& textStore)
152 : inherited{textStore}
153 , fColor{Color::kRed}
154 , fColored{false}
155 {
156 }
157 inline Color ColoredUniformHidableTextMarkerOwner::GetColor () const
158 {
159 return fColor;
160 }
161 inline void ColoredUniformHidableTextMarkerOwner::SetColor (const Color& color)
162 {
163 fColor = color;
164 FixupSubMarkers ();
165 }
166 inline bool ColoredUniformHidableTextMarkerOwner::GetColored () const
167 {
168 return fColored;
169 }
170 inline void ColoredUniformHidableTextMarkerOwner::SetColored (bool colored)
171 {
172 fColored = colored;
173 FixupSubMarkers ();
174 }
175
176}
#define EnsureNotNull(p)
Definition Assertions.h:340