Skip to main content

WidgetImpl

Trait WidgetImpl 

Source
pub trait WidgetImpl: ObjectImpl + ObjectSubclass<Type: IsA<Widget>> {
Show 79 methods // Provided methods fn adjust_baseline_allocation(&self, baseline: &mut i32) { ... } fn adjust_baseline_request( &self, minimum_baseline: &mut i32, natural_baseline: &mut i32, ) { ... } fn preferred_height_and_baseline_for_width( &self, width: i32, ) -> (i32, i32, i32, i32) { ... } fn adjust_size_allocation( &self, orientation: Orientation, minimum_size: &mut i32, natural_size: &mut i32, allocated_pos: &mut i32, allocated_size: &mut i32, ) { ... } fn adjust_size_request( &self, orientation: Orientation, minimum_size: &mut i32, natural_size: &mut i32, ) { ... } fn button_press_event(&self, event: &EventButton) -> Propagation { ... } fn button_release_event(&self, event: &EventButton) -> Propagation { ... } fn child_notify(&self, child_property: &ParamSpec) { ... } fn composited_changed(&self) { ... } fn compute_expand(&self, hexpand: &mut bool, vexpand: &mut bool) { ... } fn configure_event(&self, event: &EventConfigure) -> Propagation { ... } fn window_state_event(&self, event: &EventWindowState) -> Propagation { ... } fn damage_event(&self, event: &EventExpose) -> Propagation { ... } fn delete_event(&self, event: &Event) -> Propagation { ... } fn destroy(&self) { ... } fn destroy_event(&self, event: &Event) -> Propagation { ... } fn direction_changed(&self, previous_direction: TextDirection) { ... } fn dispatch_child_properties_changed(&self, pspecs: &[ParamSpec]) { ... } fn drag_begin(&self, context: &DragContext) { ... } fn drag_data_delete(&self, context: &DragContext) { ... } fn drag_data_get( &self, context: &DragContext, selection_data: &SelectionData, info: u32, time: u32, ) { ... } fn drag_data_received( &self, context: &DragContext, x: i32, y: i32, selection_data: &SelectionData, info: u32, time: u32, ) { ... } fn drag_drop( &self, context: &DragContext, x: i32, y: i32, time: u32, ) -> Propagation { ... } fn drag_end(&self, context: &DragContext) { ... } fn drag_failed( &self, context: &DragContext, result: DragResult, ) -> Propagation { ... } fn drag_leave(&self, context: &DragContext, time: u32) { ... } fn drag_motion( &self, context: &DragContext, x: i32, y: i32, time: u32, ) -> Propagation { ... } fn draw(&self, cr: &Context) -> Propagation { ... } fn can_activate_accel(&self, signal_id: SignalId) -> bool { ... } fn request_mode(&self) -> SizeRequestMode { ... } fn preferred_width(&self) -> (i32, i32) { ... } fn preferred_width_for_height(&self, height: i32) -> (i32, i32) { ... } fn preferred_height(&self) -> (i32, i32) { ... } fn preferred_height_for_width(&self, width: i32) -> (i32, i32) { ... } fn size_allocate(&self, allocation: &Allocation) { ... } fn realize(&self) { ... } fn unrealize(&self) { ... } fn map(&self) { ... } fn unmap(&self) { ... } fn show(&self) { ... } fn hide(&self) { ... } fn grab_focus(&self) { ... } fn focus(&self, direction: DirectionType) -> bool { ... } fn motion_notify_event(&self, event: &EventMotion) -> Propagation { ... } fn scroll_event(&self, event: &EventScroll) -> Propagation { ... } fn enter_notify_event(&self, event: &EventCrossing) -> Propagation { ... } fn leave_notify_event(&self, event: &EventCrossing) -> Propagation { ... } fn focus_in_event(&self, event: &EventFocus) -> Propagation { ... } fn focus_out_event(&self, event: &EventFocus) -> Propagation { ... } fn key_press_event(&self, event: &EventKey) -> Propagation { ... } fn key_release_event(&self, event: &EventKey) -> Propagation { ... } fn map_event(&self, event: &Event) -> Propagation { ... } fn unmap_event(&self, event: &Event) -> Propagation { ... } fn show_all(&self) { ... } fn state_flags_changed(&self, previous_state_flags: StateFlags) { ... } fn parent_set(&self, previous_parent: Option<&Widget>) { ... } fn hierarchy_changed(&self, previous_toplevel: Option<&Widget>) { ... } fn grab_notify(&self, was_grabbed: bool) { ... } fn mnemonic_activate(&self, group_cycling: bool) -> bool { ... } fn move_focus(&self, direction: DirectionType) { ... } fn keynav_failed(&self, direction: DirectionType) -> bool { ... } fn event(&self, event: &Event) -> Propagation { ... } fn property_notify_event(&self, event: &EventProperty) -> Propagation { ... } fn selection_clear_event(&self, event: &EventSelection) -> Propagation { ... } fn selection_request_event(&self, event: &EventSelection) -> Propagation { ... } fn selection_notify_event(&self, event: &EventSelection) -> Propagation { ... } fn proximity_in_event(&self, event: &EventProximity) -> Propagation { ... } fn proximity_out_event(&self, event: &EventProximity) -> Propagation { ... } fn visibility_notify_event(&self, event: &EventVisibility) -> Propagation { ... } fn grab_broken_event(&self, event: &EventGrabBroken) -> Propagation { ... } fn touch_event(&self, event: &EventTouch) -> Propagation { ... } fn selection_get( &self, selection_data: &SelectionData, info: u32, time: u32, ) { ... } fn selection_received(&self, selection_data: &SelectionData, time: u32) { ... } fn popup_menu(&self) -> bool { ... } fn show_help(&self, help_type: WidgetHelpType) -> bool { ... } fn screen_changed(&self, previous_screen: Option<&Screen>) { ... } fn query_tooltip( &self, x: i32, y: i32, keyboard_tooltip: bool, tooltip: &Tooltip, ) -> bool { ... } fn style_updated(&self) { ... } fn queue_draw_region(&self, region: &Region) { ... }
}

