]>
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
136 bool SetItemColumnImage( long lItem
144 wxString
GetItemText(long lItem
) const;
145 void SetItemText( long lItem
146 ,const wxString
& rsStr
152 long GetItemData(long lItem
) const;
153 bool SetItemData( long lItem
158 // Gets the item rectangle
160 bool GetItemRect( long lItem
162 ,int nCode
= wxLIST_RECT_BOUNDS
168 bool GetItemPosition( long lItem
171 bool SetItemPosition( long lItem
176 // Gets the number of items in the list control
178 int GetItemCount(void) const;
181 // Gets the number of columns in the list control
183 inline int GetColumnCount(void) const { return m_nColCount
; }
186 // Retrieves the spacing between icons in pixels.
187 // If bIsSmall is true, gets the spacing for the small icon
188 // view, otherwise the large icon view.
190 int GetItemSpacing(bool bIsSmall
) const;
193 // Foreground colour of an item.
195 wxColour
GetItemTextColour(long lItem
) const;
196 void SetItemTextColour( long lItem
197 ,const wxColour
& rCol
201 // Background colour of an item.
203 wxColour
GetItemBackgroundColour(long lItem
) const;
204 void SetItemBackgroundColour( long lItem
205 ,const wxColour
& rCol
209 // Gets the number of selected items in the list control
211 int GetSelectedItemCount(void) const;
214 // Text colour of the listview
216 wxColour
GetTextColour(void) const;
217 void SetTextColour(const wxColour
& rCol
);
220 // Gets the index of the topmost visible item when in
221 // list or report view
223 long GetTopItem(void) const;
226 // Add or remove a single window style
227 void SetSingleStyle( long lStyle
232 // Set the whole window style
234 void SetWindowStyleFlag(long lStyle
);
237 // Searches for an item, starting from 'item'.
238 // item can be -1 to find the first item that matches the
240 // Returns the item or -1 if unsuccessful.
241 long GetNextItem( long lItem
242 ,int nGeometry
= wxLIST_NEXT_ALL
243 ,int lState
= wxLIST_STATE_DONTCARE
247 // Gets one of the three image lists
249 wxImageList
* GetImageList(int nWhich
) const;
252 // Sets the image list
254 void SetImageList( wxImageList
* pImageList
257 void AssignImageList( wxImageList
* pImageList
262 // Returns true if it is a virtual list control
264 inline bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
267 // Refresh items selectively (only useful for virtual list controls)
269 void RefreshItem(long lItem
);
270 void RefreshItems( long lItemFrom
276 ////////////////////////////////////////////////////////////////////////////
280 // Arranges the items
282 bool Arrange(int nFlag
= wxLIST_ALIGN_DEFAULT
);
287 bool DeleteItem(long lItem
);
291 bool DeleteAllItems(void);
296 bool DeleteColumn(int nCol
);
299 // Deletes all columns
301 bool DeleteAllColumns(void);
304 // Clears items, and columns if there are any.
311 wxTextCtrl
* EditLabel( long lItem
312 ,wxClassInfo
* pTextControlClass
= CLASSINFO(wxTextCtrl
)
316 // End label editing, optionally cancelling the edit
318 bool EndEditLabel(bool bCancel
);
321 // Ensures this item is visible
323 bool EnsureVisible(long lItem
);
326 // Find an item whose label matches this string, starting from the item after 'start'
327 // or the beginning if 'start' is -1.
329 long FindItem( long lStart
330 ,const wxString
& rsStr
331 ,bool bPartial
= false
335 // Find an item whose data matches this data, starting from the item after 'start'
336 // or the beginning if 'start' is -1.
338 long FindItem( long lStart
343 // Find an item nearest this position in the specified direction, starting from
344 // the item after 'start' or the beginning if 'start' is -1.
346 long FindItem( long lStart
347 ,const wxPoint
& rPoint
352 // Determines which item (if any) is at the specified point,
353 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
355 long HitTest( const wxPoint
& rPoint
360 // Inserts an item, returning the index of the new item if successful,
363 long InsertItem(wxListItem
& rInfo
);
366 // Insert a string item
368 long InsertItem( long lIndex
369 ,const wxString
& rsLabel
373 // Insert an image item
375 long InsertItem( long lIndex
380 // Insert an image/string item
382 long InsertItem( long lIndex
383 ,const wxString
& rsLabel
388 // For list view mode (only), inserts a column.
390 long InsertColumn( long lCol
394 long InsertColumn( long lCol
395 ,const wxString
& rsHeading
396 ,int nFormat
= wxLIST_FORMAT_LEFT
401 // set the number of items in a virtual list control
403 void SetItemCount(long lCount
);
406 // Scrolls the list control. If in icon, small icon or report view mode,
407 // x specifies the number of pixels to scroll. If in list view mode, x
408 // specifies the number of columns to scroll.
409 // If in icon, small icon or list view mode, y specifies the number of pixels
410 // to scroll. If in report view mode, y specifies the number of lines to scroll.
412 bool ScrollList( int nDx
419 // fn is a function which takes 3 long arguments: item1, item2, data.
420 // item1 is the long data associated with a first item (NOT the index).
421 // item2 is the long data associated with a second item (NOT the index).
422 // data is the same value as passed to SortItems.
423 // The return value is a negative number if the first item should precede the second
424 // item, a positive number of the second item should precede the first,
425 // or zero if the two items are equivalent.
427 // data is arbitrary data to be passed to the sort function.
429 bool SortItems( wxListCtrlCompare fn
437 virtual bool OS2Command( WXUINT uParam
441 // Bring the control in sync with current m_windowStyle value
443 void UpdateStyle(void);
446 // Implementation: converts wxWidgets style to MSW style.
447 // Can be a single style flag or a bit list.
448 // oldStyle is 'normalised' so that it doesn't contain
449 // conflicting styles.
451 long ConvertToOS2Style( long& lOldStyle
454 long ConvertArrangeToOS2Style(long lStyle
);
455 long ConvertViewToOS2Style(long lStyle
);
457 virtual MRESULT
OS2WindowProc( WXUINT uMsg
463 ////////////////////////////////////////////////////////////////////////////
464 // Necessary for drawing hrules and vrules, if specified
465 void OnPaint(wxPaintEvent
& rEvent
);
469 // common part of all ctors
474 // Free memory taken by all internal data
476 void FreeAllInternalData(void);
478 wxTextCtrl
* m_pTextCtrl
; // The control used for editing a label
479 wxImageList
* m_pImageListNormal
; // The image list for normal icons
480 wxImageList
* m_pImageListSmall
; // The image list for small icons
481 wxImageList
* m_pImageListState
; // The image list state icons (not implemented yet)
482 bool m_bOwnsImageListNormal
;
483 bool m_bOwnsImageListSmall
;
484 bool m_bOwnsImageListState
;
485 long m_lBaseStyle
; // Basic PM style flags, for recreation purposes
486 int m_nColCount
; // PM doesn't have GetColumnCount so must
487 // keep track of inserted/deleted columns
490 // true if we have any internal data (user data & attributes)
492 bool m_bAnyInternalData
;
495 // true if we have any items with custom attributes
500 // These functions are only used for virtual list view controls, i.e. the
501 // ones with wxLC_VIRTUAL style
503 // return the text for the given column of the given item
505 virtual wxString
OnGetItemText( long lItem
510 // Return the icon for the given item. In report view, OnGetItemImage will
511 // only be called for the first column. See OnGetItemColumnImage for
514 virtual int OnGetItemImage(long lItem
) const;
517 // Return the icon for the given item and column
519 virtual int OnGetItemColumnImage(long lItem
, long lColumn
) const;
522 // Return the attribute for the item (may return NULL if none)
524 virtual wxListItemAttr
* OnGetItemAttr(long lItem
) const;
527 bool DoCreateControl( int nX
533 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
534 DECLARE_EVENT_TABLE()
535 DECLARE_NO_COPY_CLASS(wxListCtrl
)
536 }; // end of CLASS wxListCtrl
538 #endif // wxUSE_LISTCTRL
540 #endif // _WX_LISTCTRL_H_