]> git.saurik.com Git - wxWidgets.git/blob - samples/listctrl/listtest.h
Get the stock label when stock ID is used with empty label in Create()
[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
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // Define a new application type
13 class MyApp: public wxApp
14 {
15 public:
16 MyApp() { }
17
18 virtual bool OnInit();
19
20 private:
21 DECLARE_NO_COPY_CLASS(MyApp)
22 };
23
24 class MyListCtrl: public wxListCtrl
25 {
26 public:
27 MyListCtrl(wxWindow *parent,
28 const wxWindowID id,
29 const wxPoint& pos,
30 const wxSize& size,
31 long style)
32 : wxListCtrl(parent, id, pos, size, style),
33 m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont)
34 {
35 }
36
37 // add one item to the listctrl in report mode
38 void InsertItemInReportView(int i);
39
40 void OnColClick(wxListEvent& event);
41 void OnColRightClick(wxListEvent& event);
42 void OnColBeginDrag(wxListEvent& event);
43 void OnColDragging(wxListEvent& event);
44 void OnColEndDrag(wxListEvent& event);
45 void OnBeginDrag(wxListEvent& event);
46 void OnBeginRDrag(wxListEvent& event);
47 void OnBeginLabelEdit(wxListEvent& event);
48 void OnEndLabelEdit(wxListEvent& event);
49 void OnDeleteItem(wxListEvent& event);
50 void OnDeleteAllItems(wxListEvent& event);
51 void OnGetInfo(wxListEvent& event);
52 void OnSetInfo(wxListEvent& event);
53 void OnSelected(wxListEvent& event);
54 void OnDeselected(wxListEvent& event);
55 void OnListKeyDown(wxListEvent& event);
56 void OnActivated(wxListEvent& event);
57 void OnFocused(wxListEvent& event);
58 void OnCacheHint(wxListEvent& event);
59
60 void OnChar(wxKeyEvent& event);
61
62 private:
63 void SetColumnImage(int col, int image);
64
65 void LogEvent(const wxListEvent& event, const wxChar *eventName);
66 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
67
68 virtual wxString OnGetItemText(long item, long column) const;
69 virtual int OnGetItemImage(long item) const;
70 virtual wxListItemAttr *OnGetItemAttr(long item) const;
71
72 wxListItemAttr m_attr;
73
74 DECLARE_NO_COPY_CLASS(MyListCtrl)
75 DECLARE_EVENT_TABLE()
76 };
77
78 // Define a new frame type
79 class MyFrame: public wxFrame
80 {
81 public:
82 MyFrame(const wxChar *title, int x, int y, int w, int h);
83 virtual ~MyFrame();
84
85 void DoSize();
86
87 protected:
88 void OnSize(wxSizeEvent& event);
89
90 void OnQuit(wxCommandEvent& event);
91 void OnAbout(wxCommandEvent& event);
92 void OnListView(wxCommandEvent& event);
93 void OnReportView(wxCommandEvent& event);
94 void OnIconView(wxCommandEvent& event);
95 void OnIconTextView(wxCommandEvent& event);
96 void OnSmallIconView(wxCommandEvent& event);
97 void OnSmallIconTextView(wxCommandEvent& event);
98 void OnVirtualView(wxCommandEvent& event);
99
100 void OnFocusLast(wxCommandEvent& event);
101 void OnToggleFirstSel(wxCommandEvent& event);
102 void OnDeselectAll(wxCommandEvent& event);
103 void OnSelectAll(wxCommandEvent& event);
104 void OnAdd(wxCommandEvent& event);
105 void OnEdit(wxCommandEvent& event);
106 void OnDelete(wxCommandEvent& event);
107 void OnDeleteAll(wxCommandEvent& event);
108 void OnSort(wxCommandEvent& event);
109 void OnSetFgColour(wxCommandEvent& event);
110 void OnSetBgColour(wxCommandEvent& event);
111 void OnToggleMultiSel(wxCommandEvent& event);
112 void OnShowColInfo(wxCommandEvent& event);
113 void OnShowSelInfo(wxCommandEvent& event);
114 void OnFreeze(wxCommandEvent& event);
115 void OnThaw(wxCommandEvent& event);
116 void OnToggleLines(wxCommandEvent& event);
117
118 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
119 void OnUpdateToggleMultiSel(wxUpdateUIEvent& event);
120
121 wxImageList *m_imageListNormal;
122 wxImageList *m_imageListSmall;
123
124 wxPanel *m_panel;
125 MyListCtrl *m_listCtrl;
126 wxTextCtrl *m_logWindow;
127
128 private:
129 // recreate the list control with the new flags
130 void RecreateList(long flags, bool withText = true);
131
132 // fill the control with items depending on the view
133 void InitWithListItems();
134 void InitWithReportItems();
135 void InitWithIconItems(bool withText, bool sameIcon = false);
136 void InitWithVirtualItems();
137
138 // return true if the control is not in virtual view, give an error message
139 // and return false if it is
140 bool CheckNonVirtual() const;
141
142
143 wxLog *m_logOld;
144
145 DECLARE_NO_COPY_CLASS(MyFrame)
146 DECLARE_EVENT_TABLE()
147 };
148
149
150 // IDs for the menu commands
151 enum
152 {
153 LIST_ABOUT,
154 LIST_QUIT,
155
156 LIST_LIST_VIEW,
157 LIST_ICON_VIEW,
158 LIST_ICON_TEXT_VIEW,
159 LIST_SMALL_ICON_VIEW,
160 LIST_SMALL_ICON_TEXT_VIEW,
161 LIST_REPORT_VIEW,
162 LIST_VIRTUAL_VIEW,
163
164 LIST_DESELECT_ALL,
165 LIST_SELECT_ALL,
166 LIST_DELETE_ALL,
167 LIST_DELETE,
168 LIST_ADD,
169 LIST_EDIT,
170 LIST_SORT,
171 LIST_SET_FG_COL,
172 LIST_SET_BG_COL,
173 LIST_TOGGLE_MULTI_SEL,
174 LIST_TOGGLE_FIRST,
175 LIST_SHOW_COL_INFO,
176 LIST_SHOW_SEL_INFO,
177 LIST_FOCUS_LAST,
178 LIST_FREEZE,
179 LIST_THAW,
180 LIST_TOGGLE_LINES,
181
182 LIST_CTRL = 1000
183 };
184