00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ARMAGETRON_WIDGET_BASE_H
00029 #define ARMAGETRON_WIDGET_BASE_H
00030
00031 #include "tValue.h"
00032
00033 #ifndef DEDICATED
00034
00035 #include "tString.h"
00036 #include "tXmlParser.h"
00037 #define DONTDOIT
00038 #include "rGradient.h"
00039 #include "rTexture.h"
00040 #include <memory>
00041 #include "tSafePTR.h"
00042
00043 class cCockpit;
00044
00054
00056 namespace cWidget {
00057
00059 class Base : public tReferencable<Base> {
00060 int m_Cam;
00061 bool m_ParsingTemplate;
00062 protected:
00063 void DisplayError(tXmlParser::node cur);
00064 bool m_Render;
00065 bool m_RenderDefault;
00066 bool m_Sticky;
00067 cCockpit *m_Cockpit;
00068 public:
00069 Base() : m_ParsingTemplate(false), m_Render(true), m_RenderDefault(true), m_Sticky(true) {}
00070 virtual ~Base() { }
00071 virtual void Render() = 0;
00072 void SetCam(int Cam);
00073
00074 int GetCam(void) { return m_Cam; }
00075 virtual bool Process(tXmlParser::node cur);
00076 void SetDefaultState (bool state) { m_Render = m_RenderDefault = state; }
00077 void SetCockpit(cCockpit *cockpit) {m_Cockpit = cockpit;}
00078 void SetSticky (bool sticky) { m_Sticky = sticky; }
00079 bool Active() { return m_Render; }
00080
00081 void Toggle(bool state) {
00082 if(m_Sticky) {
00083 if(state) {
00084 m_Render = !m_Render;
00085 }
00086 } else {
00087 m_Render = state;
00088 }
00089 }
00093 virtual void HandleEvent(bool state, int id) { Toggle(state); }
00096 void ParseTemplate(bool state) {m_ParsingTemplate = state;}
00097 };
00098
00099 typedef std::auto_ptr<Base> Base_ptr;
00100
00102 class WithCoordinates : virtual public Base {
00103 tCoord m_originalPosition;
00104 tCoord m_originalSize;
00105 protected:
00106 tCoord m_position;
00107 tCoord m_size;
00108 public:
00109 WithCoordinates();
00110 bool Process(tXmlParser::node cur);
00111 void SetFactor(float factor);
00112 };
00113
00115 class WithDataFunctions : virtual public Base {
00116 tValue::Base *ProcessValue(tXmlParser::node cur);
00117 tValue::Base *ProcessMath(tXmlParser::node cur);
00118 tValue::Base *ProcessConditionalCore(tXmlParser::node cur);
00119 tValue::Base *ProcessConditional(tXmlParser::node cur);
00120 tValue::Base *ProcessAtomicData(tXmlParser::node cur);
00121 void ProcessDataTags(tXmlParser::node cur, tValue::Base &data);
00122 tValue::Base *ProcessDataSource(tString const &data);
00123 protected:
00124 tValue::Set ProcessDataSet(tXmlParser::node cur);
00125 public:
00126 bool Process(tXmlParser::node cur);
00127 };
00128
00130 class WithSingleData : virtual public WithDataFunctions {
00131 protected:
00132 tValue::Set m_data;
00133 public:
00134 bool Process(tXmlParser::node cur);
00135 };
00136
00138 class WithIdData : virtual public WithDataFunctions {
00139 protected:
00140 std::map<tString, tValue::Set> m_data;
00141 public:
00142 bool Process(tXmlParser::node cur);
00143 };
00144
00146 class WithTable : virtual public WithIdData {
00147 void ProcessCore(tXmlParser::node cur);
00148 void ProcessTable(tXmlParser::node cur);
00149 void ProcessRow(tXmlParser::node cur);
00150 void ProcessCell(tXmlParser::node cur);
00151 protected:
00152
00153
00154 std::deque<std::deque<std::deque<tValue::Set> > > m_table;
00155 public:
00156 bool Process(tXmlParser::node cur);
00157 };
00158
00160 class WithColorFunctions : virtual public Base {
00161 protected:
00162 rGradient ProcessGradient(tXmlParser::node cur);
00163 void ProcessGradientCore(tXmlParser::node cur, rGradient &gradient);
00164 void ProcessImage(tXmlParser::node cur, rGradient &gradient, int repeat);
00165 public:
00166 bool Process(tXmlParser::node cur);
00167 };
00168
00170 class WithForeground : virtual public WithColorFunctions {
00171 protected:
00172 rGradient m_foreground;
00173 public:
00174 bool Process(tXmlParser::node cur);
00175 };
00176
00178 class WithBackground : virtual public WithColorFunctions {
00179 protected:
00180 rGradient m_background;
00181 public:
00182 bool Process(tXmlParser::node cur);
00183 };
00184
00186 class WithLineColor : virtual public WithColorFunctions {
00187 protected:
00188 rGradient m_line_color;
00189 public:
00190 bool Process(tXmlParser::node cur);
00191 };
00192
00194 class WithCaption : virtual public Base{
00195 void ProcessCaption(tXmlParser::node cur);
00196 void ProcessCaptionLocation(tXmlParser::node cur);
00197 protected:
00198 enum location {
00199 top,
00200 bottom,
00201 off
00202 };
00203 tString m_caption;
00204 int m_captionloc;
00205 WithCaption() : Base(), m_captionloc(off) {};
00206 public:
00207 bool Process(tXmlParser::node cur);
00208 };
00209
00211 class WithReverse : virtual public Base{
00212 protected:
00213 bool m_reverse;
00214 WithReverse() : m_reverse(false){};
00215 public:
00216 bool Process(tXmlParser::node cur);
00217 };
00218
00220 class WithAngles : virtual public Base{
00221 protected:
00222 float m_angle_min;
00223 float m_angle_max;
00224 WithAngles() : m_angle_min(0), m_angle_max(M_PI){};
00225 public:
00226 bool Process(tXmlParser::node cur);
00227 };
00228
00230 class WithShowSettings : virtual public Base{
00231 protected:
00232 bool m_showmin;
00233 bool m_showmax;
00234 bool m_showvalue;
00235 WithShowSettings() : m_showmin(true), m_showmax(true), m_showvalue(true) {};
00236 public:
00237 bool Process(tXmlParser::node cur);
00238
00239 };
00240
00241 }
00242
00243 #endif
00244 #endif