added support for item attributes in virtual list control
[wxWidgets.git] / samples / listctrl / listtest.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: listctrl.h
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // Define a new application type
13 class MyApp: public wxApp
14 {
15 public:
16 virtual bool OnInit();
17 };
18
19 class MyListCtrl: public wxListCtrl
20 {
21 public:
22 MyListCtrl(wxWindow *parent,
23 const wxWindowID id,
24 const wxPoint& pos,
25 const wxSize& size,
26 long style)
27 : wxListCtrl(parent, id, pos, size, style),
28 m_attr(*wxCYAN, *wxLIGHT_GREY, wxNullFont)
29 {
30 }
31
32 // add one item to the listctrl in report mode
33 void InsertItemInReportView(int i);
34
35 void OnColClick(wxListEvent& event);
36 void OnBeginDrag(wxListEvent& event);
37 void OnBeginRDrag(wxListEvent& event);
38 void OnBeginLabelEdit(wxListEvent& event);
39 void OnEndLabelEdit(wxListEvent& event);
40 void OnDeleteItem(wxListEvent& event);
41 void OnDeleteAllItems(wxListEvent& event);
42 void OnGetInfo(wxListEvent& event);
43 void OnSetInfo(wxListEvent& event);
44 void OnSelected(wxListEvent& event);
45 void OnDeselected(wxListEvent& event);
46 void OnListKeyDown(wxListEvent& event);
47 void OnActivated(wxListEvent& event);
48
49 void OnChar(wxKeyEvent& event);
50
51 private:
52 void LogEvent(const wxListEvent& event, const wxChar *eventName);
53
54 virtual wxString OnGetItemText(long item, long column) const;
55 virtual int OnGetItemImage(long item) const;
56 virtual wxListItemAttr *OnGetItemAttr(long item) const;
57
58 wxListItemAttr m_attr;
59
60 DECLARE_EVENT_TABLE()
61 };
62
63 // Define a new frame type
64 class MyFrame: public wxFrame
65 {
66 public:
67 MyListCtrl *m_listCtrl;
68 wxTextCtrl *m_logWindow;
69
70 MyFrame(const wxChar *title, int x, int y, int w, int h);
71 ~MyFrame();
72
73 public:
74 void OnSize(wxSizeEvent& event);
75
76 void OnQuit(wxCommandEvent& event);
77 void OnAbout(wxCommandEvent& event);
78 void OnListView(wxCommandEvent& event);
79 void OnReportView(wxCommandEvent& event);
80 void OnIconView(wxCommandEvent& event);
81 void OnIconTextView(wxCommandEvent& event);
82 void OnSmallIconView(wxCommandEvent& event);
83 void OnSmallIconTextView(wxCommandEvent& event);
84 void OnVirtualView(wxCommandEvent& event);
85
86 void OnToggleFirstSel(wxCommandEvent& event);
87 void OnDeselectAll(wxCommandEvent& event);
88 void OnSelectAll(wxCommandEvent& event);
89 void OnAdd(wxCommandEvent& event);
90 void OnDelete(wxCommandEvent& event);
91 void OnDeleteAll(wxCommandEvent& event);
92 void OnSort(wxCommandEvent& event);
93 void OnSetFgColour(wxCommandEvent& event);
94 void OnSetBgColour(wxCommandEvent& event);
95 void OnToggleMultiSel(wxCommandEvent& event);
96 void OnShowColInfo(wxCommandEvent& event);
97 void OnShowSelInfo(wxCommandEvent& event);
98
99 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
100
101 wxImageList *m_imageListNormal;
102 wxImageList *m_imageListSmall;
103
104 private:
105 // recreate the list control with the new flags
106 void RecreateList(long flags, bool withText = TRUE);
107
108 // fill the control with items depending on the view
109 void InitWithListItems();
110 void InitWithReportItems();
111 void InitWithIconItems(bool withText, bool sameIcon = FALSE);
112 void InitWithVirtualItems();
113
114 wxLog *m_logOld;
115
116 DECLARE_EVENT_TABLE()
117 };
118
119
120 // IDs for the menu commands
121 enum
122 {
123 LIST_ABOUT,
124 LIST_QUIT,
125
126 LIST_LIST_VIEW,
127 LIST_ICON_VIEW,
128 LIST_ICON_TEXT_VIEW,
129 LIST_SMALL_ICON_VIEW,
130 LIST_SMALL_ICON_TEXT_VIEW,
131 LIST_REPORT_VIEW,
132 LIST_VIRTUAL_VIEW,
133
134 LIST_DESELECT_ALL,
135 LIST_SELECT_ALL,
136 LIST_DELETE_ALL,
137 LIST_DELETE,
138 LIST_ADD,
139 LIST_SORT,
140 LIST_SET_FG_COL,
141 LIST_SET_BG_COL,
142 LIST_TOGGLE_MULTI_SEL,
143 LIST_TOGGLE_FIRST,
144 LIST_SHOW_COL_INFO,
145 LIST_SHOW_SEL_INFO,
146
147 LIST_CTRL = 1000
148 };
149