Skip to main content

Button

Struct Button 

Source
pub struct Button { /* private fields */ }

Implementations§

Source§

impl Button

Source

pub fn new( bounds: Rect, title: &str, command: CommandId, is_default: bool, ) -> Self

Source

pub fn set_disabled(&mut self, disabled: bool)

Source

pub fn is_disabled(&self) -> bool

Source

pub fn set_broadcast(&mut self, broadcast: bool)

Set whether this button broadcasts its command instead of sending it as a command event Matches Borland: bfBroadcast flag

Source

pub fn set_selectable(&mut self, selectable: bool)

Set whether this button is selectable (can receive focus) Matches Borland: ofSelectable flag

Trait Implementations§

Source§

impl View for Button

Source§

fn bounds(&self) -> Rect

Source§

fn set_bounds(&mut self, bounds: Rect)

Source§

fn draw(&mut self, terminal: &mut Terminal)

Source§

fn handle_event(&mut self, event: &mut Event)

Source§

fn can_focus(&self) -> bool

Source§

fn state(&self) -> StateFlags

Get view state flags
Source§

fn set_state(&mut self, state: StateFlags)

Set view state flags
Source§

fn options(&self) -> u16

Get view option flags (OF_SELECTABLE, OF_PRE_PROCESS, OF_POST_PROCESS, etc.)
Source§

fn set_options(&mut self, options: u16)

Set view option flags
Source§

fn is_default_button(&self) -> bool

Check if this view is a default button (for Enter key handling at Dialog level) Corresponds to Borland’s TButton::amDefault flag (tbutton.cc line 239)
Source§

fn button_command(&self) -> Option<u16>

Get the command ID for this button (if it’s a button) Returns None if not a button Used by Dialog to activate default button on Enter key
Source§

fn set_palette_chain(&mut self, node: Option<PaletteChainNode>)

Set the QCell-based palette chain node for this view. Called by parent (Group/Window) during draw to establish the safe owner chain.
Source§

fn get_palette_chain(&self) -> Option<&PaletteChainNode>

Get the QCell-based palette chain node for this view. Used by map_color() to safely walk the owner chain.
Source§

fn get_palette(&self) -> Option<Palette>

Get this view’s palette for the Borland indirect palette system Matches Borland: TView::getPalette() Read more
Source§

fn set_focus(&mut self, focused: bool)

Set focus state - default implementation uses SF_FOCUSED flag Views should override only if they need custom focus behavior
Source§

fn is_focused(&self) -> bool

Check if view is focused - reads SF_FOCUSED flag
Source§

fn set_state_flag(&mut self, flag: StateFlags, enable: bool)

Set or clear specific state flag(s) Matches Borland’s TView::setState(ushort aState, Boolean enable) If enable is true, sets the flag(s), otherwise clears them
Source§

fn get_state_flag(&self, flag: StateFlags) -> bool

Check if specific state flag(s) are set Matches Borland’s TView::getState(ushort aState)
Source§

fn has_shadow(&self) -> bool

Check if view has shadow enabled
Source§

fn shadow_bounds(&self) -> Rect

Get bounds including shadow area
Source§

fn update_cursor(&self, _terminal: &mut Terminal)

Update cursor state (called after draw) Views that need to show a cursor when focused should override this
Source§

fn zoom(&mut self, _max_bounds: Rect)

Zoom (maximize/restore) the view with given maximum bounds Matches Borland: TWindow::zoom() toggles between current and max size Default implementation does nothing (only windows support zoom)
Source§

fn valid(&mut self, _command: CommandId) -> bool

Validate the view before performing a command (usually closing) Matches Borland: TView::valid(ushort command) - returns Boolean Returns true if the view’s state is valid for the given command Used for “Save before closing?” type scenarios and input validation Read more
Source§

fn as_any(&self) -> &dyn Any

Downcast to concrete type (immutable) Allows accessing specific view type methods from trait object
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast to concrete type (mutable) Allows accessing specific view type methods from trait object
Source§

fn dump_to_file(&self, terminal: &Terminal, path: &str) -> Result<()>

Dump this view’s region of the terminal buffer to an ANSI file for debugging
Source§

fn set_list_selection(&mut self, _index: usize)

Set the selection index for listbox views Only implemented by ListBox, other views ignore this
Source§

fn get_list_selection(&self) -> usize

Get the selection index for listbox views Only implemented by ListBox, other views return 0
Source§

fn get_redraw_union(&self) -> Option<Rect>

Get the union rect of previous and current bounds for redrawing Matches Borland: TView::locate() calculates union of old and new bounds Returns None if the view hasn’t moved since last redraw Used by Desktop to implement Borland’s drawUnderRect pattern
Source§

fn clear_move_tracking(&mut self)

Clear movement tracking after redrawing Matches Borland: Called after drawUnderRect completes
Source§

fn get_end_state(&self) -> CommandId

Get the end state for modal views Matches Borland: TGroup::endState field Returns the command ID that ended modal execution (0 if still running)
Source§

fn set_end_state(&mut self, _command: CommandId)

Set the end state for modal views Called by end_modal() to signal the modal loop should exit
Source§

fn make_global(&self, local_x: i16, local_y: i16) -> (i16, i16)

Convert local coordinates to global (screen) coordinates Matches Borland: TView::makeGlobal(TPoint source, TPoint& dest) Read more
Source§

fn make_local(&self, global_x: i16, global_y: i16) -> (i16, i16)

Convert global (screen) coordinates to local view coordinates Matches Borland: TView::makeLocal(TPoint source, TPoint& dest) Read more
Source§

fn draw_shadow(&self, terminal: &mut Terminal)

Draw shadow for this view Draws a shadow offset dynamically based on terminal cell aspect ratio Shadow is semi-transparent - darkens the underlying content by 50% This matches the Borland Turbo Vision behavior more closely
Get the linked control ViewId for labels Matches Borland: TLabel::link field Returns Some(ViewId) if this is a label with a linked control, None otherwise Used by Group to implement focus transfer when clicking labels
Source§

fn init_after_add(&mut self)

Initialize internal owner pointers after view is added to parent and won’t move This is called by parent’s add() method after the view is in its final position Views that contain other views by value should override this to set up owner chains Default implementation does nothing
Source§

fn constrain_to_parent_bounds(&mut self)

Constrain view bounds to parent/owner bounds Used after positioning (e.g., centering) to ensure view stays within valid area Matches Borland: TView::locate() constrains position to owner bounds
Source§

fn set_parent_bounds(&mut self, _bounds: Rect)

Set the parent’s bounds for drag/resize limit resolution. Called by Desktop when adding windows.
Source§

fn map_color(&self, color_index: u8) -> Attr

Map a logical color index to an actual color attribute Matches Borland: TView::mapColor(uchar index) Read more

Auto Trait Implementations§

§

impl Freeze for Button

§

impl !RefUnwindSafe for Button

§

impl !Send for Button

§

impl !Sync for Button

§

impl Unpin for Button

§

impl UnsafeUnpin for Button

§

impl !UnwindSafe for Button

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.