xtd 1.0.0
Loading...
Searching...
No Matches
message_notifier.hpp
1#pragma once
3#include "component.hpp"
4#include "iwin32_window.hpp"
5#include "message_notifier_button.hpp"
7#include <xtd/drawing/icon>
8#include <xtd/chrono>
9#include <xtd/delegate>
10#include <xtd/string>
11#include <xtd/event>
12#include <xtd/event_args>
13#include <xtd/not_implemented_exception>
14#include <xtd/optional>
15
17namespace xtd {
19 namespace forms {
20 // TODO: IMPL + move to seperate file
21 class notifier_button_click_event_args : public xtd::event_args {
22 public:
23 //...
24 explicit notifier_button_click_event_args(const message_notifier_button& button) : button_(button) {}
25
26 [[nodiscard]] auto button() const noexcept -> xtd::forms::message_notifier_button {
27 return button_;
28 }
29
30 private:
32 //...
33 };
34
35 using notifier_button_click_event_handler = xtd::delegate<void(xtd::object& sender, const xtd::forms::notifier_button_click_event_args& e)>;
36
37
38 // TODO: IMPL + move to seperate file
39 class notifier_closed_event_args : public xtd::event_args {
40 public:
41 explicit notifier_closed_event_args(const std::optional<xtd::forms::message_notifier_button>& button) : button_(button) {}
42
43 [[nodiscard]] auto button() const noexcept -> std::optional<xtd::forms::message_notifier_button> {
44 return button_;
45 }
46
47 [[nodiscard]] auto close_on_timeout() const noexcept -> bool {
48 return close_on_timeout_;
49 }
50
51 [[nodiscard]] auto close_on_click_message() const noexcept -> bool {
52 return close_on_click_message_;
53 }
54
55 private:
56 bool close_on_timeout_ = false;
57 bool close_on_click_message_ = false;
58 std::optional<xtd::forms::message_notifier_button> button_ = std::nullopt;
59 //...
60 };
61
62 using notifier_closed_event_handler = xtd::delegate<void(xtd::object& sender, const xtd::forms::notifier_closed_event_args& e)>;
63
64
65 class forms_export_ message_notifier final : public component {
66 public:
68
72
74
76 message_notifier() = default;
78
80
82 [[nodiscard]] auto buttons() const noexcept -> const message_notifier_button_collection& {return buttons_;}
83 [[nodiscard]] auto buttons() noexcept -> message_notifier_button_collection& {return buttons_;}
84
85 [[nodiscard]] auto close_timeout_enabled() const noexcept -> bool {return close_timeout_enabled_;}
86 auto close_timeout_enabled(bool value) noexcept -> message_notifier& {close_timeout_enabled_ = value; return *this;}
87
88 [[nodiscard]] auto close_timeout_interval() const noexcept -> std::chrono::milliseconds {return close_timeout_interval_;}
89 auto close_timeout_interval(std::chrono::milliseconds value) noexcept -> message_notifier& {close_timeout_interval_ = value; return *this;}
90 auto close_timeout_interval_milliseconds(xtd::int32 value) noexcept -> message_notifier& {close_timeout_interval_ = std::chrono::milliseconds(value); return *this;}
91
92 [[nodiscard]] auto icon() const noexcept -> const xtd::drawing::image& {return icon_;}
93 auto icon(const xtd::drawing::image& icon) noexcept -> message_notifier& {icon_ = icon; return *this;}
94 auto icon(const xtd::drawing::icon& value) noexcept -> message_notifier& {icon_ = value.to_bitmap(); return *this;}
95
96 [[nodiscard]] auto notifier_appearance() const noexcept -> xtd::forms::notifier_appearance {return notifier_appearance_;}
97 auto notifier_appearance(xtd::forms::notifier_appearance value) noexcept -> message_notifier& {notifier_appearance_ = value; return *this;}
98
99 [[nodiscard]] auto message() const noexcept -> const xtd::string& {return message_;}
100 auto message(const xtd::string& value) noexcept -> message_notifier& {message_ = value; return *this;}
101
102 [[nodiscard]] auto notifier_button_clicked() const noexcept -> std::optional<xtd::forms::message_notifier_button> {return notifier_button_clicked_;}
103
104 [[nodiscard]] auto title() const noexcept -> const xtd::string& {return title_;}
105 auto title(const xtd::string& value) noexcept -> message_notifier& {title_ = value; return *this;}
107
109
111 auto reset() -> void;
112
113 auto show() -> void;
114 auto show(const iwin32_window& owner) -> void;
116
118
123
124 protected:
126
128 auto on_notifier_closed(const xtd::forms::notifier_closed_event_args& e) -> void {notifier_closed(*this, e);}
129 auto on_button_click(const xtd::forms::notifier_button_click_event_args& e) -> void {button_click(*this, e);}
131
132 private:
133 xtd::string title_;
134 xtd::string message_;
136 bool close_timeout_enabled_ = false;
137 std::chrono::milliseconds close_timeout_interval_ = std::chrono::milliseconds(10'000);
138 message_notifier_button_collection buttons_;
139 std::optional<xtd::forms::message_notifier_button> notifier_button_clicked_ = std::nullopt;
140 xtd::forms::notifier_appearance notifier_appearance_ = xtd::forms::notifier_appearance::standard;
141 };
142 }
143}
144
Contains xtd::forms::layout::arranged_element_collection collection.
Represents a Windows icon, which is a small bitmap image that is used to represent an object....
Definition icon.hpp:28
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.hpp:49
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Represents an event.
Definition event.hpp:23
component()
Initialises a new instance of the component class.
Provides an interface to expose Win32 HWND handles.
Definition iwin32_window.hpp:23
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
Definition message_notifier_button.hpp:9
Definition message_notifier.hpp:21
Definition message_notifier.hpp:39
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains xtd::forms::component class.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
@ e
The E key.
Definition console_key.hpp:96
xtd::forms::control_appearance notifier_appearance
Specifies the appearance of a notifier.
Definition notifier_appearance.hpp:21
@ e
The E key.
Definition keys.hpp:207
Contains xtd::forms::iwin32_window interface.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::forms::notifier_appearance enum class.