Provided Methods§

Source

fn adjust_baseline_allocation(&self, baseline: &mut i32)

Source

fn adjust_baseline_request( &self, minimum_baseline: &mut i32, natural_baseline: &mut i32, )

Source

fn preferred_height_and_baseline_for_width( &self, width: i32, ) -> (i32, i32, i32, i32)

Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified width, or the default height if width is -1. The baselines may be -1 which means that no baseline is requested for this widget.

The returned request will be modified by the GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

§width

the width which is available for allocation, or -1 if none

§Returns
§minimum_height

location for storing the minimum height, or None

§natural_height

location for storing the natural height, or None

§minimum_baseline

location for storing the baseline for the minimum height, or None

§natural_baseline

location for storing the baseline for the natural height, or None

Source

fn adjust_size_allocation( &self, orientation: Orientation, minimum_size: &mut i32, natural_size: &mut i32, allocated_pos: &mut i32, allocated_size: &mut i32, )

Convert an initial size allocation assigned by a Container using WidgetExt::size_allocate(), into an actual size allocation to be used by the widget. adjust_size_allocation adjusts to a child widget’s actual allocation from what a parent container computed for the child. The adjusted allocation must be entirely within the original allocation. In any custom implementation, chain up to the default Widget implementation of this method, which applies the margin and alignment properties of Widget. Chain up before performing your own adjustments so your own adjustments remove more allocation after the Widget base class has already removed margin and alignment. The natural size passed in should be adjusted in the same way as the allocated size, which allows adjustments to perform alignments or other changes based on natural size.

Source

fn adjust_size_request( &self, orientation: Orientation, minimum_size: &mut i32, natural_size: &mut i32, )

Convert an initial size request from a widget’s SizeRequestMode virtual method implementations into a size request to be used by parent containers in laying out the widget. adjust_size_request adjusts from a child widget’s original request to what a parent container should use for layout. The for_size argument will be -1 if the request should not be for a particular size in the opposing orientation, i.e. if the request is not height-for-width or width-for-height. If for_size is greater than -1, it is the proposed allocation in the opposing orientation that we need the request for. Implementations of adjust_size_request should chain up to the default implementation, which applies Widget’s margin properties and imposes any values from WidgetExt::set_size_request(). Chaining up should be last, after your subclass adjusts the request, so Widget can apply constraints and add the margin properly.

Source

fn button_press_event(&self, event: &EventButton) -> Propagation

Signal will be emitted when a button (typically from a mouse) is pressed.

Source

fn button_release_event(&self, event: &EventButton) -> Propagation

Signal will be emitted when a button (typically from a mouse) is released.

Source

fn child_notify(&self, child_property: &ParamSpec)

Emits a child-notify signal for the [child property][child-properties] child_property on widget.

This is the analogue of ObjectExt::notify() for child properties.

Also see ContainerExt::child_notify().

§child_property

the name of a child property installed on the class of widget’s parent

Source

fn composited_changed(&self)

Signal emitted when the composited status of widgets screen changes. See Screen::is_composited().

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 configure_event(&self, event: &EventConfigure) -> Propagation

Signal will be emitted when the size, position or stacking of the widget’s window has changed.

Source

fn window_state_event(&self, event: &EventWindowState) -> Propagation

Signal emitted when the state of the toplevel window associated to the widget changes.

Source

fn damage_event(&self, event: &EventExpose) -> Propagation

