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/textctrl.h"
24 #include "wx/dcclient.h"
25 #include "wx/scrolwin.h"
26 #include "wx/settings.h"
28 #if wxUSE_DRAG_AND_DROP
29 class WXDLLEXPORT wxDropTarget
;
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 class WXDLLEXPORT wxListItem
;
37 class WXDLLEXPORT wxListEvent
;
38 class WXDLLEXPORT wxListCtrl
;
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 class WXDLLEXPORT wxListHeaderData
;
45 class WXDLLEXPORT wxListItemData
;
46 class WXDLLEXPORT wxListLineData
;
48 class WXDLLEXPORT wxListHeaderWindow
;
49 class WXDLLEXPORT wxListMainWindow
;
51 class WXDLLEXPORT wxListRenameTimer
;
52 class WXDLLEXPORT wxListTextCtrl
;
54 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 class WXDLLEXPORT wxListCtrl
: public wxControl
62 wxListCtrl( wxWindow
*parent
,
64 const wxPoint
&pos
= wxDefaultPosition
,
65 const wxSize
&size
= wxDefaultSize
,
66 long style
= wxLC_ICON
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
&name
= "listctrl" )
70 Create(parent
, id
, pos
, size
, style
, validator
, name
);
74 bool Create( wxWindow
*parent
,
76 const wxPoint
&pos
= wxDefaultPosition
,
77 const wxSize
&size
= wxDefaultSize
,
78 long style
= wxLC_ICON
,
79 const wxValidator
& validator
= wxDefaultValidator
,
80 const wxString
&name
= "listctrl" );
82 bool GetColumn( int col
, wxListItem
& item
) const;
83 bool SetColumn( int col
, wxListItem
& item
);
84 int GetColumnWidth( int col
) const;
85 bool SetColumnWidth( int col
, int width
);
86 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
88 bool GetItem( wxListItem
& info
) const;
89 bool SetItem( wxListItem
& info
) ;
90 long SetItem( long index
, int col
, const wxString
& label
, int imageId
= -1 );
91 int GetItemState( long item
, long stateMask
) const;
92 bool SetItemState( long item
, long state
, long stateMask
);
93 bool SetItemImage( long item
, int image
, int selImage
);
94 wxString
GetItemText( long item
) const;
95 void SetItemText( long item
, const wxString
& str
);
96 long GetItemData( long item
) const;
97 bool SetItemData( long item
, long data
);
98 bool GetItemRect( long item
, wxRect
& rect
, int code
= wxLIST_RECT_BOUNDS
) const;
99 bool GetItemPosition( long item
, wxPoint
& pos
) const;
100 bool SetItemPosition( long item
, const wxPoint
& pos
); // not supported in wxGLC
101 int GetItemCount() const;
102 int GetColumnCount() const;
103 void SetItemSpacing( int spacing
, bool isSmall
= FALSE
);
104 int GetItemSpacing( bool isSmall
) const;
105 int GetSelectedItemCount() const;
106 wxColour
GetTextColour() const;
107 void SetTextColour(const wxColour
& col
);
108 long GetTopItem() const;
110 void SetSingleStyle( long style
, bool add
= TRUE
) ;
111 void SetWindowStyleFlag( long style
);
112 void RecreateWindow() {}
113 long GetNextItem( long item
, int geometry
= wxLIST_NEXT_ALL
, int state
= wxLIST_STATE_DONTCARE
) const;
114 wxImageList
*GetImageList( int which
) const;
115 void SetImageList( wxImageList
*imageList
, int which
);
116 void AssignImageList( wxImageList
*imageList
, int which
);
117 bool Arrange( int flag
= wxLIST_ALIGN_DEFAULT
); // always wxLIST_ALIGN_LEFT in wxGLC
120 bool DeleteItem( long item
);
121 bool DeleteAllItems();
122 bool DeleteAllColumns();
123 bool DeleteColumn( int col
);
125 void SetItemCount(long count
);
127 void EditLabel( long item
) { Edit(item
); }
128 void Edit( long item
);
130 bool EnsureVisible( long item
);
131 long FindItem( long start
, const wxString
& str
, bool partial
= FALSE
);
132 long FindItem( long start
, long data
);
133 long FindItem( long start
, const wxPoint
& pt
, int direction
); // not supported in wxGLC
134 long HitTest( const wxPoint
& point
, int& flags
);
135 long InsertItem(wxListItem
& info
);
136 long InsertItem( long index
, const wxString
& label
);
137 long InsertItem( long index
, int imageIndex
);
138 long InsertItem( long index
, const wxString
& label
, int imageIndex
);
139 long InsertColumn( long col
, wxListItem
& info
);
140 long InsertColumn( long col
, const wxString
& heading
, int format
= wxLIST_FORMAT_LEFT
,
142 bool ScrollList( int dx
, int dy
);
143 bool SortItems( wxListCtrlCompare fn
, long data
);
144 bool Update( long item
);
146 // returns true if it is a virtual list control
147 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
149 // refresh items selectively (only useful for virtual list controls)
150 void RefreshItem(long item
);
151 void RefreshItems(long itemFrom
, long itemTo
);
153 // implementation only from now on
154 // -------------------------------
156 void OnIdle( wxIdleEvent
&event
);
157 void OnSize( wxSizeEvent
&event
);
159 // We have to hand down a few functions
161 bool SetBackgroundColour( const wxColour
&colour
);
162 bool SetForegroundColour( const wxColour
&colour
);
163 bool SetFont( const wxFont
&font
);
165 #if wxUSE_DRAG_AND_DROP
166 void SetDropTarget( wxDropTarget
*dropTarget
);
167 wxDropTarget
*GetDropTarget() const;
170 bool SetCursor( const wxCursor
&cursor
);
171 wxColour
GetBackgroundColour() const;
172 wxColour
GetForegroundColour() const;
173 bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
179 wxImageList
*m_imageListNormal
;
180 wxImageList
*m_imageListSmall
;
181 wxImageList
*m_imageListState
; // what's that ?
182 bool m_ownsImageListNormal
,
183 m_ownsImageListSmall
,
184 m_ownsImageListState
;
185 wxListHeaderWindow
*m_headerWin
;
186 wxListMainWindow
*m_mainWin
;
189 // return the text for the given column of the given item
190 virtual wxString
OnGetItemText(long item
, long column
) const;
192 // return the icon for the given item
193 virtual int OnGetItemImage(long item
) const;
195 // return the attribute for the item (may return NULL if none)
196 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
198 // it calls our OnGetXXX() functions
200 friend class WXDLLEXPORT wxListMainWindow
;
203 // Virtual function hiding supression
204 virtual void Update() { wxWindowBase::Update(); }
206 // create the header window
207 void CreateHeaderWindow();
209 DECLARE_EVENT_TABLE()
210 DECLARE_DYNAMIC_CLASS(wxListCtrl
);
214 #endif // __LISTCTRLH_G__