xtd - Reference Guide  0.1.1
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:
16  theme() = default;
17  explicit theme(const xtd::ustring& name) : theme(name, xtd::forms::theme_style::system_auto, false) {}
25  theme(const theme&) = default;
26  theme& operator=(const theme&) = default;
27  bool operator==(const theme& value) const {return theme_base::operator==(value);}
28  bool operator!=(const theme& value) const {return !operator==(value);}
30 
31  const xtd::forms::theme_colors& theme_colors() const {return theme_colors_;}
32  xtd::forms::theme_colors& theme_colors() {return theme_colors_;}
34  if (theme_colors_ != theme_colors)
35  theme_colors_ = theme_colors;
36  return *this;
37  }
38 
39  const xtd::forms::theme_images& theme_images() const {return theme_images_;}
40  xtd::forms::theme_images& theme_images() {return theme_images_;}
42  if (theme_images_ != theme_images)
43  theme_images_ = theme_images;
44  return *this;
45  }
46 
47  const xtd::forms::theme_renderers& theme_renderers() const {return theme_renderers_;}
48  xtd::forms::theme_renderers& theme_renderers() {return theme_renderers_;}
50  if (theme_renderers_ != theme_renderers)
51  theme_renderers_ = theme_renderers;
52  return *this;
53  }
54 
55  static const theme empty;
56 
57  static const theme& current_theme() {
58  if (current_theme_ == theme::empty) current_theme_ = default_theme();
59  return current_theme_;
60  }
61  static void current_theme(const theme& theme) {
62  current_theme_ = theme;
63  theme_colors::current_theme(current_theme_.theme_colors_);
64  theme_images::current_theme(current_theme_.theme_images_);
65  theme_renderers::current_theme(current_theme_.theme_renderers_);
66  }
67  static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
68 
69  static theme default_theme() {return theme_from_name(default_theme_name());}
70 
71  static theme theme_from_name(const xtd::ustring& theme_name);
72 
73  private:
74  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)) {}
75  xtd::forms::theme_colors theme_colors_ = xtd::forms::theme_colors::current_theme();
76  xtd::forms::theme_images theme_images_ = xtd::forms::theme_images::current_theme();
77  xtd::forms::theme_renderers theme_renderers_ = xtd::forms::theme_renderers::current_theme();
78  static theme current_theme_;
79  };
80  }
81 }
Definition: theme_base.h:15
Definition: theme_colors.h:15
Definition: theme_images.h:14
Definition: theme_renderers.h:14
Definition: theme.h:14
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
theme_style
Specifies the style of theme.
Definition: theme_style.h:16
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::forms::theme_base class.
Contains xtd::forms::theme_colors class.
Contains xtd::forms::theme_images class.
Contains xtd::forms::theme_renderers class.