diff --git a/Common/Gfx/Canvas.h b/Common/Gfx/Canvas.h index 1285d861..f45ab82c 100644 --- a/Common/Gfx/Canvas.h +++ b/Common/Gfx/Canvas.h @@ -26,6 +26,7 @@ namespace Gfx { +// Provides methods for drawing text, bitmaps, etc. class __declspec(novtable) Canvas { public: @@ -34,6 +35,8 @@ public: int GetW() const { return m_W; } int GetH() const { return m_H; } + // Resize the draw area of the Canvas. This function must not be called if BeginDraw() has been + // called and has not yet been matched by a correspoding call to EndDraw. virtual void Resize(int w, int h); // BeginDraw() must be matched by a corresponding call to EndDraw(). Drawing functions must be @@ -54,6 +57,7 @@ public: virtual HDC GetDC() = 0; virtual void ReleaseDC(HDC dc) = 0; + // The Create* functions allocate objects specific to this Canvas object. virtual FontCollection* CreateFontCollection() = 0; virtual TextFormat* CreateTextFormat() = 0; diff --git a/Common/Gfx/TextFormat.h b/Common/Gfx/TextFormat.h index 9878e5f0..47082166 100644 --- a/Common/Gfx/TextFormat.h +++ b/Common/Gfx/TextFormat.h @@ -39,17 +39,24 @@ enum class VerticalAlignment : BYTE Bottom }; +// Represents the logical font properties used to format text. class __declspec(novtable) TextFormat { public: virtual ~TextFormat(); + // Returns true if this TextFormat object is valid for use in draw operations. virtual bool IsInitialized() const = 0; + // Sets the logical properties of the font to use. If the font is not found in the system font + // collection, the given |fontCollection| is also searched. |fontCollection| may be nullptr. virtual void SetProperties( const WCHAR* fontFamily, int size, bool bold, bool italic, const FontCollection* fontCollection) = 0; + // Sets the trimming and wrapping of the text. If |trim| is true, subsequent draws using this + // TextFormat object will produce clipped text with an ellipsis if the text overflows the + // bounding rectangle. virtual void SetTrimming(bool trim) = 0; virtual void SetHorizontalAlignment(HorizontalAlignment alignment); diff --git a/Common/Gfx/TextFormatD2D.h b/Common/Gfx/TextFormatD2D.h index 02cee99b..2c4f292c 100644 --- a/Common/Gfx/TextFormatD2D.h +++ b/Common/Gfx/TextFormatD2D.h @@ -25,6 +25,7 @@ namespace Gfx { +// Provides a Direct2D/DirectWrite implementation of TextFormat for use with CanvasD2D. class TextFormatD2D : public TextFormat { public: @@ -38,6 +39,7 @@ public: const FontCollection* fontCollection) override; virtual void SetTrimming(bool trim) override; + virtual void SetHorizontalAlignment(HorizontalAlignment alignment) override; virtual void SetVerticalAlignment(VerticalAlignment alignment) override; diff --git a/Common/Gfx/TextFormatGDIP.h b/Common/Gfx/TextFormatGDIP.h index 8e294466..f363204f 100644 --- a/Common/Gfx/TextFormatGDIP.h +++ b/Common/Gfx/TextFormatGDIP.h @@ -24,6 +24,7 @@ namespace Gfx { +// Provides a GDI+ implementation of TextFormat for use with CanvasGDIP. class TextFormatGDIP : public TextFormat { public: @@ -37,6 +38,7 @@ public: const FontCollection* fontCollection) override; virtual void SetTrimming(bool trim) override; + virtual void SetHorizontalAlignment(HorizontalAlignment alignment) override; virtual void SetVerticalAlignment(VerticalAlignment alignment) override;