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.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
renderer.h
Go to the documentation of this file.
1
4#pragma once
5#include <optional>
6#include <xtd/delegate.h>
7#include <xtd/object.h>
8#include <xtd/ustring.h>
9#include <xtd/drawing/color.h>
10#include <xtd/drawing/font.h>
12#include <xtd/drawing/image.h>
14#include "../forms_export.h"
15#include "text_format_flags.h"
19
21namespace xtd {
23 namespace forms {
30 class forms_export_ renderer : public object {
31 public:
32 using button_renderer = xtd::delegate<void(xtd::drawing::graphics, const xtd::drawing::rectangle&, const xtd::ustring&, const xtd::drawing::font&, xtd::forms::text_format_flags, const xtd::drawing::image&, const xtd::drawing::rectangle&, bool focused, xtd::forms::visual_styles::push_button_state, const std::optional<xtd::drawing::color>&, const std::optional<xtd::drawing::color>&)>;
33 using check_box_renderer = xtd::delegate<void(xtd::drawing::graphics, const xtd::drawing::rectangle&, const xtd::ustring&, const xtd::drawing::font&, xtd::forms::text_format_flags, const xtd::drawing::image&, const xtd::drawing::rectangle&, bool focused, xtd::forms::visual_styles::check_box_state, const std::optional<xtd::drawing::color>&, const std::optional<xtd::drawing::color>&)>;
34 using radio_button_renderer = xtd::delegate<void(xtd::drawing::graphics, const xtd::drawing::rectangle&, const xtd::ustring&, const xtd::drawing::font&, xtd::forms::text_format_flags, const xtd::drawing::image&, const xtd::drawing::rectangle&, bool focused, xtd::forms::visual_styles::radio_button_state, const std::optional<xtd::drawing::color>&, const std::optional<xtd::drawing::color>&)>;
35
36 renderer() = default;
37 explicit renderer(const xtd::ustring& name) : name_(name) {}
39 renderer(const renderer&) = default;
40 renderer& operator=(const renderer&) = default;
41 bool operator==(const renderer& value) const {return name_ == value.name_;}
42 bool operator!=(const renderer& value) const {return !operator==(value);}
43 friend std::ostream& operator<<(std::ostream& os, const renderer& theme) noexcept {return os << theme.to_string();}
45
46 virtual const xtd::ustring& name() const {return name_;}
47 renderer& name(const xtd::ustring& name) {
48 name_ = name;
49 return *this;
50 }
51
52 button_renderer button_render() const {return button_renderer_;}
53 void button_render(button_renderer button_renderer) {button_renderer_ = button_renderer;}
54
55 check_box_renderer check_box_render() const {return check_box_renderer_;}
56 void check_box_render(check_box_renderer check_box_renderer) {check_box_renderer_ = check_box_renderer;}
57
58 radio_button_renderer radio_button_render() const {return radio_button_renderer_;}
59 void radio_button_render(radio_button_renderer radio_button_renderer) {radio_button_renderer_ = radio_button_renderer;}
60
61 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_renderer_(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
62 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_renderer_(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
63 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_renderer_(g, bounds, text, font, flags, image, image_bounds, focused, state, back_color, fore_color);}
64
65 xtd::ustring to_string() const noexcept override {
66 if (!name_.empty()) return xtd::ustring::format("{}, name: {}", ustring::full_class_name(*this), name_);
68 }
69
70 static const renderer empty;
71
72 protected:
73
74 private:
75 static void default_button_renderer(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);
76 static void default_check_box_renderer(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);
77 static void default_radio_button_renderer(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);
78
79 xtd::ustring name_;
80 button_renderer button_renderer_ = button_renderer(default_button_renderer);
81 check_box_renderer check_box_renderer_ = check_box_renderer(default_check_box_renderer);
82 radio_button_renderer radio_button_renderer_ = radio_button_renderer(default_radio_button_renderer);
83 };
84 }
85}
Contains xtd::forms::visual_styles::check_box_state enum class.
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
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
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition: renderer.h:65
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition: theme_base.h:41
Definition: theme.h:14
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
static ustring full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t.
Definition: ustring.h:427
Contains xtd::drawing::color class.
Contains xtd::delegate delegate.
Contains xtd::drawing::font class.
Contains xtd::drawing::graphics class.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
#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
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::object class.
Contains xtd::forms::visual_styles::push_button_state enum class.
Contains xtd::forms::visual_styles::radio_button_state enum class.
Contains xtd::drawing::rectangle class.
Contains xtd::forms::text_format_flags enum class.
Contains xtd::ustring class.