Window
struct · ferroui-controls · v0.5.0
struct Window
A top-level window.
Members
TYPEto_refhandle_closingon_closingsize_to_content_propertyextend_client_area_to_decorations_hint_propertyextend_client_area_title_bar_height_hint_propertyis_extended_into_window_decorations_propertywindow_decoration_margin_propertyoff_screen_margin_propertywindow_decorations_propertywindow_decorations_theme_propertyshow_activated_propertyshow_in_taskbar_propertyclosing_behavior_propertywindow_state_propertytitle_propertyicon_propertywindow_startup_location_propertycan_resize_propertycan_minimize_propertycan_maximize_propertywindow_closed_eventwindow_opened_eventnewowned_windowssize_to_contentset_size_to_contenttitleset_titleextend_client_area_to_decorations_hintset_extend_client_area_to_decorations_hintextend_client_area_title_bar_height_hintset_extend_client_area_title_bar_height_hintis_extended_into_window_decorationswindow_decoration_margincaption_button_insetsoff_screen_marginwindow_decorationsset_window_decorationswindow_decorations_themeset_window_decorations_themesystem_decorationsset_system_decorationsshow_activatedset_show_activatedshow_in_taskbarset_show_in_taskbarclosing_behaviorset_closing_behaviorwindow_stateset_window_statecan_resizeset_can_resizecan_minimizeset_can_minimizecan_maximizeset_can_maximizeiconset_iconwindow_startup_locationset_window_startup_locationpositionset_positionis_dialogbegin_move_dragbegin_resize_dragclosingcloseclose_with_resultclose_coreshow_with_ownershow_dialogshow_dialog_typedshow_dialog_taskshow_dialog_typed_tasksort_windows_by_z_order
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<Window>
Returns a strong reference to this object.
handle_closing
fn handle_closing(self: &Self, reason: WindowCloseReason) -> bool
Handles a closing notification from the platform implementation.
Returns true if closing is cancelled, otherwise false. reason
is the reason the window is closing.
on_closing
fn on_closing(self: &Self, e: &WindowClosingEventArgs)
Raises the Closing event.
A type that derives from Window may override this member. The
override must call the base implementation if the Closing
event needs to be raised.
size_to_content_property
fn size_to_content_property() -> &'static StyledProperty<SizeToContent>
Defines the SizeToContent property.
extend_client_area_to_decorations_hint_property
fn extend_client_area_to_decorations_hint_property() -> &'static StyledProperty<bool>
Defines the ExtendClientAreaToDecorationsHint property.
extend_client_area_title_bar_height_hint_property
fn extend_client_area_title_bar_height_hint_property() -> &'static StyledProperty<f64>
Defines the ExtendClientAreaTitleBarHeightHint property.
is_extended_into_window_decorations_property
fn is_extended_into_window_decorations_property() -> &'static DirectProperty<Window, bool>
Defines the IsExtendedIntoWindowDecorations property.
window_decoration_margin_property
fn window_decoration_margin_property() -> &'static DirectProperty<Window, Thickness>
Defines the WindowDecorationMargin property.
off_screen_margin_property
fn off_screen_margin_property() -> &'static DirectProperty<Window, Thickness>
Defines the OffScreenMargin property.
window_decorations_property
fn window_decorations_property() -> &'static StyledProperty<WindowDecorations>
Defines the WindowDecorations property.
window_decorations_theme_property
fn window_decorations_theme_property() -> &'static StyledProperty<Option<Ref<ControlTheme>>>
Defines the WindowDecorationsTheme property.
show_activated_property
fn show_activated_property() -> &'static StyledProperty<bool>
Defines the ShowActivated property.
show_in_taskbar_property
fn show_in_taskbar_property() -> &'static StyledProperty<bool>
Enables or disables the taskbar icon.
closing_behavior_property
fn closing_behavior_property() -> &'static StyledProperty<WindowClosingBehavior>
Defines the ClosingBehavior property.
window_state_property
fn window_state_property() -> &'static DirectProperty<Window, WindowState>
Represents the currently effective window state (normal, minimized, maximized).
title_property
fn title_property() -> &'static StyledProperty<Option<String>>
Defines the Title property.
icon_property
fn icon_property() -> &'static StyledProperty<Option<Rc<WindowIcon>>>
Defines the Icon property.
window_startup_location_property
fn window_startup_location_property() -> &'static StyledProperty<WindowStartupLocation>
Defines the WindowStartupLocation property.
can_resize_property
fn can_resize_property() -> &'static StyledProperty<bool>
Defines the CanResize property.
can_minimize_property
fn can_minimize_property() -> &'static StyledProperty<bool>
Defines the CanMinimize property.
can_maximize_property
fn can_maximize_property() -> &'static StyledProperty<bool>
Defines the CanMaximize property.
window_closed_event
fn window_closed_event() -> &'static RoutedEvent<RoutedEventArgs>
Routed event that can be used for global tracking of window destruction.
window_opened_event
fn window_opened_event() -> &'static RoutedEvent<RoutedEventArgs>
Routed event that can be used for global tracking of opening windows.
new
fn new() -> Ref<Self>
Creates a window over a window of the windowing platform.
Panics
Panics when no windowing platform is registered.
owned_windows
fn owned_windows(self: &Self) -> Vec<Ref<Window>>
The child windows owned by this window.
size_to_content
fn size_to_content(self: &Self) -> SizeToContent
A value indicating how the window will size itself to fit its content.
If the value is other than SizeToContent::MANUAL, it is
automatically set to SizeToContent::MANUAL if a user resizes the
window by using the resize grip or dragging the border.
NOTE: Because of a limitation of X11, the value will be reset on X11
to SizeToContent::MANUAL on any resize - including the resize
that happens when the window is first shown. This is because X11
resize notifications are asynchronous and there is no way to know
whether a resize came from the user or the layout system. To avoid
this, consider setting CanResize to false, which will disable user
resizing of the window.
set_size_to_content
fn set_size_to_content(self: &Self, value: SizeToContent)
title
fn title(self: &Self) -> Option<String>
The title of the window.
set_title
fn set_title(self: &Self, value: Option<String>)
extend_client_area_to_decorations_hint
fn extend_client_area_to_decorations_hint(self: &Self) -> bool
Whether the client area is extended into the window decorations (chrome or border).
set_extend_client_area_to_decorations_hint
fn set_extend_client_area_to_decorations_hint(self: &Self, value: bool)
extend_client_area_title_bar_height_hint
fn extend_client_area_title_bar_height_hint(self: &Self) -> f64
The title bar height hint for when the client area is extended. A value of -1 will cause the title bar to be auto sized to the OS default. Any other positive value will cause the title bar to assume that height.
set_extend_client_area_title_bar_height_hint
fn set_extend_client_area_title_bar_height_hint(self: &Self, value: f64)
is_extended_into_window_decorations
fn is_extended_into_window_decorations(self: &Self) -> bool
Whether the client area is extended into the window decorations.
window_decoration_margin
fn window_decoration_margin(self: &Self) -> Thickness
The thickness around the window that is used by borders and the title bar.
caption_button_insets
fn caption_button_insets(self: &Self) -> Thickness
The room the caption buttons take at the left and the right of the title bar while the
client area is extended into the decorations: the traffic lights of macOS at the left, the
caption buttons the toolkit draws (Windows, Linux) at the right; zero otherwise. Not in
upstream: the insets of WinUI's AppWindowTitleBar (LeftInset, RightInset), which a
TitleBar leaves free.
off_screen_margin
fn off_screen_margin(self: &Self) -> Thickness
The window margin that is hidden off the screen area. This is generally only the case on Windows when maximized, where the window border is hidden off the screen. This margin may be used to ensure user content doesn't overlap this space.
window_decorations
fn window_decorations(self: &Self) -> WindowDecorations
The window decorations (title bar, border, etc).
set_window_decorations
fn set_window_decorations(self: &Self, value: WindowDecorations)
window_decorations_theme
fn window_decorations_theme(self: &Self) -> Option<Ref<ControlTheme>>
The theme used to render the window decorations when they are not drawn by the system.
set_window_decorations_theme
fn set_window_decorations_theme(self: &Self, value: impl Into<Nullable<ControlTheme>>)
system_decorations
fn system_decorations(self: &Self) -> WindowDecorations
Deprecated. Use window_decorations instead.
set_system_decorations
fn set_system_decorations(self: &Self, value: WindowDecorations)
Deprecated. Use set_window_decorations instead.
show_activated
fn show_activated(self: &Self) -> bool
Whether a window is activated when first shown.
set_show_activated
fn set_show_activated(self: &Self, value: bool)
show_in_taskbar
fn show_in_taskbar(self: &Self) -> bool
Enables or disables the taskbar icon.
set_show_in_taskbar
fn set_show_in_taskbar(self: &Self, value: bool)
closing_behavior
fn closing_behavior(self: &Self) -> WindowClosingBehavior
A value indicating how the closing event behaves in the presence of child windows.
set_closing_behavior
fn set_closing_behavior(self: &Self, value: WindowClosingBehavior)
window_state
fn window_state(self: &Self) -> WindowState
Represents the currently effective window state (normal, minimized, maximized).
set_window_state
fn set_window_state(self: &Self, value: WindowState)
can_resize
fn can_resize(self: &Self) -> bool
Enables or disables resizing of the window.
set_can_resize
fn set_can_resize(self: &Self, value: bool)
can_minimize
fn can_minimize(self: &Self) -> bool
Enables or disables minimizing the window.
This property might be ignored by some window managers on Linux.
set_can_minimize
fn set_can_minimize(self: &Self, value: bool)
can_maximize
fn can_maximize(self: &Self) -> bool
Enables or disables maximizing the window.
When CanResize is false, this property is always false. On macOS,
setting this property to false also disables the full screen mode.
This property might be ignored by some window managers on Linux.
set_can_maximize
fn set_can_maximize(self: &Self, value: bool)
icon
fn icon(self: &Self) -> Option<Rc<WindowIcon>>
The icon of the window.
set_icon
fn set_icon(self: &Self, value: Option<Rc<WindowIcon>>)
window_startup_location
fn window_startup_location(self: &Self) -> WindowStartupLocation
The startup location of the window.
set_window_startup_location
fn set_window_startup_location(self: &Self, value: WindowStartupLocation)
position
fn position(self: &Self) -> PixelPoint
The window position in screen coordinates.
set_position
fn set_position(self: &Self, value: PixelPoint)
is_dialog
fn is_dialog(self: &Self) -> bool
Whether this window was opened as a dialog.
begin_move_drag
fn begin_move_drag(self: &Self, e: &PointerPressedEventArgs)
Starts moving a window with left button being held. Should be called from a left mouse button press event handler.
begin_resize_drag
fn begin_resize_drag(self: &Self, edge: WindowEdge, e: &PointerPressedEventArgs)
Starts resizing a window. This function is used if an application has window resizing controls. Should be called from a left mouse button press event handler.
closing
fn closing(self: &Self, handler: impl Fn(&WindowClosingEventArgs) -> () + 'static) -> Subscription
Fired before a window is closed.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the window.
close
fn close(self: &Self)
Closes the window.
close_with_result
fn close_with_result(self: &Self, dialog_result: Option<BoxedValue>)
Closes a dialog window with the specified result.
When the window is shown with show_dialog or
show_dialog_typed, the handle of its task
gives the dialog_result value when the window is closed.
close_core
fn close_core(self: &Self, reason: WindowCloseReason, is_programmatic: bool, ignore_cancel: bool)
Closes the window for reason; with ignore_cancel the window
closes even when a closing handler cancels (internal upstream: for
the application lifetime).
show_with_owner
fn show_with_owner(self: &Self, owner: &Window)
Shows the window as a child of owner.
Panics
Panics when the window has already been closed, and when the owner is closed, not visible or the window itself.
show_dialog
fn show_dialog(self: &Self, owner: &Window) -> JoinHandle<Option<BoxedValue>>
Shows the window as a dialog owned by owner.
Returns the handle of a task of the dispatcher that tracks the
lifetime of the dialog: it ends, in a dispatcher job, with the dialog
result (see close_with_result) once the
dialog has closed, or with JoinError::Canceled when the dispatcher
shuts down first. Nothing blocks: the caller keeps running, and
dropping the handle leaves the dialog open.
Panics
Panics when the window has already been closed or is already shown, and when the owner is closed, not visible or the window itself.
show_dialog_typed
fn show_dialog_typed<TResult: Clone + Default + 'static>(self: &Self, owner: &Window) -> JoinHandle<TResult>
Shows the window as a dialog owned by owner; TResult is the type
of the result produced by the dialog.
Returns the handle of a task that gives the result of the dialog when
it closes: the value passed to
close_with_result, or the default of
TResult when the dialog closed without a result. When the dialog
result is not a TResult, the task panics, and its handle ends with
JoinError::Panicked.
Panics
See show_dialog.
show_dialog_task
fn show_dialog_task(self: &Self, owner: &Window) -> DispatcherTask<Option<BoxedValue>>
The deprecated form of show_dialog: a
DispatcherTask, which raises a failure again when it is observed.
Panics
See show_dialog.
Deprecated since 0.5.0. use
show_dialog, which gives aJoinHandle
show_dialog_typed_task
fn show_dialog_typed_task<TResult: Clone + Default + 'static>(self: &Self, owner: &Window) -> DispatcherTask<TResult>
The deprecated form of show_dialog_typed:
a DispatcherTask, which raises the failure to cast the dialog result
again when it is observed.
Panics
See show_dialog.
Deprecated since 0.5.0. use
show_dialog_typed, which gives aJoinHandle
sort_windows_by_z_order
fn sort_windows_by_z_order(windows: &mut [Ref<Window>])
Sorts the windows ascending by their Z order - the topmost window will be the last in the list.
Panics
Panics when one of the windows is closed, and when no windowing platform is registered.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtContentControlImplExtControlImplExtTopLevelImplExtWindowBaseImplExtWindowImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<Window>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleVisualImplInteractiveImplContentControlImplControlImplIFocusScopeInputElementImplStyledElementImplFerroObjectImplTemplatedControlImplLayoutableImplTopLevelImplWindowBaseImplWindowImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.