Skip to content

Commit

Permalink
Preliminary work on TreeView controls for world configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Oct 21, 2010
1 parent 3100508 commit 1e8cacc
Show file tree
Hide file tree
Showing 5 changed files with 1,083 additions and 249 deletions.
65 changes: 49 additions & 16 deletions dialogs/world_prefs/GenPropertyPage.h
Expand Up @@ -11,6 +11,8 @@ typedef CTypedPtrMap <CMapStringToPtr, CString, CObject*> CObjectMap;

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

#define ID_TREEVIEW (WM_USER + 1004)

typedef struct t_gen_sort_param
{
// initialise via constructor - makes sure we don't leave something out!
Expand Down Expand Up @@ -61,6 +63,7 @@ class CGenPropertyPage : public CPropertyPage
CFindInfo * m_pObjectFindInfo; // the findinfo structure
CListCtrl * m_ctlList; // the list control which displays the items
CStatic * m_ctlSummary; // count of items shown
bool m_bWantTreeControl; // true if it wants to show a tree control instead of a list control

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

CTreeCtrl m_cTreeCtrl; // for the tree views
map<CString, HTREEITEM> m_GroupsMap; // for inserting into groups

// set up variables for use later on

void CGenPropertyPage::SetUpPage (CString strObjectType,
CObjectMap * ObjectMap,
CListCtrl * ctlList,
CStatic * ctlSummary,
t_CompareObjects CompareObjects,
CFindInfo * pFindInfo,
const unsigned long iMask);
void CGenPropertyPage::SetUpPage (CString strObjectType,
CObjectMap * ObjectMap,
CListCtrl * ctlList,
CStatic * ctlSummary,
t_CompareObjects CompareObjects,
CFindInfo * pFindInfo,
const unsigned long iMask,
const bool bWantTreeControl);

// add an new item

void OnAddItem(CDialog & dlg); // adds a new item to the list
void OnChangeItem(CDialog & dlg); // changes an existing item
bool ChangeOneItem(CDialog & dlg, CString * pstrObjectName, const int nItem, HTREEITEM hdlItem); // changes one existing item
bool DeleteOneItem(CString * pstrObjectName, int & iIncluded, int & iExecuting); // deletes one existing item
void OnDeleteItem() ; // delete an item from the list
void OnCopyItem() ; // copy an item to the clipboard in XML
bool CopyOneItem(CString * pstrObjectName, CArchive & ar) ; // copy an item to the clipboard in XML
void OnPasteItem() ; // paste an item from the clipboard in XML
void OnColumnclickItemList(NMHDR* pNMHDR, LRESULT* pResult);
void LoadList (void); // load up list initially or after load from file
bool EditFilterText (CString & sText); // edit the filter text

void SortItems (void); // sort the tree/list control
int GetSelectedItemCount () const; // how many items are selected?
int GetItemCount () const; // how many items are there in the list/tree?
void CheckParentHasChildren (HTREEITEM hdlParent); // if this group is empty, delete it


// ================== start of virtual functions =======================

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

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

// ================== end of virtual functions =======================

// add a single item - returns new item number
// add a single list control item - returns new item number

int add_list_item (CObject * pItem,
const CString * pstrObjectName,
const int nItem,
const BOOL bInsert);

// add a single tree control item - returns new item number

HTREEITEM add_tree_item (CObject * pItem,
const CString * pstrObjectName);

int add_item (CObject * pItem,
const CString * pstrObjectName,
const int nItem,
const BOOL bInsert);

// Overrides
// ClassWizard generate virtual function overrides
Expand Down Expand Up @@ -173,12 +198,20 @@ void CGenPropertyPage::SetUpPage (CString strObjectType,

// for finding

// finds item n in the tree control
static HTREEITEM get_tree_item (CTreeCtrl * pTree, const int n);

static void InitiateSearch (const CObject * pObject,
CFindInfo & FindInfo);

static bool GetNextLine (const CObject * pObject,
CFindInfo & FindInfo,
CString & strLine);
static bool GetNextListLine (const CObject * pObject,
CFindInfo & FindInfo,
CString & strLine);


static bool GetNextTreeLine (const CObject * pObject,
CFindInfo & FindInfo,
CString & strLine);

void DoFind (bool bAgain);

Expand Down
14 changes: 10 additions & 4 deletions dialogs/world_prefs/configuration.cpp
Expand Up @@ -205,7 +205,8 @@ void CMUSHclientDoc:: LoadPrefsP7 (CPrefsP7 &page7)
&page7.m_ctlSummary,
page7.CompareObjects,
&m_AliasesFindInfo,
XML_ALIASES);
XML_ALIASES,
true); // tree control

page7.m_iColumnCount = CPrefsP7::eColumnCount;
page7.m_iColWidth = new int [CPrefsP7::eColumnCount];
Expand Down Expand Up @@ -246,7 +247,8 @@ void CMUSHclientDoc:: LoadPrefsP8 (CPrefsP8 &page8)
&page8.m_ctlSummary,
page8.CompareObjects,
&m_TriggersFindInfo,
XML_TRIGGERS);
XML_TRIGGERS,
true); // tree control

page8.m_iColumnCount = CPrefsP8::eColumnCount;
page8.m_iColWidth = new int [CPrefsP8::eColumnCount];
Expand Down Expand Up @@ -582,7 +584,9 @@ void CMUSHclientDoc:: LoadPrefsP16 (CPrefsP16 &page16)
&page16.m_ctlSummary,
page16.CompareObjects,
&m_TimersFindInfo,
XML_TIMERS);
XML_TIMERS,
true); // tree control


page16.m_iColumnCount = CPrefsP16::eColumnCount;
page16.m_iColWidth = new int [CPrefsP16::eColumnCount];
Expand Down Expand Up @@ -672,7 +676,9 @@ void CMUSHclientDoc:: LoadPrefsP18 (CPrefsP18 &page18)
&page18.m_ctlSummary,
page18.CompareObjects,
&m_VariablesFindInfo,
XML_VARIABLES);
XML_VARIABLES,
false); // NOT tree control


page18.m_iColumnCount = CPrefsP18::eColumnCount;
page18.m_iColWidth = new int [CPrefsP18::eColumnCount];
Expand Down

0 comments on commit 1e8cacc

Please sign in to comment.