]>
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" | |
ee7ee469 | 23 | #include "wx/textctrl.h" |
c801d85f KB |
24 | #include "wx/dcclient.h" |
25 | #include "wx/scrolwin.h" | |
26 | #include "wx/settings.h" | |
27 | ||
1e6d9499 JS |
28 | #if wxUSE_DRAG_AND_DROP |
29 | class WXDLLEXPORT wxDropTarget; | |
30 | #endif | |
31 | ||
c801d85f KB |
32 | //----------------------------------------------------------------------------- |
33 | // classes | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
1e6d9499 JS |
36 | class WXDLLEXPORT wxListItem; |
37 | class WXDLLEXPORT wxListEvent; | |
38 | class WXDLLEXPORT wxListCtrl; | |
c801d85f KB |
39 | |
40 | //----------------------------------------------------------------------------- | |
41 | // internal classes | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
1e6d9499 JS |
44 | class WXDLLEXPORT wxListHeaderData; |
45 | class WXDLLEXPORT wxListItemData; | |
46 | class WXDLLEXPORT wxListLineData; | |
c801d85f | 47 | |
1e6d9499 JS |
48 | class WXDLLEXPORT wxListHeaderWindow; |
49 | class WXDLLEXPORT wxListMainWindow; | |
c801d85f | 50 | |
1e6d9499 | 51 | class WXDLLEXPORT wxListRenameTimer; |
e179bd65 | 52 | class WXDLLEXPORT wxListTextCtrl; |
c801d85f | 53 | |
c801d85f KB |
54 | //----------------------------------------------------------------------------- |
55 | // wxListCtrl | |
56 | //----------------------------------------------------------------------------- | |
57 | ||
1e6d9499 | 58 | class WXDLLEXPORT wxListCtrl: public wxControl |
c801d85f | 59 | { |
b16088bf | 60 | public: |
e179bd65 | 61 | wxListCtrl(); |
674ac8b9 VZ |
62 | wxListCtrl( wxWindow *parent, |
63 | wxWindowID id = -1, | |
64 | const wxPoint &pos = wxDefaultPosition, | |
65 | const wxSize &size = wxDefaultSize, | |
66 | long style = wxLC_ICON, | |
67 | const wxValidator& validator = wxDefaultValidator, | |
68 | const wxString &name = "listctrl" ) | |
32e9da8b | 69 | { |
b16088bf | 70 | Create(parent, id, pos, size, style, validator, name); |
32e9da8b | 71 | } |
e179bd65 | 72 | ~wxListCtrl(); |
29149a64 | 73 | |
674ac8b9 VZ |
74 | bool Create( wxWindow *parent, |
75 | wxWindowID id = -1, | |
76 | const wxPoint &pos = wxDefaultPosition, | |
77 | const wxSize &size = wxDefaultSize, | |
78 | long style = wxLC_ICON, | |
79 | const wxValidator& validator = wxDefaultValidator, | |
80 | const wxString &name = "listctrl" ); | |
b16088bf | 81 | |
e487524e | 82 | bool GetColumn( int col, wxListItem& item ) const; |
debe6624 | 83 | bool SetColumn( int col, wxListItem& item ); |
e487524e | 84 | int GetColumnWidth( int col ) const; |
debe6624 | 85 | bool SetColumnWidth( int col, int width); |
e179bd65 | 86 | int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think |
b16088bf | 87 | |
e487524e | 88 | bool GetItem( wxListItem& info ) const; |
c801d85f | 89 | bool SetItem( wxListItem& info ) ; |
debe6624 | 90 | long SetItem( long index, int col, const wxString& label, int imageId = -1 ); |
e487524e | 91 | int GetItemState( long item, long stateMask ) const; |
debe6624 JS |
92 | bool SetItemState( long item, long state, long stateMask); |
93 | bool SetItemImage( long item, int image, int selImage); | |
e487524e | 94 | wxString GetItemText( long item ) const; |
debe6624 | 95 | void SetItemText( long item, const wxString& str ); |
e487524e | 96 | long GetItemData( long item ) const; |
debe6624 | 97 | bool SetItemData( long item, long data ); |
0a240683 | 98 | bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const; |
e487524e | 99 | bool GetItemPosition( long item, wxPoint& pos ) const; |
debe6624 | 100 | bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC |
e179bd65 RR |
101 | int GetItemCount() const; |
102 | int GetColumnCount() const; | |
33d0b396 | 103 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); |
e487524e | 104 | int GetItemSpacing( bool isSmall ) const; |
e179bd65 | 105 | int GetSelectedItemCount() const; |
0530737d VZ |
106 | wxColour GetTextColour() const; |
107 | void SetTextColour(const wxColour& col); | |
e179bd65 | 108 | long GetTopItem() const; |
b16088bf | 109 | |
debe6624 | 110 | void SetSingleStyle( long style, bool add = TRUE ) ; |
e179bd65 RR |
111 | void SetWindowStyleFlag( long style ); |
112 | void RecreateWindow() {} | |
113 | long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const; | |
114 | wxImageList *GetImageList( int which ) const; | |
115 | void SetImageList( wxImageList *imageList, int which ); | |
2e12c11a | 116 | void AssignImageList( wxImageList *imageList, int which ); |
debe6624 | 117 | bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC |
57c4d796 | 118 | |
4f22cf8d | 119 | void ClearAll(); |
debe6624 | 120 | bool DeleteItem( long item ); |
e179bd65 RR |
121 | bool DeleteAllItems(); |
122 | bool DeleteAllColumns(); | |
debe6624 | 123 | bool DeleteColumn( int col ); |
57c4d796 | 124 | |
2c1f73ee VZ |
125 | void SetItemCount(long count); |
126 | ||
e179bd65 RR |
127 | void EditLabel( long item ) { Edit(item); } |
128 | void Edit( long item ); | |
57c4d796 | 129 | |
debe6624 | 130 | bool EnsureVisible( long item ); |
e179bd65 RR |
131 | long FindItem( long start, const wxString& str, bool partial = FALSE ); |
132 | long FindItem( long start, long data ); | |
133 | long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC | |
134 | long HitTest( const wxPoint& point, int& flags); | |
c801d85f | 135 | long InsertItem(wxListItem& info); |
e179bd65 RR |
136 | long InsertItem( long index, const wxString& label ); |
137 | long InsertItem( long index, int imageIndex ); | |
138 | long InsertItem( long index, const wxString& label, int imageIndex ); | |
139 | long InsertColumn( long col, wxListItem& info ); | |
140 | long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, | |
141 | int width = -1 ); | |
142 | bool ScrollList( int dx, int dy ); | |
143 | bool SortItems( wxListCtrlCompare fn, long data ); | |
144 | bool Update( long item ); | |
29149a64 | 145 | |
2c1f73ee VZ |
146 | // returns true if it is a virtual list control |
147 | bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; } | |
148 | ||
77e7a1dc | 149 | void OnIdle( wxIdleEvent &event ); |
b16088bf | 150 | void OnSize( wxSizeEvent &event ); |
57c4d796 | 151 | |
77e7a1dc | 152 | // We have to hand down a few functions |
57c4d796 | 153 | |
f03fc89f VZ |
154 | bool SetBackgroundColour( const wxColour &colour ); |
155 | bool SetForegroundColour( const wxColour &colour ); | |
156 | bool SetFont( const wxFont &font ); | |
57c4d796 | 157 | |
1e6d9499 | 158 | #if wxUSE_DRAG_AND_DROP |
efbb7287 VZ |
159 | void SetDropTarget( wxDropTarget *dropTarget ); |
160 | wxDropTarget *GetDropTarget() const; | |
1e6d9499 JS |
161 | #endif |
162 | ||
efbb7287 VZ |
163 | bool SetCursor( const wxCursor &cursor ); |
164 | wxColour GetBackgroundColour() const; | |
165 | wxColour GetForegroundColour() const; | |
166 | bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
167 | void SetFocus(); | |
c801d85f | 168 | |
b16088bf RR |
169 | // implementation |
170 | // -------------- | |
57c4d796 | 171 | |
a3622daa VZ |
172 | wxImageList *m_imageListNormal; |
173 | wxImageList *m_imageListSmall; | |
c801d85f | 174 | wxImageList *m_imageListState; // what's that ? |
29149a64 | 175 | bool m_ownsImageListNormal, |
2e12c11a VS |
176 | m_ownsImageListSmall, |
177 | m_ownsImageListState; | |
c801d85f KB |
178 | wxListHeaderWindow *m_headerWin; |
179 | wxListMainWindow *m_mainWin; | |
a3622daa | 180 | |
2c1f73ee VZ |
181 | protected: |
182 | // return the text for the given column of the given item | |
183 | virtual wxString OnGetItemText(long item, long column) const; | |
184 | ||
185 | // return the icon for the given item | |
186 | virtual int OnGetItemImage(long item) const; | |
187 | ||
6c02c329 VZ |
188 | // return the attribute for the item (may return NULL if none) |
189 | virtual wxListItemAttr *OnGetItemAttr(long item) const; | |
190 | ||
2c1f73ee | 191 | // it calls our OnGetXXX() functions |
012409e9 | 192 | |
ad08ef44 | 193 | friend class WXDLLEXPORT wxListMainWindow; |
2c1f73ee | 194 | |
b16088bf | 195 | private: |
210a651b | 196 | // Virtual function hiding supression |
6c02c329 | 197 | virtual void Update() { wxWindowBase::Update(); } |
210a651b | 198 | |
cf1dfa6b VZ |
199 | // create the header window |
200 | void CreateHeaderWindow(); | |
201 | ||
b16088bf RR |
202 | DECLARE_EVENT_TABLE() |
203 | DECLARE_DYNAMIC_CLASS(wxListCtrl); | |
c801d85f KB |
204 | }; |
205 | ||
206 | ||
207 | #endif // __LISTCTRLH_G__ |