From 3d43200af00372dd54abe2b86b00ca15a4fc6d82 Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 31 Mar 2015 06:57:02 +0200 Subject: added possibility to draw vertical text bottomum and topdown --- libtemplate/templatefunction.c | 28 +++++++++++++++++++++++++++- libtemplate/templatefunction.h | 8 ++++++++ libtemplate/templateview.c | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) (limited to 'libtemplate') diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index 5e72948..afbc5fa 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -135,6 +135,8 @@ void cTemplateFunction::SetParameters(vector > params) { p.first = ptCache; } else if (!name.compare("determinatefont")) { p.first = ptDeterminateFont; + } else if (!name.compare("direction")) { + p.first = ptDirection; } else { p.first = ptNone; } @@ -276,6 +278,9 @@ bool cTemplateFunction::CalculateParameters(void) { case ptBackground: paramValid = SetBackground(value); break; + case ptDirection: + paramValid = SetDirection(value); + break; default: paramValid = true; break; @@ -420,6 +425,8 @@ int cTemplateFunction::GetNumericParameter(eParamType type) { return 0; else if (type == ptBackground) return 0; + else if (type == ptDirection) + return diBottomUp; return -1; } return hit->second; @@ -475,6 +482,9 @@ int cTemplateFunction::GetWidth(bool cutted) { else funcWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str()); break; } + case ftDrawTextVertical: + funcWidth = GetNumericParameter(ptFontSize)*1.2; + break; case ftFill: case ftDrawImage: case ftDrawRectangle: @@ -496,6 +506,9 @@ int cTemplateFunction::GetHeight(void) { case ftDrawText: funcHeight = fontManager->Height(fontName, GetNumericParameter(ptFontSize)); break; + case ftDrawTextVertical: + funcHeight = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str()); + break; case ftFill: case ftDrawImage: case ftDrawRectangle: @@ -1092,6 +1105,16 @@ bool cTemplateFunction::SetBackground(string value) { return true; } +bool cTemplateFunction::SetDirection(string value) { + int direction = diNone; + if (!value.compare("bottomup")) + direction = diBottomUp; + else if (!value.compare("topdown")) + direction = diTopDown; + numericParameters.insert(pair(ptDirection, direction)); + return true; +} + void cTemplateFunction::ParseStringParameters(void) { //first replace stringtokens in Text (drawText) stringstream text; @@ -1581,7 +1604,10 @@ string cTemplateFunction::GetParamName(eParamType pt) { break; case ptDeterminateFont: name = "Determinate Font"; - break; + break; + case ptDirection: + name = "Text Direction"; + break; default: name = "Unknown"; break; diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index a862aa7..3c7e515 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -81,6 +81,7 @@ enum eParamType { ptHideRoot, ptCache, ptDeterminateFont, + ptDirection, ptNone }; @@ -105,6 +106,12 @@ enum eOverflowType { otCut }; +enum eDirection { + diNone, + diBottomUp, + diTopDown +}; + class cTemplateFunction { protected: eFuncType type; @@ -156,6 +163,7 @@ protected: bool SetHideRoot(string value); bool SetDetached(string value); bool SetBackground(string value); + bool SetDirection(string value); void ParseStringParameters(void); void ParseNumericalParameters(void); void CalculateAlign(int elementWidth, int elementHeight); diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index df523a1..a111d70 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -727,6 +727,7 @@ void cTemplateView::SetFunctionDefinitions(void) { attributes.insert("height"); attributes.insert("align"); attributes.insert("valign"); + attributes.insert("direction"); attributes.insert("font"); attributes.insert("fontsize"); attributes.insert("color"); -- cgit v1.2.3