Struct native_windows_gui::TreeView
source · [−]pub struct TreeView {
pub handle: ControlHandle,
}
Expand description
A tree-view control is a window that displays a hierarchical list of items.
While a treeview can support selected multiple item programatically (using select_item
), this is not fully supported
by the winapi implementation.
Requires the tree-view
feature
Builder parameters:
parent
: Required. The tree-view parent container.position
: The treeview position.enabled
: If the treeview can be used by the user. It also has a grayed out look if disabled.focus
: The control receive focus after being createdflags
: A combination of theTreeViewFlags
values.ex_flags
: A combination of win32 window extended flags. Unlikeflags
, ex_flags must be used straight from winapifont
: The font used for the treeview textparent
: The treeview parent container.image_list
: Image list containing the icon to use in the tree-view
Control events:
MousePress(_)
: Generic mouse press events on the tree viewOnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel eventOnTreeViewClick
: When the user has clicked the left mouse button within the control.OnTreeViewDoubleClick
: When the user has clicked the left mouse button within the control twice rapidly.OnTreeViewRightClick
: When the user has clicked the right mouse button within the control.OnTreeFocusLost
: When the control has lost the input focusOnTreeFocus
: When the control has acquired the input focusOnTreeItemDelete
: Just before an item is deleted. Also sent for all the children.OnTreeItemExpanded
: After an item was expanded or collapsed. Sends aEventData::OnTreeItemUpdate
.OnTreeItemChanged
: After the state of an item was changed. Sends aEventData::OnTreeItemUpdate
.OnTreeItemSelectionChanged
: After the current selection was changed. Sends aEventData::OnTreeItemChanged
.
Fields
handle: ControlHandle
Implementations
sourceimpl TreeView
impl TreeView
pub fn builder<'a>() -> TreeViewBuilder<'a>
sourcepub fn set_image_list(&self, list: Option<&ImageList>)
pub fn set_image_list(&self, list: Option<&ImageList>)
Sets the image list of the treeview
sourcepub fn image_list(&self) -> Option<ImageList>
pub fn image_list(&self) -> Option<ImageList>
Returns the image list of the treeview or None if there is none. The returned image list is not owned
sourcepub fn set_item_image(&self, item: &TreeItem, index: i32, on_select: bool)
pub fn set_item_image(&self, item: &TreeItem, index: i32, on_select: bool)
Sets the image that will appear left to the item text. index
is the index of the image in the image-list
Won’t do anything if the control do not have a image list or if the item is not in the tree
If on_select
is set to true, sets the icon that is used when an item is active
sourcepub fn item_image(&self, item: &TreeItem, on_select: bool) -> i32
pub fn item_image(&self, item: &TreeItem, on_select: bool) -> i32
Returns the index of the image in the tree view image list.
If there is no image list in the control or the item is not in the control, 0 will be returned.
If on_select
is set to true, returns the icon that is used when an item is active
sourcepub fn set_text_color(&self, r: u8, g: u8, b: u8)
pub fn set_text_color(&self, r: u8, g: u8, b: u8)
Sets the text color in the treeview
sourcepub fn text_color(&self) -> [u8; 3]
pub fn text_color(&self) -> [u8; 3]
Returns the text color in the treeview
sourcepub fn indent(&self) -> u32
pub fn indent(&self) -> u32
Retrieves the amount, in pixels, that child items are indented relative to their parent items.
sourcepub fn set_indent(&self, indent: u32)
pub fn set_indent(&self, indent: u32)
Sets the width of indentation for a tree-view control and redraws the control to reflect the new width.
sourcepub fn root(&self) -> Option<TreeItem>
pub fn root(&self) -> Option<TreeItem>
Return the root item of the tree view if one is present.
If there is no root in the tree, returns None
.
sourcepub fn first_child(&self, item: &TreeItem) -> Option<TreeItem>
pub fn first_child(&self, item: &TreeItem) -> Option<TreeItem>
Returns the first child of an item or None
if the item has no child or if it’s not part of the tree view
To iterate over all the children, use TreeView.iter_item(&parent_item)
sourcepub fn next_sibling(&self, item: &TreeItem) -> Option<TreeItem>
pub fn next_sibling(&self, item: &TreeItem) -> Option<TreeItem>
Returns the next sibling in the tree or None
if the item has no more sibling or if it’s not part of the tree view
sourcepub fn previous_sibling(&self, item: &TreeItem) -> Option<TreeItem>
pub fn previous_sibling(&self, item: &TreeItem) -> Option<TreeItem>
Returns the previous sibling in the tree or None
if the item has no more sibling or if it’s not part of the tree view
sourcepub fn parent(&self, item: &TreeItem) -> Option<TreeItem>
pub fn parent(&self, item: &TreeItem) -> Option<TreeItem>
Returns the parent of the item in the tree or None
if the item is root
sourcepub fn selected_item(&self) -> Option<TreeItem>
pub fn selected_item(&self) -> Option<TreeItem>
Return the currently selected item. If there are more than one selected item, returns the first one.
If there is no selected item, returns None
.
sourcepub fn selected_items(&self) -> Vec<TreeItem>
pub fn selected_items(&self) -> Vec<TreeItem>
Returns the selected items in a Treeview
If there is no selected items, returns an empty Vec
.
sourcepub fn selected_item_count(&self) -> usize
pub fn selected_item_count(&self) -> usize
Returns the number of selected item in the tree view
sourcepub fn insert_item<'a>(
&self,
new: &'a str,
parent: Option<&TreeItem>,
position: TreeInsert
) -> TreeItem
pub fn insert_item<'a>(
&self,
new: &'a str,
parent: Option<&TreeItem>,
position: TreeInsert
) -> TreeItem
Insert a new item into the TreeView and return a reference to new newly added item
sourcepub fn insert_item_with_param<'a>(
&self,
new: &'a str,
parent: Option<&TreeItem>,
position: TreeInsert,
data: isize
) -> TreeItem
pub fn insert_item_with_param<'a>(
&self,
new: &'a str,
parent: Option<&TreeItem>,
position: TreeInsert,
data: isize
) -> TreeItem
Insert a new item into the TreeView with associated lParam and return a reference to new newly added item
sourcepub fn remove_item(&self, item: &TreeItem)
pub fn remove_item(&self, item: &TreeItem)
Remove an item and its children from the tree view
sourcepub fn select_item(&self, item: &TreeItem)
pub fn select_item(&self, item: &TreeItem)
Selects the specified tree-view item and scrolls the item into view.
sourcepub fn unselect_item(&self, item: &TreeItem)
pub fn unselect_item(&self, item: &TreeItem)
Unselects an item from the treeview
sourcepub fn iter<'a>(&'a self) -> TreeViewIterator<'a>ⓘNotable traits for TreeViewIterator<'a>impl<'a> Iterator for TreeViewIterator<'a> type Item = TreeItem;
pub fn iter<'a>(&'a self) -> TreeViewIterator<'a>ⓘNotable traits for TreeViewIterator<'a>impl<'a> Iterator for TreeViewIterator<'a> type Item = TreeItem;
Creates an iterator over the tree view items
sourcepub fn iter_item<'a>(&'a self, item: &TreeItem) -> TreeViewIterator<'a>ⓘNotable traits for TreeViewIterator<'a>impl<'a> Iterator for TreeViewIterator<'a> type Item = TreeItem;
pub fn iter_item<'a>(&'a self, item: &TreeItem) -> TreeViewIterator<'a>ⓘNotable traits for TreeViewIterator<'a>impl<'a> Iterator for TreeViewIterator<'a> type Item = TreeItem;
Creates an iterator over the children of an item. This does not include the item itself.
sourcepub fn item_text(&self, tree_item: &TreeItem) -> Option<String>
pub fn item_text(&self, tree_item: &TreeItem) -> Option<String>
Returns the text of the selected item. Return None if the item is not in the tree view. The returned text value cannot be bigger than 260 characters
sourcepub fn set_item_text(&self, tree_item: &TreeItem, new_text: &str)
pub fn set_item_text(&self, tree_item: &TreeItem, new_text: &str)
Set the text for specified item in the treeview.
sourcepub fn item_param(&self, tree_item: &TreeItem) -> Option<isize>
pub fn item_param(&self, tree_item: &TreeItem) -> Option<isize>
Returns the lParam of the selected item. Return None if the item is not in the tree view.
sourcepub fn item_has_children(&self, tree_item: &TreeItem) -> Option<bool>
pub fn item_has_children(&self, tree_item: &TreeItem) -> Option<bool>
Returns true
if the tree view item has children. Returns None
if the item is not in the tree view.
sourcepub fn item_state(&self, tree_item: &TreeItem) -> Option<TreeItemState>
pub fn item_state(&self, tree_item: &TreeItem) -> Option<TreeItemState>
Returns the item state in the tree view or None
if the item is not in the tree view
sourcepub fn set_expand_state(&self, item: &TreeItem, state: ExpandState)
pub fn set_expand_state(&self, item: &TreeItem, state: ExpandState)
Expands or collapses the list of child items associated with the specified parent item, if any.
sourcepub fn ensure_visible(&self, item: &TreeItem)
pub fn ensure_visible(&self, item: &TreeItem)
Ensures that a tree-view item is visible, expanding the parent item or scrolling the tree-view control, if necessary.
sourcepub fn visible_len(&self) -> usize
pub fn visible_len(&self) -> usize
Return the number of item in the tree view visible by the user
sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Invalidate the whole drawing region.
sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Return true if the control user can interact with the control, return false otherwise
sourcepub fn set_enabled(&self, v: bool)
pub fn set_enabled(&self, v: bool)
Enable or disable the control
sourcepub fn visible(&self) -> bool
pub fn visible(&self) -> bool
Return true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))
sourcepub fn set_visible(&self, v: bool)
pub fn set_visible(&self, v: bool)
Show or hide the control to the user
sourcepub fn set_position(&self, x: i32, y: i32)
pub fn set_position(&self, x: i32, y: i32)
Set the position of the button in the parent window
sourcepub fn class_name(&self) -> &'static str
pub fn class_name(&self) -> &'static str
Winapi class name used during control creation
sourcepub fn forced_flags(&self) -> u32
pub fn forced_flags(&self) -> u32
Winapi flags required by the control
sourcepub fn edit_label(&self, item: &TreeItem) -> Option<ControlHandle>
pub fn edit_label(&self, item: &TreeItem) -> Option<ControlHandle>
Begins to in-place edit the specified item’s text. Return None if Failed. Return the treeview’s handle if successful.
sourcepub fn end_edit_label_now(&self, f_cancel: bool) -> bool
pub fn end_edit_label_now(&self, f_cancel: bool) -> bool
End the in-place editing of the tree item’s label. The parameter f_cancel indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, the system cancels editing without saving the changes. Otherwise, the system saves the changes to the label. Return true if successful, otherwise return false.
Trait Implementations
sourceimpl From<&TreeView> for ControlHandle
impl From<&TreeView> for ControlHandle
sourceimpl From<&mut TreeView> for ControlHandle
impl From<&mut TreeView> for ControlHandle
sourceimpl PartialEq<ControlHandle> for TreeView
impl PartialEq<ControlHandle> for TreeView
sourcefn eq(&self, other: &ControlHandle) -> bool
fn eq(&self, other: &ControlHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<TreeView> for ControlHandle
impl PartialEq<TreeView> for ControlHandle
sourceimpl PartialEq<TreeView> for TreeView
impl PartialEq<TreeView> for TreeView
impl Eq for TreeView
impl StructuralEq for TreeView
impl StructuralPartialEq for TreeView
Auto Trait Implementations
impl RefUnwindSafe for TreeView
impl !Send for TreeView
impl !Sync for TreeView
impl Unpin for TreeView
impl UnwindSafe for TreeView
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more