more wxListCtrl fixes: inserting/deleting items now works again (tested in the sample...
[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, const wxWindowID id, const wxPoint& pos,
23 const wxSize& size, long style):
24 wxListCtrl(parent, id, pos, size, style)
25 {
26 }
27
28 // add one item to the listctrl in report mode
29 void InsertItemInReportView(int i);
30
31 void OnColClick(wxListEvent& event);
32 void OnBeginDrag(wxListEvent& event);
33 void OnBeginRDrag(wxListEvent& event);
34 void OnBeginLabelEdit(wxListEvent& event);
35 void OnEndLabelEdit(wxListEvent& event);
36 void OnDeleteItem(wxListEvent& event);
37 void OnDeleteAllItems(wxListEvent& event);
38 void OnGetInfo(wxListEvent& event);
39 void OnSetInfo(wxListEvent& event);
40 void OnSelected(wxListEvent& event);
41 void OnDeselected(wxListEvent& event);
42 void OnListKeyDown(wxListEvent& event);
43 void OnActivated(wxListEvent& event);
44
45 void OnChar(wxKeyEvent& event);
46
47 private:
48 void LogEvent(const wxListEvent& event, const wxChar *eventName);
49
50 virtual wxString OnGetItemText(long item, long column) const;
51 virtual int OnGetItemImage(long item) const;
52
53 DECLARE_EVENT_TABLE()
54 };
55
56 // Define a new frame type
57 class MyFrame: public wxFrame
58 {
59 public:
60 MyListCtrl *m_listCtrl;
61 wxTextCtrl *m_logWindow;
62
63 MyFrame(const wxChar *title, int x, int y, int w, int h);
64 ~MyFrame();
65
66 public:
67 void OnSize(wxSizeEvent& event);
68
69 void OnQuit(wxCommandEvent& event);
70 void OnAbout(wxCommandEvent& event);
71 void OnListView(wxCommandEvent& event);
72 void OnReportView(wxCommandEvent& event);
73 void OnIconView(wxCommandEvent& event);
74 void OnIconTextView(wxCommandEvent& event);
75 void OnSmallIconView(wxCommandEvent& event);
76 void OnSmallIconTextView(wxCommandEvent& event);
77 void OnVirtualView(wxCommandEvent& event);
78
79 void OnToggleFirstSel(wxCommandEvent& event);
80 void OnDeselectAll(wxCommandEvent& event);
81 void OnSelectAll(wxCommandEvent& event);
82 void OnAdd(wxCommandEvent& event);
83 void OnDelete(wxCommandEvent& event);
84 void OnDeleteAll(wxCommandEvent& event);
85 void OnSort(wxCommandEvent& event);
86 void OnSetFgColour(wxCommandEvent& event);
87 void OnSetBgColour(wxCommandEvent& event);
88 void OnToggleMultiSel(wxCommandEvent& event);
89 void OnShowColInfo(wxCommandEvent& event);
90 void OnShowSelInfo(wxCommandEvent& event);
91
92 void OnUpdateShowColInfo(wxUpdateUIEvent& event);
93
94 wxImageList *m_imageListNormal;
95 wxImageList *m_imageListSmall;
96
97 private:
98 // recreate the list control with the new flags
99 void RecreateList(long flags, bool withText = TRUE);
100
101 // fill the control with items depending on the view
102 void InitWithListItems();
103 void InitWithReportItems();
104 void InitWithIconItems(bool withText, bool sameIcon = FALSE);
105 void InitWithVirtualItems();
106
107 wxLog *m_logOld;
108
109 DECLARE_EVENT_TABLE()
110 };
111
112
113 // IDs for the menu commands
114 enum
115 {
116 LIST_ABOUT,
117 LIST_QUIT,
118
119 LIST_LIST_VIEW,
120 LIST_ICON_VIEW,
121 LIST_ICON_TEXT_VIEW,
122 LIST_SMALL_ICON_VIEW,
123 LIST_SMALL_ICON_TEXT_VIEW,
124 LIST_REPORT_VIEW,
125 LIST_VIRTUAL_VIEW,
126
127 LIST_DESELECT_ALL,
128 LIST_SELECT_ALL,
129 LIST_DELETE_ALL,
130 LIST_DELETE,
131 LIST_ADD,
132 LIST_SORT,
133 LIST_SET_FG_COL,
134 LIST_SET_BG_COL,
135 LIST_TOGGLE_MULTI_SEL,
136 LIST_TOGGLE_FIRST,
137 LIST_SHOW_COL_INFO,
138 LIST_SHOW_SEL_INFO,
139
140 LIST_CTRL = 1000
141 };
142