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