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