xtd 0.2.0
Loading...
Searching...
No Matches
message_notifier.h
1#pragma once
3#include "component.h"
4#include "iwin32_window.h"
5#include "message_notifier_button.h"
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
22 public:
23 //...
25
27 return button_;
28 }
29
30 private:
32 //...
33 };
34
35 using notifier_button_click_event_handler = delegate<void(object& sender, const notifier_button_click_event_args& e)>;
36
37
38 // TODO: IMPL + move to seperate file
40 public:
41 explicit notifier_closed_event_args(const std::optional<xtd::forms::message_notifier_button>& button) : button_(button) {}
42
43 std::optional<xtd::forms::message_notifier_button> button() const noexcept {
44 return button_;
45 }
46
47 bool close_on_timeout() const noexcept {
48 return close_on_timeout_;
49 }
50
51 bool close_on_click_message() const noexcept {
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 = delegate<void(object& sender, const notifier_closed_event_args& e)>;
63
64
66 public:
69
70 message_notifier() = default;
71
73
74 const message_notifier_button_collection& buttons() const noexcept { return buttons_; }
75 message_notifier_button_collection& buttons() noexcept { return buttons_; }
76
77 std::optional<xtd::forms::message_notifier_button> notifier_button_clicked() const noexcept { return notifier_button_clicked_; }
78
79 xtd::string title() const noexcept { return title_; }
80 message_notifier& title(const xtd::string& title) noexcept { title_ = title; return *this; }
81
82 xtd::string message() const noexcept { return message_; }
83 message_notifier& message(const xtd::string& message) noexcept { message_ = message; return *this; }
84
85 const xtd::drawing::image& icon() const noexcept { return icon_; }
86 message_notifier& icon(const xtd::drawing::image& icon) noexcept { icon_ = icon; return *this; }
87 message_notifier& icon(const xtd::drawing::icon& icon) noexcept { icon_ = icon.to_bitmap(); return *this; }
88
89 bool close_timeout_enabled() const noexcept { return close_timeout_enabled_; }
90 message_notifier& close_timeout_enabled(bool value) noexcept { close_timeout_enabled_ = value; return *this; }
91
92 std::chrono::milliseconds close_timeout_interval() const noexcept { return close_timeout_interval_; }
93 message_notifier& close_timeout_interval(std::chrono::milliseconds value) noexcept { close_timeout_interval_ = value; return *this;}
94 message_notifier& close_timeout_interval_milliseconds(int32 value) noexcept { close_timeout_interval_ = std::chrono::milliseconds(value); return *this; }
95
96 xtd::forms::notifier_appearance notifier_appearance() const noexcept {return notifier_appearance_; }
97 message_notifier& notifier_appearance(xtd::forms::notifier_appearance notifier_appearance) noexcept { notifier_appearance_ = notifier_appearance; return *this; }
98
99 void reset();
100
101 void show();
102 void show(const iwin32_window& owner);
103
104 event<message_notifier, xtd::forms::notifier_closed_event_handler> notifier_closed;
105 event<message_notifier, xtd::forms::notifier_button_click_event_handler> button_click;
106
107 protected:
108 virtual void on_notifier_closed(const xtd::forms::notifier_closed_event_args& e) {
109 notifier_closed(*this, e);
110 }
111 virtual void on_button_click(const xtd::forms::notifier_button_click_event_args& e) {
112 button_click(*this, e);
113 }
114
115 private:
116 xtd::string title_;
117 xtd::string message_;
119 bool close_timeout_enabled_ = false;
120 std::chrono::milliseconds close_timeout_interval_ = std::chrono::milliseconds(10'000);
121 message_notifier_button_collection buttons_;
122 std::optional<xtd::forms::message_notifier_button> notifier_button_clicked_ = std::nullopt;
124
125 };
126 }
127}
128
Contains xtd::forms::layout::arranged_element_collection collection.
Represents text as a sequence of character units.
Definition basic_string.h:79
Represents a Windows icon, which is a small bitmap image that is used to represent an object....
Definition icon.h:28
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:49
static image empty
Represent an empty xtd::drawing::image.
Definition image.h:65
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents a Windows button control.
Definition button.h:49
Provides a collection of button objects for use by a Windows Forms application.
Definition buttons.h:24
Provides the base implementation and enables object sharing between applications.
Definition component.h:25
Definition message_notifier_button.h:9
Definition message_notifier.h:65
const message_notifier_button_collection & buttons() const noexcept
Properties.
Definition message_notifier.h:74
Definition message_notifier.h:21
Definition message_notifier.h:39
Contains xtd::forms::component class.
#define forms_export_
Define shared library export.
Definition forms_export.h:13
@ show
Display the hot-key prefix.
control_appearance
Specifies the appearance of a control.
Definition control_appearance.h:21
control_appearance notifier_appearance
Specifies the appearance of a notifier.
Definition notifier_appearance.h:21
@ e
The E key.
@ standard
The appearance of the control is determined by current theme of xtd.
Contains xtd::forms::iwin32_window interface.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::forms::notifier_appearance enum class.