Skip to content

Commit 6f27d52

Browse files
author
AZ
committed
Inherit properties and events from base classes defined in XML database, removed base classes categories from property book
1 parent 6572fd7 commit 6f27d52

File tree

14 files changed

+1331
-364
lines changed

14 files changed

+1331
-364
lines changed

build/premake/core.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ project "LibCore"
1414
{
1515
"../../include/wxguidesigner/**.h", "../../src/wxguidesigner/**.cpp",
1616
"../../include/wx/**.h", "../../src/wx/**.cpp",
17+
"../../output/db/controlbase.xml", "../../output/db/controlbase/**.xml",
1718
"../../output/db/controls.xml", "../../output/db/controls/**.xml"
1819
}
1920
includedirs

include/wxguidesigner/rtti/database.h

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <wx/log.h>
2020

2121
class wxXmlNode;
22+
23+
using namespace std;
2224
//=============================================================================
2325
// ChildInfoNode
2426
//=============================================================================
@@ -178,34 +180,43 @@ class ClassNode
178180
wxString GetName() const { return m_name; }
179181
wxString GetDescription() const { return m_desc; }
180182
ClassType GetType() const { return m_type; }
181-
183+
//-----------------------------------------------------------------------------
184+
// Inherited classes
185+
//-----------------------------------------------------------------------------
186+
ClassInfo GetBaseInfo( size_t index );
187+
wxString GetBaseName( size_t index );
188+
size_t GetBaseCount();
182189
bool IsKindOf( const wxString &className );
183190
bool IsTypeOf( ClassType type );
184-
185-
size_t GetBaseCount() { return m_bases.GetCount(); }
186-
size_t GetChildInfoCount() { return m_children.size(); }
187-
size_t GetEventInfoCount() { return m_events.size(); }
191+
//-----------------------------------------------------------------------------
192+
// PropertyInfos
193+
//-----------------------------------------------------------------------------
194+
PropertyInfo GetPropertyInfo( size_t index );
195+
PropertyInfo GetPropertyInfo( const wxString &name );
188196
size_t GetPropertyInfoCount() { return m_props.size(); }
189-
190-
wxString GetBaseName( size_t index );
191-
ChildInfo GetChildInfo( size_t index );
197+
bool PropertyInfoExists( const wxString &name );
198+
//-----------------------------------------------------------------------------
199+
// EventInfos
200+
//-----------------------------------------------------------------------------
192201
EventInfo GetEventInfo( size_t index );
193-
PropertyInfo GetPropertyInfo( size_t index );
194-
202+
size_t GetEventInfoCount() { return m_events.size(); }
203+
//-----------------------------------------------------------------------------
204+
// ChildInfos
205+
//-----------------------------------------------------------------------------
206+
ChildInfo GetChildInfo( size_t index );
207+
size_t GetChildInfoCount() { return m_children.size(); }
195208
bool IsChildInfoOk( const wxString &name, size_t count );
196-
bool PropertyInfoExists ( const wxString &name );
197209

198210
private:
199-
void AddBaseName( const wxString &name ) { m_bases.Add( name ); }
200-
void AddChildInfo( ChildInfo info ) { m_children.push_back( info ); }
201-
void AddEventInfo( EventInfo info ) { m_events.push_back( info ); }
202-
void AddPropertyInfo( PropertyInfo info ) { m_props.push_back( info ); }
203-
211+
void AddBaseInfo ( ClassInfo info );
212+
void AddChildInfo ( ChildInfo info ) { m_children.push_back( info ); }
213+
void AddEventInfo ( EventInfo info ) { m_events.push_back( info ); }
214+
void AddPropertyInfo( PropertyInfo info ) { m_props.push_back( info ); }
204215

