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__
15 #pragma interface "listctrl.h"
19 #include "wx/object.h"
20 #if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
21 #include "wx/generic/imaglist.h"
23 #include "wx/imaglist.h"
26 #include "wx/control.h"
28 #include "wx/dcclient.h"
29 #include "wx/scrolwin.h"
30 #include "wx/settings.h"
32 #if wxUSE_DRAG_AND_DROP
33 class WXDLLEXPORT wxDropTarget
;
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 class WXDLLEXPORT wxListItem
;
41 class WXDLLEXPORT wxListEvent
;
42 class WXDLLEXPORT wxListCtrl
;
44 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
48 class WXDLLEXPORT wxListHeaderData
;
49 class WXDLLEXPORT wxListItemData
;
50 class WXDLLEXPORT wxListLineData
;
52 class WXDLLEXPORT wxListHeaderWindow
;
53 class WXDLLEXPORT wxListMainWindow
;
55 class WXDLLEXPORT wxListRenameTimer
;
56 class WXDLLEXPORT wxListTextCtrl
;
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 class WXDLLEXPORT wxGenericListCtrl
: public wxControl
66 wxGenericListCtrl( wxWindow
*parent
,
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" )
74 Create(parent
, id
, pos
, size
, style
, validator
, name
);
78 bool Create( wxWindow
*parent
,
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" );
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
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;
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
128 bool DeleteItem( long item
);
129 bool DeleteAllItems();
130 bool DeleteAllColumns();
131 bool DeleteColumn( int col
);
133 void SetItemCount(long count
);
135 void EditLabel( long item
) { Edit(item
); }
136 void Edit( long item
);
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
,
150 bool ScrollList( int dx
, int dy
);
151 bool SortItems( wxListCtrlCompare fn
, long data
);
152 bool Update( long item
);
154 // returns true if it is a virtual list control
155 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
157 // refresh items selectively (only useful for virtual list controls)
158 void RefreshItem(long item
);
159 void RefreshItems(long itemFrom
, long itemTo
);
161 // implementation only from now on
162 // -------------------------------
164 void OnIdle( wxIdleEvent
&event
);
165 void OnSize( wxSizeEvent
&event
);
167 // We have to hand down a few functions
169 virtual void Freeze();
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
);
179 #if wxUSE_DRAG_AND_DROP
180 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
181 virtual wxDropTarget
*GetDropTarget() const;
184 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
186 virtual void SetFocus();
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
;
201 // return the text for the given column of the given item
202 virtual wxString
OnGetItemText(long item
, long column
) const;
204 // return the icon for the given item
205 virtual int OnGetItemImage(long item
) const;
207 // return the attribute for the item (may return NULL if none)
208 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
210 // it calls our OnGetXXX() functions
211 friend class WXDLLEXPORT wxListMainWindow
;
214 // Virtual function hiding supression
215 virtual void Update() { wxWindow::Update(); }
217 // create the header window
218 void CreateHeaderWindow();
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
);
224 DECLARE_EVENT_TABLE()
225 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl
);
228 #if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
230 * wxListCtrl has to be a real class or we have problems with
231 * the run-time information.
234 class WXDLLEXPORT wxListCtrl
: public wxGenericListCtrl
236 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
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
)
251 #endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
253 #endif // __LISTCTRLH_G__