Upstream tarball 20080414
[amule.git] / src / extern / wxWidgets / listctrl.h
blob0bd208f5be6d104d9aecb681f7a3bb66b27dd8a6
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/listctrl.h
3 // Purpose: Generic list control
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // RCS-ID: $Id: listctrl.h 8318 2008-04-01 18:41:23Z gonosztopi $
7 // Copyright: (c) 1998 Robert Roebling and Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef LISTCTRL_287_H
12 #define LISTCTRL_287_H
14 #include <wx/defs.h>
15 #include <wx/listbase.h>
16 #include <wx/textctrl.h>
18 #define wxLC_OWNERDRAW 0x10000
20 class WXDLLIMPEXP_CORE wxImageList;
22 #if wxUSE_DRAG_AND_DROP
23 class WXDLLEXPORT wxDropTarget;
24 #endif
26 // Fix for bug in wx's implementation, which uses longs for item*
27 typedef int (wxCALLBACK *MuleListCtrlCompare)(wxUIntPtr item1, wxUIntPtr item2, long sortData);
29 namespace MuleExtern {
31 // ----------------------------------------------------------------------------
32 // constants
33 // ----------------------------------------------------------------------------
35 extern const wxChar wxListCtrlNameStr[];
37 //-----------------------------------------------------------------------------
38 // internal classes
39 //-----------------------------------------------------------------------------
41 class wxListHeaderWindow;
42 class wxListMainWindow;
44 //-----------------------------------------------------------------------------
45 // wxListCtrl
46 //-----------------------------------------------------------------------------
48 class wxGenericListCtrl: public wxControl
50 public:
52 wxGenericListCtrl();
53 wxGenericListCtrl( wxWindow *parent,
54 wxWindowID winid = wxID_ANY,
55 const wxPoint &pos = wxDefaultPosition,
56 const wxSize &size = wxDefaultSize,
57 long style = wxLC_ICON,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString &name = wxListCtrlNameStr)
61 Create(parent, winid, pos, size, style, validator, name);
63 virtual ~wxGenericListCtrl();
65 bool Create( wxWindow *parent,
66 wxWindowID winid = wxID_ANY,
67 const wxPoint &pos = wxDefaultPosition,
68 const wxSize &size = wxDefaultSize,
69 long style = wxLC_ICON,
70 const wxValidator& validator = wxDefaultValidator,
71 const wxString &name = wxListCtrlNameStr);
73 bool GetColumn( int col, wxListItem& item ) const;
74 bool SetColumn( int col, wxListItem& item );
75 int GetColumnWidth( int col ) const;
76 bool SetColumnWidth( int col, int width);
77 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
78 void GetVisibleLines(long* first, long* last);
79 wxRect GetViewRect() const;
81 bool GetItem( wxListItem& info ) const;
82 bool SetItem( wxListItem& info );
83 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
84 int GetItemState( long item, long stateMask ) const;
85 bool SetItemState( long item, long state, long stateMask);
86 bool SetItemImage( long item, int image, int selImage = -1 );
87 bool SetItemColumnImage( long item, long column, int image );
88 wxString GetItemText( long item ) const;
89 void SetItemText( long item, const wxString& str );
90 wxUIntPtr GetItemData( long item ) const;
91 #if wxABI_VERSION >= 20804
92 bool SetItemPtrData(long item, wxUIntPtr data);
93 #endif // wxABI 2.8.4+
95 // It is not certain that sizeof(long) == sizeof(void*), and since we
96 // just about only use pointers as item-data, I've choosen to disable
97 // this function to prevent mistakes. Use SetItemPtrData instead.
98 #if 0
99 bool SetItemData(long item, long data);
100 #endif
101 bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
102 bool GetItemPosition( long item, wxPoint& pos ) const;
103 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
104 int GetItemCount() const;
105 int GetColumnCount() const;
106 void SetItemSpacing( int spacing, bool isSmall = false );
107 wxSize GetItemSpacing() const;
108 void SetItemTextColour( long item, const wxColour& col);
109 wxColour GetItemTextColour( long item ) const;
110 void SetItemBackgroundColour( long item, const wxColour &col);
111 wxColour GetItemBackgroundColour( long item ) const;
112 void SetItemFont( long item, const wxFont &f);
113 wxFont GetItemFont( long item ) const;
114 int GetSelectedItemCount() const;
115 wxColour GetTextColour() const;
116 void SetTextColour(const wxColour& col);
117 long GetTopItem() const;
119 void SetSingleStyle( long style, bool add = true ) ;
120 void SetWindowStyleFlag( long style );
121 void RecreateWindow() {}
122 long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
123 wxImageList *GetImageList( int which ) const;
124 void SetImageList( wxImageList *imageList, int which );
125 void AssignImageList( wxImageList *imageList, int which );
126 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
128 void ClearAll();
129 bool DeleteItem( long item );
130 bool DeleteAllItems();
131 bool DeleteAllColumns();
132 bool DeleteColumn( int col );
134 void SetItemCount(long count);
136 wxTextCtrl *EditLabel(long item,
137 wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
138 wxTextCtrl* GetEditControl() const;
139 void Edit( long item ) { EditLabel(item); }
141 bool EnsureVisible( long item );
142 long FindItem( long start, const wxString& str, bool partial = false );
143 long FindItem( long start, wxUIntPtr data );
144 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
145 long HitTest( const wxPoint& point, int& flags, long *pSubItem = NULL ) const;
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,
152 int format = wxLIST_FORMAT_LEFT, int width = -1 );
153 bool ScrollList( int dx, int dy );
154 bool SortItems( MuleListCtrlCompare fn, long data );
155 bool Update( long item );
156 // Must provide overload to avoid hiding it (and warnings about it)
157 virtual void Update() { wxControl::Update(); }
159 // are we in report mode?
160 bool InReportView() const { return HasFlag(wxLC_REPORT); }
162 // are we in virtual report mode?
163 bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
165 // do we have a header window?
166 bool HasHeader() const
167 { return InReportView() && !HasFlag(wxLC_NO_HEADER); }
169 // refresh items selectively (only useful for virtual list controls)
170 void RefreshItem(long item);
171 void RefreshItems(long itemFrom, long itemTo);
173 #if WXWIN_COMPATIBILITY_2_6
174 // obsolete, don't use
175 wxDEPRECATED( int GetItemSpacing( bool isSmall ) const );
176 #endif // WXWIN_COMPATIBILITY_2_6
178 virtual wxVisualAttributes GetDefaultAttributes() const
180 return GetClassDefaultAttributes(GetWindowVariant());
183 static wxVisualAttributes
184 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
186 // implementation only from now on
187 // -------------------------------
189 void OnInternalIdle( );
190 void OnSize( wxSizeEvent &event );
192 // We have to hand down a few functions
193 virtual void Refresh(bool eraseBackground = true,
194 const wxRect *rect = NULL);
196 virtual void Freeze();
197 virtual void Thaw();
198 virtual void OnDrawItem(int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted);
200 virtual bool SetBackgroundColour( const wxColour &colour );
201 virtual bool SetForegroundColour( const wxColour &colour );
202 virtual wxColour GetBackgroundColour() const;
203 virtual wxColour GetForegroundColour() const;
204 virtual bool SetFont( const wxFont &font );
205 virtual bool SetCursor( const wxCursor &cursor );
207 virtual int GetScrollPos(int orient) const;
208 virtual void SetScrollPos(int orient, int pos, bool refresh = true);
210 #if wxUSE_DRAG_AND_DROP
211 virtual void SetDropTarget( wxDropTarget *dropTarget );
212 virtual wxDropTarget *GetDropTarget() const;
213 #endif
215 virtual bool ShouldInheritColours() const { return false; }
216 virtual void SetFocus();
217 virtual bool GetFocus();
219 // implementation
220 // --------------
222 wxImageList *m_imageListNormal;
223 wxImageList *m_imageListSmall;
224 wxImageList *m_imageListState; // what's that ?
225 bool m_ownsImageListNormal,
226 m_ownsImageListSmall,
227 m_ownsImageListState;
228 wxListHeaderWindow *m_headerWin;
229 wxListMainWindow *m_mainWin;
230 wxCoord m_headerHeight;
232 protected:
233 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
235 // take into account the coordinates difference between the container
236 // window and the list control window itself here
237 virtual void DoClientToScreen( int *x, int *y ) const;
238 virtual void DoScreenToClient( int *x, int *y ) const;
240 virtual wxSize DoGetBestSize() const;
242 // return the text for the given column of the given item
243 virtual wxString OnGetItemText(long item, long column) const;
245 // return the icon for the given item. In report view, OnGetItemImage will
246 // only be called for the first column. See OnGetItemColumnImage for
247 // details.
248 virtual int OnGetItemImage(long item) const;
250 // return the icon for the given item and column.
251 virtual int OnGetItemColumnImage(long item, long column) const;
253 // return the attribute for the item (may return NULL if none)
254 virtual wxListItemAttr *OnGetItemAttr(long item) const;
256 // it calls our OnGetXXX() functions
257 friend class wxListMainWindow;
259 private:
260 // create the header window
261 void CreateHeaderWindow();
263 // calculate and set height of the header
264 void CalculateAndSetHeaderHeight();
266 // reposition the header and the main window in the report view depending
267 // on whether it should be shown or not
268 void ResizeReportView(bool showHeader);
270 DECLARE_EVENT_TABLE()
273 #if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && (!defined(__WXMAC__) || defined(__WXUNIVERSAL__))
275 * wxListCtrl has to be a real class or we have problems with
276 * the run-time information.
279 class wxListCtrl: public wxGenericListCtrl
281 public:
282 wxListCtrl() {}
284 wxListCtrl(wxWindow *parent, wxWindowID winid = wxID_ANY,
285 const wxPoint& pos = wxDefaultPosition,
286 const wxSize& size = wxDefaultSize,
287 long style = wxLC_ICON,
288 const wxValidator &validator = wxDefaultValidator,
289 const wxString &name = wxListCtrlNameStr)
290 : wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
295 #endif // !__WXMSW__ || __WXUNIVERSAL__
297 } // namespace MuleExtern
299 #endif // LISTCTRL_287_H