]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
bdc72a22 | 2 | // Name: wx/generic/listctrl.h |
c801d85f KB |
3 | // Purpose: Generic list control |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
bdc72a22 | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef __LISTCTRLH_G__ | |
12 | #define __LISTCTRLH_G__ | |
13 | ||
14 | #ifdef __GNUG__ | |
0d3820b3 | 15 | #pragma interface "listctrl.h" |
c801d85f KB |
16 | #endif |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/object.h" | |
b54e41c5 | 20 | #include "wx/imaglist.h" |
c801d85f KB |
21 | #include "wx/control.h" |
22 | #include "wx/timer.h" | |
23 | #include "wx/dcclient.h" | |
24 | #include "wx/scrolwin.h" | |
25 | #include "wx/settings.h" | |
26 | ||
1e6d9499 JS |
27 | #if wxUSE_DRAG_AND_DROP |
28 | class WXDLLEXPORT wxDropTarget; | |
29 | #endif | |
30 | ||
c801d85f KB |
31 | //----------------------------------------------------------------------------- |
32 | // classes | |
33 | //----------------------------------------------------------------------------- | |
34 | ||
1e6d9499 JS |
35 | class WXDLLEXPORT wxListItem; |
36 | class WXDLLEXPORT wxListEvent; | |
37 | class WXDLLEXPORT wxListCtrl; | |
c801d85f KB |
38 | |
39 | //----------------------------------------------------------------------------- | |
40 | // internal classes | |
41 | //----------------------------------------------------------------------------- | |
42 | ||
1e6d9499 JS |
43 | class WXDLLEXPORT wxListHeaderData; |
44 | class WXDLLEXPORT wxListItemData; | |
45 | class WXDLLEXPORT wxListLineData; | |
c801d85f | 46 | |
1e6d9499 JS |
47 | class WXDLLEXPORT wxListHeaderWindow; |
48 | class WXDLLEXPORT wxListMainWindow; | |
c801d85f | 49 | |
1e6d9499 | 50 | class WXDLLEXPORT wxListRenameTimer; |
e179bd65 | 51 | class WXDLLEXPORT wxListTextCtrl; |
c801d85f | 52 | |
c801d85f KB |
53 | //----------------------------------------------------------------------------- |
54 | // wxListCtrl | |
55 | //----------------------------------------------------------------------------- | |
56 | ||
1e6d9499 | 57 | class WXDLLEXPORT wxListCtrl: public wxControl |
c801d85f | 58 | { |
b16088bf | 59 | public: |
e179bd65 | 60 | wxListCtrl(); |
674ac8b9 VZ |
61 | wxListCtrl( wxWindow *parent, |
62 | wxWindowID id = -1, | |
63 | const wxPoint &pos = wxDefaultPosition, | |
64 | const wxSize &size = wxDefaultSize, | |
65 | long style = wxLC_ICON, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
67 | const wxString &name = "listctrl" ) | |
32e9da8b | 68 | { |
b16088bf | 69 | Create(parent, id, pos, size, style, validator, name); |
32e9da8b | 70 | } |
e179bd65 | 71 | ~wxListCtrl(); |
29149a64 | 72 | |
674ac8b9 VZ |
73 | bool Create( wxWindow *parent, |
74 | wxWindowID id = -1, | |
75 | const wxPoint &pos = wxDefaultPosition, | |
76 | const wxSize &size = wxDefaultSize, | |
77 | long style = wxLC_ICON, | |
78 | const wxValidator& validator = wxDefaultValidator, | |
79 | const wxString &name = "listctrl" ); | |
b16088bf | 80 | |
e487524e | 81 | bool GetColumn( int col, wxListItem& item ) const; |
debe6624 | 82 | bool SetColumn( int col, wxListItem& item ); |
e487524e | 83 | int GetColumnWidth( int col ) const; |
debe6624 | 84 | bool SetColumnWidth( int col, int width); |
e179bd65 | 85 | int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think |
b16088bf | 86 | |
e487524e | 87 | bool GetItem( wxListItem& info ) const; |
c801d85f | 88 | bool SetItem( wxListItem& info ) ; |
debe6624 | 89 | long SetItem( long index, int col, const wxString& label, int imageId = -1 ); |
e487524e | 90 | int GetItemState( long item, long stateMask ) const; |
debe6624 JS |
91 | bool SetItemState( long item, long state, long stateMask); |
92 | bool SetItemImage( long item, int image, int selImage); | |
e487524e | 93 | wxString GetItemText( long item ) const; |
debe6624 | 94 | void SetItemText( long item, const wxString& str ); |
e487524e | 95 | long GetItemData( long item ) const; |
debe6624 | 96 | bool SetItemData( long item, long data ); |
0a240683 | 97 | bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const; |
e487524e | 98 | bool GetItemPosition( long item, wxPoint& pos ) const; |
debe6624 | 99 | bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC |
e179bd65 RR |
100 | int GetItemCount() const; |
101 | int GetColumnCount() const; | |
33d0b396 | 102 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); |
e487524e | 103 | int GetItemSpacing( bool isSmall ) const; |
5b98eb2f RL |
104 | void SetItemTextColour( long item, const wxColour& col); |
105 | wxColour GetItemTextColour( long item ) const; | |
106 | void SetItemBackgroundColour( long item, const wxColour &col); | |
107 | wxColour GetItemBackgroundColour( long item ) const; | |
e179bd65 | 108 | int GetSelectedItemCount() const; |
0530737d VZ |
109 | wxColour GetTextColour() const; |
110 | void SetTextColour(const wxColour& col); | |
e179bd65 | 111 | long GetTopItem() const; |
b16088bf | 112 | |
debe6624 | 113 | void SetSingleStyle( long style, bool add = TRUE ) ; |
e179bd65 RR |
114 | void SetWindowStyleFlag( long style ); |
115 | void RecreateWindow() {} | |
116 | long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const; | |
117 | wxImageList *GetImageList( int which ) const; | |
118 | void SetImageList( wxImageList *imageList, int which ); | |
2e12c11a | 119 | void AssignImageList( wxImageList *imageList, int which ); |
debe6624 | 120 | bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC |
57c4d796 | 121 | |
4f22cf8d | 122 | void ClearAll(); |
debe6624 | 123 | bool DeleteItem( long item ); |
e179bd65 RR |
124 | bool DeleteAllItems(); |
125 | bool DeleteAllColumns(); | |
debe6624 | 126 | bool DeleteColumn( int col ); |
57c4d796 | 127 | |
2c1f73ee VZ |
128 | void SetItemCount(long count); |
129 | ||
e179bd65 RR |
130 | void EditLabel( long item ) { Edit(item); } |
131 | void Edit( long item ); | |
57c4d796 | 132 | |
debe6624 | 133 | bool EnsureVisible( long item ); |
e179bd65 RR |
134 | long FindItem( long start, const wxString& str, bool partial = FALSE ); |
135 | long FindItem( long start, long data ); | |
136 | long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC | |
137 | long HitTest( const wxPoint& point, int& flags); | |
c801d85f | 138 | long InsertItem(wxListItem& info); |
e179bd65 RR |
139 | long InsertItem( long index, const wxString& label ); |
140 | long InsertItem( long index, int imageIndex ); | |
141 | long InsertItem( long index, const wxString& label, int imageIndex ); | |
142 | long InsertColumn( long col, wxListItem& info ); | |
143 | long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, | |
144 | int width = -1 ); | |
145 | bool ScrollList( int dx, int dy ); | |
146 | bool SortItems( wxListCtrlCompare fn, long data ); | |
147 | bool Update( long item ); | |
29149a64 | 148 | |
2c1f73ee VZ |
149 | // returns true if it is a virtual list control |
150 | bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; } | |
151 | ||
1a6cb56f VZ |
152 | // refresh items selectively (only useful for virtual list controls) |
153 | void RefreshItem(long item); | |
154 | void RefreshItems(long itemFrom, long itemTo); | |
155 | ||
156 | // implementation only from now on | |
157 | // ------------------------------- | |
158 | ||
77e7a1dc | 159 | void OnIdle( wxIdleEvent &event ); |
b16088bf | 160 | void OnSize( wxSizeEvent &event ); |
57c4d796 | 161 | |
77e7a1dc | 162 | // We have to hand down a few functions |
57c4d796 | 163 | |
c5c528fc VZ |
164 | virtual void Freeze(); |
165 | virtual void Thaw(); | |
166 | ||
167 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
168 | virtual bool SetForegroundColour( const wxColour &colour ); | |
169 | virtual wxColour GetBackgroundColour() const; | |
170 | virtual wxColour GetForegroundColour() const; | |
171 | virtual bool SetFont( const wxFont &font ); | |
172 | virtual bool SetCursor( const wxCursor &cursor ); | |
57c4d796 | 173 | |
1e6d9499 | 174 | #if wxUSE_DRAG_AND_DROP |
c5c528fc VZ |
175 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
176 | virtual wxDropTarget *GetDropTarget() const; | |
1e6d9499 JS |
177 | #endif |
178 | ||
c5c528fc VZ |
179 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); |
180 | ||
181 | virtual void SetFocus(); | |
c801d85f | 182 | |
b16088bf RR |
183 | // implementation |
184 | // -------------- | |
57c4d796 | 185 | |
a3622daa VZ |
186 | wxImageList *m_imageListNormal; |
187 | wxImageList *m_imageListSmall; | |
c801d85f | 188 | wxImageList *m_imageListState; // what's that ? |
29149a64 | 189 | bool m_ownsImageListNormal, |
2e12c11a VS |
190 | m_ownsImageListSmall, |
191 | m_ownsImageListState; | |
c801d85f KB |
192 | wxListHeaderWindow *m_headerWin; |
193 | wxListMainWindow *m_mainWin; | |
a3622daa | 194 | |
2c1f73ee VZ |
195 | protected: |
196 | // return the text for the given column of the given item | |
197 | virtual wxString OnGetItemText(long item, long column) const; | |
198 | ||
199 | // return the icon for the given item | |
200 | virtual int OnGetItemImage(long item) const; | |
201 | ||
6c02c329 VZ |
202 | // return the attribute for the item (may return NULL if none) |
203 | virtual wxListItemAttr *OnGetItemAttr(long item) const; | |
204 | ||
2c1f73ee | 205 | // it calls our OnGetXXX() functions |
ad08ef44 | 206 | friend class WXDLLEXPORT wxListMainWindow; |
2c1f73ee | 207 | |
b16088bf | 208 | private: |
210a651b | 209 | // Virtual function hiding supression |
8ac7c509 | 210 | virtual void Update() { wxWindow::Update(); } |
210a651b | 211 | |
cf1dfa6b VZ |
212 | // create the header window |
213 | void CreateHeaderWindow(); | |
214 | ||
c0f8674c VZ |
215 | // reposition the header and the main window in the report view depending |
216 | // on whether it should be shown or not | |
217 | void ResizeReportView(bool showHeader); | |
218 | ||
b16088bf RR |
219 | DECLARE_EVENT_TABLE() |
220 | DECLARE_DYNAMIC_CLASS(wxListCtrl); | |
c801d85f KB |
221 | }; |
222 | ||
223 | ||
224 | #endif // __LISTCTRLH_G__ | |
5b98eb2f RL |
225 | |
226 | // vi:sts=4:sw=4:et |