205216
wxString m_name;
206217
wxString m_desc;
207218
ClassType m_type;
208-
wxArrayString m_bases;
219+
ClassInfos m_baseInfos;
209220
ChildInfos m_children;
210221
EventInfos m_events;
211222
PropertyInfos m_props;
@@ -219,11 +230,11 @@ class DLLIMPEXP_WXGUIDESIGNER ClassInfoDB
219230
{
220231
public:
221232
static ClassInfoDB *Get();
222-
static void Free();
233+
static void Free();
223234

224-
bool ClassInfoExists( const wxString &name );
225-
ClassInfo GetClassInfo ( const wxString &name ) const;
226-
PropertyType GetPropertyType( const wxString &name ) const;
235+
bool ClassInfoExists ( const wxString &name );
236+
ClassInfo GetClassInfo ( const wxString &name ) const;
237+
PropertyType GetPropertyType ( const wxString &name ) const;
227238

228239
private:
229240
ClassInfoDB();
@@ -236,19 +247,27 @@ class DLLIMPEXP_WXGUIDESIGNER ClassInfoDB
236247
void InitPropertyTypes();
237248
void Init();
238249

239-
bool LoadXML ( const wxString &path );
250+
void LoadClasses( const wxString &category );
251+
bool LoadXML ( const wxString &category );
240252
bool CheckClass ( const wxString &name );
241253
void Parse ( wxXmlNode *node, bool recursively = false );
242254

243-
ChildInfo DoGetChildInfo ( wxXmlNode *childNode );
244-
EventInfo DoGetEventInfo ( wxXmlNode *eventNode );
245-
PropertyInfo DoGetPropertyInfo ( wxXmlNode *propertyNode );
255+
void AddBaseInfos ( ClassInfo classInfo,
256+
ClassInfo baseInfo );
257+
258+
ChildInfo DoGetChildInfo ( wxXmlNode *childNode );
259+
EventInfo DoGetEventInfo ( wxXmlNode *eventNode );
260+
PropertyInfo DoGetPropertyInfo ( wxXmlNode *propertyNode );
246261

247-
ClassType ClassTypeFromString( const wxString &value ) const;
262+
ClassType ClassTypeFromString ( const wxString &value ) const;
248263

249264
ClassInfoMap m_classes;
250265
PropertyTypeMap m_propTypes;
251-
wxArrayString m_classList;
266+
267+
typedef map< wxString, wxString > ClassNameMap;
268+
269+
wxArrayString m_baseList;
270+
ClassNameMap m_classMap;
252271

253272
static ClassInfoDB *ms_instance;
254273
};

