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