xtd 0.2.0
link_label.h
Go to the documentation of this file.
1 #pragma once
5 #include "cursors.h"
6 #include "label.h"
7 #include "link.h"
8 #include "link_area.h"
9 #include "link_behavior.h"
11 #include <xtd/drawing/system_colors>
12 #include <xtd/any>
13 #include <tuple>
14 
16 namespace xtd {
18  namespace forms {
41  class link_label : public label {
42  struct data;
43 
44  public:
46 
53 
55  class link_collection : public xtd::forms::layout::arranged_element_collection<xtd::forms::link_label::link> {
56  public:
58 
63 
65 
70  explicit link_collection(const allocator_type& allocator = allocator_type());
72 
74  explicit link_collection(const base& collection);
75  link_collection(const link_collection& collection);
76  link_collection& operator =(const link_collection& collection);
77  link_collection(link_collection&&) = default;
79 
81 
83  using base::operator [];
88  const_reference operator [](const xtd::ustring& name) const noexcept;
93  reference operator [](const xtd::ustring& name) noexcept;
95  };
96 
98 
101  link_label();
103 
105 
112  xtd::drawing::color active_link_color() const noexcept;
119  link_label& active_link_color(const xtd::drawing::color& color);
120 
125  xtd::drawing::color disabled_link_color() const noexcept;
131  link_label& disabled_link_color(const xtd::drawing::color& color);
132 
133  xtd::forms::link_area link_area() const noexcept;
135 
136  xtd::forms::link_behavior link_behavior() const noexcept;
138 
139  xtd::drawing::color link_color() const noexcept;
140  link_label& link_color(const xtd::drawing::color& color);
141 
142  const link_collection& links() const noexcept;
143  link_collection& links();
144 
145  xtd::forms::cursor override_cursor() const noexcept;
146  link_label& override_cursor(const xtd::forms::cursor& cursor);
147 
148  xtd::drawing::color visited_link_color() const noexcept;
149  link_label& visited_link_color(const xtd::drawing::color& color);
151 
153 
155  using control::create;
162  static link_label create(const xtd::ustring& text, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
170  static link_label create(const control& parent, const xtd::ustring& text, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
172 
174 
181 
182  protected:
184 
186  xtd::drawing::size measure_control() const noexcept override;
187  void on_cursor_changed(const xtd::event_args& e) override;
188  void on_mouse_click(const xtd::forms::mouse_event_args& e) override;
189  void on_mouse_down(const xtd::forms::mouse_event_args& e) override;
190  void on_mouse_up(const xtd::forms::mouse_event_args& e) override;
191  void on_mouse_move(const xtd::forms::mouse_event_args& e) override;
192  void on_paint(xtd::forms::paint_event_args& e) override;
193  void on_text_align_changed(const xtd::event_args& e) override;
194  void on_text_changed(const xtd::event_args& e) override;
195 
198  link_label::link& point_in_link(const xtd::drawing::point& point);
200 
201  private:
202  xtd::drawing::point get_text_location(size_t line) const noexcept;
203  std::vector<std::tuple<xtd::drawing::rectangle, bool>> generate_text_rects() const noexcept;
204  xtd::drawing::font link_font() const noexcept;
205 
206  std::shared_ptr<data> data_;
207  };
208  }
209 }
210 
Contains xtd::forms::cursors factory.
const value_type & const_reference
Represents the value type const reference the collection.
Definition: arranged_element_collection.h:76
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
pointer data()
Direct access to the underlying array.
Definition: arranged_element_collection.h:165
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Represents a standard Windows label.
Definition: label.h:36
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
value_type & reference
Represents the value type reference of the collection.
Definition: arranged_element_collection.h:74
virtual drawing::font font() const noexcept
Gets the font of the text displayed by the control.
virtual const xtd::ustring & name() const noexcept
Gets the name of the control.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Represents the image used to paint the mouse pointer.
Definition: cursor.h:38
Represents a collection of objects.
Definition: arranged_element_collection.h:31
link_behavior
Specifies the behaviors of a link in a xtd::forms::link_label.
Definition: link_behavior.h:20
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:45
Represents an event.
Definition: event.h:21
Provides data for the xtd::forms::control::paint event.
Definition: paint_event_args.h:28
virtual drawing::point location() const noexcept
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
virtual const xtd::ustring & text() const noexcept
Gets the text associated with this control.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
std::allocator< value_type > allocator_type
Represents the allocator type of the collection.
Definition: arranged_element_collection.h:68
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down, and xtd::forms::control::mouse_move events.
Definition: mouse_event_args.h:32
Contains xtd::forms::label control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
size_t size
Represents a size of any object in bytes.
Definition: types.h:195