implemented function drawslope

This commit is contained in:
louis 2014-10-25 16:58:05 +02:00
parent ee39eb8066
commit 0b9e3787a2
10 changed files with 94 additions and 5 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
<!ELEMENT area (loop|fill|drawtext|drawtextbox|drawimage|drawrectangle|drawellipse)*>
<!ELEMENT area (loop|fill|drawtext|drawtextbox|drawimage|drawrectangle|drawellipse|drawslope)*>
<!ATTLIST area
x CDATA #IMPLIED
y CDATA #IMPLIED
@ -10,7 +10,7 @@
debug (true|false) #IMPLIED
>
<!ELEMENT areascroll (loop|fill|drawtext|drawtextbox|drawimage|drawrectangle|drawellipse)*>
<!ELEMENT areascroll (loop|fill|drawtext|drawtextbox|drawimage|drawrectangle|drawellipse|drawslope)*>
<!ATTLIST areascroll
x CDATA #IMPLIED
y CDATA #IMPLIED
@ -27,7 +27,7 @@
debug (true|false) #IMPLIED
>
<!ELEMENT loop (drawtext|drawtextbox|drawimage|drawrectangle|drawellipse)+>
<!ELEMENT loop (drawtext|drawtextbox|drawimage|drawrectangle|drawellipse|drawslope)+>
<!ATTLIST loop
x CDATA #REQUIRED
y CDATA #REQUIRED
@ -101,8 +101,8 @@
<!ELEMENT drawellipse EMPTY>
<!ATTLIST drawellipse
x CDATA #REQUIRED
y CDATA #REQUIRED
x CDATA #IMPLIED
y CDATA #IMPLIED
width CDATA #IMPLIED
height CDATA #IMPLIED
align (left|center|right) #IMPLIED
@ -114,6 +114,21 @@
debug NMTOKEN #IMPLIED
>
<!ELEMENT drawslope EMPTY>
<!ATTLIST drawslope
x CDATA #IMPLIED
y CDATA #IMPLIED
width CDATA #REQUIRED
height CDATA #REQUIRED
align (left|center|right) #IMPLIED
valign (top|center|bottom) #IMPLIED
color CDATA #REQUIRED
type CDATA #REQUIRED
name NMTOKEN #IMPLIED
condition CDATA #IMPLIED
debug NMTOKEN #IMPLIED
>
<!ELEMENT drawimage EMPTY>
<!ATTLIST drawimage
x CDATA #IMPLIED

View File

@ -136,6 +136,15 @@ void cPixmapContainer::DrawEllipse(int num, const cRect &Rect, tColor Color, int
pixmaps[num]->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;

View File

@ -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);

View File

@ -83,6 +83,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > 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;

View File

@ -32,6 +32,7 @@ enum eFuncType {
ftDrawImage,
ftDrawRectangle,
ftDrawEllipse,
ftDrawSlope,
ftNone
};
@ -54,6 +55,7 @@ enum eParamType {
ptLayer,
ptTransparency,
ptQuadrant,
ptType,
ptAlign,
ptValign,
ptScrollMode,

View File

@ -107,6 +107,8 @@ void cTemplatePixmap::AddFunction(string name, vector<pair<string, string> > &pa
type = ftDrawRectangle;
} else if (!name.compare("drawellipse")) {
type = ftDrawEllipse;
} else if (!name.compare("drawslope")) {
type = ftDrawSlope;
}
if (type == ftNone) {

View File

@ -558,6 +558,20 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("quadrant");
funcsAllowed.insert(pair< string, set<string> >(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<string> >(name, attributes));
}
/************************************************************************************

View File

@ -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);

View File

@ -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: