fluent-tray
Fluent Design-based GUI Library for System Tray Applications
|
Class with information on each menu. More...
#include <fluent_tray.hpp>
Public Member Functions | |
FluentMenu (bool toggleable=false, const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;}) | |
Create menu object. | |
FluentMenu (const FluentMenu &)=default | |
FluentMenu & | operator= (const FluentMenu &)=default |
FluentMenu (FluentMenu &&)=default | |
FluentMenu & | operator= (FluentMenu &&)=default |
~FluentMenu () noexcept | |
bool | create_menu (HINSTANCE hinstance, HWND parent_hwnd, std::size_t id, const std::string &label_text="", const std::string &icon_path="", const std::string &checkmark="✓") |
Creates a menu window. | |
bool | process_click_event () |
Execute the process when clicked on the menu. | |
void | check () noexcept |
Checks the menu if it is toggleable. | |
void | uncheck () noexcept |
Unchecks the menu if it is toggleable. | |
bool | is_checked () const noexcept |
Refer to the check status of the menu. | |
bool | is_toggleable () const noexcept |
Check if the menu is toggleable. | |
HWND | window_handle () const noexcept |
Refer to the menu window handle. | |
HMENU | menu_handle () const noexcept |
Refer to the menu handle. | |
std::size_t | id () const noexcept |
Refer to the menu identifier. | |
bool | get_label (std::string &str) const |
Get menu label as UTF-8 string. | |
void | show_separator_line () noexcept |
Show a separator line under the menu. | |
void | hide_separator_line () noexcept |
Hide a separator line under the menu. | |
bool | set_color (const COLORREF &text_color=CLR_INVALID, const COLORREF &back_color=CLR_INVALID, const COLORREF &border_color=CLR_INVALID) noexcept |
Set the menu color. | |
bool | draw_menu (LPDRAWITEMSTRUCT info, HFONT font) const |
Draws a menu using drawing information and the specified font. | |
HBRUSH | background_brush () const noexcept |
Refer to the brush for drawing the background. | |
bool | calculate_required_dims (HFONT font, SIZE &size) const |
Calculates the size of the bounding box surrounding the menu based on the font information and the length of the label. | |
Class with information on each menu.
|
inlineexplicit |
Create menu object.
[in] | toggleable | Create a switchable menu |
[in] | callback | Function called when a click on the menu or a check is enabled. |
[in] | unchecked_callback | Function called when a check is disabled. |
The callback function must be a function with a bool return value and no arguments. The tray will exit successfully if the callback function returns false.
|
default |
|
default |
|
inlinenoexcept |
|
inlinenoexcept |
Refer to the brush for drawing the background.
Used for the return value of WM_CTLCOLORBTN message.
|
inline |
Calculates the size of the bounding box surrounding the menu based on the font information and the length of the label.
[in] | font | The handle of font. |
[out] | size | The output width and height dimensions. |
|
inlinenoexcept |
Checks the menu if it is toggleable.
Update only the current state without calling the callback function.
|
inline |
Creates a menu window.
[in] | hinstance | An instance handle of application. |
[in] | parent_hwnd | A window handle of tray. |
[in] | id | A new unique identifier. |
[in] | label_text | A label text. |
[in] | icon_path | An icon path to show next to the label. |
[in] | checkmark | A checkmark string. |
|
inline |
Draws a menu using drawing information and the specified font.
[in] | info | Structure that holds drawing information. |
[in] | font | The handle of font. |
info is the DRAWITEMSTRUCT obtained when the owner window receives a WM_DRAWITEM message.
|
inline |
Get menu label as UTF-8 string.
[out] | str | The output string. |
|
inlinenoexcept |
Hide a separator line under the menu.
|
inlinenoexcept |
Refer to the menu identifier.
|
inlinenoexcept |
Refer to the check status of the menu.
|
inlinenoexcept |
Check if the menu is toggleable.
|
inlinenoexcept |
Refer to the menu handle.
|
default |
|
default |
|
inline |
Execute the process when clicked on the menu.
|
inlinenoexcept |
Set the menu color.
[in] | text_color | The color for label text. |
[in] | back_color | The color for background. |
[in] | border_color | The color for separator line. |
If the set value is CLR_INVALID, the value is not changed.
|
inlinenoexcept |
Show a separator line under the menu.
|
inlinenoexcept |
Unchecks the menu if it is toggleable.
Update only the current state without calling the callback function.
|
inlinenoexcept |
Refer to the menu window handle.