Struct winsafe::gui::spec::ListViewItems
source · pub struct ListViewItems<'a, T: 'static> { /* private fields */ }
gui
only.Expand description
Exposes item methods of a ListView
control.
You cannot directly instantiate this object, it is created internally by the control.
Implementations§
source§impl<'a, T> ListViewItems<'a, T>
impl<'a, T> ListViewItems<'a, T>
sourcepub fn add(
&self,
texts: &[impl AsRef<str>],
icon_index: Option<u32>,
data: T
) -> ListViewItem<'a, T>
pub fn add( &self, texts: &[impl AsRef<str>], icon_index: Option<u32>, data: T ) -> ListViewItem<'a, T>
Appends a new item by sending an
lvm::InsertItem
message, and returns
the newly added item.
The texts are relative to each column.
§Panics
Panics if texts
is empty, or if the number of texts is greater than
the number of columns.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListView; // initialized somewhere
let new_item = my_list.items().add(
&[
"First column text",
"Second column text",
],
None, // no icon; requires a previous set_image_list()
(), // no object data; requires specifying the generic `ListView` type
);
sourcepub fn count(&self) -> u32
pub fn count(&self) -> u32
Retrieves the total number of items by sending an
lvm::GetItemCount
message.
sourcepub fn delete_all(&self)
pub fn delete_all(&self)
Deletes all items by sending an
lvm::DeleteAllItems
message.
sourcepub fn delete_selected(&self)
pub fn delete_selected(&self)
Deletes all selected items by sending
lvm::DeleteItem
messages.
sourcepub fn find(&self, text: &str) -> Option<ListViewItem<'a, T>>
pub fn find(&self, text: &str) -> Option<ListViewItem<'a, T>>
Searches for an item with the given text, case-insensitive, by sending
an lvm::FindItem
message.
sourcepub fn focused(&self) -> Option<ListViewItem<'a, T>>
pub fn focused(&self) -> Option<ListViewItem<'a, T>>
Retrieves the focused item by sending an
lvm::GetNextItem
message.
sourcepub const fn get(&self, index: u32) -> ListViewItem<'a, T>
pub const fn get(&self, index: u32) -> ListViewItem<'a, T>
Retrieves the item at the given zero-based position.
Note: This method is cheap – even if index
is beyond the range of
existing items, an object will still be returned. However, operations
upon this object will produce no effect.
sourcepub fn hit_test(&self, coords: POINT) -> Option<ListViewItem<'a, T>>
pub fn hit_test(&self, coords: POINT) -> Option<ListViewItem<'a, T>>
Retrieves the item at the specified position by sending an
lvm::HitTest
message.
coords
must be relative to the list view.
sourcepub fn iter(&self) -> impl Iterator<Item = ListViewItem<'a, T>> + 'a
pub fn iter(&self) -> impl Iterator<Item = ListViewItem<'a, T>> + 'a
Returns an iterator over all items.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListView; // initialized somewhere
for item in my_list.items().iter() {
println!("Item {}, text of the first column: {}",
item.index(), item.text(0));
}
sourcepub fn iter_selected(&self) -> impl Iterator<Item = ListViewItem<'a, T>> + 'a
pub fn iter_selected(&self) -> impl Iterator<Item = ListViewItem<'a, T>> + 'a
Returns an iterator over the selected items.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListView; // initialized somewhere
for item in my_list.items().iter_selected() {
println!("Selected item {}, text of the first column: {}",
item.index(), item.text(0));
}
sourcepub fn map_id_to_index(&self, item_id: u32) -> ListViewItem<'a, T>
pub fn map_id_to_index(&self, item_id: u32) -> ListViewItem<'a, T>
Retrieves the item of the unique ID by sending an
lvm::MapIdToIndex
message.
If the item of the given unique ID doesn’t exist anymore, returns
None
.
§Panics
Panics if the given ID doesn’t exist among the items.
sourcepub fn select_all(&self, set: bool)
pub fn select_all(&self, set: bool)
Sets or remove the selection for all items by sending an
lvm::SetItemState
message.
sourcepub fn selected_count(&self) -> u32
pub fn selected_count(&self) -> u32
Retrieves the number of selected items by sending an
lvm::GetSelectedCount
message.
sourcepub fn set_count(&self, count: u32, behavior: Option<LVSICF>)
pub fn set_count(&self, count: u32, behavior: Option<LVSICF>)
Sets the number of items in a virtual list view – that is, a list view
created with LVS::OWNERDATA
style – by
sending an lvm::SetItemCount
message.
sourcepub fn sort<F>(&self, func: F)
pub fn sort<F>(&self, func: F)
Sorts the items according to a callback by sending an
lvm::SortItemsEx
message.
The callback receives the two items to be compared.
§Examples
Sorting by the text of the first column:
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListView; // initialized somewhere
my_list.items().sort(|itemA, itemB| -> std::cmp::Ordering {
itemA.text(0).cmp( &itemB.text(0) )
});