git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61134
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
changed. See the updated wxWindow::SetBackgroundStyle() description in the
manual for more details.
changed. See the updated wxWindow::SetBackgroundStyle() description in the
manual for more details.
+- wxTreeCtrl::GetSelection now asserts if the tree has the wxTR_MULTIPLE style.
+ Instead use GetSelections() for multiple items; or if you want only the
+ single item last touched, the new wxTreeCtrl::GetFocusedItem.
+
Changes in behaviour which may result in compilation errors
-----------------------------------------------------------
Changes in behaviour which may result in compilation errors
-----------------------------------------------------------
return m_current;
}
virtual size_t GetSelections(wxArrayTreeItemIds&) const;
return m_current;
}
virtual size_t GetSelections(wxArrayTreeItemIds&) const;
+ virtual wxTreeItemId GetFocusedItem() const { return m_current; }
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item,
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item,
// control with a lot of items (~ O(number of items)).
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const = 0;
// control with a lot of items (~ O(number of items)).
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const = 0;
+ // get the last item to be clicked when the control has wxTR_MULTIPLE
+ // equivalent to GetSelection() if not wxTR_MULTIPLE
+ virtual wxTreeItemId GetFocusedItem() const = 0;
+
// get the parent of this item (may return NULL if root)
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const = 0;
// get the parent of this item (may return NULL if root)
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const = 0;
*/
virtual wxTreeItemId GetFirstVisibleItem() const;
*/
virtual wxTreeItemId GetFirstVisibleItem() const;
+ /**
+ Returns the item last clicked or otherwise selected.
+ Unlike GetSelection(), it can be used whether or not
+ the control has the @c wxTR_MULTIPLE style.
+
+ @since 2.9.1
+ */
+ virtual wxTreeItemId GetFocusedItem() const;
+
/**
Returns the normal image list.
*/
/**
Returns the normal image list.
*/
/**
Returns the selection, or an invalid item if there is no selection. This
function only works with the controls without @c wxTR_MULTIPLE style,
/**
Returns the selection, or an invalid item if there is no selection. This
function only works with the controls without @c wxTR_MULTIPLE style,
- use GetSelections() for the controls which do have this style.
+ use GetSelections() for the controls which do have this style
+ or, if a single item is wanted, use GetFocusedItem().
*/
virtual wxTreeItemId GetSelection() const;
*/
virtual wxTreeItemId GetSelection() const;
void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::DoSort(bool reverse)
{
void MyFrame::DoSort(bool reverse)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnHighlight(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnHighlight(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId id = m_treeCtrl->GetSelection();
+ wxTreeItemId id = m_treeCtrl->GetFocusedItem();
void MyFrame::OnDump(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnDump(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId root = m_treeCtrl->GetSelection();
+ wxTreeItemId root = m_treeCtrl->GetFocusedItem();
void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event))
{
- m_treeCtrl->SelectItem(m_treeCtrl->GetSelection());
+ m_treeCtrl->SelectItem(m_treeCtrl->GetFocusedItem());
}
void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event))
}
void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event))
void MyFrame::DoSetBold(bool bold)
{
void MyFrame::DoSetBold(bool bold)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnDeleteChildren(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnDeleteChildren(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent < 100)
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent < 100)
m_treeCtrl->SetSpacing( indent+5 );
m_treeCtrl->SetSpacing( indent+5 );
+ m_treeCtrl->Refresh();
+ }
}
void MyFrame::OnDecSpacing(wxCommandEvent& WXUNUSED(event))
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent > 10)
}
void MyFrame::OnDecSpacing(wxCommandEvent& WXUNUSED(event))
{
unsigned int indent = m_treeCtrl->GetSpacing();
if (indent > 10)
m_treeCtrl->SetSpacing( indent-5 );
m_treeCtrl->SetSpacing( indent-5 );
+ m_treeCtrl->Refresh();
+ }
}
void MyFrame::OnToggleIcon(wxCommandEvent& WXUNUSED(event))
{
}
void MyFrame::OnToggleIcon(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::OnToggleState(wxCommandEvent& WXUNUSED(event))
{
void MyFrame::OnToggleState(wxCommandEvent& WXUNUSED(event))
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();
void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
{
void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
{
- wxTreeItemId item = m_treeCtrl->GetSelection();
+ wxTreeItemId item = m_treeCtrl->GetFocusedItem();