mousetrap v0.2.0
Loading...
Searching...
No Matches
mousetrap::Window Class Reference

window, registered to an application More...

#include <window.hpp>

Inheritance diagram for mousetrap::Window:
mousetrap::has_signal_unmap< Window > mousetrap::has_signal_map< Window > mousetrap::has_signal_show< Window > mousetrap::has_signal_hide< Window > mousetrap::has_signal_destroy< Window > mousetrap::has_signal_unrealize< Window > mousetrap::has_signal_realize< Window > mousetrap::has_signal_activate_focused_widget< Window > mousetrap::has_signal_activate_default_widget< Window > mousetrap::has_signal_close_request< Window > mousetrap::Widget

Public Member Functions

 Window (Application &application)
 construct
 
 Window (detail::WindowInternal *)
 construct from internal
 
 ~Window ()
 destructor
 
NativeObject get_internal () const override
 expose internal
 
 operator NativeObject () const override
 override signal emitter
 
void set_application (Application &application)
 link with application
 
void set_maximized (bool)
 attempt to maximize the window
 
void set_fullscreen (bool)
 set whether the window should attempt to enter fullscreen mode
 
void set_minimized (bool)
 attempt to minimize the window
 
void present ()
 present the window to the user
 
void set_hide_on_close (bool)
 set whether mousetrap::Window::close should hide or destroy the window, true by default
 
bool get_hide_on_close () const
 get whether mousetrap::Window::close should hide or destroy the window, true by default
 
void close ()
 hide the window, it will be inaccesible until mousetrap::Window::present is called again
 
void set_child (const Widget &)
 set the child of the window
 
void remove_child ()
 remove child
 
void set_destroy_with_parent (bool)
 set whether the window should be destroyed if its parent window is destroyed, true by default
 
bool get_destroy_with_parent () const
 get whether the window should be destroyed if its parent window is destroyed
 
void set_title (const std::string &title)
 set the title of the titlebar
 
std::string get_title () const
 get the title of the window
 
HeaderBar get_header_bar () const
 access the windows header bar widget
 
void set_is_modal (bool)
 set whether the window should be modal. A modal window prevents users from interacting with any other open application window
 
bool get_is_modal () const
 get whether the window is modal. A modal window prevents users from interacting with any other open application window
 
void set_transient_for (Window &partner)
 set whether this window should always be shown on top of the partner window
 
void set_is_decorated (bool)
 set whether the window has a titlebar
 
bool get_is_decorated () const
 get whether the window has a titlebar
 
void set_has_close_button (bool)
 set whether the window should have a close button
 
bool get_has_close_button () const
 get whether the window has a close button
 
void set_startup_notification_identifier (const std::string &id)
 set the window startup notification identifier, usually results in the users OS sending a notification "<name> is ready"
 
void set_focus_visible (bool)
 set whether the focused widget should be highlighted with a rectangle
 
bool get_focus_visible () const
 get whether the focused widget should be highlighted with a rectangle
 
void set_default_widget (const Widget &widget)
 set default widget
 
void destroy ()
 free all internal references
 
- Public Member Functions inherited from mousetrap::Widget
 Widget (detail::WidgetInternal *)
 construct from internal
 
virtual ~Widget ()
 default dtor
 
 Widget (const Widget &)=delete
 
Widgetoperator= (const Widget &) const =delete
 
 Widget (Widget &&other)=delete
 
Widgetoperator= (Widget &&)=delete
 
 operator NativeObject () const override
 implement signal emitter
 
NativeObject get_internal () const override
 expose internally managed object, \for_internal_use_only
 
virtual operator NativeWidget () const
 expose as GtkWidget, this is the only function that needs to be implemented in oder for an object to act as a widget
 
void activate ()
 activate the widget, if it is activatable. This will also trigger any associated animations or signals
 
Vector2f get_size_request ()
 get minimum allocated size
 
void set_size_request (Vector2f)
 set minimum allocated size
 
bool operator== (const Widget &other) const
 check if both widgets point to the same internal object
 
bool operator!= (const Widget &other) const
 check if both widgets point to the same internal object
 
void set_margin_top (float margin)
 set top margin, minimum distance to any other widget boundary
 
float get_margin_top () const
 get top margin, minimum distance to any other widget boundary
 
