- Added wxTransparentColour.
- Added wxToolBar::GetToolByPos().
- Added wxProgressDialog::Was{Cancelled,Skipped}() (Julien Weinzorn).
+- Added wxTreeCtrl::{Clear,Set}FocusedItem() (Nikolay Tiushkov).
GTK:
virtual size_t GetSelections(wxArrayTreeItemIds&) const;
virtual wxTreeItemId GetFocusedItem() const { return m_current; }
+ virtual void ClearFocusedItem();
+ virtual void SetFocusedItem(const wxTreeItemId& item);
+
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item,
wxTreeItemIdValue& cookie) const;
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const;
virtual wxTreeItemId GetFocusedItem() const;
+ virtual void ClearFocusedItem();
+ virtual void SetFocusedItem(const wxTreeItemId& item);
+
+
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item,
wxTreeItemIdValue& cookie) const;
// and the tree has wxTR_HIDE_ROOT style)
bool IsHiddenRoot(const wxTreeItemId& item) const;
- // clears/sets the currently focused item
- void ClearFocusedItem();
- void SetFocusedItem(const wxTreeItemId& item);
// check if the given flags (taken from TV_HITTESTINFO structure)
// indicate a position "on item": this is less trivial than just checking
// equivalent to GetSelection() if not wxTR_MULTIPLE
virtual wxTreeItemId GetFocusedItem() const = 0;
+
+ // Clears the currently focused item
+ virtual void ClearFocusedItem() = 0;
+ // Sets the currently focused item. Item should be valid
+ virtual void SetFocusedItem(const wxTreeItemId& item) = 0;
+
+
// get the parent of this item (may return NULL if root)
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const = 0;
*/
virtual wxTreeItemId GetFocusedItem() const;
+
+ /**
+ Clears the currently focused item
+
+ @since 2.9.1
+ */
+ virtual void ClearFocusedItem();
+
+ /**
+ Sets the currently focused item.
+
+ @param item
+ The item to make the current one. It must be valid.
+ @since 2.9.1
+ */
+ virtual void SetFocusedItem(const wxTreeItemId& item);
+
+
/**
Returns the normal image list.
*/
MENU_LINK(ToggleIcon)
MENU_LINK(ToggleState)
MENU_LINK(SelectRoot)
+ MENU_LINK(SetFocusedRoot)
+ MENU_LINK(ClearFocused)
MENU_LINK(ShowFirstVisible)
#ifdef wxHAS_LAST_VISIBLE
tree_menu->Append(TreeTest_DeleteChildren, wxT("Delete &children"));
tree_menu->Append(TreeTest_DeleteAll, wxT("Delete &all items"));
tree_menu->Append(TreeTest_SelectRoot, wxT("Select root item"));
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_SetFocusedRoot, wxT("Set focus to root item"));
+ tree_menu->Append(TreeTest_ClearFocused, wxT("Reset focus"));
tree_menu->AppendSeparator();
tree_menu->Append(TreeTest_Count, wxT("Count children of current item"));
m_treeCtrl->SelectItem(m_treeCtrl->GetRootItem());
}
+void MyFrame::OnSetFocusedRoot(wxCommandEvent& WXUNUSED(event))
+{
+ if ( !m_treeCtrl->HasFlag(wxTR_HIDE_ROOT) )
+ m_treeCtrl->SetFocusedItem(m_treeCtrl->GetRootItem());
+}
+
+void MyFrame::OnClearFocused(wxCommandEvent& WXUNUSED(event))
+{
+ m_treeCtrl->ClearFocusedItem();
+}
+
void MyFrame::OnUnselect(wxCommandEvent& WXUNUSED(event))
{
m_treeCtrl->UnselectAll();
void OnSelectChildren(wxCommandEvent& event);
#endif // NO_MULTIPLE_SELECTION
void OnSelectRoot(wxCommandEvent& event);
+ void OnSetFocusedRoot(wxCommandEvent& event);
+ void OnClearFocused(wxCommandEvent& event);
void OnDelete(wxCommandEvent& event);
void OnDeleteChildren(wxCommandEvent& event);
void OnDeleteAll(wxCommandEvent& event);
TreeTest_Select,
TreeTest_Unselect,
TreeTest_SelectRoot,
+ TreeTest_ClearFocused,
+ TreeTest_SetFocusedRoot,
TreeTest_SelectChildren,
TreeTest_ShowFirstVisible,
TreeTest_ShowLastVisible,
}
}
+void wxGenericTreeCtrl::ClearFocusedItem()
+{
+ wxTreeItemId item = GetFocusedItem();
+ if ( item.IsOk() )
+ SelectItem(item, false);
+}
+
+void wxGenericTreeCtrl::SetFocusedItem(const wxTreeItemId& item)
+{
+ wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
+
+ SelectItem(item, true);
+}
+
void wxGenericTreeCtrl::UnselectAllChildren(wxGenericTreeItem *item)
{
if (item->IsSelected())
void wxTreeCtrl::SetFocusedItem(const wxTreeItemId& item)
{
+ wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
+
TempSetter set(m_changingSelection);
::SetFocus(GetHwnd(), HITEM(item));