Module app

Available on crate feature dep_fltk only.
Expand description

Application related methods and functions

Modules§

cairo
Enables the use of the cairo context with Cairo-rs. Requires the cairoext build flag.
prefs
Provids bindings to Preferences which provides methods to store user settings between application starts

Structs§

App
Basic Application struct, used to instantiate, set the scheme and run the event loop
GlobalState
Represents global state
Receiver
Creates a receiver struct
Screen
An available screen
Sender
Creates a sender struct

Enums§

ClipboardContent
Types of Clipboard contents
ClipboardEvent
The event clipboard type
ContrastMode
Contrast modes supported by FLTK
MouseButton
Defines Mouse buttons
MouseWheel
Event direction with Mousewheel event
Option
global FLTK options
Scheme
Set the app scheme

Traits§

WidgetId
Allows setting a an id to a widget. Will not work with the single-threaded feature.

Functions§

abi_version
Gets FLTK ABI version
add_check
Add a check callback to run within the event loop. This function returns a handle that can be used for future interaction with the callback.
add_clipboard_notify
Register a callback whenever there is a change to the selection buffer or the clipboard. The clipboard is source 1 and the selection buffer is source 0
add_clipboard_notify2Deprecated
Register a callback whenever there is a change to the selection buffer or the clipboard. The clipboard is source 1 and the selection buffer is source 0. A callback via closure cannot be removed!
add_clipboard_notify3
Register a callback whenever there is a change to the selection buffer or the clipboard. The clipboard is source 1 and the selection buffer is source 0. A callback via closure cannot be removed!
add_handler
Adds a custom handler for unhandled events
add_idleDeprecated
Add an idle callback to run within the event loop. Calls to WidgetExt::redraw within the callback require an explicit sleep
add_idle2
Add an idle callback to run within the event loop. Calls to WidgetExt::redraw within the callback require an explicit sleep
add_idle3
Add an idle callback to run within the event loop. This function returns a handle that can be used for future interaction with the callback. Calls to WidgetExt::redraw within the callback require an explicit sleep
add_symbol
Add a new symbol, that can be accessed using the @ prefix
add_system_handler
Add a system handler
add_timeoutDeprecated
Adds a one-shot timeout callback. The timeout duration tm is indicated in seconds Example:
add_timeout2
Adds a one-shot timeout callback. The timeout duration tm is indicated in seconds Example:
add_timeout3
Adds a one-shot timeout callback. The timeout duration tm is indicated in seconds This function returns a handle that can be use for future interaction with the timeout Example:
api_version
Gets FLTK API version
awake
Trigger event loop handling in the main thread
awake_callback
Registers a function that will be called by the main thread during the next message handling cycle
background
Set the background color
background2
Set the background color for input and text widgets
belowmouse
Gets the widget that is below the mouse cursor. This returns an Option<impl WidgetExt> which can be specified in the function call
cairo_gc
Get the graphics context, fl_gc
callback_reason
Get the callback reason
channel
Creates a channel returning a Sender and Receiver structs (mpsc: multiple producer single consumer).
check
Calling this during a big calculation will keep the screen up to date and the interface responsive.
clipboard_contains
Check the contents of the clipboard
close_display
Close the current display
compose
Text editing widget should call this for each FL_KEYBOARD event.
compose_reset
Reset the length of bytes of app::compose()
compose_state
Return the length of bytes written in app::compose()
contrast_level
Get the contrast level
contrast_mode
Get the contrast mode
copy
Copy text to the clipboard
copy2
Copy text to the selection buffer
crate_version
Gets FLTK crate version
damage
Returns whether any of the widgets were damaged
delete_widget
Deletes widgets and their children.
disable_wayland
Disables wayland when building with use-wayland. Needs to be called before showing the first window
display
Gets the display global variable, fl_display. _XDisplay on X11, HINSTANCE on Windows.
dnd
Initiate dnd action
draw_frame_active
Determines if the currently drawn box is active or inactive
enable_locks
Enable locks. This is called automatically in the beginning of the app initialization
event
Returns the latest captured event
event_button
Returns the captured button event. 1 for left key, 2 for middle, 3 for right
event_clicks
Returns false for a single click and true for more
event_clicks_num
Returns the number of clicks - 1
event_clipboard
Get the clipboard content type
event_clipboard_image
Get the clipboard content if it’s an image
event_coords
Returns the x and y coordinates of the captured event
event_dispatch
The event dispatch function is called after native events are converted to FLTK events, but before they are handled by FLTK. If the dispatch function handler is set, it is up to the dispatch function to call app::handle_raw(Event, WindowPtr) or to ignore the event.
event_dx
Returns the current horizontal mouse scrolling associated with the Mousewheel event. Returns MouseWheel::None, Right or Left
event_dx_value
Returns the current horizontal mouse scrolling value associated with the Mousewheel event. Right is positive
event_dy
Returns the current vertical mouse scrolling associated with the Mousewheel event. Returns MouseWheel::None, Up or Down.
event_dy_value
Returns the current vertical mouse scrolling value associated with the Mousewheel event. Down is positive
event_inside
Returns whether an event occurred within a region
event_inside_widget
Returns whether an event occurred within a widget
event_is_click
Determines whether an event was a click
event_key
Returns the pressed key
event_key_down
Returns whether the key is pressed or held down during the last event
event_length
Returns the duration of an event
event_mouse_button
Returns the captured button event
event_original_key
Returns the original key
event_state
Returns the state of the event
event_text
Returns a textual representation of the latest event
event_x
Gets the x coordinate of the mouse in the window
event_x_root
Gets the x coordinate of the mouse in the screen
event_y
Gets the y coordinate of the mouse in the window
event_y_root
Gets the y coordinate of the mouse in the screen
first_window
Returns the first window of the application
flush
Causes all the windows that need it to be redrawn and graphics forced out through the pipes.
focus
Gets the widget which has focus
font_count
Gets the number of loaded fonts
font_index
Finds the index of a font through its name
font_name
Gets the name of a font through its index
font_size
Get the app’s font size
fonts
Gets a Vector<String> of loaded fonts, unless get_font_names() or load_system_fonts() is called, this will return a Vec with a String representation of the default Fonts shipped by FLTK, which is the same as the enums::Font.
foreground
Set the foreground color
frame_border_radius_max
Get the max border radius for frame types
frame_color
Fl::box_color. Gets the current frame color within box/frame drawing mode
frame_shadow_width
Get the shadow width for frames types with shadows
frame_type
Get the app’s frame type
get_font
Get the font’s name
get_font_name
Get the font’s name
get_font_names
Returns a list of fonts made available by the OS to the application.
get_font_sizes
Get a font’s sizes
get_mouse
Gets the mouse coordinates relative to the screen
get_system_colors
Gets the system colors
grab
Get the grabbed window
graphics_context
Get the graphics context, fl_gc
handle
Send a signal to a window. Integral values from 0 to 30 are reserved. Returns Ok(true) if the event was handled. Returns Ok(false) if the event was not handled. Returns Err on error or in use of one of the reserved values.
handle_main
Send a signal to the main window. Integral values from 0 to 30 are reserved. Returns Ok(true) if the event was handled. Returns Ok(false) if the event was not handled.
handle_raw
Send a signal to a window pointer from event_dispatch. Returns true if the event was handled. Returns false if the event was not handled or ignored.
has_check
Checks whether the check function, associated with the handle, is installed
has_idleDeprecated
Checks whether an idle function is installed
has_idle2
Checks whether an idle function is installed
has_idle3
Checks whether the idle function, associated with the handle, is installed
has_timeoutDeprecated
Check whether a timeout is installed
has_timeout2
Check whether a timeout is installed
has_timeout3
Check whether the timeout, associated with the handle, is installed
init_all
Inits all styles, fonts and images available to FLTK. Also initializes global locking
is_event_alt
Returns whether the event is a alt key press
is_event_command
Returns whether the event is a command key press
is_event_ctrl
Returns whether the event is a control key press
is_event_shift
Returns whether the event is a shift press
is_initialized
Check if fltk-rs was initialized
keyboard_screen_scaling
Controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/
lock
Locks the main UI thread
menu_linespacing
Get the default menu line-spacing
modal
Returns the last modal window of the application
next_window
Returns the next window in order
open_display
Open the current display
option
Get the option’s value
own_colormap
Makes FLTK use its own colormap. This may make FLTK display better
paste
Pastes content from the clipboard
paste_image
Pastes image content from the clipboard
paste_image2
Pastes image content from the selection buffer
paste_text
Pastes textual content from the clipboard
paste_text2
Pastes textual content from the selection buffer
program_should_quit
Determines whether a program should quit
pushed
Gets the widget which was pushed
quit
Quit the app
ready
This is similar to app::check() except this does not call app::flush() or any callbacks, which is useful if your program is in a state where such callbacks are illegal.
redraw
Redraws everything
releaseDeprecated
Unset the currently grabbed window
reload_scheme
Reload the app scheme
remove_check
Remove the check function associated with the handle
remove_clipboard_notify
Stop calling the specified callback when there are changes to the selection buffer or the clipboard. The clipboard is source 1 and the selection buffer is source 0
remove_clipboard_notify3
Stop calling the specified callback when there are changes to the selection buffer or the clipboard. The clipboard is source 1 and the selection buffer is source 0
remove_idleDeprecated
Remove an idle function
remove_idle2
Remove an idle function
remove_idle3
Remove the idle function associated with the handle
remove_system_handler
Add a system handler
remove_timeoutDeprecated
Removes a timeout callback
remove_timeout2
Removes a timeout callback
remove_timeout3
Removes the timeout callback associated with the handle
repeat_timeoutDeprecated
Repeats a timeout callback from the expiration of the previous timeout. You may only call this method inside a timeout callback. The timeout duration tm is indicated in seconds Example:
repeat_timeout2
Repeats a timeout callback from the expiration of the previous timeout. You may only call this method inside a timeout callback. The timeout duration tm is indicated in seconds Example:
repeat_timeout3
Repeats the timeout callback, associated with the hadle, from the expiration of the previous timeout. You may only call this method inside a timeout callback. The timeout duration tm is indicated in seconds Example:
run
Runs the event loop
scheme
Gets the scheme of the application
screen_coords
Returns a pair of the x & y coords of the screen
screen_count
Returns the screen count
screen_dpi
Returns a screen’s (vertical, horizontal) dpi resolution
screen_num
Returns the screen number of a screen that contains the specified position
screen_num_inside
Returns the screen number for the screen which intersects the most with the provided rectangle
screen_scale
Returns the screen scale
screen_scaling_supported
Returns whether scaling the screen is supported
screen_size
Returns a pair of the width and height of the screen
screen_work_area
Get a screen’s working area
screen_xywh
Get a screen’s xywh
scrollbar_size
Get the app’s scrollbar size
set_background2_color
Set the background color for input and text widgets
set_background_color
Set the background color
set_belowmouse
Sets the widget that’s below the mouse
set_callback
Sets the callback of a widget
set_color
Swap a color with a custom RGB value
set_contrast_function
Set the contrast function, for use in set_contrast_mode(ContrastMode::Custom)
set_contrast_level
Set the contrast level
set_contrast_mode
Set the contrast mode
set_damage
Sets the damage to true or false, eliciting a redraw by the application
set_focus
Sets the widget which has focus at the start of the application
set_font
Set the app’s font
set_font_size
Set the app’s font size
set_fonts
Initializes loaded fonts of a certain pattern name Returns the number of fonts found. For safety purposes, the name can be queried using get_font_name(unsafe { transmute(index) })
set_foreground_color
Set the foreground color
set_frame_border_radius_max
Set the max border radius for frame types
set_frame_color
Fl::set_box_color. Sets the current frame color within box/frame drawing mode
set_frame_shadow_width
Set the shadow width for frames types with shadows
set_frame_type
Set the app’s default frame type
set_frame_type2
Set the app’s default frame type without storing the old type
set_frame_type_cb
Set the app’s default frame type
set_grab
Set the current grab
set_inactive_color
Sets the app’s default selection color
set_menu_linespacing
Set the menu line-spacing
set_option
Set the option’s value
set_raw_callback
Set a widget callback using a C style API
set_scheme
sets the scheme of the application
set_screen_scale
Sets the screen scale
set_scrollbar_size
Set the application’s scrollbar size
set_selection_color
Sets the app’s default selection color
set_visible_focus
Show focus around widgets
set_visual
Sets the visual mode of the application
should_program_quit
Returns whether a quit signal was sent
sleep
Put the thread to sleep for dur seconds
swap_frame_type
Swap the default frame type with a new frame type
unlock
Unlocks the main UI thread
version
Gets FLTK version
version_str
Gets FLTK version string
visible_focus
Return whether visible focus is shown
wait
Starts waiting for events. Calls to redraw within wait require an explicit sleep
wait_for
Waits a maximum of dur seconds or until “something happens”. Returns true if an event happened (always true on windows). Returns false if nothing happened.
widget_from_id
Get back the widget thru its id
windows
Returns the apps windows.

Type Aliases§

AppScheme
Alias Scheme to AppScheme
CheckHandle
Handle object for interacting with check callbacks
Display
The display global variable, fl_display. _XDisplay on X11, HINSTANCE on Windows.
GraphicsContext
The current graphics context of the app, fl_gc. *mut c_void to HDC on Windows, CGContextRef on macOS, _XGC on X11
IdleHandle
Handle object for interacting with idle callbacks
TimeoutHandle
Handle object for interacting with timeouts
WidgetPtr
Alias Widget ptr
WindowPtr
Alias Window ptr