From 0b9e3787a2a920e010ab53330262fe8644e4b0d0 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 25 Oct 2014 16:58:05 +0200 Subject: implemented function drawslope --- HISTORY | 2 ++ dtd/functions.dtd | 25 ++++++++++++++++++++----- libcore/pixmapcontainer.c | 9 +++++++++ libcore/pixmapcontainer.h | 1 + libtemplate/templatefunction.c | 14 ++++++++++++++ libtemplate/templatefunction.h | 2 ++ libtemplate/templatepixmap.c | 2 ++ libtemplate/templateview.c | 14 ++++++++++++++ views/view.c | 29 +++++++++++++++++++++++++++++ views/view.h | 1 + 10 files changed, 94 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index 42d102c..fdf9aab 100644 --- a/HISTORY +++ b/HISTORY @@ -32,4 +32,6 @@ Version 0.0.2 - fixed bug that x and y of subviews was not respected - if a subview is completely not set in a skin, the default menu is used - fixed a bug if displaydetailedtext is called without correct menucat (mailbox plugin) +- implemented function drawslope, see Wiki for documentation + diff --git a/dtd/functions.dtd b/dtd/functions.dtd index 5e78876..424378f 100644 --- a/dtd/functions.dtd +++ b/dtd/functions.dtd @@ -1,4 +1,4 @@ - + - + - + + + + DrawEllipse(Rect, Color, Quadrants); } +void cPixmapContainer::DrawSlope(int num, const cRect &Rect, tColor Color, int Type) { + if (checkRunning && !Running()) + return; + cMutexLock MutexLock(&mutex); + if (!pixmaps[num]) + return; + pixmaps[num]->DrawSlope(Rect, Color, Type); +} + void cPixmapContainer::DrawImage(int num, const cPoint &Point, const cImage &Image) { if (checkRunning && !Running()) return; diff --git a/libcore/pixmapcontainer.h b/libcore/pixmapcontainer.h index 3904f16..3b3105a 100644 --- a/libcore/pixmapcontainer.h +++ b/libcore/pixmapcontainer.h @@ -35,6 +35,7 @@ protected: void DrawText(int num, const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, std::string fontName, int fontSize); void DrawRectangle(int num, const cRect &Rect, tColor Color); void DrawEllipse(int num, const cRect &Rect, tColor Color, int Quadrants = 0); + void DrawSlope(int num, const cRect &Rect, tColor Color, int Type); void DrawImage(int num, const cPoint &Point, const cImage &Image); void DrawBitmap(int num, const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false); void Fill(int num, tColor Color); diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index 9dca94e..b96f0be 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -83,6 +83,8 @@ void cTemplateFunction::SetParameters(vector > params) { p.first = ptTransparency; } else if (!name.compare("quadrant")) { p.first = ptQuadrant; + } else if (!name.compare("type")) { + p.first = ptType; } else if (!name.compare("align")) { p.first = ptAlign; } else if (!name.compare("valign")) { @@ -215,6 +217,7 @@ bool cTemplateFunction::CalculateParameters(void) { case ptLayer: case ptTransparency: case ptQuadrant: + case ptType: case ptNumElements: case ptFloatWidth: case ptFloatHeight: @@ -301,6 +304,9 @@ void cTemplateFunction::CompleteParameters(void) { case ftDrawEllipse: CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight)); break; + case ftDrawSlope: + CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight)); + break; case ftDrawText: CalculateAlign(GetWidth(), GetHeight()); break; @@ -439,6 +445,7 @@ int cTemplateFunction::GetWidth(bool cutted) { case ftDrawImage: case ftDrawRectangle: case ftDrawEllipse: + case ftDrawSlope: case ftDrawTextBox: funcWidth = GetNumericParameter(ptWidth); break; @@ -459,6 +466,7 @@ int cTemplateFunction::GetHeight(void) { case ftDrawImage: case ftDrawRectangle: case ftDrawEllipse: + case ftDrawSlope: funcHeight = GetNumericParameter(ptHeight); break; case ftDrawTextBox: { @@ -1265,6 +1273,9 @@ string cTemplateFunction::GetFuncName(void) { case ftDrawEllipse: name = "Function DrawEllipse"; break; + case ftDrawSlope: + name = "Function DrawSlope"; + break; case ftNone: name = "Undefined"; break; @@ -1332,6 +1343,9 @@ string cTemplateFunction::GetParamName(eParamType pt) { case ptQuadrant: name = "Quadrant"; break; + case ptType: + name = "Type"; + break; case ptAlign: name = "Align"; break; diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index 9a784c5..b6c2d53 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -32,6 +32,7 @@ enum eFuncType { ftDrawImage, ftDrawRectangle, ftDrawEllipse, + ftDrawSlope, ftNone }; @@ -54,6 +55,7 @@ enum eParamType { ptLayer, ptTransparency, ptQuadrant, + ptType, ptAlign, ptValign, ptScrollMode, diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c index 8aaa4f3..4fbd513 100644 --- a/libtemplate/templatepixmap.c +++ b/libtemplate/templatepixmap.c @@ -107,6 +107,8 @@ void cTemplatePixmap::AddFunction(string name, vector > &pa type = ftDrawRectangle; } else if (!name.compare("drawellipse")) { type = ftDrawEllipse; + } else if (!name.compare("drawslope")) { + type = ftDrawSlope; } if (type == ftNone) { diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index 37bb13b..7786ce1 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -558,6 +558,20 @@ void cTemplateView::SetFunctionDefinitions(void) { attributes.insert("quadrant"); funcsAllowed.insert(pair< string, set >(name, attributes)); + name = "drawslope"; + attributes.clear(); + attributes.insert("debug"); + attributes.insert("condition"); + attributes.insert("name"); + attributes.insert("x"); + attributes.insert("y"); + attributes.insert("align"); + attributes.insert("valign"); + attributes.insert("width"); + attributes.insert("height"); + attributes.insert("color"); + attributes.insert("type"); + funcsAllowed.insert(pair< string, set >(name, attributes)); } /************************************************************************************ diff --git a/views/view.c b/views/view.c index 3b72253..75a24e0 100644 --- a/views/view.c +++ b/views/view.c @@ -251,6 +251,9 @@ void cView::DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< case ftDrawEllipse: DoDrawEllipse(num, func); break; + case ftDrawSlope: + DoDrawSlope(num, func); + break; case ftDrawImage: DoDrawImage(num, func); break; @@ -348,6 +351,9 @@ void cView::DrawLoop(int numPixmap, cTemplateFunction *func, map < string, vecto case ftDrawEllipse: DoDrawEllipse(numPixmap, func, x0, y0); break; + case ftDrawSlope: + DoDrawSlope(numPixmap, func, x0, y0); + break; case ftDrawImage: DoDrawImage(numPixmap, func, x0, y0); break; @@ -634,9 +640,32 @@ void cView::DoDrawEllipse(int num, cTemplateFunction *func, int x0, int y0) { cRect size(x, y, w, h); tColor clr = func->GetColorParameter(ptColor); int quadrant = func->GetNumericParameter(ptQuadrant); + if (quadrant < -4 || quadrant > 8) { + esyslog("skindesigner: wrong quadrant %d for drawellipse, allowed values are from -4 to 8", quadrant); + quadrant = 0; + } DrawEllipse(num, size, clr, quadrant); } +void cView::DoDrawSlope(int num, cTemplateFunction *func, int x0, int y0) { + int x = func->GetNumericParameter(ptX); + int y = func->GetNumericParameter(ptY); + if (x < 0) x = 0; + x += x0; + if (y < 0) y = 0; + y += y0; + int w = func->GetNumericParameter(ptWidth); + int h = func->GetNumericParameter(ptHeight); + cRect size(x, y, w, h); + tColor clr = func->GetColorParameter(ptColor); + int type = func->GetNumericParameter(ptType); + if (type < 0 || type > 7) { + esyslog("skindesigner: wrong type %d for drawslope, allowed values are from 0 to 7", type); + type = 0; + } + DrawSlope(num, size, clr, type); +} + void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) { int x = func->GetNumericParameter(ptX); int y = func->GetNumericParameter(ptY); diff --git a/views/view.h b/views/view.h index 4609935..a793c31 100644 --- a/views/view.h +++ b/views/view.h @@ -17,6 +17,7 @@ private: void DoDrawFloatingTextBox(int num, cTemplateFunction *func); void DoDrawRectangle(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0); void DoDrawEllipse(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0); + void DoDrawSlope(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0); void DoDrawImage(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0); void ActivateScrolling(void); protected: -- cgit v1.2.3