X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1824493628261b2cb7ceceb431d85c427f1c976b..0dfef5a8124ac0f1bb2aed6ef5ddfa833e8e2c6e:/samples/regtest/regtest.cpp diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index 4f3eb6ee1f..6a0ce41c81 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -29,6 +29,7 @@ #include "wx/log.h" #include "wx/treectrl.h" #include "wx/msw/registry.h" +#include "wx/msw/imaglist.h" // ---------------------------------------------------------------------------- // application type @@ -58,8 +59,7 @@ public: }; // array of children of the node -struct TreeNode; -WX_DEFINE_ARRAY(TreeNode *, TreeChildren); +//class TreeNode; // ---------------------------------------------------------------------------- // our control @@ -96,8 +96,10 @@ public: private: // structure describing a registry key/value - struct TreeNode + class TreeNode : public wxTreeItemData { +WX_DEFINE_ARRAY(TreeNode *, TreeChildren); + public: RegTreeCtrl *m_pTree; // must be !NULL TreeNode *m_pParent; // NULL only for the root node long m_id; // the id of the tree control item @@ -138,7 +140,7 @@ private: wxImageList *m_imageList; TreeNode *GetNode(const wxTreeEvent& event) - { return (TreeNode *)GetItemData(event.m_item.m_itemId); } + { return (TreeNode *)GetItemData((WXHTREEITEM)event.GetItem()); } public: // create a new node and insert it to the tree @@ -267,11 +269,11 @@ bool RegApp::OnInit() { // create the main frame window and show it RegFrame *frame = new RegFrame(NULL, "wxRegKey Test", 50, 50, 600, 350); - frame->Show(true); + frame->Show(TRUE); SetTopWindow(frame); - return true; + return TRUE; } // ---------------------------------------------------------------------------- @@ -389,7 +391,7 @@ RegImageList::RegImageList() : wxImageList(16, 16, TRUE) // should be in sync with enum RegImageList::RegIcon static const char *aszIcons[] = { "key1","key2","key3","value1","value2" }; 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)); } } @@ -418,9 +420,7 @@ RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent, wxASSERT_MSG( pNewNode->m_id, "can't create tree control item!"); // save the pointer in the item - if ( !SetItemData(pNewNode->m_id, (long)pNewNode) ) { - wxFAIL_MSG("can't store item's data in tree control!"); - } + SetItemData(pNewNode->m_id, pNewNode); // add it to the list of parent's children if ( pParent != NULL ) { @@ -461,7 +461,7 @@ RegTreeCtrl::~RegTreeCtrl() 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)); } } @@ -529,7 +529,7 @@ void RegTreeCtrl::OnChar(wxKeyEvent& event) if ( event.KeyCode() == WXK_DELETE ) DeleteSelected(); else - wxTreeCtrl::OnChar(event); + event.Skip(); } void RegTreeCtrl::OnSelChanged(wxTreeEvent& event) @@ -541,7 +541,7 @@ void RegTreeCtrl::OnSelChanged(wxTreeEvent& event) void RegTreeCtrl::OnItemExpanding(wxTreeEvent& 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 wxSetCursor(*wxHOURGLASS_CURSOR); @@ -563,7 +563,7 @@ void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) if ( !pNode->IsRoot() ) { int idIcon = bExpanding ? RegImageList::OpenedKey : RegImageList::ClosedKey; - SetItemImage(pNode->Id(), idIcon, idIcon); + SetItemImage(pNode->Id(), idIcon); } } @@ -578,7 +578,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() { // remove dummy item if ( m_lDummy != 0 ) { - m_pTree->DeleteItem(m_lDummy); + m_pTree->Delete(m_lDummy); m_lDummy = 0; } else { @@ -589,7 +589,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() if ( IsRoot() ) { // we're the root key m_pTree->AddStdKeys(); - return true; + return TRUE; } if ( Parent()->IsRoot() ) { @@ -603,7 +603,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() if ( !m_pKey->Open() ) { wxLogError("The key '%s' can't be opened.", FullName()); - return false; + return FALSE; } // enumeration variables @@ -666,7 +666,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() bCont = m_pKey->GetNextValue(str, l); } - return true; + return TRUE; } void RegTreeCtrl::TreeNode::OnCollapse() @@ -691,11 +691,11 @@ void RegTreeCtrl::TreeNode::AddDummy() void RegTreeCtrl::TreeNode::DestroyChildren() { // destroy all children - uint nCount = m_aChildren.Count(); - for ( uint n = 0; n < nCount; n++ ) { - long lId = m_aChildren[n]->Id(); + unsigned int nCount = m_aChildren.Count(); + for ( unsigned int n = 0; n < nCount; n++ ) { + long lId = m_aChildren[n]->Id(); delete m_aChildren[n]; - m_pTree->DeleteItem(lId); + m_pTree->Delete(lId); } m_aChildren.Empty(); @@ -834,7 +834,7 @@ bool RegTreeCtrl::IsKeySelected() const long lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); - wxCHECK( pCurrent != NULL, false ); + wxCHECK( pCurrent != NULL, FALSE ); return pCurrent->IsKey(); } \ No newline at end of file