added test for EditLabel, Unicode fixes
[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(*wxBLUE, *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 OnFocused(wxListEvent& event);
53 void OnCacheHint(wxListEvent& event);
54
55 void OnChar(wxKeyEvent& event);
56
57 private:
58 void SetColumnImage(int col, int image);
59
60 void LogEvent(const wxListEvent& event, const wxChar *eventName);
61
62 virtual wxString OnGetItemText(long item, long column) const;
63 virtual int OnGetItemImage(long item) const;
64 virtual wxListItemAttr *OnGetItemAttr(long item) const;
65
66 wxListItemAttr m_attr;
67
68 DECLARE_EVENT_TABLE()
69 };
70
71 // Define a new frame type
72 class MyFrame: public wxFrame
73 {
74 public:
75 MyListCtrl *m_listCtrl;
76 wxTextCtrl *m_logWindow;
77
78 MyFrame(const wxChar *title, int x, int y, int w, int h);
79 ~MyFrame();
80
81 public:
82 void OnSize(wxSizeEvent& event);
83
84 void OnQuit(wxCommandEvent& event);
85 void OnAbout(wxCommandEvent& event);
86 void OnListView(wxCommandEvent& event);
87 void OnReportView(wxCommandEvent& event);
88 void OnIconView(wxCommandEvent& event);
89 void OnIconTextView(wxCommandEvent& event);
90 void OnSmallIconView(wxCommandEvent& event);
91 void OnSmallIconTextView(wxCommandEvent& event);
92 void OnVirtualView(wxCommandEvent& event);
93
94 void OnFocusLast(wxCommandEvent& event);
95 void OnToggleFirstSel(wxCommandEvent& event);
96 void OnDeselectAll(wxCommandEvent& event);
97 void OnSelectAll(wxCommandEvent& event);
98 void OnAdd(wxCommandEvent& event);
99 void OnEdit(wxCommandEvent& event);
100 void OnDelete(wxCommandEvent& event);
101 void OnDeleteAll(wxCommandEvent& event);
102 void OnSort(wxCommandEvent& event);
103 void OnSetFgColour(wxCommandEvent& event);
104 void OnSetBgColour(wxCommandEvent& event);
105 void OnToggleMultiSel(wxCommandEvent& event);
106 void OnShowColInfo(wxCommandEvent& event);
107 void OnShowSelInfo(wxCommandEvent& event);
108 void OnFreeze(wxCommandEvent& event);
109 void OnThaw(wxCommandEvent& event);
110
111 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
112
113 wxImageList *m_imageListNormal;
114 wxImageList *m_imageListSmall;
115
116 private:
117 // recreate the list control with the new flags
118 void RecreateList(long flags, bool withText = TRUE);
119
120 // fill the control with items depending on the view
121 void InitWithListItems();
122 void InitWithReportItems();
123 void InitWithIconItems(bool withText, bool sameIcon = FALSE);
124 void InitWithVirtualItems();
125
126 wxLog *m_logOld;
127
128 DECLARE_EVENT_TABLE()
129 };
130
131
132 // IDs for the menu commands
133 enum
134 {
135 LIST_ABOUT,
136 LIST_QUIT,
137
138 LIST_LIST_VIEW,
139 LIST_ICON_VIEW,
140 LIST_ICON_TEXT_VIEW,
141 LIST_SMALL_ICON_VIEW,
142 LIST_SMALL_ICON_TEXT_VIEW,
143 LIST_REPORT_VIEW,
144 LIST_VIRTUAL_VIEW,
145
146 LIST_DESELECT_ALL,
147 LIST_SELECT_ALL,
148 LIST_DELETE_ALL,
149 LIST_DELETE,
150 LIST_ADD,
151 LIST_EDIT,
152 LIST_SORT,
153 LIST_SET_FG_COL,
154 LIST_SET_BG_COL,
155 LIST_TOGGLE_MULTI_SEL,
156 LIST_TOGGLE_FIRST,
157 LIST_SHOW_COL_INFO,
158 LIST_SHOW_SEL_INFO,
159 LIST_FOCUS_LAST,
160 LIST_FREEZE,
161 LIST_THAW,
162
163 LIST_CTRL = 1000
164 };
165