1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/listctrl.h
3 // Purpose: Generic list control
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __LISTCTRLH_G__
12 #define __LISTCTRLH_G__
14 #if defined(__GNUG__) && !defined(__APPLE__)
15 #pragma interface "listctrl.h"
19 #include "wx/object.h"
20 #include "wx/generic/imaglist.h"
22 #include "wx/control.h"
24 #include "wx/dcclient.h"
25 #include "wx/scrolwin.h"
26 #include "wx/settings.h"
27 #include "wx/listbase.h"
29 #if wxUSE_DRAG_AND_DROP
30 class WXDLLEXPORT wxDropTarget
;
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 class WXDLLEXPORT wxListItem
;
38 class WXDLLEXPORT wxListEvent
;
40 #if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
41 class WXDLLEXPORT wxListCtrl
;
42 #define wxImageListType wxImageList
44 #define wxImageListType wxGenericImageList
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 class WXDLLEXPORT wxListHeaderData
;
52 class WXDLLEXPORT wxListItemData
;
53 class WXDLLEXPORT wxListLineData
;
55 class WXDLLEXPORT wxListHeaderWindow
;
56 class WXDLLEXPORT wxListMainWindow
;
58 class WXDLLEXPORT wxListRenameTimer
;
59 class WXDLLEXPORT wxListTextCtrl
;
61 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
65 class WXDLLEXPORT wxGenericListCtrl
: public wxControl
69 wxGenericListCtrl( wxWindow
*parent
,
71 const wxPoint
&pos
= wxDefaultPosition
,
72 const wxSize
&size
= wxDefaultSize
,
73 long style
= wxLC_ICON
,
74 const wxValidator
& validator
= wxDefaultValidator
,
75 const wxString
&name
= "listctrl" )
77 Create(parent
, id
, pos
, size
, style
, validator
, name
);
81 bool Create( wxWindow
*parent
,
83 const wxPoint
&pos
= wxDefaultPosition
,
84 const wxSize
&size
= wxDefaultSize
,
85 long style
= wxLC_ICON
,
86 const wxValidator
& validator
= wxDefaultValidator
,
87 const wxString
&name
= "listctrl" );
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
95 bool GetItem( wxListItem
& info
) const;
96 bool SetItem( wxListItem
& info
) ;
97 long SetItem( long index
, int col
, const wxString
& label
, int imageId
= -1 );
98 int GetItemState( long item
, long stateMask
) const;
99 bool SetItemState( long item
, long state
, long stateMask
);
100 bool SetItemImage( long item
, int image
, int selImage
);
101 wxString
GetItemText( long item
) const;
102 void SetItemText( long item
, const wxString
& str
);
103 long GetItemData( long item
) const;
104 bool SetItemData( long item
, long data
);
105 bool GetItemRect( long item
, wxRect
& rect
, int code
= wxLIST_RECT_BOUNDS
) const;
106 bool GetItemPosition( long item
, wxPoint
& pos
) const;
107 bool SetItemPosition( long item
, const wxPoint
& pos
); // not supported in wxGLC
108 int GetItemCount() const;
109 int GetColumnCount() const;
110 void SetItemSpacing( int spacing
, bool isSmall
= FALSE
);
111 int GetItemSpacing( bool isSmall
) const;
112 void SetItemTextColour( long item
, const wxColour
& col
);
113 wxColour
GetItemTextColour( long item
) const;
114 void SetItemBackgroundColour( long item
, const wxColour
&col
);
115 wxColour
GetItemBackgroundColour( long item
) const;
116 int GetSelectedItemCount() const;
117 wxColour
GetTextColour() const;
118 void SetTextColour(const wxColour
& col
);
119 long GetTopItem() const;
121 void SetSingleStyle( long style
, bool add
= TRUE
) ;
122 void SetWindowStyleFlag( long style
);
123 void RecreateWindow() {}
124 long GetNextItem( long item
, int geometry
= wxLIST_NEXT_ALL
, int state
= wxLIST_STATE_DONTCARE
) const;
125 wxImageListType
*GetImageList( int which
) const;
126 void SetImageList( wxImageListType
*imageList
, int which
);
127 void AssignImageList( wxImageListType
*imageList
, int which
);
128 bool Arrange( int flag
= wxLIST_ALIGN_DEFAULT
); // always wxLIST_ALIGN_LEFT in wxGLC
131 bool DeleteItem( long item
);
132 bool DeleteAllItems();
133 bool DeleteAllColumns();
134 bool DeleteColumn( int col
);
136 void SetItemCount(long count
);
138 void EditLabel( long item
) { Edit(item
); }
139 void Edit( long item
);
141 bool EnsureVisible( long item
);
142 long FindItem( long start
, const wxString
& str
, bool partial
= FALSE
);
143 long FindItem( long start
, long data
);
144 long FindItem( long start
, const wxPoint
& pt
, int direction
); // not supported in wxGLC
145 long HitTest( const wxPoint
& point
, int& flags
);
146 long InsertItem(wxListItem
& info
);
147 long InsertItem( long index
, const wxString
& label
);
148 long InsertItem( long index
, int imageIndex
);
149 long InsertItem( long index
, const wxString
& label
, int imageIndex
);
150 long InsertColumn( long col
, wxListItem
& info
);
151 long InsertColumn( long col
, const wxString
& heading
, int format
= wxLIST_FORMAT_LEFT
,
153 bool ScrollList( int dx
, int dy
);
154 bool SortItems( wxListCtrlCompare fn
, long data
);
155 bool Update( long item
);
157 // returns true if it is a virtual list control
158 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
160 // refresh items selectively (only useful for virtual list controls)
161 void RefreshItem(long item
);
162 void RefreshItems(long itemFrom
, long itemTo
);
164 // implementation only from now on
165 // -------------------------------
167 void OnIdle( wxIdleEvent
&event
);
168 void OnSize( wxSizeEvent
&event
);
170 // We have to hand down a few functions
172 virtual void Freeze();
175 virtual bool SetBackgroundColour( const wxColour
&colour
);
176 virtual bool SetForegroundColour( const wxColour
&colour
);
177 virtual wxColour
GetBackgroundColour() const;
178 virtual wxColour
GetForegroundColour() const;
179 virtual bool SetFont( const wxFont
&font
);
180 virtual bool SetCursor( const wxCursor
&cursor
);
182 #if wxUSE_DRAG_AND_DROP
183 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
184 virtual wxDropTarget
*GetDropTarget() const;
187 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
189 virtual void SetFocus();
194 wxImageListType
*m_imageListNormal
;
195 wxImageListType
*m_imageListSmall
;
196 wxImageListType
*m_imageListState
; // what's that ?
197 bool m_ownsImageListNormal
,
198 m_ownsImageListSmall
,
199 m_ownsImageListState
;
200 wxListHeaderWindow
*m_headerWin
;
201 wxListMainWindow
*m_mainWin
;
204 // return the text for the given column of the given item
205 virtual wxString
OnGetItemText(long item
, long column
) const;
207 // return the icon for the given item
208 virtual int OnGetItemImage(long item
) const;
210 // return the attribute for the item (may return NULL if none)
211 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
213 // it calls our OnGetXXX() functions
214 friend class WXDLLEXPORT wxListMainWindow
;
217 // Virtual function hiding supression
218 virtual void Update() { wxWindow::Update(); }
220 // create the header window
221 void CreateHeaderWindow();
223 // reposition the header and the main window in the report view depending
224 // on whether it should be shown or not
225 void ResizeReportView(bool showHeader
);
227 DECLARE_EVENT_TABLE()
228 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl
);
231 #if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
233 * wxListCtrl has to be a real class or we have problems with
234 * the run-time information.
237 class WXDLLEXPORT wxListCtrl
: public wxGenericListCtrl
239 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
244 wxListCtrl(wxWindow
*parent
, wxWindowID id
= -1,
245 const wxPoint
& pos
= wxDefaultPosition
,
246 const wxSize
& size
= wxDefaultSize
,
247 long style
= wxLC_ICON
,
248 const wxValidator
&validator
= wxDefaultValidator
,
249 const wxString
&name
= "listctrl" )
250 : wxGenericListCtrl(parent
, id
, pos
, size
, style
, validator
, name
)
254 #endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
256 #endif // __LISTCTRLH_G__