include/wxguidesigner/rtti/tree.h

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -151,67 +151,68 @@ class PropertyNode
151151
//=============================================================================
152152
// ObjectNode Class
153153
//=============================================================================
154-
class ObjectNode : public IObject
154+
class ObjectNode //: public IObject
155155
{
156156
public:
157-
ObjectNode( ClassInfo classInfo,
158-
Object parent,
159-
bool expanded = true,
160-
bool isReference = false );
157+
ObjectNode( ClassInfo classInfo, Object parent,
158+
bool expanded = true, bool isReference = false );
161159
~ObjectNode();
162160

163-
virtual wxString GetClassName() const;
164-
virtual wxString GetDescription() const;
161+
wxString GetName() const;
162+
wxString GetDescription() const;
165163

166-
wxString GetName();
167-
168-
ClassInfo GetClassInfo() const;
169-
170-
bool IsReference() const { return m_isRef; }
164+
bool IsReference() const;
171165
bool IsRoot();
172-
bool IsExpanded();
173-
bool IsTopLevel() { return m_info->IsTypeOf( CLASS_TYPE_TOPLEVEL ); }
174-
166+
bool IsTopLevel();
167+
//-----------------------------------------------------------------------------
168+
// State into the tree
169+
//-----------------------------------------------------------------------------
170+
bool IsExpanded() const;
175171
void Collapse();
176172
void Expand();
177-
178-
// Events
179-
void AddEvent( Event event );
180-
Event GetEvent( size_t index );
181-
Event GetEvent( const wxString &name );
173+
//-----------------------------------------------------------------------------
174+
// ClassInfos
175+
//-----------------------------------------------------------------------------
176+
ClassInfo GetClassInfo() const;
177+
wxString GetClassName() const;
178+
//-----------------------------------------------------------------------------
179+
// Events
180+
//-----------------------------------------------------------------------------
181+
void AddEvent ( Event event );
182+
Event GetEvent ( size_t index ) const;
183+
Event GetEvent ( const wxString &name ) const;
182184
size_t GetEventCount();
183-
184-
// Properties
185-
void AddProperty( Property prop );
186-
Property GetProperty( size_t index );
187-
Property GetProperty( const wxString &name );
188-
Properties GetProperties() const { return m_props; }
189-
bool PropertyExists( const wxString &name );
185+
//-----------------------------------------------------------------------------
186+
// Properties
187+
//-----------------------------------------------------------------------------
188+
void AddProperty ( Property prop );
189+
bool PropertyExists ( const wxString &name );
190+
Property GetProperty ( size_t index ) const;
191+
Property GetProperty ( const wxString &name ) const;
192+
Property GetChildProperty( Property parent,
193+
const wxString &name ) const;
194+
Properties GetProperties() const;
190195
size_t GetPropertyCount();
191-
Property GetChildProperty( Property parent, const wxString &name );
192-
193-
// Inherited classes
194-
void AddBaseInfo( ClassInfo info );
195-
ClassInfo GetBaseInfo( size_t index );
196-
wxString GetBaseName( size_t index );
197-
size_t GetBaseCount();
198-
199-
// Parent / children objects
200-
void AddChild( Object child );
201-
Object GetChild( size_t index );
202-
Object GetParent();
203-
Objects GetChildren() const { return m_children; }
196+
//-----------------------------------------------------------------------------
197+
// Parent / children objects
198+
//-----------------------------------------------------------------------------
199+
void AddChild ( Object child );
200+
Object GetChild ( size_t index ) const;
201+
Object GetParent() const;
202+
Objects GetChildren() const;
204203
size_t GetChildCount();
205-
204+
//-----------------------------------------------------------------------------
205+
// Serialize
206+
//-----------------------------------------------------------------------------
206207
wxXmlNode *Serialize( wxXmlNode *parent );
208+
207209
private:
208210
friend class ObjectTree;
209211

210212
wxXmlNode *SerializeChildren( Objects children, wxXmlNode *parent );
211213
wxXmlNode *SerializeProperties( Properties props, wxXmlNode *parent );
212214

213215
ClassInfo m_info;
214-
ClassInfos m_baseinfos;
215216
Object m_parent;
216217
Objects m_children;
217218
bool m_expanded;
@@ -220,7 +221,7 @@ class ObjectNode : public IObject
220221
Properties m_props;
221222
};
222223
//=============================================================================
223-
// ObjectTree Singleton Class
224+
// ObjectTree Class
224225
//=============================================================================
225226
class ObjectTree// : public IObjectManager
226227
{
@@ -231,26 +232,28 @@ class ObjectTree// : public IObjectManager
231232
virtual Object CreateObject ( const wxString &className,
232233
Object parent = Object() );
233234

234-
virtual Object GetSelectedObject() const { return m_sel; }
235-
236-
Object GetTopLevelObject( Object object ) const;
235+
virtual Object GetSelectedObject() const;
236+
Object GetTopLevelObject( Object object ) const;
237237

238238
virtual void SelectObject ( Object object, bool withEvent = true );
239239

240240
virtual bool Load ( const wxString &filePath );
241+
//-----------------------------------------------------------------------------
242+
// Serialize
243+
//-----------------------------------------------------------------------------
241244
virtual bool Serialize ( wxXmlNode *rootNode );
242245
virtual bool Serialize ( const wxString &filePath );
243246

244247
private:
245-
bool CheckType( const wxString &parentType,
246-
const wxString &childType );
248+
// bool CheckType ( const wxString &parentType,
249+
// const wxString &childType );
247250

248251
size_t GetChildInfoCount( Object parent, ClassInfo info );
249252

250253
Object DoCreateObject( Object parentObject, wxXmlNode *parentNode,
251254
bool isReference = false );
252-
Object m_root;
253-
Object m_sel;
255+
Object m_root; // Root object
256+
Object m_sel; // Selected object
254257
};
255258

256259
#endif //__WXGUIDESIGNER_RTTI_TREE_H__

