1998-05-22 19:57:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: treetest.h
|
|
|
|
// Purpose: wxTreeCtrl sample
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart and Markus Holzem
|
1998-10-28 21:32:29 +00:00
|
|
|
// Licence: wxWindows license
|
1998-05-22 19:57:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Define a new application type
|
1998-10-28 21:32:29 +00:00
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool OnInit();
|
|
|
|
};
|
1998-05-22 19:57:05 +00:00
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
class MyTreeItemData : public wxTreeItemData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyTreeItemData(const wxString& desc) : m_desc(desc) { }
|
|
|
|
|
|
|
|
void ShowInfo(wxTreeCtrl *tree);
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_desc;
|
1998-05-22 19:57:05 +00:00
|
|
|
};
|
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
class MyTreeCtrl : public wxTreeCtrl
|
1998-05-22 19:57:05 +00:00
|
|
|
{
|
|
|
|
public:
|
1998-10-28 21:32:29 +00:00
|
|
|
enum
|
|
|
|
{
|
1998-11-30 00:08:57 +00:00
|
|
|
TreeCtrlIcon_File,
|
|
|
|
TreeCtrlIcon_Folder
|
1998-10-28 21:32:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MyTreeCtrl(wxWindow *parent, const wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
long style);
|
|
|
|
virtual ~MyTreeCtrl();
|
|
|
|
|
|
|
|
void OnBeginDrag(wxTreeEvent& event);
|
|
|
|
void OnBeginRDrag(wxTreeEvent& event);
|
|
|
|
void OnBeginLabelEdit(wxTreeEvent& event);
|
|
|
|
void OnEndLabelEdit(wxTreeEvent& event);
|
|
|
|
void OnDeleteItem(wxTreeEvent& event);
|
|
|
|
void OnGetInfo(wxTreeEvent& event);
|
|
|
|
void OnSetInfo(wxTreeEvent& event);
|
|
|
|
void OnItemExpanded(wxTreeEvent& event);
|
|
|
|
void OnItemExpanding(wxTreeEvent& event);
|
|
|
|
void OnItemCollapsed(wxTreeEvent& event);
|
|
|
|
void OnItemCollapsing(wxTreeEvent& event);
|
|
|
|
void OnSelChanged(wxTreeEvent& event);
|
|
|
|
void OnSelChanging(wxTreeEvent& event);
|
|
|
|
void OnKeyDown(wxTreeEvent& event);
|
|
|
|
|
1998-11-26 19:10:01 +00:00
|
|
|
void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);
|
|
|
|
|
|
|
|
void AddTestItemsToTree(size_t numChildren,
|
|
|
|
size_t depth);
|
1998-11-13 20:47:22 +00:00
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
private:
|
|
|
|
void AddItemsRecursively(const wxTreeItemId& idParent,
|
|
|
|
size_t nChildren,
|
1998-11-13 20:47:22 +00:00
|
|
|
size_t depth,
|
1998-11-26 19:10:01 +00:00
|
|
|
size_t folder);
|
1998-10-28 21:32:29 +00:00
|
|
|
|
|
|
|
wxImageList *m_imageListNormal;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 19:57:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame type
|
|
|
|
class MyFrame: public wxFrame
|
1998-10-25 17:04:49 +00:00
|
|
|
{
|
|
|
|
public:
|
1998-10-28 21:32:29 +00:00
|
|
|
// ctor and dtor
|
|
|
|
MyFrame(const wxString& title, int x, int y, int w, int h);
|
|
|
|
virtual ~MyFrame();
|
1998-10-26 17:11:33 +00:00
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
// menu callbacks
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
1998-11-13 20:47:22 +00:00
|
|
|
void OnDump(wxCommandEvent& event);
|
1998-11-26 19:10:01 +00:00
|
|
|
void OnDelete(wxCommandEvent& event);
|
|
|
|
void OnDeleteAll(wxCommandEvent& event);
|
|
|
|
void OnRecreate(wxCommandEvent& event);
|
1998-10-26 17:11:33 +00:00
|
|
|
|
1998-11-30 00:08:57 +00:00
|
|
|
void OnSetBold(wxCommandEvent& event) { DoSetBold(TRUE); }
|
|
|
|
void OnClearBold(wxCommandEvent& event) { DoSetBold(FALSE); }
|
|
|
|
|
1998-10-26 17:11:33 +00:00
|
|
|
private:
|
1998-10-28 21:32:29 +00:00
|
|
|
MyTreeCtrl *m_treeCtrl;
|
1998-05-22 19:57:05 +00:00
|
|
|
|
1998-11-30 00:08:57 +00:00
|
|
|
void DoSetBold(bool bold = TRUE);
|
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
1998-05-22 19:57:05 +00:00
|
|
|
|
1998-10-28 21:32:29 +00:00
|
|
|
// menu and control ids
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TreeTest_Quit,
|
|
|
|
TreeTest_About,
|
1998-11-13 20:47:22 +00:00
|
|
|
TreeTest_Dump,
|
1998-11-30 00:08:57 +00:00
|
|
|
TreeTest_Bold,
|
|
|
|
TreeTest_UnBold,
|
1998-11-26 19:10:01 +00:00
|
|
|
TreeTest_Delete,
|
|
|
|
TreeTest_DeleteAll,
|
|
|
|
TreeTest_Recreate,
|
1998-10-28 21:32:29 +00:00
|
|
|
TreeTest_Ctrl = 100
|
|
|
|
};
|
1998-05-22 19:57:05 +00:00
|
|
|
|
1998-10-26 17:11:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TreeCtrlIcon_File,
|
|
|
|
TreeCtrlIcon_Folder
|
|
|
|
};
|