diff options
Diffstat (limited to 'skinengine/src/skin_object.h')
-rw-r--r-- | skinengine/src/skin_object.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/skinengine/src/skin_object.h b/skinengine/src/skin_object.h new file mode 100644 index 0000000..8d8c466 --- /dev/null +++ b/skinengine/src/skin_object.h @@ -0,0 +1,90 @@ +#ifndef skin_object_h__
+#define skin_object_h__
+
+class CSkinObject: public ISkinElement
+{
+protected:
+ // ganaral options
+ TCHAR *m_id;
+ ISkinDataSource *m_ds;
+ ISkinElement *m_parent;
+
+ // options from skin data
+ int m_width, m_height;
+ int m_stateMask;
+
+ // dynamic parameters
+ RECT m_rcPosition;
+
+ // properties
+ struct Property
+ {
+ enum { None, Text, Integer } m_type;
+ TCHAR *m_key;
+ union
+ {
+ TCHAR *m_valueText;
+ int m_valueInt;
+ };
+
+ Property(const TCHAR *key, int value)
+ {
+ m_type = Integer;
+ m_key = _tcsdup(key);
+ m_valueInt = value;
+ }
+ Property(const TCHAR *key, const TCHAR *value)
+ {
+ m_type = Text;
+ m_key = _tcsdup(key);
+ m_valueText = _tcsdup(value);
+ }
+ ~Property()
+ {
+ free(m_key);
+ if (m_type == Text) free(m_valueText);
+ }
+
+ static int cmp(const Property *p1, const Property *p2)
+ {
+ return lstrcmp(p1->m_key, p2->m_key);
+ }
+ };
+ OBJLIST<Property> m_properties;
+
+public:
+ CSkinObject(): m_id(0), m_ds(0), m_parent(0), m_properties(5, Property::cmp)
+ {
+ }
+ virtual ~CSkinObject()
+ {
+ if (m_id) free(m_id);
+ }
+
+public: // ISkinElement implementation
+ virtual void SetParent(ISkinElement *parent);
+ virtual void SetId(const TCHAR *id);
+ virtual void SetDataSource(ISkinDataSource *ds);
+ virtual void Destroy();
+
+ virtual void LoadFromXml(HXML hXml);
+ virtual void Measure(SkinRenderParams *params);
+ virtual void Layout(SkinRenderParams *params);
+ virtual void Paint(SkinRenderParams *params) = 0;
+
+ virtual bool IsComplexObject();
+ virtual ISkinElement *GetParent();
+ virtual int GetChildCount();
+ virtual ISkinElement *GetChild(int index);
+ virtual bool AppendChild(ISkinElement *child);
+ virtual bool InsertChild(ISkinElement *child, int index);
+ virtual void RemoveChild(ISkinElement *child);
+
+ virtual void SetPropText(const TCHAR *key, const TCHAR *value);
+ virtual const TCHAR *GetPropText(const TCHAR *key, const TCHAR *value);
+ virtual void SetPropInt(const TCHAR *key, int value);
+ virtual void SetPropIntText(const TCHAR *key, const TCHAR *value);
+ virtual int GetPropInt(const TCHAR *key);
+};
+
+#endif // skin_object_h__
|