pub struct CellDataFunc { /* private fields */ }Expand description
A cell data func set on a CellLayout’s CellRenderer.
When implementing CellLayoutImpl::set_cell_data_func, you will need to store these, keyed
to the passed CellRenderer, somewhere in your class’s instance data. Whenever your
implementation needs to set attribute values on the cell renderers for a particular
TreeIter, you should use CellDataFunc::call in order to do so, if there is a
CellDataFunc instance present for that cell renderer.
§Example
ⓘ
struct MyWidget {
model: RefCell<TreeModel>,
items: RefCell<Vec<MyItem>>,
cells: RefCell<Vec<CellRenderer>>,
cell_data_funcs: RefCell<HashMap<CellRenderer, CellDataFunc>>,
// ... other fields
}
impl CellLayoutImpl for MyWidget {
fn set_cell_data_func(&self, cell: &CellRenderer, cell_data_func: Option<CellDataFunc>) {
// Store or clear the passed CellDataFunc.
if let Some(cell_data_func) = cell_data_func {
self.cell_data_funcs.borrow_mut().insert(cell.clone(), cell_data_func);
} else {
self.cell_data_funcs.borrow_mut().remove(cell);
}
// Things have changed, so redraw.
self.redraw();
}
}
impl MyWidget {
fn redraw(&self) {
for item in &*self.items.borrow() {
let iter: TreeIter = item.iter(&*self.model.borrow());
for cell in &*self.cells.borrow() {
if let Some(cell_data_func) = self.cell_data_funcs.borrow().get(cell) {
// There's a CellDataFunc for this CellRenderer, so call it so it can set
// renderer attributes for the item at this iter.
cell_data_func.call(&*self.obj(), cell, &*self.model.borrow(), &iter);
}
}
item.draw(&*self.cells.borrow());
}
}
}Implementations§
Source§impl CellDataFunc
impl CellDataFunc
Sourcepub fn call(
&self,
cell_layout: &impl IsA<CellLayout>,
cell: &impl IsA<CellRenderer>,
model: &impl IsA<TreeModel>,
iter: &TreeIter,
)
pub fn call( &self, cell_layout: &impl IsA<CellLayout>, cell: &impl IsA<CellRenderer>, model: &impl IsA<TreeModel>, iter: &TreeIter, )
Calls the data func on the specified cell renderer, tree model, and iter.
Usually this will set up cell’s attribute values correctly for iter.
Trait Implementations§
Source§impl Drop for CellDataFunc
impl Drop for CellDataFunc
Auto Trait Implementations§
impl !Send for CellDataFunc
impl !Sync for CellDataFunc
impl Freeze for CellDataFunc
impl RefUnwindSafe for CellDataFunc
impl Unpin for CellDataFunc
impl UnsafeUnpin for CellDataFunc
impl UnwindSafe for CellDataFunc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more