Signal emitted when a redirected window belonging to widget gets drawn into.

Source

fn delete_event(&self, event: &Event) -> Propagation

Signal emitted if a user requests that a toplevel window is closed.

Source

fn destroy(&self)

Source

fn destroy_event(&self, event: &Event) -> Propagation

Signal is emitted when a gdk::Window is destroyed.

Source

fn direction_changed(&self, previous_direction: TextDirection)

Signal emitted when the text direction of a widget changes.

Source

fn dispatch_child_properties_changed(&self, pspecs: &[ParamSpec])

Seldomly overidden.

Source

fn drag_begin(&self, context: &DragContext)

Signal emitted on the drag source when a drag is started.

Source

fn drag_data_delete(&self, context: &DragContext)

Signal emitted on the drag source when a drag with the action gdk::DragAction::MOVE is successfully completed.

Source

fn drag_data_get( &self, context: &DragContext, selection_data: &SelectionData, info: u32, time: u32, )

Signal emitted on the drag source when the drop site requests the data which is dragged.

Source

fn drag_data_received( &self, context: &DragContext, x: i32, y: i32, selection_data: &SelectionData, info: u32, time: u32, )

Signal emitted on the drop site when the dragged data has been received.

Source

fn drag_drop( &self, context: &DragContext, x: i32, y: i32, time: u32, ) -> Propagation

Signal emitted on the drop site when the user drops the data onto the widget.

Source

fn drag_end(&self, context: &DragContext)

Signal emitted on the drag source when a drag is finished.

Source

fn drag_failed(&self, context: &DragContext, result: DragResult) -> Propagation

Signal emitted on the drag source when a drag has failed.

Source

fn drag_leave(&self, context: &DragContext, time: u32)

Signal emitted on the drop site when the cursor leaves the widget.

Source

fn drag_motion( &self, context: &DragContext, x: i32, y: i32, time: u32, ) -> Propagation

signal emitted on the drop site when the user moves the cursor over the widget during a drag.

Source

fn draw(&self, cr: &Context) -> Propagation

Signal emitted when a widget is supposed to render itself.

Source

fn can_activate_accel(&self, signal_id: SignalId) -> bool

Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the can-activate-accel signal on widget; if the signal isn’t overridden by a handler or in a derived widget, then the default check is that the widget must be sensitive, and the widget and all its ancestors mapped.

§signal_id

the ID of a signal installed on widget

§Returns

true if the accelerator can be activated.

Source

fn request_mode(&self) -> SizeRequestMode

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

Bin widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.

§Returns

The SizeRequestMode preferred by widget.

Source

fn preferred_width(&self) -> (i32, i32)

Retrieves a widget’s initial minimum and natural width.

This call is specific to height-for-width requests.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

§Returns
§minimum_width

location to store the minimum width, or None

§natural_width

location to store the natural width, or None

Source

fn preferred_width_for_height(&self, height: i32) -> (i32, i32)

Retrieves a widget’s minimum and natural width if it would be given the specified height.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

§height

the height which is available for allocation

§Returns
§minimum_width

location for storing the minimum width, or None

§natural_width

location for storing the natural width, or None

Source

fn preferred_height(&self) -> (i32, i32)

Retrieves a widget’s initial minimum and natural height.

This call is specific to width-for-height requests.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

§Returns
§minimum_height

location to store the minimum height, or None

§natural_height

location to store the natural height, or None

Source

fn preferred_height_for_width(&self, width: i32) -> (i32, i32)

Retrieves a widget’s minimum and natural height if it would be given the specified width.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

§width

the width which is available for allocation

§Returns
§minimum_height

location for storing the minimum height, or None

§natural_height

location for storing the natural height, or None

Source

fn size_allocate(&self, allocation: &Allocation)

This function is only used by Container subclasses, to assign a size and position to their child widgets.

In this function, the allocation may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual method on the child will be used to adjust the allocation. Standard adjustments include removing the widget’s margins, and applying the widget’s halign and valign properties.

For baseline support in containers you need to use WidgetExt::size_allocate_with_baseline() instead.

§allocation

position and size to be allocated to widget

Source

fn realize(&self)

window will be created when a widget is realized. 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 WidgetExt::realize() realizes the widget’s parents in addition to widget 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 draw. Or simply g_signal_connect () to the realize signal.

Source

fn unrealize(&self)

window).

Source

fn map(&self)

This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.

Source

fn unmap(&self)

This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.

Source

fn show(&self)

Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen. If you want to show all the widgets in a container, it’s easier to call WidgetExt::show_all() on the container, instead of individually showing the widgets.

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 container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.

Source

fn hide(&self)

Reverses the effects of WidgetExt::show(), causing the widget to be hidden (invisible to the user).

Source

fn grab_focus(&self)

