gtk4::subclass::widget

Trait WidgetImpl

Source
pub trait WidgetImpl: ObjectImpl + ObjectSubclass<Type: IsA<Widget> + IsA<Accessible> + IsA<Buildable> + IsA<ConstraintTarget>> {
Show 24 methods // Provided methods fn compute_expand(&self, hexpand: &mut bool, vexpand: &mut bool) { ... } fn contains(&self, x: f64, y: f64) -> bool { ... } fn direction_changed(&self, previous_direction: TextDirection) { ... } fn focus(&self, direction_type: DirectionType) -> bool { ... } fn request_mode(&self) -> SizeRequestMode { ... } fn grab_focus(&self) -> bool { ... } fn hide(&self) { ... } fn keynav_failed(&self, direction_type: DirectionType) -> bool { ... } fn map(&self) { ... } fn measure( &self, orientation: Orientation, for_size: i32, ) -> (i32, i32, i32, i32) { ... } fn mnemonic_activate(&self, group_cycling: bool) -> bool { ... } fn move_focus(&self, direction_type: DirectionType) { ... } fn query_tooltip( &self, x: i32, y: i32, keyboard_tooltip: bool, tooltip: &Tooltip, ) -> bool { ... } fn realize(&self) { ... } fn root(&self) { ... } fn set_focus_child(&self, child: Option<&Widget>) { ... } fn show(&self) { ... } fn size_allocate(&self, width: i32, height: i32, baseline: i32) { ... } fn snapshot(&self, snapshot: &Snapshot) { ... } fn state_flags_changed(&self, state_flags: &StateFlags) { ... } fn system_setting_changed(&self, settings: &SystemSetting) { ... } fn unmap(&self) { ... } fn unrealize(&self) { ... } fn unroot(&self) { ... }
}

Provided Methods§

Source

fn compute_expand(&self, hexpand: &mut bool, vexpand: &mut bool)

Computes whether a container should give this widget extra space when possible.

Source

fn contains(&self, x: f64, y: f64) -> bool

Tests if a given point is contained in the widget.

The coordinates for (x, y) must be in widget coordinates, so (0, 0) is assumed to be the top left of @self’s content area.

§x

X coordinate to test, relative to @self’s origin

§y

Y coordinate to test, relative to @self’s origin

§Returns

true if @self contains the point (x, y)

Source

fn direction_changed(&self, previous_direction: TextDirection)

Signal emitted when the text direction of a widget changes.

Source

fn focus(&self, direction_type: DirectionType) -> bool

Vfunc for gtk_widget_child_focus()

Source

fn request_mode(&self) -> SizeRequestMode

Gets whether the widget prefers a height-for-width layout or a width-for-height layout.

Single-child widgets generally propagate the preference of their child, more complex widgets need to request something either in context of their children or in context of their allocation capabilities.

§Returns

The SizeRequestMode preferred by @self.

Source

fn grab_focus(&self) -> bool

Causes @self to have the keyboard focus for the window that it belongs to.

If @self is not focusable, or its WidgetImpl::grab_focus() implementation cannot transfer the focus to a descendant of @self that is focusable, it will not take focus and false will be returned.

Calling WidgetExt::grab_focus() on an already focused widget is allowed, should not have an effect, and return true.

§Returns

true if focus is now inside @self

Source

fn hide(&self)

👎Deprecated: Since 4.10

Reverses the effects of [method.Gtk.Widget.show].

This is causing the widget to be hidden (invisible to the user).

§Deprecated since 4.10

Use WidgetExt::set_visible() instead

Source

fn keynav_failed(&self, direction_type: DirectionType) -> bool

Emits the keynav-failed signal on the widget.

This function should be called whenever keyboard navigation within a single widget hits a boundary.

The return value of this function should be interpreted in a way similar to the return value of WidgetExt::child_focus(). When true is returned, stay in the widget, the failed keyboard navigation is ok and/or there is nowhere we can/should move the focus to. When false is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling WidgetExt::child_focus() on the widget’s toplevel.

