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:
16  using image_getter = xtd::delegate<xtd::drawing::image(const xtd::ustring& name, const xtd::drawing::size& size)>;
17 
18  theme_images() = default;
19  explicit theme_images(const xtd::ustring& name) : theme_base(name) {}
20  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) {}
22  theme_images(const theme_images&) = default;
23  theme_images& operator=(const theme_images&) = default;
24  bool operator==(const theme_images& value) const {return theme_base::operator==(value);}
25  bool operator!=(const theme_images& value) const {return !operator==(value);}
27 
28  static const theme_images empty;
29 
30  static xtd::drawing::size default_size() {return {32, 32};}
31 
32  xtd::drawing::image from_name(const xtd::ustring& name) const {return from_name(name, default_size());}
33  xtd::drawing::image from_name(const xtd::ustring& name, const xtd::drawing::size& size) const {return image_getter_(name, size);}
34 
35  static theme_images current_theme() {
36  if (current_theme_ == theme_images::empty) current_theme_ = default_theme();
37  return current_theme_;
38  }
39  static void current_theme(const theme_images& theme) {
40  current_theme_ = theme;
41  }
42  static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
43 
44  static theme_images default_theme() {return theme_from_name(default_theme_name());}
45 
46  static theme_images theme_from_name(const xtd::ustring& theme_name);
47 
48  private:
49  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) {}
50  image_getter image_getter_;
51  static theme_images current_theme_;
52  };
53  }
54 }
Contains xtd::delegate delegate.
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
Definition: theme_images.h:14
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Definition: theme.h:14
Contains xtd::drawing::image class.
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:34
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
size_t size
Represents a size of any object in bytes.
Definition: types.h:171