O
Otto Wyss
I've the following function declaration:
wxTree GetLastChild (const wxTree& item, long& cookie) const;
I'd like to make the cookie parameter optional, i.e. "long& cookie =
....", without breaking any software using the old API. The
implementation looks like
wxTree wxTreeListMainWindow::GetLastChild (const wxTree& item,
long& cookie) const {
wxCHECK_MSG (item.IsOk(), wxTree(), wxT("invalid tree item"));
wxArrayTreeListItems& children = ((wxTreeListItem*)
item.m_pItem)->GetChildren();
// it's ok to cast cookie to long, indices won't overflow "void*"
long *pIndex = ((long*)&cookie);
(*pIndex) = children.Count();
return (!children.IsEmpty())? wxTree(children.Last()): wxTree();
}
BTW the cast is not from me! Is this optional parameter possible? If not
what alternatives are there?
Full source:
"http://cvs.sourceforge.net/viewcvs.py/wxcode/wxCode/components/treelist
ctrl/src/treelistctrl.cpp?view=markup"
O. Wyss
wxTree GetLastChild (const wxTree& item, long& cookie) const;
I'd like to make the cookie parameter optional, i.e. "long& cookie =
....", without breaking any software using the old API. The
implementation looks like
wxTree wxTreeListMainWindow::GetLastChild (const wxTree& item,
long& cookie) const {
wxCHECK_MSG (item.IsOk(), wxTree(), wxT("invalid tree item"));
wxArrayTreeListItems& children = ((wxTreeListItem*)
item.m_pItem)->GetChildren();
// it's ok to cast cookie to long, indices won't overflow "void*"
long *pIndex = ((long*)&cookie);
(*pIndex) = children.Count();
return (!children.IsEmpty())? wxTree(children.Last()): wxTree();
}
BTW the cast is not from me! Is this optional parameter possible? If not
what alternatives are there?
Full source:
"http://cvs.sourceforge.net/viewcvs.py/wxcode/wxCode/components/treelist
ctrl/src/treelistctrl.cpp?view=markup"
O. Wyss