Skip to content

Commit 1e8cacc

Browse files
committed
Preliminary work on TreeView controls for world configuration
1 parent 3100508 commit 1e8cacc

File tree

5 files changed

+1083
-249
lines changed

5 files changed

+1083
-249
lines changed

dialogs/world_prefs/GenPropertyPage.h

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ typedef CTypedPtrMap <CMapStringToPtr, CString, CObject*> CObjectMap;
1111

1212
typedef int (* t_CompareObjects) (const int iColumn, const CObject * item1, const CObject * item2);
1313

14+
#define ID_TREEVIEW (WM_USER + 1004)
15+
1416
typedef struct t_gen_sort_param
1517
{
1618
// initialise via constructor - makes sure we don't leave something out!
@@ -61,6 +63,7 @@ class CGenPropertyPage : public CPropertyPage
6163
CFindInfo * m_pObjectFindInfo; // the findinfo structure
6264
CListCtrl * m_ctlList; // the list control which displays the items
6365
CStatic * m_ctlSummary; // count of items shown
66+
bool m_bWantTreeControl; // true if it wants to show a tree control instead of a list control
6467

6568
// count of columns is used for arrays below
6669
int m_iColumnCount; // how many columns there are
@@ -76,27 +79,39 @@ class CGenPropertyPage : public CPropertyPage
7679
BOOL m_reverse; // if true, reverse sort
7780
t_CompareObjects m_CompareObjects; // for comparing when sorting
7881

82+
CTreeCtrl m_cTreeCtrl; // for the tree views
83+
map<CString, HTREEITEM> m_GroupsMap; // for inserting into groups
84+
7985
// set up variables for use later on
8086

81-
void CGenPropertyPage::SetUpPage (CString strObjectType,
82-
CObjectMap * ObjectMap,
83-
CListCtrl * ctlList,
84-
CStatic * ctlSummary,
85-
t_CompareObjects CompareObjects,
86-
CFindInfo * pFindInfo,
87-
const unsigned long iMask);
87+
void CGenPropertyPage::SetUpPage (CString strObjectType,
88+
CObjectMap * ObjectMap,
89+
CListCtrl * ctlList,
90+
CStatic * ctlSummary,
91+
t_CompareObjects CompareObjects,
92+
CFindInfo * pFindInfo,
93+
const unsigned long iMask,
94+
const bool bWantTreeControl);
8895

8996
// add an new item
9097

9198
void OnAddItem(CDialog & dlg); // adds a new item to the list
9299
void OnChangeItem(CDialog & dlg); // changes an existing item
100+
bool ChangeOneItem(CDialog & dlg, CString * pstrObjectName, const int nItem, HTREEITEM hdlItem); // changes one existing item
101+
bool DeleteOneItem(CString * pstrObjectName, int & iIncluded, int & iExecuting); // deletes one existing item
93102
void OnDeleteItem() ; // delete an item from the list
94103
void OnCopyItem() ; // copy an item to the clipboard in XML
104+
bool CopyOneItem(CString * pstrObjectName, CArchive & ar) ; // copy an item to the clipboard in XML
95105
void OnPasteItem() ; // paste an item from the clipboard in XML
96106
void OnColumnclickItemList(NMHDR* pNMHDR, LRESULT* pResult);
97107
void LoadList (void); // load up list initially or after load from file
98108
bool EditFilterText (CString & sText); // edit the filter text
99-
109+
void SortItems (void); // sort the tree/list control
110+
int GetSelectedItemCount () const; // how many items are selected?
111+
int GetItemCount () const; // how many items are there in the list/tree?
112+
void CheckParentHasChildren (HTREEITEM hdlParent); // if this group is empty, delete it
113+
114+
100115
// ================== start of virtual functions =======================
101116

102117
// dialog management - initialise, load, unload, check if changed, get name
@@ -121,6 +136,10 @@ void CGenPropertyPage::SetUpPage (CString strObjectType,
121136
virtual __int64 GetModificationNumber (CObject * pItem) const = 0; // get modification number
122137
virtual CString GetScriptName (CObject * pItem) const = 0; // get script subroutine name
123138
virtual CString GetLabel (CObject * pItem) const = 0; // get item label
139+
virtual CString GetGroup (CObject * pItem) const = 0; // get item group
140+
virtual CString GetDescription (CObject * pItem) const = 0; // get item description for tree control
141+
virtual int GetSequence (CObject * pItem) const = 0; // get item sequence for sorting
142+
virtual CString GetFindText (CObject * pItem) const = 0; // get text for searching on
124143

125144
// list management - add the item to the list control
126145
virtual int AddItem (CObject * pItem, // add one item to the list control
@@ -139,12 +158,18 @@ void CGenPropertyPage::SetUpPage (CString strObjectType,
139158

140159
// ================== end of virtual functions =======================
141160

142-
// add a single item - returns new item number
161+
// add a single list control item - returns new item number
162+
163+
int add_list_item (CObject * pItem,
164+
const CString * pstrObjectName,
165+
const int nItem,
166+
const BOOL bInsert);
167+
168+
// add a single tree control item - returns new item number
169+
170+
HTREEITEM add_tree_item (CObject * pItem,
171+
const CString * pstrObjectName);
143172

144-
int add_item (CObject * pItem,
145-
const CString * pstrObjectName,
146-
const int nItem,
147-
const BOOL bInsert);
148173

149174
// Overrides
150175
// ClassWizard generate virtual function overrides
@@ -173,12 +198,20 @@ void CGenPropertyPage::SetUpPage (CString strObjectType,
173198

174199
// for finding
175200

201+
// finds item n in the tree control
202+
static HTREEITEM get_tree_item (CTreeCtrl * pTree, const int n);
203+
176204
static void InitiateSearch (const CObject * pObject,
177205
CFindInfo & FindInfo);
178206

179-
static bool GetNextLine (const CObject * pObject,
180-
CFindInfo & FindInfo,
181-
CString & strLine);
207+
static bool GetNextListLine (const CObject * pObject,
208+
CFindInfo & FindInfo,
209+
CString & strLine);
210+
211+
212+
static bool GetNextTreeLine (const CObject * pObject,
213+
CFindInfo & FindInfo,
214+
CString & strLine);
182215

183216
void DoFind (bool bAgain);
184217

dialogs/world_prefs/configuration.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ void CMUSHclientDoc:: LoadPrefsP7 (CPrefsP7 &page7)
205205
&page7.m_ctlSummary,
206206
page7.CompareObjects,
207207
&m_AliasesFindInfo,
208-
XML_ALIASES);
208+
XML_ALIASES,
209+
true); // tree control
209210

210211
page7.m_iColumnCount = CPrefsP7::eColumnCount;
211212
page7.m_iColWidth = new int [CPrefsP7::eColumnCount];
@@ -246,7 +247,8 @@ void CMUSHclientDoc:: LoadPrefsP8 (CPrefsP8 &page8)
246247
&page8.m_ctlSummary,
247248
page8.CompareObjects,
248249
&m_TriggersFindInfo,
249-
XML_TRIGGERS);
250+
XML_TRIGGERS,
251+
true); // tree control
250252

251253
page8.m_iColumnCount = CPrefsP8::eColumnCount;
252254
page8.m_iColWidth = new int [CPrefsP8::eColumnCount];
@@ -582,7 +584,9 @@ void CMUSHclientDoc:: LoadPrefsP16 (CPrefsP16 &page16)
582584
&page16.m_ctlSummary,
583585
page16.CompareObjects,
584586
&m_TimersFindInfo,
585-
XML_TIMERS);
587+
XML_TIMERS,
588+
true); // tree control
589+
586590

587591
page16.m_iColumnCount = CPrefsP16::eColumnCount;
588592
page16.m_iColWidth = new int [CPrefsP16::eColumnCount];
@@ -672,7 +676,9 @@ void CMUSHclientDoc:: LoadPrefsP18 (CPrefsP18 &page18)
672676
&page18.m_ctlSummary,
673677
page18.CompareObjects,
674678
&m_VariablesFindInfo,
675-
XML_VARIABLES);
679+
XML_VARIABLES,
680+
false); // NOT tree control
681+
676682

677683
page18.m_iColumnCount = CPrefsP18::eColumnCount;
678684
page18.m_iColWidth = new int [CPrefsP18::eColumnCount];

0 commit comments

Comments
 (0)