void set_margin_bottom (float margin)
 set bottom margin, minimum distance to any other widget boundary
 
float get_margin_bottom () const
 set botom margin, minimum distance to any other widget boundary
 
void set_margin_start (float margin)
 set left margin, minimum distance to any other widget boundary
 
float get_margin_start () const
 get left margin, minimum distance to any other widget boundary
 
void set_margin_end (float margin)
 set right margin, minimum distance to any other widget boundary
 
float get_margin_end () const
 get right margin, minimum distance to any other widget boundary
 
void set_margin_horizontal (float margin)
 set left and right margin, minimum distance to any other widget boundary
 
void set_margin_vertical (float margin)
 set top and bottom margin, minimum distance to any other widget boundary
 
void set_margin (float margin)
 set margin in all directions, minimum distance to any other widget boundary
 
void set_expand_horizontally (bool should_expand)
 set whether widget should attempt to allocate the maximum allowed space horizontally
 
bool get_expand_horizontally () const
 get whether widget should attempt to allocate the maximum allowed space horizontally
 
void set_expand_vertically (bool should_expand)
 set whether widget should attempt to allocate the maximum allowed space verticall
 
bool get_expand_vertically () const
 get whether widget should attempt to allocate the maximum allowed space vertically
 
void set_expand (bool both)
 set whether the widget should attempt to allocate the maximum allowed space in both dimensions
 
void set_horizontal_alignment (Alignment)
 set where the widget should align itself along the x-axis
 
Alignment get_horizontal_alignment () const
 get where the widget should align itself along the x-axis
 
void set_vertical_alignment (Alignment)
 set where the widget should align itself along the y-axis
 
Alignment get_vertical_alignment () const
 get where the widget should align itself along the y-axis
 
void set_alignment (Alignment both)
 set where the widget should align itself along both axes
 
void set_opacity (float opacity)
 set widget opacity, in [0, 1], if opacity is set to 0, equivalent to mousetrap::Widget::hide()
 
float get_opacity ()
 get widget opacity
 
void set_is_visible (bool b)
 set whether the widget should be hidden
 
bool get_is_visible ()
 get whether the widget is hidden
 
void set_tooltip_text (const std::string &text)
 set text displayed as a tooltip when the user hovers over the widget
 
void set_tooltip_widget (const Widget &widget)
 set arbitrary widget displayed as a tooltip when user hovers over the widget
 
void remove_tooltip_widget ()
 remove tooltip
 
void set_cursor (CursorType type)
 set the shape of cursor displayed when the cursor is above the widget
 
void set_cursor_from_image (const Image &image, Vector2i offset)
 set cursor from custom image
 
void hide ()
 hide the widget, this may set its allocated size to 0
 
void show ()
 show the widget, this allocates its size
 
void add_controller (const EventController &)
 add an event controller to the widget, a widget may have an arbitrary number of controllers
 
void remove_controller (const EventController &)
 remove an event controller from the widget, if event controller is not registered to widget, does nothing
 
void set_is_focusable (bool)
 set whether the widgets can contain input focus
 
bool get_is_focusable () const
 get whether widget can contain focus input focus
 
void grab_focus ()
 attempt to grab the input focus
 
bool get_has_focus ()
 get whether the wigdet currently holds input focus
 
void set_focus_on_click (bool)
 set whether the input should attempt to grab the focus when the user clicks on it
 
bool get_focus_on_click () const
 get whether the input should attempt to grab the focus when the user clicks on it
 
bool get_is_realized ()
 get whether the widget was realized
 
Vector2f get_minimum_size () const
 get minimum size, this will always be equal to or larger than the size request
 
Vector2f get_natural_size () const
 get natural size, this is the intended size of the widget if no expansion or clipping occurrs
 
Vector2f get_position () const
 get position
 
Vector2f get_allocated_size () const
 get allocated size
 
void unparent ()
 remove the widget from the container it is in, if any
 
void set_can_respond_to_input (bool)
 set whether the widget is allowed to gather input events. If set to false, the widget may appear "grayed out"
 
bool get_can_respond_to_input () const
 get whether the widget is allowed to gather input events
 
template<typename Function_t , typename Data_t >
void set_tick_callback (Function_t function, Data_t data)
 add a callback that is invoked every frame
 
