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