Struct 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 created
  • flags: A combination of the TreeViewFlags values.
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • font: The font used for the treeview text
  • parent: 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 view
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
  • OnTreeViewClick: 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 focus
  • OnTreeFocus: When the control has acquired the input focus
  • OnTreeItemDelete: Just before an item is deleted. Also sent for all the children.
  • OnTreeItemExpanded: After an item was expanded or collapsed. Sends a EventData::OnTreeItemUpdate.
  • OnTreeItemChanged: After the state of an item was changed. Sends a EventData::OnTreeItemUpdate.
  • OnTreeItemSelectionChanged: After the current selection was changed. Sends a EventData::OnTreeItemChanged.

Fields§

§handle: ControlHandle

Implementations§

Source§

impl TreeView

Source

pub fn builder<'a>() -> TreeViewBuilder<'a>

Source

pub fn set_image_list(&self, list: Option<&ImageList>)

Sets the image list of the treeview

Source

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

Source

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

Source

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

Source

pub fn set_text_color(&self, r: u8, g: u8, b: u8)

Sets the text color in the treeview

Source

pub fn text_color(&self) -> [u8; 3]

Returns the text color in the treeview

Source

pub fn indent(&self) -> u32

Retrieves the amount, in pixels, that child items are indented relative to their parent items.

Source

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.

Source

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.

Source

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)

Source

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

Source

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

Source

pub fn parent(&self, item: &TreeItem) -> Option<TreeItem>

Returns the parent of the item in the tree or None if the item is root

Source

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.

Source

pub fn selected_items(&self) -> Vec<TreeItem>

Returns the selected items in a Treeview If there is no selected items, returns an empty Vec.

Source

pub fn selected_item_count(&self) -> usize

Returns the number of selected item in the tree view

Source

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

Source

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

Source

pub fn remove_item(&self, item: &TreeItem)

Remove an item and its children from the tree view

Source

pub fn select_item(&self, item: &TreeItem)

Selects the specified tree-view item and scrolls the item into view.

Source

pub fn unselect_item(&self, item: &TreeItem)

Unselects an item from the treeview

Source

pub fn iter<'a>(&'a self) -> TreeViewIterator<'a>

Creates an iterator over the tree view items

Source

pub fn iter_item<'a>(&'a self, item: &TreeItem) -> TreeViewIterator<'a>

Creates an iterator over the children of an item. This does not include the item itself.

Source

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

Source

pub fn set_item_text(&self, tree_item: &TreeItem, new_text: &str)

Set the text for specified item in the treeview.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn clear(&self)

Remove every item from the treeview by removing the root item

Source

pub fn len(&self) -> usize

Return the total number of item in the tree view

Source

pub fn visible_len(&self) -> usize

Return the number of item in the tree view visible by the user

Source

pub fn invalidate(&self)

Invalidate the whole drawing region.

Source

pub fn font(&self) -> Option<Font>

Return the font of the control

Source

pub fn set_font(&self, font: Option<&Font>)

Set the font of the control

Source

pub fn focus(&self) -> bool

Return true if the control currently has the keyboard focus

Source

pub fn set_focus(&self)

Set the keyboard focus on the button.

Source

pub fn enabled(&self) -> bool

Return true if the control user can interact with the control, return false otherwise

Source

pub fn set_enabled(&self, v: bool)

Enable or disable the control

Source

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))

Source

pub fn set_visible(&self, v: bool)

Show or hide the control to the user

Source

pub fn size(&self) -> (u32, u32)

Return the size of the button in the parent window

Source

pub fn set_size(&self, x: u32, y: u32)

Set the size of the button in the parent window

Source

pub fn position(&self) -> (i32, i32)

Return the position of the button in the parent window

Source

pub fn set_position(&self, x: i32, y: i32)

Set the position of the button in the parent window

Source

pub fn class_name(&self) -> &'static str

Winapi class name used during control creation

Source

pub fn flags(&self) -> u32

Winapi base flags used during window creation

Source

pub fn forced_flags(&self) -> u32

Winapi flags required by the control

Source

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.

Source

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§

Source§

impl Default for TreeView

Source§

fn default() -> TreeView

Returns the “default value” for a type. Read more
Source§

impl Drop for TreeView

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&TreeView> for ControlHandle

Source§

fn from(control: &TreeView) -> Self

Converts to this type from the input type.
Source§

impl From<&mut TreeView> for ControlHandle

Source§

fn from(control: &mut TreeView) -> Self

Converts to this type from the input type.
Source§

impl PartialEq<ControlHandle> for TreeView

Source§

fn eq(&self, other: &ControlHandle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<TreeView> for ControlHandle

Source§

fn eq(&self, other: &TreeView) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for TreeView

Source§

fn eq(&self, other: &TreeView) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TreeView

Source§

impl StructuralPartialEq for TreeView

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.