1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/listctrl.cpp
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/settings.h"
36 #include "wx/textctrl.h"
37 #include "wx/imaglist.h"
38 #include "wx/listctrl.h"
39 #include "wx/dcclient.h"
41 #include "wx/os2/private.h"
44 // FIELDOFFSET in DETAIL view as defined in the OS2TK45 simply doesn't work
45 // We use this, which does!
48 #define FIELDOFFSET(type, field) ((ULONG)&(((type *)0)->field))
50 // ----------------------------------------------------------------------------
51 // private helper classes
52 // ----------------------------------------------------------------------------
54 /////////////////////////////////////////////////////////////////////////////
56 // Under OS/2 we have to use our own RECORDCORE based struct if we have
57 // user data to store in a PM Container Control (and wxListCtrl is a PM
58 // Container in ICON, NAME, TEXT or DETAIL view). m_ulUserData is a four
59 // byte value containing a pointer to our CListIntemInternalData class
62 // And now for the big time OS/2 Kludge. In traditional OS/2 PM
63 // applications using containers, programmers determine BEFORE creation
64 // how many records the view will have, initially, and how many columns
65 // the detail view of the container will have, as the container represents
66 // a known data block. Thus the OS/2 PM CV_DETAIL view, i.e.
67 // the wxWidgets wxLC_REPORT view, relies on STATIC structure for its
68 // columnar data. It gets the data to display by telling it the specific
69 // offset of the field in the struct containing the displayable data. That
70 // data has be of OS/2 Types, PSZ (char string), CDATE or CTIME format.
71 // wxWidgets is dynamic in nature, however. We insert columns, one at a
72 // time and do not know how many until the app is done inserting them. So
73 // for OS/2 I have to set a max allowable since they are fixed. We return
74 // an error to the app if they include more than we can handle.
76 // For example to display the data "Col 4 of Item 6" in a report view, I'd
78 // pRecord->m_pzColumn4 = "Col 4 of Item 6";
79 // pField->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn4);
80 // and then call the PM API to set it.
82 // This really stinks but I can't use a pointer to another struct as the
83 // FIELDOFFSET call could only tell OS/2 the four byte value offset of
84 // pointer field and it would display giberish in the column.
85 /////////////////////////////////////////////////////////////////////////////
86 typedef struct _MYRECORD
89 unsigned long m_ulItemId
;
90 unsigned long m_ulUserData
; //actually a pointer value to real data (a CListItemInternalData class instance)
101 } MYRECORD
, *PMYRECORD
;
103 /////////////////////////////////////////////////////////////////////////////
104 // CLASS CListItemInternalData
107 // The MSW version had problems with SetTextColour() et al as the
108 // CListItemAttr's were stored keyed on the item index. If a item was
109 // inserted anywhere but the end of the list the the text attributes
110 // (colour etc) for the following items were out of sync.
113 // Under MSW the only way to associate data with a
114 // List item independent of its position in the list is to store a pointer
115 // to it in its lParam attribute. However user programs are already using
116 // this (via the SetItemData() GetItemData() calls).
118 // However what we can do is store a pointer to a structure which contains
119 // the attributes we want *and* a lParam for the users data, e.g.
121 // class CListItemInternalData
124 // GuiAdvCtrl_CListItemAttr* pAttr;
125 // long lParam; // user data
128 // To conserve memory, a CListItemInternalData is only allocated for a
129 // LV_ITEM if text attributes or user data(lparam) are being set.
131 // For OS/2, the lParam value points to whatever actual data we have
132 /////////////////////////////////////////////////////////////////////////////
133 class CListItemInternalData
137 CListItemInternalData(): m_pAttr(NULL
)
141 ~CListItemInternalData()
147 wxListItemAttr
* m_pAttr
;
148 WXLPARAM m_lParam
; // user data
149 PMYRECORD m_pMyRecord
; // so we can set the m_ulUserData to 0 when this is deleted
150 }; // end of CLASS CListItemInternalData
152 /////////////////////////////////////////////////////////////////////////////
153 // STRUCT SInternalDataSort
157 // fn is a function which takes 3 long arguments: item1, item2, data.
158 // item1 is the long data associated with a first item (NOT the index).
159 // item2 is the long data associated with a second item (NOT the index).
160 // data is the same value as passed to SortItems.
162 // The return value is a negative number if the first item should precede the
163 // second item, a positive number of the second item should precede the first,
164 // or zero if the two items are equivalent.
166 // data is arbitrary data to be passed to the sort function.
168 // Internal structures for proxying the user compare function
169 // so that we can pass it the *real* user data
170 /////////////////////////////////////////////////////////////////////////////
171 typedef struct internalDataSort
173 wxListCtrlCompare m_fnUser
;
175 } SInternalDataSort
; // end of STRUCT SInternalDataSort
177 // ----------------------------------------------------------------------------
178 // private helper functions
179 // ----------------------------------------------------------------------------
181 /////////////////////////////////////////////////////////////////////////////
183 // FindOS2ListFieldByColNum
185 // There is no way, under OS/2 to get a field in a container by index,
186 // directly, so you must get the first one, then cycle through the list
187 // until you get to where you want to be.
190 // hWnd -- window handle of container to search
191 // lIndex -- index to set
194 // pointer to the FIELDINFO struct at the index in the container record
196 /////////////////////////////////////////////////////////////////////////////
197 PFIELDINFO
FindOS2ListFieldByColNum (
202 PFIELDINFO pFieldInfo
= NULL
;
206 if (!::WinSendMsg( hWnd
209 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
212 for (i
= 0; i
< vCnrInfo
.cFields
; i
++)
215 pFieldInfo
= (PFIELDINFO
)PVOIDFROMMR(::WinSendMsg( hWnd
216 ,CM_QUERYDETAILFIELDINFO
221 pFieldInfo
= (PFIELDINFO
)PVOIDFROMMR(::WinSendMsg( hWnd
222 ,CM_QUERYDETAILFIELDINFO
228 if (i
== (ULONG
)lIndex
)
234 } // end of FindOS2ListFieldByColNum
236 /////////////////////////////////////////////////////////////////////////////
238 // FindOS2ListRecordByID
240 // There is no way, under OS/2 to get a record in a container by index,
241 // directly, so you must get the first one, then cycle through the list
242 // until you get to where you want to be.
245 // hWnd -- window handle of container to search
246 // lItemId -- index to set
249 // pointer to the internal RECORDCORE struct at the index in the container
251 /////////////////////////////////////////////////////////////////////////////
252 PMYRECORD
FindOS2ListRecordByID (
257 PMYRECORD pRecord
= NULL
;
261 if (!::WinSendMsg( hWnd
264 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
267 for (i
= 0; i
< vCnrInfo
.cRecords
; i
++)
270 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
273 ,MPFROM2SHORT(CMA_FIRST
, CMA_ITEMORDER
)
276 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
279 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
283 if (pRecord
->m_ulItemId
== (ULONG
)lItemId
)
287 } // end of FindOS2ListRecordByID
289 /////////////////////////////////////////////////////////////////////////////
293 // Since OS/2 does not keep native record id's but wx insists on inserting
294 // and selecting via ID's, when we insert a record in the middle we need
295 // to bump the id's of each record after the one we just inserted.
298 // hWnd -- window handle of container to search
299 // pRecord -- record after which we starting bumping id's
304 /////////////////////////////////////////////////////////////////////////////
312 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
315 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
318 pRecord
->m_ulItemId
++;
320 } // end of BumpRecordIds
322 /////////////////////////////////////////////////////////////////////////////
326 // Get the internal data given a handle and an id
329 // hWnd -- window handle to the control in which item is located
330 // lItemId -- ID to get
333 // pointer to the internal data
336 // Under OS/2 PM a container item cannot be obtained via a simple index or
337 // id retrieval. We have to walk the record list if we are looking for
338 // a record at a specific index location
339 /////////////////////////////////////////////////////////////////////////////
340 CListItemInternalData
* GetInternalData (
345 PMYRECORD pRecord
= FindOS2ListRecordByID( hWnd
349 // Internal user data is stored AFTER the last field of the RECORDCORE
353 return((CListItemInternalData
*)(pRecord
->m_ulUserData
));
354 } // end of GetInternalData
356 /////////////////////////////////////////////////////////////////////////////
360 // Get the internal data given a pointer to a list control and an id
363 // pCtl -- pointer to control inwhich item is located
364 // lItemId -- ID to get
367 // pointer to the internal data
369 /////////////////////////////////////////////////////////////////////////////
370 CListItemInternalData
* GetInternalData (
375 return(GetInternalData( (HWND
)pCtl
->GetHWND()
378 } // end of GetInternalData
380 /////////////////////////////////////////////////////////////////////////////
382 // DeleteInternalData
384 // Delete the internal data for a record
387 // pCtl -- pointer to the list control containing the record
388 // lItemId -- the record index to delete the internal data from
391 // pointer to the internal data attribute
393 /////////////////////////////////////////////////////////////////////////////
394 void DeleteInternalData (
399 CListItemInternalData
* pData
= GetInternalData( pCtl
404 if (pData
->m_pMyRecord
)
405 pData
->m_pMyRecord
->m_ulUserData
= 0;
408 } // end of DeleteInternalData
410 // #pragma page "GetInternalDataAttr"
411 /////////////////////////////////////////////////////////////////////////////
413 // GetInternalDataAttr
415 // Get the internal data item attribute given a pointer to a list control
419 // pCtl -- pointer to control to set
420 // lItemId -- ID to set
423 // pointer to the internal data attribute
425 /////////////////////////////////////////////////////////////////////////////
426 wxListItemAttr
* GetInternalDataAttr (
431 CListItemInternalData
* pData
= GetInternalData( pCtl
436 return(pData
->m_pAttr
);
439 } // end of GetInternalDataAttr
441 /////////////////////////////////////////////////////////////////////////////
443 // InternalDataCompareFunc
445 // This is compare function we pass to PM. It wraps the real compare
446 // function in SInternalDataSort
449 // p1 -- is the first record structure to compare
450 // p2 -- is the second record structure to compare
451 // lStorage -- is the same value as passed to SortItems.
454 // pointer to the internal data attribute
456 /////////////////////////////////////////////////////////////////////////////
457 SHORT EXPENTRY
InternalDataCompareFunc (
463 SInternalDataSort
* pInternalData
= (SInternalDataSort
*)pStorage
;
464 CListItemInternalData
* pData1
= (CListItemInternalData
*)p1
->m_ulUserData
;
465 CListItemInternalData
* pData2
= (CListItemInternalData
*)p2
->m_ulUserData
;
466 long lD1
= (pData1
== NULL
? 0 : (long)pData1
->m_lParam
);
467 long lD2
= (pData2
== NULL
? 0 : (long)pData2
->m_lParam
);
469 return(pInternalData
->m_fnUser( lD1
471 ,pInternalData
->m_lData
473 } // end of InternalDataCompareFunc
475 /////////////////////////////////////////////////////////////////////////////
477 // ConvertFromOS2ListItem
479 // Convert from an internal PM List item to a Toolkit List item
482 // hWndListCtrl -- the control's windows handle
483 // rInfo -- the library list control to convert to
484 // pRecord -- the OS list control to convert from
489 /////////////////////////////////////////////////////////////////////////////
490 void ConvertFromOS2ListItem (
496 CListItemInternalData
* pInternaldata
= (CListItemInternalData
*)pRecord
->m_ulUserData
;
497 bool bNeedText
= FALSE
;
500 rInfo
.SetData(pInternaldata
->m_lParam
);
504 rInfo
.SetStateMask(0);
505 rInfo
.SetId((long)pRecord
->m_ulItemId
);
506 if (hWndListCtrl
!= 0)
508 pRecord
= FindOS2ListRecordByID( hWndListCtrl
514 // The wxListItem class is really set up to handle the WIN32 list item
515 // and OS/2 are not as complicated. Just set both state members to the
516 // same thing under OS/2
518 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_DROPONABLE
)
520 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_DROPHILITED
);
521 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_DROPHILITED
);
523 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_SELECTED
)
525 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_SELECTED
);
526 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_SELECTED
);
528 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_DISABLED
)
530 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_DISABLED
);
531 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_DISABLED
);
533 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_FILTERED
)
535 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_FILTERED
);
536 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_FILTERED
);
538 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_INUSE
)
540 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_INUSE
);
541 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_INUSE
);
543 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_PICKED
)
545 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_PICKED
);
546 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_PICKED
);
548 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_SOURCE
)
550 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_SOURCE
);
551 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_SOURCE
);
554 if (pRecord
->m_vRecord
.pszText
!= (PSZ
)NULL
)
556 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_TEXT
);
557 rInfo
.SetText(pRecord
->m_vRecord
.pszText
);
559 if (pRecord
->m_vRecord
.pszIcon
!= (PSZ
)NULL
||
560 pRecord
->m_vRecord
.pszName
!= (PSZ
)NULL
)
562 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_IMAGE
);
563 rInfo
.SetImage(pRecord
->m_vRecord
.hptrIcon
);
565 if (pRecord
->m_ulUserData
)
566 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_DATA
);
567 } // end of ConvertFromOS2ListItem
569 /////////////////////////////////////////////////////////////////////////////
573 // Convert from an library states to OS states
576 // lState -- the state
577 // pRecord -- the OS list control to use
582 /////////////////////////////////////////////////////////////////////////////
583 void ConvertToOS2Flags (
588 if (lState
& wxLIST_STATE_DROPHILITED
)
589 pRecord
->m_vRecord
.flRecordAttr
|= CRA_DROPONABLE
;
590 if (lState
& wxLIST_STATE_SELECTED
)
591 pRecord
->m_vRecord
.flRecordAttr
|= CRA_SELECTED
;
592 if (lState
& wxLIST_STATE_DISABLED
)
593 pRecord
->m_vRecord
.flRecordAttr
|= CRA_DISABLED
;
594 if (lState
& wxLIST_STATE_FILTERED
)
595 pRecord
->m_vRecord
.flRecordAttr
|= CRA_FILTERED
;
596 if (lState
& wxLIST_STATE_INUSE
)
597 pRecord
->m_vRecord
.flRecordAttr
|= CRA_INUSE
;
598 if (lState
& wxLIST_STATE_PICKED
)
599 pRecord
->m_vRecord
.flRecordAttr
|= CRA_PICKED
;
600 if (lState
& wxLIST_STATE_SOURCE
)
601 pRecord
->m_vRecord
.flRecordAttr
|= CRA_SOURCE
;
602 } // end of ConvertToOS2Flags
604 /////////////////////////////////////////////////////////////////////////////
606 // ConvertToOS2ListItem
608 // Convert from a library List item to an internal OS2 List item. We set
609 // only the fields we need to set. Some of them are set by the API when
610 // they are added to the container.
613 // pCtrl -- the control to use
614 // rInfo -- the item to convert
615 // pRecord -- the OS list control to use, should be zeroed out
616 // pFieldinfo -- a field struct that may contain columnar data for detail view
621 /////////////////////////////////////////////////////////////////////////////
622 void ConvertToOS2ListItem (
623 const wxListCtrl
* pCtrl
624 , const wxListItem
& rInfo
626 , PFIELDINFO pFieldInfo
629 pRecord
->m_ulItemId
= (ULONG
)rInfo
.GetId();
630 pRecord
->m_vRecord
.cb
= sizeof(RECORDCORE
);
631 if (rInfo
.GetMask() & wxLIST_MASK_STATE
)
633 ConvertToOS2Flags( rInfo
.m_state
637 if (pCtrl
->GetWindowStyleFlag() & wxLC_ICON
||
638 pCtrl
->GetWindowStyleFlag() & wxLC_SMALL_ICON
)
640 pRecord
->m_vRecord
.pszIcon
= (char*)rInfo
.GetText().c_str();
642 if (pCtrl
->GetWindowStyleFlag() & wxLC_LIST
) // PM TEXT view
644 pRecord
->m_vRecord
.pszText
= (char*)rInfo
.GetText().c_str();
647 // In the case of a report view the text will be the data in the lead column
648 // ???? Don't know why, but that is how it works in other ports.
650 if (pCtrl
->GetWindowStyleFlag() & wxLC_REPORT
)
654 switch(rInfo
.GetColumn())
657 pRecord
->m_pzColumn1
= (char*)rInfo
.GetText().c_str();
658 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn1
);
662 pRecord
->m_pzColumn2
= (char*)rInfo
.GetText().c_str();
663 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn2
);
667 pRecord
->m_pzColumn3
= (char*)rInfo
.GetText().c_str();
668 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn3
);
672 pRecord
->m_pzColumn4
= (char*)rInfo
.GetText().c_str();
673 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn4
);
677 pRecord
->m_pzColumn5
= (char*)rInfo
.GetText().c_str();
678 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn5
);
682 pRecord
->m_pzColumn6
= (char*)rInfo
.GetText().c_str();
683 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn6
);
687 pRecord
->m_pzColumn7
= (char*)rInfo
.GetText().c_str();
688 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn7
);
692 pRecord
->m_pzColumn8
= (char*)rInfo
.GetText().c_str();
693 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn8
);
697 pRecord
->m_pzColumn9
= (char*)rInfo
.GetText().c_str();
698 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn9
);
702 pRecord
->m_pzColumn10
= (char*)rInfo
.GetText().c_str();
703 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn10
);
707 wxFAIL_MSG( _T("wxOS2 does not support more than 10 columns in REPORT view") );
712 if (rInfo
.GetMask() & wxLIST_MASK_IMAGE
)
714 pRecord
->m_vRecord
.hptrIcon
= (HPOINTER
)rInfo
.GetImage();
715 pRecord
->m_vRecord
.hptrMiniIcon
= (HPOINTER
)rInfo
.m_miniImage
;
717 } // end of ConvertToOS2ListItem
719 /////////////////////////////////////////////////////////////////////////////
721 // ConvertToOS2ListCol
723 // Convert from a library List column to an internal PM List column
726 // lCol -- the columnd to convert
727 // rItem -- the item to convert
728 // pField -- the OS list column to use
733 /////////////////////////////////////////////////////////////////////////////
734 void ConvertToOS2ListCol (
736 , const wxListItem
& rItem
740 memset(pField
, '\0', sizeof(FIELDINFO
));
741 pField
->cb
= sizeof(FIELDINFO
);
744 // Default some settings
746 pField
->flData
= CFA_HORZSEPARATOR
| CFA_SEPARATOR
;
747 pField
->flTitle
= CFA_CENTER
;
749 if (rItem
.GetMask() & wxLIST_MASK_TEXT
)
751 pField
->flData
|= CFA_STRING
;
752 pField
->pTitleData
= (PVOID
)rItem
.GetText().c_str(); // text is column title not data
754 if (rItem
.GetMask() & wxLIST_MASK_FORMAT
)
756 if (rItem
.m_format
== wxLIST_FORMAT_LEFT
)
757 pField
->flData
|= CFA_LEFT
;
758 else if (rItem
.m_format
== wxLIST_FORMAT_RIGHT
)
759 pField
->flData
|= CFA_RIGHT
;
760 else if (rItem
.m_format
== wxLIST_FORMAT_CENTRE
)
761 pField
->flData
|= CFA_CENTER
;
764 pField
->flData
|= CFA_CENTER
; // Just ensure the default is centered
765 if (rItem
.GetMask() & wxLIST_MASK_WIDTH
)
767 if (!(rItem
.GetWidth() == wxLIST_AUTOSIZE
||
768 rItem
.GetWidth() == wxLIST_AUTOSIZE_USEHEADER
))
769 pField
->cxWidth
= rItem
.GetWidth();
770 // else: OS/2 automatically sets the width if created with the approppriate style
774 // Still need to set the actual data
776 pField
->offStruct
= 0;
777 } // end of ConvertToOS2ListCol
779 // ----------------------------------------------------------------------------
781 // ----------------------------------------------------------------------------
783 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG
)
784 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG
)
785 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
)
786 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT
)
787 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM
)
788 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
)
789 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO
)
790 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO
)
791 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED
)
792 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED
)
793 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN
)
794 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM
)
795 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK
)
796 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK
)
797 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG
)
798 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING
)
799 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG
)
800 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
)
801 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
)
802 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED
)
803 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED
)
804 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT
)
806 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
807 IMPLEMENT_DYNAMIC_CLASS(wxListView
, wxListCtrl
)
808 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
810 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
812 BEGIN_EVENT_TABLE(wxListCtrl
, wxControl
)
813 EVT_PAINT(wxListCtrl::OnPaint
)
816 // ============================================================================
818 // ============================================================================
820 // ----------------------------------------------------------------------------
821 // wxListCtrl construction
822 // ----------------------------------------------------------------------------
824 void wxListCtrl::Init ()
826 m_pImageListNormal
= NULL
;
827 m_pImageListSmall
= NULL
;
828 m_pImageListState
= NULL
;
829 m_bOwnsImageListNormal
= FALSE
;
830 m_bOwnsImageListSmall
= FALSE
;
831 m_bOwnsImageListState
= FALSE
;
835 m_bAnyInternalData
= FALSE
;
836 m_bHasAnyAttr
= FALSE
;
837 } // end of wxListCtrl::Init
839 bool wxListCtrl::Create (
842 , const wxPoint
& rPos
843 , const wxSize
& rSize
845 , const wxValidator
& rValidator
846 , const wxString
& rsName
851 int nWidth
= rSize
.x
;
852 int nHeight
= rSize
.y
;
855 SetValidator(rValidator
);
856 #endif // wxUSE_VALIDATORS
859 SetWindowStyleFlag(lStyle
);
870 m_windowId
= (vId
== -1) ? NewControlId() : vId
;
872 long lSstyle
= WS_VISIBLE
| WS_TABSTOP
;
874 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
875 lSstyle
|= WS_CLIPSIBLINGS
;
876 m_lBaseStyle
= lSstyle
;
877 if (!DoCreateControl( nX
884 pParent
->AddChild(this);
886 } // end of wxListCtrl::Create
888 bool wxListCtrl::DoCreateControl (
895 DWORD lWstyle
= m_lBaseStyle
;
896 long lOldStyle
= 0; // Dummy
900 lWstyle
|= ConvertToOS2Style( lOldStyle
901 ,GetWindowStyleFlag()
904 m_hWnd
= (WXHWND
)::WinCreateWindow( GetParent()->GetHWND()
909 ,GetParent()->GetHWND()
921 // Now set the display attributes of the container
923 if (!::WinSendMsg( GetHWND()
926 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
929 lWstyle
= ConvertViewToOS2Style(GetWindowStyleFlag());
930 vCnrInfo
.flWindowAttr
|= lWstyle
;
931 if (!::WinSendMsg( GetHWND()
934 ,(MPARAM
)CMA_FLWINDOWATTR
939 // And now set needed arrangement flags
941 lWstyle
= ConvertArrangeToOS2Style(GetWindowStyleFlag());
942 if (!::WinSendMsg( GetHWND()
944 ,(MPARAM
)CMA_ARRANGEGRID
948 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
));
949 SetForegroundColour(GetParent()->GetForegroundColour());
951 SetFont(*wxSMALL_FONT
);
960 } // end of wxListCtrl::DoCreateControl
962 void wxListCtrl::UpdateStyle ()
967 DWORD dwStyleNew
= ConvertToOS2Style( lDummy
968 ,GetWindowStyleFlag()
971 dwStyleNew
|= m_lBaseStyle
;
974 // Get the current window style.
976 ULONG dwStyleOld
= ::WinQueryWindowULong(GetHWND(), QWL_STYLE
);
979 // Only set the window style if the view bits have changed.
981 if (dwStyleOld
!= dwStyleNew
)
983 ::WinSetWindowULong(GetHWND(), QWL_STYLE
, dwStyleNew
);
986 } // end of wxListCtrl::UpdateStyle
988 void wxListCtrl::FreeAllInternalData ()
990 if (m_bAnyInternalData
)
992 int n
= GetItemCount();
995 for (i
= 0; i
< n
; i
++)
996 DeleteInternalData(this, (long)i
);
997 m_bAnyInternalData
= FALSE
;
999 } // end of wxListCtrl::FreeAllInternalData
1001 wxListCtrl::~wxListCtrl ()
1003 FreeAllInternalData();
1006 m_pTextCtrl
->SetHWND(0);
1007 m_pTextCtrl
->UnsubclassWin();
1012 if (m_bOwnsImageListNormal
)
1013 delete m_pImageListNormal
;
1014 if (m_bOwnsImageListSmall
)
1015 delete m_pImageListSmall
;
1016 if (m_bOwnsImageListState
)
1017 delete m_pImageListState
;
1018 } // end of wxListCtrl::~wxListCtrl
1020 // ----------------------------------------------------------------------------
1021 // set/get/change style
1022 // ----------------------------------------------------------------------------
1024 // Add or remove a single window style
1025 void wxListCtrl::SetSingleStyle (
1030 long lFlag
= GetWindowStyleFlag();
1033 // Get rid of conflicting styles
1037 if (lStyle
& wxLC_MASK_TYPE
)
1038 lFlag
= lFlag
& ~wxLC_MASK_TYPE
;
1039 if (lStyle
& wxLC_MASK_ALIGN
)
1040 lFlag
= lFlag
& ~wxLC_MASK_ALIGN
;
1041 if (lStyle
& wxLC_MASK_SORT
)
1042 lFlag
= lFlag
& ~wxLC_MASK_SORT
;
1056 m_windowStyle
= lFlag
;
1058 } // end of wxListCtrl::SetSingleStyle
1060 // Set the whole window style
1061 void wxListCtrl::SetWindowStyleFlag (
1065 m_windowStyle
= lFlag
;
1067 } // end of wxListCtrl::SetWindowStyleFlag
1069 long wxListCtrl::ConvertToOS2Style (
1077 // The only styles OS2 uses on creation are auto arrange, read only, and
1078 // and selection styles. This lib does not support OS/2 MINIRECORDCORE
1079 // or VERIFYPOINTER styles
1081 if (lStyle
& wxLC_AUTOARRANGE
)
1082 lWstyle
|= CCS_AUTOPOSITION
;
1083 if (lStyle
& wxLC_SINGLE_SEL
)
1084 lWstyle
|= CCS_SINGLESEL
;
1086 lWstyle
|= CCS_EXTENDSEL
;
1087 if (!(lStyle
& wxLC_EDIT_LABELS
))
1088 lWstyle
|= CCS_READONLY
;
1090 } // end of wxListCtrl::ConvertToOS2Style
1092 long wxListCtrl::ConvertArrangeToOS2Style (
1098 if (lStyle
& wxLC_ALIGN_LEFT
)
1100 lWstyle
|= CMA_LEFT
;
1103 if (lStyle
& wxLC_ALIGN_TOP
)
1108 } // end of wxListCtrl::ConvertArrangeToOS2Style
1110 long wxListCtrl::ConvertViewToOS2Style (
1114 long lWstyle
= CA_DRAWICON
; // we will only use icons
1116 if (lStyle
& wxLC_ICON
)
1120 if (lStyle
& wxLC_SMALL_ICON
)
1122 lWstyle
|= (CV_ICON
| CV_MINI
);
1124 if (lStyle
& wxLC_LIST
)
1128 if (lStyle
& wxLC_REPORT
)
1130 lWstyle
|= CV_DETAIL
;
1132 if (lStyle
& wxLC_VIRTUAL
)
1134 lWstyle
|= CA_OWNERDRAW
;
1136 if (lStyle
& wxLC_AUTOARRANGE
)
1140 if (!(lStyle
& wxLC_NO_HEADER
))
1142 lWstyle
|= CA_DETAILSVIEWTITLES
;
1145 } // end of wxListCtrl::ConvertViewToOS2Style
1147 // ----------------------------------------------------------------------------
1149 // ----------------------------------------------------------------------------
1151 // Sets the foreground, i.e. text, colour
1152 bool wxListCtrl::SetForegroundColour (
1153 const wxColour
& rCol
)
1155 ULONG ulColor
= wxColourToRGB(rCol
);
1157 if (!wxWindow::SetForegroundColour(rCol
))
1161 ::WinSetPresParam( GetHWND()
1167 } // end of wxListCtrl::SetForegroundColour
1169 // Sets the background colour
1170 bool wxListCtrl::SetBackgroundColour (
1171 const wxColour
& rCol
1174 if (!wxWindow::SetBackgroundColour(rCol
))
1178 // We set the same colour for both the "empty" background and the items
1181 ULONG ulColor
= wxColourToRGB(rCol
);
1183 ::WinSetPresParam( GetHWND()
1189 } // end of wxListCtrl::SetBackgroundColour
1191 // Gets information about this column
1192 bool wxListCtrl::GetColumn (
1197 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND()
1203 rItem
.SetWidth(pFieldInfo
->cxWidth
);
1204 if ((rItem
.GetMask() & wxLIST_MASK_TEXT
) &&
1205 (pFieldInfo
->flData
& CFA_STRING
) &&
1206 (pFieldInfo
->pUserData
!= NULL
))
1208 rItem
.SetText((char*)pFieldInfo
->pUserData
);
1210 if (rItem
.GetMask() & wxLIST_MASK_FORMAT
)
1212 if (pFieldInfo
->flData
& CFA_LEFT
)
1213 rItem
.m_format
= wxLIST_FORMAT_LEFT
;
1214 else if (pFieldInfo
->flData
& CFA_RIGHT
)
1215 rItem
.m_format
= wxLIST_FORMAT_RIGHT
;
1216 else if (pFieldInfo
->flData
& CFA_CENTER
)
1217 rItem
.m_format
= wxLIST_FORMAT_CENTRE
;
1220 } // end of wxListCtrl::GetColumn
1222 // Sets information about this column
1223 bool wxListCtrl::SetColumn (
1228 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum( GetHWND()
1231 ConvertToOS2ListCol( nCol
1236 // Since we changed the field pointed to, we invalidate to see the result
1238 ::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO
, NULL
, NULL
);
1240 } // end of wxListCtrl::SetColumn
1242 // Gets the column width
1243 int wxListCtrl::GetColumnWidth (
1247 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND()
1253 return((int)pFieldInfo
->cxWidth
);
1254 } // end of wxListCtrl::GetColumnWidth
1256 // Sets the column width
1257 bool wxListCtrl::SetColumnWidth (
1263 int nWidth2
= nWidth
;
1265 if (GetWindowStyleFlag() & wxLC_LIST
)
1268 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum( GetHWND()
1271 pFieldInfo
->cxWidth
= nWidth
;
1272 ::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO
, NULL
, NULL
);
1274 } // end of wxListCtrl::SetColumnWidth
1276 // Gets the number of items that can fit vertically in the
1277 // visible area of the list control (list or report view)
1278 // or the total number of items in the list control (icon
1279 // or small icon view)
1280 int wxListCtrl::GetCountPerPage () const
1282 QUERYRECORDRECT vQueryRect
;
1288 if (!::WinSendMsg( GetHWND()
1291 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1294 memset(&vQueryRect
, '\0', sizeof(QUERYRECORDRECT
));
1295 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1296 if (vCnrInfo
.flWindowAttr
& CV_ICON
)
1297 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1298 else if (vCnrInfo
.flWindowAttr
& CV_NAME
)
1299 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1300 else if (vCnrInfo
.flWindowAttr
& CV_TEXT
)
1301 vQueryRect
.fsExtent
= CMA_TEXT
;
1302 else if (vCnrInfo
.flWindowAttr
& CV_DETAIL
)
1303 vQueryRect
.fsExtent
= CMA_TEXT
;
1304 if (!::WinSendMsg( GetHWND()
1306 ,MPFROMP(&vRectRecord
)
1307 ,MPFROMP(&vQueryRect
)
1310 if (!::WinSendMsg( GetHWND()
1311 ,CM_QUERYVIEWPORTRECT
1312 ,MPFROMP(&vRectControl
)
1313 ,MPFROM2SHORT(CMA_WINDOW
, (USHORT
)FALSE
)
1316 nCount
= (int)((int)((vRectControl
.xRight
- vRectControl
.xLeft
) / (vRectRecord
.xRight
- vRectRecord
.xLeft
)) *
1317 (int)((vRectControl
.yTop
- vRectControl
.yBottom
) / (vRectRecord
.yTop
- vRectRecord
.yBottom
))
1319 if (nCount
> (int)vCnrInfo
.cFields
)
1320 nCount
= (int)vCnrInfo
.cFields
;
1322 } // end of wxListCtrl::GetCountPerPage
1324 // Gets the edit control for editing labels.
1325 wxTextCtrl
* wxListCtrl::GetEditControl() const
1330 // Gets information about the item
1331 bool wxListCtrl::GetItem (
1335 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1340 // Give NULL as hwnd as we already have everything we need
1342 ConvertFromOS2ListItem( NULL
1347 } // end of wxListCtrl::GetItem
1349 // Sets information about the item
1350 bool wxListCtrl::SetItem (
1354 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND()
1357 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1361 ConvertToOS2ListItem( this
1368 // Check if setting attributes or lParam
1370 if (rInfo
.HasAttributes() || (rInfo
.GetMask() & wxLIST_MASK_DATA
))
1373 // Get internal item data
1374 // perhaps a cache here ?
1376 CListItemInternalData
* pData
= GetInternalData( this
1385 m_bAnyInternalData
= TRUE
;
1386 pData
= new CListItemInternalData();
1387 pRecord
->m_ulUserData
= (unsigned long)pData
;
1393 if (rInfo
.GetMask() & wxLIST_MASK_DATA
)
1394 pData
->m_lParam
= (WXLPARAM
)rInfo
.GetData();
1397 if (rInfo
.HasAttributes())
1400 *pData
->m_pAttr
= *rInfo
.GetAttributes();
1402 pData
->m_pAttr
= new wxListItemAttr(*rInfo
.GetAttributes());
1404 pData
->m_pMyRecord
= pRecord
; // they point to each other
1408 // We need to update the item immediately to show the new image
1410 bool bUpdateNow
= (rInfo
.GetMask() & wxLIST_MASK_IMAGE
) != 0;
1413 // Check whether it has any custom attributes
1415 if (rInfo
.HasAttributes())
1417 m_bHasAnyAttr
= TRUE
;
1420 // If the colour has changed, we must redraw the item
1424 if (::WinIsWindowVisible(GetHWND()))
1426 ::WinSendMsg( GetHWND()
1427 ,CM_INVALIDATERECORD
1429 ,MPFROM2SHORT(1, CMA_ERASE
| CMA_REPOSITION
| CMA_TEXTCHANGED
)
1431 RefreshItem(pRecord
->m_ulItemId
);
1433 ::WinSendMsg( GetHWND()
1434 ,CM_INVALIDATEDETAILFIELDINFO
1439 } // end of wxListCtrl::SetItem
1441 long wxListCtrl::SetItem (
1444 , const wxString
& rsLabel
1450 vInfo
.m_text
= rsLabel
;
1451 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1452 vInfo
.m_itemId
= lIndex
;
1456 vInfo
.m_image
= nImageId
;
1457 vInfo
.m_mask
|= wxLIST_MASK_IMAGE
;
1459 return SetItem(vInfo
);
1460 } // end of wxListCtrl::SetItem
1462 // Gets the item state
1463 int wxListCtrl::GetItemState (
1470 vInfo
.m_mask
= wxLIST_MASK_STATE
;
1471 vInfo
.m_stateMask
= lStateMask
;
1472 vInfo
.m_itemId
= lItem
;
1474 if (!GetItem(vInfo
))
1476 return vInfo
.m_state
;
1477 } // end of wxListCtrl::GetItemState
1479 // Sets the item state
1480 bool wxListCtrl::SetItemState (
1486 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1491 // Don't use SetItem() here as it doesn't work with the virtual list
1494 ConvertToOS2Flags( lState
1499 // for the virtual list controls we need to refresh the previously focused
1500 // item manually when changing focus without changing selection
1501 // programmatically because otherwise it keeps its focus rectangle until
1502 // next repaint (yet another comctl32 bug)
1507 (lStateMask
& wxLIST_STATE_FOCUSED
) &&
1508 (lState
& wxLIST_STATE_FOCUSED
) )
1510 lFocusOld
= GetNextItem( -1
1512 ,wxLIST_STATE_FOCUSED
1519 ::WinSendMsg( GetHWND()
1520 ,CM_INVALIDATERECORD
1522 ,MPFROM2SHORT(1, CMA_ERASE
| CMA_REPOSITION
| CMA_TEXTCHANGED
)
1525 if (lFocusOld
!= -1)
1528 // No need to refresh the item if it was previously selected, it would
1529 // only result in annoying flicker
1531 if (!(GetItemState( lFocusOld
1532 ,wxLIST_STATE_SELECTED
1533 ) & wxLIST_STATE_SELECTED
))
1535 RefreshItem(lFocusOld
);
1539 } // end of wxListCtrl::SetItemState
1541 // Sets the item image
1542 bool wxListCtrl::SetItemImage (
1545 , int WXUNUSED(nSelImage
))
1547 return SetItemColumnInfo(lItem
, 0, nImage
);
1548 } // end of wxListCtrl::SetItemImage
1550 // Sets the item image
1551 bool wxListCtrl::SetItemColumnImage (
1558 vInfo
.m_mask
= wxLIST_MASK_IMAGE
;
1559 vInfo
.m_image
= nImage
;
1560 vInfo
.m_itemId
= lItem
;
1561 vInfo
.m_col
= lColumn
;
1562 return SetItem(vInfo
);
1563 } // end of wxListCtrl::SetItemColumnImage
1565 // Gets the item text
1566 wxString
wxListCtrl::GetItemText (
1572 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1573 vInfo
.m_itemId
= lItem
;
1575 if (!GetItem(vInfo
))
1576 return wxEmptyString
;
1577 return vInfo
.m_text
;
1578 } // end of wxListCtrl::GetItemText
1580 // Sets the item text
1581 void wxListCtrl::SetItemText (
1583 , const wxString
& rsStr
1588 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1589 vInfo
.m_itemId
= lItem
;
1590 vInfo
.m_text
= rsStr
;
1592 } // end of wxListCtrl::SetItemText
1594 // Gets the item data
1595 long wxListCtrl::GetItemData (
1601 vInfo
.m_mask
= wxLIST_MASK_DATA
;
1602 vInfo
.m_itemId
= lItem
;
1603 if (!GetItem(vInfo
))
1605 return vInfo
.m_data
;
1606 } // end of wxListCtrl::GetItemData
1608 // Sets the item data
1609 bool wxListCtrl::SetItemData (
1616 vInfo
.m_mask
= wxLIST_MASK_DATA
;
1617 vInfo
.m_itemId
= lItem
;
1618 vInfo
.m_data
= lData
;
1619 return SetItem(vInfo
);
1620 } // end of wxListCtrl::SetItemData
1622 // Gets the item rectangle
1623 bool wxListCtrl::GetItemRect (
1630 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1633 QUERYRECORDRECT vQueryRect
;
1639 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1640 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
1641 vQueryRect
.fRightSplitWindow
= TRUE
;
1642 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1643 ::WinSendMsg( GetHWND()
1646 ,MPFROMP(&vQueryRect
)
1649 // remember OS/2 is backwards
1654 rRect
.x
= vRect
.xLeft
;
1655 rRect
.y
= nHeight
- vRect
.yTop
;
1656 rRect
.width
= vRect
.xRight
;
1657 rRect
.height
= nHeight
- vRect
.yBottom
;
1660 } // end of wxListCtrl::GetItemRect
1662 // Gets the item position
1663 bool wxListCtrl::GetItemPosition (
1669 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1672 QUERYRECORDRECT vQueryRect
;
1678 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1679 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
1680 vQueryRect
.fRightSplitWindow
= TRUE
;
1681 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1682 ::WinSendMsg( GetHWND()
1685 ,MPFROMP(&vQueryRect
)
1688 // remember OS/2 is backwards
1693 rPos
.x
= vRect
.xLeft
;
1694 rPos
.y
= nHeight
- vRect
.yTop
;
1697 } // end of wxListCtrl::GetItemPosition
1699 // Sets the item position.
1700 bool wxListCtrl::SetItemPosition (
1702 , const wxPoint
& rPos
1706 // Items cannot be positioned in X/Y coord in OS/2
1709 } // end of wxListCtrl::SetItemPosition
1711 // Gets the number of items in the list control
1712 int wxListCtrl::GetItemCount () const
1716 if (!::WinSendMsg( GetHWND()
1719 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1722 return vCnrInfo
.cRecords
;
1723 } // end of wxListCtrl::GetItemCount
1725 // Retrieves the spacing between icons in pixels.
1726 // If small is TRUE, gets the spacing for the small icon
1727 // view, otherwise the large icon view.
1728 int wxListCtrl::GetItemSpacing (
1734 if (!::WinSendMsg( GetHWND()
1737 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1740 return vCnrInfo
.cyLineSpacing
;
1741 } // end of wxListCtrl::GetItemSpacing
1743 void wxListCtrl::SetItemTextColour (
1745 , const wxColour
& rCol
1750 vInfo
.m_itemId
= lItem
;
1751 vInfo
.SetTextColour(rCol
);
1753 } // end of wxListCtrl::SetItemTextColour
1755 wxColour
wxListCtrl::GetItemTextColour (
1761 vInfo
.m_itemId
= lItem
;
1763 return vInfo
.GetTextColour();
1764 } // end of wxListCtrl::GetItemTextColour
1766 void wxListCtrl::SetItemBackgroundColour (
1768 , const wxColour
& rCol
1773 vInfo
.m_itemId
= lItem
;
1774 vInfo
.SetBackgroundColour(rCol
);
1776 } // end of wxListCtrl::SetItemBackgroundColour
1778 wxColour
wxListCtrl::GetItemBackgroundColour (
1784 vInfo
.m_itemId
= lItem
;
1786 return vInfo
.GetBackgroundColour();
1787 } // end of wxListCtrl::GetItemBackgroundColour
1789 // Gets the number of selected items in the list control
1790 int wxListCtrl::GetSelectedItemCount () const
1792 PMYRECORD pRecord
= NULL
;
1794 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
1795 ,CM_QUERYRECORDEMPHASIS
1797 ,(MPARAM
)CRA_SELECTED
1805 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
1806 ,CM_QUERYRECORDEMPHASIS
1808 ,(MPARAM
)CRA_SELECTED
1814 } // end of wxListCtrl::GetSelectedItemCount
1816 // Gets the text colour of the listview
1817 wxColour
wxListCtrl::GetTextColour () const
1822 ::WinQueryPresParam( GetHWND()
1832 } // end of wxListCtrl::GetTextColour
1834 // Sets the text colour of the listview
1835 void wxListCtrl::SetTextColour (
1836 const wxColour
& rCol
1839 ULONG ulColor
= wxColourToRGB(rCol
);
1841 ::WinSetPresParam( GetHWND()
1846 } // end of wxListCtrl::SetTextColour
1848 // Gets the index of the topmost visible item when in
1849 // list or report view
1850 long wxListCtrl::GetTopItem () const
1852 PMYRECORD pRecord
= NULL
;
1853 QUERYRECFROMRECT vQueryRect
;
1856 ::WinSendMsg( GetHWND()
1857 ,CM_QUERYVIEWPORTRECT
1859 ,MPFROM2SHORT(CMA_WINDOW
, TRUE
)
1861 vQueryRect
.cb
= sizeof(QUERYRECFROMRECT
);
1862 vQueryRect
.rect
= vRect
;
1863 vQueryRect
.fsSearch
= CMA_PARTIAL
;
1865 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
1866 ,CM_QUERYRECORDFROMRECT
1868 ,MPFROMP(&vQueryRect
)
1873 return (long)pRecord
->m_ulItemId
;
1874 } // end of wxListCtrl::GetTopItem
1876 // Searches for an item, starting from 'item'.
1877 // 'geometry' is one of
1878 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1879 // 'state' is a state bit flag, one or more of
1880 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1881 // item can be -1 to find the first item that matches the
1883 // Returns the item or -1 if unsuccessful.
1884 long wxListCtrl::GetNextItem (
1886 , int WXUNUSED(nGeom
)
1887 , int WXUNUSED(nState
)
1890 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1894 pRecord
= (PMYRECORD
)pRecord
->m_vRecord
.preccNextRecord
;
1896 return((long)pRecord
->m_ulItemId
);
1898 } // end of wxListCtrl::GetNextItem
1900 wxImageList
* wxListCtrl::GetImageList (
1904 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1906 return m_pImageListNormal
;
1908 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1910 return m_pImageListSmall
;
1912 else if (nWhich
== wxIMAGE_LIST_STATE
)
1914 return m_pImageListState
;
1917 } // end of wxListCtrl::GetImageList
1919 void wxListCtrl::SetImageList (
1920 wxImageList
* pImageList
1924 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1926 if (m_bOwnsImageListNormal
)
1927 delete m_pImageListNormal
;
1928 m_pImageListNormal
= pImageList
;
1929 m_bOwnsImageListNormal
= FALSE
;
1931 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1933 if (m_bOwnsImageListSmall
)
1934 delete m_pImageListSmall
;
1935 m_pImageListSmall
= pImageList
;
1936 m_bOwnsImageListSmall
= FALSE
;
1938 else if (nWhich
== wxIMAGE_LIST_STATE
)
1940 if (m_bOwnsImageListState
)
1941 delete m_pImageListState
;
1942 m_pImageListState
= pImageList
;
1943 m_bOwnsImageListState
= FALSE
;
1945 } // end of wxListCtrl::SetImageList
1947 void wxListCtrl::AssignImageList (
1948 wxImageList
* pImageList
1952 SetImageList( pImageList
1955 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1956 m_bOwnsImageListNormal
= TRUE
;
1957 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1958 m_bOwnsImageListSmall
= TRUE
;
1959 else if (nWhich
== wxIMAGE_LIST_STATE
)
1960 m_bOwnsImageListState
= TRUE
;
1961 } // end of wxListCtrl::AssignImageList
1963 // ----------------------------------------------------------------------------
1965 // ----------------------------------------------------------------------------
1967 // Arranges the items
1968 bool wxListCtrl::Arrange (
1975 if (nFlag
== wxLIST_ALIGN_SNAP_TO_GRID
)
1977 ulType
= CMA_ARRANGEGRID
;
1978 if (nFlag
== wxLIST_ALIGN_LEFT
)
1979 ulFlags
|= CMA_LEFT
;
1980 else if (nFlag
== wxLIST_ALIGN_TOP
)
1982 else if (nFlag
== wxLIST_ALIGN_DEFAULT
)
1983 ulFlags
|= CMA_LEFT
;
1986 ulType
= CMA_ARRANGESTANDARD
;
1987 ::WinSendMsg( GetHWND()
1993 // We do not support CMA_ARRANGESELECTED
1996 } // end of wxListCtrl::Arrange
1999 bool wxListCtrl::DeleteItem (
2003 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2006 if (LONGFROMMR(::WinSendMsg( GetHWND()
2009 ,MPFROM2SHORT(1, CMA_FREE
)
2016 // The virtual list control doesn't refresh itself correctly, help it
2021 // We need to refresh all the lines below the one which was deleted
2025 if (lItem
> 0 && GetItemCount())
2027 GetItemRect( lItem
- 1
2033 vRectItem
.y
= vRectItem
.height
= 0;
2035 wxRect vRectWin
= GetRect();
2037 vRectWin
.height
= vRectWin
.GetBottom() - vRectItem
.GetBottom();
2038 vRectWin
.y
= vRectItem
.GetBottom();
2039 RefreshRect(vRectWin
);
2042 } // end of wxListCtrl::DeleteItem
2044 // Deletes all items
2045 bool wxListCtrl::DeleteAllItems ()
2047 return((LONG
)::WinSendMsg( GetHWND()
2050 ,MPFROM2SHORT(0, CMA_FREE
)
2052 } // end of wxListCtrl::DeleteAllItems
2054 // Deletes all items
2055 bool wxListCtrl::DeleteAllColumns ()
2057 while (m_nColCount
> 0)
2059 DeleteColumn(m_nColCount
- 1);
2063 wxASSERT_MSG(m_nColCount
== 0, wxT("no columns should be left"));
2065 } // end of wxListCtrl::DeleteAllColumns
2068 bool wxListCtrl::DeleteColumn (
2072 bool bSuccess
= FALSE
;
2073 PFIELDINFO pField
= FindOS2ListFieldByColNum( GetHWND()
2076 bSuccess
= ((LONG
)::WinSendMsg( GetHWND()
2077 ,CM_REMOVEDETAILFIELDINFO
2079 ,MPFROM2SHORT((SHORT
)1, CMA_FREE
)
2081 if (bSuccess
&& (m_nColCount
> 0))
2084 } // end of wxListCtrl::DeleteColumn
2086 // Clears items, and columns if there are any.
2087 void wxListCtrl::ClearAll ()
2090 if (m_nColCount
> 0)
2092 } // end of wxListCtrl::ClearAll
2095 // OS/2 does not use a text control for its container labels. You merely
2096 // "open" a record for editting.
2098 wxTextCtrl
* wxListCtrl::EditLabel (
2100 , wxClassInfo
* WXUNUSED(pTextControlClass
)
2104 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2108 vEdit
.cb
= sizeof(CNREDITDATA
);
2109 vEdit
.hwndCnr
= GetHWND();
2110 vEdit
.pRecord
= &pRecord
->m_vRecord
;
2111 vEdit
.pFieldInfo
= NULL
;
2112 vEdit
.ppszText
= NULL
;
2116 ::WinSendMsg( GetHWND()
2122 } // end of wxListCtrl::EditLabel
2124 // End label editing, optionally cancelling the edit. Under OS/2 you close
2125 // the record for editting
2126 bool wxListCtrl::EndEditLabel (
2127 bool WXUNUSED(bCancel
)
2130 ::WinSendMsg( GetHWND()
2136 } // end of wxListCtrl::EndEditLabel
2138 // Ensures this item is visible
2139 bool wxListCtrl::EnsureVisible (
2143 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2146 ::WinSendMsg( GetHWND()
2147 ,CM_INVALIDATERECORD
2149 ,MPFROM2SHORT((SHORT
)1, CMA_NOREPOSITION
)
2152 } // end of wxListCtrl::EnsureVisible
2154 // Find an item whose label matches this string, starting from the item after 'start'
2155 // or the beginning if 'start' is -1.
2156 long wxListCtrl::FindItem (
2158 , const wxString
& rsStr
2163 SEARCHSTRING vSearch
;
2164 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2170 if (!::WinSendMsg( GetHWND()
2173 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
2177 if (vCnrInfo
.flWindowAttr
& CV_ICON
)
2179 if (vCnrInfo
.flWindowAttr
& CV_NAME
)
2181 if (vCnrInfo
.flWindowAttr
& CV_TEXT
)
2183 if (vCnrInfo
.flWindowAttr
& CV_DETAIL
)
2186 ulFlag
|= CV_EXACTLENGTH
;
2188 vSearch
.cb
= sizeof(SEARCHSTRING
);
2189 vSearch
.pszSearch
= (char*)rsStr
.c_str();
2190 vSearch
.fsPrefix
= TRUE
;
2191 vSearch
.fsCaseSensitive
= TRUE
;
2192 vSearch
.usView
= ulFlag
;
2196 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2204 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2212 return pRecord
->m_ulItemId
;
2213 } // end of wxListCtrl::FindItem
2215 // Find an item whose data matches this data, starting from the item after 'start'
2216 // or the beginning if 'start' is -1.
2217 long wxListCtrl::FindItem (
2222 long lIdx
= lStart
+ 1;
2223 long lCount
= GetItemCount();
2225 while (lIdx
< lCount
)
2227 if (GetItemData(lIdx
) == lData
)
2232 } // end of wxListCtrl::FindItem
2234 // Find an item nearest this position in the specified direction, starting from
2235 // the item after 'start' or the beginning if 'start' is -1.
2236 long wxListCtrl::FindItem (
2238 , const wxPoint
& rPoint
2243 QUERYRECORDRECT vQueryRect
;
2244 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2251 if (!::WinSendMsg( GetHWND()
2254 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
2258 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
2259 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
2260 vQueryRect
.fRightSplitWindow
= TRUE
;
2261 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
2263 ::WinSendMsg( GetHWND()
2266 ,MPFROMP(&vQueryRect
)
2268 vLibRect
.SetLeft(vRect
.xLeft
);
2269 vLibRect
.SetTop(vRect
.yTop
);
2270 vLibRect
.SetRight(vRect
.xRight
);
2271 vLibRect
.SetBottom(vRect
.yBottom
);
2272 if (vLibRect
.Inside(rPoint
))
2273 return pRecord
->m_ulItemId
;
2275 for (i
= lStart
+ 1; i
< vCnrInfo
.cRecords
; i
++)
2277 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
2280 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
2282 vQueryRect
.pRecord
= (PRECORDCORE
)pRecord
;
2283 ::WinSendMsg( GetHWND()
2286 ,MPFROMP(&vQueryRect
)
2288 vLibRect
.SetLeft(vRect
.xLeft
);
2289 vLibRect
.SetTop(vRect
.yTop
);
2290 vLibRect
.SetRight(vRect
.xRight
);
2291 vLibRect
.SetBottom(vRect
.yBottom
);
2292 if (vLibRect
.Inside(rPoint
))
2293 return pRecord
->m_ulItemId
;
2296 } // end of wxListCtrl::FindItem
2298 // Determines which item (if any) is at the specified point,
2299 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
2300 long wxListCtrl::HitTest (
2301 const wxPoint
& rPoint
2302 , int& WXUNUSED(rFlags
)
2305 PMYRECORD pRecord
= NULL
;
2306 QUERYRECFROMRECT vQueryRect
;
2311 // Get height for OS/2 point conversion
2313 ::WinSendMsg( GetHWND()
2314 ,CM_QUERYVIEWPORTRECT
2316 ,MPFROM2SHORT(CMA_WINDOW
, TRUE
)
2318 lHeight
= vRect
.yTop
- vRect
.yBottom
;
2321 // For now just try and get a record in the general vicinity and forget
2324 vRect
.xLeft
= rPoint
.x
- 2;
2325 vRect
.xRight
= rPoint
.x
+ 2;
2326 vRect
.yTop
= (lHeight
- rPoint
.y
) + 2;
2327 vRect
.yBottom
= (lHeight
- rPoint
.y
) - 2;
2329 vQueryRect
.cb
= sizeof(QUERYRECFROMRECT
);
2330 vQueryRect
.rect
= vRect
;
2331 vQueryRect
.fsSearch
= CMA_PARTIAL
;
2333 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2334 ,CM_QUERYRECORDFROMRECT
2336 ,MPFROMP(&vQueryRect
)
2341 return pRecord
->m_ulItemId
;
2342 } // end of wxListCtrl::HitTest
2344 // Inserts an item, returning the index of the new item if successful,
2346 long wxListCtrl::InsertItem (
2350 wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
2352 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND()
2355 PMYRECORD pRecordAfter
= NULL
;
2356 PMYRECORD pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2358 ,MPFROMLONG(sizeof(MYRECORD
) - sizeof(RECORDCORE
))
2362 ConvertToOS2ListItem( this
2368 if (rInfo
.GetId() > 0)
2369 pRecordAfter
= FindOS2ListRecordByID( GetHWND()
2373 RECORDINSERT vInsert
;
2375 vInsert
.cb
= sizeof(RECORDINSERT
);
2376 vInsert
.pRecordParent
= NULL
;
2378 vInsert
.pRecordOrder
= (PRECORDCORE
)CMA_FIRST
;
2380 vInsert
.pRecordOrder
= (PRECORDCORE
)pRecordAfter
;
2381 vInsert
.zOrder
= CMA_TOP
;
2382 vInsert
.cRecordsInsert
= 1;
2383 vInsert
.fInvalidateRecord
= TRUE
;
2386 // Check wether we need to allocate our internal data
2388 bool bNeedInternalData
= ((rInfo
.GetMask() & wxLIST_MASK_DATA
) ||
2389 rInfo
.HasAttributes()
2391 if (bNeedInternalData
)
2393 m_bAnyInternalData
= TRUE
;
2396 // Internal stucture that manages data
2398 CListItemInternalData
* pData
= new CListItemInternalData();
2400 pRecord
->m_ulUserData
= (unsigned long)pData
;
2401 if (rInfo
.GetMask() & wxLIST_MASK_DATA
)
2402 pData
->m_lParam
= (WXLPARAM
)rInfo
.GetData();
2405 // Check whether it has any custom attributes
2407 if (rInfo
.HasAttributes())
2410 // Take copy of attributes
2412 pData
->m_pAttr
= new wxListItemAttr(*rInfo
.GetAttributes());
2415 if (!::WinSendMsg( GetHWND()
2422 // OS/2 must mannually bump the index's of following records
2424 BumpRecordIds( GetHWND()
2427 ::WinSendMsg( GetHWND()
2428 ,CM_INVALIDATEDETAILFIELDINFO
2432 return pRecord
->m_ulItemId
;
2433 } // end of wxListCtrl::InsertItem
2435 long wxListCtrl::InsertItem (
2437 , const wxString
& rsLabel
2442 memset(&vInfo
, '\0', sizeof(wxListItem
));
2443 vInfo
.m_text
= rsLabel
;
2444 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
2445 vInfo
.m_itemId
= lIndex
;
2446 return InsertItem(vInfo
);
2447 } // end of wxListCtrl::InsertItem
2449 // Inserts an image item
2450 long wxListCtrl::InsertItem (
2457 vInfo
.m_image
= nImageIndex
;
2458 vInfo
.m_mask
= wxLIST_MASK_IMAGE
;
2459 vInfo
.m_itemId
= lIndex
;
2460 return InsertItem(vInfo
);
2461 } // end of wxListCtrl::InsertItem
2463 // Inserts an image/string item
2464 long wxListCtrl::InsertItem (
2466 , const wxString
& rsLabel
2472 vInfo
.m_image
= nImageIndex
;
2473 vInfo
.m_text
= rsLabel
;
2474 vInfo
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2475 vInfo
.m_itemId
= lIndex
;
2476 return InsertItem(vInfo
);
2477 } // end of wxListCtrl::InsertItem
2479 // For details view mode (only), inserts a column.
2480 long wxListCtrl::InsertColumn (
2486 PFIELDINFO pField
= (PFIELDINFO
)::WinSendMsg( GetHWND()
2487 ,CM_ALLOCDETAILFIELDINFO
2491 PFIELDINFO pFieldAfter
= FindOS2ListFieldByColNum ( GetHWND()
2494 FIELDINFOINSERT vInsert
;
2496 ConvertToOS2ListCol ( lCol
2501 vInsert
.cb
= sizeof(FIELDINFOINSERT
);
2502 vInsert
.pFieldInfoOrder
= pFieldAfter
;
2503 vInsert
.fInvalidateFieldInfo
= TRUE
;
2504 vInsert
.cFieldInfoInsert
= 1;
2506 bSuccess
= ::WinSendMsg( GetHWND()
2507 ,CM_INSERTDETAILFIELDINFO
2512 } // end of wxListCtrl::InsertColumn
2514 long wxListCtrl::InsertColumn (
2516 , const wxString
& rsHeading
2523 vItem
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2524 vItem
.m_text
= rsHeading
;
2527 vItem
.m_mask
|= wxLIST_MASK_WIDTH
;
2528 vItem
.m_width
= nWidth
;
2530 vItem
.m_format
= nFormat
;
2532 return InsertColumn( lCol
2535 } // end of wxListCtrl::InsertColumn
2537 // scroll the control by the given number of pixels (exception: in list view,
2538 // dx is interpreted as number of columns)
2539 bool wxListCtrl::ScrollList (
2545 ::WinSendMsg( GetHWND()
2547 ,(MPARAM
)CMA_HORIZONTAL
2551 ::WinSendMsg( GetHWND()
2553 ,(MPARAM
)CMA_VERTICAL
2557 } // end of wxListCtrl::ScrollList
2559 bool wxListCtrl::SortItems (
2560 wxListCtrlCompare fn
2564 SInternalDataSort vInternalData
;
2566 vInternalData
.m_fnUser
= fn
;
2567 vInternalData
.m_lData
= lData
;
2569 // WPARAM cast is needed for mingw/cygwin
2570 if (!::WinSendMsg( GetHWND()
2572 ,(PFN
)InternalDataCompareFunc
2573 ,(PVOID
)&vInternalData
2576 wxLogDebug(_T("CM_SORTRECORD failed"));
2580 } // end of wxListCtrl::SortItems
2582 // ----------------------------------------------------------------------------
2583 // message processing
2584 // ----------------------------------------------------------------------------
2586 bool wxListCtrl::OS2Command (
2591 if (uCmd
== CN_ENDEDIT
)
2593 wxCommandEvent
vEvent( wxEVT_COMMAND_TEXT_UPDATED
2597 vEvent
.SetEventObject( this );
2598 ProcessCommand(vEvent
);
2601 else if (uCmd
== CN_KILLFOCUS
)
2603 wxCommandEvent
vEvent( wxEVT_KILL_FOCUS
2606 vEvent
.SetEventObject( this );
2607 ProcessCommand(vEvent
);
2612 } // end of wxListCtrl::OS2Command
2614 // Necessary for drawing hrules and vrules, if specified
2615 void wxListCtrl::OnPaint (
2616 wxPaintEvent
& rEvent
2619 wxPaintDC
vDc(this);
2620 wxPen
vPen(wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT
)
2624 wxSize vClientSize
= GetClientSize();
2626 int nItemCount
= GetItemCount();
2629 bool bDrawHRules
= ((GetWindowStyle() & wxLC_HRULES
) != 0);
2630 bool bDrawVRules
= ((GetWindowStyle() & wxLC_VRULES
) != 0);
2632 wxControl::OnPaint(rEvent
);
2635 // Reset the device origin since it may have been set
2637 vDc
.SetDeviceOrigin(0, 0);
2638 if (!bDrawHRules
&& !bDrawVRules
)
2640 if ((GetWindowStyle() & wxLC_REPORT
) == 0)
2643 vDc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2647 long lTop
= GetTopItem();
2649 for (i
= lTop
; i
< lTop
+ GetCountPerPage() + 1; i
++)
2655 nCy
= vItemRect
.GetTop();
2656 if (i
!= 0) // Don't draw the first one
2665 if (i
== nItemCount
- 1)
2667 nCy
= vItemRect
.GetBottom();
2678 if (bDrawVRules
&& (i
> -1))
2680 wxRect vFirstItemRect
;
2690 int nX
= vItemRect
.GetX();
2692 for (nCol
= 0; nCol
< GetColumnCount(); nCol
++)
2694 int nColWidth
= GetColumnWidth(nCol
);
2697 vDc
.DrawLine( nX
- 1
2698 ,vFirstItemRect
.GetY() - 2
2700 ,vItemRect
.GetBottom()
2705 } // end of wxListCtrl::OnPaint
2707 // ----------------------------------------------------------------------------
2708 // virtual list controls
2709 // ----------------------------------------------------------------------------
2711 wxString
wxListCtrl::OnGetItemText (
2712 long WXUNUSED(lItem
)
2713 , long WXUNUSED(lCol
)
2716 // this is a pure virtual function, in fact - which is not really pure
2717 // because the controls which are not virtual don't need to implement it
2718 wxFAIL_MSG( _T("not supposed to be called") );
2719 return wxEmptyString
;
2720 } // end of wxListCtrl::OnGetItemText
2722 int wxListCtrl::OnGetItemImage (
2723 long WXUNUSED(lItem
)
2727 wxFAIL_MSG( _T("not supposed to be called") );
2729 } // end of wxListCtrl::OnGetItemImage
2731 int wxListCtrl::OnGetItemColumnImage (
2737 return OnGetItemImage(lItem
);
2740 } // end of wxListCtrl::OnGetItemColumnImage
2742 wxListItemAttr
* wxListCtrl::OnGetItemAttr (
2743 long WXUNUSED_UNLESS_DEBUG(lItem
)
2746 wxASSERT_MSG( lItem
>= 0 && lItem
< GetItemCount(),
2747 _T("invalid item index in OnGetItemAttr()") );
2750 // No attributes by default
2753 } // end of wxListCtrl::OnGetItemAttr
2755 void wxListCtrl::SetItemCount (
2759 wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
2762 // Cannot explicitly set the record count in OS/2
2764 } // end of wxListCtrl::SetItemCount
2766 void wxListCtrl::RefreshItem (
2776 } // end of wxListCtrl::RefreshItem
2778 void wxListCtrl::RefreshItems (
2786 GetItemRect( lItemFrom
2789 GetItemRect( lItemTo
2793 wxRect vRect
= vRect1
;
2795 vRect
.height
= vRect2
.GetBottom() - vRect1
.GetTop();
2797 } // end of wxListCtrl::RefreshItems
2799 MRESULT
wxListCtrl::OS2WindowProc(
2805 bool bProcessed
= FALSE
;
2807 wxListEvent
vEvent( wxEVT_NULL
2810 wxEventType vEventType
= wxEVT_NULL
;
2811 PCNRDRAGINIT pDragInit
= NULL
;
2812 PCNREDITDATA pEditData
= NULL
;
2813 PNOTIFYRECORDENTER pNotifyEnter
= NULL
;
2815 vEvent
.SetEventObject(this);
2820 // First off let's set some internal data
2822 switch(SHORT2FROMMP(wParam
))
2828 CListItemInternalData
* pInternaldata
= (CListItemInternalData
*)lParam
;
2832 wxListItem
* pItem
= (wxListItem
*)&vEvent
.GetItem();
2834 pItem
->SetData((long)pInternaldata
->m_lParam
);
2840 // Now let's go through the codes we're interested in
2842 switch(SHORT2FROMMP(wParam
))
2845 pDragInit
= (PCNRDRAGINIT
)lParam
;
2848 PMYRECORD pRecord
= (PMYRECORD
)pDragInit
->pRecord
;
2850 vEventType
= wxEVT_COMMAND_LIST_BEGIN_RDRAG
;
2851 vEvent
.m_itemIndex
= pRecord
->m_ulItemId
;
2852 vEvent
.m_pointDrag
.x
= pDragInit
->x
;
2853 vEvent
.m_pointDrag
.y
= pDragInit
->y
;
2858 pEditData
= (PCNREDITDATA
)lParam
;
2861 vEventType
= wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
;
2862 ConvertFromOS2ListItem( GetHWND()
2863 ,(wxListItem
&)vEvent
.GetItem()
2864 ,(PMYRECORD
)pEditData
->pRecord
2866 vEvent
.m_itemIndex
= vEvent
.GetItem().GetId();
2871 pEditData
= (PCNREDITDATA
)lParam
;
2874 vEventType
= wxEVT_COMMAND_LIST_END_LABEL_EDIT
;
2875 ConvertFromOS2ListItem( GetHWND()
2876 ,(wxListItem
&)vEvent
.GetItem()
2877 ,(PMYRECORD
)pEditData
->pRecord
2879 if (pEditData
->cbText
== 0)
2880 return (MRESULT
)FALSE
;
2881 vEvent
.m_itemIndex
= vEvent
.GetItem().GetId();
2886 pNotifyEnter
= (PNOTIFYRECORDENTER
)lParam
;
2889 wxListItem
* pItem
= (wxListItem
*)&vEvent
.GetItem();
2890 PMYRECORD pMyRecord
= (PMYRECORD
)pNotifyEnter
->pRecord
;
2892 vEventType
= wxEVT_COMMAND_LIST_ITEM_ACTIVATED
;
2893 vEvent
.m_itemIndex
= pMyRecord
->m_ulItemId
;
2894 pItem
->SetText(GetItemText(pMyRecord
->m_ulItemId
));
2895 pItem
->SetData(GetItemData(pMyRecord
->m_ulItemId
));
2900 // Add the CN_DROP messages for Direct Manipulation
2903 vEvent
.SetEventType(vEventType
);
2904 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
2908 lRc
= wxControl::OS2WindowProc( uMsg
2913 } // end of wxListCtrl::WindowProc
2915 #endif // wxUSE_LISTCTRL