output/db/controlbase.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Name: controlbase.xml
4+
Purpose: Control base classes group list
5+
Author: Andrea Zanellato
6+
Modified by:
7+
Created: 2012/06/29
8+
Revision: $Hash$
9+
Copyleft: (ɔ) Andrea Zanellato
10+
Licence: GNU General Public License Version 3
11+
-->
12+
<controlbase>
13+
<item>Project</item>
14+
<item>wxWindow</item>
15+
<item>wxTopLevelWindow</item>
16+
<item>wxSizer</item>
17+
<item>wxControl</item>
18+
<item>wxBookCtrlBase</item>
19+
</controlbase>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Name: bookctrlbase.xml
4+
Purpose: wxBookCtrlBase class definition
5+
Author: Andrea Zanellato
6+
Modified by:
7+
Created: 2012/06/28
8+
Revision: $Hash$
9+
Copyleft: (ɔ) Andrea Zanellato
10+
Licence: GNU General Public License Version 3
11+
-->
12+
<class name="wxBookCtrlBase" type="abstract">
13+
<description>
14+
&lt;p&gt;A book control is a convenient way of displaying multiple pages of information, displayed one page at a time. &lt;/p&gt;
15+
&lt;p&gt;wxWidgets has five variants of this control:&lt;/p&gt;
16+
&lt;ul&gt;
17+
&lt;li&gt;&lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_choicebook.html" title="wxChoicebook is a class similar to wxNotebook, but uses a wxChoice control to show the labels instead..."&gt;wxChoicebook&lt;/a&gt;: controlled by a &lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_choice.html" title="A choice item is used to select one of a list of strings."&gt;wxChoice&lt;/a&gt; &lt;/li&gt;
18+
&lt;li&gt;&lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_listbook.html" title="wxListbook is a class similar to wxNotebook but which uses a wxListCtrl to show the labels instead of..."&gt;wxListbook&lt;/a&gt;: controlled by a &lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_list_ctrl.html" title="A list control presents lists in a number of formats: list view, report view, icon view and small ico..."&gt;wxListCtrl&lt;/a&gt; &lt;/li&gt;
19+
&lt;li&gt;&lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_notebook.html" title="This class represents a notebook control, which manages multiple windows with associated tabs..."&gt;wxNotebook&lt;/a&gt;: uses a row of tabs &lt;/li&gt;
20+
&lt;li&gt;&lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_treebook.html" title="This class is an extension of the wxNotebook class that allows a tree structured set of pages to be s..."&gt;wxTreebook&lt;/a&gt;: controlled by a &lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_tree_ctrl.html" title="A tree control presents information as a hierarchy, with items that may be expanded to show further i..."&gt;wxTreeCtrl&lt;/a&gt; &lt;/li&gt;
21+
&lt;li&gt;&lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_toolbook.html" title="wxToolbook is a class similar to wxNotebook but which uses a wxToolBar to show the labels instead of ..."&gt;wxToolbook&lt;/a&gt;: controlled by a &lt;a class="el" href="http://docs.wxwidgets.org/trunk/classwx_tool_bar.html" title="A toolbar is a bar of buttons and/or other controls usually placed below the menu bar in a wxFrame..."&gt;wxToolBar&lt;/a&gt;&lt;/li&gt;
22+
&lt;/ul&gt;
23+
&lt;p&gt;This abstract class is the parent of all these book controls, and provides their basic interface. This is a pure virtual class so you cannot allocate it directly.&lt;/p&gt;
24+
</description>
25+
<inherits>
26+
<class>wxControl</class>
27+
<class>wxWithImages</class>
28+
</inherits>
29+
<style>
30+
<flag name="wxBK_DEFAULT">
31+
<description>Native controller placement.</description>
32+
</flag>
33+
<flag name="wxBK_TOP">
34+
<description>Controller above pages.</description>
35+
</flag>
36+
<flag name="wxBK_BOTTOM">
37+
<description>Controller below pages.</description>
38+
</flag>
39+
<flag name="wxBK_LEFT">
40+
<description>Controller on the left.</description>
41+
</flag>
42+
<flag name="wxBK_RIGHT">
43+
<description>Controller on the right.</description>
44+
</flag>
45+
</style>
46+
</class>

output/db/controlbase/control.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Name: control.xml
4+
Purpose: wxControl class definition
5+
Author: Andrea Zanellato
6+
Modified by:
7+
Created: 2011/12/01
8+
Revision: $Hash$
9+
Copyleft: (ɔ) Andrea Zanellato
10+
Licence: GNU General Public License Version 3
11+
-->
12+
<class name="wxControl" type="abstract">
13+
<description>
14+
&lt;p&gt;This is the base class for a control or "widget".&lt;/p&gt;
15+
&lt;p&gt;A control is generally a small window which processes user input and/or displays one or more item of data.&lt;/p&gt;
16+
</description>
17+
<inherits>
18+
<class>wxWindow</class>
19+
</inherits>
20+
<text name="label" label="Label">
21+
<description>Label to display on the control.</description>
22+
</text>
23+
<event name="wxClipboardTextEvent">
24+
<type name="wxEVT_COMMAND_TEXT_COPY">
25+
<description>Some or all of the controls content was copied to the clipboard.</description>
26+
<macro_id>EVT_TEXT_COPY</macro_id>
27+
</type>
28+
<type name="wxEVT_COMMAND_TEXT_CUT">
29+
<description>Some or all of the controls content was cut (i.e. copied and deleted).</description>
30+
<macro_id>EVT_TEXT_CUT</macro_id>
31+
</type>
32+
<type name="wxEVT_COMMAND_TEXT_PASTE">
33+
<description>Clipboard content was pasted into the control.</description>
34+
<macro_id>EVT_TEXT_PASTE</macro_id>
35+
</type>
36+
</event>
37+
</class>

0 commit comments

Comments
 (0)