1998-05-22 15:57:05 -04: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 16:32:29 -05:00
|
|
|
// Licence: wxWindows license
|
1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Define a new application type
|
1998-10-28 16:32:29 -05:00
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool OnInit();
|
|
|
|
};
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
class MyTreeItemData : public wxTreeItemData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyTreeItemData(const wxString& desc) : m_desc(desc) { }
|
|
|
|
|
|
|
|
void ShowInfo(wxTreeCtrl *tree);
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_desc;
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
class MyTreeCtrl : public wxTreeCtrl
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
|
|
|
public:
|
1998-10-28 16:32:29 -05:00
|
|
|
enum
|
|
|
|
{
|
1998-11-29 19:08:57 -05:00
|
|
|
TreeCtrlIcon_File,
|
|
|
|
TreeCtrlIcon_Folder
|
1998-10-28 16:32:29 -05: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);
|
1998-12-09 13:12:31 -05:00
|
|
|
void OnTreeKeyDown(wxKeyEvent& event);
|
1998-10-28 16:32:29 -05:00
|
|
|
|
1998-11-26 14:10:01 -05:00
|
|
|
void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);
|
|
|
|
|
|
|
|
void AddTestItemsToTree(size_t numChildren,
|
|
|
|
size_t depth);
|
1998-11-13 15:47:22 -05:00
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
private:
|
|
|
|
void AddItemsRecursively(const wxTreeItemId& idParent,
|
|
|
|
size_t nChildren,
|
1998-11-13 15:47:22 -05:00
|
|
|
size_t depth,
|
1998-11-26 14:10:01 -05:00
|
|
|
size_t folder);
|
1998-10-28 16:32:29 -05:00
|
|
|
|
|
|
|
wxImageList *m_imageListNormal;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame type
|
|
|
|
class MyFrame: public wxFrame
|
1998-10-25 12:04:49 -05:00
|
|
|
{
|
|
|
|
public:
|
1998-10-28 16:32:29 -05:00
|
|
|
// ctor and dtor
|
|
|
|
MyFrame(const wxString& title, int x, int y, int w, int h);
|
|
|
|
virtual ~MyFrame();
|
1998-10-26 12:11:33 -05:00
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
// menu callbacks
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
1998-11-13 15:47:22 -05:00
|
|
|
void OnDump(wxCommandEvent& event);
|
1998-11-26 14:10:01 -05:00
|
|
|
void OnDelete(wxCommandEvent& event);
|
|
|
|
void OnDeleteAll(wxCommandEvent& event);
|
|
|
|
void OnRecreate(wxCommandEvent& event);
|
1998-10-26 12:11:33 -05:00
|
|
|
|
1998-12-07 05:38:39 -05:00
|
|
|
void OnSetBold(wxCommandEvent& WXUNUSED(event)) { DoSetBold(TRUE); }
|
|
|
|
void OnClearBold(wxCommandEvent& WXUNUSED(event)) { DoSetBold(FALSE); }
|
1998-11-29 19:08:57 -05:00
|
|
|
|
1998-10-26 12:11:33 -05:00
|
|
|
private:
|
1998-10-28 16:32:29 -05:00
|
|
|
MyTreeCtrl *m_treeCtrl;
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1998-11-29 19:08:57 -05:00
|
|
|
void DoSetBold(bool bold = TRUE);
|
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1998-10-28 16:32:29 -05:00
|
|
|
// menu and control ids
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TreeTest_Quit,
|
|
|
|
TreeTest_About,
|
1998-11-13 15:47:22 -05:00
|
|
|
TreeTest_Dump,
|
1998-11-29 19:08:57 -05:00
|
|
|
TreeTest_Bold,
|
|
|
|
TreeTest_UnBold,
|
1998-11-26 14:10:01 -05:00
|
|
|
TreeTest_Delete,
|
|
|
|
TreeTest_DeleteAll,
|
|
|
|
TreeTest_Recreate,
|
1998-10-28 16:32:29 -05:00
|
|
|
TreeTest_Ctrl = 100
|
|
|
|
};
|
1998-05-22 15:57:05 -04:00
|
|
|
|
1998-10-26 12:11:33 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TreeCtrlIcon_File,
|
|
|
|
TreeCtrlIcon_Folder
|
|
|
|
};
|