My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef FORM_EDITOR_PROPERTIES__PROPERTIES_H
#define FORM_EDITOR_PROPERTIES__PROPERTIES_H

#include "PropertiesEditor.h"

template <class T>
class PropertiesBase : public IPartBase
{
public:
PropertiesBase(T* c) : _This(c) {}
virtual ~PropertiesBase() {}

virtual void InitProperties() {}
virtual int OpenProperties();
virtual void ClearProperties() { GetProperties().Clear(); }
virtual int ExecuteProperties(const Size& wndSize = Null);

Array<Property>& GetProperties() { return _Properties; }
const Array<Property>& GetProperties() const { return _Properties; }

int GetPropertyGroupCount() const { return GetPropertiesGroups().GetCount(); }
Vector<String> GetPropertiesGroups() const;
Array<Property*> GetPropertiesByGroup(const String& group);

T* GetObject() { return _This; }

private:
T* _This;
Array<Property> _Properties;
};

template <class T>
Vector<String> PropertiesBase<T>::GetPropertiesGroups() const
{
const Array<Property>& props = GetProperties();
Vector<String> result;
for (int i = 0; i < props.GetCount(); ++i)
{
bool found = false;
for (int j = 0; j < result.GetCount(); ++j)
if (props[i].MetaString("Group") == result[j])
{
found = true;
break;
}
if (!found)
result << props[i].MetaString("Group");
}
return result;
}

template <class T>
Array<Property*> PropertiesBase<T>::GetPropertiesByGroup(const String& group)
{
Array<Property>& props = GetProperties();
Array<Property*> result;
for (int i = 0; i < props.GetCount(); ++i)
{
if (props[i].MetaString("Group") == group)
result.Add(&props[i]);
}
return result;
}

template <class T>
int PropertiesBase<T>::OpenProperties()
{
return PropertiesWindow<PropertiesBase<T> >(this).Execute();
}

template <class T>
int PropertiesBase<T>::ExecuteProperties(const Size& wndSize)
{
PropertiesWindow<PropertiesBase<T> > wnd(this);
if (!IsNull(wndSize))
wnd.GetWorkArea().CenterRect(wndSize);
int r = wnd.Execute();
return r;
}

#endif

Change log

r4180 by Sc0rch on Nov 17, 2011   Diff
MapRender: First release
(FormEditorCommon, FormEditorProperties,
Map, MapBG, MapCommon, MapEditor,
MapRenderTest.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2047 bytes, 81 lines
Powered by Google Project Hosting