5#include "Stroika/Foundation/Execution/Exceptions.h"
7namespace Stroika::Frameworks::Led {
14 template <
typename COORD_TYPE>
15 constexpr Point_Base<COORD_TYPE>::Point_Base ()
20 template <
typename COORD_TYPE>
21 constexpr Point_Base<COORD_TYPE>::Point_Base (COORD_TYPE newV, COORD_TYPE newH)
26 template <
typename COORD_TYPE>
27 constexpr Point_Base<COORD_TYPE> operator+ (
const Point_Base<COORD_TYPE>& lhs,
const Point_Base<COORD_TYPE>& rhs)
29 Led_Point result = lhs;
40 inline Led_Point operator- (
const Led_Point& lhs,
const Led_Point& rhs)
42 return (Led_Point (lhs.v - rhs.v, lhs.h - rhs.h));
50 template <
typename POINT_TYPE,
typename SIZE_TYPE>
55 constexpr Rect_Base<POINT_TYPE, SIZE_TYPE>::Rect_Base ()
56 : top (CoordinateType (0))
57 , left (CoordinateType (0))
58 , bottom (CoordinateType (0))
59 , right (CoordinateType (0))
62 template <
typename POINT_TYPE,
typename SIZE_TYPE>
67 constexpr Rect_Base<POINT_TYPE, SIZE_TYPE>::Rect_Base (CoordinateType newTop, CoordinateType newLeft, DistanceType newHeight, DistanceType newWidth)
70 , bottom (newTop + newHeight)
71 , right (newLeft + newWidth)
74 template <
typename POINT_TYPE,
typename SIZE_TYPE>
75 constexpr Rect_Base<POINT_TYPE, SIZE_TYPE>::Rect_Base (POINT_TYPE origin, SIZE_TYPE size)
78 , bottom (origin.v + size.v)
79 , right (origin.h + size.h)
82 template <
typename POINT_TYPE,
typename SIZE_TYPE>
87 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::CoordinateType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetTop ()
const
91 template <
typename POINT_TYPE,
typename SIZE_TYPE>
96 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::CoordinateType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetLeft ()
const
100 template <
typename POINT_TYPE,
typename SIZE_TYPE>
105 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::CoordinateType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetBottom ()
const
109 template <
typename POINT_TYPE,
typename SIZE_TYPE>
114 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::CoordinateType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetRight ()
const
118 template <
typename POINT_TYPE,
typename SIZE_TYPE>
123 inline bool Rect_Base<POINT_TYPE, SIZE_TYPE>::IsEmpty ()
const
125 return (right <= left or bottom <= top);
127 template <
typename POINT_TYPE,
typename SIZE_TYPE>
132 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::DistanceType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetHeight ()
const
134 Ensure (bottom >= top);
135 return (bottom - top);
137 template <
typename POINT_TYPE,
typename SIZE_TYPE>
142 inline typename Rect_Base<POINT_TYPE, SIZE_TYPE>::DistanceType Rect_Base<POINT_TYPE, SIZE_TYPE>::GetWidth ()
const
144 Ensure (right >= left);
145 return (right - left);
147 template <
typename POINT_TYPE,
typename SIZE_TYPE>
148 inline POINT_TYPE Rect_Base<POINT_TYPE, SIZE_TYPE>::GetTopLeft ()
const
150 return (POINT_TYPE (top, left));
152 template <
typename POINT_TYPE,
typename SIZE_TYPE>
153 inline POINT_TYPE Rect_Base<POINT_TYPE, SIZE_TYPE>::GetTopRight ()
const
155 return (POINT_TYPE (top, right));
157 template <
typename POINT_TYPE,
typename SIZE_TYPE>
158 inline POINT_TYPE Rect_Base<POINT_TYPE, SIZE_TYPE>::GetBotRight ()
const
160 return (POINT_TYPE (bottom, right));
162 template <
typename POINT_TYPE,
typename SIZE_TYPE>
163 inline POINT_TYPE Rect_Base<POINT_TYPE, SIZE_TYPE>::GetOrigin ()
const
165 return (POINT_TYPE (top, left));
167 template <
typename POINT_TYPE,
typename SIZE_TYPE>
168 inline SIZE_TYPE Rect_Base<POINT_TYPE, SIZE_TYPE>::GetSize ()
const
170 return (SIZE_TYPE (bottom - top, right - left));
172 template <
typename POINT_TYPE,
typename SIZE_TYPE>
173 inline bool Rect_Base<POINT_TYPE, SIZE_TYPE>::Contains (POINT_TYPE p)
const
175 return ((p >= GetTopLeft ()) and (p <= GetBotRight ()));
177 template <
typename POINT_TYPE,
typename SIZE_TYPE>
178 inline bool Rect_Base<POINT_TYPE, SIZE_TYPE>::Contains (Rect_Base<POINT_TYPE, SIZE_TYPE> r)
const
181 return (Contains (r.GetTopLeft ()) and Contains (r.GetBotRight ()));
183 template <
typename POINT_TYPE,
typename SIZE_TYPE>
184 inline void Rect_Base<POINT_TYPE, SIZE_TYPE>::SetOrigin (POINT_TYPE p)
189 template <
typename POINT_TYPE,
typename SIZE_TYPE>
190 inline void Rect_Base<POINT_TYPE, SIZE_TYPE>::SetTop (CoordinateType t)
194 template <
typename POINT_TYPE,
typename SIZE_TYPE>
195 inline void Rect_Base<POINT_TYPE, SIZE_TYPE>::SetLeft (CoordinateType l)
199 template <
typename POINT_TYPE,
typename SIZE_TYPE>
200 inline void Rect_Base<POINT_TYPE, SIZE_TYPE>::SetBottom (CoordinateType b)
204 template <
typename POINT_TYPE,
typename SIZE_TYPE>
205 inline void Rect_Base<POINT_TYPE, SIZE_TYPE>::SetRight (CoordinateType r)
209 template <
typename POINT_TYPE,
typename SIZE_TYPE>
210 inline const Rect_Base<POINT_TYPE, SIZE_TYPE>& Rect_Base<POINT_TYPE, SIZE_TYPE>::operator+= (
const POINT_TYPE& delta)
212 *
this = THIS_TYPE (GetTopLeft () + delta, GetSize ());
215 template <
typename POINT_TYPE,
typename SIZE_TYPE>
216 inline const Rect_Base<POINT_TYPE, SIZE_TYPE>& Rect_Base<POINT_TYPE, SIZE_TYPE>::operator-= (
const POINT_TYPE& delta)
218 *
this = THIS_TYPE (GetTopLeft () - delta, GetSize ());
221 template <
typename POINT_TYPE,
typename SIZE_TYPE>
226 inline const Rect_Base<POINT_TYPE, SIZE_TYPE>& Rect_Base<POINT_TYPE, SIZE_TYPE>::operator*= (
const Rect_Base<POINT_TYPE, SIZE_TYPE>& intersectWith)
228 POINT_TYPE topLeft = max (GetTopLeft (), intersectWith.GetTopLeft ());
229 POINT_TYPE botRight = min (GetBotRight (), intersectWith.GetBotRight ());
230 POINT_TYPE newSize = botRight - topLeft;
231 if (newSize >= Led_Point (0, 0)) {
232 *
this = THIS_TYPE (topLeft, SIZE_TYPE (newSize));
235 *
this = THIS_TYPE (0, 0, 0, 0);
239 template <
typename POINT_TYPE,
typename SIZE_TYPE>
240 inline bool Rect_Base<POINT_TYPE, SIZE_TYPE>::operator== (
const Rect_Base<POINT_TYPE, SIZE_TYPE>& rhs)
const
242 return ((GetLeft () == rhs.GetLeft ()) and (GetRight () == rhs.GetRight ()) and (GetTop () == rhs.GetTop ()) and
243 (GetBottom () == rhs.GetBottom ()));
251 constexpr inline TWIPS::TWIPS (
long v)
255 constexpr TWIPS::operator long ()
const
259 inline TWIPS& TWIPS::operator+= (
const TWIPS& rhs)
261 fValue += rhs.fValue;
264 inline TWIPS& TWIPS::operator-= (
const TWIPS& rhs)
266 fValue -= rhs.fValue;
269 inline TWIPS& TWIPS::operator*= (
double rhs)
271 fValue =
static_cast<long> (fValue * rhs);
274 inline TWIPS operator+ (
const TWIPS& lhs,
const TWIPS& rhs)
276 return TWIPS (
static_cast<long> (lhs) +
static_cast<long> (rhs));
278 inline TWIPS operator- (
const TWIPS& lhs,
const TWIPS& rhs)
280 return TWIPS (
static_cast<long> (lhs) -
static_cast<long> (rhs));
282 inline constexpr TWIPS TWIPS::kPoint = TWIPS{20};
283 inline constexpr TWIPS TWIPS::kInch = TWIPS{1440};
284 inline constexpr TWIPS TWIPS::kOneInch = TWIPS{1440};
286#if qStroika_Foundation_Common_Platform_Windows
292 inline FontObject::~FontObject ()
294 (void)DeleteObject ();
296 inline FontObject ::operator HFONT ()
const
300 inline int FontObject ::GetObject (
int nCount, LPVOID lpObject)
const
302 Assert (m_hObject !=
nullptr);
303 return ::GetObject (m_hObject, nCount, lpObject);
305 inline BOOL FontObject ::DeleteObject ()
307 if (m_hObject ==
nullptr)
311 return ::DeleteObject (h);
313 inline BOOL FontObject ::CreateFontIndirect (
const LOGFONT* lpLogFont)
315 return Attach (::CreateFontIndirect (lpLogFont));
317 inline BOOL FontObject ::Attach (HFONT hObject)
319 Assert (m_hObject ==
nullptr);
320 if (hObject ==
nullptr)
327#if qStroika_Foundation_Common_Platform_Windows
333 inline Brush::Brush (COLORREF crColor)
336 if (!Attach (::CreateSolidBrush (crColor)))
337 Foundation::Execution::Throw (bad_alloc{});
339 inline Brush::~Brush ()
341 (void)DeleteObject ();
343 inline Brush::operator HBRUSH ()
const
347 inline BOOL Brush::Attach (HBRUSH hObject)
349 Assert (m_hObject ==
nullptr);
350 if (hObject ==
nullptr)
355 inline BOOL Brush::DeleteObject ()
357 if (m_hObject ==
nullptr)
359 HBRUSH h = m_hObject;
361 return ::DeleteObject (h);
365#if qStroika_Frameworks_Led_SupportGDI
371 inline Region::Region ()
372#if qStroika_Foundation_Common_Platform_Windows
373 : fRgn{::CreateRectRgn (0, 0, 0, 0)}
376#if qStroika_Foundation_Common_Platform_Windows
377 Foundation::Execution::ThrowIfNull (fRgn);
380 inline Region::Region (
const Led_Rect& r)
381#if qStroika_Foundation_Common_Platform_Windows
382 : fRgn (::CreateRectRgn (r.GetLeft (), r.GetTop (), r.GetRight (), r.GetBottom ()))
385 Require (r.GetHeight () >= 0);
386 Require (r.GetWidth () >= 0);
387#if qStroika_Foundation_Common_Platform_Windows
388 Foundation::Execution::ThrowIfNull (fRgn);
390 Assert (GetBoundingRect () == r or (GetBoundingRect ().IsEmpty () and r.IsEmpty ()));
392 inline Region::Region (
const Region& from)
393#if qStroika_Foundation_Common_Platform_Windows
394 : fRgn (::CreateRectRgn (0, 0, 0, 0))
397#if qStroika_Foundation_Common_Platform_Windows
398 Foundation::Execution::ThrowIfNull (fRgn);
400#if qStroika_Foundation_Common_Platform_Windows
401 Verify (::CombineRgn (fRgn, from, from, RGN_COPY) != ERROR);
404 inline const Region& Region::operator= (
const Region& rhs)
406#if qStroika_Foundation_Common_Platform_Windows
407 Verify (::CombineRgn (fRgn, rhs, rhs, RGN_COPY) != ERROR);
409#if qStroika_Foundation_Common_Platform_Windows
410 Foundation::Execution::ThrowIfNull (fRgn);
414 inline Region::~Region ()
416#if qStroika_Foundation_Common_Platform_Windows
417 if (fRgn !=
nullptr) {
418 ::DeleteObject (fRgn);
422 inline bool Region::IsEmpty ()
const
424#if qStroika_Foundation_Common_Platform_Windows
430 inline Led_Rect Region::GetBoundingRect ()
const
432#if qStroika_Foundation_Common_Platform_Windows
435 int tmp = ::GetRgnBox (fRgn, &r);
439 Assert (AsLedRect (r) == Led_Rect (0, 0, 0, 0));
442 return AsLedRect (r);
445 return Led_Rect (0, 0, 0, 0);
448 inline Region operator* (
const Region& lhs,
const Region& rhs)
451#if qStroika_Foundation_Common_Platform_Windows
452 Verify (::CombineRgn (result, lhs, rhs, RGN_AND) != ERROR);
456 inline Region operator+ (
const Region& lhs,
const Region& rhs)
459#if qStroika_Foundation_Common_Platform_Windows
460 Verify (::CombineRgn (result, lhs, rhs, RGN_OR) != ERROR);
464 inline Led_Rect operator* (
const Led_Rect& lhs,
const Led_Rect& rhs)
469#if qStroika_Foundation_Common_Platform_Windows
470 inline Region::operator HRGN ()
const
474 inline int Region::CombineRgn (Region* pRgn1, Region* pRgn2,
int nCombineMode)
476 Require (pRgn1 !=
nullptr);
477 Require (pRgn2 !=
nullptr);
478 Require (fRgn !=
nullptr);
479 return ::CombineRgn (fRgn, pRgn1->fRgn, pRgn2->fRgn, nCombineMode);
481 inline BOOL Region::PtInRegion (
int x,
int y)
const
483 Require (fRgn !=
nullptr);
484 return ::PtInRegion (fRgn, x, y);
486 inline BOOL Region::PtInRegion (POINT point)
const
488 Require (fRgn !=
nullptr);
489 return ::PtInRegion (fRgn, point.x, point.y);
492 inline BOOL Region::DeleteObject ()
498 return ::DeleteObject (r);
508#if qStroika_Frameworks_Led_SupportGDI
509 inline DistanceType TabStopList::ComputeTabStopAfterPosition (Tablet* tablet, DistanceType afterPos)
const
512 return tablet->CvtFromTWIPSH (ComputeTabStopAfterPosition (tablet->CvtToTWIPSH (afterPos)));
516#if qStroika_Foundation_Common_Platform_Windows
522 inline Bitmap::~Bitmap ()
524 if (m_hObject !=
nullptr) {
525 ::DeleteObject (m_hObject);
528 inline void Bitmap::DeleteObject ()
530 if (m_hObject !=
nullptr) {
531 ::DeleteObject (m_hObject);
535 inline Bitmap::operator HBITMAP ()
const
539 inline Led_Size Bitmap::GetImageSize ()
const
547#if qStroika_Frameworks_Led_SupportGDI
553#if qStroika_Foundation_Common_Platform_Windows
554 inline Tablet::operator HDC ()
const
564 inline CoordinateType Tablet::CvtFromTWIPSV (TWIPS from)
const
566#if qStroika_Foundation_Common_Platform_Windows
567 if (fLogPixelsV == 0) {
568 fLogPixelsV = GetDeviceCaps (LOGPIXELSY);
571 Verify (::GetViewportOrgEx (m_hAttribDC, &vpOrg));
573 Verify (::GetWindowOrgEx (m_hAttribDC, &wOrg));
575 x.y += ::MulDiv (from, fLogPixelsV, 1440);
576 Verify (::DPtoLP (m_hAttribDC, &x, 1));
578 Assert (x.x == wOrg.x);
582 return from * Globals::Get ().GetMainScreenLogPixelsV () / 1440;
591 inline CoordinateType Tablet::CvtFromTWIPSH (TWIPS from)
const
593#if qStroika_Foundation_Common_Platform_Windows
594 if (fLogPixelsH == 0) {
595 fLogPixelsH = GetDeviceCaps (LOGPIXELSX);
598 Verify (::GetViewportOrgEx (m_hAttribDC, &vpOrg));
600 Verify (::GetWindowOrgEx (m_hAttribDC, &wOrg));
602 x.x += ::MulDiv (from, fLogPixelsH, 1440);
603 Verify (::DPtoLP (m_hAttribDC, &x, 1));
605 Assert (x.y == wOrg.y);
609 return from * Globals::Get ().GetMainScreenLogPixelsH () / 1440;
618 inline TWIPS Tablet::CvtToTWIPSV (CoordinateType from)
const
620#if qStroika_Foundation_Common_Platform_Windows
621 if (fLogPixelsV == 0) {
622 fLogPixelsV = GetDeviceCaps (LOGPIXELSY);
625 Verify (::GetViewportOrgEx (m_hAttribDC, &vpOrg));
627 Verify (::GetWindowOrgEx (m_hAttribDC, &wOrg));
630 Verify (::LPtoDP (m_hAttribDC, &x, 1));
632 Assert (x.x == wOrg.x);
633 return TWIPS (::MulDiv (x.y, 1440, fLogPixelsV));
635 return TWIPS (from * 1440 / Globals::Get ().GetMainScreenLogPixelsV ());
644 inline TWIPS Tablet::CvtToTWIPSH (CoordinateType from)
const
646#if qStroika_Foundation_Common_Platform_Windows
647 if (fLogPixelsH == 0) {
648 fLogPixelsH = GetDeviceCaps (LOGPIXELSX);
651 Verify (::GetViewportOrgEx (m_hAttribDC, &vpOrg));
653 Verify (::GetWindowOrgEx (m_hAttribDC, &wOrg));
656 Verify (::LPtoDP (m_hAttribDC, &x, 1));
658 Assert (x.y == vpOrg.y);
659 return TWIPS (::MulDiv (x.x, 1440, fLogPixelsH));
661 return TWIPS (from * 1440 / Globals::Get ().GetMainScreenLogPixelsH ());
665#if qStroika_Foundation_Common_Platform_Windows
666 inline BOOL Tablet::BitBlt (
int x,
int y,
int nWidth,
int nHeight, Tablet* pSrcDC,
int xSrc,
int ySrc, DWORD dwRop)
669 return ::BitBlt (m_hDC, x, y, nWidth, nHeight, pSrcDC->m_hDC, xSrc, ySrc, dwRop);
671 inline BOOL Tablet::CreateCompatibleDC (Tablet* pDC)
673 Assert (m_hDC ==
nullptr);
674 Assert (m_hAttribDC ==
nullptr);
676 m_hDC = ::CreateCompatibleDC (pDC ==
nullptr ?
nullptr : pDC->m_hDC);
677 if (m_hDC ==
nullptr)
684 inline COLORREF Tablet::SetTextColor (COLORREF crColor)
686 Assert (m_hDC !=
nullptr);
687 COLORREF crRetVal = CLR_INVALID;
689 if (m_hDC != m_hAttribDC)
690 crRetVal = ::SetTextColor (m_hDC, crColor);
691 if (m_hAttribDC !=
nullptr)
692 crRetVal = ::SetTextColor (m_hAttribDC, crColor);
695 inline COLORREF Tablet::SetBkColor (COLORREF crColor)
697 Assert (m_hDC !=
nullptr);
698 COLORREF crRetVal = CLR_INVALID;
700 if (m_hDC != m_hAttribDC)
701 crRetVal = ::SetBkColor (m_hDC, crColor);
702 if (m_hAttribDC !=
nullptr)
703 crRetVal = ::SetBkColor (m_hAttribDC, crColor);
706 inline HWND Tablet::GetWindow ()
const
708 Assert (m_hDC !=
nullptr);
709 return ::WindowFromDC (m_hDC);
711 inline BOOL Tablet::IsPrinting ()
const
715 inline BOOL Tablet::RoundRect (
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
717 Assert (m_hDC !=
nullptr);
718 return ::RoundRect (m_hDC, x1, y1, x2, y2, x3, y3);
720 inline BOOL Tablet::TextOut (
int x,
int y, LPCTSTR lpszString,
int nCount)
722 Assert (m_hDC !=
nullptr);
723 return ::TextOut (m_hDC, x, y, lpszString, nCount);
725 inline int Tablet::SetBkMode (
int nBkMode)
727 Assert (m_hDC !=
nullptr);
730 if (m_hDC != m_hAttribDC)
731 nRetVal = ::SetBkMode (m_hDC, nBkMode);
732 if (m_hAttribDC !=
nullptr)
733 nRetVal = ::SetBkMode (m_hAttribDC, nBkMode);
736 inline unsigned int Tablet::SetTextAlign (
unsigned int nTextAlign)
738 Assert (m_hDC !=
nullptr);
739 unsigned int nRetVal = 0;
741 if (m_hDC != m_hAttribDC)
742 nRetVal = ::SetTextAlign (m_hDC, nTextAlign);
743 if (m_hAttribDC !=
nullptr)
744 nRetVal = ::SetTextAlign (m_hAttribDC, nTextAlign);
747 inline SIZE Tablet::GetWindowExt ()
const
749 Assert (m_hAttribDC !=
nullptr);
751 Verify (::GetWindowExtEx (m_hAttribDC, &size));
754 inline SIZE Tablet::GetViewportExt ()
const
756 Assert (m_hAttribDC !=
nullptr);
758 Verify (::GetViewportExtEx (m_hAttribDC, &size));
761 inline BOOL Tablet::Rectangle (
int x1,
int y1,
int x2,
int y2)
763 Assert (m_hDC !=
nullptr);
764 return ::Rectangle (m_hDC, x1, y1, x2, y2);
766 inline BOOL Tablet::Rectangle (
const RECT& r)
768 Assert (m_hDC !=
nullptr);
769 return ::Rectangle (m_hDC, r.left, r.top, r.right, r.bottom);
771 inline BOOL Tablet::Rectangle (LPCRECT lpRect)
773 Assert (m_hDC !=
nullptr);
774 return ::Rectangle (m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
776 inline BOOL Tablet::GetTextMetrics (LPTEXTMETRIC lpMetrics)
const
778 Assert (m_hAttribDC !=
nullptr);
779 return ::GetTextMetrics (m_hAttribDC, lpMetrics);
781 inline HBITMAP Tablet::SelectObject (HBITMAP hBitmap)
783 Assert (m_hDC !=
nullptr);
784 return (HBITMAP)::SelectObject (m_hDC, hBitmap);
787 inline HFONT Tablet::SelectObject (HFONT hFont)
789 Assert (m_hDC !=
nullptr);
790 return (HFONT)::SelectObject (m_hDC, hFont);
793 inline POINT Tablet::SetWindowOrg (
int x,
int y)
795 Assert (m_hDC !=
nullptr);
797 memset (&point, 0,
sizeof (point));
798 if (m_hDC != m_hAttribDC)
799 Verify (::SetWindowOrgEx (m_hDC, x, y, &point));
800 if (m_hAttribDC !=
nullptr)
801 Verify (::SetWindowOrgEx (m_hAttribDC, x, y, &point));
804 inline int Tablet::GetDeviceCaps (
int nIndex)
const
806 Assert (m_hAttribDC !=
nullptr);
807 return ::GetDeviceCaps (m_hAttribDC, nIndex);
809 inline BOOL Tablet::Attach (HDC hDC, Tablet::OwnDCControl ownsDC)
811 Assert (m_hDC ==
nullptr);
812 Assert (m_hAttribDC ==
nullptr);
822 inline HDC Tablet::Detach ()
825 m_hAttribDC =
nullptr;
830 inline void Tablet::MoveTo (
const Led_Point& to)
832#if qStroika_Foundation_Common_Platform_Windows
833 Assert (m_hDC !=
nullptr);
834 Verify (::MoveToEx (m_hDC, to.h, to.v,
nullptr));
835#elif qStroika_FeatureSupported_XWindows
836 fCurDrawLineLoc = to;
839 inline void Tablet::LineTo (
const Led_Point& to)
841#if qStroika_Foundation_Common_Platform_Windows
842 Assert (m_hDC !=
nullptr);
843 Verify (::LineTo (m_hDC, to.h, to.v));
844#elif qStroika_FeatureSupported_XWindows
845 ::XDrawLine (fDisplay, fDrawable, fGC, fCurDrawLineLoc.h, fCurDrawLineLoc.v, to.h, to.v);
846 fCurDrawLineLoc = to;
849 inline Region Tablet::GetClip ()
const
852#if qStroika_Foundation_Common_Platform_Windows
853 int r = ::GetClipRgn (*
this, result);
854 Assert (r == 0 or r == 1 or r == -1);
856#if !qInternalErrorWithStaticRegionDeclaredInFunction
859 Region kWideOpened = Region (Led_Rect (-10000, -10000, 20000, 20000));
860 result = kWideOpened;
867 inline bool Tablet::GetClip (Region* r)
const
870#if qStroika_Foundation_Common_Platform_Windows
871 int res = ::GetClipRgn (*
this, *r);
872 Assert (res == 0 or res == 1 or res == -1);
882 inline void Tablet::SetClip ()
884#if qStroika_Foundation_Common_Platform_Windows
885 Verify (::SelectClipRgn (*
this,
nullptr) != ERROR);
886#elif qStroika_FeatureSupported_XWindows
887 static Led_Rect kWideOpened = Led_Rect (-10000, -10000, 20000, 20000);
888 XRectangle xrectangle = AsXRect (kWideOpened);
889 ::XSetClipRectangles (fDisplay, fGC, 0, 0, &xrectangle, 1, Unsorted);
894 inline void Tablet::SetClip (
const Led_Rect& clipTo)
896#if qStroika_Foundation_Common_Platform_Windows
897 Verify (::SelectClipRgn (*
this, Region (clipTo)) != ERROR);
898 Ensure (GetClip ().GetBoundingRect () == clipTo);
899#elif qStroika_FeatureSupported_XWindows
900 XRectangle xrectangle = AsXRect (clipTo);
901 ::XSetClipRectangles (fDisplay, fGC, 0, 0, &xrectangle, 1, Unsorted);
906 inline void Tablet::SetClip (
const Region& clipTo)
908#if qStroika_Foundation_Common_Platform_Windows
909 Verify (::SelectClipRgn (*
this, clipTo) != ERROR);
916#if qStroika_Frameworks_Led_SupportGDI
922 inline Globals& Globals::Get ()
924 if (sThe ==
nullptr) {
925 sThe =
new Globals ();
929 inline DistanceType Globals::GetMainScreenLogPixelsH ()
const
933 inline DistanceType Globals::GetMainScreenLogPixelsV ()
const
944 inline Led_Rect operator- (
const Led_Rect& lhs,
const Led_Point& rhs)
946 return Led_Rect (lhs.GetTop () - rhs.v, lhs.GetLeft () - rhs.h, lhs.GetHeight (), lhs.GetWidth ());
948 inline Led_Rect operator+ (Led_Point p, Led_Rect r)
950 return (Led_Rect (r.GetTop () + p.v, r.GetLeft () + p.h, r.GetHeight (), r.GetWidth ()));
952 inline Led_Rect operator+ (Led_Rect r, Led_Point p)
954 return (Led_Rect (r.GetTop () + p.v, r.GetLeft () + p.h, r.GetHeight (), r.GetWidth ()));
962 inline bool Intersect (
const Led_Rect& lhs,
const Led_Rect& rhs)
964 if (rhs.GetTop () >= lhs.GetBottom ()) {
967 else if (rhs.GetBottom () <= lhs.GetTop ()) {
970 else if (rhs.GetLeft () >= lhs.GetRight ()) {
973 else if (rhs.GetRight () <= lhs.GetLeft ()) {
977 if (rhs.GetHeight () == 0 or rhs.GetWidth () == 0 or lhs.GetHeight () == 0 or lhs.GetWidth () == 0) {
982#if qStroika_Frameworks_Led_SupportGDI
983 inline bool Intersect (
const Led_Rect& lhs,
const Region& rhs)
985#if qStroika_Foundation_Common_Platform_Windows
988 return result.CombineRgn (&lhsRgn,
const_cast<Region*
> (&rhs), RGN_AND) != NULLREGION;
991 inline bool Intersect (
const Region& lhs,
const Led_Rect& rhs)
993#if qStroika_Foundation_Common_Platform_Windows
996 return result.CombineRgn (
const_cast<Region*
> (&lhs), &rhsRgn, RGN_AND) != NULLREGION;
999 inline bool Intersect (
const Region& lhs,
const Region& rhs)
1001#if qStroika_Foundation_Common_Platform_Windows
1003 return result.CombineRgn (
const_cast<Region*
> (&lhs),
const_cast<Region*
> (&rhs), RGN_AND) != NULLREGION;
1013 inline Led_Rect
Intersection (
const Led_Rect& lhs,
const Led_Rect& rhs)
1024 inline Led_Size operator+ (Led_Size lhs, Led_Size rhs)
1026 return Led_Size (lhs.v + rhs.v, lhs.h + rhs.h);
1028 inline Led_Size operator* (
int lhs, Led_Size rhs)
1030 return Led_Size (lhs * rhs.v, lhs * rhs.h);
1043 inline Led_Rect InsetRect (
const Led_Rect& r,
int vBy,
int hBy)
1045 return Led_Rect (r.GetTop () + vBy, r.GetLeft () + hBy, max (0L, CoordinateType (r.GetHeight ()) - 2 * vBy),
1046 max (0L, CoordinateType (r.GetWidth ()) - 2 * hBy));
1059 inline Led_Rect EnsureRectInRect (
const Led_Rect& r, Led_Rect enlosingR)
1061 DistanceType winWidth = min (r.GetWidth (), enlosingR.GetWidth ());
1062 DistanceType winHeight = min (r.GetHeight (), enlosingR.GetHeight ());
1063 CoordinateType winLeft = max (r.GetLeft (), enlosingR.GetLeft ());
1064 CoordinateType winTop = max (r.GetTop (), enlosingR.GetTop ());
1066 DISABLE_COMPILER_MSC_WARNING_START (4018)
1067 if ((winLeft + winWidth) > enlosingR.GetRight ()) {
1068 winLeft = enlosingR.GetRight () - winWidth;
1070 if ((winTop + winHeight) > enlosingR.GetBottom ()) {
1071 winTop = enlosingR.GetBottom () - winHeight;
1073 DISABLE_COMPILER_MSC_WARNING_END (4018)
1074 return Led_Rect (winTop, winLeft, winHeight, winWidth);
1077#if qStroika_Frameworks_Led_SupportGDI
1088 inline Led_Rect EnsureRectOnScreen ([[maybe_unused]] Led_Rect& r)
1090#if qStroika_Foundation_Common_Platform_Windows
1093 memset (&rWorkArea, 0,
sizeof (rWorkArea));
1094 BOOL bResult = SystemParametersInfo (SPI_GETWORKAREA,
sizeof (RECT), &rWorkArea, 0);
1096 rWorkArea.left = rWorkArea.top = 0;
1097 rWorkArea.right = GetSystemMetrics (SM_CXSCREEN);
1098 rWorkArea.bottom = GetSystemMetrics (SM_CYSCREEN);
1100 return EnsureRectInRect (r, AsLedRect (rWorkArea));
1103 return Led_Rect (0, 0, 0, 0);
1113#if qStroika_Foundation_Common_Platform_Windows
1114 inline Led_Point AsLedPoint (POINT p)
1116 return Led_Point (p.y, p.x);
1118 inline POINT AsPOINT (Led_Point p)
1125 inline Led_Rect AsLedRect (RECT r)
1127 return Led_Rect (r.top, r.left, r.bottom - r.top, r.right - r.left);
1129 inline RECT AsRECT (Led_Rect r)
1132 newR.top = r.GetTop ();
1133 newR.left = r.GetLeft ();
1134 newR.bottom = r.GetBottom ();
1135 newR.right = r.GetRight ();
1138 inline SIZE AsSIZE (Led_Size s)
1145 inline Led_Size AsLedSize (SIZE s)
1152#elif qStroika_FeatureSupported_XWindows
1153 inline Led_Rect AsLedRect (
const XRectangle& r)
1155 return Led_Rect (r.y, r.x, r.height, r.width);
1157 inline XRectangle AsXRect (
const Led_Rect& r)
1160 newR.x = r.GetLeft ();
1161 newR.y = r.GetTop ();
1162 newR.height = r.GetHeight ();
1163 newR.width = r.GetWidth ();
1168#if qStroika_Frameworks_Led_SupportGDI
1174 inline TWIPS Led_CvtScreenPixelsToTWIPSV (CoordinateType from)
1176#if qStroika_Foundation_Common_Platform_Windows
1177 return TWIPS (::MulDiv (from, 1440, Globals::Get ().GetMainScreenLogPixelsV ()));
1179 return TWIPS (from * 1440 / Globals::Get ().GetMainScreenLogPixelsV ());
1188 inline TWIPS Led_CvtScreenPixelsToTWIPSH (CoordinateType from)
1190#if qStroika_Foundation_Common_Platform_Windows
1191 return TWIPS (::MulDiv (from, 1440, Globals::Get ().GetMainScreenLogPixelsH ()));
1193 return TWIPS (from * 1440 / Globals::Get ().GetMainScreenLogPixelsH ());
1201 inline CoordinateType Led_CvtScreenPixelsFromTWIPSV (TWIPS from)
1203#if qStroika_Foundation_Common_Platform_Windows
1204 return ::MulDiv (from, Globals::Get ().GetMainScreenLogPixelsV (), 1440);
1206 return TWIPS{from * Globals::Get ().GetMainScreenLogPixelsV () / 1440};
1214 inline CoordinateType Led_CvtScreenPixelsFromTWIPSH (TWIPS from)
1216#if qStroika_Foundation_Common_Platform_Windows
1217 return ::MulDiv (from, Globals::Get ().GetMainScreenLogPixelsH (), 1440);
1219 return TWIPS{from * Globals::Get ().GetMainScreenLogPixelsH () / 1440};
1224#if qStroika_Frameworks_Led_SupportGDI
1230#if qStroika_Foundation_Common_Platform_Windows
1231 inline FontMetrics::FontMetrics (
const TEXTMETRIC& from)
1232 : fPlatformSpecific (from)
1235#elif qStroika_FeatureSupported_XWindows
1236 inline FontMetrics::FontMetrics (
const FontMetrics::PlatformSpecific& from)
1237 : fPlatformSpecific (from)
1241 inline DistanceType FontMetrics::GetAscent ()
const
1243#if qStroika_Foundation_Common_Platform_Windows
1244 return (fPlatformSpecific.tmAscent);
1245#elif qStroika_FeatureSupported_XWindows
1246 return fPlatformSpecific.fAscent;
1249 inline DistanceType FontMetrics::GetDescent ()
const
1251#if qStroika_Foundation_Common_Platform_Windows
1252 return (fPlatformSpecific.tmDescent);
1253#elif qStroika_FeatureSupported_XWindows
1254 return fPlatformSpecific.fDescent;
1257 inline DistanceType FontMetrics::GetLeading ()
const
1259#if qStroika_Foundation_Common_Platform_Windows
1260 return (fPlatformSpecific.tmExternalLeading);
1261#elif qStroika_FeatureSupported_XWindows
1262 return (fPlatformSpecific.fLeading);
1265 inline DistanceType FontMetrics::GetHeight ()
const
1267#if qStroika_Foundation_Common_Platform_Windows
1268 Assert (fPlatformSpecific.tmHeight >= 0);
1269 Assert (GetAscent () + GetDescent () == DistanceType (fPlatformSpecific.tmHeight));
1271 return (GetAscent () + GetDescent ());
1273 inline DistanceType FontMetrics::GetLineHeight ()
const
1275 return (GetAscent () + GetDescent () + GetLeading ());
1277 inline nonvirtual DistanceType FontMetrics::GetMaxCharacterWidth ()
const
1279#if qStroika_Foundation_Common_Platform_MacOS
1280 return fPlatformSpecific.widMax;
1281#elif qStroika_Foundation_Common_Platform_Windows
1282 return fPlatformSpecific.tmMaxCharWidth;
1283#elif qStroika_FeatureSupported_XWindows
1284 return fPlatformSpecific.fMaxCharWidth;
1287#if qStroika_Foundation_Common_Platform_Windows
1288 inline nonvirtual DistanceType FontMetrics::GetAveCharacterWidth ()
const
1290 return fPlatformSpecific.tmAveCharWidth;
1293#if qStroika_Foundation_Common_Platform_MacOS
1294 inline FontMetrics::operator
const FontInfo* ()
const
1296 return &fPlatformSpecific;
1298 inline FontMetrics::operator FontInfo* ()
1300 return (&fPlatformSpecific);
1302#elif qStroika_Foundation_Common_Platform_Windows
1303 inline FontMetrics::operator
const TEXTMETRIC* ()
const
1305 return &fPlatformSpecific;
1307 inline FontMetrics::operator TEXTMETRIC* ()
1309 return &fPlatformSpecific;
1319 constexpr inline Color::Color (ColorValue redValue, ColorValue greenValue, ColorValue blueValue)
1321 , fGreen{greenValue}
1325#if qStroika_Foundation_Common_Platform_Windows
1326 inline Color::Color (COLORREF colorRef)
1327 : fRed (static_cast<ColorValue> (GetRValue (colorRef)) << 8)
1328 , fGreen (static_cast<ColorValue> (GetGValue (colorRef)) << 8)
1329 , fBlue (static_cast<ColorValue> (GetBValue (colorRef)) << 8)
1333 inline Color::ColorValue Color::GetRed ()
const
1337 inline Color::ColorValue Color::GetGreen ()
const
1341 inline Color::ColorValue Color::GetBlue ()
const
1345#if qStroika_Foundation_Common_Platform_Windows
1346 inline COLORREF Color::GetOSRep ()
const
1348 return RGB (fRed >> 8, fGreen >> 8, fBlue >> 8);
1351 inline Color operator* (Color lhs,
float factor)
1353 using CV = Color::ColorValue;
1354 return Color (
static_cast<CV
> (lhs.GetRed () * factor),
static_cast<CV
> (lhs.GetGreen () * factor),
static_cast<CV
> (lhs.GetBlue () * factor));
1356 inline Color operator/ (Color lhs,
float divBy)
1358 return Color (
static_cast<Color::ColorValue
> (lhs.GetRed () / divBy),
static_cast<Color::ColorValue
> (lhs.GetGreen () / divBy),
1359 static_cast<Color::ColorValue
> (lhs.GetBlue () / divBy));
1361 inline Color operator+ (Color lhs, Color rhs)
1363 return Color (lhs.GetRed () + rhs.GetRed (), lhs.GetGreen () + rhs.GetGreen (), lhs.GetBlue () + rhs.GetBlue ());
1365 inline Color operator- (Color lhs, Color rhs)
1367 return Color (lhs.GetRed () - rhs.GetRed (), lhs.GetGreen () - rhs.GetGreen (), lhs.GetBlue () - rhs.GetBlue ());
1369 inline unsigned int Distance_Squared (Color lhs, Color rhs)
1371 int rDiff =
static_cast<int> (lhs.GetRed ()) -
static_cast<int> (rhs.GetRed ());
1372 int gDiff =
static_cast<int> (lhs.GetGreen ()) -
static_cast<int> (rhs.GetGreen ());
1373 int bDiff =
static_cast<int> (lhs.GetBlue ()) -
static_cast<int> (rhs.GetBlue ());
1374 unsigned int sum = rDiff * rDiff + gDiff * gDiff + bDiff * bDiff;
1377 inline unsigned int Distance (Color lhs, Color rhs)
1379 return static_cast<unsigned int> (::sqrt (
static_cast<float> (Distance_Squared (lhs, rhs))));
1381#if qStroika_Foundation_Common_Platform_Windows
1382 inline unsigned int Distance_Squared (COLORREF lhs, COLORREF rhs)
1384 int rDiff =
static_cast<int> (GetRValue (lhs)) -
static_cast<int> (GetRValue (rhs));
1385 int gDiff =
static_cast<int> (GetGValue (lhs)) -
static_cast<int> (GetGValue (rhs));
1386 int bDiff =
static_cast<int> (GetBValue (lhs)) -
static_cast<int> (GetBValue (rhs));
1387 unsigned int sum = rDiff * rDiff + gDiff * gDiff + bDiff * bDiff;
1395 struct less<Stroika::Frameworks::Led::Color> {
1398 if (_Left.GetRed () < _Right.GetRed ()) {
1401 else if (_Left.GetRed () == _Right.GetRed ()) {
1402 if (_Left.GetGreen () < _Right.GetGreen ()) {
1405 else if (_Left.GetGreen () == _Right.GetGreen ()) {
1406 return (_Left.GetBlue () < _Right.GetBlue ());
1414namespace Stroika::Frameworks::Led {
1415#if qStroika_Foundation_Common_Platform_Windows
1416 inline Pen::Pen (
int nPenStyle,
int nWidth, COLORREF crColor)
1417 : m_hObject{nullptr}
1419 if (!Attach (::CreatePen (nPenStyle, nWidth, crColor)))
1420 Foundation::Execution::Throw (bad_alloc{});
1424 (void)DeleteObject ();
1426 inline Pen::operator HPEN ()
const
1430 inline BOOL Pen::Attach (HPEN hObject)
1432 Assert (m_hObject ==
nullptr);
1433 if (hObject ==
nullptr)
1435 m_hObject = hObject;
1438 inline BOOL Pen::DeleteObject ()
1440 if (m_hObject ==
nullptr)
1443 m_hObject =
nullptr;
1444 return ::DeleteObject (h);
1449namespace Stroika::Frameworks::Led {
1455 constexpr LineSpacing::LineSpacing (Rule rule)
1458 Require (rule == eSingleSpace or rule == eOnePointFiveSpace or rule == eDoubleSpace);
1460 constexpr LineSpacing::LineSpacing (Rule rule, TWIPS twips)
1462 , fArg{static_cast<unsigned> (twips)}
1464 Require (rule == eAtLeastTWIPSSpacing or rule == eExactTWIPSSpacing);
1466 constexpr LineSpacing::LineSpacing (Rule rule,
unsigned lineCount)
1470 Require (rule == eExactLinesSpacing);
1471 switch (lineCount) {
1473 fRule = eSingleSpace;
1476 fRule = eOnePointFiveSpace;
1479 fRule = eDoubleSpace;
1483 constexpr bool LineSpacing::operator== (
const LineSpacing& rhs)
const
1485 if (fRule != rhs.fRule) {
1488 if (fRule == LineSpacing::eAtLeastTWIPSSpacing or fRule == LineSpacing::eExactTWIPSSpacing or fRule == LineSpacing::eExactLinesSpacing) {
1489 if (fArg != rhs.fArg) {
1501#if qStroika_Foundation_Common_Platform_Windows
1502 inline FontSpecification::FontNameSpecifier::FontNameSpecifier ()
1513 inline FontSpecification::FontSpecification (
const IncrementalFontSpecification& from)
1514#if qStroika_Foundation_Common_Platform_Windows
1515 : fFontInfo (((
const FontSpecification&)from).fFontInfo)
1517 : fFontFamily (from.fFontFamily)
1518 , fBold (from.fBold)
1519 , fItalics (from.fItalics)
1520 , fUnderline (from.fUnderline)
1521 , fFontSize (from.fFontSize)
1523 , fSubOrSuperScript (((
const FontSpecification&)from).fSubOrSuperScript)
1524 , fTextColor (((
const FontSpecification&)from).fTextColor)
1532 inline SDKString FontSpecification::GetFontName ()
const
1534#if qStroika_Foundation_Common_Platform_Windows
1535 return fFontInfo.lfFaceName;
1537 return fFontFamily.AsSDKString ();
1541 inline FontSpecification::FontNameSpecifier FontSpecification::GetFontNameSpecifier ()
const
1543#if qStroika_Foundation_Common_Platform_Windows
1544 return fFontInfo.lfFaceName;
1556 inline bool FontSpecification::GetStyle_Plain ()
const
1558 if (fSubOrSuperScript != eNoSubOrSuperscript) {
1561#if qStroika_Foundation_Common_Platform_Windows
1562 return (fFontInfo.lfItalic ==
false and fFontInfo.lfWeight <= FW_NORMAL and fFontInfo.lfUnderline ==
false and fFontInfo.lfStrikeOut ==
false);
1564 return not fBold and not fItalics and not fUnderline;
1572 inline void FontSpecification::SetStyle_Plain ()
1574 fSubOrSuperScript = eNoSubOrSuperscript;
1575#if qStroika_Foundation_Common_Platform_Windows
1576 fFontInfo.lfItalic =
false;
1577 fFontInfo.lfWeight = FW_NORMAL;
1578 fFontInfo.lfUnderline =
false;
1579 fFontInfo.lfStrikeOut =
false;
1580#elif qStroika_FeatureSupported_XWindows
1586 inline bool FontSpecification::GetStyle_Bold ()
const
1588#if qStroika_Foundation_Common_Platform_Windows
1589 return fFontInfo.lfWeight > FW_NORMAL;
1594 inline void FontSpecification::SetStyle_Bold (
bool isBold)
1596#if qStroika_Foundation_Common_Platform_Windows
1597 fFontInfo.lfWeight = isBold ? FW_BOLD : FW_NORMAL;
1598#elif qStroika_FeatureSupported_XWindows
1602 inline bool FontSpecification::GetStyle_Italic ()
const
1604#if qStroika_Foundation_Common_Platform_Windows
1605 return !!fFontInfo.lfItalic;
1610 inline void FontSpecification::SetStyle_Italic (
bool isItalic)
1612#if qStroika_Foundation_Common_Platform_Windows
1613 fFontInfo.lfItalic = isItalic;
1615 fItalics = isItalic;
1618 inline bool FontSpecification::GetStyle_Underline ()
const
1620#if qStroika_Foundation_Common_Platform_Windows
1621 return !!fFontInfo.lfUnderline;
1626 inline void FontSpecification::SetStyle_Underline (
bool isUnderline)
1628#if qStroika_Foundation_Common_Platform_Windows
1629 fFontInfo.lfUnderline = isUnderline;
1630#elif qStroika_FeatureSupported_XWindows
1631 fUnderline = isUnderline;
1634 inline FontSpecification::SubOrSuperScript FontSpecification::GetStyle_SubOrSuperScript ()
const
1636 return fSubOrSuperScript;
1638 inline void FontSpecification::SetStyle_SubOrSuperScript (SubOrSuperScript subOrSuperScript)
1640 fSubOrSuperScript = subOrSuperScript;
1642#if qStroika_Foundation_Common_Platform_Windows
1643 inline bool FontSpecification::GetStyle_Strikeout ()
const
1645 return !!fFontInfo.lfStrikeOut;
1647 inline void FontSpecification::SetStyle_Strikeout (
bool isStrikeout)
1649 fFontInfo.lfStrikeOut = isStrikeout;
1653 inline FontSpecification::FontSize FontSpecification::GetPointSize ()
const
1655#if qStroika_Foundation_Common_Platform_Windows
1656 if (fFontInfo.lfHeight >= 0) {
1660 WindowDC screenDC (
nullptr);
1662 Verify (font.CreateFontIndirect (&fFontInfo));
1663 HFONT oldFont = screenDC.SelectObject (font);
1665 screenDC.GetTextMetrics (&tms);
1666 screenDC.SelectObject (oldFont);
1667 return (
unsigned short)::MulDiv (tms.tmHeight, 72, Globals::Get ().GetMainScreenLogPixelsV ());
1670 return static_cast<unsigned short> (::MulDiv (-fFontInfo.lfHeight, 72, Globals::Get ().GetMainScreenLogPixelsV ()));
1676 inline void FontSpecification::SetPointSize (FontSize pointSize)
1678#if qStroika_Foundation_Common_Platform_Windows
1679 fFontInfo.lfHeight = ::MulDiv (-
long (pointSize), Globals::Get ().GetMainScreenLogPixelsV (), 72);
1681 fFontSize = pointSize;
1684#if qStroika_Foundation_Common_Platform_Windows
1685 inline long FontSpecification::PeekAtTMHeight ()
const
1687 return fFontInfo.lfHeight;
1689 inline void FontSpecification::PokeAtTMHeight (
long tmHeight)
1691 fFontInfo.lfHeight = tmHeight;
1694 inline Color FontSpecification::GetTextColor ()
const
1698 inline void FontSpecification::SetTextColor (
const Color& textColor)
1700 fTextColor = textColor;
1702#if qStroika_Foundation_Common_Platform_Windows
1703 inline LOGFONT FontSpecification::GetOSRep ()
const
1707 inline void FontSpecification::GetOSRep (LOGFONT* logFont)
const
1710 *logFont = fFontInfo;
1712 inline void FontSpecification::SetOSRep (LOGFONT logFont)
1714 fFontInfo = logFont;
1716 inline void FontSpecification::LightSetOSRep (LOGFONT logFont)
1718 fFontInfo = logFont;
1719 fFontInfo.lfWidth = 0;
1720 fFontInfo.lfEscapement = 0;
1721 fFontInfo.lfOrientation = 0;
1722 fFontInfo.lfCharSet = DEFAULT_CHARSET;
1723 fFontInfo.lfOutPrecision = 0;
1724 fFontInfo.lfClipPrecision = 0;
1725 fFontInfo.lfQuality = 0;
1726 fFontInfo.lfPitchAndFamily = 0;
1729#if qStroika_Foundation_Common_Platform_Windows
1730 inline FontSpecification::FontSpecification (
const LOGFONT& logFont)
1732 , fSubOrSuperScript (eNoSubOrSuperscript)
1733 , fTextColor (Color::kBlack)
1735 LightSetOSRep (logFont);
1738 inline bool FontSpecification::operator== (
const FontSpecification& rhs)
const
1740 const FontSpecification& lhs = *
this;
1742 if (lhs.GetFontNameSpecifier () != rhs.GetFontNameSpecifier ()) {
1747#if qStroika_Foundation_Common_Platform_Windows
1748 if (lhs.GetStyle_Bold () != rhs.GetStyle_Bold ()) {
1751 if (lhs.GetStyle_Italic () != rhs.GetStyle_Italic ()) {
1754 if (lhs.GetStyle_Underline () != rhs.GetStyle_Underline ()) {
1757 if (lhs.GetStyle_Strikeout () != rhs.GetStyle_Strikeout ()) {
1760#elif qStroika_FeatureSupported_XWindows
1761 if (lhs.GetStyle_Bold () != rhs.GetStyle_Bold ()) {
1764 if (lhs.GetStyle_Italic () != rhs.GetStyle_Italic ()) {
1767 if (lhs.GetStyle_Underline () != rhs.GetStyle_Underline ()) {
1771 if (lhs.GetStyle_SubOrSuperScript () != rhs.GetStyle_SubOrSuperScript ()) {
1776 if (lhs.GetTextColor () != rhs.GetTextColor ()) {
1781#if qStroika_Foundation_Common_Platform_Windows
1783 if (lhs.PeekAtTMHeight () == rhs.PeekAtTMHeight ()) {
1786 else if ((lhs.PeekAtTMHeight () > 0) == (rhs.PeekAtTMHeight () > 0)) {
1793 if (lhs.GetPointSize () != rhs.GetPointSize ()) {
1799 inline void FontSpecification::MergeIn (
const IncrementalFontSpecification& addInTheseAttributes)
1802 if (addInTheseAttributes.GetFontNameSpecifier_Valid ()) {
1803 SetFontNameSpecifier (addInTheseAttributes.GetFontNameSpecifier ());
1807 if (addInTheseAttributes.GetStyle_Bold_Valid ()) {
1808 SetStyle_Bold (addInTheseAttributes.GetStyle_Bold ());
1810 if (addInTheseAttributes.GetStyle_Italic_Valid ()) {
1811 SetStyle_Italic (addInTheseAttributes.GetStyle_Italic ());
1813 if (addInTheseAttributes.GetStyle_Underline_Valid ()) {
1814 SetStyle_Underline (addInTheseAttributes.GetStyle_Underline ());
1816 if (addInTheseAttributes.GetStyle_SubOrSuperScript_Valid ()) {
1817 SetStyle_SubOrSuperScript (addInTheseAttributes.GetStyle_SubOrSuperScript ());
1819#if qStroika_Foundation_Common_Platform_Windows
1820 if (addInTheseAttributes.GetStyle_Strikeout_Valid ()) {
1821 SetStyle_Strikeout (addInTheseAttributes.GetStyle_Strikeout ());
1826 if (addInTheseAttributes.GetPointSize_Valid ()) {
1827#if qStroika_Foundation_Common_Platform_Windows
1829 PokeAtTMHeight (addInTheseAttributes.PeekAtTMHeight ());
1831 SetPointSize (addInTheseAttributes.GetPointSize ());
1834 if (addInTheseAttributes.GetPointSizeIncrement_Valid ()) {
1835 short pointSize = GetPointSize ();
1836 pointSize += addInTheseAttributes.GetPointSizeIncrement ();
1837 if (pointSize <= 0) {
1840 SetPointSize (pointSize);
1844 if (addInTheseAttributes.GetTextColor_Valid ()) {
1845 SetTextColor (addInTheseAttributes.GetTextColor ());
1848#if qStroika_Foundation_Common_Platform_Windows
1850 if (addInTheseAttributes.GetDidSetOSRepCallFlag ()) {
1852 addInTheseAttributes.GetOSRep (&lf);
1863 inline IncrementalFontSpecification::IncrementalFontSpecification (
const FontSpecification& fontSpec)
1864 : FontSpecification{fontSpec}
1865 , fFontSpecifierValid (true)
1866 , fStyleValid_Bold (true)
1867 , fStyleValid_Italic (true)
1868 , fStyleValid_Underline (true)
1869 , fStyleValid_SubOrSuperScript (true)
1871#if qStroika_Foundation_Common_Platform_Windows
1872 fStyleValid_Strikeout (true)
1873 , fDidSetOSRepCallFlag (true)
1876 fFontSizeValid (true)
1877 , fFontSizeIncrementValid (false)
1878 , fTextColorValid (true)
1881 inline FontSpecification::FontNameSpecifier IncrementalFontSpecification::GetFontNameSpecifier ()
const
1883 Require (fFontSpecifierValid);
1884 return inherited::GetFontNameSpecifier ();
1886 inline bool IncrementalFontSpecification::GetFontNameSpecifier_Valid ()
const
1888 return (fFontSpecifierValid);
1890 inline void IncrementalFontSpecification::InvalidateFontNameSpecifier ()
1892 fFontSpecifierValid =
false;
1893#if qStroika_Foundation_Common_Platform_Windows
1894 fDidSetOSRepCallFlag =
false;
1897 inline void IncrementalFontSpecification::SetFontNameSpecifier (FontNameSpecifier fontNameSpecifier)
1899 fFontSpecifierValid =
true;
1900#if qStroika_Foundation_Common_Platform_Windows
1901 fDidSetOSRepCallFlag =
false;
1903 inherited::SetFontNameSpecifier (fontNameSpecifier);
1905 inline void IncrementalFontSpecification::SetFontName (
const SDKString& fontName)
1907 fFontSpecifierValid =
true;
1908#if qStroika_Foundation_Common_Platform_Windows
1909 fDidSetOSRepCallFlag =
false;
1911 inherited::SetFontName (fontName);
1913 inline bool IncrementalFontSpecification::GetStyle_Plain ()
const
1915 Require (fStyleValid_Bold);
1916 Require (fStyleValid_Italic);
1917 Require (fStyleValid_Underline);
1918 Require (fStyleValid_SubOrSuperScript);
1919#if qStroika_Foundation_Common_Platform_Windows
1920 Require (fStyleValid_Strikeout);
1922 return inherited::GetStyle_Plain ();
1924 inline bool IncrementalFontSpecification::GetStyle_Plain_Valid ()
const
1926 bool isValid = fStyleValid_Bold and fStyleValid_Italic and fStyleValid_Underline and fStyleValid_SubOrSuperScript;
1927#if qStroika_Foundation_Common_Platform_Windows
1928 isValid = isValid and fStyleValid_Strikeout;
1932 inline void IncrementalFontSpecification::InvalidateStyles ()
1934 fStyleValid_Bold =
false;
1935 fStyleValid_Italic =
false;
1936 fStyleValid_Underline =
false;
1937 fStyleValid_SubOrSuperScript =
false;
1938#if qStroika_Foundation_Common_Platform_Windows
1939 fStyleValid_Strikeout =
false;
1940 fDidSetOSRepCallFlag =
false;
1943 inline void IncrementalFontSpecification::SetStyle_Plain ()
1945 fStyleValid_Bold =
true;
1946 fStyleValid_Italic =
true;
1947 fStyleValid_Underline =
true;
1948 fStyleValid_SubOrSuperScript =
true;
1949#if qStroika_Foundation_Common_Platform_Windows
1950 fStyleValid_Strikeout =
true;
1951 fDidSetOSRepCallFlag =
false;
1953 inherited::SetStyle_Plain ();
1955 inline bool IncrementalFontSpecification::GetStyle_Bold ()
const
1957 Require (fStyleValid_Bold);
1958 return inherited::GetStyle_Bold ();
1960 inline bool IncrementalFontSpecification::GetStyle_Bold_Valid ()
const
1962 return (fStyleValid_Bold);
1964 inline void IncrementalFontSpecification::InvalidateStyle_Bold ()
1966 fStyleValid_Bold =
false;
1967#if qStroika_Foundation_Common_Platform_Windows
1968 fDidSetOSRepCallFlag =
false;
1971 inline void IncrementalFontSpecification::SetStyle_Bold (
bool isBold)
1973 fStyleValid_Bold =
true;
1974#if qStroika_Foundation_Common_Platform_Windows
1975 fDidSetOSRepCallFlag =
false;
1977 inherited::SetStyle_Bold (isBold);
1979 inline bool IncrementalFontSpecification::GetStyle_Italic ()
const
1981 Require (fStyleValid_Italic);
1982 return inherited::GetStyle_Italic ();
1984 inline bool IncrementalFontSpecification::GetStyle_Italic_Valid ()
const
1986 return (fStyleValid_Italic);
1988 inline void IncrementalFontSpecification::InvalidateStyle_Italic ()
1990 fStyleValid_Italic =
false;
1991#if qStroika_Foundation_Common_Platform_Windows
1992 fDidSetOSRepCallFlag =
false;
1995 inline void IncrementalFontSpecification::SetStyle_Italic (
bool isItalic)
1997 fStyleValid_Italic =
true;
1998#if qStroika_Foundation_Common_Platform_Windows
1999 fDidSetOSRepCallFlag =
false;
2001 inherited::SetStyle_Italic (isItalic);
2003 inline bool IncrementalFontSpecification::GetStyle_Underline ()
const
2005 Require (fStyleValid_Underline);
2006 return inherited::GetStyle_Underline ();
2008 inline bool IncrementalFontSpecification::GetStyle_Underline_Valid ()
const
2010 return (fStyleValid_Underline);
2012 inline void IncrementalFontSpecification::InvalidateStyle_Underline ()
2014 fStyleValid_Underline =
false;
2015#if qStroika_Foundation_Common_Platform_Windows
2016 fDidSetOSRepCallFlag =
false;
2019 inline void IncrementalFontSpecification::SetStyle_Underline (
bool isUnderline)
2021 fStyleValid_Underline =
true;
2022#if qStroika_Foundation_Common_Platform_Windows
2023 fDidSetOSRepCallFlag =
false;
2025 inherited::SetStyle_Underline (isUnderline);
2027 inline FontSpecification::SubOrSuperScript IncrementalFontSpecification::GetStyle_SubOrSuperScript ()
const
2029 Require (fStyleValid_SubOrSuperScript);
2030 return inherited::GetStyle_SubOrSuperScript ();
2032 inline bool IncrementalFontSpecification::GetStyle_SubOrSuperScript_Valid ()
const
2034 return (fStyleValid_SubOrSuperScript);
2036 inline void IncrementalFontSpecification::InvalidateStyle_SubOrSuperScript ()
2038 fStyleValid_SubOrSuperScript =
false;
2039#if qStroika_Foundation_Common_Platform_Windows
2040 fDidSetOSRepCallFlag =
false;
2043 inline void IncrementalFontSpecification::SetStyle_SubOrSuperScript (SubOrSuperScript subOrSuperScript)
2045 fStyleValid_SubOrSuperScript =
true;
2046#if qStroika_Foundation_Common_Platform_Windows
2047 fDidSetOSRepCallFlag =
false;
2049 inherited::SetStyle_SubOrSuperScript (subOrSuperScript);
2051#if qStroika_Foundation_Common_Platform_Windows
2052 inline bool IncrementalFontSpecification::GetStyle_Strikeout ()
const
2054 Require (fStyleValid_Strikeout);
2055 return (inherited::GetStyle_Strikeout ());
2057 inline bool IncrementalFontSpecification::GetStyle_Strikeout_Valid ()
const
2059 return (fStyleValid_Strikeout);
2061 inline void IncrementalFontSpecification::InvalidateStyle_Strikeout ()
2063 fStyleValid_Strikeout =
false;
2064#if qStroika_Foundation_Common_Platform_Windows
2065 fDidSetOSRepCallFlag =
false;
2068 inline void IncrementalFontSpecification::SetStyle_Strikeout (
bool isStrikeout)
2070 fStyleValid_Strikeout =
true;
2071#if qStroika_Foundation_Common_Platform_Windows
2072 fDidSetOSRepCallFlag =
false;
2074 inherited::SetStyle_Strikeout (isStrikeout);
2078 inline unsigned short IncrementalFontSpecification::GetPointSize ()
const
2080 Require (fFontSizeValid);
2081 Require (not fFontSizeIncrementValid);
2082 return inherited::GetPointSize ();
2084 inline bool IncrementalFontSpecification::GetPointSize_Valid ()
const
2086 return (fFontSizeValid);
2088 inline void IncrementalFontSpecification::InvalidatePointSize ()
2090 fFontSizeValid =
false;
2091 fFontSizeIncrementValid =
false;
2092#if qStroika_Foundation_Common_Platform_Windows
2093 fDidSetOSRepCallFlag =
false;
2096 inline void IncrementalFontSpecification::SetPointSize (FontSize pointSize)
2098 fFontSizeValid =
true;
2099#if qStroika_Foundation_Common_Platform_Windows
2100 fDidSetOSRepCallFlag =
false;
2102 inherited::SetPointSize (pointSize);
2103 fFontSizeIncrementValid =
false;
2105#if qStroika_Foundation_Common_Platform_Windows
2106 inline void IncrementalFontSpecification::PokeAtTMHeight (
long tmHeight)
2108 fFontSizeValid =
true;
2109 fDidSetOSRepCallFlag =
false;
2110 fFontSizeIncrementValid =
false;
2111 inherited::PokeAtTMHeight (tmHeight);
2114 inline short IncrementalFontSpecification::GetPointSizeIncrement ()
const
2116 Require (not fFontSizeValid);
2117 Require (fFontSizeIncrementValid);
2118 return (
short)inherited::GetPointSize ();
2120 inline bool IncrementalFontSpecification::GetPointSizeIncrement_Valid ()
const
2122 return (fFontSizeIncrementValid);
2124 inline void IncrementalFontSpecification::InvalidatePointSizeIncrement ()
2126 fFontSizeValid =
false;
2127 fFontSizeIncrementValid =
false;
2128#if qStroika_Foundation_Common_Platform_Windows
2129 fDidSetOSRepCallFlag =
false;
2132 inline void IncrementalFontSpecification::SetPointSizeIncrement (
short pointSizeIncrement)
2134 fFontSizeValid =
false;
2135#if qStroika_Foundation_Common_Platform_Windows
2136 fDidSetOSRepCallFlag =
false;
2138 inherited::SetPointSize ((
unsigned short)pointSizeIncrement);
2139 fFontSizeIncrementValid =
true;
2141 inline Color IncrementalFontSpecification::GetTextColor ()
const
2143 Require (fTextColorValid);
2144 return inherited::GetTextColor ();
2146 inline bool IncrementalFontSpecification::GetTextColor_Valid ()
const
2148 return (fTextColorValid);
2150 inline void IncrementalFontSpecification::InvalidateTextColor ()
2152 fTextColorValid =
false;
2154 inline void IncrementalFontSpecification::SetTextColor (
const Color& textColor)
2156 fTextColorValid =
true;
2157 inherited::SetTextColor (textColor);
2159#if qStroika_Foundation_Common_Platform_Windows
2160 inline LOGFONT IncrementalFontSpecification::GetOSRep ()
const
2162 Require (fFontSpecifierValid and fStyleValid_Bold and fStyleValid_Italic and fStyleValid_Underline and fFontSizeValid);
2163 Require (fStyleValid_Strikeout);
2164 return inherited::GetOSRep ();
2166 inline void IncrementalFontSpecification::GetOSRep (LOGFONT* logFont)
const
2169 Require (fFontSpecifierValid and fStyleValid_Bold and fStyleValid_Italic and fStyleValid_Underline and fFontSizeValid);
2170 Require (fStyleValid_Strikeout);
2171 inherited::GetOSRep (logFont);
2173 inline void IncrementalFontSpecification::SetOSRep (LOGFONT logFont)
2175 fFontSpecifierValid =
true;
2176 fStyleValid_Bold =
true;
2177 fStyleValid_Italic =
true;
2178 fStyleValid_Underline =
true;
2179 fStyleValid_Strikeout =
true;
2180 fFontSizeValid =
true;
2181 fFontSizeIncrementValid =
false;
2182 fDidSetOSRepCallFlag =
true;
2183 inherited::SetOSRep (logFont);
2185 inline void IncrementalFontSpecification::LightSetOSRep (LOGFONT logFont)
2187 fFontSpecifierValid =
true;
2188 fStyleValid_Bold =
true;
2189 fStyleValid_Italic =
true;
2190 fStyleValid_Underline =
true;
2191 fStyleValid_Strikeout =
true;
2192 fFontSizeValid =
true;
2193 fFontSizeIncrementValid =
false;
2194 fDidSetOSRepCallFlag =
true;
2195 inherited::LightSetOSRep (logFont);
2197 inline bool IncrementalFontSpecification::GetDidSetOSRepCallFlag ()
const
2199 return fDidSetOSRepCallFlag;
2202 inline void IncrementalFontSpecification::MergeIn (
const IncrementalFontSpecification& addInTheseAttributes)
2205 if (addInTheseAttributes.GetFontNameSpecifier_Valid ()) {
2206 SetFontNameSpecifier (addInTheseAttributes.GetFontNameSpecifier ());
2210 if (addInTheseAttributes.GetStyle_Bold_Valid ()) {
2211 SetStyle_Bold (addInTheseAttributes.GetStyle_Bold ());
2213 if (addInTheseAttributes.GetStyle_Italic_Valid ()) {
2214 SetStyle_Italic (addInTheseAttributes.GetStyle_Italic ());
2216 if (addInTheseAttributes.GetStyle_Underline_Valid ()) {
2217 SetStyle_Underline (addInTheseAttributes.GetStyle_Underline ());
2219#if qStroika_Foundation_Common_Platform_Windows
2220 if (addInTheseAttributes.GetStyle_Strikeout_Valid ()) {
2221 SetStyle_Strikeout (addInTheseAttributes.GetStyle_Strikeout ());
2226 if (addInTheseAttributes.GetPointSize_Valid ()) {
2227#if qStroika_Foundation_Common_Platform_Windows
2229 PokeAtTMHeight (addInTheseAttributes.PeekAtTMHeight ());
2231 SetPointSize (addInTheseAttributes.GetPointSize ());
2234 if (addInTheseAttributes.GetPointSizeIncrement_Valid ()) {
2235 short pointSize = GetPointSize ();
2236 pointSize += addInTheseAttributes.GetPointSizeIncrement ();
2237 if (pointSize <= 0) {
2240 SetPointSize (pointSize);
2244 if (addInTheseAttributes.GetTextColor_Valid ()) {
2245 SetTextColor (addInTheseAttributes.GetTextColor ());
2248#if qStroika_Foundation_Common_Platform_Windows
2249 fDidSetOSRepCallFlag = addInTheseAttributes.GetDidSetOSRepCallFlag ();
2252 inline bool IncrementalFontSpecification::operator== (
const IncrementalFontSpecification& rhs)
const
2259 if (GetFontNameSpecifier_Valid () != rhs.GetFontNameSpecifier_Valid ()) {
2262 if (GetFontNameSpecifier_Valid () and (GetFontNameSpecifier () != rhs.GetFontNameSpecifier ())) {
2269 if (GetStyle_Bold_Valid () != rhs.GetStyle_Bold_Valid ()) {
2272 if (GetStyle_Bold_Valid () and (GetStyle_Bold () != rhs.GetStyle_Bold ())) {
2277 if (GetStyle_Italic_Valid () != rhs.GetStyle_Italic_Valid ()) {
2280 if (GetStyle_Italic_Valid () and (GetStyle_Italic () != rhs.GetStyle_Italic ())) {
2285 if (GetStyle_Underline_Valid () != rhs.GetStyle_Underline_Valid ()) {
2288 if (GetStyle_Underline_Valid () and (GetStyle_Underline () != rhs.GetStyle_Underline ())) {
2293 if (GetStyle_SubOrSuperScript_Valid () != rhs.GetStyle_SubOrSuperScript_Valid ()) {
2296 if (GetStyle_SubOrSuperScript_Valid () and (GetStyle_SubOrSuperScript () != rhs.GetStyle_SubOrSuperScript ())) {
2300#if qStroika_Foundation_Common_Platform_Windows
2302 if (GetStyle_Strikeout_Valid () != rhs.GetStyle_Strikeout_Valid ()) {
2305 if (GetStyle_Strikeout_Valid () and (GetStyle_Strikeout () != rhs.GetStyle_Strikeout ())) {
2313 if (GetTextColor_Valid () != rhs.GetTextColor_Valid ()) {
2316 if (GetTextColor_Valid () and (GetTextColor () != rhs.GetTextColor ())) {
2323 if (GetPointSizeIncrement_Valid () != rhs.GetPointSizeIncrement_Valid ()) {
2326 if (GetPointSizeIncrement_Valid () and (GetPointSizeIncrement () != rhs.GetPointSizeIncrement ())) {
2331 if (GetPointSize_Valid () != rhs.GetPointSize_Valid ()) {
2334 if (GetPointSize_Valid ()) {
2335#if qStroika_Foundation_Common_Platform_Windows
2337 if (PeekAtTMHeight () == rhs.PeekAtTMHeight ()) {
2340 else if ((PeekAtTMHeight () > 0) == (rhs.PeekAtTMHeight () > 0)) {
2347 if (GetPointSize () != rhs.GetPointSize ()) {
2361 inline const vector<SDKString>& InstalledFonts::GetUsableFontNames ()
const
2366#if qStroika_Frameworks_Led_SupportGDI
2372 inline Color Led_GetTextColor ()
2374#if qStroika_Foundation_Common_Platform_Windows
2375 return Color (::GetSysColor (COLOR_WINDOWTEXT));
2376#elif qStroika_FeatureSupported_XWindows
2377 return (Color::kBlack);
2386 inline Color Led_GetTextBackgroundColor ()
2388#if qStroika_Foundation_Common_Platform_Windows
2389 return Color (::GetSysColor (COLOR_WINDOW));
2390#elif qStroika_FeatureSupported_XWindows
2391 return (Color::kWhite);
2396#if qStroika_Frameworks_Led_SupportGDI
2402 inline Color Led_GetSelectedTextColor ()
2404#if qStroika_Foundation_Common_Platform_MacOS
2405 RGBColor hiliteRGBValue;
2406 LMGetHiliteRGB (&hiliteRGBValue);
2412 if (Color (hiliteRGBValue) == Color::kBlack) {
2413 return (Color::kWhite);
2416 return (Color::kBlack);
2418#elif qStroika_Foundation_Common_Platform_Windows
2420 return Color (::GetSysColor (COLOR_HIGHLIGHTTEXT));
2421#elif qStroika_FeatureSupported_XWindows
2422 return (Color::kWhite);
2425 inline Color Led_GetSelectedTextBackgroundColor ()
2427#if qStroika_Foundation_Common_Platform_MacOS
2428 RGBColor hiliteRGBValue;
2429 LMGetHiliteRGB (&hiliteRGBValue);
2430 return Color (hiliteRGBValue);
2431#elif qStroika_Foundation_Common_Platform_Windows
2433 return Color (::GetSysColor (COLOR_HIGHLIGHT));
2434#elif qStroika_FeatureSupported_XWindows
2435 return (Color::kBlack);
2440#if qStroika_Frameworks_Led_SupportGDI
2446 inline Tablet::ClipNarrowAndRestore::ClipNarrowAndRestore (Tablet* tablet)
2448 , fHasOldClip (false)
2452#if qStroika_Foundation_Common_Platform_Windows
2453 if (::GetDeviceCaps (fTablet->m_hDC, TECHNOLOGY) == DT_METAFILE) {
2457 fHasOldClip = tablet->GetClip (&fOldClip);
2459 inline Tablet::ClipNarrowAndRestore::ClipNarrowAndRestore (Tablet* tablet,
const Led_Rect& clipFurtherTo)
2461 , fHasOldClip (false)
2465 fHasOldClip = tablet->GetClip (&fOldClip);
2466#if qStroika_Foundation_Common_Platform_MacOS
2467 Assert (fHasOldClip);
2468 tablet->SetClip (fOldClip * clipFurtherTo);
2469#elif qStroika_Foundation_Common_Platform_Windows
2474 if (::GetDeviceCaps (tablet->m_hDC, TECHNOLOGY) == DT_METAFILE) {
2477 Verify (::IntersectClipRect (*tablet, clipFurtherTo.GetLeft (), clipFurtherTo.GetTop (), clipFurtherTo.GetRight (),
2478 clipFurtherTo.GetBottom ()) != ERROR);
2481 inline Tablet::ClipNarrowAndRestore::ClipNarrowAndRestore (Tablet* tablet, [[maybe_unused]]
const Region& clipFurtherTo)
2483 , fHasOldClip (false)
2487 fHasOldClip = tablet->GetClip (&fOldClip);
2488#if qStroika_Foundation_Common_Platform_MacOS
2489 Assert (fHasOldClip);
2490 tablet->SetClip (fOldClip * clipFurtherTo);
2491#elif qStroika_Foundation_Common_Platform_Windows
2497 inline Tablet::ClipNarrowAndRestore::~ClipNarrowAndRestore ()
2500#if qStroika_Foundation_Common_Platform_Windows
2501 if (::GetDeviceCaps (fTablet->m_hDC, TECHNOLOGY) == DT_METAFILE) {
2506 fTablet->SetClip (fOldClip);
2509 fTablet->SetClip ();
2514#if qStroika_Foundation_Common_Platform_Windows
2520 inline WindowDC::WindowDC (HWND hWnd)
2523 Require (fHWnd_ ==
nullptr or ::IsWindow (fHWnd_));
2524 if (!Attach (::GetWindowDC (fHWnd_))) {
2525 Foundation::Execution::Throw (bad_alloc{});
2528 inline WindowDC::~WindowDC ()
2531 ::ReleaseDC (fHWnd_, Detach ());
2536#if qStroika_Frameworks_Led_SupportGDI
2542#if qStroika_Foundation_Common_Platform_Windows
2543 inline GDI_Obj_Selector::GDI_Obj_Selector (Tablet* tablet, HGDIOBJ objToSelect)
2545 , fRestoreObject (nullptr)
2546 , fRestoreAttribObject (nullptr)
2552 if (tablet->m_hDC != tablet->m_hAttribDC) {
2553 fRestoreObject = ::SelectObject (tablet->m_hDC, objToSelect);
2555 if (tablet->m_hAttribDC !=
nullptr) {
2556 fRestoreAttribObject = ::SelectObject (tablet->m_hAttribDC, objToSelect);
2559#elif qStroika_Foundation_Common_Platform_MacOS
2560 inline GDI_Obj_Selector::GDI_Obj_Selector (Tablet* tablet,
const Pen& pen)
2564 fRestorePen (Pen (::GetPortPenMode (Led_GetCurrentGDIPort ()), &Pen::kBlackPattern, Color (GDI_GetForeColor ())))
2566 fRestorePen (Pen (Led_GetCurrentGDIPort ()->pnMode, &Led_GetCurrentGDIPort ()->pnPat, Color (GDI_GetForeColor ())))
2569 Assert (Led_GetCurrentGDIPort () == *tablet);
2570 GDI_RGBForeColor (pen.fPenColor.GetOSRep ());
2571 ::PenMode (pen.fPenStyle);
2572 ::PenPat (&pen.fPenPat);
2574#elif qStroika_FeatureSupported_XWindows
2575 inline GDI_Obj_Selector::GDI_Obj_Selector (Tablet* tablet,
const Pen& pen)
2579 inline GDI_Obj_Selector::~GDI_Obj_Selector ()
2581#if qStroika_Foundation_Common_Platform_Windows
2583 if (fRestoreObject !=
nullptr) {
2584 Verify (::SelectObject (fTablet->m_hDC, fRestoreObject));
2586 if (fRestoreAttribObject !=
nullptr) {
2587 Verify (::SelectObject (fTablet->m_hAttribDC, fRestoreAttribObject));
2589#elif qStroika_Foundation_Common_Platform_MacOS
2590 GDI_RGBForeColor (fRestorePen.fPenColor.GetOSRep ());
2591 ::PenMode (fRestorePen.fPenStyle);
2592 ::PenPat (&fRestorePen.fPenPat);
2602 inline short Led_GetMacPictTop (
const Led_Picture* picture)
2605 return Led_ByteSwapFromMac (picture->picFrameTop);
2607 inline short Led_GetMacPictLeft (
const Led_Picture* picture)
2610 return Led_ByteSwapFromMac (picture->picFrameLeft);
2612 inline short Led_GetMacPictBottom (
const Led_Picture* picture)
2615 return Led_ByteSwapFromMac (picture->picFrameBottom);
2617 inline short Led_GetMacPictRight (
const Led_Picture* picture)
2620 return Led_ByteSwapFromMac (picture->picFrameRight);
2622 inline short Led_GetMacPictWidth (
const Led_Picture* picture)
2624 return Led_GetMacPictRight (picture) - Led_GetMacPictLeft (picture);
2626 inline short Led_GetMacPictHeight (
const Led_Picture* picture)
2628 return Led_GetMacPictBottom (picture) - Led_GetMacPictTop (picture);
2630 inline Led_Size Led_GetMacPictSize (
const Led_Picture* picture)
2632 return Led_Size (Led_GetMacPictHeight (picture), Led_GetMacPictWidth (picture));
2635#if qStroika_Frameworks_Led_ProvideIMESupport
2641 DISABLE_COMPILER_MSC_WARNING_START (6011)
2642 inline IME& IME::Get ()
2644 if (sThe ==
nullptr) {
2650 DISABLE_COMPILER_MSC_WARNING_END (6011)
2651 inline
void IME::Enable ()
2653 if (fIMEEnableProc !=
nullptr) {
2654 fIMEEnableProc (
nullptr,
true);
2657 inline void IME::Disable ()
2659 if (fIMEEnableProc !=
nullptr) {
2660 fIMEEnableProc (
nullptr,
false);
2663 inline bool IME::Available ()
const
2665 return fWinNlsAvailable;
2667 inline void IME::ForgetPosition ()
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define RequireNotNull(p)
set< T > Intersection(const set< T > &s1, const set< T > &s2)
basic_string< SDKChar > SDKString
Ptr Attach(PlatformNativeHandle sd)