xtd 0.2.0
tool_bar_button.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "component.hpp"
7#include "context_menu.hpp"
8#include "control_ref.hpp"
9#include "image_list.hpp"
12#include <xtd/event>
13#include <xtd/event_handler>
14#include <xtd/iclonable>
15#include <xtd/iequatable>
16
18namespace xtd {
20 namespace forms {
22 class control;
23 class tool_bar;
25
43 class tool_bar_button : public xtd::forms::component, public xtd::iclonable, public xtd::iequatable<tool_bar_button> {
44 struct data;
45
46 public:
48
58
60 tool_bar_button(const tool_bar_button&) noexcept = default;
61 tool_bar_button(tool_bar_button&&) noexcept = default;
62 tool_bar_button& operator =(const tool_bar_button&) noexcept = default;
64
66
71 std::optional<xtd::forms::control_ref> control() const noexcept;
81 tool_bar_button& control(std::nullptr_t value);
82
86 std::optional<std::reference_wrapper<xtd::forms::context_menu>> drop_down_menu() const noexcept;
96 tool_bar_button& drop_down_menu(std::nullptr_t value);
97
101 bool enabled() const noexcept;
107
111 size_t image_index() const noexcept;
117
121 const xtd::string& name() const noexcept;
126 tool_bar_button& name(const xtd::string& value);
127
130 std::optional<std::reference_wrapper<xtd::forms::tool_bar>> parent() const noexcept;
131
135 bool pushed() const noexcept;
141
145 const xtd::drawing::rectangle& rectangle() const noexcept;
146
156
160 const xtd::any_object& tag() const noexcept;
166
170 const xtd::string& text() const noexcept;
175 tool_bar_button& text(const xtd::string& value);
176
180 const xtd::string& tool_tip_text() const noexcept;
185 tool_bar_button& tool_tip_text(const xtd::string& value);
186
190 bool visible() const noexcept;
197
199
204 bool equals(const xtd::object& obj) const noexcept override;
208 bool equals(const tool_bar_button& other) const noexcept override;
209
212 xtd::size get_hash_code() const noexcept override;
213
217 xtd::string to_string() const noexcept override;
219
221
227 static tool_bar_button create_control(const xtd::string& text, const xtd::forms::control& control);
232
249
262 static tool_bar_button create_push_button(const xtd::string& text, size_t image_index);
263
267
271
286
287 protected:
289
295 xtd::uptr<xtd::object> clone() const override;
297
298 private:
299 friend xtd::forms::tool_bar;
300 xtd::sptr<data> data_;
301 };
302 }
303}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides the base implementation and enables object sharing between applications.
Definition component.hpp:26
Represents a shortcut menu.
Definition context_menu.hpp:36
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
static tool_bar_button create_stretchable_separator()
A factory to create a toolbar stretchable separator.
bool enabled() const noexcept
Gets a value indicating whether the button is enabled.
tool_bar_button()
Initialises a new instance of xtd::forms::tool_bar_button class.
tool_bar_button(const xtd::string &text)
Initializes a new instance of the xtd::forms::tool_bar_button class and displays the assigned text on...
xtd::string to_string() const noexcept override
Returns a string that represents the xtd::forms::tool_bar_button control.
static tool_bar_button create_push_button(const xtd::string &text)
A factory to create a toolbar button with specified text.
const xtd::string & text() const noexcept
Gets the text displayed on the toolbar button.
const xtd::any_object & tag() const noexcept
Gets the object that contains data about the toolbar button.
bool visible() const noexcept
Gets a value indicating whether the toolbar button is visible.
bool pushed() const noexcept
Gets a value indicating whether a toggle-style toolbar button is currently in the pushed state.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool equals(const xtd::object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
xtd::uptr< xtd::object > clone() const override
Creates a new object that is a copy of the current instance.
const xtd::string & name() const noexcept
Gets the name of the button.
static tool_bar_button create_separator()
A factory to create a toolbar separator.
static tool_bar_button create_control(const xtd::string &text, const xtd::forms::control &control)
A factory to create a control toolbar button with specified text and control.
static tool_bar_button create_drop_down_button(const xtd::string &text, const xtd::forms::context_menu &drop_down_menu)
A factory to create a drop-down toolbar button with specified text and context menu.
std::optional< xtd::forms::control_ref > control() const noexcept
Gets the control to be displayed in the control toolbar button.
xtd::forms::tool_bar_button_style style() const noexcept
Gets the style of the toolbar button.
std::optional< std::reference_wrapper< xtd::forms::context_menu > > drop_down_menu() const noexcept
Gets the menu to be displayed in the drop-down toolbar button.
size_t image_index() const noexcept
Gets the index value of the image assigned to the button.
const xtd::string & tool_tip_text() const noexcept
Gets the text that appears as a xtd::forms::tool_tip for the button.
const xtd::drawing::rectangle & rectangle() const noexcept
Gets the bounding rectangle for a toolbar button.
static tool_bar_button create_toggle_button(const xtd::string &text)
A factory to create a toolbar toggle button with specified text.
std::optional< std::reference_wrapper< xtd::forms::tool_bar > > parent() const noexcept
Gets the toolbar control that the toolbar button is assigned to.
Represents a Windows toolbar.
Definition tool_bar.hpp:52
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Contains xtd::forms::component class.
Contains xtd::forms::const_control_ref typedef.
Contains xtd::forms::context_menu menu.
Contains xtd::forms::control_ref typedef.
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:25
@ other
The operating system is other.
Definition platform_id.hpp:58
tool_bar_button_style
Specifies the button style within a toolbar.
Definition tool_bar_button_style.hpp:23
std::reference_wrapper< control > control_ref
Represents a control reference.
Definition control_ref.hpp:25
@ size
Specifies that both the width and height property values of the control are defined.
Definition bounds_specified.hpp:36
Contains xtd::forms::image_list component.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
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
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::forms::tool_bar_button_ref alias.
Contains xtd::forms::tool_bar_button_style enum class.