pub struct MessageWindow {
    id: i32,
    title: String,
    window_box: WindowRectangle,
    close_box: WindowRectangle,
    selected: bool,
}
Expand description

Represents a rectangular region that can handle messages directed to that region.

Note: The IMessageHandler interface is an example of a “Facade” design pattern, where the complexity of the MessageWindow is exposed only through a few methods to a system that only needs to deal with those few methods.

Fields§

§id: i32

Unique ID of this window.

§title: String

Title/Name of this window.

§window_box: WindowRectangle

Position of this window in global coordinates.

§close_box: WindowRectangle

Position of the close window within the window box, although the coordinates are also global coordinates to eliminate the need to convert between window and global coordinates.

§selected: bool

Whether this window has been selected (a button click occurred within the window).

Implementations§

source§

impl MessageWindow

source

pub fn new(title: &str, x: i32, y: i32, width: i32, height: i32) -> MessageWindow

Constructor

Parameters
  • title

    Title of the MessageWindow.

  • x

    X position of the upper left corner of the window’s region.

  • y

    Y position of the upper left corner of the window’s region.

  • width

    Width of the window’s region.

  • height

    Height of the window’s region.

Returns

Returns a new instance of the MessageWindow struct.

source

fn handle_button_down_message(&mut self, message: &Message) -> MessageReturnTypes

Helper method to handle the ButtonDown message.

Parameters
  • message

    A Message object describing the ButtonDown message.

Returns

Returns a value from the MessageReturnTypes enumeration indicating what action the caller should take. In this case, always return Continue so other handlers can react to the same message (assumes no windows are overlapping).

source

fn handle_button_up_message(&mut self, message: &Message) -> MessageReturnTypes

Helper method to handle the ButtonUp message.

Parameters
  • message

    A Message object describing the ButtonUp message.

Returns

Returns a value from the MessageReturnTypes enumeration indicating what action the caller should take: (Stop) This message was handled and processing should stop, (Continue) this message can be passed on to other handlers, or (Close) this handler is closed so remove from the handlers list and stop further processing.

source

fn handle_close_message(&mut self, _message: &Message) -> MessageReturnTypes

Helper method to handle the Close message.

Parameters
  • _message

    NOT USED.

Returns

Returns a value from the MessageReturnTypes enumeration indicating what action the caller should take. In this case, always return Close to indicate this handler should be removed from the handler list so no further messages can be sent to this window.

Trait Implementations§

source§

impl IMessageHandler for MessageWindow

source§

fn id(&self) -> i32

ID of the window. This is used to uniquely identify a window in the collection.
source§

fn process_message(&mut self, message: &Message) -> MessageReturnTypes

Called with a message for the window. Read more
source§

fn to_string(&self) -> String

Return a string representation of the message handler.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V