2014-09-27 09:25:14 +02:00
|
|
|
#ifndef __TEMPLATEFUNCTION_H
|
|
|
|
#define __TEMPLATEFUNCTION_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
#include "parameter.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
// --- cTemplateFunction -------------------------------------------------------------
|
|
|
|
|
|
|
|
enum eFuncType {
|
|
|
|
ftOsd,
|
|
|
|
ftView,
|
|
|
|
ftViewElement,
|
|
|
|
ftViewList,
|
|
|
|
ftPixmap,
|
|
|
|
ftPixmapScroll,
|
|
|
|
ftLoop,
|
|
|
|
ftFill,
|
|
|
|
ftDrawText,
|
|
|
|
ftDrawTextBox,
|
2015-03-12 17:28:35 +01:00
|
|
|
ftDrawTextVertical,
|
2014-09-27 09:25:14 +02:00
|
|
|
ftDrawImage,
|
|
|
|
ftDrawRectangle,
|
|
|
|
ftDrawEllipse,
|
2014-10-25 16:58:05 +02:00
|
|
|
ftDrawSlope,
|
2014-09-27 09:25:14 +02:00
|
|
|
ftNone
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eParamType {
|
|
|
|
ptCond,
|
|
|
|
ptName,
|
2015-04-01 13:26:36 +02:00
|
|
|
ptMode,
|
2015-04-11 16:21:33 +02:00
|
|
|
ptDrawDebugGrid,
|
|
|
|
ptDebugGridX,
|
|
|
|
ptDebugGridY,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptX,
|
|
|
|
ptY,
|
|
|
|
ptWidth,
|
|
|
|
ptHeight,
|
|
|
|
ptMenuItemWidth,
|
2015-03-22 08:29:52 +01:00
|
|
|
ptDetached,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptFadeTime,
|
2015-05-03 11:22:01 +02:00
|
|
|
ptShiftTime,
|
2015-05-10 12:55:23 +02:00
|
|
|
ptShiftType,
|
|
|
|
ptShiftMode,
|
2015-05-03 11:22:01 +02:00
|
|
|
ptStartX,
|
|
|
|
ptStartY,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptDelay,
|
|
|
|
ptImageType,
|
|
|
|
ptPath,
|
|
|
|
ptColor,
|
|
|
|
ptFont,
|
|
|
|
ptFontSize,
|
|
|
|
ptText,
|
|
|
|
ptLayer,
|
|
|
|
ptTransparency,
|
2015-03-28 11:57:51 +01:00
|
|
|
ptBackground,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptQuadrant,
|
2014-10-25 16:58:05 +02:00
|
|
|
ptType,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptAlign,
|
|
|
|
ptValign,
|
|
|
|
ptScrollMode,
|
|
|
|
ptScrollSpeed,
|
|
|
|
ptOrientation,
|
|
|
|
ptNumElements,
|
|
|
|
ptScrollElement,
|
|
|
|
ptScrollHeight,
|
|
|
|
ptFloat,
|
|
|
|
ptFloatWidth,
|
|
|
|
ptFloatHeight,
|
|
|
|
ptMaxLines,
|
|
|
|
ptColumnWidth,
|
|
|
|
ptRowHeight,
|
|
|
|
ptOverflow,
|
|
|
|
ptScaleTvX,
|
|
|
|
ptScaleTvY,
|
|
|
|
ptScaleTvWidth,
|
|
|
|
ptScaleTvHeight,
|
2015-03-15 18:11:07 +01:00
|
|
|
ptHideRoot,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptCache,
|
|
|
|
ptDeterminateFont,
|
2015-03-31 06:57:02 +02:00
|
|
|
ptDirection,
|
2015-04-12 17:10:06 +02:00
|
|
|
ptAnimType,
|
|
|
|
ptAnimFreq,
|
2014-09-27 09:25:14 +02:00
|
|
|
ptNone
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eImageType {
|
|
|
|
itChannelLogo,
|
|
|
|
itSepLogo,
|
|
|
|
itSkinPart,
|
|
|
|
itMenuIcon,
|
|
|
|
itIcon,
|
|
|
|
itImage
|
|
|
|
};
|
|
|
|
|
2015-05-10 12:55:23 +02:00
|
|
|
enum eShiftType {
|
|
|
|
stNone,
|
|
|
|
stLeft,
|
|
|
|
stRight,
|
|
|
|
stTop,
|
|
|
|
stBottom
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eShiftMode {
|
|
|
|
smLinear,
|
|
|
|
smSlowedDown
|
|
|
|
};
|
|
|
|
|
2015-04-12 17:10:06 +02:00
|
|
|
enum eAnimType {
|
|
|
|
atNone,
|
|
|
|
atBlink,
|
|
|
|
atAnimated
|
|
|
|
};
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
enum eFloatType {
|
|
|
|
flNone,
|
|
|
|
flTopLeft,
|
|
|
|
flTopRight
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eOverflowType {
|
|
|
|
otNone,
|
|
|
|
otWrap,
|
|
|
|
otCut
|
|
|
|
};
|
|
|
|
|
2015-03-31 06:57:02 +02:00
|
|
|
enum eDirection {
|
|
|
|
diNone,
|
|
|
|
diBottomUp,
|
|
|
|
diTopDown
|
|
|
|
};
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
class cTemplateFunction {
|
|
|
|
protected:
|
|
|
|
eFuncType type;
|
|
|
|
bool debug;
|
|
|
|
int containerX; //X of parent container
|
|
|
|
int containerY; //Y of parent container
|
|
|
|
int containerWidth; //width of parent container
|
|
|
|
int containerHeight; //height of parent container
|
|
|
|
int columnWidth; //if func is executed in a loop, width of loop column
|
|
|
|
int rowHeight; //if func is executed in a loop, height of loop row
|
|
|
|
cGlobals *globals; //globals
|
|
|
|
map< eParamType, string > nativeParameters; //native parameters directly from xml
|
|
|
|
map< eParamType, int > numericParameters; //sucessfully parsed numeric parameters
|
|
|
|
map< eParamType, string > numericDynamicParameters; //numeric parameters with dynamic tokens
|
|
|
|
bool parsedCompletely;
|
|
|
|
bool updated;
|
|
|
|
map< eParamType, tColor > colorParameters;
|
|
|
|
cConditionalParameter *condParam;
|
|
|
|
//drawimage parameters
|
|
|
|
string imgPath;
|
|
|
|
//drawtext parameters
|
|
|
|
string fontName;
|
|
|
|
vector<cTextToken> textTokens;
|
|
|
|
string parsedText;
|
|
|
|
int parsedTextWidth;
|
|
|
|
string cuttedText;
|
|
|
|
bool alreadyCutted;
|
|
|
|
//drawtextbox parameters
|
|
|
|
int textboxHeight;
|
|
|
|
//dynamic tokens
|
|
|
|
map < string, string > *stringTokens;
|
|
|
|
map < string, int > *intTokens;
|
|
|
|
//private functions
|
|
|
|
bool SetCondition(string cond);
|
|
|
|
bool SetNumericParameter(eParamType type, string value);
|
|
|
|
bool SetAlign(eParamType type, string value);
|
|
|
|
bool SetFont(eParamType type, string value);
|
|
|
|
bool SetImageType(eParamType type, string value);
|
|
|
|
bool SetColor(eParamType type, string value);
|
|
|
|
bool SetTextTokens(string value);
|
|
|
|
void ParseTextToken(string &value, size_t start, size_t end);
|
|
|
|
void ParseConditionalTextToken(string &value, size_t start, size_t end);
|
2014-11-01 13:03:52 +01:00
|
|
|
void ParsePrintfTextToken(string &value, size_t start, size_t end);
|
2014-09-27 09:25:14 +02:00
|
|
|
bool SetScrollMode(string value);
|
|
|
|
bool SetScrollSpeed(string value);
|
|
|
|
bool SetOrientation(string value);
|
|
|
|
bool SetFloating(string value);
|
|
|
|
bool SetOverflow(string value);
|
2015-03-15 18:11:07 +01:00
|
|
|
bool SetHideRoot(string value);
|
2015-03-22 08:29:52 +01:00
|
|
|
bool SetDetached(string value);
|
2015-03-28 11:57:51 +01:00
|
|
|
bool SetBackground(string value);
|
2015-03-31 06:57:02 +02:00
|
|
|
bool SetDirection(string value);
|
2015-04-12 17:10:06 +02:00
|
|
|
bool SetAnimType(string value);
|
2015-05-10 12:55:23 +02:00
|
|
|
bool SetShiftType(string value);
|
|
|
|
bool SetShiftMode(string value);
|
2015-04-11 16:21:33 +02:00
|
|
|
void SetDebugGrid(string value);
|
2014-09-27 09:25:14 +02:00
|
|
|
void ParseStringParameters(void);
|
|
|
|
void ParseNumericalParameters(void);
|
|
|
|
void CalculateAlign(int elementWidth, int elementHeight);
|
|
|
|
int CalculateTextBoxHeight(void);
|
2014-11-01 13:03:52 +01:00
|
|
|
int ReplaceIntToken(string intTok);
|
2014-09-27 09:25:14 +02:00
|
|
|
public:
|
|
|
|
cTemplateFunction(eFuncType type);
|
|
|
|
virtual ~cTemplateFunction(void);
|
|
|
|
//Setter Functions
|
|
|
|
void SetParameters(vector<pair<string, string> > params);
|
|
|
|
void SetParameter(eParamType type, string value);
|
|
|
|
void SetContainer(int x, int y, int w, int h);
|
|
|
|
void SetLoopContainer(int columnWidth, int rowHeight);
|
|
|
|
void SetWidthManually(string width);
|
|
|
|
void SetHeightManually(string height);
|
|
|
|
void SetXManually(int newX);
|
|
|
|
void SetYManually(int newY);
|
|
|
|
void SetMaxTextWidth(int maxWidth);
|
|
|
|
void SetTextboxHeight(int boxHeight);
|
|
|
|
void SetGlobals(cGlobals *globals) { this->globals = globals; };
|
|
|
|
void SetTranslatedText(string translation);
|
|
|
|
//PreCache Parameters
|
|
|
|
bool CalculateParameters(void);
|
2014-11-01 16:02:56 +01:00
|
|
|
//Complete Parameters
|
|
|
|
bool ReCalculateParameters(void);
|
2014-09-27 09:25:14 +02:00
|
|
|
void CompleteParameters(void);
|
|
|
|
//Set and Unset Dynamic Tokens from view
|
|
|
|
void SetStringTokens(map < string, string > *tok) { stringTokens = tok; };
|
|
|
|
void SetIntTokens(map < string, int > *tok) { intTokens = tok; };
|
|
|
|
void UnsetIntTokens(void) { intTokens = NULL; };
|
|
|
|
void UnsetStringTokens(void) { stringTokens = NULL; };
|
|
|
|
//Clear dynamically parameters
|
|
|
|
void ClearDynamicParameters(void);
|
|
|
|
//Parse parameters with dynamically set Tokens
|
|
|
|
bool ParseParameters(void);
|
|
|
|
//Getter Functions
|
|
|
|
eFuncType GetType(void) { return type; };
|
|
|
|
bool DoDebug(void) { return debug; };
|
|
|
|
string GetParameter(eParamType type);
|
|
|
|
int GetNumericParameter(eParamType type);
|
|
|
|
string GetText(bool cut = true);
|
|
|
|
string GetImagePath(void) { return imgPath; };
|
|
|
|
tColor GetColorParameter(eParamType type);
|
|
|
|
string GetFontName(void) { return fontName; };
|
|
|
|
string GetFuncName(void);
|
|
|
|
string GetParamName(eParamType pt);
|
|
|
|
//Dynamic width or height parameter
|
|
|
|
int GetWidth(bool cutted = true);
|
|
|
|
int GetHeight(void);
|
2015-03-12 17:28:35 +01:00
|
|
|
int GetContainerWidth(void) { return containerWidth; };
|
|
|
|
int GetContainerHeight(void) { return containerHeight; };
|
2014-09-27 09:25:14 +02:00
|
|
|
void GetNeededWidths(multimap<eParamType,string> *widths);
|
|
|
|
void GetNeededHeights(multimap<eParamType,string> *heights);
|
|
|
|
void GetNeededPosX(multimap<eParamType,string> *posXs);
|
|
|
|
void GetNeededPosY(multimap<eParamType,string> *posYs);
|
|
|
|
void SetWidth(eParamType type, string label, int funcWidth);
|
|
|
|
void SetHeight(eParamType type, string label, int funcHeight);
|
|
|
|
void SetX(eParamType type, string label, int funcX);
|
|
|
|
void SetY(eParamType type, string label, int funcY);
|
|
|
|
//Status Functions
|
|
|
|
bool ParsedCompletely(void) { return parsedCompletely; };
|
|
|
|
bool DoExecute(void);
|
|
|
|
bool Updated(void) { return updated; };
|
2015-04-12 17:10:06 +02:00
|
|
|
bool IsAnimated(void);
|
2014-09-27 09:25:14 +02:00
|
|
|
//Debug
|
|
|
|
void Debug(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__TEMPLATEFUNCTION_H
|