xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
theme_renderers.h
Go to the documentation of this file.
1
4#pragma once
5#include <xtd/delegate.h>
6#include <xtd/drawing/image.h>
7#include "renderer.h"
8#include "theme_base.h"
9
11namespace xtd {
13 namespace forms {
15 public:
16 using renderer_getter = xtd::delegate<xtd::forms::renderer()>;
17
18 theme_renderers() = default;
19 explicit theme_renderers(const xtd::ustring& name) : theme_base(name) {}
20 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) {}
22 theme_renderers(const theme_renderers&) = default;
23 theme_renderers& operator=(const theme_renderers&) = default;
24 bool operator==(const theme_renderers& value) const {return theme_base::operator==(value);}
25 bool operator!=(const theme_renderers& value) const {return !operator==(value);}
27
28 static const theme_renderers empty;
29
30 static xtd::drawing::size default_size() {return {32, 32};}
31
32 xtd::forms::renderer renderer() const {return renderer_getter_();}
33 xtd::forms::renderer::button_renderer button_render() const {return renderer_getter_().button_render();}
34 void button_render(xtd::forms::renderer::button_renderer button_renderer) {renderer_getter_().button_render(button_renderer);}
35 xtd::forms::renderer::check_box_renderer check_box_render() const {return renderer_getter_().check_box_render();}
36 void check_box_render(xtd::forms::renderer::check_box_renderer check_box_renderer) {renderer_getter_().check_box_render(check_box_renderer);}
37 xtd::forms::renderer::radio_button_renderer radio_button_render() const {return renderer_getter_().radio_button_render();}
38 void radio_button_render(xtd::forms::renderer::radio_button_renderer radio_button_renderer) {renderer_getter_().radio_button_render(radio_button_renderer);}
39
40 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);}
41 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);}
42 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);}
43
44 static theme_renderers current_theme() {
45 if (current_theme_ == theme_renderers::empty) current_theme_ = default_theme();
46 return current_theme_;
47 }
48 static void current_theme(const theme_renderers& theme) {
49 current_theme_ = theme;
50 }
51 static void current_theme(const xtd::ustring& name) {current_theme(theme_from_name(name));}
52
53 static theme_renderers default_theme() {return theme_from_name(default_theme_name());}
54
55 static theme_renderers theme_from_name(const xtd::ustring& theme_name);
56
57 private:
58 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) {}
59 renderer_getter renderer_getter_;
60 static theme_renderers current_theme_;
61 };
62 }
63}
Defines a particular format for text, including font face, size, and style attributes....
Definition: font.h:39
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition: image.h:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Provides button renderer methods.
Definition: button_renderer.h:30
Provides check box renderer methods.
Definition: check_box_renderer.h:29
Provides radio button renderer methods.
Definition: radio_button_renderer.h:29
Provides control renderers methods.
Definition: renderer.h:30
Definition: theme_base.h:15
Definition: theme_renderers.h:14
Definition: theme.h:14
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::delegate delegate.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ g
The G key.
text_format_flags
Specifies the display and layout information for text strings.
Definition: text_format_flags.h:18
push_button_state
Specifies the visual state of a button that is drawn with visual styles.
Definition: push_button_state.h:20
radio_button_state
Specifies the visual state of a radio button that is drawn with visual styles.
Definition: radio_button_state.h:20
check_box_state
Specifies the visual state of a check box that is drawn with visual styles.
Definition: check_box_state.h:20
theme_style
Specifies the style of theme.
Definition: theme_style.h:16
Contains xtd::drawing::image class.
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::renderer class.
Contains xtd::forms::theme_base class.