xtd - Reference Guide 0.2.0
label.h
Go to the documentation of this file.
1 #pragma once
5 #include "control.h"
6 #include "border_sides.h"
7 #include "border_style.h"
8 #include "content_alignment.h"
9 #include "flat_style.h"
10 #include "image_list.h"
11 
13 namespace xtd {
15  namespace forms {
28  class forms_export_ label : public control {
29  public:
31 
34  label();
36 
38 
44  virtual bool auto_ellipsis() const noexcept {return data_->auto_ellipsis;};
50  virtual label& auto_ellipsis(bool value);
51 
54  virtual forms::border_sides border_sides() const noexcept {return data_->border_sides;}
58 
62  virtual xtd::forms::border_style border_style() const noexcept {return data_->border_style.value_or(xtd::forms::border_style::none);}
72  virtual xtd::forms::label& border_style(std::nullptr_t border_style);
73 
76 
80  virtual xtd::forms::flat_style flat_style() const noexcept {return data_->flat_style;}
86 
91  virtual const drawing::image& image() const {return data_->image;}
96  virtual xtd::forms::label& image(const drawing::image& value);
97 
100  virtual xtd::forms::content_alignment image_align() const noexcept {return data_->image_align;}
103  virtual xtd::forms::label& image_align(content_alignment value);
104 
110  virtual int32_t image_index() const noexcept {return data_->image_index;}
116  virtual xtd::forms::label& image_index(int32_t value);
117 
120  virtual const forms::image_list& image_list() const noexcept {return data_->image_list;}
123  virtual forms::image_list& image_list() {return data_->image_list;}
126  virtual xtd::forms::label& image_list(const forms::image_list& value);
127 
130  virtual bool shadow() const noexcept {return data_->shadow;}
133  virtual xtd::forms::label& shadow(bool value);
134 
138  virtual xtd::forms::content_alignment text_align() const noexcept {return data_->text_align;}
143  virtual xtd::forms::label& text_align(xtd::forms::content_alignment text_align);
145 
147 
158 
159  protected:
161 
163  xtd::forms::create_params create_params() const override;
164  xtd::drawing::size measure_control() const override;
165  void on_font_changed(const xtd::event_args& e) override;
166 
169  virtual void on_image_changed(const xtd::event_args& e) {
170  if (data_->flat_style != xtd::forms::flat_style::system) invalidate();
171  if (can_raise_events()) image_changed(*this, e);
172  }
173 
174  void on_paint(xtd::forms::paint_event_args& e) override;
175  void on_resize(const xtd::event_args& e) override;
176 
181  virtual void on_text_align_changed(const xtd::event_args& e);
182 
183  void on_text_changed(const xtd::event_args& e) override;
185 
186  private:
187  struct data {
188  bool auto_ellipsis = false;
190  std::optional<xtd::forms::border_style> border_style;
193  int32_t image_index = -1;
196  bool shadow = false;
198  };
199  std::shared_ptr<data> data_ = std::make_shared<data>();
200  };
201  }
202 }
virtual int32_t image_index() const noexcept
Gets the image list index value of the image displayed on the label control.
Definition: label.h:110
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition: label.h:21
virtual bool shadow() const noexcept
Gets a value that allows to draw a drop shadow under the text.
Definition: label.h:130
flat_style
Specifies the appearance of a control.
Definition: flat_style.h:20
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition: image_list.h:25
virtual forms::image_list & image_list()
Gets the image_list that contains the image displayed on a label control.
Definition: label.h:123
virtual const drawing::image & image() const
Gets the image that is displayed on a label control.
Definition: label.h:91
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 standard Windows label.
Definition: label.h:28
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual xtd::forms::content_alignment image_align() const noexcept
Gets the alignment of the image on the label control.
Definition: label.h:100
The appearance of the control is determined by current theme of xtd.
control_appearance
Specifies the appearance of a control.
Definition: control_appearance.h:17
virtual forms::border_sides border_sides() const noexcept
Gets the border sides for the control.
Definition: label.h:54
The appearance of the control is determined by the user&#39;s operating system.
virtual xtd::forms::border_style border_style() const noexcept
Gets the border style for the control.
Definition: label.h:62
event< label, event_handler > text_align_changed
Occurs when the value of the xtd::forms::label::text_align property has changed.
Definition: label.h:156
Represents an event.
Definition: event.h:21
Provides data for the paint event.
Definition: paint_event_args.h:27
virtual const forms::image_list & image_list() const noexcept
Gets the image_list that contains the image displayed on a label control.
Definition: label.h:120
Contains xtd::forms::image_list component.
content_alignment
Specifies alignment of content on the drawing surface.
Definition: content_alignment.h:17
virtual xtd::forms::flat_style flat_style() const noexcept
Gets the flat style appearance of the label control.
Definition: label.h:80
border_sides
Specifies how a control anchors to the edges of its container.
Definition: border_sides.h:19
virtual bool auto_ellipsis() const noexcept
Gets a value indicating whether the ellipsis character (...) appears at the right edge of the xtd::fo...
Definition: label.h:44
border_style
Specifies the border style for a control.
Definition: border_style.h:18
static image_list empty
Represents an image_list empty.
Definition: image_list.h:38
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:47
Contains xtd::forms::content_alignment enum class.
Contains xtd::forms::border_sides enum class.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:73
event< label, event_handler > image_changed
Occurs when the value of the image property changes.
Definition: label.h:153
Contains xtd::forms::flat_style enum class.
virtual forms::control_appearance control_appearance() const
Gets control appearance.
Content is vertically aligned at the top, and horizontally aligned on the left.
Contains xtd::forms::control control.
All flags except none.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Content is vertically aligned at the middle, and horizontally aligned at the center.
image_list()
Initialize a new instance ao image_list class.
Contains xtd::forms::border_style enum class.
virtual xtd::forms::content_alignment text_align() const noexcept
Gets the alignment of the text on the button control.
Definition: label.h:138
static image empty
Represent an empty xtd::drawing::image.
Definition: image.h:62
virtual void on_image_changed(const xtd::event_args &e)
Raises the button_base::image_changed event.
Definition: label.h:169