xtd 0.2.0
tool_bar_button.h
Go to the documentation of this file.
1 #pragma once
5 #include "component.h"
6 #include "const_control_ref.h"
7 #include "context_menu.h"
8 #include "control_ref.h"
9 #include "image_list.h"
10 #include "tool_bar_button_ref.h"
11 #include "tool_bar_button_style.h"
12 #include <xtd/event>
13 #include <xtd/event_handler>
14 #include <xtd/iequatable>
15 
17 namespace xtd {
19  namespace forms {
21  class control;
22  class tool_bar;
24 
40  class tool_bar_button : public xtd::forms::component, public xtd::iequatable<tool_bar_button> {
41  struct data;
42 
43  public:
45 
53  explicit tool_bar_button(const xtd::ustring& text);
55 
57  tool_bar_button(const tool_bar_button&) noexcept = default;
58  tool_bar_button(tool_bar_button&&) noexcept = default;
59  tool_bar_button& operator =(const tool_bar_button&) noexcept = default;
61 
63 
68  std::optional<xtd::forms::control_ref> control() const noexcept;
78  tool_bar_button& control(std::nullptr_t value);
79 
83  std::optional<std::reference_wrapper<xtd::forms::context_menu>> drop_down_menu() const noexcept;
93  tool_bar_button& drop_down_menu(std::nullptr_t value);
94 
98  bool enabled() const noexcept;
103  tool_bar_button& enabled(bool value);
104 
108  size_t image_index() const noexcept;
113  tool_bar_button& image_index(size_t value);
114 
118  const xtd::ustring& name() const noexcept;
123  tool_bar_button& name(const xtd::ustring& value);
124 
127  std::optional<std::reference_wrapper<xtd::forms::tool_bar>> parent() const noexcept;
128 
132  bool pushed() const noexcept;
137  tool_bar_button& pushed(bool value);
138 
142  const xtd::drawing::rectangle& rectangle() const noexcept;
143 
147  xtd::forms::tool_bar_button_style style() const noexcept;
153 
157  std::any tag() const noexcept;
162  tool_bar_button& tag(std::any value);
163 
167  const xtd::ustring& text() const noexcept;
172  tool_bar_button& text(const xtd::ustring& value);
173 
177  const xtd::ustring& tool_tip_text() const noexcept;
183 
187  bool visible() const noexcept;
192  tool_bar_button& visible(bool value);
194 
196 
202  static tool_bar_button create_control(const xtd::ustring& text, const xtd::forms::control& control);
206  static tool_bar_button create_control(const xtd::forms::control& control);
207 
212  static tool_bar_button create_drop_down_button(const xtd::ustring& text, const xtd::forms::context_menu& drop_down_menu);
217  static tool_bar_button create_drop_down_button(size_t image_index, const xtd::forms::context_menu& drop_down_menu);
223  static tool_bar_button create_drop_down_button(const xtd::ustring& text, size_t image_index, const xtd::forms::context_menu& drop_down_menu);
224 
228  static tool_bar_button create_push_button(const xtd::ustring& text);
232  static tool_bar_button create_push_button(size_t image_index);
237  static tool_bar_button create_push_button(const xtd::ustring& text, size_t image_index);
238 
242 
246 
254  static tool_bar_button create_toggle_button(size_t image_index);
259  static tool_bar_button create_toggle_button(const xtd::ustring& text, size_t image_index);
260 
261  bool equals(const tool_bar_button& other) const noexcept override;
262 
266  xtd::ustring to_string() const noexcept override;
267 
268  private:
269  friend xtd::forms::tool_bar;
270  std::shared_ptr<data> data_;
271  };
272  }
273 }
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.h:23
static tool_bar_button create_separator()
A factory to create a toolbar separator.
std::any tag() const noexcept
Gets the object that contains data about the toolbar button.
static tool_bar_button create_toggle_button(const xtd::ustring &text)
A factory to create a toolbar toggle button with specified text.
static tool_bar_button create_stretchable_separator()
A factory to create a toolbar stretchable separator.
Represents a toolbar button.
Definition: tool_bar_button.h:40
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
bool pushed() const noexcept
Gets a value indicating whether a toggle-style toolbar button is currently in the pushed state...
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
static tool_bar_button create_control(const xtd::ustring &text, const xtd::forms::control &control)
A factory to create a control toolbar button with specified text and control.
Contains xtd::forms::control_ref typedef.
Contains xtd::forms::tool_bar_button_ref alias.
xtd::ustring to_string() const noexcept override
Returns a string that represents the xtd::forms::tool_bar_button control.
tool_bar_button()
Initialises a new instance of xtd::forms::tool_bar_button class.
const xtd::ustring & name() const noexcept
Gets the name of the button.
std::optional< std::reference_wrapper< xtd::forms::tool_bar > > parent() const noexcept
Gets the toolbar control that the toolbar button is assigned to.
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.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Contains xtd::forms::image_list component.
tool_bar_button_style
Specifies the button style within a toolbar.
Definition: tool_bar_button_style.h:21
xtd::forms::tool_bar_button_style style() const noexcept
Gets the style of the toolbar button.
const xtd::ustring & tool_tip_text() const noexcept
Gets the text that appears as a xtd::forms::tool_tip for the button.
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:44
The operating system is other.
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
bool enabled() const noexcept
Gets a value indicating whether the button is enabled.
Contains xtd::forms::context_menu menu.
std::optional< xtd::forms::control_ref > control() const noexcept
Gets the control to be displayed in the control toolbar button.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
Contains xtd::forms::const_control_ref typedef.
static tool_bar_button create_drop_down_button(const xtd::ustring &text, const xtd::forms::context_menu &drop_down_menu)
A factory to create a drop-down toolbar button with specified text and context menu.
const xtd::drawing::rectangle & rectangle() const noexcept
Gets the bounding rectangle for a toolbar button.
size_t image_index() const noexcept
Gets the index value of the image assigned to the button.
Represents a shortcut menu.
Definition: context_menu.h:33
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Contains xtd::forms::component class.
Contains xtd::forms::tool_bar_button_style enum class.
bool visible() const noexcept
Gets a value indicating whether the toolbar button is visible.
const xtd::ustring & text() const noexcept
Gets the text displayed on the toolbar button.
static tool_bar_button create_push_button(const xtd::ustring &text)
A factory to create a toolbar button with specified text.
Provides the base implementation and enables object sharing between applications. ...
Definition: component.h:23
The left or right CTRL modifier key.