X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/721b839791b78a52348ee0bf8281b98864f3b463..f5766910b6731eb03e82371416e9778203396ce7:/samples/regtest/regtest.cpp diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index 76845feb09..a0c05f3a96 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -114,17 +114,17 @@ private: 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 + wxTreeItemId m_id; // the id of the tree control item wxString m_strName; // name of the key/value TreeChildren m_aChildren; // array of subkeys/values bool m_bKey; // key or value? wxRegKey *m_pKey; // only may be !NULL if m_bKey == true // trivial accessors - long Id() const { return m_id; } - bool IsRoot() const { return m_pParent == NULL; } - bool IsKey() const { return m_bKey; } - TreeNode *Parent() const { return m_pParent; } + wxTreeItemId Id() const { return m_id; } + bool IsRoot() const { return m_pParent == NULL; } + bool IsKey() const { return m_bKey; } + TreeNode *Parent() const { return m_pParent; } // notifications bool OnExpand(); @@ -156,7 +156,7 @@ private: wxString m_nameOld; // the initial value of item being renamed TreeNode *GetNode(const wxTreeEvent& event) - { return (TreeNode *)GetItemData((WXHTREEITEM)event.GetItem()); } + { return (TreeNode *)GetItemData(event.GetItem()); } public: // create a new node and insert it to the tree @@ -181,7 +181,7 @@ class RegFrame : public wxFrame { public: // ctor & dtor - RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h); + RegFrame(wxFrame *parent, const wxChar *title, int x, int y, int w, int h); virtual ~RegFrame(); // callbacks @@ -233,7 +233,7 @@ enum Menu_Delete, Menu_Info, - Ctrl_RegTree = 200, + Ctrl_RegTree = 200 }; // ---------------------------------------------------------------------------- @@ -331,8 +331,8 @@ bool RegApp::OnInit() // RegFrame // ---------------------------------------------------------------------------- -RegFrame::RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h) - : wxFrame(parent, -1, title, wxPoint(x, y), wxSize(w, h)) +RegFrame::RegFrame(wxFrame *parent, const wxChar *title, int x, int y, int w, int h) + : wxFrame(parent, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)) { // this reduces flicker effects SetBackgroundColour(wxColour(255, 255, 255)); @@ -361,9 +361,11 @@ RegFrame::RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h) m_treeCtrl = new RegTreeCtrl(this, Ctrl_RegTree); #endif +#if wxUSE_STATUSBAR // create the status line // ---------------------- CreateStatusBar(2); +#endif // wxUSE_STATUSBAR } RegFrame::~RegFrame() @@ -383,7 +385,7 @@ void RegFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageDialog dialog(this, _T("wxRegistry sample\n") - _T("© 1998, 2000 Vadim Zeitlin"), + _T("(c) 1998, 2000 Vadim Zeitlin"), _T("About wxRegTest"), wxOK); dialog.ShowModal(); @@ -398,7 +400,7 @@ void RegFrame::OnTest(wxCommandEvent& WXUNUSED(event)) void RegFrame::OnGoTo(wxCommandEvent& WXUNUSED(event)) { - static wxString s_location = _T("HKEY_CURRENT_USER\\Software\\wxWindows"); + static wxString s_location = _T("HKEY_CURRENT_USER\\Software\\wxWidgets"); wxString location = wxGetTextFromUser( _T("Enter the location to go to:"), @@ -617,7 +619,7 @@ void RegTreeCtrl::OnIdle(wxIdleEvent& WXUNUSED(event)) void RegTreeCtrl::OnRightClick(wxMouseEvent& event) { int iFlags; - long lId = HitTest(wxPoint(event.GetX(), event.GetY()), iFlags); + wxTreeItemId lId = HitTest(wxPoint(event.GetX(), event.GetY()), iFlags); if ( iFlags & wxTREE_HITTEST_ONITEMLABEL ) { // select the item first @@ -636,7 +638,7 @@ void RegTreeCtrl::OnDeleteItem(wxTreeEvent& WXUNUSED(event)) // test the key creation functions void RegTreeCtrl::OnMenuTest() { - long lId = GetSelection(); + wxTreeItemId lId = GetSelection(); TreeNode *pNode = (TreeNode *)GetItemData(lId); wxCHECK_RET( pNode != NULL, wxT("tree item without data?") ); @@ -697,8 +699,12 @@ void RegTreeCtrl::OnChar(wxKeyEvent& event) void RegTreeCtrl::OnSelChanged(wxTreeEvent& event) { +#if wxUSE_STATUSBAR wxFrame *pFrame = (wxFrame *) wxWindow::GetParent(); pFrame->SetStatusText(GetNode(event)->FullName(), 1); +#else + wxUnusedVar(event); +#endif // wxUSE_STATUSBAR } void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) @@ -958,7 +964,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() while ( bCont ) { wxString strItem; - if (str.IsEmpty()) + if (str.empty()) strItem = _T(""); else strItem = str; @@ -1082,11 +1088,8 @@ void RegTreeCtrl::TreeNode::DestroyChildren() size_t nCount = m_aChildren.GetCount(); for ( size_t n = 0; n < nCount; n++ ) { - long lId = m_aChildren[n]->Id(); - // no, wxTreeCtrl will do it - //delete m_aChildren[n]; - wxTreeItemId theId(lId); // Temp variable seems necessary for BC++ - m_pTree->Delete(theId); + wxTreeItemId lId = m_aChildren[n]->Id(); + m_pTree->Delete(lId); } m_aChildren.Empty(); @@ -1177,17 +1180,17 @@ void RegTreeCtrl::GoTo(const wxString& location) void RegTreeCtrl::DeleteSelected() { - long lCurrent = GetSelection(), - lParent = GetItemParent(lCurrent); + wxTreeItemId lCurrent = GetSelection(), + lParent = GetItemParent(lCurrent); - if ( lParent == 0 ) + if ( lParent == GetRootItem() ) { wxLogError(wxT("Can't delete root key.")); return; } TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent), - *pParent = (TreeNode *)GetItemData(lParent); + *pParent = (TreeNode *)GetItemData(lParent); wxCHECK_RET(pCurrent && pParent, wxT("either node or parent without data?")); @@ -1214,7 +1217,7 @@ void RegTreeCtrl::DeleteSelected() void RegTreeCtrl::CreateNewKey(const wxString& strName) { - long lCurrent = GetSelection(); + wxTreeItemId lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, wxT("node without data?") ); @@ -1234,7 +1237,7 @@ void RegTreeCtrl::CreateNewKey(const wxString& strName) void RegTreeCtrl::CreateNewTextValue(const wxString& strName) { - long lCurrent = GetSelection(); + wxTreeItemId lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, wxT("node without data?") ); @@ -1253,7 +1256,7 @@ void RegTreeCtrl::CreateNewTextValue(const wxString& strName) void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName) { - long lCurrent = GetSelection(); + wxTreeItemId lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, wxT("node without data?") ); @@ -1272,7 +1275,7 @@ void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName) void RegTreeCtrl::ShowProperties() { - long lCurrent = GetSelection(); + wxTreeItemId lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); if ( !pCurrent || pCurrent->IsRoot() ) @@ -1315,7 +1318,7 @@ void RegTreeCtrl::ShowProperties() bool RegTreeCtrl::IsKeySelected() const { - long lCurrent = GetSelection(); + wxTreeItemId lCurrent = GetSelection(); TreeNode *pCurrent = (TreeNode *) GetItemData(lCurrent); wxCHECK( pCurrent != NULL, false ); @@ -1325,7 +1328,7 @@ bool RegTreeCtrl::IsKeySelected() const void RegTreeCtrl::DoRefresh() { - long lId = GetSelection(); + wxTreeItemId lId = GetSelection(); if ( !lId ) return;