1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/listctrl.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
32 #include "wx/settings.h"
33 #include "wx/dcclient.h"
34 #include "wx/textctrl.h"
37 #include "wx/imaglist.h"
38 #include "wx/listctrl.h"
40 #include "wx/os2/private.h"
43 // FIELDOFFSET in DETAIL view as defined in the OS2TK45 simply doesn't work
44 // We use this, which does!
47 #define FIELDOFFSET(type, field) ((ULONG)&(((type *)0)->field))
49 // ----------------------------------------------------------------------------
50 // private helper classes
51 // ----------------------------------------------------------------------------
53 /////////////////////////////////////////////////////////////////////////////
55 // Under OS/2 we have to use our own RECORDCORE based struct if we have
56 // user data to store in a PM Container Control (and wxListCtrl is a PM
57 // Container in ICON, NAME, TEXT or DETAIL view). m_ulUserData is a four
58 // byte value containing a pointer to our CListIntemInternalData class
61 // And now for the big time OS/2 Kludge. In traditional OS/2 PM
62 // applications using containers, programmers determine BEFORE creation
63 // how many records the view will have, initially, and how many columns
64 // the detail view of the container will have, as the container represents
65 // a known data block. Thus the OS/2 PM CV_DETAIL view, i.e.
66 // the wxWidgets wxLC_REPORT view, relies on STATIC structure for its
67 // columnar data. It gets the data to display by telling it the specific
68 // offset of the field in the struct containing the displayable data. That
69 // data has be of OS/2 Types, PSZ (char string), CDATE or CTIME format.
70 // wxWidgets is dynamic in nature, however. We insert columns, one at a
71 // time and do not know how many until the app is done inserting them. So
72 // for OS/2 I have to set a max allowable since they are fixed. We return
73 // an error to the app if they include more than we can handle.
75 // For example to display the data "Col 4 of Item 6" in a report view, I'd
77 // pRecord->m_pzColumn4 = "Col 4 of Item 6";
78 // pField->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn4);
79 // and then call the PM API to set it.
81 // This really stinks but I can't use a pointer to another struct as the
82 // FIELDOFFSET call could only tell OS/2 the four byte value offset of
83 // pointer field and it would display giberish in the column.
84 /////////////////////////////////////////////////////////////////////////////
85 typedef struct _MYRECORD
88 unsigned long m_ulItemId
;
89 unsigned long m_ulUserData
; //actually a pointer value to real data (a CListItemInternalData class instance)
100 } MYRECORD
, *PMYRECORD
;
102 /////////////////////////////////////////////////////////////////////////////
103 // CLASS CListItemInternalData
106 // The MSW version had problems with SetTextColour() et al as the
107 // CListItemAttr's were stored keyed on the item index. If a item was
108 // inserted anywhere but the end of the list the text attributes
109 // (colour etc) for the following items were out of sync.
112 // Under MSW the only way to associate data with a
113 // List item independent of its position in the list is to store a pointer
114 // to it in its lParam attribute. However user programs are already using
115 // this (via the SetItemData() GetItemData() calls).
117 // However what we can do is store a pointer to a structure which contains
118 // the attributes we want *and* a lParam for the users data, e.g.
120 // class CListItemInternalData
123 // GuiAdvCtrl_CListItemAttr* pAttr;
124 // long lParam; // user data
127 // To conserve memory, a CListItemInternalData is only allocated for a
128 // LV_ITEM if text attributes or user data(lparam) are being set.
130 // For OS/2, the lParam value points to whatever actual data we have
131 /////////////////////////////////////////////////////////////////////////////
132 class CListItemInternalData
136 CListItemInternalData(): m_pAttr(NULL
)
140 ~CListItemInternalData()
145 wxListItemAttr
* m_pAttr
;
146 WXLPARAM m_lParam
; // user data
147 PMYRECORD m_pMyRecord
; // so we can set the m_ulUserData to 0 when this is deleted
148 }; // end of CLASS CListItemInternalData
150 /////////////////////////////////////////////////////////////////////////////
151 // STRUCT SInternalDataSort
155 // fn is a function which takes 3 long arguments: item1, item2, data.
156 // item1 is the long data associated with a first item (NOT the index).
157 // item2 is the long data associated with a second item (NOT the index).
158 // data is the same value as passed to SortItems.
160 // The return value is a negative number if the first item should precede the
161 // second item, a positive number of the second item should precede the first,
162 // or zero if the two items are equivalent.
164 // data is arbitrary data to be passed to the sort function.
166 // Internal structures for proxying the user compare function
167 // so that we can pass it the *real* user data
168 /////////////////////////////////////////////////////////////////////////////
169 typedef struct internalDataSort
171 wxListCtrlCompare m_fnUser
;
173 } SInternalDataSort
; // end of STRUCT SInternalDataSort
175 // ----------------------------------------------------------------------------
176 // private helper functions
177 // ----------------------------------------------------------------------------
179 /////////////////////////////////////////////////////////////////////////////
181 // FindOS2ListFieldByColNum
183 // There is no way, under OS/2 to get a field in a container by index,
184 // directly, so you must get the first one, then cycle through the list
185 // until you get to where you want to be.
188 // hWnd -- window handle of container to search
189 // lIndex -- index to set
192 // pointer to the FIELDINFO struct at the index in the container record
194 /////////////////////////////////////////////////////////////////////////////
195 PFIELDINFO
FindOS2ListFieldByColNum (
200 PFIELDINFO pFieldInfo
= NULL
;
204 if (!::WinSendMsg( hWnd
207 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
210 for (i
= 0; i
< vCnrInfo
.cFields
; i
++)
213 pFieldInfo
= (PFIELDINFO
)PVOIDFROMMR(::WinSendMsg( hWnd
214 ,CM_QUERYDETAILFIELDINFO
219 pFieldInfo
= (PFIELDINFO
)PVOIDFROMMR(::WinSendMsg( hWnd
220 ,CM_QUERYDETAILFIELDINFO
226 if (i
== (ULONG
)lIndex
)
232 } // end of FindOS2ListFieldByColNum
234 /////////////////////////////////////////////////////////////////////////////
236 // FindOS2ListRecordByID
238 // There is no way, under OS/2 to get a record in a container by index,
239 // directly, so you must get the first one, then cycle through the list
240 // until you get to where you want to be.
243 // hWnd -- window handle of container to search
244 // lItemId -- index to set
247 // pointer to the internal RECORDCORE struct at the index in the container
249 /////////////////////////////////////////////////////////////////////////////
250 PMYRECORD
FindOS2ListRecordByID (
255 PMYRECORD pRecord
= NULL
;
259 if (!::WinSendMsg( hWnd
262 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
265 for (i
= 0; i
< vCnrInfo
.cRecords
; i
++)
268 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
271 ,MPFROM2SHORT(CMA_FIRST
, CMA_ITEMORDER
)
274 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
277 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
281 if (pRecord
->m_ulItemId
== (ULONG
)lItemId
)
285 } // end of FindOS2ListRecordByID
287 /////////////////////////////////////////////////////////////////////////////
291 // Since OS/2 does not keep native record id's but wx insists on inserting
292 // and selecting via ID's, when we insert a record in the middle we need
293 // to bump the id's of each record after the one we just inserted.
296 // hWnd -- window handle of container to search
297 // pRecord -- record after which we starting bumping id's
302 /////////////////////////////////////////////////////////////////////////////
310 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( hWnd
313 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
316 pRecord
->m_ulItemId
++;
318 } // end of BumpRecordIds
320 /////////////////////////////////////////////////////////////////////////////
324 // Get the internal data given a handle and an id
327 // hWnd -- window handle to the control in which item is located
328 // lItemId -- ID to get
331 // pointer to the internal data
334 // Under OS/2 PM a container item cannot be obtained via a simple index or
335 // id retrieval. We have to walk the record list if we are looking for
336 // a record at a specific index location
337 /////////////////////////////////////////////////////////////////////////////
338 CListItemInternalData
* GetInternalData (
343 PMYRECORD pRecord
= FindOS2ListRecordByID( hWnd
347 // Internal user data is stored AFTER the last field of the RECORDCORE
351 return((CListItemInternalData
*)(pRecord
->m_ulUserData
));
352 } // end of GetInternalData
354 /////////////////////////////////////////////////////////////////////////////
358 // Get the internal data given a pointer to a list control and an id
361 // pCtl -- pointer to control inwhich item is located
362 // lItemId -- ID to get
365 // pointer to the internal data
367 /////////////////////////////////////////////////////////////////////////////
368 CListItemInternalData
* GetInternalData (
373 return(GetInternalData( (HWND
)pCtl
->GetHWND()
376 } // end of GetInternalData
378 /////////////////////////////////////////////////////////////////////////////
380 // DeleteInternalData
382 // Delete the internal data for a record
385 // pCtl -- pointer to the list control containing the record
386 // lItemId -- the record index to delete the internal data from
389 // pointer to the internal data attribute
391 /////////////////////////////////////////////////////////////////////////////
392 void DeleteInternalData (
397 CListItemInternalData
* pData
= GetInternalData( pCtl
402 if (pData
->m_pMyRecord
)
403 pData
->m_pMyRecord
->m_ulUserData
= 0;
406 } // end of DeleteInternalData
408 // #pragma page "GetInternalDataAttr"
409 /////////////////////////////////////////////////////////////////////////////
411 // GetInternalDataAttr
413 // Get the internal data item attribute given a pointer to a list control
417 // pCtl -- pointer to control to set
418 // lItemId -- ID to set
421 // pointer to the internal data attribute
423 /////////////////////////////////////////////////////////////////////////////
424 wxListItemAttr
* GetInternalDataAttr (
429 CListItemInternalData
* pData
= GetInternalData( pCtl
434 return(pData
->m_pAttr
);
437 } // end of GetInternalDataAttr
439 /////////////////////////////////////////////////////////////////////////////
441 // InternalDataCompareFunc
443 // This is compare function we pass to PM. It wraps the real compare
444 // function in SInternalDataSort
447 // p1 -- is the first record structure to compare
448 // p2 -- is the second record structure to compare
449 // lStorage -- is the same value as passed to SortItems.
452 // pointer to the internal data attribute
454 /////////////////////////////////////////////////////////////////////////////
455 SHORT EXPENTRY
InternalDataCompareFunc (
461 SInternalDataSort
* pInternalData
= (SInternalDataSort
*)pStorage
;
462 CListItemInternalData
* pData1
= (CListItemInternalData
*)p1
->m_ulUserData
;
463 CListItemInternalData
* pData2
= (CListItemInternalData
*)p2
->m_ulUserData
;
464 long lD1
= (pData1
== NULL
? 0 : (long)pData1
->m_lParam
);
465 long lD2
= (pData2
== NULL
? 0 : (long)pData2
->m_lParam
);
467 return(pInternalData
->m_fnUser( lD1
469 ,pInternalData
->m_lData
471 } // end of InternalDataCompareFunc
473 /////////////////////////////////////////////////////////////////////////////
475 // ConvertFromOS2ListItem
477 // Convert from an internal PM List item to a Toolkit List item
480 // hWndListCtrl -- the control's windows handle
481 // rInfo -- the library list control to convert to
482 // pRecord -- the OS list control to convert from
487 /////////////////////////////////////////////////////////////////////////////
488 void ConvertFromOS2ListItem ( HWND hWndListCtrl
,
492 CListItemInternalData
* pInternaldata
= (CListItemInternalData
*)pRecord
->m_ulUserData
;
493 bool bNeedText
= false;
496 rInfo
.SetData(pInternaldata
->m_lParam
);
500 rInfo
.SetStateMask(0);
501 rInfo
.SetId((long)pRecord
->m_ulItemId
);
502 if (hWndListCtrl
!= 0)
504 pRecord
= FindOS2ListRecordByID( hWndListCtrl
510 // The wxListItem class is really set up to handle the WIN32 list item
511 // and OS/2 are not as complicated. Just set both state members to the
512 // same thing under OS/2
514 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_DROPONABLE
)
516 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_DROPHILITED
);
517 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_DROPHILITED
);
519 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_SELECTED
)
521 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_SELECTED
);
522 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_SELECTED
);
524 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_DISABLED
)
526 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_DISABLED
);
527 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_DISABLED
);
529 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_FILTERED
)
531 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_FILTERED
);
532 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_FILTERED
);
534 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_INUSE
)
536 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_INUSE
);
537 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_INUSE
);
539 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_PICKED
)
541 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_PICKED
);
542 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_PICKED
);
544 if (pRecord
->m_vRecord
.flRecordAttr
& CRA_SOURCE
)
546 rInfo
.SetStateMask(rInfo
.m_stateMask
| wxLIST_STATE_SOURCE
);
547 rInfo
.SetState(rInfo
.m_state
| wxLIST_STATE_SOURCE
);
550 if (pRecord
->m_vRecord
.pszText
!= (PSZ
)NULL
)
552 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_TEXT
);
553 rInfo
.SetText(pRecord
->m_vRecord
.pszText
);
555 if (pRecord
->m_vRecord
.pszIcon
!= (PSZ
)NULL
||
556 pRecord
->m_vRecord
.pszName
!= (PSZ
)NULL
)
558 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_IMAGE
);
559 rInfo
.SetImage(pRecord
->m_vRecord
.hptrIcon
);
561 if (pRecord
->m_ulUserData
)
562 rInfo
.SetMask(rInfo
.GetMask() | wxLIST_MASK_DATA
);
563 } // end of ConvertFromOS2ListItem
565 /////////////////////////////////////////////////////////////////////////////
569 // Convert from an library states to OS states
572 // lState -- the state
573 // pRecord -- the OS list control to use
578 /////////////////////////////////////////////////////////////////////////////
579 void ConvertToOS2Flags (
584 if (lState
& wxLIST_STATE_DROPHILITED
)
585 pRecord
->m_vRecord
.flRecordAttr
|= CRA_DROPONABLE
;
586 if (lState
& wxLIST_STATE_SELECTED
)
587 pRecord
->m_vRecord
.flRecordAttr
|= CRA_SELECTED
;
588 if (lState
& wxLIST_STATE_DISABLED
)
589 pRecord
->m_vRecord
.flRecordAttr
|= CRA_DISABLED
;
590 if (lState
& wxLIST_STATE_FILTERED
)
591 pRecord
->m_vRecord
.flRecordAttr
|= CRA_FILTERED
;
592 if (lState
& wxLIST_STATE_INUSE
)
593 pRecord
->m_vRecord
.flRecordAttr
|= CRA_INUSE
;
594 if (lState
& wxLIST_STATE_PICKED
)
595 pRecord
->m_vRecord
.flRecordAttr
|= CRA_PICKED
;
596 if (lState
& wxLIST_STATE_SOURCE
)
597 pRecord
->m_vRecord
.flRecordAttr
|= CRA_SOURCE
;
598 } // end of ConvertToOS2Flags
600 /////////////////////////////////////////////////////////////////////////////
602 // ConvertToOS2ListItem
604 // Convert from a library List item to an internal OS2 List item. We set
605 // only the fields we need to set. Some of them are set by the API when
606 // they are added to the container.
609 // pCtrl -- the control to use
610 // rInfo -- the item to convert
611 // pRecord -- the OS list control to use, should be zeroed out
612 // pFieldinfo -- a field struct that may contain columnar data for detail view
617 /////////////////////////////////////////////////////////////////////////////
618 void ConvertToOS2ListItem (
619 const wxListCtrl
* pCtrl
620 , const wxListItem
& rInfo
622 , PFIELDINFO pFieldInfo
625 pRecord
->m_ulItemId
= (ULONG
)rInfo
.GetId();
626 pRecord
->m_vRecord
.cb
= sizeof(RECORDCORE
);
627 if (rInfo
.GetMask() & wxLIST_MASK_STATE
)
629 ConvertToOS2Flags( rInfo
.m_state
633 if (pCtrl
->GetWindowStyleFlag() & wxLC_ICON
||
634 pCtrl
->GetWindowStyleFlag() & wxLC_SMALL_ICON
)
636 pRecord
->m_vRecord
.pszIcon
= (char*)rInfo
.GetText().c_str();
638 if (pCtrl
->GetWindowStyleFlag() & wxLC_LIST
) // PM TEXT view
640 pRecord
->m_vRecord
.pszText
= (char*)rInfo
.GetText().c_str();
643 // In the case of a report view the text will be the data in the lead column
644 // ???? Don't know why, but that is how it works in other ports.
646 if (pCtrl
->GetWindowStyleFlag() & wxLC_REPORT
)
650 switch(rInfo
.GetColumn())
653 pRecord
->m_pzColumn1
= (char*)rInfo
.GetText().c_str();
654 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn1
);
658 pRecord
->m_pzColumn2
= (char*)rInfo
.GetText().c_str();
659 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn2
);
663 pRecord
->m_pzColumn3
= (char*)rInfo
.GetText().c_str();
664 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn3
);
668 pRecord
->m_pzColumn4
= (char*)rInfo
.GetText().c_str();
669 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn4
);
673 pRecord
->m_pzColumn5
= (char*)rInfo
.GetText().c_str();
674 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn5
);
678 pRecord
->m_pzColumn6
= (char*)rInfo
.GetText().c_str();
679 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn6
);
683 pRecord
->m_pzColumn7
= (char*)rInfo
.GetText().c_str();
684 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn7
);
688 pRecord
->m_pzColumn8
= (char*)rInfo
.GetText().c_str();
689 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn8
);
693 pRecord
->m_pzColumn9
= (char*)rInfo
.GetText().c_str();
694 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn9
);
698 pRecord
->m_pzColumn10
= (char*)rInfo
.GetText().c_str();
699 pFieldInfo
->offStruct
= FIELDOFFSET(MYRECORD
, m_pzColumn10
);
703 wxFAIL_MSG( wxT("wxOS2 does not support more than 10 columns in REPORT view") );
708 if (rInfo
.GetMask() & wxLIST_MASK_IMAGE
)
710 pRecord
->m_vRecord
.hptrIcon
= (HPOINTER
)rInfo
.GetImage();
711 pRecord
->m_vRecord
.hptrMiniIcon
= (HPOINTER
)rInfo
.m_miniImage
;
713 } // end of ConvertToOS2ListItem
715 /////////////////////////////////////////////////////////////////////////////
717 // ConvertToOS2ListCol
719 // Convert from a library List column to an internal PM List column
722 // lCol -- the columnd to convert
723 // rItem -- the item to convert
724 // pField -- the OS list column to use
729 /////////////////////////////////////////////////////////////////////////////
730 void ConvertToOS2ListCol (
732 , const wxListItem
& rItem
736 memset(pField
, '\0', sizeof(FIELDINFO
));
737 pField
->cb
= sizeof(FIELDINFO
);
740 // Default some settings
742 pField
->flData
= CFA_HORZSEPARATOR
| CFA_SEPARATOR
;
743 pField
->flTitle
= CFA_CENTER
;
745 if (rItem
.GetMask() & wxLIST_MASK_TEXT
)
747 pField
->flData
|= CFA_STRING
;
748 pField
->pTitleData
= (PVOID
)rItem
.GetText().c_str(); // text is column title not data
750 if (rItem
.GetMask() & wxLIST_MASK_FORMAT
)
752 if (rItem
.m_format
== wxLIST_FORMAT_LEFT
)
753 pField
->flData
|= CFA_LEFT
;
754 else if (rItem
.m_format
== wxLIST_FORMAT_RIGHT
)
755 pField
->flData
|= CFA_RIGHT
;
756 else if (rItem
.m_format
== wxLIST_FORMAT_CENTRE
)
757 pField
->flData
|= CFA_CENTER
;
760 pField
->flData
|= CFA_CENTER
; // Just ensure the default is centered
761 if (rItem
.GetMask() & wxLIST_MASK_WIDTH
)
763 if (!(rItem
.GetWidth() == wxLIST_AUTOSIZE
||
764 rItem
.GetWidth() == wxLIST_AUTOSIZE_USEHEADER
))
765 pField
->cxWidth
= rItem
.GetWidth();
766 // else: OS/2 automatically sets the width if created with the approppriate style
770 // Still need to set the actual data
772 pField
->offStruct
= 0;
773 } // end of ConvertToOS2ListCol
775 BEGIN_EVENT_TABLE(wxListCtrl
, wxControl
)
776 EVT_PAINT(wxListCtrl::OnPaint
)
779 // ============================================================================
781 // ============================================================================
783 // ----------------------------------------------------------------------------
784 // wxListCtrl construction
785 // ----------------------------------------------------------------------------
787 void wxListCtrl::Init ()
789 m_pImageListNormal
= NULL
;
790 m_pImageListSmall
= NULL
;
791 m_pImageListState
= NULL
;
792 m_bOwnsImageListNormal
= false;
793 m_bOwnsImageListSmall
= false;
794 m_bOwnsImageListState
= false;
798 m_bAnyInternalData
= false;
799 m_bHasAnyAttr
= false;
800 } // end of wxListCtrl::Init
802 bool wxListCtrl::Create ( wxWindow
* pParent
,
807 const wxValidator
& rValidator
,
808 const wxString
& rsName
)
812 int nWidth
= rSize
.x
;
813 int nHeight
= rSize
.y
;
816 SetValidator(rValidator
);
817 #endif // wxUSE_VALIDATORS
820 SetWindowStyleFlag(lStyle
);
831 m_windowId
= (vId
== -1) ? NewControlId() : vId
;
833 long lSstyle
= WS_VISIBLE
| WS_TABSTOP
;
835 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
836 lSstyle
|= WS_CLIPSIBLINGS
;
837 m_lBaseStyle
= lSstyle
;
838 if (!DoCreateControl( nX
845 pParent
->AddChild(this);
847 } // end of wxListCtrl::Create
849 bool wxListCtrl::DoCreateControl ( int nX
, int nY
,
850 int nWidth
, int nHeight
)
852 DWORD lWstyle
= m_lBaseStyle
;
853 long lOldStyle
= 0; // Dummy
857 lWstyle
|= ConvertToOS2Style( lOldStyle
858 ,GetWindowStyleFlag()
861 m_hWnd
= (WXHWND
)::WinCreateWindow( GetParent()->GetHWND()
866 ,GetParent()->GetHWND()
878 // Now set the display attributes of the container
880 if (!::WinSendMsg( GetHWND()
883 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
886 lWstyle
= ConvertViewToOS2Style(GetWindowStyleFlag());
887 vCnrInfo
.flWindowAttr
|= lWstyle
;
888 if (!::WinSendMsg( GetHWND()
891 ,(MPARAM
)CMA_FLWINDOWATTR
896 // And now set needed arrangement flags
898 lWstyle
= ConvertArrangeToOS2Style(GetWindowStyleFlag());
899 if (!::WinSendMsg( GetHWND()
901 ,(MPARAM
)CMA_ARRANGEGRID
905 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
));
906 SetForegroundColour(GetParent()->GetForegroundColour());
908 SetFont(*wxSMALL_FONT
);
911 SetSize( nX
, nY
, nWidth
, nHeight
);
913 } // end of wxListCtrl::DoCreateControl
915 void wxListCtrl::UpdateStyle ()
920 DWORD dwStyleNew
= ConvertToOS2Style( lDummy
, GetWindowStyleFlag() );
922 dwStyleNew
|= m_lBaseStyle
;
925 // Get the current window style.
927 ULONG dwStyleOld
= ::WinQueryWindowULong(GetHWND(), QWL_STYLE
);
930 // Only set the window style if the view bits have changed.
932 if (dwStyleOld
!= dwStyleNew
)
934 ::WinSetWindowULong(GetHWND(), QWL_STYLE
, dwStyleNew
);
937 } // end of wxListCtrl::UpdateStyle
939 void wxListCtrl::FreeAllInternalData ()
941 if (m_bAnyInternalData
)
943 int n
= GetItemCount();
946 for (i
= 0; i
< n
; i
++)
947 DeleteInternalData(this, (long)i
);
948 m_bAnyInternalData
= false;
950 } // end of wxListCtrl::FreeAllInternalData
952 wxListCtrl::~wxListCtrl ()
954 FreeAllInternalData();
957 m_pTextCtrl
->SetHWND(0);
958 m_pTextCtrl
->UnsubclassWin();
959 wxDELETE(m_pTextCtrl
);
962 if (m_bOwnsImageListNormal
)
963 delete m_pImageListNormal
;
964 if (m_bOwnsImageListSmall
)
965 delete m_pImageListSmall
;
966 if (m_bOwnsImageListState
)
967 delete m_pImageListState
;
968 } // end of wxListCtrl::~wxListCtrl
970 // ----------------------------------------------------------------------------
971 // set/get/change style
972 // ----------------------------------------------------------------------------
974 // Add or remove a single window style
975 void wxListCtrl::SetSingleStyle (
980 long lFlag
= GetWindowStyleFlag();
983 // Get rid of conflicting styles
987 if (lStyle
& wxLC_MASK_TYPE
)
988 lFlag
= lFlag
& ~wxLC_MASK_TYPE
;
989 if (lStyle
& wxLC_MASK_ALIGN
)
990 lFlag
= lFlag
& ~wxLC_MASK_ALIGN
;
991 if (lStyle
& wxLC_MASK_SORT
)
992 lFlag
= lFlag
& ~wxLC_MASK_SORT
;
1006 m_windowStyle
= lFlag
;
1008 } // end of wxListCtrl::SetSingleStyle
1010 // Set the whole window style
1011 void wxListCtrl::SetWindowStyleFlag (
1015 m_windowStyle
= lFlag
;
1017 } // end of wxListCtrl::SetWindowStyleFlag
1019 long wxListCtrl::ConvertToOS2Style (
1027 // The only styles OS2 uses on creation are auto arrange, read only, and
1028 // and selection styles. This lib does not support OS/2 MINIRECORDCORE
1029 // or VERIFYPOINTER styles
1031 if (lStyle
& wxLC_AUTOARRANGE
)
1032 lWstyle
|= CCS_AUTOPOSITION
;
1033 if (lStyle
& wxLC_SINGLE_SEL
)
1034 lWstyle
|= CCS_SINGLESEL
;
1036 lWstyle
|= CCS_EXTENDSEL
;
1037 if (!(lStyle
& wxLC_EDIT_LABELS
))
1038 lWstyle
|= CCS_READONLY
;
1040 } // end of wxListCtrl::ConvertToOS2Style
1042 long wxListCtrl::ConvertArrangeToOS2Style (
1048 if (lStyle
& wxLC_ALIGN_LEFT
)
1050 lWstyle
|= CMA_LEFT
;
1053 if (lStyle
& wxLC_ALIGN_TOP
)
1058 } // end of wxListCtrl::ConvertArrangeToOS2Style
1060 long wxListCtrl::ConvertViewToOS2Style (
1064 long lWstyle
= CA_DRAWICON
; // we will only use icons
1066 if (lStyle
& wxLC_ICON
)
1070 if (lStyle
& wxLC_SMALL_ICON
)
1072 lWstyle
|= (CV_ICON
| CV_MINI
);
1074 if (lStyle
& wxLC_LIST
)
1078 if (lStyle
& wxLC_REPORT
)
1080 lWstyle
|= CV_DETAIL
;
1082 if (lStyle
& wxLC_VIRTUAL
)
1084 lWstyle
|= CA_OWNERDRAW
;
1086 if (lStyle
& wxLC_AUTOARRANGE
)
1090 if (!(lStyle
& wxLC_NO_HEADER
))
1092 lWstyle
|= CA_DETAILSVIEWTITLES
;
1095 } // end of wxListCtrl::ConvertViewToOS2Style
1097 // ----------------------------------------------------------------------------
1099 // ----------------------------------------------------------------------------
1101 // Sets the foreground, i.e. text, colour
1102 bool wxListCtrl::SetForegroundColour (const wxColour
& rCol
)
1104 ULONG ulColor
= wxColourToRGB(rCol
);
1106 if (!wxWindow::SetForegroundColour(rCol
))
1109 ::WinSetPresParam( GetHWND()
1115 } // end of wxListCtrl::SetForegroundColour
1117 // Sets the background colour
1118 bool wxListCtrl::SetBackgroundColour ( const wxColour
& rCol
)
1120 if (!wxWindow::SetBackgroundColour(rCol
))
1124 // We set the same colour for both the "empty" background and the items
1127 ULONG ulColor
= wxColourToRGB(rCol
);
1129 ::WinSetPresParam( GetHWND()
1135 } // end of wxListCtrl::SetBackgroundColour
1137 // Gets information about this column
1138 bool wxListCtrl::GetColumn ( int nCol
, wxListItem
& rItem
) const
1140 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND(), nCol
);
1144 rItem
.SetWidth(pFieldInfo
->cxWidth
);
1145 if ((rItem
.GetMask() & wxLIST_MASK_TEXT
) &&
1146 (pFieldInfo
->flData
& CFA_STRING
) &&
1147 (pFieldInfo
->pUserData
!= NULL
))
1149 rItem
.SetText((char*)pFieldInfo
->pUserData
);
1151 if (rItem
.GetMask() & wxLIST_MASK_FORMAT
)
1153 if (pFieldInfo
->flData
& CFA_LEFT
)
1154 rItem
.m_format
= wxLIST_FORMAT_LEFT
;
1155 else if (pFieldInfo
->flData
& CFA_RIGHT
)
1156 rItem
.m_format
= wxLIST_FORMAT_RIGHT
;
1157 else if (pFieldInfo
->flData
& CFA_CENTER
)
1158 rItem
.m_format
= wxLIST_FORMAT_CENTRE
;
1161 } // end of wxListCtrl::GetColumn
1163 // Sets information about this column
1164 bool wxListCtrl::SetColumn ( int nCol
, wxListItem
& rItem
)
1166 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum( GetHWND(), nCol
);
1167 ConvertToOS2ListCol( nCol
, rItem
, pFieldInfo
);
1169 // Since we changed the field pointed to, we invalidate to see the result
1171 ::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO
, NULL
, NULL
);
1173 } // end of wxListCtrl::SetColumn
1175 // Gets the column width
1176 int wxListCtrl::GetColumnWidth ( int nCol
) const
1178 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND(), nCol
);
1182 return((int)pFieldInfo
->cxWidth
);
1183 } // end of wxListCtrl::GetColumnWidth
1185 // Sets the column width
1186 bool wxListCtrl::SetColumnWidth ( int nCol
, int nWidth
)
1189 int nWidth2
= nWidth
;
1191 if (GetWindowStyleFlag() & wxLC_LIST
)
1194 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum( GetHWND(), nCol
);
1195 pFieldInfo
->cxWidth
= nWidth
;
1196 ::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO
, NULL
, NULL
);
1198 } // end of wxListCtrl::SetColumnWidth
1200 // Gets the number of items that can fit vertically in the
1201 // visible area of the list control (list or report view)
1202 // or the total number of items in the list control (icon
1203 // or small icon view)
1204 int wxListCtrl::GetCountPerPage () const
1206 QUERYRECORDRECT vQueryRect
;
1212 if (!::WinSendMsg( GetHWND()
1215 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1218 memset(&vQueryRect
, '\0', sizeof(QUERYRECORDRECT
));
1219 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1220 if (vCnrInfo
.flWindowAttr
& CV_ICON
)
1221 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1222 else if (vCnrInfo
.flWindowAttr
& CV_NAME
)
1223 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1224 else if (vCnrInfo
.flWindowAttr
& CV_TEXT
)
1225 vQueryRect
.fsExtent
= CMA_TEXT
;
1226 else if (vCnrInfo
.flWindowAttr
& CV_DETAIL
)
1227 vQueryRect
.fsExtent
= CMA_TEXT
;
1228 if (!::WinSendMsg( GetHWND()
1230 ,MPFROMP(&vRectRecord
)
1231 ,MPFROMP(&vQueryRect
)
1234 if (!::WinSendMsg( GetHWND()
1235 ,CM_QUERYVIEWPORTRECT
1236 ,MPFROMP(&vRectControl
)
1237 ,MPFROM2SHORT(CMA_WINDOW
, (USHORT
)FALSE
)
1240 nCount
= (int)((int)((vRectControl
.xRight
- vRectControl
.xLeft
) / (vRectRecord
.xRight
- vRectRecord
.xLeft
)) *
1241 (int)((vRectControl
.yTop
- vRectControl
.yBottom
) / (vRectRecord
.yTop
- vRectRecord
.yBottom
))
1243 if (nCount
> (int)vCnrInfo
.cFields
)
1244 nCount
= (int)vCnrInfo
.cFields
;
1246 } // end of wxListCtrl::GetCountPerPage
1248 // Gets the edit control for editing labels.
1249 wxTextCtrl
* wxListCtrl::GetEditControl() const
1254 // Gets information about the item
1255 bool wxListCtrl::GetItem ( wxListItem
& rInfo
) const
1257 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), rInfo
.GetId() );
1260 // Give NULL as hwnd as we already have everything we need
1262 ConvertFromOS2ListItem( NULL
, rInfo
, pRecord
);
1264 } // end of wxListCtrl::GetItem
1266 // Sets information about the item
1267 bool wxListCtrl::SetItem ( wxListItem
& rInfo
)
1269 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND(), rInfo
.GetColumn() );
1270 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), rInfo
.GetId() );
1272 ConvertToOS2ListItem( this
1279 // Check if setting attributes or lParam
1281 if (rInfo
.HasAttributes() || (rInfo
.GetMask() & wxLIST_MASK_DATA
))
1284 // Get internal item data
1285 // perhaps a cache here ?
1287 CListItemInternalData
* pData
= GetInternalData( this
1296 m_bAnyInternalData
= true;
1297 pData
= new CListItemInternalData();
1298 pRecord
->m_ulUserData
= (unsigned long)pData
;
1304 if (rInfo
.GetMask() & wxLIST_MASK_DATA
)
1305 pData
->m_lParam
= (WXLPARAM
)rInfo
.GetData();
1308 if (rInfo
.HasAttributes())
1311 *pData
->m_pAttr
= *rInfo
.GetAttributes();
1313 pData
->m_pAttr
= new wxListItemAttr(*rInfo
.GetAttributes());
1315 pData
->m_pMyRecord
= pRecord
; // they point to each other
1319 // We need to update the item immediately to show the new image
1321 bool bUpdateNow
= (rInfo
.GetMask() & wxLIST_MASK_IMAGE
) != 0;
1324 // Check whether it has any custom attributes
1326 if (rInfo
.HasAttributes())
1328 m_bHasAnyAttr
= true;
1331 // If the colour has changed, we must redraw the item
1335 if (::WinIsWindowVisible(GetHWND()))
1337 ::WinSendMsg( GetHWND()
1338 ,CM_INVALIDATERECORD
1340 ,MPFROM2SHORT(1, CMA_ERASE
| CMA_REPOSITION
| CMA_TEXTCHANGED
)
1342 RefreshItem(pRecord
->m_ulItemId
);
1344 ::WinSendMsg( GetHWND()
1345 ,CM_INVALIDATEDETAILFIELDINFO
1350 } // end of wxListCtrl::SetItem
1352 long wxListCtrl::SetItem (
1355 , const wxString
& rsLabel
1361 vInfo
.m_text
= rsLabel
;
1362 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1363 vInfo
.m_itemId
= lIndex
;
1367 vInfo
.m_image
= nImageId
;
1368 vInfo
.m_mask
|= wxLIST_MASK_IMAGE
;
1370 return SetItem(vInfo
);
1371 } // end of wxListCtrl::SetItem
1373 // Gets the item state
1374 int wxListCtrl::GetItemState (
1381 vInfo
.m_mask
= wxLIST_MASK_STATE
;
1382 vInfo
.m_stateMask
= lStateMask
;
1383 vInfo
.m_itemId
= lItem
;
1385 if (!GetItem(vInfo
))
1387 return vInfo
.m_state
;
1388 } // end of wxListCtrl::GetItemState
1390 // Sets the item state
1391 bool wxListCtrl::SetItemState ( long lItem
, long lState
, long lStateMask
)
1393 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), lItem
);
1396 // Don't use SetItem() here as it doesn't work with the virtual list
1399 ConvertToOS2Flags( lState
, pRecord
);
1402 // for the virtual list controls we need to refresh the previously focused
1403 // item manually when changing focus without changing selection
1404 // programmatically because otherwise it keeps its focus rectangle until
1405 // next repaint (yet another comctl32 bug)
1410 (lStateMask
& wxLIST_STATE_FOCUSED
) &&
1411 (lState
& wxLIST_STATE_FOCUSED
) )
1413 lFocusOld
= GetNextItem( -1
1415 ,wxLIST_STATE_FOCUSED
1422 ::WinSendMsg( GetHWND()
1423 ,CM_INVALIDATERECORD
1425 ,MPFROM2SHORT(1, CMA_ERASE
| CMA_REPOSITION
| CMA_TEXTCHANGED
)
1428 if (lFocusOld
!= -1)
1431 // No need to refresh the item if it was previously selected, it would
1432 // only result in annoying flicker
1434 if (!(GetItemState( lFocusOld
1435 ,wxLIST_STATE_SELECTED
1436 ) & wxLIST_STATE_SELECTED
))
1438 RefreshItem(lFocusOld
);
1442 } // end of wxListCtrl::SetItemState
1444 // Sets the item image
1445 bool wxListCtrl::SetItemImage (
1448 , int WXUNUSED(nSelImage
))
1450 return SetItemColumnInfo(lItem
, 0, nImage
);
1451 } // end of wxListCtrl::SetItemImage
1453 // Sets the item image
1454 bool wxListCtrl::SetItemColumnImage (
1461 vInfo
.m_mask
= wxLIST_MASK_IMAGE
;
1462 vInfo
.m_image
= nImage
;
1463 vInfo
.m_itemId
= lItem
;
1464 vInfo
.m_col
= lColumn
;
1465 return SetItem(vInfo
);
1466 } // end of wxListCtrl::SetItemColumnImage
1468 // Gets the item text
1469 wxString
wxListCtrl::GetItemText (
1475 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1476 vInfo
.m_itemId
= lItem
;
1478 if (!GetItem(vInfo
))
1479 return wxEmptyString
;
1480 return vInfo
.m_text
;
1481 } // end of wxListCtrl::GetItemText
1483 // Sets the item text
1484 void wxListCtrl::SetItemText (
1486 , const wxString
& rsStr
1491 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
1492 vInfo
.m_itemId
= lItem
;
1493 vInfo
.m_text
= rsStr
;
1495 } // end of wxListCtrl::SetItemText
1497 // Gets the item data
1498 long wxListCtrl::GetItemData (
1504 vInfo
.m_mask
= wxLIST_MASK_DATA
;
1505 vInfo
.m_itemId
= lItem
;
1506 if (!GetItem(vInfo
))
1508 return vInfo
.m_data
;
1509 } // end of wxListCtrl::GetItemData
1511 // Sets the item data
1512 bool wxListCtrl::SetItemPtrData (
1519 vInfo
.m_mask
= wxLIST_MASK_DATA
;
1520 vInfo
.m_itemId
= lItem
;
1521 vInfo
.m_data
= lData
;
1522 return SetItem(vInfo
);
1523 } // end of wxListCtrl::SetItemPtrData
1525 // Gets the item rectangle
1526 bool wxListCtrl::GetItemRect ( long lItem
,
1531 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), lItem
);
1532 QUERYRECORDRECT vQueryRect
;
1538 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1539 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
1540 vQueryRect
.fRightSplitWindow
= TRUE
;
1541 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1542 ::WinSendMsg( GetHWND()
1545 ,MPFROMP(&vQueryRect
)
1548 // remember OS/2 is backwards
1550 GetClientSize( NULL
, &nHeight
);
1551 rRect
.x
= vRect
.xLeft
;
1552 rRect
.y
= nHeight
- vRect
.yTop
;
1553 rRect
.width
= vRect
.xRight
;
1554 rRect
.height
= nHeight
- vRect
.yBottom
;
1557 } // end of wxListCtrl::GetItemRect
1559 // Gets the item position
1560 bool wxListCtrl::GetItemPosition ( long lItem
, wxPoint
& rPos
) const
1563 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND() , lItem
);
1564 QUERYRECORDRECT vQueryRect
;
1570 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
1571 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
1572 vQueryRect
.fRightSplitWindow
= TRUE
;
1573 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
1574 ::WinSendMsg( GetHWND()
1577 ,MPFROMP(&vQueryRect
)
1580 // remember OS/2 is backwards
1582 GetClientSize( NULL
, &nHeight
);
1583 rPos
.x
= vRect
.xLeft
;
1584 rPos
.y
= nHeight
- vRect
.yTop
;
1587 } // end of wxListCtrl::GetItemPosition
1589 // Sets the item position.
1590 bool wxListCtrl::SetItemPosition ( long lItem
, const wxPoint
& rPos
)
1593 // Items cannot be positioned in X/Y coord in OS/2
1596 } // end of wxListCtrl::SetItemPosition
1598 // Gets the number of items in the list control
1599 int wxListCtrl::GetItemCount () const
1603 if (!::WinSendMsg( GetHWND()
1606 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1609 return vCnrInfo
.cRecords
;
1610 } // end of wxListCtrl::GetItemCount
1612 // Retrieves the spacing between icons in pixels.
1613 // If bIsSmall is true, gets the spacing for the small icon
1614 // view, otherwise the large icon view.
1615 int wxListCtrl::GetItemSpacing ( bool bIsSmall
) const
1619 if (!::WinSendMsg( GetHWND()
1622 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
1625 return vCnrInfo
.cyLineSpacing
;
1626 } // end of wxListCtrl::GetItemSpacing
1628 void wxListCtrl::SetItemTextColour (
1630 , const wxColour
& rCol
1635 vInfo
.m_itemId
= lItem
;
1636 vInfo
.SetTextColour(rCol
);
1638 } // end of wxListCtrl::SetItemTextColour
1640 wxColour
wxListCtrl::GetItemTextColour (
1646 vInfo
.m_itemId
= lItem
;
1648 return vInfo
.GetTextColour();
1649 } // end of wxListCtrl::GetItemTextColour
1651 void wxListCtrl::SetItemBackgroundColour (
1653 , const wxColour
& rCol
1658 vInfo
.m_itemId
= lItem
;
1659 vInfo
.SetBackgroundColour(rCol
);
1661 } // end of wxListCtrl::SetItemBackgroundColour
1663 wxColour
wxListCtrl::GetItemBackgroundColour (
1669 vInfo
.m_itemId
= lItem
;
1671 return vInfo
.GetBackgroundColour();
1672 } // end of wxListCtrl::GetItemBackgroundColour
1674 // Gets the number of selected items in the list control
1675 int wxListCtrl::GetSelectedItemCount () const
1677 PMYRECORD pRecord
= NULL
;
1679 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
1680 ,CM_QUERYRECORDEMPHASIS
1682 ,(MPARAM
)CRA_SELECTED
1690 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
1691 ,CM_QUERYRECORDEMPHASIS
1693 ,(MPARAM
)CRA_SELECTED
1699 } // end of wxListCtrl::GetSelectedItemCount
1701 // Gets the text colour of the listview
1702 wxColour
wxListCtrl::GetTextColour () const
1707 ::WinQueryPresParam( GetHWND()
1717 } // end of wxListCtrl::GetTextColour
1719 // Sets the text colour of the listview
1720 void wxListCtrl::SetTextColour (
1721 const wxColour
& rCol
1724 ULONG ulColor
= wxColourToRGB(rCol
);
1726 ::WinSetPresParam( GetHWND()
1731 } // end of wxListCtrl::SetTextColour
1733 // Gets the index of the topmost visible item when in
1734 // list or report view
1735 long wxListCtrl::GetTopItem () const
1737 PMYRECORD pRecord
= NULL
;
1738 QUERYRECFROMRECT vQueryRect
;
1741 ::WinSendMsg( GetHWND()
1742 ,CM_QUERYVIEWPORTRECT
1744 ,MPFROM2SHORT(CMA_WINDOW
, TRUE
)
1746 vQueryRect
.cb
= sizeof(QUERYRECFROMRECT
);
1747 vQueryRect
.rect
= vRect
;
1748 vQueryRect
.fsSearch
= CMA_PARTIAL
;
1750 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
1751 ,CM_QUERYRECORDFROMRECT
1753 ,MPFROMP(&vQueryRect
)
1758 return (long)pRecord
->m_ulItemId
;
1759 } // end of wxListCtrl::GetTopItem
1761 // Searches for an item, starting from 'item'.
1762 // 'geometry' is one of
1763 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
1764 // 'state' is a state bit flag, one or more of
1765 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
1766 // item can be -1 to find the first item that matches the
1768 // Returns the item or -1 if unsuccessful.
1769 long wxListCtrl::GetNextItem (
1771 , int WXUNUSED(nGeom
)
1772 , int WXUNUSED(nState
)
1775 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1779 pRecord
= (PMYRECORD
)pRecord
->m_vRecord
.preccNextRecord
;
1781 return((long)pRecord
->m_ulItemId
);
1783 } // end of wxListCtrl::GetNextItem
1785 wxImageList
* wxListCtrl::GetImageList (
1789 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1791 return m_pImageListNormal
;
1793 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1795 return m_pImageListSmall
;
1797 else if (nWhich
== wxIMAGE_LIST_STATE
)
1799 return m_pImageListState
;
1802 } // end of wxListCtrl::GetImageList
1804 void wxListCtrl::SetImageList ( wxImageList
* pImageList
,
1807 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1809 if (m_bOwnsImageListNormal
)
1810 delete m_pImageListNormal
;
1811 m_pImageListNormal
= pImageList
;
1812 m_bOwnsImageListNormal
= false;
1814 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1816 if (m_bOwnsImageListSmall
)
1817 delete m_pImageListSmall
;
1818 m_pImageListSmall
= pImageList
;
1819 m_bOwnsImageListSmall
= false;
1821 else if (nWhich
== wxIMAGE_LIST_STATE
)
1823 if (m_bOwnsImageListState
)
1824 delete m_pImageListState
;
1825 m_pImageListState
= pImageList
;
1826 m_bOwnsImageListState
= false;
1828 } // end of wxListCtrl::SetImageList
1830 void wxListCtrl::AssignImageList ( wxImageList
* pImageList
, int nWhich
)
1832 SetImageList( pImageList
, nWhich
);
1834 if (nWhich
== wxIMAGE_LIST_NORMAL
)
1835 m_bOwnsImageListNormal
= true;
1836 else if (nWhich
== wxIMAGE_LIST_SMALL
)
1837 m_bOwnsImageListSmall
= true;
1838 else if (nWhich
== wxIMAGE_LIST_STATE
)
1839 m_bOwnsImageListState
= true;
1840 } // end of wxListCtrl::AssignImageList
1842 // ----------------------------------------------------------------------------
1844 // ----------------------------------------------------------------------------
1846 // Arranges the items
1847 bool wxListCtrl::Arrange ( int nFlag
)
1852 if (nFlag
== wxLIST_ALIGN_SNAP_TO_GRID
)
1854 ulType
= CMA_ARRANGEGRID
;
1855 if (nFlag
== wxLIST_ALIGN_LEFT
)
1856 ulFlags
|= CMA_LEFT
;
1857 else if (nFlag
== wxLIST_ALIGN_TOP
)
1859 else if (nFlag
== wxLIST_ALIGN_DEFAULT
)
1860 ulFlags
|= CMA_LEFT
;
1863 ulType
= CMA_ARRANGESTANDARD
;
1864 ::WinSendMsg( GetHWND()
1870 // We do not support CMA_ARRANGESELECTED
1873 } // end of wxListCtrl::Arrange
1876 bool wxListCtrl::DeleteItem ( long lItem
)
1878 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), lItem
);
1879 if (LONGFROMMR(::WinSendMsg( GetHWND()
1882 ,MPFROM2SHORT(1, CMA_FREE
)
1889 // The virtual list control doesn't refresh itself correctly, help it
1894 // We need to refresh all the lines below the one which was deleted
1898 if (lItem
> 0 && GetItemCount())
1900 GetItemRect( lItem
- 1
1906 vRectItem
.y
= vRectItem
.height
= 0;
1908 wxRect vRectWin
= GetRect();
1910 vRectWin
.height
= vRectWin
.GetBottom() - vRectItem
.GetBottom();
1911 vRectWin
.y
= vRectItem
.GetBottom();
1912 RefreshRect(vRectWin
);
1915 } // end of wxListCtrl::DeleteItem
1917 // Deletes all items
1918 bool wxListCtrl::DeleteAllItems ()
1920 return((LONG
)::WinSendMsg( GetHWND()
1923 ,MPFROM2SHORT(0, CMA_FREE
)
1925 } // end of wxListCtrl::DeleteAllItems
1927 // Deletes all items
1928 bool wxListCtrl::DeleteAllColumns ()
1930 while (m_nColCount
> 0)
1932 DeleteColumn(m_nColCount
- 1);
1936 wxASSERT_MSG(m_nColCount
== 0, wxT("no columns should be left"));
1938 } // end of wxListCtrl::DeleteAllColumns
1941 bool wxListCtrl::DeleteColumn ( int nCol
)
1943 bool bSuccess
= false;
1944 PFIELDINFO pField
= FindOS2ListFieldByColNum( GetHWND(), nCol
);
1945 bSuccess
= ((LONG
)::WinSendMsg( GetHWND()
1946 ,CM_REMOVEDETAILFIELDINFO
1948 ,MPFROM2SHORT((SHORT
)1, CMA_FREE
)
1950 if (bSuccess
&& (m_nColCount
> 0))
1953 } // end of wxListCtrl::DeleteColumn
1955 // Clears items, and columns if there are any.
1956 void wxListCtrl::ClearAll ()
1959 if (m_nColCount
> 0)
1961 } // end of wxListCtrl::ClearAll
1964 // OS/2 does not use a text control for its container labels. You merely
1965 // "open" a record for editting.
1967 wxTextCtrl
* wxListCtrl::EditLabel (
1969 , wxClassInfo
* WXUNUSED(pTextControlClass
)
1973 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
1977 vEdit
.cb
= sizeof(CNREDITDATA
);
1978 vEdit
.hwndCnr
= GetHWND();
1979 vEdit
.pRecord
= &pRecord
->m_vRecord
;
1980 vEdit
.pFieldInfo
= NULL
;
1981 vEdit
.ppszText
= NULL
;
1985 ::WinSendMsg( GetHWND()
1991 } // end of wxListCtrl::EditLabel
1993 // End label editing, optionally cancelling the edit. Under OS/2 you close
1994 // the record for editting
1995 bool wxListCtrl::EndEditLabel ( bool WXUNUSED(bCancel
) )
1997 ::WinSendMsg( GetHWND()
2003 } // end of wxListCtrl::EndEditLabel
2005 // Ensures this item is visible
2006 bool wxListCtrl::EnsureVisible ( long lItem
)
2008 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND(), lItem
);
2009 ::WinSendMsg( GetHWND()
2010 ,CM_INVALIDATERECORD
2012 ,MPFROM2SHORT((SHORT
)1, CMA_NOREPOSITION
)
2015 } // end of wxListCtrl::EnsureVisible
2017 // Find an item whose label matches this string, starting from the item after 'start'
2018 // or the beginning if 'start' is -1.
2019 long wxListCtrl::FindItem (
2021 , const wxString
& rsStr
2026 SEARCHSTRING vSearch
;
2027 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2033 if (!::WinSendMsg( GetHWND()
2036 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
2040 if (vCnrInfo
.flWindowAttr
& CV_ICON
)
2042 if (vCnrInfo
.flWindowAttr
& CV_NAME
)
2044 if (vCnrInfo
.flWindowAttr
& CV_TEXT
)
2046 if (vCnrInfo
.flWindowAttr
& CV_DETAIL
)
2049 ulFlag
|= CV_EXACTLENGTH
;
2051 vSearch
.cb
= sizeof(SEARCHSTRING
);
2052 vSearch
.pszSearch
= (char*)rsStr
.c_str();
2053 vSearch
.fsPrefix
= TRUE
;
2054 vSearch
.fsCaseSensitive
= TRUE
;
2055 vSearch
.usView
= ulFlag
;
2059 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2067 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2075 return pRecord
->m_ulItemId
;
2076 } // end of wxListCtrl::FindItem
2078 // Find an item whose data matches this data, starting from the item after 'start'
2079 // or the beginning if 'start' is -1.
2080 long wxListCtrl::FindItem (
2085 long lIdx
= lStart
+ 1;
2086 long lCount
= GetItemCount();
2088 while (lIdx
< lCount
)
2090 if (GetItemData(lIdx
) == lData
)
2095 } // end of wxListCtrl::FindItem
2097 // Find an item nearest this position in the specified direction, starting from
2098 // the item after 'start' or the beginning if 'start' is -1.
2099 long wxListCtrl::FindItem (
2101 , const wxPoint
& rPoint
2106 QUERYRECORDRECT vQueryRect
;
2107 PMYRECORD pRecord
= FindOS2ListRecordByID( GetHWND()
2114 if (!::WinSendMsg( GetHWND()
2117 ,(MPARAM
)(USHORT
)sizeof(CNRINFO
)
2121 vQueryRect
.cb
= sizeof(QUERYRECORDRECT
);
2122 vQueryRect
.pRecord
= &pRecord
->m_vRecord
;
2123 vQueryRect
.fRightSplitWindow
= TRUE
;
2124 vQueryRect
.fsExtent
= CMA_ICON
| CMA_TEXT
;
2126 ::WinSendMsg( GetHWND()
2129 ,MPFROMP(&vQueryRect
)
2131 vLibRect
.SetLeft(vRect
.xLeft
);
2132 vLibRect
.SetTop(vRect
.yTop
);
2133 vLibRect
.SetRight(vRect
.xRight
);
2134 vLibRect
.SetBottom(vRect
.yBottom
);
2135 if (vLibRect
.Contains(rPoint
))
2136 return pRecord
->m_ulItemId
;
2138 for (i
= lStart
+ 1; i
< vCnrInfo
.cRecords
; i
++)
2140 pRecord
= (PMYRECORD
)PVOIDFROMMR(::WinSendMsg( GetHWND()
2143 ,MPFROM2SHORT(CMA_NEXT
, CMA_ITEMORDER
)
2145 vQueryRect
.pRecord
= (PRECORDCORE
)pRecord
;
2146 ::WinSendMsg( GetHWND()
2149 ,MPFROMP(&vQueryRect
)
2151 vLibRect
.SetLeft(vRect
.xLeft
);
2152 vLibRect
.SetTop(vRect
.yTop
);
2153 vLibRect
.SetRight(vRect
.xRight
);
2154 vLibRect
.SetBottom(vRect
.yBottom
);
2155 if (vLibRect
.Contains(rPoint
))
2156 return pRecord
->m_ulItemId
;
2159 } // end of wxListCtrl::FindItem
2161 // Determines which item (if any) is at the specified point,
2162 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
2163 long wxListCtrl::HitTest (
2164 const wxPoint
& rPoint
2165 , int& WXUNUSED(rFlags
)
2168 PMYRECORD pRecord
= NULL
;
2169 QUERYRECFROMRECT vQueryRect
;
2174 // Get height for OS/2 point conversion
2176 ::WinSendMsg( GetHWND()
2177 ,CM_QUERYVIEWPORTRECT
2179 ,MPFROM2SHORT(CMA_WINDOW
, TRUE
)
2181 lHeight
= vRect
.yTop
- vRect
.yBottom
;
2184 // For now just try and get a record in the general vicinity and forget
2187 vRect
.xLeft
= rPoint
.x
- 2;
2188 vRect
.xRight
= rPoint
.x
+ 2;
2189 vRect
.yTop
= (lHeight
- rPoint
.y
) + 2;
2190 vRect
.yBottom
= (lHeight
- rPoint
.y
) - 2;
2192 vQueryRect
.cb
= sizeof(QUERYRECFROMRECT
);
2193 vQueryRect
.rect
= vRect
;
2194 vQueryRect
.fsSearch
= CMA_PARTIAL
;
2196 pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2197 ,CM_QUERYRECORDFROMRECT
2199 ,MPFROMP(&vQueryRect
)
2204 return pRecord
->m_ulItemId
;
2205 } // end of wxListCtrl::HitTest
2207 // Inserts an item, returning the index of the new item if successful,
2209 long wxListCtrl::InsertItem (
2213 wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual controls") );
2215 PFIELDINFO pFieldInfo
= FindOS2ListFieldByColNum ( GetHWND()
2218 PMYRECORD pRecordAfter
= NULL
;
2219 PMYRECORD pRecord
= (PMYRECORD
)::WinSendMsg( GetHWND()
2221 ,MPFROMLONG(sizeof(MYRECORD
) - sizeof(RECORDCORE
))
2225 ConvertToOS2ListItem( this
2231 if (rInfo
.GetId() > 0)
2232 pRecordAfter
= FindOS2ListRecordByID( GetHWND()
2236 RECORDINSERT vInsert
;
2238 vInsert
.cb
= sizeof(RECORDINSERT
);
2239 vInsert
.pRecordParent
= NULL
;
2241 vInsert
.pRecordOrder
= (PRECORDCORE
)CMA_FIRST
;
2243 vInsert
.pRecordOrder
= (PRECORDCORE
)pRecordAfter
;
2244 vInsert
.zOrder
= CMA_TOP
;
2245 vInsert
.cRecordsInsert
= 1;
2246 vInsert
.fInvalidateRecord
= TRUE
;
2249 // Check whether we need to allocate our internal data
2251 bool bNeedInternalData
= ((rInfo
.GetMask() & wxLIST_MASK_DATA
) ||
2252 rInfo
.HasAttributes()
2254 if (bNeedInternalData
)
2256 m_bAnyInternalData
= true;
2259 // Internal stucture that manages data
2261 CListItemInternalData
* pData
= new CListItemInternalData();
2263 pRecord
->m_ulUserData
= (unsigned long)pData
;
2264 if (rInfo
.GetMask() & wxLIST_MASK_DATA
)
2265 pData
->m_lParam
= (WXLPARAM
)rInfo
.GetData();
2268 // Check whether it has any custom attributes
2270 if (rInfo
.HasAttributes())
2273 // Take copy of attributes
2275 pData
->m_pAttr
= new wxListItemAttr(*rInfo
.GetAttributes());
2278 if (!::WinSendMsg( GetHWND()
2285 // OS/2 must mannually bump the index's of following records
2287 BumpRecordIds( GetHWND()
2290 ::WinSendMsg( GetHWND()
2291 ,CM_INVALIDATEDETAILFIELDINFO
2295 return pRecord
->m_ulItemId
;
2296 } // end of wxListCtrl::InsertItem
2298 long wxListCtrl::InsertItem (
2300 , const wxString
& rsLabel
2305 memset(&vInfo
, '\0', sizeof(wxListItem
));
2306 vInfo
.m_text
= rsLabel
;
2307 vInfo
.m_mask
= wxLIST_MASK_TEXT
;
2308 vInfo
.m_itemId
= lIndex
;
2309 return InsertItem(vInfo
);
2310 } // end of wxListCtrl::InsertItem
2312 // Inserts an image item
2313 long wxListCtrl::InsertItem (
2320 vInfo
.m_image
= nImageIndex
;
2321 vInfo
.m_mask
= wxLIST_MASK_IMAGE
;
2322 vInfo
.m_itemId
= lIndex
;
2323 return InsertItem(vInfo
);
2324 } // end of wxListCtrl::InsertItem
2326 // Inserts an image/string item
2327 long wxListCtrl::InsertItem (
2329 , const wxString
& rsLabel
2335 vInfo
.m_image
= nImageIndex
;
2336 vInfo
.m_text
= rsLabel
;
2337 vInfo
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
2338 vInfo
.m_itemId
= lIndex
;
2339 return InsertItem(vInfo
);
2340 } // end of wxListCtrl::InsertItem
2342 // For details view mode (only), inserts a column.
2343 long wxListCtrl::InsertColumn (
2349 PFIELDINFO pField
= (PFIELDINFO
)::WinSendMsg( GetHWND()
2350 ,CM_ALLOCDETAILFIELDINFO
2354 PFIELDINFO pFieldAfter
= FindOS2ListFieldByColNum ( GetHWND()
2357 FIELDINFOINSERT vInsert
;
2359 ConvertToOS2ListCol ( lCol
2364 vInsert
.cb
= sizeof(FIELDINFOINSERT
);
2365 vInsert
.pFieldInfoOrder
= pFieldAfter
;
2366 vInsert
.fInvalidateFieldInfo
= TRUE
;
2367 vInsert
.cFieldInfoInsert
= 1;
2369 bSuccess
= ::WinSendMsg( GetHWND()
2370 ,CM_INSERTDETAILFIELDINFO
2375 } // end of wxListCtrl::InsertColumn
2377 long wxListCtrl::InsertColumn (
2379 , const wxString
& rsHeading
2386 vItem
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2387 vItem
.m_text
= rsHeading
;
2390 vItem
.m_mask
|= wxLIST_MASK_WIDTH
;
2391 vItem
.m_width
= nWidth
;
2393 vItem
.m_format
= nFormat
;
2395 return InsertColumn( lCol
2398 } // end of wxListCtrl::InsertColumn
2400 // scroll the control by the given number of pixels (exception: in list view,
2401 // dx is interpreted as number of columns)
2402 bool wxListCtrl::ScrollList ( int nDx
, int nDy
)
2405 ::WinSendMsg( GetHWND()
2407 ,(MPARAM
)CMA_HORIZONTAL
2411 ::WinSendMsg( GetHWND()
2413 ,(MPARAM
)CMA_VERTICAL
2417 } // end of wxListCtrl::ScrollList
2419 bool wxListCtrl::SortItems ( wxListCtrlCompare fn
, long lData
)
2421 SInternalDataSort vInternalData
;
2423 vInternalData
.m_fnUser
= fn
;
2424 vInternalData
.m_lData
= lData
;
2426 // WPARAM cast is needed for mingw/cygwin
2427 if (!::WinSendMsg( GetHWND()
2429 ,(PFN
)InternalDataCompareFunc
2430 ,(PVOID
)&vInternalData
2433 wxLogDebug(wxT("CM_SORTRECORD failed"));
2437 } // end of wxListCtrl::SortItems
2439 // ----------------------------------------------------------------------------
2440 // message processing
2441 // ----------------------------------------------------------------------------
2443 bool wxListCtrl::OS2Command ( WXUINT uCmd
, WXWORD wId
)
2445 if (uCmd
== CN_ENDEDIT
)
2447 wxCommandEvent
vEvent( wxEVT_TEXT
, wId
);
2449 vEvent
.SetEventObject( this );
2450 ProcessCommand(vEvent
);
2453 else if (uCmd
== CN_KILLFOCUS
)
2455 wxCommandEvent
vEvent( wxEVT_KILL_FOCUS
, wId
);
2456 vEvent
.SetEventObject( this );
2457 ProcessCommand(vEvent
);
2462 } // end of wxListCtrl::OS2Command
2464 // Necessary for drawing hrules and vrules, if specified
2465 void wxListCtrl::OnPaint ( wxPaintEvent
& rEvent
)
2467 wxPaintDC
vDc(this);
2468 wxPen
vPen(wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT
)
2472 wxSize vClientSize
= GetClientSize();
2474 int nItemCount
= GetItemCount();
2477 bool bDrawHRules
= ((GetWindowStyle() & wxLC_HRULES
) != 0);
2478 bool bDrawVRules
= ((GetWindowStyle() & wxLC_VRULES
) != 0);
2480 wxControl::OnPaint(rEvent
);
2483 // Reset the device origin since it may have been set
2485 vDc
.SetDeviceOrigin(0, 0);
2486 if (!bDrawHRules
&& !bDrawVRules
)
2488 if ((GetWindowStyle() & wxLC_REPORT
) == 0)
2491 vDc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2495 long lTop
= GetTopItem();
2497 for (i
= lTop
; i
< lTop
+ GetCountPerPage() + 1; i
++)
2503 nCy
= vItemRect
.GetTop();
2504 if (i
!= 0) // Don't draw the first one
2513 if (i
== nItemCount
- 1)
2515 nCy
= vItemRect
.GetBottom();
2526 if (bDrawVRules
&& (i
> -1))
2528 wxRect vFirstItemRect
;
2538 int nX
= vItemRect
.GetX();
2540 for (nCol
= 0; nCol
< GetColumnCount(); nCol
++)
2542 int nColWidth
= GetColumnWidth(nCol
);
2545 vDc
.DrawLine( nX
- 1
2546 ,vFirstItemRect
.GetY() - 2
2548 ,vItemRect
.GetBottom()
2553 } // end of wxListCtrl::OnPaint
2555 // ----------------------------------------------------------------------------
2556 // virtual list controls
2557 // ----------------------------------------------------------------------------
2559 wxString
wxListCtrl::OnGetItemText (
2560 long WXUNUSED(lItem
)
2561 , long WXUNUSED(lCol
)
2564 // this is a pure virtual function, in fact - which is not really pure
2565 // because the controls which are not virtual don't need to implement it
2566 wxFAIL_MSG( wxT("not supposed to be called") );
2567 return wxEmptyString
;
2568 } // end of wxListCtrl::OnGetItemText
2570 int wxListCtrl::OnGetItemImage (
2571 long WXUNUSED(lItem
)
2575 wxFAIL_MSG( wxT("not supposed to be called") );
2577 } // end of wxListCtrl::OnGetItemImage
2579 int wxListCtrl::OnGetItemColumnImage (
2585 return OnGetItemImage(lItem
);
2588 } // end of wxListCtrl::OnGetItemColumnImage
2590 void wxListCtrl::SetItemCount (
2594 wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") );
2597 // Cannot explicitly set the record count in OS/2
2599 } // end of wxListCtrl::SetItemCount
2601 void wxListCtrl::RefreshItem (
2611 } // end of wxListCtrl::RefreshItem
2613 void wxListCtrl::RefreshItems ( long lItemFrom
, long lItemTo
)
2618 GetItemRect( lItemFrom
, vRect1
);
2619 GetItemRect( lItemTo
, vRect2
);
2621 wxRect vRect
= vRect1
;
2623 vRect
.height
= vRect2
.GetBottom() - vRect1
.GetTop();
2625 } // end of wxListCtrl::RefreshItems
2627 MRESULT
wxListCtrl::OS2WindowProc( WXUINT uMsg
,
2631 bool bProcessed
= false;
2633 wxListEvent
vEvent( wxEVT_NULL
2636 wxEventType vEventType
= wxEVT_NULL
;
2637 PCNRDRAGINIT pDragInit
= NULL
;
2638 PCNREDITDATA pEditData
= NULL
;
2639 PNOTIFYRECORDENTER pNotifyEnter
= NULL
;
2641 vEvent
.SetEventObject(this);
2646 // First off let's set some internal data
2648 switch(SHORT2FROMMP(wParam
))
2654 CListItemInternalData
* pInternaldata
= (CListItemInternalData
*)lParam
;
2658 wxListItem
* pItem
= (wxListItem
*)&vEvent
.GetItem();
2660 pItem
->SetData((long)pInternaldata
->m_lParam
);
2666 // Now let's go through the codes we're interested in
2668 switch(SHORT2FROMMP(wParam
))
2671 pDragInit
= (PCNRDRAGINIT
)lParam
;
2674 PMYRECORD pRecord
= (PMYRECORD
)pDragInit
->pRecord
;
2676 vEventType
= wxEVT_LIST_BEGIN_RDRAG
;
2677 vEvent
.m_itemIndex
= pRecord
->m_ulItemId
;
2678 vEvent
.m_pointDrag
.x
= pDragInit
->x
;
2679 vEvent
.m_pointDrag
.y
= pDragInit
->y
;
2684 pEditData
= (PCNREDITDATA
)lParam
;
2687 vEventType
= wxEVT_LIST_BEGIN_LABEL_EDIT
;
2688 ConvertFromOS2ListItem( GetHWND()
2689 ,(wxListItem
&)vEvent
.GetItem()
2690 ,(PMYRECORD
)pEditData
->pRecord
2692 vEvent
.m_itemIndex
= vEvent
.GetItem().GetId();
2697 pEditData
= (PCNREDITDATA
)lParam
;
2700 vEventType
= wxEVT_LIST_END_LABEL_EDIT
;
2701 ConvertFromOS2ListItem( GetHWND()
2702 ,(wxListItem
&)vEvent
.GetItem()
2703 ,(PMYRECORD
)pEditData
->pRecord
2705 if (pEditData
->cbText
== 0)
2706 return (MRESULT
)FALSE
;
2707 vEvent
.m_itemIndex
= vEvent
.GetItem().GetId();
2712 pNotifyEnter
= (PNOTIFYRECORDENTER
)lParam
;
2715 wxListItem
* pItem
= (wxListItem
*)&vEvent
.GetItem();
2716 PMYRECORD pMyRecord
= (PMYRECORD
)pNotifyEnter
->pRecord
;
2718 vEventType
= wxEVT_LIST_ITEM_ACTIVATED
;
2719 vEvent
.m_itemIndex
= pMyRecord
->m_ulItemId
;
2720 pItem
->SetText(GetItemText(pMyRecord
->m_ulItemId
));
2721 pItem
->SetData(GetItemData(pMyRecord
->m_ulItemId
));
2726 // Add the CN_DROP messages for Direct Manipulation
2729 vEvent
.SetEventType(vEventType
);
2730 bProcessed
= HandleWindowEvent(vEvent
);
2734 lRc
= wxControl::OS2WindowProc( uMsg
2739 } // end of wxListCtrl::WindowProc
2741 #endif // wxUSE_LISTCTRL