Causes widget to have the keyboard focus for the Window it’s inside. widget must be a focusable widget, such as a Entry; something like Frame won’t work.

More precisely, it must have the GTK_CAN_FOCUS flag set. Use WidgetExt::set_can_focus() to modify that flag.

The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.

Source

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

Source

fn motion_notify_event(&self, event: &EventMotion) -> Propagation

Signal emitted when the pointer moves over the widget’s gdk::Window.

Source

fn scroll_event(&self, event: &EventScroll) -> Propagation

Signal emitted when a button in the 4 to 7 range is pressed.

Source

fn enter_notify_event(&self, event: &EventCrossing) -> Propagation

Signal event will be emitted when the pointer enters the widget’s window.

Source

fn leave_notify_event(&self, event: &EventCrossing) -> Propagation

Will be emitted when the pointer leaves the widget’s window.

Source

fn focus_in_event(&self, event: &EventFocus) -> Propagation

Signal emitted when the keyboard focus enters the widget’s window.

Source

fn focus_out_event(&self, event: &EventFocus) -> Propagation

Signal emitted when the keyboard focus leaves the widget’s window.

Source

fn key_press_event(&self, event: &EventKey) -> Propagation

Signal emitted when a key is pressed.

Source

fn key_release_event(&self, event: &EventKey) -> Propagation

Signal is emitted when a key is released.

Source

fn map_event(&self, event: &Event) -> Propagation

Signal emitted when the widget’s window is mapped.

Source

fn unmap_event(&self, event: &Event) -> Propagation

Signal will be emitted when the widget’s window is unmapped.

Source

fn show_all(&self)

Recursively shows a widget, and any child widgets (if the widget is a container).

Source

fn state_flags_changed(&self, previous_state_flags: StateFlags)

Signal emitted when the widget state changes, see WidgetExt::state_flags().

Source

fn parent_set(&self, previous_parent: Option<&Widget>)

Signal emitted when a new parent has been set on a widget.

Source

fn hierarchy_changed(&self, previous_toplevel: Option<&Widget>)

Signal emitted when the anchored state of a widget changes.

Source

fn grab_notify(&self, was_grabbed: bool)

Signal emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed.

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: DirectionType)

Signal emitted when a change of focus is requested

Source

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

This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the keynav-failed signal on the widget and its return value 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 DirectionType::TabForward and DirectionType::TabBackward. 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 container(s).

Source

fn event(&self, event: &Event) -> Propagation

Rarely-used function. This function is used to emit the event signals on a widget (those signals should never be emitted without using this function to do so). If you want to synthesize an event though, don’t use this function; instead, use main_do_event() so the event will behave as if it were in the event queue. Don’t synthesize expose events; instead, use Window::invalidate_rect() to invalidate a region of the window.

§event

a GdkEvent

§Returns

return from the event signal emission (true if the event was handled)

Source

fn property_notify_event(&self, event: &EventProperty) -> Propagation

Signal will be emitted when a property on the widget’s window has been changed or deleted.

Source

fn selection_clear_event(&self, event: &EventSelection) -> Propagation

Signal will be emitted when the the widget’s window has lost ownership of a selection.

Source

fn selection_request_event(&self, event: &EventSelection) -> Propagation

Signal will be emitted when another client requests ownership of the selection owned by the widget’s window.

Source

fn selection_notify_event(&self, event: &EventSelection) -> Propagation

Source

fn proximity_in_event(&self, event: &EventProximity) -> Propagation

Source

fn proximity_out_event(&self, event: &EventProximity) -> Propagation

Source

fn visibility_notify_event(&self, event: &EventVisibility) -> Propagation

Signal emitted when the widget’s window is obscured or unobscured.

Source

fn grab_broken_event(&self, event: &EventGrabBroken) -> Propagation

Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken.

Source

fn touch_event(&self, event: &EventTouch) -> Propagation

Signal emitted when a touch event happens

Source

fn selection_get(&self, selection_data: &SelectionData, info: u32, time: u32)

Source

fn selection_received(&self, selection_data: &SelectionData, time: u32)

Source

fn popup_menu(&self) -> bool

Signal emitted whenever a widget should pop up a context menu.

Source

fn show_help(&self, help_type: WidgetHelpType) -> bool

Source

fn screen_changed(&self, previous_screen: Option<&Screen>)

Signal emitted when the screen of a widget has changed.

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 style_updated(&self)

Signal emitted when the GtkStyleContext of a widget is changed.

Source

fn queue_draw_region(&self, region: &Region)

Invalidates the area of widget defined by region by calling Window::invalidate_region() on the widget’s window and all its child windows. Once the main loop becomes idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.

Normally you would only use this function in widget implementations. You might also use it to schedule a redraw of a DrawingArea or some portion thereof.

§region

region to draw

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§