lecui 1.0.0-alpha.20
lecui C++ user interface library
tray_icon.h
1//
2// tray_icon.h - tray icon interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "../form.h"
15#else
16#include <liblec/lecui/form.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
24 std::string label;
25
27 std::function<void()> action = nullptr;
28
30 std::vector<tray_menu_item> children;
31
33 std::string image_file;
34
36 std::string font = "Segoe UI";
37
39 float font_size = 9.f;
40 };
41
45 class lecui_api tray_icon {
46 public:
50 ~tray_icon();
51
62 bool add(int png_resource,
63 const std::string& title,
64 const std::vector<tray_menu_item>& items,
65 const std::string& default_item,
66 std::string& error);
67
74 bool change(int png_resource,
75 const std::string& title,
76 std::string& error);
77
81 void remove();
82
83 private:
84 class impl;
85 impl& _d;
86
87 // Default constructor and copying an object of this class are not allowed
88 tray_icon() = delete;
89 tray_icon(const tray_icon&) = delete;
90 tray_icon& operator=(const tray_icon&) = delete;
91 };
92 }
93}
Form base class. The user must inherit from this class and call one of the two constructors from its ...
Definition: form.h:122
Tray icon class.
Definition: tray_icon.h:45
bool add(int png_resource, const std::string &title, const std::vector< tray_menu_item > &items, const std::string &default_item, std::string &error)
Add the system tray icon.
tray_icon(form &fm)
Constructor.
void remove()
Remove the tray icon.
bool change(int png_resource, const std::string &title, std::string &error)
Change the tray icon.
Top level namespace for the liblec libraries.
Definition: appearance.h:19
Menu items.
Definition: tray_icon.h:22
std::string image_file
The image to use for the menu item (placed on the right).
Definition: tray_icon.h:33
std::string font
The font to use.
Definition: tray_icon.h:36
std::string label
The label text of the menu item.
Definition: tray_icon.h:24
std::vector< tray_menu_item > children
The children of the menu item (used to make a tree).
Definition: tray_icon.h:30
std::function< void()> action
The action handler.
Definition: tray_icon.h:27
float font_size
The font size.
Definition: tray_icon.h:39