+ //
+ // The wxListItem class is really set up to handle the WIN32 list item
+ // and OS/2 are not as complicated. Just set both state members to the
+ // same thing under OS/2
+ //
+ if (pRecord->m_vRecord.flRecordAttr & CRA_DROPONABLE)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_DROPHILITED);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_DROPHILITED);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_SELECTED)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_SELECTED);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_SELECTED);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_DISABLED)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_DISABLED);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_DISABLED);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_FILTERED)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_FILTERED);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_FILTERED);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_INUSE)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_INUSE);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_INUSE);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_PICKED)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_PICKED);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_PICKED);
+ }
+ if (pRecord->m_vRecord.flRecordAttr & CRA_SOURCE)
+ {
+ rInfo.SetStateMask(rInfo.m_stateMask | wxLIST_STATE_SOURCE);
+ rInfo.SetState(rInfo.m_state | wxLIST_STATE_SOURCE);
+ }
+
+ if (pRecord->m_vRecord.pszText != (PSZ)NULL)
+ {
+ rInfo.SetMask(rInfo.GetMask() | wxLIST_MASK_TEXT);
+ rInfo.SetText(pRecord->m_vRecord.pszText);
+ }
+ if (pRecord->m_vRecord.pszIcon != (PSZ)NULL ||
+ pRecord->m_vRecord.pszName != (PSZ)NULL)
+ {
+ rInfo.SetMask(rInfo.GetMask() | wxLIST_MASK_IMAGE);
+ rInfo.SetImage(pRecord->m_vRecord.hptrIcon);
+ }
+ if (pRecord->m_ulUserData)
+ rInfo.SetMask(rInfo.GetMask() | wxLIST_MASK_DATA);
+} // end of ConvertFromOS2ListItem
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// ConvertToOS2Flags
+//
+// Convert from an library states to OS states
+//
+// PARAMETERS
+// lState -- the state
+// pRecord -- the OS list control to use
+//
+// RETURN VALUE
+// none
+//
+/////////////////////////////////////////////////////////////////////////////
+void ConvertToOS2Flags (
+ long lState
+, PMYRECORD pRecord
+)
+{
+ if (lState & wxLIST_STATE_DROPHILITED)
+ pRecord->m_vRecord.flRecordAttr |= CRA_DROPONABLE;
+ if (lState & wxLIST_STATE_SELECTED)
+ pRecord->m_vRecord.flRecordAttr |= CRA_SELECTED;
+ if (lState & wxLIST_STATE_DISABLED)
+ pRecord->m_vRecord.flRecordAttr |= CRA_DISABLED;
+ if (lState & wxLIST_STATE_FILTERED)
+ pRecord->m_vRecord.flRecordAttr |= CRA_FILTERED;
+ if (lState & wxLIST_STATE_INUSE)
+ pRecord->m_vRecord.flRecordAttr |= CRA_INUSE;
+ if (lState & wxLIST_STATE_PICKED)
+ pRecord->m_vRecord.flRecordAttr |= CRA_PICKED;
+ if (lState & wxLIST_STATE_SOURCE)
+ pRecord->m_vRecord.flRecordAttr |= CRA_SOURCE;
+} // end of ConvertToOS2Flags
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// ConvertToOS2ListItem
+//
+// Convert from a library List item to an internal OS2 List item. We set
+// only the fields we need to set. Some of them are set by the API when
+// they are added to the container.
+//
+// PARAMETERS
+// pCtrl -- the control to use
+// rInfo -- the item to convert
+// pRecord -- the OS list control to use, should be zeroed out
+// pFieldinfo -- a field struct that may contain columnar data for detail view
+//
+// RETURN VALUE
+// none
+//
+/////////////////////////////////////////////////////////////////////////////
+void ConvertToOS2ListItem (
+ const wxListCtrl* pCtrl
+, const wxListItem& rInfo
+, PMYRECORD pRecord
+, PFIELDINFO pFieldInfo
+)
+{
+ pRecord->m_ulItemId = (ULONG)rInfo.GetId();
+ pRecord->m_vRecord.cb = sizeof(RECORDCORE);
+ if (rInfo.GetMask() & wxLIST_MASK_STATE)
+ {
+ ConvertToOS2Flags( rInfo.m_state
+ ,pRecord
+ );
+ }
+ if (pCtrl->GetWindowStyleFlag() & wxLC_ICON ||
+ pCtrl->GetWindowStyleFlag() & wxLC_SMALL_ICON)
+ {
+ pRecord->m_vRecord.pszIcon = (char*)rInfo.GetText().c_str();
+ }
+ if (pCtrl->GetWindowStyleFlag() & wxLC_LIST) // PM TEXT view
+ {
+ pRecord->m_vRecord.pszText = (char*)rInfo.GetText().c_str();
+ }
+ //
+ // In the case of a report view the text will be the data in the lead column
+ // ???? Don't know why, but that is how it works in other ports.
+ //
+ if (pCtrl->GetWindowStyleFlag() & wxLC_REPORT)
+ {
+ if (pFieldInfo)
+ {
+ switch(rInfo.GetColumn())
+ {
+ case 0:
+ pRecord->m_pzColumn1 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn1);
+ break;
+
+ case 1:
+ pRecord->m_pzColumn2 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn2);
+ break;
+
+ case 2:
+ pRecord->m_pzColumn3 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn3);
+ break;
+
+ case 3:
+ pRecord->m_pzColumn4 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn4);
+ break;
+
+ case 4:
+ pRecord->m_pzColumn5 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn5);
+ break;
+
+ case 5:
+ pRecord->m_pzColumn6 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn6);
+ break;
+
+ case 6:
+ pRecord->m_pzColumn7 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn7);
+ break;
+
+ case 7:
+ pRecord->m_pzColumn8 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn8);
+ break;
+
+ case 8:
+ pRecord->m_pzColumn9 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn9);
+ break;
+
+ case 9:
+ pRecord->m_pzColumn10 = (char*)rInfo.GetText().c_str();
+ pFieldInfo->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn10);
+ break;
+
+ default:
+ wxFAIL_MSG( _T("wxOS2 does not support more than 10 columns in REPORT view") );
+ break;
+ }
+ }
+ }
+ if (rInfo.GetMask() & wxLIST_MASK_IMAGE)
+ {
+ pRecord->m_vRecord.hptrIcon = (HPOINTER)rInfo.GetImage();
+ pRecord->m_vRecord.hptrMiniIcon = (HPOINTER)rInfo.m_miniImage;
+ }
+} // end of ConvertToOS2ListItem
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// ConvertToOS2ListCol
+//
+// Convert from a library List column to an internal PM List column
+//
+// PARAMETERS
+// lCol -- the columnd to convert
+// rItem -- the item to convert
+// pField -- the OS list column to use
+//
+// RETURN VALUE
+// none
+//
+/////////////////////////////////////////////////////////////////////////////
+void ConvertToOS2ListCol (
+ long lCol
+, const wxListItem& rItem
+, PFIELDINFO pField
+)
+{
+ memset(pField, '\0', sizeof(FIELDINFO));
+ pField->cb = sizeof(FIELDINFO);
+
+ //
+ // Default some settings
+ //
+ pField->flData = CFA_HORZSEPARATOR | CFA_SEPARATOR;
+ pField->flTitle = CFA_CENTER;
+
+ if (rItem.GetMask() & wxLIST_MASK_TEXT)
+ {
+ pField->flData |= CFA_STRING;
+ pField->pTitleData = (PVOID)rItem.GetText().c_str(); // text is column title not data
+ }
+ if (rItem.GetMask() & wxLIST_MASK_FORMAT)
+ {
+ if (rItem.m_format == wxLIST_FORMAT_LEFT)
+ pField->flData |= CFA_LEFT;
+ else if (rItem.m_format == wxLIST_FORMAT_RIGHT)
+ pField->flData |= CFA_RIGHT;
+ else if (rItem.m_format == wxLIST_FORMAT_CENTRE)
+ pField->flData |= CFA_CENTER;
+ }
+ else
+ pField->flData |= CFA_CENTER; // Just ensure the default is centered
+ if (rItem.GetMask() & wxLIST_MASK_WIDTH)
+ {
+ if (!(rItem.GetWidth() == wxLIST_AUTOSIZE ||
+ rItem.GetWidth() == wxLIST_AUTOSIZE_USEHEADER))
+ pField->cxWidth = rItem.GetWidth();
+ // else: OS/2 automatically sets the width if created with the approppriate style
+ }
+
+ //
+ // Still need to set the actual data
+ //
+ pField->offStruct = 0;
+} // end of ConvertToOS2ListCol
+
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
+
+IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
+IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
+
+IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
+
+BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
+ EVT_PAINT(wxListCtrl::OnPaint)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxListCtrl construction
+// ----------------------------------------------------------------------------
+
+void wxListCtrl::Init ()
+{
+ m_pImageListNormal = NULL;
+ m_pImageListSmall = NULL;
+ m_pImageListState = NULL;
+ m_bOwnsImageListNormal = FALSE;
+ m_bOwnsImageListSmall = FALSE;
+ m_bOwnsImageListState = FALSE;
+ m_lBaseStyle = 0L;
+ m_nColCount = 0;
+ m_pTextCtrl = NULL;
+ m_bAnyInternalData = FALSE;
+ m_bHasAnyAttr = FALSE;
+} // end of wxListCtrl::Init
+
+bool wxListCtrl::Create (
+ wxWindow* pParent
+, wxWindowID vId
+, const wxPoint& rPos
+, const wxSize& rSize
+, long lStyle
+, const wxValidator& rValidator
+, const wxString& rsName
+)
+{
+ int nX = rPos.x;
+ int nY = rPos.y;
+ int nWidth = rSize.x;
+ int nHeight = rSize.y;
+
+#if wxUSE_VALIDATORS
+ SetValidator(rValidator);
+#endif // wxUSE_VALIDATORS
+
+ SetName(rsName);
+ SetWindowStyleFlag(lStyle);
+ SetParent(pParent);
+ if (nWidth <= 0)
+ nWidth = 100;
+ if (nHeight <= 0)
+ nHeight = 30;
+ if (nX < 0)
+ nX = 0;
+ if (nY < 0)
+ nY = 0;
+
+ m_windowId = (vId == -1) ? NewControlId() : vId;
+
+ long lSstyle = WS_VISIBLE | WS_TABSTOP;
+
+ if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
+ lSstyle |= WS_CLIPSIBLINGS;
+ m_lBaseStyle = lSstyle;
+ if (!DoCreateControl( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ ))
+ return FALSE;
+ if (pParent)
+ pParent->AddChild(this);
+ return TRUE;
+} // end of wxListCtrl::Create
+
+bool wxListCtrl::DoCreateControl (
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+)
+{
+ DWORD lWstyle = m_lBaseStyle;
+ long lOldStyle = 0; // Dummy
+
+ CNRINFO vCnrInfo;
+
+ lWstyle |= ConvertToOS2Style( lOldStyle
+ ,GetWindowStyleFlag()
+ );
+
+ m_hWnd = (WXHWND)::WinCreateWindow( GetParent()->GetHWND()
+ ,WC_CONTAINER
+ ,NULL
+ ,m_lBaseStyle
+ ,0, 0, 0, 0
+ ,GetParent()->GetHWND()
+ ,HWND_BOTTOM
+ ,(ULONG)m_windowId
+ ,NULL
+ ,NULL
+ );
+ if (!m_hWnd)
+ {
+ return FALSE;
+ }
+
+ //
+ // Now set the display attributes of the container
+ //
+ if (!::WinSendMsg( GetHWND()
+ ,CM_QUERYCNRINFO
+ ,MPFROMP(&vCnrInfo)
+ ,(MPARAM)(USHORT)sizeof(CNRINFO)
+ ))
+ return FALSE;
+ lWstyle = ConvertViewToOS2Style(GetWindowStyleFlag());
+ vCnrInfo.flWindowAttr |= lWstyle;
+ if (!::WinSendMsg( GetHWND()
+ ,CM_SETCNRINFO
+ ,MPFROMP(&vCnrInfo)
+ ,(MPARAM)CMA_FLWINDOWATTR
+ ))
+ return FALSE;
+
+ //
+ // And now set needed arrangement flags
+ //
+ lWstyle = ConvertArrangeToOS2Style(GetWindowStyleFlag());
+ if (!::WinSendMsg( GetHWND()
+ ,CM_ARRANGE
+ ,(MPARAM)CMA_ARRANGEGRID
+ ,(MPARAM)lWstyle
+ ))
+ return FALSE;
+ SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+ SetForegroundColour(GetParent()->GetForegroundColour());
+ SubclassWin(m_hWnd);
+ SetFont(*wxSMALL_FONT);
+ SetXComp(0);
+ SetYComp(0);
+ SetSize( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );