blob: 1ddefaa9b939cad8cff06850174bca59470e4022 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001// fill.cpp - GUIFill object
2
3#include <stdarg.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <fcntl.h>
8#include <sys/reboot.h>
9#include <sys/stat.h>
10#include <sys/time.h>
11#include <sys/mman.h>
12#include <sys/types.h>
13#include <sys/ioctl.h>
14#include <time.h>
15#include <unistd.h>
16#include <stdlib.h>
17
18#include <string>
19
20extern "C" {
Dees_Troy2673cec2013-04-02 20:22:16 +000021#include "../twcommon.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040022#include "../minuitwrp/minui.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040023}
24
25#include "rapidxml.hpp"
26#include "objects.hpp"
27
Vojtech Bocekede51c52014-02-07 23:58:09 +010028GUIFill::GUIFill(xml_node<>* node) : GUIObject(node)
Dees_Troy51a0e822012-09-05 15:24:24 -040029{
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020030 xml_attribute<>* attr;
31 xml_node<>* child;
Dees_Troy51a0e822012-09-05 15:24:24 -040032
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020033 if (!node)
34 return;
Dees_Troy51a0e822012-09-05 15:24:24 -040035
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020036 attr = node->first_attribute("color");
37 if (!attr) {
Dees_Troy2673cec2013-04-02 20:22:16 +000038 LOGERR("No color specified for fill\n");
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020039 return;
Dees_Troya13d74f2013-03-24 08:54:55 -050040 }
Dees_Troy51a0e822012-09-05 15:24:24 -040041
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020042 std::string color = attr->value();
43 ConvertStrToColor(color, &mColor);
Dees_Troy51a0e822012-09-05 15:24:24 -040044
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020045 // Load the placement
46 LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH);
Dees_Troy51a0e822012-09-05 15:24:24 -040047
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020048 return;
Dees_Troy51a0e822012-09-05 15:24:24 -040049}
50
51int GUIFill::Render(void)
52{
Vojtech Bocekede51c52014-02-07 23:58:09 +010053 if(!isConditionTrue())
54 return 0;
55
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020056 gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
57 gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
58 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040059}
60