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
- Global
State - Represents global state
- Receiver
- Creates a receiver struct
- Screen
- An available screen
- Sender
- Creates a sender struct
Enums§
- Clipboard
Content - Types of Clipboard contents
- Clipboard
Event - The event clipboard type
- Contrast
Mode - Contrast modes supported by FLTK
- Mouse
Button - Defines Mouse buttons
- Mouse
Wheel - Event direction with Mousewheel event
- Option
- global FLTK options
- Scheme
- Set the app scheme
Traits§
- Widget
Id - 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_ notify2 Deprecated - 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_
idle Deprecated - 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_
timeout Deprecated - 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
orLeft
- 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
orDown
. - 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 theenums::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_
idle Deprecated - 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_
timeout Deprecated - 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
- release
Deprecated - 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_
idle Deprecated - 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_
timeout Deprecated - Removes a timeout callback
- remove_
timeout2 - Removes a timeout callback
- remove_
timeout3 - Removes the timeout callback associated with the handle
- repeat_
timeout Deprecated - 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 usingget_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
- Check
Handle - Handle object for interacting with check callbacks
- Display
- The display global variable,
fl_display
._XDisplay
on X11,HINSTANCE
on Windows. - Graphics
Context - The current graphics context of the app,
fl_gc
.*mut c_void
toHDC
on Windows,CGContextRef
on macOS,_XGC
on X11 - Idle
Handle - Handle object for interacting with idle callbacks
- Timeout
Handle - Handle object for interacting with timeouts
- Widget
Ptr - Alias Widget ptr
- Window
Ptr - Alias Window ptr