Skip to content

Commit

Permalink
Added checkbox to toggle on/off treeview
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Oct 21, 2010
1 parent 49540c2 commit d2970a9
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dialogs/world_prefs/GenPropertyPage.h
Expand Up @@ -12,6 +12,7 @@ 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)
#define ID_USE_TREEVIEW (WM_USER + 1005)

typedef struct t_gen_sort_param
{
Expand Down Expand Up @@ -82,6 +83,9 @@ class CGenPropertyPage : public CPropertyPage
CTreeCtrl m_cTreeCtrl; // for the tree views
map<CString, HTREEITEM> m_GroupsMap; // for inserting into groups

CButton m_cUseTreeViewCtrl; // button for turning on/off tree views
CFont m_checkboxFont; // font for it

// set up variables for use later on

void CGenPropertyPage::SetUpPage (CString strObjectType,
Expand Down
38 changes: 38 additions & 0 deletions dialogs/world_prefs/genpropertypage.cpp
Expand Up @@ -1018,6 +1018,17 @@ void CGenPropertyPage::LoadList (void)

delete m_ScriptEngine;

if (m_bWantTreeControl)
{
m_cTreeCtrl.ShowWindow (SW_SHOW);
m_ctlList->ShowWindow (SW_HIDE);
}
else
{
m_ctlList->ShowWindow (SW_SHOW);
m_cTreeCtrl.ShowWindow (SW_HIDE);
}

} // end of CGenPropertyPage::LoadList


Expand Down Expand Up @@ -1277,7 +1288,34 @@ BOOL CGenPropertyPage::OnInitDialog()
GetSafeHwnd(),
(HMENU)ID_TREEVIEW);

if (m_strObjectType != "variable")
{
int iRight = wndpl.rcNormalPosition.right;
GetDlgItem (IDC_COUNT)->GetWindowPlacement (&wndpl);
wndpl.rcNormalPosition.right = iRight;
wndpl.rcNormalPosition.left = wndpl.rcNormalPosition.right - 100;

m_cUseTreeViewCtrl.Create(Translate ("Tree View"),
BS_CHECKBOX | WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
wndpl.rcNormalPosition,
this,
ID_USE_TREEVIEW);


// bloody hell! so much work ...
LOGFONT logFont;
CFont * pFont = GetDlgItem (IDC_COPY)->GetFont();
pFont->GetLogFont(&logFont);

// fix up the font
m_checkboxFont.CreateFontIndirect(&logFont);
m_cUseTreeViewCtrl.SetFont(&m_checkboxFont);

// set check state appropriately
m_cUseTreeViewCtrl.SetCheck (m_bWantTreeControl);

} // end of adding "treeview" checkbox

// now hide one of the controls
if (m_bWantTreeControl)
m_ctlList->ShowWindow (SW_HIDE);
Expand Down
21 changes: 21 additions & 0 deletions dialogs/world_prefs/prefspropertypages.cpp
Expand Up @@ -2578,6 +2578,7 @@ BEGIN_MESSAGE_MAP(CPrefsP7, CGenPropertyPage)
ON_UPDATE_COMMAND_UI(IDC_MOVE_UP, OnUpdateCanSequence)
ON_UPDATE_COMMAND_UI(IDC_MOVE_DOWN, OnUpdateCanSequence)
ON_NOTIFY(NM_DBLCLK, ID_TREEVIEW, OnDblclkAliasesList)
ON_BN_CLICKED(ID_USE_TREEVIEW, OnUseTreeViewChecked)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3380,6 +3381,12 @@ if (EditFilterText (m_doc->m_strAliasesFilter))
LoadList (); // need to reload the list now
}

void CPrefsP7::OnUseTreeViewChecked()
{
m_bWantTreeControl = ((CButton *) GetDlgItem (ID_USE_TREEVIEW))->GetCheck () != 0;
LoadList ();
} // end of CPrefsP7::OnUseTreeViewChecked

void CPrefsP7::GetFilterInfo (CObject * pItem, lua_State * L)
{
CAlias * alias = (CAlias *) pItem;
Expand Down Expand Up @@ -3541,6 +3548,7 @@ BEGIN_MESSAGE_MAP(CPrefsP8, CGenPropertyPage)
ON_UPDATE_COMMAND_UI(IDC_LOAD_TRIGGER, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_TRIGGERS, OnUpdateHaveDefaults)
ON_NOTIFY(NM_DBLCLK, ID_TREEVIEW, OnDblclkTriggersList)
ON_BN_CLICKED(ID_USE_TREEVIEW, OnUseTreeViewChecked)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4508,6 +4516,12 @@ if (EditFilterText (m_doc->m_strTriggersFilter))
LoadList (); // need to reload the list now
}

void CPrefsP8::OnUseTreeViewChecked()
{
m_bWantTreeControl = ((CButton *) GetDlgItem (ID_USE_TREEVIEW))->GetCheck () != 0;
LoadList ();
} // end of CPrefsP8::OnUseTreeViewChecked

void CPrefsP8::OnFilter()
{
LoadList (); // need to reload the list now
Expand Down Expand Up @@ -6205,6 +6219,7 @@ BEGIN_MESSAGE_MAP(CPrefsP16, CGenPropertyPage)
ON_UPDATE_COMMAND_UI(IDC_LOAD_TIMERS, OnUpdateNotUsingDefaults)
ON_UPDATE_COMMAND_UI(IDC_USE_DEFAULT_TIMERS, OnUpdateHaveDefaults)
ON_NOTIFY(NM_DBLCLK, ID_TREEVIEW, OnDblclkTimersList)
ON_BN_CLICKED(ID_USE_TREEVIEW, OnUseTreeViewChecked)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -6889,6 +6904,12 @@ if (EditFilterText (m_doc->m_strTimersFilter))
LoadList (); // need to reload the list now
}

void CPrefsP16::OnUseTreeViewChecked()
{
m_bWantTreeControl = ((CButton *) GetDlgItem (ID_USE_TREEVIEW))->GetCheck () != 0;
LoadList ();
} // end of CPrefsP16::OnUseTreeViewChecked

void CPrefsP16::GetFilterInfo (CObject * pItem, lua_State * L)
{
CTimer * timer = (CTimer *) pItem;
Expand Down
3 changes: 3 additions & 0 deletions dialogs/world_prefs/prefspropertypages.h
Expand Up @@ -654,6 +654,7 @@ class CPrefsP7 : public CGenPropertyPage
afx_msg void OnUpdateNeedOneSelection(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedXMLClipboard(CCmdUI* pCmdUI);
afx_msg void OnUpdateCanSequence(CCmdUI* pCmdUI);
afx_msg void OnUseTreeViewChecked();
DECLARE_MESSAGE_MAP()

};
Expand Down Expand Up @@ -781,6 +782,7 @@ class CPrefsP8 : public CGenPropertyPage
afx_msg void OnUpdateNeedSelection(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedOneSelection(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedXMLClipboard(CCmdUI* pCmdUI);
afx_msg void OnUseTreeViewChecked();
DECLARE_MESSAGE_MAP()

};
Expand Down Expand Up @@ -1384,6 +1386,7 @@ class CPrefsP16 : public CGenPropertyPage
afx_msg void OnUpdateNotUsingDefaults(CCmdUI* pCmdUI);
afx_msg void OnUpdateHaveDefaults(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedXMLClipboard(CCmdUI* pCmdUI);
afx_msg void OnUseTreeViewChecked();
DECLARE_MESSAGE_MAP()

};
Expand Down

0 comments on commit d2970a9

Please sign in to comment.