]> git.saurik.com Git - wxWidgets.git/blob - samples/listctrl/listtest.h
made Shift-JIS encoding upper case; made SJIS the canonical name for it (just because...
[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 #if WXWIN_COMPATIBILITY_2_4
52 void OnGetInfo(wxListEvent& event);
53 void OnSetInfo(wxListEvent& event);
54 #endif
55 void OnSelected(wxListEvent& event);
56 void OnDeselected(wxListEvent& event);
57 void OnListKeyDown(wxListEvent& event);
58 void OnActivated(wxListEvent& event);
59 void OnFocused(wxListEvent& event);
60 void OnCacheHint(wxListEvent& event);
61
62 void OnChar(wxKeyEvent& event);
63
64 private:
65 void SetColumnImage(int col, int image);
66
67 void LogEvent(const wxListEvent& event, const wxChar *eventName);
68 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
69
70 virtual wxString OnGetItemText(long item, long column) const;
71 virtual int OnGetItemImage(long item) const;
72 virtual wxListItemAttr *OnGetItemAttr(long item) const;
73
74 wxListItemAttr m_attr;
75
76 DECLARE_NO_COPY_CLASS(MyListCtrl)
77 DECLARE_EVENT_TABLE()
78 };
79
80 // Define a new frame type
81 class MyFrame: public wxFrame
82 {
83 public:
84 MyFrame(const wxChar *title, int x, int y, int w, int h);
85 virtual ~MyFrame();
86
87 void DoSize();
88
89 protected:
90 void OnSize(wxSizeEvent& event);
91
92 void OnQuit(wxCommandEvent& event);
93 void OnAbout(wxCommandEvent& event);
94 void OnListView(wxCommandEvent& event);
95 void OnReportView(wxCommandEvent& event);
96 void OnIconView(wxCommandEvent& event);
97 void OnIconTextView(wxCommandEvent& event);
98 void OnSmallIconView(wxCommandEvent& event);
99 void OnSmallIconTextView(wxCommandEvent& event);
100 void OnVirtualView(wxCommandEvent& event);
101 void OnSmallVirtualView(wxCommandEvent& event);
102
103 void OnFocusLast(wxCommandEvent& event);
104 void OnToggleFirstSel(wxCommandEvent& event);
105 void OnDeselectAll(wxCommandEvent& event);
106 void OnSelectAll(wxCommandEvent& event);
107 void OnAdd(wxCommandEvent& event);
108 void OnEdit(wxCommandEvent& event);
109 void OnDelete(wxCommandEvent& event);
110 void OnDeleteAll(wxCommandEvent& event);
111 void OnSort(wxCommandEvent& event);
112 void OnSetFgColour(wxCommandEvent& event);
113 void OnSetBgColour(wxCommandEvent& event);
114 void OnToggleMultiSel(wxCommandEvent& event);
115 void OnShowColInfo(wxCommandEvent& event);
116 void OnShowSelInfo(wxCommandEvent& event);
117 void OnFreeze(wxCommandEvent& event);
118 void OnThaw(wxCommandEvent& event);
119 void OnToggleLines(wxCommandEvent& event);
120
121 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
122 void OnUpdateToggleMultiSel(wxUpdateUIEvent& event);
123
124 wxImageList *m_imageListNormal;
125 wxImageList *m_imageListSmall;
126
127 wxPanel *m_panel;
128 MyListCtrl *m_listCtrl;
129 wxTextCtrl *m_logWindow;
130
131 private:
132 // recreate the list control with the new flags
133 void RecreateList(long flags, bool withText = true);
134
135 // fill the control with items depending on the view
136 void InitWithListItems();
137 void InitWithReportItems();
138 void InitWithIconItems(bool withText, bool sameIcon = false);
139 void InitWithVirtualItems();
140
141 // return true if the control is not in virtual view, give an error message
142 // and return false if it is
143 bool CheckNonVirtual() const;
144
145
146 wxLog *m_logOld;
147
148 bool m_smallVirtual;
149
150 DECLARE_NO_COPY_CLASS(MyFrame)
151 DECLARE_EVENT_TABLE()
152 };
153
154
155 // IDs for the menu commands
156 enum
157 {
158 LIST_ABOUT = wxID_ABOUT,
159 LIST_QUIT = wxID_EXIT,
160
161 LIST_LIST_VIEW = wxID_HIGHEST,
162 LIST_ICON_VIEW,
163 LIST_ICON_TEXT_VIEW,
164 LIST_SMALL_ICON_VIEW,
165 LIST_SMALL_ICON_TEXT_VIEW,
166 LIST_REPORT_VIEW,
167 LIST_VIRTUAL_VIEW,
168 LIST_SMALL_VIRTUAL_VIEW,
169
170 LIST_DESELECT_ALL,
171 LIST_SELECT_ALL,
172 LIST_DELETE_ALL,
173 LIST_DELETE,
174 LIST_ADD,
175 LIST_EDIT,
176 LIST_SORT,
177 LIST_SET_FG_COL,
178 LIST_SET_BG_COL,
179 LIST_TOGGLE_MULTI_SEL,
180 LIST_TOGGLE_FIRST,
181 LIST_SHOW_COL_INFO,
182 LIST_SHOW_SEL_INFO,
183 LIST_FOCUS_LAST,
184 LIST_FREEZE,
185 LIST_THAW,
186 LIST_TOGGLE_LINES,
187
188 LIST_CTRL = 1000
189 };
190