no message
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@910 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/treectrl.h"
|
#include "wx/treectrl.h"
|
||||||
#include "wx/msw/registry.h"
|
#include "wx/msw/registry.h"
|
||||||
|
#include "wx/msw/imaglist.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// application type
|
// application type
|
||||||
@@ -58,8 +59,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// array of children of the node
|
// array of children of the node
|
||||||
struct TreeNode;
|
//class TreeNode;
|
||||||
WX_DEFINE_ARRAY(TreeNode *, TreeChildren);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// our control
|
// our control
|
||||||
@@ -96,8 +96,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// structure describing a registry key/value
|
// structure describing a registry key/value
|
||||||
struct TreeNode
|
class TreeNode : public wxTreeItemData
|
||||||
{
|
{
|
||||||
|
WX_DEFINE_ARRAY(TreeNode *, TreeChildren);
|
||||||
|
public:
|
||||||
RegTreeCtrl *m_pTree; // must be !NULL
|
RegTreeCtrl *m_pTree; // must be !NULL
|
||||||
TreeNode *m_pParent; // NULL only for the root node
|
TreeNode *m_pParent; // NULL only for the root node
|
||||||
long m_id; // the id of the tree control item
|
long m_id; // the id of the tree control item
|
||||||
@@ -138,7 +140,7 @@ private:
|
|||||||
wxImageList *m_imageList;
|
wxImageList *m_imageList;
|
||||||
|
|
||||||
TreeNode *GetNode(const wxTreeEvent& event)
|
TreeNode *GetNode(const wxTreeEvent& event)
|
||||||
{ return (TreeNode *)GetItemData(event.m_item.m_itemId); }
|
{ return (TreeNode *)GetItemData((WXHTREEITEM)event.GetItem()); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// create a new node and insert it to the tree
|
// create a new node and insert it to the tree
|
||||||
@@ -389,7 +391,7 @@ RegImageList::RegImageList() : wxImageList(16, 16, TRUE)
|
|||||||
// should be in sync with enum RegImageList::RegIcon
|
// should be in sync with enum RegImageList::RegIcon
|
||||||
static const char *aszIcons[] = { "key1","key2","key3","value1","value2" };
|
static const char *aszIcons[] = { "key1","key2","key3","value1","value2" };
|
||||||
wxString str = "icon_";
|
wxString str = "icon_";
|
||||||
for ( uint n = 0; n < WXSIZEOF(aszIcons); n++ ) {
|
for ( unsigned int n = 0; n < WXSIZEOF(aszIcons); n++ ) {
|
||||||
Add(wxIcon(str + aszIcons[n], wxBITMAP_TYPE_ICO_RESOURCE));
|
Add(wxIcon(str + aszIcons[n], wxBITMAP_TYPE_ICO_RESOURCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,9 +420,7 @@ RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent,
|
|||||||
wxASSERT_MSG( pNewNode->m_id, "can't create tree control item!");
|
wxASSERT_MSG( pNewNode->m_id, "can't create tree control item!");
|
||||||
|
|
||||||
// save the pointer in the item
|
// save the pointer in the item
|
||||||
if ( !SetItemData(pNewNode->m_id, (long)pNewNode) ) {
|
SetItemData(pNewNode->m_id, pNewNode);
|
||||||
wxFAIL_MSG("can't store item's data in tree control!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// add it to the list of parent's children
|
// add it to the list of parent's children
|
||||||
if ( pParent != NULL ) {
|
if ( pParent != NULL ) {
|
||||||
@@ -461,7 +461,7 @@ RegTreeCtrl::~RegTreeCtrl()
|
|||||||
|
|
||||||
void RegTreeCtrl::AddStdKeys()
|
void RegTreeCtrl::AddStdKeys()
|
||||||
{
|
{
|
||||||
for ( uint ui = 0; ui < wxRegKey::nStdKeys; ui++ ) {
|
for ( unsigned int ui = 0; ui < wxRegKey::nStdKeys; ui++ ) {
|
||||||
InsertNewTreeNode(m_pRoot, wxRegKey::GetStdKeyName(ui));
|
InsertNewTreeNode(m_pRoot, wxRegKey::GetStdKeyName(ui));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,7 +541,7 @@ void RegTreeCtrl::OnSelChanged(wxTreeEvent& event)
|
|||||||
void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event)
|
void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event)
|
||||||
{
|
{
|
||||||
TreeNode *pNode = GetNode(event);
|
TreeNode *pNode = GetNode(event);
|
||||||
bool bExpanding = event.m_code == wxTREE_EXPAND_EXPAND;
|
bool bExpanding = event.GetCode() == wxTREE_EXPAND_EXPAND;
|
||||||
|
|
||||||
// expansion might take some time
|
// expansion might take some time
|
||||||
wxSetCursor(*wxHOURGLASS_CURSOR);
|
wxSetCursor(*wxHOURGLASS_CURSOR);
|
||||||
@@ -563,7 +563,7 @@ void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event)
|
|||||||
if ( !pNode->IsRoot() ) {
|
if ( !pNode->IsRoot() ) {
|
||||||
int idIcon = bExpanding ? RegImageList::OpenedKey
|
int idIcon = bExpanding ? RegImageList::OpenedKey
|
||||||
: RegImageList::ClosedKey;
|
: RegImageList::ClosedKey;
|
||||||
SetItemImage(pNode->Id(), idIcon, idIcon);
|
SetItemImage(pNode->Id(), idIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +578,7 @@ bool RegTreeCtrl::TreeNode::OnExpand()
|
|||||||
{
|
{
|
||||||
// remove dummy item
|
// remove dummy item
|
||||||
if ( m_lDummy != 0 ) {
|
if ( m_lDummy != 0 ) {
|
||||||
m_pTree->DeleteItem(m_lDummy);
|
m_pTree->Delete(m_lDummy);
|
||||||
m_lDummy = 0;
|
m_lDummy = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -691,11 +691,11 @@ void RegTreeCtrl::TreeNode::AddDummy()
|
|||||||
void RegTreeCtrl::TreeNode::DestroyChildren()
|
void RegTreeCtrl::TreeNode::DestroyChildren()
|
||||||
{
|
{
|
||||||
// destroy all children
|
// destroy all children
|
||||||
uint nCount = m_aChildren.Count();
|
unsigned int nCount = m_aChildren.Count();
|
||||||
for ( uint n = 0; n < nCount; n++ ) {
|
for ( unsigned int n = 0; n < nCount; n++ ) {
|
||||||
long lId = m_aChildren[n]->Id();
|
long lId = m_aChildren[n]->Id();
|
||||||
delete m_aChildren[n];
|
delete m_aChildren[n];
|
||||||
m_pTree->DeleteItem(lId);
|
m_pTree->Delete(lId);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_aChildren.Empty();
|
m_aChildren.Empty();
|
||||||
|
@@ -545,7 +545,8 @@ wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent,
|
|||||||
void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
void wxTreeCtrl::Delete(const wxTreeItemId& item)
|
||||||
{
|
{
|
||||||
wxTreeItemData *data = GetItemData(item);
|
wxTreeItemData *data = GetItemData(item);
|
||||||
delete data; // may be NULL, ok
|
if(data!=NULL)
|
||||||
|
delete data; // may be NULL, ok
|
||||||
|
|
||||||
if ( !TreeView_DeleteItem(wxhWnd, (HTREEITEM)(WXHTREEITEM)item) )
|
if ( !TreeView_DeleteItem(wxhWnd, (HTREEITEM)(WXHTREEITEM)item) )
|
||||||
{
|
{
|
||||||
@@ -612,6 +613,11 @@ void wxTreeCtrl::Toggle(const wxTreeItemId& item)
|
|||||||
DoExpand(item, TVE_TOGGLE);
|
DoExpand(item, TVE_TOGGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action)
|
||||||
|
{
|
||||||
|
DoExpand(item, action);
|
||||||
|
}
|
||||||
|
|
||||||
void wxTreeCtrl::Unselect()
|
void wxTreeCtrl::Unselect()
|
||||||
{
|
{
|
||||||
SelectItem(wxTreeItemId((WXHTREEITEM) 0));
|
SelectItem(wxTreeItemId((WXHTREEITEM) 0));
|
||||||
|
Reference in New Issue
Block a user