The default keynav-failed handler returns false for [enum@Gtk.DirectionType.tab-forward] and [enum@Gtk.DirectionType.tab-backward]. For the other values of DirectionType it returns true.

Whenever the default handler returns true, it also calls WidgetExt::error_bell() to notify the user of the failed keyboard navigation.

A use case for providing an own implementation of ::keynav-failed (either by connecting to it or by overriding it) would be a row of Entry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.

§direction

direction of focus movement

§Returns

true if stopping keyboard navigation is fine, false if the emitting widget should try to handle the keyboard navigation attempt in its parent widget

Source

fn map(&self)

Causes a widget to be mapped if it isn’t already.

This function is only for use in widget implementations.

Source

fn measure( &self, orientation: Orientation, for_size: i32, ) -> (i32, i32, i32, i32)

Measures @self in the orientation @orientation and for the given @for_size.

As an example, if @orientation is Orientation::Horizontal and @for_size is 300, this functions will compute the minimum and natural width of @self if it is allocated at a height of 300 pixels.

See GtkWidget’s geometry management section for a more details on implementing GtkWidgetClass.measure().

§orientation

the orientation to measure

§for_size

Size for the opposite of @orientation, i.e. if @orientation is Orientation::Horizontal, this is the height the widget should be measured with. The Orientation::Vertical case is analogous. This way, both height-for-width and width-for-height requests can be implemented. If no size is known, -1 can be passed.

§Returns
§minimum

location to store the minimum size

§natural

location to store the natural size

§minimum_baseline

location to store the baseline position for the minimum size, or -1 to report no baseline

§natural_baseline

location to store the baseline position for the natural size, or -1 to report no baseline

Source

fn mnemonic_activate(&self, group_cycling: bool) -> bool

Emits the mnemonic-activate signal.

§group_cycling

true if there are other widgets with the same mnemonic

§Returns

true if the signal has been handled

Source

fn move_focus(&self, direction_type: DirectionType)

Signal emitted when a change of focus is requested

Source

fn query_tooltip( &self, x: i32, y: i32, keyboard_tooltip: bool, tooltip: &Tooltip, ) -> bool

Signal emitted when “has-tooltip” is true and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode.

Source

fn realize(&self)

Creates the GDK resources associated with a widget.

Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.

Realizing a widget requires all the widget’s parent widgets to be realized; calling this function realizes the widget’s parents in addition to @self itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.

This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as realize.

Source

fn root(&self)

Called when the widget gets added to a Root widget. Must chain up

Source

fn set_focus_child(&self, child: Option<&Widget>)

Set the focus child of the widget.

This function is only suitable for widget implementations. If you want a certain widget to get the input focus, call WidgetExt::grab_focus() on it.

§child

a direct child widget of @self or NULL to unset the focus child

Source

fn show(&self)

👎Deprecated: Since 4.10

Flags a widget to be displayed.

Any widget that isn’t shown will not appear on the screen.

Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.

When a toplevel widget is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel widget is realized and mapped.

§Deprecated since 4.10

Use WidgetExt::set_visible() instead

Source

fn size_allocate(&self, width: i32, height: i32, baseline: i32)

Called to set the allocation, if the widget does not have a layout manager.

Source

fn snapshot(&self, snapshot: &Snapshot)

Vfunc called when a new snapshot of the widget has to be taken.

Source

fn state_flags_changed(&self, state_flags: &StateFlags)

Signal emitted when the widget state changes, see gtk_widget_get_state_flags().

Source

fn system_setting_changed(&self, settings: &SystemSetting)

Emitted when a system setting was changed. Must chain up.

Source

fn unmap(&self)

Causes a widget to be unmapped if it’s currently mapped.

This function is only for use in widget implementations.

Source

fn unrealize(&self)

Causes a widget to be unrealized.

This frees all GDK resources associated with the widget.

This function is only useful in widget implementations.

Source

fn unroot(&self)

Called when the widget is about to be removed from its Root widget. Must chain up

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§