debian: fix build-deps for focal
[amule.git] / src / extern / wxWidgets / listctrl.h
blobb62204cc0e90cc08cb18c95e4d3b3801269804ff
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$
7 // Copyright: Copyright (c) 1998-2011 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
19 #define WXWIN_COMPATIBILITY_2_8 1
21 #include <wx/imaglist.h>
23 #if wxUSE_DRAG_AND_DROP
24 class WXDLLEXPORT wxDropTarget;
25 #endif
27 // Fix for bug in wx's implementation, which uses longs for item*
28 typedef int (wxCALLBACK *MuleListCtrlCompare)(wxUIntPtr item1, wxUIntPtr item2, long sortData);
30 namespace MuleExtern {
32 // ----------------------------------------------------------------------------
33 // constants
34 // ----------------------------------------------------------------------------
36 extern const wxChar wxListCtrlNameStr[];
38 //-----------------------------------------------------------------------------
39 // internal classes
40 //-----------------------------------------------------------------------------
42 class wxListHeaderWindow;
43 class wxListMainWindow;
45 //-----------------------------------------------------------------------------
46 // wxListCtrl
47 //-----------------------------------------------------------------------------
49 class wxGenericListCtrl: public wxControl
51 public:
53 wxGenericListCtrl();
54 wxGenericListCtrl( wxWindow *parent,
55 wxWindowID winid = wxID_ANY,
56 const wxPoint &pos = wxDefaultPosition,
57 const wxSize &size = wxDefaultSize,
58 long style = wxLC_ICON,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString &name = wxListCtrlNameStr)
62 Create(parent, winid, pos, size, style, validator, name);
64 virtual ~wxGenericListCtrl();
66 bool Create( wxWindow *parent,
67 wxWindowID winid = wxID_ANY,
68 const wxPoint &pos = wxDefaultPosition,
69 const wxSize &size = wxDefaultSize,
70 long style = wxLC_ICON,
71 const wxValidator& validator = wxDefaultValidator,
72 const wxString &name = wxListCtrlNameStr);
74 bool GetColumn( int col, wxListItem& item ) const;
75 bool SetColumn( int col, wxListItem& item );
76 int GetColumnWidth( int col ) const;
77 bool SetColumnWidth( int col, int width);
78 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
79 void GetVisibleLines(long* first, long* last);
80 wxRect GetViewRect() const;
82 bool GetItem( wxListItem& info ) const;
83 bool SetItem( wxListItem& info );
84 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
85 int GetItemState( long item, long stateMask ) const;
86 bool SetItemState( long item, long state, long stateMask);
87 bool SetItemImage( long item, int image, int selImage = -1 );
88 bool SetItemColumnImage( long item, long column, int image );
89 wxString GetItemText( long item ) const;
90 void SetItemText( long item, const wxString& str );
91 wxUIntPtr GetItemData( long item ) const;
92 #if wxABI_VERSION >= 20804
93 bool SetItemPtrData(long item, wxUIntPtr data);
94 #endif // wxABI 2.8.4+
96 // It is not certain that sizeof(long) == sizeof(void*), and since we
97 // just about only use pointers as item-data, I've choosen to disable
98 // this function to prevent mistakes. Use SetItemPtrData instead.
99 #if 0
100 bool SetItemData(long item, long data);
101 #endif
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 wxSize GetItemSpacing() 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 void SetItemFont( long item, const wxFont &f);
114 wxFont GetItemFont( long item ) const;
115 int GetSelectedItemCount() const;
116 wxColour GetTextColour() const;
117 void SetTextColour(const wxColour& col);
118 long GetTopItem() const;
120 void SetSingleStyle( long style, bool add = true ) ;
121 void SetWindowStyleFlag( long style );
122 void RecreateWindow() {}
123 long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
124 wxImageList *GetImageList( int which ) const;
125 void SetImageList( wxImageList *imageList, int which );
126 void AssignImageList( wxImageList *imageList, int which );
127 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
129 void ClearAll();
130 bool DeleteItem( long item );
131 bool DeleteAllItems();
132 bool DeleteAllColumns();
133 bool DeleteColumn( int col );
135 void SetItemCount(long count);
137 wxTextCtrl *EditLabel(long item,
138 wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
139 wxTextCtrl* GetEditControl() const;
140 void Edit( long item ) { EditLabel(item); }
142 bool EnsureVisible( long item );
143 long FindItem( long start, const wxString& str, bool partial = false );
144 long FindItem( long start, wxUIntPtr data );
145 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
146 long HitTest( const wxPoint& point, int& flags, long *pSubItem = NULL ) const;
147 long InsertItem(wxListItem& info);
148 long InsertItem( long index, const wxString& label );
149 long InsertItem( long index, int imageIndex );
150 long InsertItem( long index, const wxString& label, int imageIndex );
151 long InsertColumn( long col, wxListItem& info );
152 long InsertColumn( long col, const wxString& heading,
153 int format = wxLIST_FORMAT_LEFT, int width = -1 );
154 bool ScrollList( int dx, int dy );
155 bool SortItems( MuleListCtrlCompare fn, long data );
156 bool Update( long item );
157 // Must provide overload to avoid hiding it (and warnings about it)
158 virtual void Update() { wxControl::Update(); }
160 // are we in report mode?
161 bool InReportView() const { return HasFlag(wxLC_REPORT); }
163 // are we in virtual report mode?
164 bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
166 // do we have a header window?
167 bool HasHeader() const
168 { return InReportView() && !HasFlag(wxLC_NO_HEADER); }
170 // refresh items selectively (only useful for virtual list controls)
171 void RefreshItem(long item);
172 void RefreshItems(long itemFrom, long itemTo);
174 virtual wxVisualAttributes GetDefaultAttributes() const
176 return GetClassDefaultAttributes(GetWindowVariant());
179 static wxVisualAttributes
180 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
182 // implementation only from now on
183 // -------------------------------
185 void OnInternalIdle( );
186 void OnSize( wxSizeEvent &event );
188 // We have to hand down a few functions
189 virtual void Refresh(bool eraseBackground = true,
190 const wxRect *rect = NULL);
192 virtual void Freeze();
193 virtual void Thaw();
194 virtual void OnDrawItem(int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted);
196 virtual bool SetBackgroundColour( const wxColour &colour );
197 virtual bool SetForegroundColour( const wxColour &colour );
198 virtual wxColour GetBackgroundColour() const;
199 virtual wxColour GetForegroundColour() const;
200 virtual bool SetFont( const wxFont &font );
201 virtual bool SetCursor( const wxCursor &cursor );
203 virtual int GetScrollPos(int orient) const;
204 virtual void SetScrollPos(int orient, int pos, bool refresh = true);
206 #if wxUSE_DRAG_AND_DROP
207 virtual void SetDropTarget( wxDropTarget *dropTarget );
208 virtual wxDropTarget *GetDropTarget() const;
209 #endif
211 virtual bool ShouldInheritColours() const { return false; }
212 virtual void SetFocus();
213 virtual bool GetFocus();
215 // implementation
216 // --------------
218 wxImageList *m_imageListNormal;
219 wxImageList *m_imageListSmall;
220 wxImageList *m_imageListState; // what's that ?
221 bool m_ownsImageListNormal,
222 m_ownsImageListSmall,
223 m_ownsImageListState;
224 wxListHeaderWindow *m_headerWin;
225 wxListMainWindow *m_mainWin;
226 wxCoord m_headerHeight;
228 protected:
229 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
231 virtual wxSize DoGetBestSize() const;
233 // return the text for the given column of the given item
234 virtual wxString OnGetItemText(long item, long column) const;
236 // return the icon for the given item. In report view, OnGetItemImage will
237 // only be called for the first column. See OnGetItemColumnImage for
238 // details.
239 virtual int OnGetItemImage(long item) const;
241 // return the icon for the given item and column.
242 virtual int OnGetItemColumnImage(long item, long column) const;
244 // return the attribute for the item (may return NULL if none)
245 virtual wxListItemAttr *OnGetItemAttr(long item) const;
247 // it calls our OnGetXXX() functions
248 friend class wxListMainWindow;
250 private:
251 // create the header window
252 void CreateHeaderWindow();
254 // calculate and set height of the header
255 void CalculateAndSetHeaderHeight();
257 // reposition the header and the main window in the report view depending
258 // on whether it should be shown or not
259 void ResizeReportView(bool showHeader);
261 DECLARE_EVENT_TABLE()
264 #if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && (!defined(__WXMAC__) || defined(__WXUNIVERSAL__))
266 * wxListCtrl has to be a real class or we have problems with
267 * the run-time information.
270 class wxListCtrl: public wxGenericListCtrl
272 public:
273 wxListCtrl() {}
275 wxListCtrl(wxWindow *parent, wxWindowID winid = wxID_ANY,
276 const wxPoint& pos = wxDefaultPosition,
277 const wxSize& size = wxDefaultSize,
278 long style = wxLC_ICON,
279 const wxValidator &validator = wxDefaultValidator,
280 const wxString &name = wxListCtrlNameStr)
281 : wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
286 #endif // !__WXMSW__ || __WXUNIVERSAL__
288 } // namespace MuleExtern
290 #endif // LISTCTRL_287_H