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_images.h
Go to the documentation of this file.
1 #pragma once
5 #include <xtd/delegate.h>
6 #include <xtd/drawing/image.h>
7 #include <xtd/drawing/size.h>
8 #include "theme_base.h"
9 
11 namespace xtd {
13  namespace forms {
14  class forms_export_ theme_images final : public theme_base {
15  public:
17 
19  using image_getter = xtd::delegate<xtd::drawing::image(const xtd::ustring& name, const xtd::drawing::size& size)>;
21 
23 
25  static const theme_images empty;
27 
29 
31  theme_images() = default;
32  explicit theme_images(const xtd::ustring& name) : theme_base(name) {}
33  theme_images(const xtd::ustring& name, xtd::forms::theme_style theme_style, const image_getter& image_getter) : theme_base(name, theme_style), image_getter_(image_getter) {}
35 
37  theme_images(const theme_images&) = default;
38  theme_images& operator=(const theme_images&) = default;
39  bool operator==(const theme_images& value) const {return theme_base::operator==(value);}
40  bool operator!=(const theme_images& value) const {return !operator==(value);}
42 
44 
46  static theme_images default_theme() {return theme_from_name(default_theme_name());}
47 
48  static xtd::drawing::size default_size() {return {32, 32};}
50 
52 
54  static theme_images current_theme() {
55  if (current_theme_ == theme_images::empty) current_theme_ = default_theme();
56  return current_theme_;
57  }
58  static void current_theme(const theme_images& theme) {
59  current_theme_ = theme;
60  }
61  static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
62 
63  static theme_images theme_from_name(const xtd::ustring& theme_name);
64 
65  xtd::drawing::image from_name(const xtd::ustring& name) const {return from_name(name, default_size());}
66  xtd::drawing::image from_name(const xtd::ustring& name, const xtd::drawing::size& size) const {return image_getter_(name, size);}
68 
69  private:
70  theme_images(const xtd::ustring& name, xtd::forms::theme_style theme_style, const image_getter& image_getter, bool is_default) : theme_base(name, theme_style, is_default), image_getter_(image_getter) {}
71  image_getter image_getter_;
72  static theme_images current_theme_;
73  };
74  }
75 }
Contains xtd::delegate delegate.
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
Definition: theme_images.h:14
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
Definition: theme.h:14
Contains xtd::drawing::image class.
Specifies that both the width and height property values of the control are defined.
theme_style
Specifies the style of theme.
Definition: theme_style.h:16
Contains xtd::drawing::size class.
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:47
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
Defines a 3D themed border. The effect depends on the border color value.