]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/listctrl.h
1 #ifndef _WX_LISTCTRL_H_
2 #define _WX_LISTCTRL_H_
5 #pragma interface "listctrl.h"
10 #include "wx/control.h"
13 #include "wx/textctrl.h"
16 class WXDLLEXPORT wxImageList
;
18 typedef int (wxCALLBACK
*wxListCtrlCompare
)(long lItem1
, long lItem2
, long lSortData
);
20 class WXDLLEXPORT wxListCtrl
: public wxControl
23 wxListCtrl() { Init(); }
24 wxListCtrl( wxWindow
* pParent
26 ,const wxPoint
& rPos
= wxDefaultPosition
27 ,const wxSize
& rSize
= wxDefaultSize
28 ,long lStyle
= wxLC_ICON
29 ,const wxValidator
& rValidator
= wxDefaultValidator
30 ,const wxString
& rsName
= _T("wxListCtrl"))
42 virtual ~wxListCtrl();
44 bool Create( wxWindow
* pParent
46 ,const wxPoint
& rPos
= wxDefaultPosition
47 ,const wxSize
& rSize
= wxDefaultSize
48 ,long lStyle
= wxLC_ICON
49 ,const wxValidator
& rValidator
= wxDefaultValidator
50 ,const wxString
& rsName
= _T("wxListCtrl")
55 ////////////////////////////////////////////////////////////////////////////
59 // Set the control colours
61 bool SetForegroundColour(const wxColour
& rCol
);
62 bool SetBackgroundColour(const wxColour
& rCol
);
65 // Information about this column
67 bool GetColumn( int nCol
70 bool SetColumn( int nCol
77 int GetColumnWidth(int nCol
) const;
78 bool SetColumnWidth( int nCol
83 // Gets the number of items that can fit vertically in the
84 // visible area of the list control (list or report view)
85 // or the total number of items in the list control (icon
86 // or small icon view)
88 int GetCountPerPage(void) const;
90 wxRect
GetViewRect() const;
92 // Gets the edit control for editing labels.
94 wxTextCtrl
* GetEditControl(void) const;
97 // Information about the item
99 bool GetItem(wxListItem
& rInfo
) const;
100 bool SetItem(wxListItem
& rInfo
);
103 // Sets a string field at a particular column
105 long SetItem( long lIndex
107 ,const wxString
& rsLabel
114 int GetItemState( long lItem
117 bool SetItemState( long lItem
123 // Sets the item image
125 bool SetItemImage( long lItem
133 wxString
GetItemText(long lItem
) const;
134 void SetItemText( long lItem
135 ,const wxString
& rsStr
141 long GetItemData(long lItem
) const;
142 bool SetItemData( long lItem
147 // Gets the item rectangle
149 bool GetItemRect( long lItem
151 ,int nCode
= wxLIST_RECT_BOUNDS
157 bool GetItemPosition( long lItem
160 bool SetItemPosition( long lItem
165 // Gets the number of items in the list control
167 int GetItemCount(void) const;
170 // Gets the number of columns in the list control
172 inline int GetColumnCount(void) const { return m_nColCount
; }
175 // Retrieves the spacing between icons in pixels.
176 // If small is TRUE, gets the spacing for the small icon
177 // view, otherwise the large icon view.
179 int GetItemSpacing(bool bIsSmall
) const;
182 // Foreground colour of an item.
184 wxColour
GetItemTextColour(long lItem
) const;
185 void SetItemTextColour( long lItem
186 ,const wxColour
& rCol
190 // Background colour of an item.
192 wxColour
GetItemBackgroundColour(long lItem
) const;
193 void SetItemBackgroundColour( long lItem
194 ,const wxColour
& rCol
198 // Gets the number of selected items in the list control
200 int GetSelectedItemCount(void) const;
203 // Text colour of the listview
205 wxColour
GetTextColour(void) const;
206 void SetTextColour(const wxColour
& rCol
);
209 // Gets the index of the topmost visible item when in
210 // list or report view
212 long GetTopItem(void) const;
215 // Add or remove a single window style
216 void SetSingleStyle( long lStyle
221 // Set the whole window style
223 void SetWindowStyleFlag(long lStyle
);
226 // Searches for an item, starting from 'item'.
227 // item can be -1 to find the first item that matches the
229 // Returns the item or -1 if unsuccessful.
230 long GetNextItem( long lItem
231 ,int nGeometry
= wxLIST_NEXT_ALL
232 ,int lState
= wxLIST_STATE_DONTCARE
236 // Gets one of the three image lists
238 wxImageList
* GetImageList(int nWhich
) const;
241 // Sets the image list
243 void SetImageList( wxImageList
* pImageList
246 void AssignImageList( wxImageList
* pImageList
251 // Returns true if it is a virtual list control
253 inline bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
256 // Refresh items selectively (only useful for virtual list controls)
258 void RefreshItem(long lItem
);
259 void RefreshItems( long lItemFrom
265 ////////////////////////////////////////////////////////////////////////////
269 // Arranges the items
271 bool Arrange(int nFlag
= wxLIST_ALIGN_DEFAULT
);
276 bool DeleteItem(long lItem
);
280 bool DeleteAllItems(void);
285 bool DeleteColumn(int nCol
);
288 // Deletes all columns
290 bool DeleteAllColumns(void);
293 // Clears items, and columns if there are any.
300 wxTextCtrl
* EditLabel( long lItem
301 ,wxClassInfo
* pTextControlClass
= CLASSINFO(wxTextCtrl
)
305 // End label editing, optionally cancelling the edit
307 bool EndEditLabel(bool bCancel
);
310 // Ensures this item is visible
312 bool EnsureVisible(long lItem
);
315 // Find an item whose label matches this string, starting from the item after 'start'
316 // or the beginning if 'start' is -1.
318 long FindItem( long lStart
319 ,const wxString
& rsStr
320 ,bool bPartial
= FALSE
324 // Find an item whose data matches this data, starting from the item after 'start'
325 // or the beginning if 'start' is -1.
327 long FindItem( long lStart
332 // Find an item nearest this position in the specified direction, starting from
333 // the item after 'start' or the beginning if 'start' is -1.
335 long FindItem( long lStart
336 ,const wxPoint
& rPoint
341 // Determines which item (if any) is at the specified point,
342 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
344 long HitTest( const wxPoint
& rPoint
349 // Inserts an item, returning the index of the new item if successful,
352 long InsertItem(wxListItem
& rInfo
);
355 // Insert a string item
357 long InsertItem( long lIndex
358 ,const wxString
& rsLabel
362 // Insert an image item
364 long InsertItem( long lIndex
369 // Insert an image/string item
371 long InsertItem( long lIndex
372 ,const wxString
& rsLabel
377 // For list view mode (only), inserts a column.
379 long InsertColumn( long lCol
383 long InsertColumn( long lCol
384 ,const wxString
& rsHeading
385 ,int nFormat
= wxLIST_FORMAT_LEFT
390 // set the number of items in a virtual list control
392 void SetItemCount(long lCount
);
395 // Scrolls the list control. If in icon, small icon or report view mode,
396 // x specifies the number of pixels to scroll. If in list view mode, x
397 // specifies the number of columns to scroll.
398 // If in icon, small icon or list view mode, y specifies the number of pixels
399 // to scroll. If in report view mode, y specifies the number of lines to scroll.
401 bool ScrollList( int nDx
408 // fn is a function which takes 3 long arguments: item1, item2, data.
409 // item1 is the long data associated with a first item (NOT the index).
410 // item2 is the long data associated with a second item (NOT the index).
411 // data is the same value as passed to SortItems.
412 // The return value is a negative number if the first item should precede the second
413 // item, a positive number of the second item should precede the first,
414 // or zero if the two items are equivalent.
416 // data is arbitrary data to be passed to the sort function.
418 bool SortItems( wxListCtrlCompare fn
426 virtual bool OS2Command( WXUINT uParam
430 // Bring the control in sync with current m_windowStyle value
432 void UpdateStyle(void);
435 // Implementation: converts wxWidgets style to MSW style.
436 // Can be a single style flag or a bit list.
437 // oldStyle is 'normalised' so that it doesn't contain
438 // conflicting styles.
440 long ConvertToOS2Style( long& lOldStyle
443 long ConvertArrangeToOS2Style(long lStyle
);
444 long ConvertViewToOS2Style(long lStyle
);
446 virtual MRESULT
OS2WindowProc( WXUINT uMsg
452 ////////////////////////////////////////////////////////////////////////////
453 // Necessary for drawing hrules and vrules, if specified
454 void OnPaint(wxPaintEvent
& rEvent
);
458 // common part of all ctors
463 // Free memory taken by all internal data
465 void FreeAllInternalData(void);
467 wxTextCtrl
* m_pTextCtrl
; // The control used for editing a label
468 wxImageList
* m_pImageListNormal
; // The image list for normal icons
469 wxImageList
* m_pImageListSmall
; // The image list for small icons
470 wxImageList
* m_pImageListState
; // The image list state icons (not implemented yet)
471 bool m_bOwnsImageListNormal
;
472 bool m_bOwnsImageListSmall
;
473 bool m_bOwnsImageListState
;
474 long m_lBaseStyle
; // Basic PM style flags, for recreation purposes
475 int m_nColCount
; // PM doesn't have GetColumnCount so must
476 // keep track of inserted/deleted columns
479 // TRUE if we have any internal data (user data & attributes)
481 bool m_bAnyInternalData
;
484 // TRUE if we have any items with custom attributes
489 // These functions are only used for virtual list view controls, i.e. the
490 // ones with wxLC_VIRTUAL style
492 // return the text for the given column of the given item
494 virtual wxString
OnGetItemText( long lItem
499 // Return the icon for the given item
501 virtual int OnGetItemImage(long lItem
) const;
504 // Return the attribute for the item (may return NULL if none)
506 virtual wxListItemAttr
* OnGetItemAttr(long lItem
) const;
509 bool DoCreateControl( int nX
515 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
516 DECLARE_EVENT_TABLE()
517 DECLARE_NO_COPY_CLASS(wxListCtrl
)
518 }; // end of CLASS wxListCtrl
520 #endif // wxUSE_LISTCTRL
522 #endif // _WX_LISTCTRL_H_