added more methods to transparently convert wxTreeItemIdValue to wxTreeItemId to wxArrayTreeItemIds

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-10-03 17:54:09 +00:00
parent 27a1fd5880
commit 14ba002a91
2 changed files with 15 additions and 10 deletions

View File

@ -123,11 +123,19 @@ protected:
WX_DEFINE_EXPORTED_ARRAY_PTR(wxTreeItemIdValue, wxArrayTreeItemIdsBase);
// this is a wrapper around the array class defined above which allow to wok
// with vaue of natural wxTreeItemId type instead of using wxTreeItemIdValue
// and does it without any loss of efficiency
class WXDLLEXPORT wxArrayTreeItemIds : public wxArrayTreeItemIdsBase
{
public:
void Add(const wxTreeItemId& id)
{ wxArrayTreeItemIdsBase::Add(id.m_pItem); }
void Insert(const wxTreeItemId& id, size_t pos)
{ wxArrayTreeItemIdsBase::Insert(id.m_pItem, pos); }
wxTreeItemId Item(size_t i) const
{ return wxTreeItemId(wxArrayTreeItemIdsBase::Item(i)); }
wxTreeItemId operator[](size_t i) const { return Item(i); }
};
// ----------------------------------------------------------------------------

View File

@ -48,11 +48,8 @@
// macros to hide the cast ugliness
// --------------------------------
// ptr is the real item id, i.e. wxTreeItemId::m_pItem
#define HITEM_PTR(ptr) (HTREEITEM)(ptr)
// item here is a wxTreeItemId
#define HITEM(item) HITEM_PTR((item).m_pItem)
// get HTREEITEM from wxTreeItemId
#define HITEM(item) ((HTREEITEM)(((item).m_pItem)))
// the native control doesn't support multiple selections under MSW and we
// have 2 ways to emulate them: either using TVS_CHECKBOXES style and let
@ -1833,7 +1830,7 @@ void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item)
size_t nCount = children.Count();
for ( size_t n = 0; n < nCount; n++ )
{
if ( !TreeView_DeleteItem(GetHwnd(), HITEM_PTR(children[n])) )
if ( !TreeView_DeleteItem(GetHwnd(), HITEM(children[n])) )
{
wxLogLastError(wxT("TreeView_DeleteItem"));
}
@ -1945,9 +1942,9 @@ void wxTreeCtrl::UnselectAll()
for ( size_t n = 0; n < count; n++ )
{
#if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
SetItemCheck(HITEM_PTR(selections[n]), false);
SetItemCheck(HITEM(selections[n]), false);
#else // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
::UnselectItem(GetHwnd(), HITEM_PTR(selections[n]));
::UnselectItem(GetHwnd(), HITEM(selections[n]));
#endif // wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE/!wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
}
@ -2362,7 +2359,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
size_t count = GetSelections(selections);
if ( count == 0 ||
count > 1 ||
HITEM_PTR(selections[0]) != htItem )
HITEM(selections[0]) != htItem )
{
// clear the previously selected items, if the
// user clicked outside of the present selection.
@ -2504,7 +2501,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
{
// TreeView_GetItemRect() will return false if item is not visible,
// which may happen perfectly well
if ( TreeView_GetItemRect(GetHwnd(), HITEM_PTR(selections[n]),
if ( TreeView_GetItemRect(GetHwnd(), HITEM(selections[n]),
&rect, TRUE) )
{
::InvalidateRect(GetHwnd(), &rect, FALSE);