Trait dui::element::Element
[−]
[src]
pub trait Element: Sized + Copy + Clone { unsafe fn from_raw_unchecked(ih: *mut Ihandle) -> Self; fn raw(&self) -> *mut Ihandle; unsafe fn target_classname() -> &'static str; fn from_handle(handle: Handle) -> Result<Self, Handle> { ... } fn from_name<S: Into<String>>(name: S) -> Option<Handle> { ... } fn from_raw(ih: *mut Ihandle) -> Self { ... } unsafe fn classname(&self) -> &CStr { ... } fn destroy(self) { ... } fn does_attrib_exist(&self, cname: &CString) -> bool { ... } fn attribs(&self) -> Vec<String> { ... } fn set_attrib<S1, S2>(&mut self, name: S1, value: S2) -> Self
where
S1: Into<String>,
S2: Into<String>, { ... } fn attrib<S: Into<String>>(&self, name: S) -> Option<String> { ... } fn set_attrib_data<S1>(&mut self, name: S1, data: *const c_void) -> Self
where
S1: Into<String>, { ... } fn attrib_data<S1>(&mut self, name: S1) -> *mut c_void
where
S1: Into<String>, { ... } fn set_attrib_handle<S1, E>(&mut self, name: S1, elem: E) -> Self
where
S1: Into<String>,
E: Element, { ... } fn attrib_handle<S1>(&mut self, name: S1) -> Option<Handle>
where
S1: Into<String>, { ... } fn clear_attrib<S: Into<String>>(&mut self, name: S) -> Self { ... } fn reset_attrib<S: Into<String>>(&mut self, name: S) -> Self { ... } fn handle_name(&self) -> Option<String> { ... } fn add_handle_name<S: Into<String>>(&self, name: S) -> Option<Handle> { ... } fn clear_handle_name<S: Into<String>>(name: S) -> Option<Handle> { ... } }
Every IUP object is an Element
.
Required Methods
unsafe fn from_raw_unchecked(ih: *mut Ihandle) -> Self
Constructs an Element from a raw IUP handle.
Safety
The from_raw_unchecked
method is faster than from_raw
but must be used with care.
The Rust binding performs important operations and checks when a raw IUP handle reaches
the bounds of safe Rust binding, that only happens when from_raw
is used. Be sure the
raw handle has reached safe Rust bounds at least once before using this method.
It's undefined behaviour if the raw handle is incompatible with Self
bindings.
Instead use the Element::from_handle
to perform safe downcasting.
fn raw(&self) -> *mut Ihandle
Gets the raw IUP handle associated with this element.
unsafe fn target_classname() -> &'static str
Gets the [class name][1] the derived object should be targeting. [1]: http://webserver2.tecgraf.puc-rio.br/iup/en/func/iupgetclassname.html
Provided Methods
fn from_handle(handle: Handle) -> Result<Self, Handle>
Constructs a specialized Element object from a general Handle if they are compatible.
fn from_name<S: Into<String>>(name: S) -> Option<Handle>
Constructs from a name associated with a element handle (with Element::add_handle_name
or LED).
fn from_raw(ih: *mut Ihandle) -> Self
Constructs an Element from a raw IUP handle.
It's undefined behaviour if the raw handle is incompatible with Self
bindings.
Instead use the Element::from_handle
to perform safe downcasting.
Panics
Panics if the raw handle is a null pointer.
unsafe fn classname(&self) -> &CStr
Gets the [class name][1] of this element. [1]: http://webserver2.tecgraf.puc-rio.br/iup/en/func/iupgetclassname.html
fn destroy(self)
Destroys an interface element and all its children.
Only dialogs, timers, popup menus and images should be normally destroyed, but detached controls can also be destroyed.
Menu bars associated with dialogs are automatically destroyed when the dialog is destroyed.
Images associated with controls are NOT automatically destroyed. The application must destroy them when they are not used anymore.
fn does_attrib_exist(&self, cname: &CString) -> bool
Checks if a specific attribute exists in the element.
fn attribs(&self) -> Vec<String>
Returns the names of all attributes of an element that are set in its internal hash table only.
fn set_attrib<S1, S2>(&mut self, name: S1, value: S2) -> Self where
S1: Into<String>,
S2: Into<String>,
S1: Into<String>,
S2: Into<String>,
Sets an interface element attribute.
See also the [IUP Attributes Guide][1]. [1]: http://webserver2.tecgraf.puc-rio.br/iup/en/attrib_guide.html
fn attrib<S: Into<String>>(&self, name: S) -> Option<String>
Gets an interface element attribute.
See also the [IUP Attributes Guide][1]. [1]: http://webserver2.tecgraf.puc-rio.br/iup/en/attrib_guide.html
fn set_attrib_data<S1>(&mut self, name: S1, data: *const c_void) -> Self where
S1: Into<String>,
S1: Into<String>,
Sets a raw interface element attribute.
Safety
While this function is not unsafe, care must be taken while using it, prefer to use
Element::set_attrib
instead. The data
pointer must live long enough (most of the time
statically).
fn attrib_data<S1>(&mut self, name: S1) -> *mut c_void where
S1: Into<String>,
S1: Into<String>,
Gets a raw interface element attribute.
fn set_attrib_handle<S1, E>(&mut self, name: S1, elem: E) -> Self where
S1: Into<String>,
E: Element,
S1: Into<String>,
E: Element,
Associates a element with an attribute.
Instead of using Element::add_handle_name
and Element::set_attrib
with a new creative
name, this function automatically creates a non conflict handle name and associates that
with the attribute.
fn attrib_handle<S1>(&mut self, name: S1) -> Option<Handle> where
S1: Into<String>,
S1: Into<String>,
Gets the handle associated with an attribute.
fn clear_attrib<S: Into<String>>(&mut self, name: S) -> Self
Clears the value associated with an attribute and use the default value.
fn reset_attrib<S: Into<String>>(&mut self, name: S) -> Self
Removes an attribute from element and its children if the attrib is inheritable.
It is useful to reset the state of inheritable attributes in a tree of elements.
fn handle_name(&self) -> Option<String>
Returns the identifier of an interface element that has an associated handle name using
Element::add_handle_name
or using LED.
Handle names shouldn't be confused with the NAME attribute.
fn add_handle_name<S: Into<String>>(&self, name: S) -> Option<Handle>
Associates a handle name with an interface element.
Can be called several times with the same element and different names.
There is no restriction for the number of names a pointer can have, but Element::handle_name
will return the first name found.
Returns the handle of the interface element previously associated to the parameter name.
Handle names shouldn't be confused with the NAME attribute.
fn clear_handle_name<S: Into<String>>(name: S) -> Option<Handle>
Clears the handle name association on the specified name.
Note this will not destroy associated elements, just remove a name from the association table.
Returns the handle of the interface element previously associated to the parameter name.
Handle names shouldn't be confused with the NAME attribute.
Implementors
impl Element for Handle
impl Element for Dialog
impl Element for MessageDlg
impl Element for FileDlg
impl Element for VBox
impl Element for HBox
impl Element for Radio
impl Element for Fill
impl Element for Label
impl Element for Text
impl Element for Button
impl Element for ProgressBar
impl Element for Toggle
impl Element for Frame
impl Element for List
impl Element for Image
impl Element for ImageRgb
impl Element for ImageRgba
impl Element for Timer
impl Element for Clipboard