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