added a bunch of new wxListCtrl messages: column right click and
[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 OnColRightClick(wxListEvent& event);
37 void OnColBeginDrag(wxListEvent& event);
38 void OnColDragging(wxListEvent& event);
39 void OnColEndDrag(wxListEvent& event);
40 void OnBeginDrag(wxListEvent& event);
41 void OnBeginRDrag(wxListEvent& event);
42 void OnBeginLabelEdit(wxListEvent& event);
43 void OnEndLabelEdit(wxListEvent& event);
44 void OnDeleteItem(wxListEvent& event);
45 void OnDeleteAllItems(wxListEvent& event);
46 void OnGetInfo(wxListEvent& event);
47 void OnSetInfo(wxListEvent& event);
48 void OnSelected(wxListEvent& event);
49 void OnDeselected(wxListEvent& event);
50 void OnListKeyDown(wxListEvent& event);
51 void OnActivated(wxListEvent& event);
52 void OnCacheHint(wxListEvent& event);
53
54 void OnChar(wxKeyEvent& event);
55
56 private:
57 void LogEvent(const wxListEvent& event, const wxChar *eventName);
58
59 virtual wxString OnGetItemText(long item, long column) const;
60 virtual int OnGetItemImage(long item) const;
61 virtual wxListItemAttr *OnGetItemAttr(long item) const;
62
63 wxListItemAttr m_attr;
64
65 DECLARE_EVENT_TABLE()
66 };
67
68 // Define a new frame type
69 class MyFrame: public wxFrame
70 {
71 public:
72 MyListCtrl *m_listCtrl;
73 wxTextCtrl *m_logWindow;
74
75 MyFrame(const wxChar *title, int x, int y, int w, int h);
76 ~MyFrame();
77
78 public:
79 void OnSize(wxSizeEvent& event);
80
81 void OnQuit(wxCommandEvent& event);
82 void OnAbout(wxCommandEvent& event);
83 void OnListView(wxCommandEvent& event);
84 void OnReportView(wxCommandEvent& event);
85 void OnIconView(wxCommandEvent& event);
86 void OnIconTextView(wxCommandEvent& event);
87 void OnSmallIconView(wxCommandEvent& event);
88 void OnSmallIconTextView(wxCommandEvent& event);
89 void OnVirtualView(wxCommandEvent& event);
90
91 void OnFocusLast(wxCommandEvent& event);
92 void OnToggleFirstSel(wxCommandEvent& event);
93 void OnDeselectAll(wxCommandEvent& event);
94 void OnSelectAll(wxCommandEvent& event);
95 void OnAdd(wxCommandEvent& event);
96 void OnDelete(wxCommandEvent& event);
97 void OnDeleteAll(wxCommandEvent& event);
98 void OnSort(wxCommandEvent& event);
99 void OnSetFgColour(wxCommandEvent& event);
100 void OnSetBgColour(wxCommandEvent& event);
101 void OnToggleMultiSel(wxCommandEvent& event);
102 void OnShowColInfo(wxCommandEvent& event);
103 void OnShowSelInfo(wxCommandEvent& event);
104
105 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
106
107 wxImageList *m_imageListNormal;
108 wxImageList *m_imageListSmall;
109
110 private:
111 // recreate the list control with the new flags
112 void RecreateList(long flags, bool withText = TRUE);
113
114 // fill the control with items depending on the view
115 void InitWithListItems();
116 void InitWithReportItems();
117 void InitWithIconItems(bool withText, bool sameIcon = FALSE);
118 void InitWithVirtualItems();
119
120 wxLog *m_logOld;
121
122 DECLARE_EVENT_TABLE()
123 };
124
125
126 // IDs for the menu commands
127 enum
128 {
129 LIST_ABOUT,
130 LIST_QUIT,
131
132 LIST_LIST_VIEW,
133 LIST_ICON_VIEW,
134 LIST_ICON_TEXT_VIEW,
135 LIST_SMALL_ICON_VIEW,
136 LIST_SMALL_ICON_TEXT_VIEW,
137 LIST_REPORT_VIEW,
138 LIST_VIRTUAL_VIEW,
139
140 LIST_DESELECT_ALL,
141 LIST_SELECT_ALL,
142 LIST_DELETE_ALL,
143 LIST_DELETE,
144 LIST_ADD,
145 LIST_SORT,
146 LIST_SET_FG_COL,
147 LIST_SET_BG_COL,
148 LIST_TOGGLE_MULTI_SEL,
149 LIST_TOGGLE_FIRST,
150 LIST_SHOW_COL_INFO,
151 LIST_SHOW_SEL_INFO,
152 LIST_FOCUS_LAST,
153
154 LIST_CTRL = 1000
155 };
156