X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e3b8fa75aab0136fc7022a410e873acf78ad085..7d8e5b8f04d24aa8c732d4e1fc3cb162a77beed5:/samples/regtest/regtest.cpp?ds=sidebyside diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index d584c7b05a..4ead1d3df7 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(); @@ -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 }; // ---------------------------------------------------------------------------- @@ -259,9 +259,10 @@ END_EVENT_TABLE() #if DO_REGTEST BEGIN_EVENT_TABLE(RegTreeCtrl, wxTreeCtrl) - EVT_TREE_DELETE_ITEM (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem) - EVT_TREE_ITEM_EXPANDING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) - EVT_TREE_SEL_CHANGED (Ctrl_RegTree, RegTreeCtrl::OnSelChanged) + EVT_TREE_DELETE_ITEM (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem) + EVT_TREE_ITEM_EXPANDING (Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) + EVT_TREE_ITEM_COLLAPSING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) + EVT_TREE_SEL_CHANGED (Ctrl_RegTree, RegTreeCtrl::OnSelChanged) EVT_TREE_BEGIN_LABEL_EDIT(Ctrl_RegTree, RegTreeCtrl::OnBeginEdit) EVT_TREE_END_LABEL_EDIT (Ctrl_RegTree, RegTreeCtrl::OnEndEdit) @@ -318,6 +319,9 @@ IMPLEMENT_APP(RegApp) // `Main program' equivalent, creating windows and returning main app frame bool RegApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + // create the main frame window and show it RegFrame *frame = new RegFrame(NULL, _T("wxRegTest"), 50, 50, 600, 350); frame->Show(true); @@ -331,8 +335,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 +365,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 +389,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 +404,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 +623,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 +642,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,14 +703,18 @@ 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) { TreeNode *pNode = GetNode(event); - bool bExpanding = event.GetKeyCode() == wxTREE_EXPAND_EXPAND; + bool bExpanding = event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_EXPANDING; // expansion might take some time wxSetCursor(*wxHOURGLASS_CURSOR); @@ -958,7 +968,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() while ( bCont ) { wxString strItem; - if (str.IsEmpty()) + if (str.empty()) strItem = _T(""); else strItem = str; @@ -1082,11 +1092,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 +1184,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 +1221,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 +1241,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 +1260,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 +1279,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 +1322,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 +1332,7 @@ bool RegTreeCtrl::IsKeySelected() const void RegTreeCtrl::DoRefresh() { - long lId = GetSelection(); + wxTreeItemId lId = GetSelection(); if ( !lId ) return;