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/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
;
39 class WXDLLEXPORT wxListCtrl
;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 class WXDLLEXPORT wxListHeaderData
;
46 class WXDLLEXPORT wxListItemData
;
47 class WXDLLEXPORT wxListLineData
;
49 class WXDLLEXPORT wxListHeaderWindow
;
50 class WXDLLEXPORT wxListMainWindow
;
52 class WXDLLEXPORT wxListRenameTimer
;
53 class WXDLLEXPORT wxListTextCtrl
;
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
59 class WXDLLEXPORT wxGenericListCtrl
: public wxControl
63 wxGenericListCtrl( wxWindow
*parent
,
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" )
71 Create(parent
, id
, pos
, size
, style
, validator
, name
);
75 bool Create( wxWindow
*parent
,
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" );
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
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;
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
125 bool DeleteItem( long item
);
126 bool DeleteAllItems();
127 bool DeleteAllColumns();
128 bool DeleteColumn( int col
);
130 void SetItemCount(long count
);
132 void EditLabel( long item
) { Edit(item
); }
133 void Edit( long item
);
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
,
147 bool ScrollList( int dx
, int dy
);
148 bool SortItems( wxListCtrlCompare fn
, long data
);
149 bool Update( long item
);
151 // returns true if it is a virtual list control
152 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
154 // refresh items selectively (only useful for virtual list controls)
155 void RefreshItem(long item
);
156 void RefreshItems(long itemFrom
, long itemTo
);
158 // implementation only from now on
159 // -------------------------------
161 void OnIdle( wxIdleEvent
&event
);
162 void OnSize( wxSizeEvent
&event
);
164 // We have to hand down a few functions
166 virtual void Freeze();
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
);
176 #if wxUSE_DRAG_AND_DROP
177 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
178 virtual wxDropTarget
*GetDropTarget() const;
181 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
183 virtual void SetFocus();
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
;
198 // return the text for the given column of the given item
199 virtual wxString
OnGetItemText(long item
, long column
) const;
201 // return the icon for the given item
202 virtual int OnGetItemImage(long item
) const;
204 // return the attribute for the item (may return NULL if none)
205 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
207 // it calls our OnGetXXX() functions
208 friend class WXDLLEXPORT wxListMainWindow
;
211 // Virtual function hiding supression
212 virtual void Update() { wxWindow::Update(); }
214 // create the header window
215 void CreateHeaderWindow();
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
);
221 DECLARE_EVENT_TABLE()
222 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl
);
225 #if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
227 * wxListCtrl has to be a real class or we have problems with
228 * the run-time information.
231 class WXDLLEXPORT wxListCtrl
: public wxGenericListCtrl
233 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
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
)
248 #endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
250 #endif // __LISTCTRLH_G__