6namespace Stroika::Frameworks::Led {
8#if qStroika_Frameworks_Led_SupportGDI
14 inline void MultiRowTextImager::InvalidateTotalRowsInWindow ()
16 fTotalRowsInWindow = 0;
18 inline MultiRowTextImager::RowReference MultiRowTextImager::GetTopRowReferenceInWindow ()
const
22 const_cast<MultiRowTextImager*
> (
this)->ReValidateSubRowInTopLineInWindow ();
23 return (RowReference (fTopLinePartitionMarkerInWindow, fSubRowInTopLineInWindow));
25 inline size_t MultiRowTextImager::GetTotalRowsInWindow_ ()
const
27 if (fTotalRowsInWindow == 0) {
28 fTotalRowsInWindow = ComputeRowsThatWouldFitInWindowWithTopRow (GetTopRowReferenceInWindow ());
30 Assert (fTotalRowsInWindow >= 1);
31 Assert (fTotalRowsInWindow == ComputeRowsThatWouldFitInWindowWithTopRow (GetTopRowReferenceInWindow ()));
32 return (fTotalRowsInWindow);
40 inline MultiRowTextImager::PartitionElementCacheInfo::Rep::Rep ()
41 : fPixelHeightCache (DistanceType (-1))
44 , fRowStartArray (nullptr)
45 , fRowHeightArray (nullptr)
48 inline MultiRowTextImager::PartitionElementCacheInfo::Rep::~Rep ()
50 if (fRowCountCache > kPackRowStartCount + 1) {
51 delete[] fRowStartArray;
53 if (fRowCountCache > kPackRowHeightCount) {
54 delete[] fRowHeightArray;
63 inline MultiRowTextImager::PartitionElementCacheInfo::PartitionElementCacheInfo ()
74 inline DistanceType MultiRowTextImager::PartitionElementCacheInfo::GetInterLineSpace ()
const
76 Assert (fRep->fInterlineSpace != DistanceType (-1));
77 return (fRep->fInterlineSpace);
79 inline void MultiRowTextImager::PartitionElementCacheInfo::SetInterLineSpace (DistanceType interlineSpace)
81 Assert (interlineSpace != DistanceType (-1));
82 fRep->fInterlineSpace = interlineSpace;
89 inline DistanceType MultiRowTextImager::PartitionElementCacheInfo::GetPixelHeight ()
const
91 return (fRep->fPixelHeightCache + GetInterLineSpace ());
99 inline size_t MultiRowTextImager::PartitionElementCacheInfo::GetRowCount ()
const
101 Assert (fRep->fRowCountCache >= 1);
102 return (fRep->fRowCountCache);
110 inline size_t MultiRowTextImager::PartitionElementCacheInfo::PeekRowCount ()
const
112 return (fRep->fRowCountCache);
119 inline size_t MultiRowTextImager::PartitionElementCacheInfo::GetLastRow ()
const
121 return GetRowCount () - 1;
129 inline DistanceType MultiRowTextImager::PartitionElementCacheInfo::PeekAtRowHeight (
size_t i)
const
131 Assert (i < fRep->fRowCountCache);
138 if (fRep->fRowCountCache <= kPackRowHeightCount) {
140 const RowHeight_* theArray =
reinterpret_cast<const RowHeight_*
> (&fRep->fRowHeightArray);
141 return (theArray[i]);
144 return (fRep->fRowHeightArray[i]);
150 inline void MultiRowTextImager::PartitionElementCacheInfo::SetRowHeight (
size_t i, DistanceType rowHeight)
152 Assert (i < fRep->fRowCountCache);
153 Assert (
sizeof (RowHeight_) > 1 or rowHeight <= 0xff);
154 Assert (
sizeof (RowHeight_) > 2 or rowHeight <= 0xffff);
158 if (fRep->fRowCountCache <= kPackRowHeightCount) {
160 RowHeight_* theArray =
reinterpret_cast<RowHeight_*
> (&fRep->fRowHeightArray);
161 theArray[i] = RowHeight_ (rowHeight);
165 fRep->fRowHeightArray[i] = RowHeight_ (rowHeight);
173 inline size_t MultiRowTextImager::PartitionElementCacheInfo::PeekAtRowStart (
size_t i)
const
175 Assert (i < fRep->fRowCountCache);
185 if (fRep->fRowCountCache <= kPackRowStartCount + 1) {
187 const RowStart_* theArray =
reinterpret_cast<const RowStart_*
> (&fRep->fRowStartArray);
188 return (theArray[i - 1]);
191 return (fRep->fRowStartArray[i - 1]);
199 inline void MultiRowTextImager::PartitionElementCacheInfo::SetRowStart (
size_t i,
size_t rowStart)
201 Assert (i < fRep->fRowCountCache);
204 Assert (rowStart == 0);
211 Assert (
sizeof (RowStart_) > 1 or rowStart <= 0xff);
212 Assert (
sizeof (RowStart_) > 2 or rowStart <= 0xffff);
213 if (fRep->fRowCountCache <= kPackRowStartCount + 1) {
215 RowStart_* theArray =
reinterpret_cast<RowStart_*
> (&fRep->fRowStartArray);
216 theArray[i - 1] = RowStart_ (rowStart);
220 fRep->fRowStartArray[i - 1] = RowStart_ (rowStart);
224 inline size_t MultiRowTextImager::PartitionElementCacheInfo::GetLineRelativeRowStartPosition (
size_t ithRow)
const
226 return (PeekAtRowStart (ithRow));
228 inline DistanceType MultiRowTextImager::PartitionElementCacheInfo::GetRowHeight (
size_t ithRow)
const
230 return (PeekAtRowHeight (ithRow));
232 inline size_t MultiRowTextImager::PartitionElementCacheInfo::LineRelativePositionInWhichRow (
size_t charPos)
const
237 for (
size_t row = fRep->fRowCountCache; row >= 1; --row) {
238 if (charPos >= PeekAtRowStart (row - 1)) {
251 inline MultiRowTextImager::RowReference::RowReference (PartitionMarker* partitionMarker,
size_t subRow)
252 : fPartitionMarker (partitionMarker)
256 inline MultiRowTextImager::RowReference& MultiRowTextImager::RowReference::operator= (
const MultiRowTextImager::RowReference& rhs)
258 fPartitionMarker = rhs.fPartitionMarker;
259 fSubRow = rhs.fSubRow;
262 inline MultiRowTextImager::PartitionMarker* MultiRowTextImager::RowReference::GetPartitionMarker ()
const
264 return (fPartitionMarker);
266 inline size_t MultiRowTextImager::RowReference::GetSubRow ()
const
270 inline bool MultiRowTextImager::RowReference::operator== (MultiRowTextImager::RowReference rhs)
const
272 return this->GetPartitionMarker () == rhs.GetPartitionMarker () and this->GetSubRow () == rhs.GetSubRow ();
286 inline bool MultiRowTextImager::GetNextRowReference (RowReference* adjustMeInPlace)
const
289 PartitionMarker* cur = adjustMeInPlace->GetPartitionMarker ();
290 size_t subRow = adjustMeInPlace->GetSubRow ();
291 PartitionElementCacheInfo pmCacheInfo = GetPartitionElementCacheInfo (cur);
292 if (subRow + 1 < pmCacheInfo.GetRowCount ()) {
294 *adjustMeInPlace = RowReference{cur, subRow};
298 if (cur->GetNext () ==
nullptr) {
302 cur = cur->GetNext ();
304 *adjustMeInPlace = RowReference{cur, subRow};
315 inline bool MultiRowTextImager::GetPreviousRowReference (RowReference* adjustMeInPlace)
const
318 PartitionMarker* cur = adjustMeInPlace->GetPartitionMarker ();
319 size_t subRow = adjustMeInPlace->GetSubRow ();
322 *adjustMeInPlace = RowReference{cur, subRow};
326 if (cur->GetPrevious () ==
nullptr) {
330 cur = cur->GetPrevious ();
331 PartitionElementCacheInfo pmCacheInfo = GetPartitionElementCacheInfo (cur);
332 subRow = pmCacheInfo.GetRowCount () - 1;
333 *adjustMeInPlace = RowReference{cur, subRow};
345 inline MultiRowTextImager::RowReference MultiRowTextImager::GetIthRowReferenceFromHere (RowReference fromHere, ptrdiff_t ith)
const
347 [[maybe_unused]]
bool result = GetIthRowReferenceFromHere (&fromHere, ith);
357 inline MultiRowTextImager::RowReference MultiRowTextImager::GetIthRowReference (
size_t ith)
const
359 RowReference fromHere (GetFirstPartitionMarker (), 0);
360 [[maybe_unused]]
bool result = GetIthRowReferenceFromHere (&fromHere, ith);
369 inline size_t MultiRowTextImager::GetRowLength (RowReference row)
const
371 return (GetEndOfRow (row) - GetStartOfRow (row));
377 inline MultiRowTextImager::RowReference MultiRowTextImager::GetLastRowReferenceInWindow ()
const
379 RowReference row = GetTopRowReferenceInWindow ();
380 Assert (GetTotalRowsInWindow_ () >= 1);
381 (void)GetIthRowReferenceFromHere (&row, GetTotalRowsInWindow_ () - 1);
384 inline void MultiRowTextImager::SetTopRowInWindow_ (RowReference row)
386 fTopLinePartitionMarkerInWindow = row.GetPartitionMarker ();
387 fSubRowInTopLineInWindow = row.GetSubRow ();
389 InvalidateTotalRowsInWindow ();
395 inline DistanceType MultiRowTextImager::GetRowHeight (RowReference row)
const
398 return GetPartitionElementCacheInfo (row.GetPartitionMarker ()).GetRowHeight (row.GetSubRow ());
#define RequireNotNull(p)
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...