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
Represents text as a sequence of character units.
Definition basic_string.hpp:71
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
Represents a toolbar button.
Definition tool_bar_button.hpp:43
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.
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
The xtd::shared_ptr_object is a shared pointer as std::shared_ptr.
Definition shared_ptr_object.hpp:30
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::forms::style_sheets::control tool_bar
The tool_bar data allows you to specify the box of a tool_bar control.
Definition tool_bar.hpp:25
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:175
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ other
The operating system is other.
@ control
The left or right CTRL modifier key.
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
Contains xtd::forms::image_list component.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::forms::tool_bar_button_ref alias.
Contains xtd::forms::tool_bar_button_style enum class.