]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/listctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/listctrl.h
3 // Purpose: wxListCtrl class
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTCTRL_H_
13 #define _WX_LISTCTRL_H_
17 #include "wx/control.h"
20 #include "wx/textctrl.h"
23 class WXDLLEXPORT wxImageList
;
25 typedef int (wxCALLBACK
*wxListCtrlCompare
)(long lItem1
, long lItem2
, long lSortData
);
27 class WXDLLEXPORT wxListCtrl
: public wxControl
30 wxListCtrl() { Init(); }
31 wxListCtrl( wxWindow
* pParent
33 ,const wxPoint
& rPos
= wxDefaultPosition
34 ,const wxSize
& rSize
= wxDefaultSize
35 ,long lStyle
= wxLC_ICON
36 ,const wxValidator
& rValidator
= wxDefaultValidator
37 ,const wxString
& rsName
= wxListCtrlNameStr
)
49 virtual ~wxListCtrl();
51 bool Create( wxWindow
* pParent
53 ,const wxPoint
& rPos
= wxDefaultPosition
54 ,const wxSize
& rSize
= wxDefaultSize
55 ,long lStyle
= wxLC_ICON
56 ,const wxValidator
& rValidator
= wxDefaultValidator
57 ,const wxString
& rsName
= wxListCtrlNameStr
62 ////////////////////////////////////////////////////////////////////////////
66 // Set the control colours
68 bool SetForegroundColour(const wxColour
& rCol
);
69 bool SetBackgroundColour(const wxColour
& rCol
);
72 // Information about this column
74 bool GetColumn( int nCol
77 bool SetColumn( int nCol
84 int GetColumnWidth(int nCol
) const;
85 bool SetColumnWidth( int nCol
90 // Gets the number of items that can fit vertically in the
91 // visible area of the list control (list or report view)
92 // or the total number of items in the list control (icon
93 // or small icon view)
95 int GetCountPerPage(void) const;
97 wxRect
GetViewRect() const;
99 // Gets the edit control for editing labels.
101 wxTextCtrl
* GetEditControl(void) const;
104 // Information about the item
106 bool GetItem(wxListItem
& rInfo
) const;
107 bool SetItem(wxListItem
& rInfo
);
110 // Sets a string field at a particular column
112 long SetItem( long lIndex
114 ,const wxString
& rsLabel
121 int GetItemState( long lItem
124 bool SetItemState( long lItem
130 // Sets the item image
132 bool SetItemImage( long lItem
140 wxString
GetItemText(long lItem
) const;
141 void SetItemText( long lItem
142 ,const wxString
& rsStr
148 long GetItemData(long lItem
) const;
149 bool SetItemData( long lItem
154 // Gets the item rectangle
156 bool GetItemRect( long lItem
158 ,int nCode
= wxLIST_RECT_BOUNDS
164 bool GetItemPosition( long lItem
167 bool SetItemPosition( long lItem
172 // Gets the number of items in the list control
174 int GetItemCount(void) const;
177 // Gets the number of columns in the list control
179 inline int GetColumnCount(void) const { return m_nColCount
; }
182 // Retrieves the spacing between icons in pixels.
183 // If bIsSmall is true, gets the spacing for the small icon
184 // view, otherwise the large icon view.
186 int GetItemSpacing(bool bIsSmall
) const;
189 // Foreground colour of an item.
191 wxColour
GetItemTextColour(long lItem
) const;
192 void SetItemTextColour( long lItem
193 ,const wxColour
& rCol
197 // Background colour of an item.
199 wxColour
GetItemBackgroundColour(long lItem
) const;
200 void SetItemBackgroundColour( long lItem
201 ,const wxColour
& rCol
205 // Gets the number of selected items in the list control
207 int GetSelectedItemCount(void) const;
210 // Text colour of the listview
212 wxColour
GetTextColour(void) const;
213 void SetTextColour(const wxColour
& rCol
);
216 // Gets the index of the topmost visible item when in
217 // list or report view
219 long GetTopItem(void) const;
222 // Add or remove a single window style
223 void SetSingleStyle( long lStyle
228 // Set the whole window style
230 void SetWindowStyleFlag(long lStyle
);
233 // Searches for an item, starting from 'item'.
234 // item can be -1 to find the first item that matches the
236 // Returns the item or -1 if unsuccessful.
237 long GetNextItem( long lItem
238 ,int nGeometry
= wxLIST_NEXT_ALL
239 ,int lState
= wxLIST_STATE_DONTCARE
243 // Gets one of the three image lists
245 wxImageList
* GetImageList(int nWhich
) const;
248 // Sets the image list
250 void SetImageList( wxImageList
* pImageList
253 void AssignImageList( wxImageList
* pImageList
258 // Returns true if it is a virtual list control
260 inline bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
263 // Refresh items selectively (only useful for virtual list controls)
265 void RefreshItem(long lItem
);
266 void RefreshItems( long lItemFrom
272 ////////////////////////////////////////////////////////////////////////////
276 // Arranges the items
278 bool Arrange(int nFlag
= wxLIST_ALIGN_DEFAULT
);
283 bool DeleteItem(long lItem
);
287 bool DeleteAllItems(void);
292 bool DeleteColumn(int nCol
);
295 // Deletes all columns
297 bool DeleteAllColumns(void);
300 // Clears items, and columns if there are any.
307 wxTextCtrl
* EditLabel( long lItem
308 ,wxClassInfo
* pTextControlClass
= CLASSINFO(wxTextCtrl
)
312 // End label editing, optionally cancelling the edit
314 bool EndEditLabel(bool bCancel
);
317 // Ensures this item is visible
319 bool EnsureVisible(long lItem
);
322 // Find an item whose label matches this string, starting from the item after 'start'
323 // or the beginning if 'start' is -1.
325 long FindItem( long lStart
326 ,const wxString
& rsStr
327 ,bool bPartial
= false
331 // Find an item whose data matches this data, starting from the item after 'start'
332 // or the beginning if 'start' is -1.
334 long FindItem( long lStart
339 // Find an item nearest this position in the specified direction, starting from
340 // the item after 'start' or the beginning if 'start' is -1.
342 long FindItem( long lStart
343 ,const wxPoint
& rPoint
348 // Determines which item (if any) is at the specified point,
349 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
351 long HitTest( const wxPoint
& rPoint
356 // Inserts an item, returning the index of the new item if successful,
359 long InsertItem(wxListItem
& rInfo
);
362 // Insert a string item
364 long InsertItem( long lIndex
365 ,const wxString
& rsLabel
369 // Insert an image item
371 long InsertItem( long lIndex
376 // Insert an image/string item
378 long InsertItem( long lIndex
379 ,const wxString
& rsLabel
384 // For list view mode (only), inserts a column.
386 long InsertColumn( long lCol
390 long InsertColumn( long lCol
391 ,const wxString
& rsHeading
392 ,int nFormat
= wxLIST_FORMAT_LEFT
397 // set the number of items in a virtual list control
399 void SetItemCount(long lCount
);
402 // Scrolls the list control. If in icon, small icon or report view mode,
403 // x specifies the number of pixels to scroll. If in list view mode, x
404 // specifies the number of columns to scroll.
405 // If in icon, small icon or list view mode, y specifies the number of pixels
406 // to scroll. If in report view mode, y specifies the number of lines to scroll.
408 bool ScrollList( int nDx
415 // fn is a function which takes 3 long arguments: item1, item2, data.
416 // item1 is the long data associated with a first item (NOT the index).
417 // item2 is the long data associated with a second item (NOT the index).
418 // data is the same value as passed to SortItems.
419 // The return value is a negative number if the first item should precede the second
420 // item, a positive number of the second item should precede the first,
421 // or zero if the two items are equivalent.
423 // data is arbitrary data to be passed to the sort function.
425 bool SortItems( wxListCtrlCompare fn
433 virtual bool OS2Command( WXUINT uParam
437 // Bring the control in sync with current m_windowStyle value
439 void UpdateStyle(void);
442 // Implementation: converts wxWidgets style to MSW style.
443 // Can be a single style flag or a bit list.
444 // oldStyle is 'normalised' so that it doesn't contain
445 // conflicting styles.
447 long ConvertToOS2Style( long& lOldStyle
450 long ConvertArrangeToOS2Style(long lStyle
);
451 long ConvertViewToOS2Style(long lStyle
);
453 virtual MRESULT
OS2WindowProc( WXUINT uMsg
459 ////////////////////////////////////////////////////////////////////////////
460 // Necessary for drawing hrules and vrules, if specified
461 void OnPaint(wxPaintEvent
& rEvent
);
465 // common part of all ctors
470 // Free memory taken by all internal data
472 void FreeAllInternalData(void);
474 wxTextCtrl
* m_pTextCtrl
; // The control used for editing a label
475 wxImageList
* m_pImageListNormal
; // The image list for normal icons
476 wxImageList
* m_pImageListSmall
; // The image list for small icons
477 wxImageList
* m_pImageListState
; // The image list state icons (not implemented yet)
478 bool m_bOwnsImageListNormal
;
479 bool m_bOwnsImageListSmall
;
480 bool m_bOwnsImageListState
;
481 long m_lBaseStyle
; // Basic PM style flags, for recreation purposes
482 int m_nColCount
; // PM doesn't have GetColumnCount so must
483 // keep track of inserted/deleted columns
486 // true if we have any internal data (user data & attributes)
488 bool m_bAnyInternalData
;
491 // true if we have any items with custom attributes
496 // These functions are only used for virtual list view controls, i.e. the
497 // ones with wxLC_VIRTUAL style
499 // return the text for the given column of the given item
501 virtual wxString
OnGetItemText( long lItem
506 // Return the icon for the given item
508 virtual int OnGetItemImage(long lItem
) const;
511 // Return the attribute for the item (may return NULL if none)
513 virtual wxListItemAttr
* OnGetItemAttr(long lItem
) const;
516 bool DoCreateControl( int nX
522 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
523 DECLARE_EVENT_TABLE()
524 DECLARE_NO_COPY_CLASS(wxListCtrl
)
525 }; // end of CLASS wxListCtrl
527 #endif // wxUSE_LISTCTRL
529 #endif // _WX_LISTCTRL_H_