template<typename Function_t >
void set_tick_callback (Function_t function)
 add a callback that is invoked every frame
 
void remove_tick_callback ()
 remove callback that si invoked every frame
 
Clipboard get_clipboard () const
 get the widgets associated clipboard
 
void set_hide_on_overflow (bool b)
 set whether a child widget inside this widget should be cutoff when it leaves this widgets boundary
 
bool get_hide_on_overflow () const
 get whether a child widget inside this widget should be cutoff when it leaves this widgets boundary
 
void set_listens_for_shortcut_actions (Action &)
 Convenience function that automatically adds the action to a shortcut controller of this widget.
 
void apply_style_class (const StyleClass &)
 apply style class to widget and its children
 
void add_css_class (const std::string &css)
 add css class
 
void remove_css_class (const std::string &css)
 remove css class
 
std::vector< std::string > get_css_classes () const
 get all applied css classes
 
- Public Member Functions inherited from mousetrap::SignalEmitter
void set_signal_blocked (const std::string &signal_id, bool b)
 block a signal by id \for_internal_use_only
 
bool get_signal_blocked (const std::string &signal_id) const
 get whether a signal is currently blocked
 
std::vector< std::string > get_all_signal_names ()
 get list of possible signal ids \for_internal_use_only
 
template<typename Function_t >
void connect_signal (const std::string &signal_id, Function_t *function, void *data=nullptr)
 connect static function to signal, does not work with lambdas \for_internal_use_only
 
void disconnect_signal (const std::string &signal_id)
 disconnect signal, it may not be invoked until reconnected, if signal is not registered, does nothing. For internal use only
 
virtual operator NativeObject () const =0
 expose as NativeObject, this is the GLib instance that signals are emitted on \for_internal_use_only
 
virtual NativeObject get_internal () const
 expose internally managed object, \for_internal_use_only
 
