// Created: 01/21/03
// RCS-ID: $Id$
// Copyright: (c) David Webster
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
- #pragma implementation "listctrl.h"
- #pragma implementation "listctrlbase.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/settings.h"
+ #include "wx/dcclient.h"
+ #include "wx/textctrl.h"
#endif
-#include "wx/textctrl.h"
#include "wx/imaglist.h"
#include "wx/listctrl.h"
-#include "wx/dcclient.h"
#include "wx/os2/private.h"
/////////////////////////////////////////////////////////////////////////////
// STRUCT SMYRECORD
// Under OS/2 we have to use our own RECORDCORE based struct if we have
-// user data to store in a PM Container Control (and CListCtrl is a PM
-// Container in ICON, NAME, TEXT or DETAILview). m_ulUserData is a four
+// user data to store in a PM Container Control (and wxListCtrl is a PM
+// Container in ICON, NAME, TEXT or DETAIL view). m_ulUserData is a four
// byte value containing a pointer to our CListIntemInternalData class
// instance.
+//
+// And now for the big time OS/2 Kludge. In traditional OS/2 PM
+// applications using containers, programmers determine BEFORE creation
+// how many records the view will have, initially, and how many columns
+// the detail view of the container will have, as the container represents
+// a known data block. Thus the OS/2 PM CV_DETAIL view, i.e.
+// the wxWidgets wxLC_REPORT view, relies on STATIC structure for its
+// columnar data. It gets the data to display by telling it the specific
+// offset of the field in the struct containing the displayable data. That
+// data has be of OS/2 Types, PSZ (char string), CDATE or CTIME format.
+// wxWidgets is dynamic in nature, however. We insert columns, one at a
+// time and do not know how many until the app is done inserting them. So
+// for OS/2 I have to set a max allowable since they are fixed. We return
+// an error to the app if they include more than we can handle.
+//
+// For example to display the data "Col 4 of Item 6" in a report view, I'd
+// have to do:
+// pRecord->m_pzColumn4 = "Col 4 of Item 6";
+// pField->offStruct = FIELDOFFSET(MYRECORD, m_pzColumn4);
+// and then call the PM API to set it.
+//
+// This really stinks but I can't use a pointer to another struct as the
+// FIELDOFFSET call could only tell OS/2 the four byte value offset of
+// pointer field and it would display giberish in the column.
/////////////////////////////////////////////////////////////////////////////
typedef struct _MYRECORD
{
RECORDCORE m_vRecord;
unsigned long m_ulItemId;
- unsigned long m_ulUserData;
+ unsigned long m_ulUserData; //actually a pointer value to real data (a CListItemInternalData class instance)
+ PSZ m_pzColumn1;
+ PSZ m_pzColumn2;
+ PSZ m_pzColumn3;
+ PSZ m_pzColumn4;
+ PSZ m_pzColumn5;
+ PSZ m_pzColumn6;
+ PSZ m_pzColumn7;
+ PSZ m_pzColumn8;
+ PSZ m_pzColumn9;
+ PSZ m_pzColumn10;
} MYRECORD, *PMYRECORD;
/////////////////////////////////////////////////////////////////////////////
// Problem:
// The MSW version had problems with SetTextColour() et al as the
// CListItemAttr's were stored keyed on the item index. If a item was
-// inserted anywhere but the end of the list the the text attributes
+// inserted anywhere but the end of the list the text attributes
// (colour etc) for the following items were out of sync.
//
// Solution:
// Under MSW the only way to associate data with a
-// List item independant of its position in the list is to store a pointer
+// List item independent of its position in the list is to store a pointer
// to it in its lParam attribute. However user programs are already using
// this (via the SetItemData() GetItemData() calls).
//
~CListItemInternalData()
{
- delete m_pAttr;
- m_pAttr = NULL;
+ wxDELETE(m_pAttr);
}
wxListItemAttr* m_pAttr;
// none
//
/////////////////////////////////////////////////////////////////////////////
-void ConvertFromOS2ListItem (
- HWND hWndListCtrl
-, wxListItem& rInfo
-, PMYRECORD pRecord
-)
+void ConvertFromOS2ListItem ( HWND hWndListCtrl,
+ wxListItem& rInfo,
+ PMYRECORD pRecord )
{
- CListItemInternalData* pInternaldata = (CListItemInternalData *)pRecord->m_ulUserData;
- bool bNeedText = FALSE;
+ CListItemInternalData* pInternaldata = (CListItemInternalData *)pRecord->m_ulUserData;
+ bool bNeedText = false;
if (pInternaldata)
rInfo.SetData(pInternaldata->m_lParam);
// 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
+// 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
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->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( wxT("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();
{
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->pUserData = (void *)rItem.GetText().c_str();
+ pField->pTitleData = (PVOID)rItem.GetText().c_str(); // text is column title not data
}
if (rItem.GetMask() & wxLIST_MASK_FORMAT)
{
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 ||
pField->cxWidth = rItem.GetWidth();
// else: OS/2 automatically sets the width if created with the approppriate style
}
-} // 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)
+ //
+ // Still need to set the actual data
+ //
+ pField->offStruct = 0;
+} // end of ConvertToOS2ListCol
BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
EVT_PAINT(wxListCtrl::OnPaint)
m_pImageListNormal = NULL;
m_pImageListSmall = NULL;
m_pImageListState = NULL;
- m_bOwnsImageListNormal = FALSE;
- m_bOwnsImageListSmall = FALSE;
- m_bOwnsImageListState = FALSE;
+ m_bOwnsImageListNormal = false;
+ m_bOwnsImageListSmall = false;
+ m_bOwnsImageListState = false;
m_lBaseStyle = 0L;
m_nColCount = 0;
m_pTextCtrl = NULL;
- m_bAnyInternalData = FALSE;
- m_bHasAnyAttr = FALSE;
+ 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
-)
+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;
+ int nX = rPos.x;
+ int nY = rPos.y;
+ int nWidth = rSize.x;
+ int nHeight = rSize.y;
#if wxUSE_VALIDATORS
SetValidator(rValidator);
m_windowId = (vId == -1) ? NewControlId() : vId;
- long lSstyle = WS_VISIBLE | WS_TABSTOP;
+ long lSstyle = WS_VISIBLE | WS_TABSTOP;
if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
lSstyle |= WS_CLIPSIBLINGS;
,nWidth
,nHeight
))
- return FALSE;
+ return false;
if (pParent)
pParent->AddChild(this);
- return TRUE;
+ return true;
} // end of wxListCtrl::Create
-bool wxListCtrl::DoCreateControl (
- int nX
-, int nY
-, int nWidth
-, int nHeight
-)
+bool wxListCtrl::DoCreateControl ( int nX, int nY,
+ int nWidth, int nHeight )
{
- DWORD lWstyle = m_lBaseStyle;
- long lOldStyle = 0; // Dummy
+ DWORD lWstyle = m_lBaseStyle;
+ long lOldStyle = 0; // Dummy
- CNRINFO vCnrInfo;
+ CNRINFO vCnrInfo;
lWstyle |= ConvertToOS2Style( lOldStyle
,GetWindowStyleFlag()
);
if (!m_hWnd)
{
- return FALSE;
+ return false;
}
//
,MPFROMP(&vCnrInfo)
,(MPARAM)(USHORT)sizeof(CNRINFO)
))
+ return false;
lWstyle = ConvertViewToOS2Style(GetWindowStyleFlag());
- vCnrInfo.flWindowAttr != lWstyle;
- ::WinSendMsg( GetHWND()
- ,CM_SETCNRINFO
- ,MPFROMP(&vCnrInfo)
- ,(MPARAM)CMA_FLWINDOWATTR
- );
+ vCnrInfo.flWindowAttr |= lWstyle;
+ if (!::WinSendMsg( GetHWND()
+ ,CM_SETCNRINFO
+ ,MPFROMP(&vCnrInfo)
+ ,(MPARAM)CMA_FLWINDOWATTR
+ ))
+ return false;
//
// And now set needed arrangement flags
//
lWstyle = ConvertArrangeToOS2Style(GetWindowStyleFlag());
- ::WinSendMsg( GetHWND()
- ,CM_ARRANGE
- ,(MPARAM)CMA_ARRANGEGRID
- ,(MPARAM)lWstyle
- );
+ 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
- );
- return TRUE;
+ SetSize( nX, nY, nWidth, nHeight );
+ return true;
} // end of wxListCtrl::DoCreateControl
void wxListCtrl::UpdateStyle ()
{
if (GetHWND())
{
- long lDummy;
- DWORD dwStyleNew = ConvertToOS2Style( lDummy
- ,GetWindowStyleFlag()
- );
+ long lDummy;
+ DWORD dwStyleNew = ConvertToOS2Style( lDummy, GetWindowStyleFlag() );
dwStyleNew |= m_lBaseStyle;
//
// Get the current window style.
//
- ULONG dwStyleOld = ::WinQueryWindowULong(GetHWND(), QWL_STYLE);
+ ULONG dwStyleOld = ::WinQueryWindowULong(GetHWND(), QWL_STYLE);
//
// Only set the window style if the view bits have changed.
{
if (m_bAnyInternalData)
{
- int n = GetItemCount();
- int i = 0;
+ int n = GetItemCount();
+ int i = 0;
for (i = 0; i < n; i++)
DeleteInternalData(this, (long)i);
- m_bAnyInternalData = FALSE;
+ m_bAnyInternalData = false;
}
} // end of wxListCtrl::FreeAllInternalData
{
m_pTextCtrl->SetHWND(0);
m_pTextCtrl->UnsubclassWin();
- delete m_pTextCtrl;
- m_pTextCtrl = NULL;
+ wxDELETE(m_pTextCtrl);
}
if (m_bOwnsImageListNormal)
// ----------------------------------------------------------------------------
// Sets the foreground, i.e. text, colour
-bool wxListCtrl::SetForegroundColour (
- const wxColour& rCol)
+bool wxListCtrl::SetForegroundColour (const wxColour& rCol)
{
- ULONG ulColor = wxColourToRGB(rCol);
+ ULONG ulColor = wxColourToRGB(rCol);
if (!wxWindow::SetForegroundColour(rCol))
- return FALSE;
-
+ return false;
::WinSetPresParam( GetHWND()
,PP_FOREGROUNDCOLOR
,sizeof(ULONG)
,&ulColor
);
- return TRUE;
+ return true;
} // end of wxListCtrl::SetForegroundColour
// Sets the background colour
-bool wxListCtrl::SetBackgroundColour (
- const wxColour& rCol
-)
+bool wxListCtrl::SetBackgroundColour ( const wxColour& rCol )
{
if (!wxWindow::SetBackgroundColour(rCol))
- return FALSE;
+ return false;
//
// We set the same colour for both the "empty" background and the items
// background
//
- ULONG ulColor = wxColourToRGB(rCol);
+ ULONG ulColor = wxColourToRGB(rCol);
::WinSetPresParam( GetHWND()
,PP_BACKGROUNDCOLOR
,sizeof(ULONG)
,&ulColor
);
- return TRUE;
+ return true;
} // end of wxListCtrl::SetBackgroundColour
// Gets information about this column
-bool wxListCtrl::GetColumn (
- int nCol
-, wxListItem& rItem
-) const
+bool wxListCtrl::GetColumn ( int nCol, wxListItem& rItem ) const
{
- PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND()
- ,nCol
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND(), nCol );
if (!pFieldInfo)
- return FALSE;
+ return false;
rItem.SetWidth(pFieldInfo->cxWidth);
if ((rItem.GetMask() & wxLIST_MASK_TEXT) &&
(pFieldInfo->flData & CFA_STRING) &&
else if (pFieldInfo->flData & CFA_CENTER)
rItem.m_format = wxLIST_FORMAT_CENTRE;
}
- return TRUE;
+ return true;
} // end of wxListCtrl::GetColumn
// Sets information about this column
-bool wxListCtrl::SetColumn (
- int nCol
-, wxListItem& rItem
-)
+bool wxListCtrl::SetColumn ( int nCol, wxListItem& rItem )
{
- PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum( GetHWND()
- ,nCol
- );
- ConvertToOS2ListCol( nCol
- ,rItem
- ,pFieldInfo
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum( GetHWND(), nCol );
+ ConvertToOS2ListCol( nCol, rItem, pFieldInfo );
//
// Since we changed the field pointed to, we invalidate to see the result
//
::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO, NULL, NULL);
- return TRUE;
+ return true;
} // end of wxListCtrl::SetColumn
// Gets the column width
-int wxListCtrl::GetColumnWidth (
- int nCol
-) const
+int wxListCtrl::GetColumnWidth ( int nCol ) const
{
- PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND()
- ,nCol
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND(), nCol );
if (!pFieldInfo)
return 0;
} // end of wxListCtrl::GetColumnWidth
// Sets the column width
-bool wxListCtrl::SetColumnWidth (
- int nCol
-, int nWidth
-)
+bool wxListCtrl::SetColumnWidth ( int nCol, int nWidth )
{
- int nCol2 = nCol;
- int nWidth2 = nWidth;
+ int nCol2 = nCol;
+ int nWidth2 = nWidth;
if (GetWindowStyleFlag() & wxLC_LIST)
nCol2 = -1;
- PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum( GetHWND()
- ,nCol
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum( GetHWND(), nCol );
pFieldInfo->cxWidth = nWidth;
::WinSendMsg(GetHWND(), CM_INVALIDATEDETAILFIELDINFO, NULL, NULL);
- return TRUE;
+ return true;
} // end of wxListCtrl::SetColumnWidth
// Gets the number of items that can fit vertically in the
}
// Gets information about the item
-bool wxListCtrl::GetItem (
- wxListItem& rInfo
-) const
+bool wxListCtrl::GetItem ( wxListItem& rInfo ) const
{
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,rInfo.GetId()
- );
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), rInfo.GetId() );
//
// Give NULL as hwnd as we already have everything we need
//
- ConvertFromOS2ListItem( NULL
- ,rInfo
- ,pRecord
- );
- return TRUE;
+ ConvertFromOS2ListItem( NULL, rInfo, pRecord );
+ return true;
} // end of wxListCtrl::GetItem
// Sets information about the item
-bool wxListCtrl::SetItem (
- wxListItem& rInfo
-)
+bool wxListCtrl::SetItem ( wxListItem& rInfo )
{
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,rInfo.GetId()
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND(), rInfo.GetColumn() );
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), rInfo.GetId() );
ConvertToOS2ListItem( this
,rInfo
,pRecord
+ ,pFieldInfo
);
//
//
// Need to set it
//
- m_bAnyInternalData = TRUE;
+ m_bAnyInternalData = true;
pData = new CListItemInternalData();
pRecord->m_ulUserData = (unsigned long)pData;
};
else
pData->m_pAttr = new wxListItemAttr(*rInfo.GetAttributes());
}
+ pData->m_pMyRecord = pRecord; // they point to each other
}
//
// We need to update the item immediately to show the new image
//
- bool bUpdateNow = (rInfo.GetMask() & wxLIST_MASK_IMAGE) != 0;
+ bool bUpdateNow = (rInfo.GetMask() & wxLIST_MASK_IMAGE) != 0;
//
// Check whether it has any custom attributes
//
if (rInfo.HasAttributes())
{
- m_bHasAnyAttr = TRUE;
+ m_bHasAnyAttr = true;
//
// If the colour has changed, we must redraw the item
//
- bUpdateNow = TRUE;
+ bUpdateNow = true;
+ }
+ if (::WinIsWindowVisible(GetHWND()))
+ {
+ ::WinSendMsg( GetHWND()
+ ,CM_INVALIDATERECORD
+ ,MPFROMP(pRecord)
+ ,MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION | CMA_TEXTCHANGED)
+ );
+ RefreshItem(pRecord->m_ulItemId);
}
::WinSendMsg( GetHWND()
- ,CM_INVALIDATERECORD
- ,MPFROMP(pRecord)
- ,MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION | CMA_TEXTCHANGED)
+ ,CM_INVALIDATEDETAILFIELDINFO
+ ,NULL
+ ,NULL
);
- RefreshItem(pRecord->m_ulItemId);
- return TRUE;
+ return true;
} // end of wxListCtrl::SetItem
long wxListCtrl::SetItem (
} // end of wxListCtrl::GetItemState
// Sets the item state
-bool wxListCtrl::SetItemState (
- long lItem
-, long lState
-, long lStateMask
-)
+bool wxListCtrl::SetItemState ( long lItem, long lState, long lStateMask )
{
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,lItem
- );
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), lItem );
//
// Don't use SetItem() here as it doesn't work with the virtual list
// controls
//
- ConvertToOS2Flags( lState
- ,pRecord
- );
+ ConvertToOS2Flags( lState, pRecord );
//
// for the virtual list controls we need to refresh the previously focused
RefreshItem(lFocusOld);
}
}
- return TRUE;
+ return true;
} // end of wxListCtrl::SetItemState
// Sets the item image
long lItem
, int nImage
, int WXUNUSED(nSelImage))
+{
+ return SetItemColumnInfo(lItem, 0, nImage);
+} // end of wxListCtrl::SetItemImage
+
+// Sets the item image
+bool wxListCtrl::SetItemColumnImage (
+ long lItem
+, long lColumn
+, int nImage)
{
wxListItem vInfo;
vInfo.m_mask = wxLIST_MASK_IMAGE;
vInfo.m_image = nImage;
vInfo.m_itemId = lItem;
+ vInfo.m_col = lColumn;
return SetItem(vInfo);
-} // end of wxListCtrl::SetItemImage
+} // end of wxListCtrl::SetItemColumnImage
// Gets the item text
wxString wxListCtrl::GetItemText (
} // end of wxListCtrl::GetItemData
// Sets the item data
-bool wxListCtrl::SetItemData (
+bool wxListCtrl::SetItemPtrData (
long lItem
-, long lData
+, wxUIntPtr lData
)
{
wxListItem vInfo;
vInfo.m_itemId = lItem;
vInfo.m_data = lData;
return SetItem(vInfo);
-} // end of wxListCtrl::SetItemData
+} // end of wxListCtrl::SetItemPtrData
// Gets the item rectangle
-bool wxListCtrl::GetItemRect (
- long lItem
-, wxRect& rRect
-, int nCode
-) const
+bool wxListCtrl::GetItemRect ( long lItem,
+ wxRect& rRect,
+ int nCode ) const
{
- bool bSuccess;
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,lItem
- );
- QUERYRECORDRECT vQueryRect;
- RECTL vRect;
- int nHeight;
+ bool bSuccess;
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), lItem );
+ QUERYRECORDRECT vQueryRect;
+ RECTL vRect;
+ int nHeight;
if (!pRecord)
- return FALSE;
+ return false;
vQueryRect.cb = sizeof(QUERYRECORDRECT);
vQueryRect.pRecord = &pRecord->m_vRecord;
vQueryRect.fRightSplitWindow = TRUE;
//
// remember OS/2 is backwards
//
- GetClientSize( NULL
- ,&nHeight
- );
+ GetClientSize( NULL, &nHeight );
rRect.x = vRect.xLeft;
rRect.y = nHeight - vRect.yTop;
rRect.width = vRect.xRight;
rRect.height = nHeight - vRect.yBottom;
- bSuccess = TRUE;
+ bSuccess = true;
return bSuccess;
} // end of wxListCtrl::GetItemRect
// Gets the item position
-bool wxListCtrl::GetItemPosition (
- long lItem
-, wxPoint& rPos
-) const
+bool wxListCtrl::GetItemPosition ( long lItem, wxPoint& rPos ) const
{
- bool bSuccess;
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,lItem
- );
- QUERYRECORDRECT vQueryRect;
- RECTL vRect;
- int nHeight;
+ bool bSuccess;
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND() , lItem );
+ QUERYRECORDRECT vQueryRect;
+ RECTL vRect;
+ int nHeight;
if (!pRecord)
- return FALSE;
+ return false;
vQueryRect.cb = sizeof(QUERYRECORDRECT);
vQueryRect.pRecord = &pRecord->m_vRecord;
vQueryRect.fRightSplitWindow = TRUE;
//
// remember OS/2 is backwards
//
- GetClientSize( NULL
- ,&nHeight
- );
+ GetClientSize( NULL, &nHeight );
rPos.x = vRect.xLeft;
rPos.y = nHeight - vRect.yTop;
- bSuccess = TRUE;
+ bSuccess = true;
return bSuccess;
} // end of wxListCtrl::GetItemPosition
// Sets the item position.
-bool wxListCtrl::SetItemPosition (
- long lItem
-, const wxPoint& rPos
-)
+bool wxListCtrl::SetItemPosition ( long lItem, const wxPoint& rPos )
{
//
// Items cannot be positioned in X/Y coord in OS/2
//
- return FALSE;
+ return false;
} // end of wxListCtrl::SetItemPosition
// Gets the number of items in the list control
} // end of wxListCtrl::GetItemCount
// Retrieves the spacing between icons in pixels.
-// If small is TRUE, gets the spacing for the small icon
+// If bIsSmall is true, gets the spacing for the small icon
// view, otherwise the large icon view.
-int wxListCtrl::GetItemSpacing (
- bool bIsSmall
-) const
+int wxListCtrl::GetItemSpacing ( bool bIsSmall ) const
{
CNRINFO vCnrInfo;
return NULL;
} // end of wxListCtrl::GetImageList
-void wxListCtrl::SetImageList (
- wxImageList* pImageList
-, int nWhich
-)
+void wxListCtrl::SetImageList ( wxImageList* pImageList,
+ int nWhich )
{
if (nWhich == wxIMAGE_LIST_NORMAL)
{
if (m_bOwnsImageListNormal)
delete m_pImageListNormal;
m_pImageListNormal = pImageList;
- m_bOwnsImageListNormal = FALSE;
+ m_bOwnsImageListNormal = false;
}
else if (nWhich == wxIMAGE_LIST_SMALL)
{
if (m_bOwnsImageListSmall)
delete m_pImageListSmall;
m_pImageListSmall = pImageList;
- m_bOwnsImageListSmall = FALSE;
+ m_bOwnsImageListSmall = false;
}
else if (nWhich == wxIMAGE_LIST_STATE)
{
if (m_bOwnsImageListState)
delete m_pImageListState;
m_pImageListState = pImageList;
- m_bOwnsImageListState = FALSE;
+ m_bOwnsImageListState = false;
}
} // end of wxListCtrl::SetImageList
-void wxListCtrl::AssignImageList (
- wxImageList* pImageList
-, int nWhich
-)
+void wxListCtrl::AssignImageList ( wxImageList* pImageList, int nWhich )
{
- SetImageList( pImageList
- ,nWhich
- );
+ SetImageList( pImageList, nWhich );
+
if (nWhich == wxIMAGE_LIST_NORMAL )
- m_bOwnsImageListNormal = TRUE;
+ m_bOwnsImageListNormal = true;
else if (nWhich == wxIMAGE_LIST_SMALL )
- m_bOwnsImageListSmall = TRUE;
+ m_bOwnsImageListSmall = true;
else if (nWhich == wxIMAGE_LIST_STATE )
- m_bOwnsImageListState = TRUE;
+ m_bOwnsImageListState = true;
} // end of wxListCtrl::AssignImageList
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Arranges the items
-bool wxListCtrl::Arrange (
- int nFlag
-)
+bool wxListCtrl::Arrange ( int nFlag )
{
- ULONG ulType = 0L;
- ULONG ulFlags = 0L;
+ ULONG ulType = 0L;
+ ULONG ulFlags = 0L;
if (nFlag == wxLIST_ALIGN_SNAP_TO_GRID)
{
//
// We do not support CMA_ARRANGESELECTED
//
- return TRUE;
+ return true;
} // end of wxListCtrl::Arrange
// Deletes an item
-bool wxListCtrl::DeleteItem (
- long lItem
-)
+bool wxListCtrl::DeleteItem ( long lItem )
{
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,lItem
- );
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), lItem );
if (LONGFROMMR(::WinSendMsg( GetHWND()
,CM_REMOVERECORD
,(MPARAM)pRecord
,MPFROM2SHORT(1, CMA_FREE)
)) == -1L)
{
- return FALSE;
+ return false;
}
//
vRectWin.y = vRectItem.GetBottom();
RefreshRect(vRectWin);
}
- return TRUE;
+ return true;
} // end of wxListCtrl::DeleteItem
// Deletes all items
}
wxASSERT_MSG(m_nColCount == 0, wxT("no columns should be left"));
- return TRUE;
+ return true;
} // end of wxListCtrl::DeleteAllColumns
// Deletes a column
-bool wxListCtrl::DeleteColumn (
- int nCol
-)
+bool wxListCtrl::DeleteColumn ( int nCol )
{
- bool bSuccess = FALSE;
- PFIELDINFO pField = FindOS2ListFieldByColNum( GetHWND()
- ,nCol
- );
+ bool bSuccess = false;
+ PFIELDINFO pField = FindOS2ListFieldByColNum( GetHWND(), nCol );
bSuccess = ((LONG)::WinSendMsg( GetHWND()
,CM_REMOVEDETAILFIELDINFO
,MPFROMP(pField)
// End label editing, optionally cancelling the edit. Under OS/2 you close
// the record for editting
-bool wxListCtrl::EndEditLabel (
- bool WXUNUSED(bCancel)
-)
+bool wxListCtrl::EndEditLabel ( bool WXUNUSED(bCancel) )
{
::WinSendMsg( GetHWND()
,CM_CLOSEEDIT
,(MPARAM)0
,(MPARAM)0
);
- return TRUE;
+ return true;
} // end of wxListCtrl::EndEditLabel
// Ensures this item is visible
-bool wxListCtrl::EnsureVisible (
- long lItem
-)
+bool wxListCtrl::EnsureVisible ( long lItem )
{
- PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND()
- ,lItem
- );
+ PMYRECORD pRecord = FindOS2ListRecordByID( GetHWND(), lItem );
::WinSendMsg( GetHWND()
,CM_INVALIDATERECORD
,MPFROMP(pRecord)
,MPFROM2SHORT((SHORT)1, CMA_NOREPOSITION)
);
- return TRUE;
+ return true;
} // end of wxListCtrl::EnsureVisible
// Find an item whose label matches this string, starting from the item after 'start'
vLibRect.SetTop(vRect.yTop);
vLibRect.SetRight(vRect.xRight);
vLibRect.SetBottom(vRect.yBottom);
- if (vLibRect.Inside(rPoint))
+ if (vLibRect.Contains(rPoint))
return pRecord->m_ulItemId;
for (i = lStart + 1; i < vCnrInfo.cRecords; i++)
vLibRect.SetTop(vRect.yTop);
vLibRect.SetRight(vRect.xRight);
vLibRect.SetBottom(vRect.yBottom);
- if (vLibRect.Inside(rPoint))
+ if (vLibRect.Contains(rPoint))
return pRecord->m_ulItemId;
}
return -1L;
wxListItem& rInfo
)
{
- wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
+ wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual controls") );
- PMYRECORD pRecordAfter = FindOS2ListRecordByID ( GetHWND()
- ,rInfo.GetId() - 1
- );
+ PFIELDINFO pFieldInfo = FindOS2ListFieldByColNum ( GetHWND()
+ ,rInfo.GetColumn()
+ );
+ PMYRECORD pRecordAfter = NULL;
PMYRECORD pRecord = (PMYRECORD)::WinSendMsg( GetHWND()
,CM_ALLOCRECORD
,MPFROMLONG(sizeof(MYRECORD) - sizeof(RECORDCORE))
- ,MPFROMLONG(1)
+ ,MPFROMSHORT(1)
);
+
+ ConvertToOS2ListItem( this
+ ,rInfo
+ ,pRecord
+ ,pFieldInfo
+ );
+
+ if (rInfo.GetId() > 0)
+ pRecordAfter = FindOS2ListRecordByID( GetHWND()
+ ,rInfo.GetId() - 1
+ );
+
RECORDINSERT vInsert;
vInsert.cb = sizeof(RECORDINSERT);
- vInsert.pRecordOrder = (PRECORDCORE)pRecordAfter;
vInsert.pRecordParent = NULL;
- vInsert.fInvalidateRecord = TRUE;
+ if (!pRecordAfter)
+ vInsert.pRecordOrder = (PRECORDCORE)CMA_FIRST;
+ else
+ vInsert.pRecordOrder = (PRECORDCORE)pRecordAfter;
vInsert.zOrder = CMA_TOP;
vInsert.cRecordsInsert = 1;
-
- ConvertToOS2ListItem( this
- ,rInfo
- ,pRecord
- );
+ vInsert.fInvalidateRecord = TRUE;
//
- // Check wether we need to allocate our internal data
+ // Check whether we need to allocate our internal data
//
bool bNeedInternalData = ((rInfo.GetMask() & wxLIST_MASK_DATA) ||
rInfo.HasAttributes()
);
if (bNeedInternalData)
{
- m_bAnyInternalData = TRUE;
+ m_bAnyInternalData = true;
//
// Internal stucture that manages data
pData->m_pAttr = new wxListItemAttr(*rInfo.GetAttributes());
}
}
- ::WinSendMsg( GetHWND()
- ,CM_INSERTRECORD
- ,MPFROMP(pRecord)
- ,MPFROMP(pRecordAfter)
- );
+ if (!::WinSendMsg( GetHWND()
+ ,CM_INSERTRECORD
+ ,MPFROMP(pRecord)
+ ,MPFROMP(&vInsert)
+ ))
+ return -1;
//
// OS/2 must mannually bump the index's of following records
//
BumpRecordIds( GetHWND()
,pRecord
);
+ ::WinSendMsg( GetHWND()
+ ,CM_INVALIDATEDETAILFIELDINFO
+ ,NULL
+ ,NULL
+ );
return pRecord->m_ulItemId;
} // end of wxListCtrl::InsertItem
{
wxListItem vInfo;
+ memset(&vInfo, '\0', sizeof(wxListItem));
vInfo.m_text = rsLabel;
vInfo.m_mask = wxLIST_MASK_TEXT;
vInfo.m_itemId = lIndex;
);
FIELDINFOINSERT vInsert;
+ ConvertToOS2ListCol ( lCol
+ ,rItem
+ ,pField
+ );
+
vInsert.cb = sizeof(FIELDINFOINSERT);
vInsert.pFieldInfoOrder = pFieldAfter;
vInsert.fInvalidateFieldInfo = TRUE;
vInsert.cFieldInfoInsert = 1;
- ConvertToOS2ListCol ( lCol
- ,rItem
- ,pField
- );
bSuccess = ::WinSendMsg( GetHWND()
,CM_INSERTDETAILFIELDINFO
,MPFROMP(pField)
// scroll the control by the given number of pixels (exception: in list view,
// dx is interpreted as number of columns)
-bool wxListCtrl::ScrollList (
- int nDx
-, int nDy
-)
+bool wxListCtrl::ScrollList ( int nDx, int nDy )
{
if (nDx > 0)
::WinSendMsg( GetHWND()
,(MPARAM)CMA_VERTICAL
,(MPARAM)nDy
);
- return TRUE;
+ return true;
} // end of wxListCtrl::ScrollList
-bool wxListCtrl::SortItems (
- wxListCtrlCompare fn
-, long lData
-)
+bool wxListCtrl::SortItems ( wxListCtrlCompare fn, long lData )
{
- SInternalDataSort vInternalData;
+ SInternalDataSort vInternalData;
vInternalData.m_fnUser = fn;
vInternalData.m_lData = lData;
,(PVOID)&vInternalData
))
{
- wxLogDebug(_T("CM_SORTRECORD failed"));
- return FALSE;
+ wxLogDebug(wxT("CM_SORTRECORD failed"));
+ return false;
}
- return TRUE;
+ return true;
} // end of wxListCtrl::SortItems
// ----------------------------------------------------------------------------
// message processing
// ----------------------------------------------------------------------------
-bool wxListCtrl::OS2Command (
- WXUINT uCmd
-, WXWORD wId
-)
+bool wxListCtrl::OS2Command ( WXUINT uCmd, WXWORD wId )
{
if (uCmd == CN_ENDEDIT)
{
- wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED
- ,wId
- );
+ wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED, wId );
vEvent.SetEventObject( this );
ProcessCommand(vEvent);
- return TRUE;
+ return true;
}
else if (uCmd == CN_KILLFOCUS)
{
- wxCommandEvent vEvent( wxEVT_KILL_FOCUS
- ,wId
- );
+ wxCommandEvent vEvent( wxEVT_KILL_FOCUS, wId );
vEvent.SetEventObject( this );
ProcessCommand(vEvent);
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
} // end of wxListCtrl::OS2Command
// Necessary for drawing hrules and vrules, if specified
-void wxListCtrl::OnPaint (
- wxPaintEvent& rEvent
-)
+void wxListCtrl::OnPaint ( wxPaintEvent& rEvent )
{
wxPaintDC vDc(this);
wxPen vPen(wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT)
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
- wxFAIL_MSG( _T("not supposed to be called") );
+ wxFAIL_MSG( wxT("not supposed to be called") );
return wxEmptyString;
} // end of wxListCtrl::OnGetItemText
) const
{
// same as above
- wxFAIL_MSG( _T("not supposed to be called") );
+ wxFAIL_MSG( wxT("not supposed to be called") );
return -1;
} // end of wxListCtrl::OnGetItemImage
-wxListItemAttr* wxListCtrl::OnGetItemAttr (
- long WXUNUSED_UNLESS_DEBUG(lItem)
+int wxListCtrl::OnGetItemColumnImage (
+ long lItem,
+ long lColumn
) const
{
- wxASSERT_MSG( lItem >= 0 && lItem < GetItemCount(),
- _T("invalid item index in OnGetItemAttr()") );
+ if (!lColumn)
+ return OnGetItemImage(lItem);
- //
- // No attributes by default
- //
- return NULL;
-} // end of wxListCtrl::OnGetItemAttr
+ return -1;
+} // end of wxListCtrl::OnGetItemColumnImage
void wxListCtrl::SetItemCount (
long lCount
)
{
- wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
+ wxASSERT_MSG( IsVirtual(), wxT("this is for virtual controls only") );
//
// Cannot explicitly set the record count in OS/2
RefreshRect(vRect);
} // end of wxListCtrl::RefreshItem
-void wxListCtrl::RefreshItems (
- long lItemFrom
-, long lItemTo
-)
+void wxListCtrl::RefreshItems ( long lItemFrom, long lItemTo )
{
- wxRect vRect1;
- wxRect vRect2;
+ wxRect vRect1;
+ wxRect vRect2;
- GetItemRect( lItemFrom
- ,vRect1
- );
- GetItemRect( lItemTo
- ,vRect2
- );
+ GetItemRect( lItemFrom , vRect1 );
+ GetItemRect( lItemTo , vRect2 );
- wxRect vRect = vRect1;
+ wxRect vRect = vRect1;
vRect.height = vRect2.GetBottom() - vRect1.GetTop();
RefreshRect(vRect);
} // end of wxListCtrl::RefreshItems
-MRESULT wxListCtrl::OS2WindowProc(
- WXUINT uMsg
-, WXWPARAM wParam
-, WXLPARAM lParam
-)
+MRESULT wxListCtrl::OS2WindowProc( WXUINT uMsg,
+ WXWPARAM wParam,
+ WXLPARAM lParam )
{
- bool bProcessed = FALSE;
+ bool bProcessed = false;
MRESULT lRc;
wxListEvent vEvent( wxEVT_NULL
,m_windowId
//
}
vEvent.SetEventType(vEventType);
- bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+ bProcessed = HandleWindowEvent(vEvent);
break;
}
if (!bProcessed)