]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/listctrl.h
Applied patch [ 858324 ] Calling EndModal inside an EVT_INIT_DIALOG event handler
[wxWidgets.git] / include / wx / generic / listctrl.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/listctrl.h
3// Purpose: Generic list control
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
7// Copyright: (c) 1998 Robert Roebling and Julian Smart
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef __LISTCTRLH_G__
12#define __LISTCTRLH_G__
13
14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15#pragma interface "listctrl.h"
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/generic/imaglist.h"
21
22#include "wx/control.h"
23#include "wx/timer.h"
24#include "wx/dcclient.h"
25#include "wx/scrolwin.h"
26#include "wx/settings.h"
27#include "wx/listbase.h"
28
29#if wxUSE_DRAG_AND_DROP
30class WXDLLEXPORT wxDropTarget;
31#endif
32
33//-----------------------------------------------------------------------------
34// classes
35//-----------------------------------------------------------------------------
36
37class WXDLLEXPORT wxListItem;
38class WXDLLEXPORT wxListEvent;
39
40#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
41class WXDLLEXPORT wxListCtrl;
42#define wxImageListType wxImageList
43#else
44#define wxImageListType wxGenericImageList
45#endif
46
47//-----------------------------------------------------------------------------
48// internal classes
49//-----------------------------------------------------------------------------
50
51class WXDLLEXPORT wxListHeaderData;
52class WXDLLEXPORT wxListItemData;
53class WXDLLEXPORT wxListLineData;
54
55class WXDLLEXPORT wxListHeaderWindow;
56class WXDLLEXPORT wxListMainWindow;
57
58class WXDLLEXPORT wxListRenameTimer;
59class WXDLLEXPORT wxListTextCtrl;
60
61//-----------------------------------------------------------------------------
62// wxListCtrl
63//-----------------------------------------------------------------------------
64
65class WXDLLEXPORT wxGenericListCtrl: public wxControl
66{
67public:
68 wxGenericListCtrl();
69 wxGenericListCtrl( wxWindow *parent,
70 wxWindowID winid = -1,
71 const wxPoint &pos = wxDefaultPosition,
72 const wxSize &size = wxDefaultSize,
73 long style = wxLC_ICON,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString &name = wxT("listctrl") );
76 ~wxGenericListCtrl();
77
78 bool Create( wxWindow *parent,
79 wxWindowID winid = -1,
80 const wxPoint &pos = wxDefaultPosition,
81 const wxSize &size = wxDefaultSize,
82 long style = wxLC_ICON,
83 const wxValidator& validator = wxDefaultValidator,
84 const wxString &name = wxT("listctrl") );
85
86 bool GetColumn( int col, wxListItem& item ) const;
87 bool SetColumn( int col, wxListItem& item );
88 int GetColumnWidth( int col ) const;
89 bool SetColumnWidth( int col, int width);
90 int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
91 wxRect GetViewRect() const;
92
93 bool GetItem( wxListItem& info ) const;
94 bool SetItem( wxListItem& info ) ;
95 long SetItem( long index, int col, const wxString& label, int imageId = -1 );
96 int GetItemState( long item, long stateMask ) const;
97 bool SetItemState( long item, long state, long stateMask);
98 bool SetItemImage( long item, int image, int selImage);
99 wxString GetItemText( long item ) const;
100 void SetItemText( long item, const wxString& str );
101 long GetItemData( long item ) const;
102 bool SetItemData( long item, long data );
103 bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
104 bool GetItemPosition( long item, wxPoint& pos ) const;
105 bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
106 int GetItemCount() const;
107 int GetColumnCount() const;
108 void SetItemSpacing( int spacing, bool isSmall = FALSE );
109 wxSize GetItemSpacing() const;
110 void SetItemTextColour( long item, const wxColour& col);
111 wxColour GetItemTextColour( long item ) const;
112 void SetItemBackgroundColour( long item, const wxColour &col);
113 wxColour GetItemBackgroundColour( long item ) const;
114 int GetSelectedItemCount() const;
115 wxColour GetTextColour() const;
116 void SetTextColour(const wxColour& col);
117 long GetTopItem() const;
118
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 wxImageListType *GetImageList( int which ) const;
124 void SetImageList( wxImageListType *imageList, int which );
125 void AssignImageList( wxImageListType *imageList, int which );
126 bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
127
128 void ClearAll();
129 bool DeleteItem( long item );
130 bool DeleteAllItems();
131 bool DeleteAllColumns();
132 bool DeleteColumn( int col );
133
134 void SetItemCount(long count);
135
136 void EditLabel( long item ) { Edit(item); }
137 void Edit( long item );
138
139 bool EnsureVisible( long item );
140 long FindItem( long start, const wxString& str, bool partial = FALSE );
141 long FindItem( long start, long data );
142 long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
143 long HitTest( const wxPoint& point, int& flags);
144 long InsertItem(wxListItem& info);
145 long InsertItem( long index, const wxString& label );
146 long InsertItem( long index, int imageIndex );
147 long InsertItem( long index, const wxString& label, int imageIndex );
148 long InsertColumn( long col, wxListItem& info );
149 long InsertColumn( long col, const wxString& heading,
150 int format = wxLIST_FORMAT_LEFT, int width = -1 );
151 bool ScrollList( int dx, int dy );
152 bool SortItems( wxListCtrlCompare fn, long data );
153 bool Update( long item );
154
155 // returns true if it is a virtual list control
156 bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; }
157
158 // refresh items selectively (only useful for virtual list controls)
159 void RefreshItem(long item);
160 void RefreshItems(long itemFrom, long itemTo);
161
162 // obsolete, don't use
163 wxDEPRECATED( int GetItemSpacing( bool isSmall ) const );
164
165
166 // implementation only from now on
167 // -------------------------------
168
169 void OnInternalIdle( );
170 void OnSize( wxSizeEvent &event );
171
172 // We have to hand down a few functions
173 virtual void Refresh(bool eraseBackground = TRUE,
174 const wxRect *rect = NULL);
175
176 virtual void Freeze();
177 virtual void Thaw();
178
179 virtual bool SetBackgroundColour( const wxColour &colour );
180 virtual bool SetForegroundColour( const wxColour &colour );
181 virtual wxColour GetBackgroundColour() const;
182 virtual wxColour GetForegroundColour() const;
183 virtual bool SetFont( const wxFont &font );
184 virtual bool SetCursor( const wxCursor &cursor );
185
186#if wxUSE_DRAG_AND_DROP
187 virtual void SetDropTarget( wxDropTarget *dropTarget );
188 virtual wxDropTarget *GetDropTarget() const;
189#endif
190
191 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
192
193 virtual bool ShouldInheritColours() const { return false; }
194 virtual void SetFocus();
195
196 // implementation
197 // --------------
198
199 wxImageListType *m_imageListNormal;
200 wxImageListType *m_imageListSmall;
201 wxImageListType *m_imageListState; // what's that ?
202 bool m_ownsImageListNormal,
203 m_ownsImageListSmall,
204 m_ownsImageListState;
205 wxListHeaderWindow *m_headerWin;
206 wxListMainWindow *m_mainWin;
207 wxCoord m_headerHeight;
208
209protected:
210 // return the text for the given column of the given item
211 virtual wxString OnGetItemText(long item, long column) const;
212
213 // return the icon for the given item
214 virtual int OnGetItemImage(long item) const;
215
216 // return the attribute for the item (may return NULL if none)
217 virtual wxListItemAttr *OnGetItemAttr(long item) const;
218
219 // it calls our OnGetXXX() functions
220 friend class WXDLLEXPORT wxListMainWindow;
221
222private:
223 // Virtual function hiding supression
224 virtual void Update() { wxWindow::Update(); }
225
226 // create the header window
227 void CreateHeaderWindow();
228
229 // calculate and set height of the header
230 void CalculateAndSetHeaderHeight();
231
232 // reposition the header and the main window in the report view depending
233 // on whether it should be shown or not
234 void ResizeReportView(bool showHeader);
235
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS(wxGenericListCtrl);
238};
239
240#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
241/*
242 * wxListCtrl has to be a real class or we have problems with
243 * the run-time information.
244 */
245
246class WXDLLEXPORT wxListCtrl: public wxGenericListCtrl
247{
248 DECLARE_DYNAMIC_CLASS(wxListCtrl)
249
250public:
251 wxListCtrl();
252
253 wxListCtrl(wxWindow *parent, wxWindowID winid = -1,
254 const wxPoint& pos = wxDefaultPosition,
255 const wxSize& size = wxDefaultSize,
256 long style = wxLC_ICON,
257 const wxValidator &validator = wxDefaultValidator,
258 const wxString &name = wxT("listctrl") );
259};
260#endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
261
262#endif // __LISTCTRLH_G__