diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index ec68626ac..2a226c5b8 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -117,8 +117,8 @@ public: bool IsItalic() const { return v.flags & FONT_ITALIC; } bool IsUnderline() const { return v.flags & FONT_UNDERLINE; } bool IsStrikeout() const { return v.flags & FONT_STRIKEOUT; } - bool IsNonAntiAliased() const { return v.flags & FONT_NON_ANTI_ALIASED; } - bool IsTrueTypeOnly() const { return v.flags & FONT_TRUE_TYPE_ONLY; } + bool IsNonAntiAliased() const { return v.flags & FONT_NON_ANTI_ALIASED; } // deprecated + bool IsTrueTypeOnly() const { return v.flags & FONT_TRUE_TYPE_ONLY; } // deprecated String GetFaceName() const; String GetFaceNameStd() const; dword GetFaceInfo() const; @@ -142,11 +142,11 @@ public: Font& NoStrikeout() { v.flags &= ~FONT_STRIKEOUT; return *this; } Font& Strikeout(bool b) { return b ? Strikeout() : NoStrikeout(); } Font& NonAntiAliased() { v.flags |= FONT_NON_ANTI_ALIASED; return *this; } - Font& NoNonAntiAliased() { v.flags &= ~FONT_NON_ANTI_ALIASED; return *this; } - Font& NonAntiAliased(bool b) { return b ? NonAntiAliased() : NoNonAntiAliased(); } - Font& TrueTypeOnly() { v.flags |= FONT_TRUE_TYPE_ONLY; return *this; } - Font& NoTrueTypeOnly() { v.flags &= ~FONT_TRUE_TYPE_ONLY; return *this; } - Font& TrueTypeOnly(bool b) { return b ? TrueTypeOnly() : NoTrueTypeOnly(); } + Font& NoNonAntiAliased() { v.flags &= ~FONT_NON_ANTI_ALIASED; return *this; } // deprecated + Font& NonAntiAliased(bool b) { return b ? NonAntiAliased() : NoNonAntiAliased(); } // deprecated + Font& TrueTypeOnly() { v.flags |= FONT_TRUE_TYPE_ONLY; return *this; } // deprecated + Font& NoTrueTypeOnly() { v.flags &= ~FONT_TRUE_TYPE_ONLY; return *this; } // deprecated + Font& TrueTypeOnly(bool b) { return b ? TrueTypeOnly() : NoTrueTypeOnly(); } // deprecated Font& FaceName(const String& name); @@ -247,7 +247,7 @@ String AsString(const Font& f); inline void SetStdFont(Font font) { Font::SetStdFont(font); } inline Font GetStdFont() { return Font::GetStdFont(); } -inline Size GetStdFontSize() { return Font::GetStdFontSize(); } +inline Size GetStdFontSize() { return Font::GetStdFontSize(); } // deprecated inline int GetStdFontCy() { return GetStdFontSize().cy; } Font StdFont(); @@ -258,13 +258,13 @@ inline Font Serif(int n = -32000) { return Font(Font::SCREEN_SERIF, n); } inline Font SansSerif(int n = -32000) { return Font(Font::SCREEN_SANS, n); } inline Font Monospace(int n = -32000) { return Font(Font::SCREEN_FIXED, n); } -inline Font Roman(int n = -32000) { return Font(Font::SCREEN_SERIF, n); } -inline Font Arial(int n = -32000) { return Font(Font::SCREEN_SANS, n); } -inline Font Courier(int n = -32000) { return Font(Font::SCREEN_FIXED, n); } +inline Font Roman(int n = -32000) { return Font(Font::SCREEN_SERIF, n); } // deprecated +inline Font Arial(int n = -32000) { return Font(Font::SCREEN_SANS, n); } // deprecated +inline Font Courier(int n = -32000) { return Font(Font::SCREEN_FIXED, n); } // deprecated -inline Font ScreenSerif(int n = -32000) { return Font(Font::SCREEN_SERIF, n); } -inline Font ScreenSans(int n = -32000) { return Font(Font::SCREEN_SANS, n); } -inline Font ScreenFixed(int n = -32000) { return Font(Font::SCREEN_FIXED, n); } +inline Font ScreenSerif(int n = -32000) { return Font(Font::SCREEN_SERIF, n); } // deprecated +inline Font ScreenSans(int n = -32000) { return Font(Font::SCREEN_SANS, n); } // deprecated +inline Font ScreenFixed(int n = -32000) { return Font(Font::SCREEN_FIXED, n); } // deprecated #ifdef PLATFORM_WIN32 // backward comaptibility inline Font Tahoma(int n = -32000) { return Font(Font::TAHOMA, n); } @@ -929,6 +929,16 @@ void DrawHighlightImage(Draw& w, int x, int y, const Image& img, bool highlight Color GradientColor(Color fc, Color tc, int i, int n); +void DrawTextEllipsis(Draw& w, int x, int y, int cx, const char *text, const char *ellipsis, + Font font = StdFont(), Color ink = SColorText(), int n = -1); +void DrawTextEllipsis(Draw& w, int x, int y, int cx, const wchar *text, const char *ellipsis, + Font font = StdFont(), Color ink = SColorText(), int n = -1); + +Size GetTLTextSize(const wchar *text, Font font = StdFont()); +int GetTLTextHeight(const wchar *s, Font font = StdFont()); +void DrawTLText(Draw& draw, int x, int y, int cx, const wchar *text, Font font = StdFont(), + Color ink = SColorText(), int accesskey = 0); + enum { BUTTON_NORMAL, BUTTON_OK, BUTTON_HIGHLIGHT, BUTTON_PUSH, BUTTON_DISABLED, BUTTON_CHECKED, BUTTON_VERTICAL = 0x100, @@ -939,16 +949,6 @@ enum { void DrawXPButton(Draw& w, Rect r, int type); -void DrawTextEllipsis(Draw& w, int x, int y, int cx, const char *text, const char *ellipsis, - Font font = StdFont(), Color ink = SColorText(), int n = -1); -void DrawTextEllipsis(Draw& w, int x, int y, int cx, const wchar *text, const char *ellipsis, - Font font = StdFont(), Color ink = SColorText(), int n = -1); -Size GetTLTextSize(const wchar *text, Font font = StdFont()); -int GetTLTextHeight(const wchar *s, Font font = StdFont()); -void DrawTLText(Draw& draw, int x, int y, int cx, const wchar *text, Font font = StdFont(), - Color ink = SColorText(), int accesskey = 0); - - struct PdfSignatureInfo; typedef String (*DrawingToPdfFnType)(const Array& report, Size pagesize, int margin, bool pdfa, const PdfSignatureInfo *sign); diff --git a/uppsrc/Draw/src.tpp/FontTextUtils_en-us.tpp b/uppsrc/Draw/src.tpp/FontTextUtils_en-us.tpp index 88060562f..c42d59842 100644 --- a/uppsrc/Draw/src.tpp/FontTextUtils_en-us.tpp +++ b/uppsrc/Draw/src.tpp/FontTextUtils_en-us.tpp @@ -1,5 +1,4 @@ topic "Font and Text Routines"; -[2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] [0 $$3,0#96390100711032703541132217272105:end] @@ -9,9 +8,59 @@ topic "Font and Text Routines"; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] +[2 $$0,0#00000000000000000000000000000000:Default] [{_} [ {{10000@(113.42.0) [s0;%% [*@7;4 Font and Text Routines]]}}&] [s3; &] +[s5;:Upp`:`:SetStdFont`(Upp`:`:Font`): [@(0.0.255) void]_[* SetStdFont]([_^Upp`:`:Font^ Fon +t]_[*@3 font])&] +[s2;%% Sets the standard font. This is the default font used to draw +most GUI texts. Standard font is normally set during GUI startup +and application rarely need to call this function.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:GetStdFont`(`): [_^Upp`:`:Font^ Font]_[* GetStdFont]()&] +[s2;%% Returns the standard font.&] +[s3; &] +[s4; &] +[s5;:Upp`:`:GetStdFontCy`(`): [@(0.0.255) int]_[* GetStdFontCy]()&] +[s2;%% Returns the standard font height (in pixels or dots).&] +[s3; &] +[s4; &] +[s5;:Upp`:`:StdFont`(`): [_^Upp`:`:Font^ Font]_[* StdFont]()&] +[s2;%% Same as GetStdFont().&] +[s3; &] +[s4; &] +[s5;:Upp`:`:StdFont`(int`): [_^Upp`:`:Font^ Font]_[* StdFont]([@(0.0.255) int]_[*@3 h])&] +[s2;%% Returns standard font with height changed to [%-*@3 h].&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Serif`(int`): [_^Upp`:`:Font^ Font]_[* Serif]([@(0.0.255) int]_[*@3 n])&] +[s2;%% Returns default serif font with height [%-*@3 n].&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:SansSerif`(int`): [_^Upp`:`:Font^ Font]_[* SansSerif]([@(0.0.255) int]_[*@3 n]_`= +_`-[@3 32000])&] +[s2;%% Returns default sans`-serif font with height [%-*@3 n].&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Monospace`(int`): [_^Upp`:`:Font^ Font]_[* Monospace]([@(0.0.255) int]_[*@3 n]_`= +_`-[@3 32000])&] +[s2;%% Returns default monospace font with height [%-*@3 n].&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Compose`(Upp`:`:Font`,int`,Upp`:`:ComposedGlyph`&`): [@(0.0.255) bool]_[* Com +pose]([_^Upp`:`:Font^ Font]_[*@3 font], [@(0.0.255) int]_[*@3 chr], [_^Upp`:`:ComposedGlyph^ C +omposedGlyph][@(0.0.255) `&]_[*@3 cg])&] +[s2;%% This function is used by DrawText implementation when unicode +point [%-*@3 chr] is missing in [%-*@3 font]. Function tries to find +two glyphs, one from original font and second possibly from other +font which, when composed, result in character corresponding +to required codepoint (e.g. [*@(255.0.255) C] `+ [*@(255.0.255) ˇ] +`= [*@(255.0.255) Č]). If such glyphs exist, they are returned +in [%-*@3 cg] and function returns true.&] +[s3;%% &] +[s4; &] [s5;:GetTextSize`(const wchar`*`,Font`,int`): [_^Size^ Size]_[* GetTextSize]([@(0.0.255) co nst]_[_^wchar^ wchar]_`*[*@3 text], [_^Font^ Font]_[*@3 font], [@(0.0.255) int]_[*@3 n]_`=_`- [@3 1])&] @@ -33,4 +82,48 @@ are considered. [%-*@3 n] is a number of characters; if negative be unicode or in 8`-bit encoding; in that case either [%-*@3 charset] is provided or it is assumed to be default charset.&] [s3;%% &] -[s0; ] \ No newline at end of file +[s4; &] +[s5;:Upp`:`:DrawTextEllipsis`(Upp`:`:Draw`&`,int`,int`,int`,const char`*`,const char`*`,Upp`:`:Font`,Upp`:`:Color`,int`): [@(0.0.255) v +oid]_[* DrawTextEllipsis]([_^Upp`:`:Draw^ Draw][@(0.0.255) `&]_[*@3 w], +[@(0.0.255) int]_[*@3 x], [@(0.0.255) int]_[*@3 y], [@(0.0.255) int]_[*@3 cx], +[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 e +llipsis], [_^Upp`:`:Font^ Font]_[*@3 font]_`=_StdFont(), [_^Upp`:`:Color^ Color]_[*@3 ink +]_`=_SColorText(), [@(0.0.255) int]_[*@3 n]_`=_`-[@3 1])&] +[s5;:Upp`:`:DrawTextEllipsis`(Upp`:`:Draw`&`,int`,int`,int`,const Upp`:`:wchar`*`,const char`*`,Upp`:`:Font`,Upp`:`:Color`,int`): [@(0.0.255) v +oid]_[* DrawTextEllipsis]([_^Upp`:`:Draw^ Draw][@(0.0.255) `&]_[*@3 w], +[@(0.0.255) int]_[*@3 x], [@(0.0.255) int]_[*@3 y], [@(0.0.255) int]_[*@3 cx], +[@(0.0.255) const]_[_^Upp`:`:wchar^ wchar]_`*[*@3 text], [@(0.0.255) const]_[@(0.0.255) cha +r]_`*[*@3 ellipsis], [_^Upp`:`:Font^ Font]_[*@3 font]_`=_StdFont(), +[_^Upp`:`:Color^ Color]_[*@3 ink]_`=_SColorText(), [@(0.0.255) int]_[*@3 n]_`=_`-[@3 1])&] +[s2;%% Draws a [%-*@3 text] line limited in width to [%-*@3 cx]. If the +text is longer than what could be fitted to [%-*@3 cx] , it is +it is truncated so that it fits together with [%-*@3 ellipsis] +text appended into [%-*@3 cx], then drawn with [%-*@3 ellipsis] appended. +[%-*@3 n] is the number of characters to be drawn, if `-1, `[w`]strlen(text) +is used instead.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:DrawTLText`(Upp`:`:Draw`&`,int`,int`,int`,const Upp`:`:wchar`*`,Upp`:`:Font`,Upp`:`:Color`,int`): [@(0.0.255) v +oid]_[* DrawTLText]([_^Upp`:`:Draw^ Draw][@(0.0.255) `&]_[*@3 draw], +[@(0.0.255) int]_[*@3 x], [@(0.0.255) int]_[*@3 y], [@(0.0.255) int]_[*@3 cx], +[@(0.0.255) const]_[_^Upp`:`:wchar^ wchar]_`*[*@3 text], [_^Upp`:`:Font^ Font]_[*@3 font]_`= +_StdFont(), [_^Upp`:`:Color^ Color]_[*@3 ink]_`=_SColorText(), [@(0.0.255) int]_[*@3 acce +sskey]_`=_[@3 0])&] +[s2;%% This function draws multiline text with tabs (contains `'`\n`' +and `'`\t`'), possibly underline single character [%-*@3 accesskey +]in the text. Width is limited by [%-*@3 cx] and text is word `- +wrapped if line is longer.&] +[s0;%% &] +[s4; &] +[s5;:Upp`:`:GetTLTextSize`(const Upp`:`:wchar`*`,Upp`:`:Font`): [_^Upp`:`:Size^ Size]_[* G +etTLTextSize]([@(0.0.255) const]_[_^Upp`:`:wchar^ wchar]_`*[*@3 text], +[_^Upp`:`:Font^ Font]_[*@3 font]_`=_StdFont())&] +[s2;%% Returns the size of multiline text with tabs.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:GetTLTextHeight`(const Upp`:`:wchar`*`,Upp`:`:Font`): [@(0.0.255) int]_[* Get +TLTextHeight]([@(0.0.255) const]_[_^Upp`:`:wchar^ wchar]_`*[*@3 s], +[_^Upp`:`:Font^ Font]_[*@3 font])&] +[s2;%% Same as GetTLTextSize(s, font).cy.&] +[s3;%% &] +[s0; ]] \ No newline at end of file diff --git a/uppsrc/Draw/src.tpp/Font_en-us.tpp b/uppsrc/Draw/src.tpp/Font_en-us.tpp index 8eeb5da32..2689e8aee 100644 --- a/uppsrc/Draw/src.tpp/Font_en-us.tpp +++ b/uppsrc/Draw/src.tpp/Font_en-us.tpp @@ -166,6 +166,7 @@ normally returns), it is replaced with standard font height.&] [s5;:Font`:`:NoNonAntiAliased`(`): [_^Font^ Font][@(0.0.255) `&]_[* NoNonAntiAliased]()&] [s5;:Font`:`:NonAntiAliased`(bool`): [_^Font^ Font][@(0.0.255) `&]_[* NonAntiAliased]([@(0.0.255) b ool]_[@3 b])&] +[s6; `[deprecated`]&] [s2;%% Sets/unsets non`-anti`-aliased flag. This indicates that anti`-aliasing should not be used when painting the font.&] [s3; &] @@ -391,22 +392,22 @@ curves.&] not active.&] [s3; &] [s4; &] -[s5;:Font`:`:Font`(int`,int`): Font([@(0.0.255) int]_[@3 face], [@(0.0.255) int]_[@3 height]) -&] +[s5;:Font`:`:Font`(int`,int`): [* Font]([@(0.0.255) int]_[*@3 face], [@(0.0.255) int]_[*@3 heig +ht])&] [s2;%% Initializes font to [%-*@3 face] index and [%-*@3 height].&] [s3; &] [s4; &] -[s5;:Font`:`:Font`(const Nuller`&`): Font([@(0.0.255) const]_[_^Nuller^ Nuller][@(0.0.255) `& +[s5;:Font`:`:Font`(const Nuller`&`): [* Font]([@(0.0.255) const]_[_^Nuller^ Nuller][@(0.0.255) `& ])&] [s2;%% Sets the font Null.&] [s3; &] [s4; &] -[s5;:Font`:`:operator Value`(`)const: operator_Value()[@(64) _][@(0.0.255) const]&] +[s5;:Font`:`:operator Value`(`)const: [* operator_Value]()[@(64) _][@(0.0.255) const]&] [s2;%% Converts the Font to the Value (font is rich Value).&] [s3; &] [s4; &] -[s5;:Font`:`:Font`(const Value`&`): Font([@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `&]_ -[@3 q])&] +[s5;:Font`:`:Font`(const Value`&`): [* Font]([@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `& +]_[@3 q])&] [s2;%% Converts the Value to the Font.&] [s3; &] [s0; ]] \ No newline at end of file