- Public Member Functions inherited from mousetrap::has_signal_close_request< Window >
void connect_signal_close_request (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_close_request (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_close_request_blocked (bool b)
 
bool get_signal_close_request_blocked () const
 
void emit_signal_close_request ()
 invoke signal handler manually
 
void disconnect_signal_close_request ()
 
- Public Member Functions inherited from mousetrap::has_signal_activate_default_widget< Window >
void connect_signal_activate_default_widget (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_activate_default_widget (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_activate_default_widget_blocked (bool b)
 
bool get_signal_activate_default_widget_blocked () const
 
void emit_signal_activate_default_widget ()
 invoke signal handler manually
 
void disconnect_signal_activate_default_widget ()
 
- Public Member Functions inherited from mousetrap::has_signal_activate_focused_widget< Window >
void connect_signal_activate_focused_widget (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_activate_focused_widget (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_activate_focused_widget_blocked (bool b)
 
bool get_signal_activate_focused_widget_blocked () const
 
void emit_signal_activate_focused_widget ()
 invoke signal handler manually
 
void disconnect_signal_activate_focused_widget ()
 
- Public Member Functions inherited from mousetrap::has_signal_realize< Window >
void connect_signal_realize (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_realize (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_realize_blocked (bool b)
 
bool get_signal_realize_blocked () const
 
void emit_signal_realize ()
 invoke signal handler manually
 
void disconnect_signal_realize ()
 
- Public Member Functions inherited from mousetrap::has_signal_unrealize< Window >
void connect_signal_unrealize (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_unrealize (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_unrealize_blocked (bool b)
 Set whether signal emission should trigger the signal handler.
 
bool get_signal_unrealize_blocked () const
 get whether signal emission should trigger the signal handler
 
void emit_signal_unrealize ()
 invoke signal handler manually
 
void disconnect_signal_unrealize ()
 disconnect the signal handler
 
- Public Member Functions inherited from mousetrap::has_signal_destroy< Window >
void connect_signal_destroy (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_destroy (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_destroy_blocked (bool b)
 Set whether signal emission should trigger the signal handler.
 
bool get_signal_destroy_blocked () const
 get whether signal emission should trigger the signal handler
 
void emit_signal_destroy ()
 invoke signal handler manually
 
void disconnect_signal_destroy ()
 disconnect the signal handler
 
- Public Member Functions inherited from mousetrap::has_signal_hide< Window >
void connect_signal_hide (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_hide (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_hide_blocked (bool b)
 
bool get_signal_hide_blocked () const
 
void emit_signal_hide ()
 invoke signal handler manually
 
void disconnect_signal_hide ()
 
- Public Member Functions inherited from mousetrap::has_signal_show< Window >
void connect_signal_show (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_show (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_show_blocked (bool b)
 
bool get_signal_show_blocked () const
 
void emit_signal_show ()
 invoke signal handler manually
 
void disconnect_signal_show ()
 
- Public Member Functions inherited from mousetrap::has_signal_map< Window >
void connect_signal_map (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_map (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_map_blocked (bool b)
 
bool get_signal_map_blocked () const
 
void emit_signal_map ()
 invoke signal handler manually
 
void disconnect_signal_map ()
 
- Public Member Functions inherited from mousetrap::has_signal_unmap< Window >
void connect_signal_unmap (Function_t f, Data_t data)
 connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function
 
void connect_signal_unmap (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_unmap_blocked (bool b)
 
bool get_signal_unmap_blocked () const
 
void emit_signal_unmap ()
 invoke signal handler manually
 
void disconnect_signal_unmap ()
 

Additional Inherited Members

- Static Public Attributes inherited from mousetrap::has_signal_close_request< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_activate_default_widget< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_activate_focused_widget< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_realize< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_unrealize< Window >
static const char * signal_id
 
- Static Public Attributes inherited from mousetrap::has_signal_destroy< Window >
static const char * signal_id
 
- Static Public Attributes inherited from mousetrap::has_signal_hide< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_show< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_map< Window >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_unmap< Window >
static const char * signal_id
 glib ID
 
- Protected Member Functions inherited from mousetrap::Widget
 Widget (NativeWidget widget)
 ctor protected. Only inheriting classes should call this
 
- Protected Member Functions inherited from mousetrap::SignalEmitter
 SignalEmitter ()
 ctor
 
 ~SignalEmitter ()
 destructor
 
- Protected Member Functions inherited from mousetrap::has_signal_close_request< Window >
 has_signal_close_request (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_activate_default_widget< Window >
 has_signal_activate_default_widget (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_activate_focused_widget< Window >
 has_signal_activate_focused_widget (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_realize< Window >
 has_signal_realize (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_unrealize< Window >
 has_signal_unrealize (Window *instance)
 ctor protected
 
- Protected Member Functions inherited from mousetrap::has_signal_destroy< Window >
 has_signal_destroy (Window *instance)
 ctor protected
 
- Protected Member Functions inherited from mousetrap::has_signal_hide< Window >
 has_signal_hide (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_show< Window >
 has_signal_show (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_map< Window >
 has_signal_map (Window *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_unmap< Window >
 has_signal_unmap (Window *instance)
 

Detailed Description

window, registered to an application

signal id signature emitted when...
close_request (Window&, (Data_t)) -> WindowCloseRequestResult Window is asked to close, usually by the user pressing the close button in the windows headerbar
activate_default_widget (Window&, (Data_t)) -> void Default widget of a window is activated, see Window::set_default_widget
activate_focuses_widget (Window&, (Data_t)) -> void Widget that is a child of Window and currently holds focus is activate
Signals inherited from Widget
realize (Window&, (Data_t)) -> void Widget is realized, usually right before it is drawn for the first time
unrealize (Window&, (Data_t)) -> void Widget is unmapped and will no longer be drawn
destroy (Window&, (Data_t)) -> void Widgets internal state is deallocated, calling Widget::~Widget() may not necessarily emit this signal
hide (Window&, (Data_t)) -> void Widget is actively hidden, leaves the visible area of the window, or its opacity is set to 0
show (Window&, (Data_t)) -> void Widget is drawn for the first time after being realized
map (Window&, (Data_t)) -> void Widget is mapped, this happens the first time it and all its parents become visible
unmap (Window&, (Data_t)) -> void Widget and all of its parents become hidden

Constructor & Destructor Documentation

◆ Window()

mousetrap::Window::Window ( Application application)

construct

Parameters
application

Member Function Documentation

◆ get_destroy_with_parent()

bool mousetrap::Window::get_destroy_with_parent ( ) const

get whether the window should be destroyed if its parent window is destroyed

Returns
true if it should also be destroyed, false if not

◆ get_focus_visible()

bool mousetrap::Window::get_focus_visible ( ) const

get whether the focused widget should be highlighted with a rectangle

Returns
true if it should be highlighted, false otherwise

◆ get_has_close_button()

bool mousetrap::Window::get_has_close_button ( ) const

get whether the window has a close button

Returns
true if close button should be shown, false otherwise

◆ get_header_bar()

HeaderBar mousetrap::Window::get_header_bar ( ) const

access the windows header bar widget

Returns
header abr

◆ get_hide_on_close()

bool mousetrap::Window::get_hide_on_close ( ) const

get whether mousetrap::Window::close should hide or destroy the window, true by default

Returns
boolean

◆ get_internal()

NativeObject mousetrap::Window::get_internal ( ) const
overridevirtual

expose internal

Reimplemented from mousetrap::Widget.

◆ get_is_decorated()

bool mousetrap::Window::get_is_decorated ( ) const

get whether the window has a titlebar

Returns
true if window has a titlebar, false otherwise

◆ get_is_modal()

bool mousetrap::Window::get_is_modal ( ) const

get whether the window is modal. A modal window prevents users from interacting with any other open application window

Returns
true if modal, false otherwise.

◆ get_title()

std::string mousetrap::Window::get_title ( ) const

get the title of the window

Returns
title

◆ operator NativeObject()

mousetrap::Window::operator NativeObject ( ) const
overridevirtual

override signal emitter

Reimplemented from mousetrap::Widget.

◆ set_application()

void mousetrap::Window::set_application ( Application application)

link with application

Parameters
application

◆ set_child()

void mousetrap::Window::set_child ( const Widget widget)

set the child of the window

Parameters
widgetchild

References set_child().

Referenced by set_child().

◆ set_default_widget()

void mousetrap::Window::set_default_widget ( const Widget widget)

set default widget

Parameters
widget

◆ set_destroy_with_parent()

void mousetrap::Window::set_destroy_with_parent ( bool  b)

set whether the window should be destroyed if its parent window is destroyed, true by default

Parameters
btrue if it should also be destroyed, false if not

◆ set_focus_visible()

void mousetrap::Window::set_focus_visible ( bool  b)

set whether the focused widget should be highlighted with a rectangle

Parameters
btrue if it should be highlighted, false otherwise

◆ set_fullscreen()

void mousetrap::Window::set_fullscreen ( bool  b)

set whether the window should attempt to enter fullscreen mode

Parameters
btrue if window should enter fullscreen mode, false otherwise

◆ set_has_close_button()

void mousetrap::Window::set_has_close_button ( bool  b)

set whether the window should have a close button

Parameters
btrue if window should have a close button, false otherwise

◆ set_hide_on_close()

void mousetrap::Window::set_hide_on_close ( bool  b)

set whether mousetrap::Window::close should hide or destroy the window, true by default

Parameters
btrue if window should only be hidden, false if it should be destroyed

◆ set_is_decorated()

void mousetrap::Window::set_is_decorated ( bool  b)

set whether the window has a titlebar

Parameters
btrue if window should have a titlebar, false othterwise

◆ set_is_modal()

void mousetrap::Window::set_is_modal ( bool  b)

set whether the window should be modal. A modal window prevents users from interacting with any other open application window

Parameters
btrue if window should be modal, false otherwise

◆ set_maximized()

void mousetrap::Window::set_maximized ( bool  b)

attempt to maximize the window

Parameters
btrue if window should be maximize, false otherwise

◆ set_minimized()

void mousetrap::Window::set_minimized ( bool  b)

attempt to minimize the window

Parameters
btrue if window should be minimized, false otherwise

◆ set_startup_notification_identifier()

void mousetrap::Window::set_startup_notification_identifier ( const std::string &  id)

set the window startup notification identifier, usually results in the users OS sending a notification "<name> is ready"

Parameters
id

◆ set_title()

void mousetrap::Window::set_title ( const std::string &  title)

set the title of the titlebar

Parameters
title

◆ set_transient_for()

void mousetrap::Window::set_transient_for ( Window partner)

set whether this window should always be shown on top of the partner window

Parameters
partnerother window, self will be shown above partner

The documentation for this class was generated from the following files: