Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
GDI.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_Led_GDI_h_
5#define _Stroika_Frameworks_Led_GDI_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
9/*
10 * Graphix Library support. This code encapsulates access to underlying GDI for modularity sake.
11 * For historical reasons - as of Led 3.0 - there is still some direct access to underlying GDI in parts of Led
12 * but that will gradually (hopefully right after 3.0) be eliminated.</p>
13 * Also - no class library dependencies (ie no MFC dependencies). So we can build MFC-Free Win32 apps more
14 * easily.
15 */
16
17#include <algorithm>
18#include <cmath>
19#include <compare>
20#include <cstdlib>
21#include <map>
22#include <string>
23#include <vector>
24
25// WHY DON'T WE NEED TO INCLUDE <Windows.h> here??? - LGP 991213
26
28
29#include "Stroika/Frameworks/Led/Support.h"
30
31namespace Stroika::Frameworks::Led {
32
34 using Foundation::Characters::String;
35
36 /**
37 * <code>CoordinateType</code> is the <code>signed</code> analog of @'DistanceType'.
38 * @'Led_Point' is a tuple of <code>Coordinates</code>s
39 * (vertical and horizontal).</p>
40 */
41 using CoordinateType = long;
42
43 /*
44 @CLASS: DistanceType
45 @DESCRIPTION: <p><code>DistanceType</code> is an unsigned type, specifying the distance (always non-negative)
46 between two graphics locations. @'Led_Size' is a tuple of <code>DistanceType</code>s
47 (vertical and horizontal).</p>
48 */
49 using DistanceType = unsigned long;
50
51 /*
52 * Many distances are specified in Led in TWIPS - 1/20 of a printers point.
53 *
54 * This means - 1/1440 of an inch.</p>
55 *
56 * This size refers to the size when printed on a page. So it can be scaled - depnding on screen resolution.
57 * Led will often save this internally - and scale it at the last minute to the resolution of the @'Tablet*' being printed on.
58 *
59 * NB: This marks a change from Led 2.3 and earlier - where most distances were stored in pixels (still many are).
60 *
61 * NB: declard as a class instead of a typedef so we get better type checking. Shouldn't affect sizes or code
62 * generation - I would hope!
63 */
64 class TWIPS {
65 public:
66 constexpr explicit TWIPS (long v);
67 constexpr operator long () const;
68
69 private:
70 long fValue;
71
72 public:
73 nonvirtual TWIPS& operator+= (const TWIPS& rhs);
74 nonvirtual TWIPS& operator-= (const TWIPS& rhs);
75 nonvirtual TWIPS& operator*= (double rhs);
76
77 public:
78 constexpr bool operator== (const TWIPS&) const = default;
79
80 public:
81 static const TWIPS kPoint;
82 static const TWIPS kInch;
83 static const TWIPS kOneInch;
84 };
85 TWIPS operator+ (const TWIPS& lhs, const TWIPS& rhs);
86 TWIPS operator- (const TWIPS& lhs, const TWIPS& rhs);
87
88 class Tablet;
89
90 /*
91 * Even though WinSDK supports GetTabbedTextExtent/TabbedTextOut () - they do a bad job.
92 * In particular, they offer no (obvious) way to specify the tab origin for
93 * GetTabbedTextExtent(). This makes proper text display nearly impossible.
94 *
95 * Also, the Mac provides NO tab support at all. Because of the Mac - we NEED
96 * to implement our own tab support. Given we are doing that anyhow, may as
97 * well use our portable support on both platforms.
98 * For both calculating widths, and doing imaging, we follow essentially
99 * the same algorithm.
100 * o Walk the text looking for a tab or EOL.
101 * o Take the tab-free initial segment and image(calculate) it.
102 * o if now on a tab, image (calculate) that.
103 * o Advance indexes over what we've imaged (calculated) and repeat.
104 */
105 class TabStopList {
106 protected:
107 TabStopList () = default;
108
109 public:
110 virtual ~TabStopList () = default;
111
112 public:
113 /*
114 @DESCRIPTION: <p>Compute where the 'ith' tabstop lies (i >= 0, and can be arbitrarily high).
115 Note that though tabstop <code>i=0</code> is the first tabstop (which by convention is usually NOT
116 at the left margin - but is really the logically 'first' one).</p>
117 <p>Note - this used to return Distance - but in Led 3.0 - it changed to returning TWIPS (see SPR#0767);</p>
118 */
119 virtual TWIPS ComputeIthTab (size_t i) const = 0;
120 /*
121 @DESCRIPTION: <p>Given a distance from the left margin, find the immediately following tabstops position.
122 This is what is actually used in the imagers to compute where to draw text. It can logically
123 be implemented by walking the tabstoplist and calling @'TabStopList::ComputeIthTab', and
124 returning the next one after the one past(or equal to) <code>afterPos</code>.</p>
125 <p>Note - this used to take/return Distance - but in Led 3.0 - it changed to take/return TWIPS (see SPR#0767);</p>
126 <p>Now there is an overloaded version using Distance that takes a Tablet* as argument.</p>
127 */
128 virtual TWIPS ComputeTabStopAfterPosition (TWIPS afterPos) const = 0;
129 nonvirtual DistanceType ComputeTabStopAfterPosition (Tablet* tablet, DistanceType afterPos) const;
130 };
131
132#if qStroika_Platform_Windows
133 /**
134 */
135 class FontObject {
136 public:
137 FontObject () = default;
138 ~FontObject ();
139 nonvirtual operator HFONT () const;
140 nonvirtual int GetObject (int nCount, LPVOID lpObject) const;
141 nonvirtual BOOL DeleteObject ();
142 nonvirtual BOOL CreateFontIndirect (const LOGFONT* lpLogFont);
143 nonvirtual BOOL Attach (HFONT hObject);
144
145 public:
146 HFONT m_hObject{nullptr};
147 };
148#endif
149
150#if qStroika_Platform_Windows
151 /**
152 */
153 class Brush {
154 public:
155 Brush (COLORREF crColor);
156 ~Brush ();
157 nonvirtual operator HBRUSH () const;
158 nonvirtual BOOL Attach (HBRUSH hObject);
159 nonvirtual BOOL DeleteObject ();
160
161 private:
162 HBRUSH m_hObject{nullptr};
163 };
164#endif
165
166 /**
167 */
168 template <typename COORD_TYPE>
169 struct Point_Base {
170 public:
171 using CoordinateType = COORD_TYPE;
172
173 public:
174 constexpr Point_Base ();
175 constexpr Point_Base (COORD_TYPE newV, COORD_TYPE newH);
176 template <typename OTHER_POINT_BASE_TYPE>
177 constexpr explicit Point_Base (OTHER_POINT_BASE_TYPE o)
178 : v (COORD_TYPE (o.v))
179 , h (COORD_TYPE (o.h))
180 {
181 }
182
183 public:
184 COORD_TYPE v;
185 COORD_TYPE h;
186
187 public:
188 /**
189 */
190 constexpr strong_ordering operator<=> (const Point_Base& rhs) const = default;
191 };
192
193 /*
194 * \note <a href="Design-Overview.md#Comparisons">Comparisons</a>:
195 * o Standard Stroika Comparison support (operator<=>,operator==, etc);
196 */
197 template <typename POINT_TYPE, typename SIZE_TYPE>
198 struct Rect_Base {
199 public:
200 using CoordinateType = typename POINT_TYPE::CoordinateType;
201 using DistanceType = typename SIZE_TYPE::CoordinateType;
202 using THIS_TYPE = Rect_Base<POINT_TYPE, SIZE_TYPE>;
203
204 public:
205 constexpr Rect_Base ();
206 constexpr Rect_Base (CoordinateType newTop, CoordinateType newLeft, DistanceType newHeight, DistanceType newWidth);
207 constexpr Rect_Base (POINT_TYPE origin, SIZE_TYPE size);
208
209 public:
210 nonvirtual CoordinateType GetTop () const;
211 nonvirtual CoordinateType GetLeft () const;
212 nonvirtual CoordinateType GetBottom () const;
213 nonvirtual CoordinateType GetRight () const;
214 nonvirtual bool IsEmpty () const; /* contains no bits - ie one side <= zero length */
215 nonvirtual DistanceType GetHeight () const;
216 nonvirtual DistanceType GetWidth () const;
217 nonvirtual POINT_TYPE GetTopLeft () const;
218 nonvirtual POINT_TYPE GetTopRight () const;
219 nonvirtual POINT_TYPE GetBotRight () const;
220 nonvirtual POINT_TYPE GetOrigin () const;
221 nonvirtual SIZE_TYPE GetSize () const;
222 nonvirtual bool Contains (POINT_TYPE p) const;
223 nonvirtual bool Contains (THIS_TYPE r) const;
224
225 nonvirtual void SetOrigin (POINT_TYPE p);
226 nonvirtual void SetTop (CoordinateType top);
227 nonvirtual void SetLeft (CoordinateType left);
228 nonvirtual void SetBottom (CoordinateType bottom);
229 nonvirtual void SetRight (CoordinateType right);
230
231 public:
232 CoordinateType top;
233 CoordinateType left;
234 CoordinateType bottom;
235 CoordinateType right;
236
237 public:
238 nonvirtual const Rect_Base<POINT_TYPE, SIZE_TYPE>& operator+= (const POINT_TYPE& delta);
239 nonvirtual const Rect_Base<POINT_TYPE, SIZE_TYPE>& operator-= (const POINT_TYPE& delta);
240 nonvirtual const Rect_Base<POINT_TYPE, SIZE_TYPE>& operator*= (const THIS_TYPE& intersectWith);
241
242 public:
243 /**
244 */
245 constexpr strong_ordering operator<=> (const Rect_Base& rhs) const = default;
246 bool operator== (const Rect_Base& rhs) const;
247 };
248
249 /**
250 * Simple typedef of @'Point_Base<COORD_TYPE>' using @'Distance'.
251 */
252 using Led_Size = Point_Base<DistanceType>;
253
254 /**
255 * Simple typedef of @'Point_Base<COORD_TYPE>' using @'CoordinateType'.
256 */
257 using Led_Point = Point_Base<CoordinateType>;
258 Led_Point operator- (const Led_Point& lhs, const Led_Point& rhs);
259
260 /*
261 @DESCRIPTION: <p>Simple typedef of @'Point_Base<COORD_TYPE>' using @'TWIPS'.</p>
262 */
263 using TWIPS_Point = Point_Base<TWIPS>;
264
265 /*
266 @DESCRIPTION: <p>Simple typedef of @'Rect_Base<POINT_TYPE,SIZE_TYPE>' using @'Led_Point' and @'Led_Size'.</p>
267 */
268 using Led_Rect = Rect_Base<Led_Point, Led_Size>;
269
270 /*
271 @DESCRIPTION: <p>Simple typedef of @'Rect_Base<POINT_TYPE,SIZE_TYPE>' using @'TWIPS_Point'.</p>
272 */
273 using TWIPS_Rect = Rect_Base<TWIPS_Point, TWIPS_Point>;
274
275#if qStroika_Frameworks_Led_SupportGDI
276 /**
277 * \brief Portable GDI abstraction for 'Region' object.
278 */
279 class Region {
280 public:
281 Region ();
282 Region (const Led_Rect& r);
283 Region (const Region& from);
284 virtual ~Region ();
285 nonvirtual const Region& operator= (const Region& rhs);
286
287 public:
288 nonvirtual bool IsEmpty () const;
289 nonvirtual Led_Rect GetBoundingRect () const;
290
291 public:
292#if qStroika_Platform_Windows
293 operator HRGN () const;
294 int CombineRgn (Region* pRgn1, Region* pRgn2, int nCombineMode);
295 BOOL PtInRegion (int x, int y) const;
296 BOOL PtInRegion (POINT point) const;
297
298 private:
299 BOOL DeleteObject ();
300#endif
301 private:
302#if qStroika_Platform_Windows
303 HRGN fRgn;
304#endif
305 };
306 Region operator* (const Region& lhs, const Region& rhs);
307 Region operator+ (const Region& lhs, const Region& rhs);
308#endif
309
310 /**
311 * This class is a portable representation of a color. It can be constructed either
312 * from its basic RGB componets, or from the native color representations on a particular platform.
313 */
314 class Color {
315 public:
316 // regardless of Mac or Windows, we use the same size ColorValue so we can write
317 // portable code more easily...
318 using ColorValue = unsigned short;
319 enum {
320 kColorValueMin = 0,
321 kColorValueMax = USHRT_MAX
322 };
323
324 public:
325 constexpr Color (const Color&) = default;
326 constexpr Color (ColorValue redValue, ColorValue greenValue, ColorValue blueValue);
327#if qStroika_Platform_Windows
328 explicit Color (COLORREF colorRef);
329#endif
330
331 public:
332 nonvirtual ColorValue GetRed () const;
333 nonvirtual ColorValue GetGreen () const;
334 nonvirtual ColorValue GetBlue () const;
335
336 /*
337 * Some useful predefined values.
338 */
339 public:
340 static const Color kBlack;
341 static const Color kWhite;
342 static const Color kRed;
343 static const Color kGreen;
344 static const Color kBlue;
345 static const Color kCyan;
346 static const Color kMagenta;
347 static const Color kYellow;
348 static const Color kMaroon;
349 static const Color kOlive;
350 static const Color kNavyBlue;
351 static const Color kPurple;
352 static const Color kTeal;
353 static const Color kGray;
354 static const Color kSilver; // aka 'light gray'
355 static const Color kDarkGreen;
356 static const Color kLimeGreen;
357 static const Color kFuchsia;
358 static const Color kAqua;
359
360 public:
361#if qStroika_Platform_Windows
362 nonvirtual COLORREF GetOSRep () const;
363#endif
364
365 public:
366 /**
367 */
368 constexpr strong_ordering operator<=> (const Color& rhs) const = default;
369 constexpr bool operator== (const Color& rhs) const = default;
370
371 private:
372 ColorValue fRed;
373 ColorValue fGreen;
374 ColorValue fBlue;
375 };
376
377 Color operator* (Color lhs, float factor);
378 Color operator/ (Color lhs, float divBy);
379 Color operator+ (Color lhs, Color rhs);
380 Color operator- (Color lhs, Color rhs);
381
382 unsigned int Distance (Color lhs, Color rhs);
383 unsigned int Distance_Squared (Color lhs, Color rhs);
384#if qStroika_Platform_Windows
385 unsigned int Distance_Squared (COLORREF lhs, COLORREF rhs);
386#endif
387
388 /**
389 * Helper class to keep track of GDI information used for drawing.
390 *
391 * Note - this class is used in conjunction with @'GDI_Obj_Selector'.
392 */
393 class Pen {
394#if qStroika_Platform_Windows
395 public:
396 Pen (int nPenStyle, int nWidth, COLORREF crColor);
397 ~Pen ();
398 nonvirtual operator HPEN () const;
399 nonvirtual BOOL Attach (HPEN hObject);
400 nonvirtual BOOL DeleteObject ();
401
402 private:
403 HPEN m_hObject;
404#endif
405 };
406
407 /*
408 @DESCRIPTION: <p>Led defines several kinds of justification, but doesn't implement all of them.
409 <ul>
410 <li><em>eLeftJustify</em></li>
411 <li><em>eRightJustify</em></li>
412 <li><em>eCenterJustify</em></li>
413 <li><em>eFullyJustify</em>- not implemented in Led 3.0 - treated as eLeftJustify</li>
414 <li><em>eDefaultForScriptJustify</em>-not implemented in Led 3.0 - treated as eLeftJustify</li>
415 </ul>
416 </p>
417 <p>These extra unimplemented enums are provided so you can more easily write code and read/write files
418 etc which keep track of this information, and even show the styles in the UI. They just aren't reflected
419 in how the text is drawn yet. That should come in the next major Led release.</p>
420 */
421 enum Justification {
422 eLeftJustify,
423 eRightJustify,
424 eCenterJustify,
425 eFullyJustify,
426 eDefaultForScriptJustify
427 };
428
429 /**
430 * There are two defined text directions:
431 * <li><em>eLeftToRight</em></li>
432 * <li><em>eRightToLeft</em></li>
433 */
434 enum TextDirection {
435 eLeftToRight,
436 eRightToLeft
437 };
438
439 /**
440 * Different styles of bullet / list markers for list items in the WordProcessor.</p>
441 *
442 * Numeric values come from RTF 1.5 Spec \levelnfc (except for eListStyle_None which is special)</p>
443 */
444 enum ListStyle {
445 eListStyle_None = 9999,
446 eListStyle_Bullet = 23
447 };
448
449 /*
450 @DESCRIPTION: <p>Support at least all the crazy formats/options in the Win32 PARAFORMAT2 structure, and
451 the ill-documented RTF 1.5 SPEC \sl options.
452 <ul>
453 <li>eSingleSpace- fArg IGNORED
454 <li>eOnePointFiveSpace- fArg IGNORED
455 <li>eDoubleSpace- fArg IGNORED
456 <li>eAtLeastTWIPSSpacing-<br>
457 The fArg member specifies the spacing from one line to the next, in twips.
458 However, if fArg specifies a value that is less than single line spacing, Led displays single-spaced text.
459 <li>eExactTWIPSSpacing-<br>
460 The fArg member specifies the spacing from one row to the next, in twips.
461 Led uses the exact spacing specified, even if fArg specifies a value that is less than single spacing.
462 <li>eExactLinesSpacing-<br>
463 The value of fArg / 20 is the spacing, in lines, from one line to the next.
464 Thus, setting fArg to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.
465 </ul>
466 </p>
467 */
468 class LineSpacing {
469 public:
470 enum Rule {
471 eSingleSpace,
472 eOnePointFiveSpace,
473 eDoubleSpace,
474 eAtLeastTWIPSSpacing,
475 eExactTWIPSSpacing,
476 eExactLinesSpacing
477 };
478 Rule fRule{eSingleSpace};
479 unsigned fArg{0};
480
481 public:
482 constexpr LineSpacing () = default;
483 constexpr LineSpacing (Rule rule);
484 constexpr LineSpacing (Rule rule, TWIPS twips);
485 constexpr LineSpacing (Rule rule, unsigned lineCount);
486
487 public:
488 constexpr bool operator== (const LineSpacing& rhs) const;
489 };
490
491 class IncrementalFontSpecification;
492
493 /**
494 * <code>FontSpecification</code> is a utility class which portably represents
495 * a user font choice. This largely corresponds to the MS-Windows <code>LOGFONT</code> structure.</p>
496 * In addition to being a portable represenation of this information, it
497 * also contains handy wrapper accessors, and extra information like subscript,
498 * superscript, and font color.</p>
499 * See also, @'IncrementalFontSpecification'</p>
500 */
502 public:
503 FontSpecification (const FontSpecification&) = default;
504 FontSpecification () = default;
505#if qStroika_Platform_Windows
506 explicit FontSpecification (const LOGFONT& logFont);
507#endif
508 // Force users to be EXPLICIT about this object-slicing, since many of the fields
509 // maybe invalid... Will the compiler REALLY do this check???? We'll see - LGP 970314
510 explicit FontSpecification (const IncrementalFontSpecification& from);
511
512 public:
513#if qStroika_Platform_Windows
514 struct FontNameSpecifier { // So struct copies etc will work and so we can define op==
516 FontNameSpecifier (const SDKChar* from);
517 SDKChar fName[LF_FACESIZE];
518 bool operator== (const FontNameSpecifier& rhs) const
519 {
520 return ::_tcscmp (fName, rhs.fName) == 0;
521 }
522 };
523#else
524 // even if no actual GDI, need FontNameSpecifer to get stuff compiling
526#endif
527
528 public:
529 // string/name wrapper
530 nonvirtual SDKString GetFontName () const;
531 nonvirtual void SetFontName (const SDKString& fontName);
532
533 // FontName info
534 nonvirtual FontNameSpecifier GetFontNameSpecifier () const;
535 nonvirtual void SetFontNameSpecifier (FontNameSpecifier fontNameSpecifier);
536
537 // Style info
538 nonvirtual bool GetStyle_Plain () const; // special composite of all other styles...
539 nonvirtual void SetStyle_Plain ();
540
541 nonvirtual bool GetStyle_Bold () const;
542 nonvirtual void SetStyle_Bold (bool isBold);
543
544 nonvirtual bool GetStyle_Italic () const;
545 nonvirtual void SetStyle_Italic (bool isItalic);
546
547 nonvirtual bool GetStyle_Underline () const;
548 nonvirtual void SetStyle_Underline (bool isUnderline);
549
550 enum SubOrSuperScript {
551 eSubscript,
552 eSuperscript,
553 eNoSubOrSuperscript
554 };
555 nonvirtual SubOrSuperScript GetStyle_SubOrSuperScript () const;
556 nonvirtual void SetStyle_SubOrSuperScript (SubOrSuperScript subOrSuperScript);
557
558#if qStroika_Platform_Windows
559 nonvirtual bool GetStyle_Strikeout () const;
560 nonvirtual void SetStyle_Strikeout (bool isStrikeout);
561#endif
562
563 using FontSize = uint16_t;
564 nonvirtual FontSize GetPointSize () const;
565 nonvirtual void SetPointSize (FontSize pointSize);
566
567#if qStroika_Platform_Windows
568 nonvirtual long PeekAtTMHeight () const; // Speed tweek
569 nonvirtual void PokeAtTMHeight (long tmHeight); // ditto
570#endif
571
572 nonvirtual Color GetTextColor () const;
573 nonvirtual void SetTextColor (const Color& textColor);
574
575 public:
576#if qStroika_Platform_Windows
577 nonvirtual LOGFONT GetOSRep () const;
578 nonvirtual void GetOSRep (LOGFONT* logFont) const;
579 nonvirtual void SetOSRep (LOGFONT logFont);
580 nonvirtual void LightSetOSRep (LOGFONT logFont);
581#endif
582
583 public:
584 /**
585 */
586 strong_ordering operator<=> (const FontSpecification& rhs) const;
587
588 public:
589 /**
590 */
591 bool operator== (const FontSpecification& rhs) const;
592
593 public:
594 nonvirtual void MergeIn (const IncrementalFontSpecification& addInTheseAttributes);
595
596 private:
597#if qStroika_Platform_Windows
598 LOGFONT fFontInfo{}; // Could make this MUCH smaller on windows - do for future release!
599#else
600 FontNameSpecifier fFontFamily{};
601 bool fBold : 1 {false};
602 bool fItalics : 1 {false};
603 bool fUnderline : 1 {false};
604 short fFontSize{0};
605#endif
606 SubOrSuperScript fSubOrSuperScript{SubOrSuperScript::eNoSubOrSuperscript};
607 Color fTextColor{Color::kBlack};
608 };
609
610 /*
611 * <code>IncrementalFontSpecification</code> is a simple subclass of
612 * @'FontSpecification' which adds a bool flag for each
613 * font attribute indicating whether or not it is really specified.
614 * With this, and the @'FontSpecification::MergeIn' method,
615 * you can specify just one or two changes to a font record, pass them around,
616 * and apply them to an existing font choice.</p>
617 * See also, @'FontSpecification'
618 */
619 class IncrementalFontSpecification : public FontSpecification {
620 private:
621 using inherited = FontSpecification;
622
623 public:
624 IncrementalFontSpecification () = default;
625
626 // I may end up regretting this, for all the confusion it
627 // can cause, but it sure makes a number of things simpler
628 // and clearer-- LGP 960520
629 IncrementalFontSpecification (const FontSpecification& fontSpec);
630
631 /*
632 * Basic form of this API. For a feature of a font, say its size, there is a
633 * GetFEATURE () -
634 * REQUIRES FEATURE VALID
635 * GetFEATURE (bool* valid, FEATUURE* feature)-
636 * Either valid or feature can be nullptr, but if NON-nullptr filled in with
637 * feature/valid (except feature NOT filled in if not valid.
638 * InvalidateFEATURE ()-
639 * Just sets valid-flag false.
640 * SetFEATURE(FEATURE)-
641 * Specifies this as the feature value, and sets the valid flag TRUE.
642 *
643 * (NOTE: MAYBE simplify this with member templates if/when that supported by compilers? - LGP 970314)
644 */
645 public:
646 nonvirtual FontNameSpecifier GetFontNameSpecifier () const;
647 nonvirtual bool GetFontNameSpecifier_Valid () const;
648 nonvirtual void InvalidateFontNameSpecifier ();
649 nonvirtual void SetFontNameSpecifier (FontNameSpecifier fontNameSpecifier);
650 nonvirtual void SetFontName (const SDKString& fontName);
651
652 // Style info
653 nonvirtual bool GetStyle_Plain () const; // special composite of all other styles...
654 nonvirtual bool GetStyle_Plain_Valid () const;
655 nonvirtual void InvalidateStyles ();
656 nonvirtual void SetStyle_Plain ();
657
658 nonvirtual bool GetStyle_Bold () const;
659 nonvirtual bool GetStyle_Bold_Valid () const;
660 nonvirtual void InvalidateStyle_Bold ();
661 nonvirtual void SetStyle_Bold (bool isBold);
662
663 nonvirtual bool GetStyle_Italic () const;
664 nonvirtual bool GetStyle_Italic_Valid () const;
665 nonvirtual void InvalidateStyle_Italic ();
666 nonvirtual void SetStyle_Italic (bool isItalic);
667
668 nonvirtual bool GetStyle_Underline () const;
669 nonvirtual bool GetStyle_Underline_Valid () const;
670 nonvirtual void InvalidateStyle_Underline ();
671 nonvirtual void SetStyle_Underline (bool isUnderline);
672
673 nonvirtual SubOrSuperScript GetStyle_SubOrSuperScript () const;
674 nonvirtual bool GetStyle_SubOrSuperScript_Valid () const;
675 nonvirtual void InvalidateStyle_SubOrSuperScript ();
676 nonvirtual void SetStyle_SubOrSuperScript (SubOrSuperScript subOrSuperScript);
677
678#if qStroika_Platform_Windows
679 nonvirtual bool GetStyle_Strikeout () const;
680 nonvirtual bool GetStyle_Strikeout_Valid () const;
681 nonvirtual void InvalidateStyle_Strikeout ();
682 nonvirtual void SetStyle_Strikeout (bool isStrikeout);
683#endif
684
685 /*
686 * Note the closely related nature of PointSize and PointSizeIncement.
687 * If one is set, that automatically unsets the other. You cannot set both
688 * at the same time. The former is used to specify the point size exactly.
689 * The latter is used to specify an ajdustment to the pointsize.
690 */
691 nonvirtual unsigned short GetPointSize () const;
692 nonvirtual bool GetPointSize_Valid () const;
693 nonvirtual void InvalidatePointSize ();
694 nonvirtual void SetPointSize (FontSize pointSize);
695#if qStroika_Platform_Windows
696 nonvirtual void PokeAtTMHeight (long tmHeight); // ditto
697#endif
698
699 nonvirtual short GetPointSizeIncrement () const;
700 nonvirtual bool GetPointSizeIncrement_Valid () const;
701 nonvirtual void InvalidatePointSizeIncrement ();
702 nonvirtual void SetPointSizeIncrement (short pointSizeIncrement);
703
704 nonvirtual Color GetTextColor () const;
705 nonvirtual bool GetTextColor_Valid () const;
706 nonvirtual void InvalidateTextColor ();
707 nonvirtual void SetTextColor (const Color& textColor);
708
709 public:
710#if qStroika_Platform_Windows
711 nonvirtual LOGFONT GetOSRep () const;
712 nonvirtual void GetOSRep (LOGFONT* logFont) const;
713 nonvirtual void SetOSRep (LOGFONT logFont); // marks all attribs as valid
714 nonvirtual void LightSetOSRep (LOGFONT logFont);
715 nonvirtual bool GetDidSetOSRepCallFlag () const; // special flag indicating user did SetOSRep() cuz that
716 // sets things valid that we don't have special 'valid' flags
717 // for. Makes MergeIn() just copy flat out!
718#endif
719
720 bool operator<=> (const IncrementalFontSpecification& rhs) = delete;
721 bool operator== (const IncrementalFontSpecification& rhs) const;
722
723 public:
724 nonvirtual void MergeIn (const IncrementalFontSpecification& addInTheseAttributes);
725
726 private:
727 bool fFontSpecifierValid : 1 {false};
728 bool fStyleValid_Bold : 1 {false};
729 bool fStyleValid_Italic : 1 {false};
730 bool fStyleValid_Underline : 1 {false};
731 bool fStyleValid_SubOrSuperScript : 1 {false};
732#if qStroika_Platform_Windows
733 bool fStyleValid_Strikeout : 1 {false};
734 bool fDidSetOSRepCallFlag : 1 {false};
735#endif
736 bool fFontSizeValid : 1 {false};
737 bool fFontSizeIncrementValid : 1 {false};
738 bool fTextColorValid : 1 {false};
739 };
740
741 IncrementalFontSpecification Intersection (const IncrementalFontSpecification& lhs, const IncrementalFontSpecification& rhs);
742
743 // Must support for other Platforms - but not done yet... Also - should have OPTIONS specified to this class (CTOR) picking various filter
744 // options...
745 class InstalledFonts {
746 public:
747 enum FilterOptions {
748#if qStroika_Platform_Windows
749 eSkipAtSignFonts = 0x1,
750 eSkipRasterFonts = 0x2,
751#endif
752
753#if qStroika_Platform_Windows
754 eDefaultFilterOptions = eSkipAtSignFonts | eSkipRasterFonts
755#else
756 eDefaultFilterOptions = 0
757#endif
758 };
759 InstalledFonts (FilterOptions filterOptions = eDefaultFilterOptions);
760
761 public:
762 nonvirtual const vector<SDKString>& GetUsableFontNames () const;
763
764 private:
765 FilterOptions fFilterOptions;
766 vector<SDKString> fFontNames;
767
768#if qStroika_Platform_Windows
769 private:
770 static BOOL FAR PASCAL FontFamilyAdderProc (ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int fontType, LPVOID pThis);
771#endif
772 };
773
774 // Query the OS for the default font that should be used for new text windows
775 FontSpecification GetStaticDefaultFont ();
776#if qStroika_Platform_Windows
777 FontSpecification GetStaticDefaultFont (BYTE charSet);
778#endif
779
780#if qStroika_Frameworks_Led_SupportGDI
781 /**
782 * Something of a hack version of GDI global variables. We want to keep certain GDI global variables
783 * computed ONCE, for speed reasons. And yet - if we get a certain windows message, we must refresh our cached global
784 * variables. The compromise is that all these globals are associated with this class, so that there is one place to
785 * call to refresh those globals.
786 */
787 class Globals {
788 public:
789 Globals ();
790
791 public:
792 static Globals& Get ();
793
794 private:
795 static Globals* sThe;
796
797 public:
798 nonvirtual void InvalidateGlobals ();
799
800 public:
801 nonvirtual DistanceType GetMainScreenLogPixelsH () const;
802 nonvirtual DistanceType GetMainScreenLogPixelsV () const;
803
804 public:
805 DistanceType fLogPixelsH;
806 DistanceType fLogPixelsV;
807
808 private:
809 class _Global_DESTRUCTOR_;
810 friend class _Global_DESTRUCTOR_;
811 };
812#endif
813
814 Led_Rect operator- (const Led_Rect& lhs, const Led_Point& rhs);
815 Led_Rect operator+ (Led_Point p, Led_Rect r);
816 Led_Rect operator+ (Led_Rect r, Led_Point p);
817 bool Intersect (const Led_Rect& lhs, const Led_Rect& rhs);
818#if qStroika_Frameworks_Led_SupportGDI
819 bool Intersect (const Led_Rect& lhs, const Region& rhs);
820 bool Intersect (const Region& lhs, const Led_Rect& rhs);
821 bool Intersect (const Region& lhs, const Region& rhs);
822#endif
823
824 Led_Rect Intersection (const Led_Rect& lhs, const Led_Rect& rhs);
825 Led_Rect operator* (const Led_Rect& lhs, const Led_Rect& rhs);
826
827 Led_Size operator+ (Led_Size lhs, Led_Size rhs);
828 Led_Size operator* (int lhs, Led_Size rhs);
829
830 Led_Rect InsetRect (const Led_Rect& r, int vBy, int hBy);
831 Led_Rect EnsureRectInRect (const Led_Rect& r, Led_Rect enlosingR);
832#if qStroika_Frameworks_Led_SupportGDI
833 Led_Rect EnsureRectOnScreen (const Led_Rect& r);
834#endif
835
836#if qStroika_Platform_Windows
837 Led_Point AsLedPoint (POINT p);
838 POINT AsPOINT (Led_Point p);
839 Led_Rect AsLedRect (RECT r);
840 RECT AsRECT (Led_Rect p);
841 SIZE AsSIZE (Led_Size s);
842 Led_Size AsLedSize (SIZE s);
843#endif
844
845#if qStroika_Frameworks_Led_SupportGDI
846 TWIPS Led_CvtScreenPixelsToTWIPSV (CoordinateType from);
847 TWIPS Led_CvtScreenPixelsToTWIPSH (CoordinateType from);
848 CoordinateType Led_CvtScreenPixelsFromTWIPSV (TWIPS from);
849 CoordinateType Led_CvtScreenPixelsFromTWIPSH (TWIPS from);
850#endif
851
852#if qStroika_Frameworks_Led_SupportGDI
853 /*
854 @CLASS: FontMetrics
855 @DESCRIPTION: <p><code>FontMetrics</code> is a portable wrapper class on the Windows
856 <em>TEXTMETRIC</em> structure. It provides
857 portable access to things like GetLineHeight (), and GetAscent (), etc...</p>
858 */
859 class FontMetrics {
860 public:
861 FontMetrics () = default;
862#if qStroika_Platform_Windows
863 FontMetrics (const TEXTMETRIC& from);
864#endif
865 FontMetrics (const FontMetrics&) = default;
866 FontMetrics& operator= (const FontMetrics& rhs) = default;
867
868 public:
869 nonvirtual DistanceType GetAscent () const;
870 nonvirtual DistanceType GetDescent () const;
871 nonvirtual DistanceType GetLeading () const;
872 nonvirtual DistanceType GetHeight () const; // does NOT include leading
873 nonvirtual DistanceType GetLineHeight () const; // includes leading
874
875 public:
876 nonvirtual DistanceType GetMaxCharacterWidth () const;
877#if qStroika_Platform_Windows
878 nonvirtual DistanceType GetAveCharacterWidth () const;
879#endif
880
881 // Convertion operator to make it easier to make GDI calls with one of our guys on a
882 // with something expected a system specific one - like to fill in its value!
883 public:
884#if qStroika_Platform_Windows
885 operator const TEXTMETRIC*() const;
886 operator TEXTMETRIC*();
887#endif
888
889 private:
890#if qStroika_Platform_Windows
891 TEXTMETRIC fPlatformSpecific{};
892#endif
893 };
894#endif
895
896#if qStroika_Frameworks_Led_SupportGDI
897 Color Led_GetTextColor ();
898 Color Led_GetTextBackgroundColor ();
899 Color Led_GetSelectedTextColor ();
900 Color Led_GetSelectedTextBackgroundColor ();
901
902 class OffscreenTablet;
903#endif
904
905#if qStroika_Frameworks_Led_SupportGDI
906 /**
907 * This class is used to wrap a low level graphics drawing device. On Windows - this is an HDC.</p>
908 *
909 * This class right now is a very thin wrapper on those drawing prodedures (mostly for backward compatability reasons.
910 * Eventually - it may do a better job of wrapping those concepts/APIs genericly.</p>
911 */
912 class Tablet {
913 public:
914#if qStroika_Platform_Windows
915 enum OwnDCControl {
916 eOwnsDC,
917 eDoesntOwnDC
918 };
919
920 Tablet (HDC hdc = nullptr, OwnDCControl ownsDC = eOwnsDC);
921#endif
922
923 public:
924 virtual ~Tablet ();
925
926 public:
927#if qStroika_Platform_Windows
928 nonvirtual operator HDC () const;
929#endif
930
931 public:
932 nonvirtual CoordinateType CvtFromTWIPSV (TWIPS from) const;
933 nonvirtual CoordinateType CvtFromTWIPSH (TWIPS from) const;
934 nonvirtual TWIPS CvtToTWIPSV (CoordinateType from) const;
935 nonvirtual TWIPS CvtToTWIPSH (CoordinateType from) const;
936
937 public:
938 nonvirtual Led_Point CvtFromTWIPS (TWIPS_Point from) const;
939 nonvirtual TWIPS_Point CvtToTWIPS (Led_Point from) const;
940 nonvirtual Led_Rect CvtFromTWIPS (TWIPS_Rect from) const;
941 nonvirtual TWIPS_Rect CvtToTWIPS (Led_Rect from) const;
942
943 public:
944 nonvirtual void ScrollBitsAndInvalRevealed (const Led_Rect& windowRect, CoordinateType scrollBy);
945 nonvirtual void FrameRegion (const Region& r, const Color& c);
946
947 public:
948 nonvirtual void FrameRectangle (const Led_Rect& r, Color c, DistanceType borderWidth);
949
950 public:
951#if qStroika_Platform_Windows
952 nonvirtual BOOL BitBlt (int x, int y, int nWidth, int nHeight, Tablet* pSrcDC, int xSrc, int ySrc, DWORD dwRop);
953 nonvirtual BOOL CreateCompatibleDC (Tablet* pDC);
954 nonvirtual COLORREF SetTextColor (COLORREF crColor);
955 nonvirtual COLORREF SetBkColor (COLORREF crColor);
956 nonvirtual BOOL IsPrinting () const;
957 nonvirtual BOOL RoundRect (int x1, int y1, int x2, int y2, int x3, int y3);
958 nonvirtual BOOL TextOut (int x, int y, LPCTSTR lpszString, int nCount);
959 // nonvirtual SIZE GetTextExtent (LPCTSTR lpszString, int nCount) const;
960 nonvirtual int SetBkMode (int nBkMode);
961 nonvirtual SIZE GetWindowExt () const;
962 nonvirtual SIZE GetViewportExt () const;
963 nonvirtual BOOL Rectangle (int x1, int y1, int x2, int y2);
964 nonvirtual BOOL Rectangle (const RECT& r);
965 nonvirtual BOOL Rectangle (LPCRECT lpRect);
966 nonvirtual BOOL GetTextMetrics (LPTEXTMETRIC lpMetrics) const;
967 nonvirtual HBITMAP SelectObject (HBITMAP hBitmap);
968#if defined(STRICT)
969 nonvirtual HFONT SelectObject (HFONT hFont);
970#endif
971 nonvirtual POINT SetWindowOrg (int x, int y);
972 nonvirtual int GetDeviceCaps (int nIndex) const;
973 nonvirtual BOOL Attach (HDC hDC, OwnDCControl ownsDC = eOwnsDC);
974 nonvirtual HDC Detach ();
975#endif
976
977#if qStroika_Platform_Windows
978 private:
979 nonvirtual HWND GetWindow () const;
980 nonvirtual unsigned int SetTextAlign (unsigned int nTextAlign);
981#endif
982
983 public:
984 nonvirtual void MoveTo (const Led_Point& to);
985 nonvirtual void LineTo (const Led_Point& to);
986
987 public:
988 nonvirtual void MeasureText (const FontMetrics& precomputedFontMetrics, const Led_tChar* text, size_t nTChars, DistanceType* charLocations);
989 nonvirtual void TabbedTextOut (const FontMetrics& precomputedFontMetrics, const Led_tChar* text, size_t nBytes,
990 TextDirection direction, Led_Point outputAt, CoordinateType hTabOrigin,
991 const TabStopList& tabStopList, DistanceType* amountDrawn, CoordinateType hScrollOffset);
992
993 public:
994 nonvirtual void SetBackColor (const Color& backColor);
995 nonvirtual void SetForeColor (const Color& foreColor);
996
997 public:
998 nonvirtual void EraseBackground_SolidHelper (const Led_Rect& eraseRect, const Color& eraseColor);
999 nonvirtual void HilightArea_SolidHelper (const Led_Rect& hilightArea, Color hilightBackColor, Color hilightForeColor,
1000 Color oldBackColor, Color oldForeColor);
1001 nonvirtual void HilightArea_SolidHelper (const Region& hilightArea, Color hilightBackColor, Color hilightForeColor,
1002 Color oldBackColor, Color oldForeColor);
1003
1004#if qStroika_Platform_Windows
1005 private:
1006 class RecolorHelper;
1007
1008 private:
1009 RecolorHelper* fRecolorHelper;
1010#endif
1011
1012 public:
1013 class ClipNarrowAndRestore;
1014
1015 public:
1016 nonvirtual Region GetClip () const;
1017 nonvirtual bool GetClip (Region* r) const;
1018 nonvirtual void SetClip ();
1019 nonvirtual void SetClip (const Led_Rect& clipTo);
1020 nonvirtual void SetClip (const Region& clipTo);
1021
1022 public:
1023 nonvirtual FontMetrics GetFontMetrics () const;
1024
1025#if qStroika_Platform_Windows
1026 public:
1027 HDC m_hDC; // The output DC (must be first data member)
1028 HDC m_hAttribDC; // The Attribute DC
1029 BOOL m_bPrinting;
1030 OwnDCControl fOwnsDC;
1031
1032 private:
1033 mutable DistanceType fLogPixelsV;
1034 mutable DistanceType fLogPixelsH;
1035#endif
1036
1037 public:
1038 friend class OffscreenTablet;
1039 };
1040
1041 /*
1042 @CLASS: Tablet::ClipNarrowAndRestore
1043 @DESCRIPTION: <p>Further narrow the existing clip region in the given tablet to the constructor. Then
1044 restore the clip region for the tablet to what it was when the contructor was called.</p>
1045 */
1046 class Tablet::ClipNarrowAndRestore {
1047 public:
1048 ClipNarrowAndRestore (Tablet* tablet);
1049 ClipNarrowAndRestore (Tablet* tablet, const Led_Rect& clipFurtherTo);
1050 ClipNarrowAndRestore (Tablet* tablet, const Region& clipFurtherTo);
1051 ~ClipNarrowAndRestore ();
1052
1053 private:
1054 Tablet* fTablet;
1055 bool fHasOldClip;
1056 Region fOldClip;
1057 };
1058
1059#if qStroika_Platform_Windows
1060 class WindowDC : public Tablet {
1061 public:
1062 WindowDC (HWND hWnd);
1063 ~WindowDC ();
1064
1065 private:
1066 HWND fHWnd_;
1067 };
1068#endif
1069
1070#if qStroika_Platform_Windows
1071 class Bitmap {
1072 public:
1073 Bitmap () = default;
1074 ~Bitmap ();
1075
1076 public:
1077 nonvirtual void DeleteObject ();
1078 nonvirtual operator HBITMAP () const;
1079
1080 public:
1081 nonvirtual Led_Size GetImageSize () const;
1082 nonvirtual BOOL CreateCompatibleBitmap (HDC hdc, DistanceType nWidth, DistanceType nHeight);
1083 nonvirtual BOOL CreateCompatibleDIBSection (HDC hdc, DistanceType nWidth, DistanceType nHeight);
1084 nonvirtual void LoadBitmap (HINSTANCE hInstance, LPCTSTR lpBitmapName);
1085
1086 private:
1087 HBITMAP m_hObject{nullptr};
1088 Led_Size fImageSize{};
1089 };
1090#endif
1091
1092 /*
1093 @DESCRIPTION: <p>An offscreen tablet is a helper object used to do offscreen imaging. This is useful in
1094 avoidance of flicker. Also, by encapsulating this procedure into a class, it becomes easier
1095 to add the functionality to several places in Led, yet with very different underlying implementations
1096 on each platform.</p>
1097 */
1098 class OffscreenTablet {
1099 public:
1100 OffscreenTablet ();
1101 ~OffscreenTablet ();
1102
1103 public:
1104 nonvirtual void Setup (Tablet* origTablet);
1105 nonvirtual Tablet* PrepareRect (const Led_Rect& currentRowRect, DistanceType extraToAddToBottomOfRect = 0);
1106 nonvirtual void BlastBitmapToOrigTablet ();
1107
1108 private:
1109 class OT : public Tablet {
1110 private:
1111 using inherited = Tablet;
1112
1113 public:
1114#if qStroika_Platform_Windows
1115 OT (HDC hdc = nullptr, OwnDCControl ownsDC = eOwnsDC);
1116#endif
1117 };
1118
1119 private:
1120 Tablet* fOrigTablet;
1121 Led_Rect fOffscreenRect;
1122 Tablet* fOffscreenTablet;
1123#if qStroika_Platform_Windows
1124 OT fMemDC;
1125 Bitmap fMemoryBitmap; // only can create / select inside loop cuz there is where we know the size.
1126 // but decare outside, so stays around for successive rows which are the same size.
1127 HBITMAP fOldBitmapInDC; // used for save/restore of bitmap associated with the DC.
1128#endif
1129 };
1130
1131 /*
1132 @DESCRIPTION: <p><code>GDI_Obj_Selector</code> is a stack-based class designed to help
1133 out selecting objects into a Tablet* (windows DC, grafport, etc).
1134 <p>The constructor takes a tablet, and object to select into it (HGDIObject, etc),
1135 and selects it into the tablet. It saves gthe results of the SelectObject calls (old values).
1136 And on its destructor, it restores the old values.</p>
1137 <p>This is useful when you want to make sure that an object you've selected into a tablet (HDC)
1138 will be released, and restored to its original state through all paths through
1139 the code, including in the even of exceptions.</p>
1140 */
1141 class GDI_Obj_Selector {
1142 public:
1143#if qStroika_Platform_Windows
1144 GDI_Obj_Selector (Tablet* tablet, HGDIOBJ objToSelect);
1145#endif
1146 public:
1147 ~GDI_Obj_Selector ();
1148
1149 private:
1150 Tablet* fTablet;
1151#if qStroika_Platform_Windows
1152 HGDIOBJ fRestoreObject;
1153 HGDIOBJ fRestoreAttribObject;
1154#endif
1155 };
1156#endif
1157
1158 /*
1159 @CLASS: Led_Picture
1160 @DESCRIPTION: <p><code>Led_Picture</code> is a portable abstraction of a Macintosh Picture object.
1161 It can be displayed on Windows (only if Apples
1162 QuickTime is installed). There are a bunch of routines (e.g Led_GetMacPictTop) which portable
1163 allow access to the size of the picture (even on windows if QT not available). And there are
1164 portable routines to draw the picture (again, with the windows QT caveat).</p>
1165 */
1166 struct Led_Picture {
1167 short picSize;
1168 short picFrameTop;
1169 short picFrameLeft;
1170 short picFrameBottom;
1171 short picFrameRight;
1172 // other data off end (specified by picSize) - note byte order for shorts is MAC
1173 };
1174
1175 short Led_GetMacPictTop (const Led_Picture* picture);
1176 short Led_GetMacPictLeft (const Led_Picture* picture);
1177 short Led_GetMacPictBottom (const Led_Picture* picture);
1178 short Led_GetMacPictRight (const Led_Picture* picture);
1179 short Led_GetMacPictWidth (const Led_Picture* picture);
1180 short Led_GetMacPictHeight (const Led_Picture* picture);
1181 Led_Size Led_GetMacPictSize (const Led_Picture* picture);
1182
1183// Windows DIB support
1184#ifndef qStroika_Frameworks_Led_HaveWindowsDIBDefined
1185#define qStroika_Frameworks_Led_HaveWindowsDIBDefined qStroika_Platform_Windows
1186#endif
1187
1188#if !qStroika_Frameworks_Led_HaveWindowsDIBDefined
1189 // structs copied (paraphrased) from MSVC 4.1 includes (WinGDI.h)
1190 struct BITMAPINFOHEADER {
1191 unsigned long biSize;
1192 long biWidth;
1193 long biHeight;
1194 unsigned short biPlanes;
1195 unsigned short biBitCount;
1196 unsigned long biCompression;
1197 unsigned long biSizeImage;
1198 long biXPelsPerMeter;
1199 long biYPelsPerMeter;
1200 unsigned long biClrUsed;
1201 unsigned long biClrImportant;
1202 };
1203 struct BITMAPCOREHEADER {
1204 unsigned long bcSize;
1205 unsigned short bcWidth;
1206 unsigned short bcHeight;
1207 unsigned short bcPlanes;
1208 unsigned short bcBitCount;
1209 };
1210 struct RGBQUAD {
1211 unsigned char rgbBlue;
1212 unsigned char rgbGreen;
1213 unsigned char rgbRed;
1214 unsigned char rgbReserved;
1215 };
1216 struct RGBTRIPLE {
1217 unsigned char rgbtBlue;
1218 unsigned char rgbtGreen;
1219 unsigned char rgbtRed;
1220 };
1221 struct BITMAPINFO {
1222 BITMAPINFOHEADER bmiHeader;
1223 RGBQUAD bmiColors[1];
1224 };
1225#endif
1226 /*
1227 @CLASS: Led_DIB
1228 @DESCRIPTION: <p><em>Led_DIB</em> is a MS-Windows DIB (device independent bitmap) object. Much
1229 like @'Led_Picture', it has a host of accessor routines to get at its size, etc. But slightly
1230 better than Led_Picture, Led_DIB can be rendered on the Mac without assuming any special
1231 software (ie no analog to QT) is available. The downside is that I only support a few types
1232 of DIBs, but I appear to have most that windows currently generates. And it wouldn't be
1233 too hard to extend the code to support a few more types, if I knew what they were.</p>
1234 */
1235 using Led_DIB = BITMAPINFO;
1236
1237 Led_Size Led_GetDIBImageSize (const Led_DIB* dib);
1238 size_t Led_GetDIBPalletByteCount (const Led_DIB* dib);
1239 size_t Led_GetDIBImageRowByteCount (const Led_DIB* dib);
1240 size_t Led_GetDIBImageByteCount (const Led_DIB* dib);
1241 Led_DIB* Led_CloneDIB (const Led_DIB* dib);
1242 const void* Led_GetDIBBitsPointer (const Led_DIB* dib);
1243
1244#if qStroika_Platform_Windows
1245 Led_DIB* Led_DIBFromHBITMAP (HDC hDC, HBITMAP hbm);
1246#endif
1247
1248#if qStroika_Frameworks_Led_SupportGDI
1249
1250 void AddRectangleToRegion (Led_Rect addRect, Region* toRgn);
1251#endif
1252
1253#if qStroika_Frameworks_Led_ProvideIMESupport
1254 class IME {
1255 public:
1256 IME ();
1257
1258 public:
1259 static IME& Get ();
1260
1261 private:
1262 static IME* sThe;
1263
1264 private:
1265 nonvirtual bool Available () const; //tmphack - don't think this is ever used
1266 public:
1267 nonvirtual void ForgetPosition ();
1268 nonvirtual void NotifyPosition (HWND pWnd, const SHORT x, const SHORT y);
1269 nonvirtual void NotifyOfFontChange (HWND hWnd, const LOGFONT& lf);
1270 nonvirtual void IMEOn (HWND pWnd);
1271 nonvirtual void IMEOff (HWND pWnd);
1272 nonvirtual void Enable ();
1273 nonvirtual void Disable ();
1274 nonvirtual wstring GetCompositionResultStringW (HWND hWnd);
1275
1276 private:
1277 nonvirtual void UpdatePosition (const HWND hWnd, const SHORT x, const SHORT y);
1278 nonvirtual void SendSimpleMessage (HWND pWnd, UINT fnc, WPARAM wParam);
1279
1280 LRESULT (FAR PASCAL* fSendIMEMessageProc)
1281 (HWND, DWORD);
1282 BOOL (FAR PASCAL* fIMEEnableProc) (HWND, BOOL);
1283 HIMC (FAR PASCAL* fImmGetContext) (HWND);
1284 BOOL (FAR PASCAL* fImmSetCompositionFont) (HIMC, const LOGFONT*);
1285 BOOL (FAR PASCAL* fImmReleaseContext) (HWND, HIMC);
1286 LONG (FAR PASCAL* fImmGetCompositionStringW) (HIMC, DWORD, LPVOID, DWORD);
1287 BOOL (FAR PASCAL* fImmSetCompositionWindow) (HIMC, const void*);
1288 BOOL (FAR PASCAL* fImmSetOpenStatus) (HIMC, BOOL);
1289
1290 bool fWinNlsAvailable;
1291 SHORT fLastX;
1292 SHORT fLastY;
1293
1294 private:
1295 class _Global_DESTRUCTOR_;
1296 friend class _Global_DESTRUCTOR_;
1297 };
1298#endif
1299
1300 Led_Rect CenterRectInRect (const Led_Rect& r, const Led_Rect& centerIn);
1301#if qStroika_Platform_Windows
1302 void Led_CenterWindowInParent (HWND w);
1303#endif
1304
1305}
1306
1307/*
1308 ********************************************************************************
1309 ***************************** Implementation Details ***************************
1310 ********************************************************************************
1311 */
1312#include "GDI.inl"
1313
1314#endif /*_Stroika_Frameworks_Led_GDI_h_*/
set< T > Intersection(const set< T > &s1, const set< T > &s2)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
conditional_t< qStroika_Foundation_Characters_SDKUseswchar_t, wchar_t, char > SDKChar
Definition SDKChar.h:77