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.h
Go to the documentation of this file.
1 #pragma once
5 #include "theme_base.h"
6 #include "theme_colors.h"
7 #include "theme_images.h"
8 #include "theme_renderers.h"
9 
11 namespace xtd {
13  namespace forms {
14  class forms_export_ theme final : public theme_base {
15  public:
17 
19  static const theme empty() {return theme();};
21 
23 
25  theme() = default;
26  explicit theme(const xtd::ustring& name) : theme(name, xtd::forms::theme_style::system_auto, false) {}
27  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style) : theme(name, theme_style, false) {}
28  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, const xtd::forms::theme_colors& theme_colors) : theme_base(name, theme_style), theme_colors_(theme_colors) {}
29  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, const xtd::forms::theme_images& theme_images) : theme_base(name, theme_style), theme_images_(theme_images) {}
30  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, const xtd::forms::theme_renderers& theme_renderers) : theme_base(name, theme_style), theme_renderers_(theme_renderers) {}
31  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, const xtd::forms::theme_colors& theme_colors, const xtd::forms::theme_images& theme_images) : theme_base(name, theme_style), theme_colors_(theme_colors), theme_images_(theme_images) {}
32  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, const xtd::forms::theme_colors& theme_colors, const xtd::forms::theme_images& theme_images, const xtd::forms::theme_renderers& theme_renderers) : theme_base(name, theme_style), theme_colors_(theme_colors), theme_images_(theme_images), theme_renderers_(theme_renderers) {}
34 
36  theme(const theme&) = default;
37  theme& operator=(const theme&) = default;
38  bool operator==(const theme& value) const {return theme_base::operator==(value);}
39  bool operator!=(const theme& value) const {return !operator==(value);}
41 
43 
45  const xtd::forms::theme_colors& theme_colors() const {return theme_colors_;}
46  xtd::forms::theme_colors& theme_colors() {return theme_colors_;}
47  theme& theme_colors(const xtd::forms::theme_colors& theme_colors) {
48  if (theme_colors_ != theme_colors)
49  theme_colors_ = theme_colors;
50  return *this;
51  }
52 
53  const xtd::forms::theme_images& theme_images() const {return theme_images_;}
54  xtd::forms::theme_images& theme_images() {return theme_images_;}
55  theme& theme_images(const xtd::forms::theme_images& theme_images) {
56  if (theme_images_ != theme_images)
57  theme_images_ = theme_images;
58  return *this;
59  }
60 
61  const xtd::forms::theme_renderers& theme_renderers() const {return theme_renderers_;}
62  xtd::forms::theme_renderers& theme_renderers() {return theme_renderers_;}
63  theme& theme_renderers(const xtd::forms::theme_renderers& theme_renderers) {
64  if (theme_renderers_ != theme_renderers)
65  theme_renderers_ = theme_renderers;
66  return *this;
67  }
69 
71 
73  static const theme& current_theme() {
74  if (current_theme_ == theme::empty()) current_theme_ = default_theme();
75  return current_theme_;
76  }
77  static void current_theme(const theme& theme) {
78  current_theme_ = theme;
79  theme_colors::current_theme(current_theme_.theme_colors_);
80  theme_images::current_theme(current_theme_.theme_images_);
81  theme_renderers::current_theme(current_theme_.theme_renderers_);
82  }
83  static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
84 
85  static theme default_theme() {return theme_from_name(default_theme_name());}
86 
87  static theme theme_from_name(const xtd::ustring& theme_name);
89 
90  private:
91  theme(const xtd::ustring& name, xtd::forms::theme_style theme_style, bool is_default) : theme_base(name, theme_style, is_default), theme_colors_(theme_colors::theme_from_name(name)), theme_images_(theme_images::theme_from_name(name)), theme_renderers_(theme_renderers::theme_from_name(name)) {}
92  xtd::forms::theme_colors theme_colors_ = xtd::forms::theme_colors::current_theme();
93  xtd::forms::theme_images theme_images_ = xtd::forms::theme_images::current_theme();
94  xtd::forms::theme_renderers theme_renderers_ = xtd::forms::theme_renderers::current_theme();
95  static theme current_theme_;
96  };
97  }
98 }
Contains xtd::forms::theme_colors class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Definition: theme_images.h:14
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Definition: theme_colors.h:15
Definition: theme.h:14
theme_style
Specifies the style of theme.
Definition: theme_style.h:16
Definition: theme_renderers.h:14
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
Definition: theme_base.h:15
Contains xtd::forms::theme_renderers class.
Contains xtd::forms::theme_images class.