]>
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;
91 // Gets the edit control for editing labels.
93 wxTextCtrl
* GetEditControl(void) const;
96 // Information about the item
98 bool GetItem(wxListItem
& rInfo
) const;
99 bool SetItem(wxListItem
& rInfo
);
102 // Sets a string field at a particular column
104 long SetItem( long lIndex
106 ,const wxString
& rsLabel
113 int GetItemState( long lItem
116 bool SetItemState( long lItem
122 // Sets the item image
124 bool SetItemImage( long lItem
132 wxString
GetItemText(long lItem
) const;
133 void SetItemText( long lItem
134 ,const wxString
& rsStr
140 long GetItemData(long lItem
) const;
141 bool SetItemData( long lItem
146 // Gets the item rectangle
148 bool GetItemRect( long lItem
150 ,int nCode
= wxLIST_RECT_BOUNDS
156 bool GetItemPosition( long lItem
159 bool SetItemPosition( long lItem
164 // Gets the number of items in the list control
166 int GetItemCount(void) const;
169 // Gets the number of columns in the list control
171 inline int GetColumnCount(void) const { return m_nColCount
; }
174 // Retrieves the spacing between icons in pixels.
175 // If small is TRUE, gets the spacing for the small icon
176 // view, otherwise the large icon view.
178 int GetItemSpacing(bool bIsSmall
) const;
181 // Foreground colour of an item.
183 wxColour
GetItemTextColour(long lItem
) const;
184 void SetItemTextColour( long lItem
185 ,const wxColour
& rCol
189 // Background colour of an item.
191 wxColour
GetItemBackgroundColour(long lItem
) const;
192 void SetItemBackgroundColour( long lItem
193 ,const wxColour
& rCol
197 // Gets the number of selected items in the list control
199 int GetSelectedItemCount(void) const;
202 // Text colour of the listview
204 wxColour
GetTextColour(void) const;
205 void SetTextColour(const wxColour
& rCol
);
208 // Gets the index of the topmost visible item when in
209 // list or report view
211 long GetTopItem(void) const;
214 // Add or remove a single window style
215 void SetSingleStyle( long lStyle
220 // Set the whole window style
222 void SetWindowStyleFlag(long lStyle
);
225 // Searches for an item, starting from 'item'.
226 // item can be -1 to find the first item that matches the
228 // Returns the item or -1 if unsuccessful.
229 long GetNextItem( long lItem
230 ,int nGeometry
= wxLIST_NEXT_ALL
231 ,int lState
= wxLIST_STATE_DONTCARE
235 // Gets one of the three image lists
237 wxImageList
* GetImageList(int nWhich
) const;
240 // Sets the image list
242 void SetImageList( wxImageList
* pImageList
245 void AssignImageList( wxImageList
* pImageList
250 // Returns true if it is a virtual list control
252 inline bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL
) != 0; }
255 // Refresh items selectively (only useful for virtual list controls)
257 void RefreshItem(long lItem
);
258 void RefreshItems( long lItemFrom
264 ////////////////////////////////////////////////////////////////////////////
268 // Arranges the items
270 bool Arrange(int nFlag
= wxLIST_ALIGN_DEFAULT
);
275 bool DeleteItem(long lItem
);
279 bool DeleteAllItems(void);
284 bool DeleteColumn(int nCol
);
287 // Deletes all columns
289 bool DeleteAllColumns(void);
292 // Clears items, and columns if there are any.
299 wxTextCtrl
* EditLabel( long lItem
300 ,wxClassInfo
* pTextControlClass
= CLASSINFO(wxTextCtrl
)
304 // End label editing, optionally cancelling the edit
306 bool EndEditLabel(bool bCancel
);
309 // Ensures this item is visible
311 bool EnsureVisible(long lItem
);
314 // Find an item whose label matches this string, starting from the item after 'start'
315 // or the beginning if 'start' is -1.
317 long FindItem( long lStart
318 ,const wxString
& rsStr
319 ,bool bPartial
= FALSE
323 // Find an item whose data matches this data, starting from the item after 'start'
324 // or the beginning if 'start' is -1.
326 long FindItem( long lStart
331 // Find an item nearest this position in the specified direction, starting from
332 // the item after 'start' or the beginning if 'start' is -1.
334 long FindItem( long lStart
335 ,const wxPoint
& rPoint
340 // Determines which item (if any) is at the specified point,
341 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
343 long HitTest( const wxPoint
& rPoint
348 // Inserts an item, returning the index of the new item if successful,
351 long InsertItem(wxListItem
& rInfo
);
354 // Insert a string item
356 long InsertItem( long lIndex
357 ,const wxString
& rsLabel
361 // Insert an image item
363 long InsertItem( long lIndex
368 // Insert an image/string item
370 long InsertItem( long lIndex
371 ,const wxString
& rsLabel
376 // For list view mode (only), inserts a column.
378 long InsertColumn( long lCol
382 long InsertColumn( long lCol
383 ,const wxString
& rsHeading
384 ,int nFormat
= wxLIST_FORMAT_LEFT
389 // set the number of items in a virtual list control
391 void SetItemCount(long lCount
);
394 // Scrolls the list control. If in icon, small icon or report view mode,
395 // x specifies the number of pixels to scroll. If in list view mode, x
396 // specifies the number of columns to scroll.
397 // If in icon, small icon or list view mode, y specifies the number of pixels
398 // to scroll. If in report view mode, y specifies the number of lines to scroll.
400 bool ScrollList( int nDx
407 // fn is a function which takes 3 long arguments: item1, item2, data.
408 // item1 is the long data associated with a first item (NOT the index).
409 // item2 is the long data associated with a second item (NOT the index).
410 // data is the same value as passed to SortItems.
411 // The return value is a negative number if the first item should precede the second
412 // item, a positive number of the second item should precede the first,
413 // or zero if the two items are equivalent.
415 // data is arbitrary data to be passed to the sort function.
417 bool SortItems( wxListCtrlCompare fn
425 virtual bool OS2Command( WXUINT uParam
429 // Bring the control in sync with current m_windowStyle value
431 void UpdateStyle(void);
434 // Implementation: converts wxWindows style to MSW style.
435 // Can be a single style flag or a bit list.
436 // oldStyle is 'normalised' so that it doesn't contain
437 // conflicting styles.
439 long ConvertToOS2Style( long& lOldStyle
442 long ConvertArrangeToOS2Style(long lStyle
);
443 long ConvertViewToOS2Style(long lStyle
);
445 virtual MRESULT
OS2WindowProc( WXUINT uMsg
451 ////////////////////////////////////////////////////////////////////////////
452 // Necessary for drawing hrules and vrules, if specified
453 void OnPaint(wxPaintEvent
& rEvent
);
457 // common part of all ctors
462 // Free memory taken by all internal data
464 void FreeAllInternalData(void);
466 wxTextCtrl
* m_pTextCtrl
; // The control used for editing a label
467 wxImageList
* m_pImageListNormal
; // The image list for normal icons
468 wxImageList
* m_pImageListSmall
; // The image list for small icons
469 wxImageList
* m_pImageListState
; // The image list state icons (not implemented yet)
470 bool m_bOwnsImageListNormal
;
471 bool m_bOwnsImageListSmall
;
472 bool m_bOwnsImageListState
;
473 long m_lBaseStyle
; // Basic PM style flags, for recreation purposes
474 int m_nColCount
; // PM doesn't have GetColumnCount so must
475 // keep track of inserted/deleted columns
478 // TRUE if we have any internal data (user data & attributes)
480 bool m_bAnyInternalData
;
483 // TRUE if we have any items with custom attributes
488 // These functions are only used for virtual list view controls, i.e. the
489 // ones with wxLC_VIRTUAL style
491 // return the text for the given column of the given item
493 virtual wxString
OnGetItemText( long lItem
498 // Return the icon for the given item
500 virtual int OnGetItemImage(long lItem
) const;
503 // Return the attribute for the item (may return NULL if none)
505 virtual wxListItemAttr
* OnGetItemAttr(long lItem
) const;
508 bool DoCreateControl( int nX
514 DECLARE_DYNAMIC_CLASS(wxListCtrl
)
515 DECLARE_EVENT_TABLE()
516 DECLARE_NO_COPY_CLASS(wxListCtrl
)
517 }; // end of CLASS wxListCtrl
519 #endif // wxUSE_LISTCTRL
521 #endif // _WX_LISTCTRL_H_