xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
theme_renderers.h
Go to the documentation of this file.
1 #pragma once
5 #include <xtd/delegate.h>
6 #include <xtd/drawing/image.h>
7 #include "renderer.h"
8 #include "theme_base.h"
9 
11 namespace xtd {
13  namespace forms {
14  class forms_export_ theme_renderers final : public theme_base {
15  public:
17 
19  using renderer_getter = xtd::delegate<xtd::forms::renderer()>;
21 
23 
25  static const theme_renderers empty;
27 
29 
31  theme_renderers() = default;
32  explicit theme_renderers(const xtd::ustring& name) : theme_base(name) {}
33  theme_renderers(const xtd::ustring& name, xtd::forms::theme_style theme_style, const renderer_getter& renderer_getter) : theme_base(name, theme_style), renderer_getter_(renderer_getter) {}
35 
37  theme_renderers(const theme_renderers&) = default;
38  theme_renderers& operator=(const theme_renderers&) = default;
39  bool operator==(const theme_renderers& value) const {return theme_base::operator==(value);}
40  bool operator!=(const theme_renderers& value) const {return !operator==(value);}
42 
44 
46  static xtd::drawing::size default_size() {return {32, 32};}
47 
48  static theme_renderers default_theme() {return theme_from_name(default_theme_name());}
49 
50  xtd::forms::renderer renderer() const {return renderer_getter_();}
51 
52  xtd::forms::renderer::button_renderer button_render() const {return renderer_getter_().button_render();}
53  void button_render(xtd::forms::renderer::button_renderer button_renderer) {renderer_getter_().button_render(button_renderer);}
54 
55  xtd::forms::renderer::check_box_renderer check_box_render() const {return renderer_getter_().check_box_render();}
56  void check_box_render(xtd::forms::renderer::check_box_renderer check_box_renderer) {renderer_getter_().check_box_render(check_box_renderer);}
57 
58  xtd::forms::renderer::radio_button_renderer radio_button_render() const {return renderer_getter_().radio_button_render();}
59  void radio_button_render(xtd::forms::renderer::radio_button_renderer radio_button_renderer) {renderer_getter_().radio_button_render(radio_button_renderer);}
61 
63 
65  void draw_button(xtd::drawing::graphics g, const xtd::drawing::rectangle& bounds, const xtd::ustring& text, const xtd::drawing::font& font, xtd::forms::text_format_flags flags, const xtd::drawing::image& image, const xtd::drawing::rectangle& image_bounds, bool focused, xtd::forms::visual_styles::push_button_state state, const std::optional<xtd::drawing::color>& back_color, const std::optional<xtd::drawing::color>& fore_color) {button_render()(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
66  void draw_check_box(xtd::drawing::graphics g, const xtd::drawing::rectangle& bounds, const xtd::ustring& text, const xtd::drawing::font& font, xtd::forms::text_format_flags flags, const xtd::drawing::image& image, const xtd::drawing::rectangle& image_bounds, bool focused, xtd::forms::visual_styles::check_box_state state, const std::optional<xtd::drawing::color>& back_color, const std::optional<xtd::drawing::color>& fore_color) {check_box_render()(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
67  void draw_radio_button(xtd::drawing::graphics g, const xtd::drawing::rectangle& bounds, const xtd::ustring& text, const xtd::drawing::font& font, xtd::forms::text_format_flags flags, const xtd::drawing::image& image, const xtd::drawing::rectangle& image_bounds, bool focused, xtd::forms::visual_styles::radio_button_state state, const std::optional<xtd::drawing::color>& back_color, const std::optional<xtd::drawing::color>& fore_color) {radio_button_render()(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
68 
69  static theme_renderers current_theme() {
70  if (current_theme_ == theme_renderers::empty) current_theme_ = default_theme();
71  return current_theme_;
72  }
73  static void current_theme(const theme_renderers& theme) {
74  current_theme_ = theme;
75  }
76  static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
77 
78  static theme_renderers theme_from_name(const xtd::ustring& theme_name);
80 
81  private:
82  theme_renderers(const xtd::ustring& name, xtd::forms::theme_style theme_style, const renderer_getter& renderer_getter, bool is_default) : theme_base(name, theme_style, is_default), renderer_getter_(renderer_getter) {}
83  renderer_getter renderer_getter_;
84  static theme_renderers current_theme_;
85  };
86  }
87 }
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
Definition: font.h:39
Contains xtd::delegate delegate.
radio_button_state
Specifies the visual state of a radio button that is drawn with visual styles.
Definition: radio_button_state.h:20
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Definition: theme.h:14
check_box_state
Specifies the visual state of a check box that is drawn with visual styles.
Definition: check_box_state.h:20
Contains xtd::drawing::image class.
Provides control renderers methods.
Definition: renderer.h:30
Provides radio button renderer methods.
Definition: radio_button_renderer.h:29
theme_style
Specifies the style of theme.
Definition: theme_style.h:16
Provides check box renderer methods.
Definition: check_box_renderer.h:29
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:34
Definition: theme_renderers.h:14
push_button_state
Specifies the visual state of a button that is drawn with visual styles.
Definition: push_button_state.h:20
Contains xtd::forms::theme_base class.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
text_format_flags
Specifies the display and layout information for text strings.
Definition: text_format_flags.h:18
Definition: theme_base.h:15
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
Provides button renderer methods.
Definition: button_renderer.h:30
Contains xtd::forms::renderer class.