pub struct Window {
    pub handle: ControlHandle,
}
Expand description

A basic top level window. At least one top level window is required to make a NWG application.

Windows can be heavily customized using the window flags. If your application don’t need a visible window (ex: a system tray app), use MessageWindow instead.

Builder parameters:

  • flags: The window flags. See WindowFlags
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • title: The text in the window title bar
  • size: The default size of the window
  • position: The default position of the window in the desktop
  • icon: The window icon
  • accept_file: If the window should accept files by drag & drop
  • maximized: If the window should be maximized at creation
  • minimized: If the window should be minimized at creation
  • center: Center the window in the current monitor based on its size. If true, this overrides position
  • topmost: If the window should always be on top of other system window
  • parent: Logical parent of the window, unlike children controls, this is NOT required.

Control events:

  • OnInit: The window was created
  • MousePress(_): Generic mouse press events on the button
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
  • OnPaint: Generic on paint event
  • OnKeyPress: Generic key press
  • OnKeyRelease: Generic ket release
  • OnResize: When the window is resized
  • OnResizeBegin: Just before the window begins being resized by the user
  • OnResizeEnd: Just after the user stops resizing the window
  • OnWindowMaximize: When the window is maximized
  • OnWindowMinimize: When the window is minimized
  • OnMove: When the window is moved by the user
  • OnFileDrop: When a file is dropped in the window (only raised if accept_file is set)
  • OnMinMaxInfo: When the size or position of the window is about to change and the size of the windows must be restricted

Fields

handle: ControlHandle

Implementations

Maximize the window

Minimize the window

Restore a minimized/maximized window

Force the window to refraw iteself and all its children

Close the window as if the user clicked the X button.

Return the icon of the window

Set the icon in the window

  • icon: The new icon. If None, the icon is removed

Return true if the control currently has the keyboard focus

Set the keyboard focus on the button

Return true if the control user can interact with the control, return false otherwise

Enable or disable the control

Return true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))

Show or hide the control to the user

Return the size of the button in the parent window

Set the size of the button in the parent window

Return the position of the button in the parent window

Set the position of the button in the parent window

Return window title

Set the window title

Winapi class name used during control creation

Winapi flags required by the control

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.