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();
{
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
Menu_Delete,
Menu_Info,
- Ctrl_RegTree = 200,
+ Ctrl_RegTree = 200
};
// ----------------------------------------------------------------------------
// 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));
m_treeCtrl = new RegTreeCtrl(this, Ctrl_RegTree);
#endif
+#if wxUSE_STATUSBAR
// create the status line
// ----------------------
CreateStatusBar(2);
+#endif // wxUSE_STATUSBAR
}
RegFrame::~RegFrame()
{
wxMessageDialog dialog(this,
_T("wxRegistry sample\n")
- _T("© 1998, 2000 Vadim Zeitlin"),
+ _T("(c) 1998, 2000 Vadim Zeitlin"),
_T("About wxRegTest"), wxOK);
dialog.ShowModal();
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
// 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?") );
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)
while ( bCont )
{
wxString strItem;
- if (str.IsEmpty())
+ if (str.empty())
strItem = _T("<default>");
else
strItem = str;
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();
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?"));
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?") );
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?") );
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?") );
void RegTreeCtrl::ShowProperties()
{
- long lCurrent = GetSelection();
+ wxTreeItemId lCurrent = GetSelection();
TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
if ( !pCurrent || pCurrent->IsRoot() )
bool RegTreeCtrl::IsKeySelected() const
{
- long lCurrent = GetSelection();
+ wxTreeItemId lCurrent = GetSelection();
TreeNode *pCurrent = (TreeNode *) GetItemData(lCurrent);
wxCHECK( pCurrent != NULL, false );
void RegTreeCtrl::DoRefresh()
{
- long lId = GetSelection();
+ wxTreeItemId lId = GetSelection();
if ( !lId )
return;