gui_theme_part.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
30 
31 #pragma once
32 
33 #include "api_gui.h"
34 #include <memory>
35 
36 #include "gui_component.h"
37 
38 namespace clan
39 {
42 
43 class GUIComponent;
44 class CSSComputedValues;
45 class GUIThemePart_Impl;
46 class Font;
47 class Canvas;
48 class Rect;
49 class Size;
50 class Point;
51 
53 class CL_API_GUI GUIThemePart
54 {
57 public:
59  GUIThemePart();
60 
62  GUIThemePart(GUIComponent *parent, const std::string &tag_name);
64 
67 public:
69  bool is_null() const { return !impl; }
70 
72  void throw_if_null() const;
73 
75  const CSSComputedValues &get_css_values() const;
76 
78  Font get_font() const;
79 
81  std::string get_tag_name() const;
82 
84  std::string get_id() const;
85 
87  bool get_class(const std::string &name) const;
88 
90  std::vector<std::string> get_classes() const;
91 
93  bool get_pseudo_class(const std::string &name) const;
94 
96  std::vector<std::string> get_pseudo_classes() const;
97 
99  Size get_css_size() const;
100 
102  int get_css_width() const;
103 
105  int get_css_height() const;
106 
108  Rect get_render_text_span_box(Canvas &canvas, const std::string &str, const Rect &content_rect) const;
109 
111  Rect get_render_text_box(Canvas &canvas, const std::string &str, const Rect &content_rect) const;
112 
114  Size get_render_text_size(Canvas &canvas, const std::string &str) const;
115 
117  Rect get_content_box(const Rect &render_box_rect) const;
118 
120  Rect get_content_shrink_box() const;
121 
123  Rect get_border_box(const Rect &content_box_rect) const;
124 
126  std::string get_property(const std::string &property, const std::string &default_value) const;
127 
129  int get_property_int(const std::string &property, const std::string &default_value) const;
131 
134 public:
136  void render_box(Canvas &canvas, const Rect &border_box);
137 
139  void set_tag_name(const std::string &name);
140 
144  bool set_class(const std::string &name, bool enable);
145 
147  void set_id(const std::string &name);
148 
152  bool set_pseudo_class(const std::string &name, bool enable);
153 
154  Rect render_text_span(Canvas &canvas, const std::string &text, const Rect &content_rect);
155  Rect render_text(Canvas &canvas, const std::string &text, const Rect &content_box);
156  Rect render_text(Canvas &canvas, const std::string &text, const Rect &content_box, int baseline);
157 
159  VerticalTextPosition get_vertical_text_align(Canvas &canvas, const Rect &content_rect);
160 
162 
165 public:
166  std::shared_ptr<GUIThemePart_Impl> impl;
168 };
169 
170 }
Definition: css_computed_values.h:58
2D Graphics Canvas
Definition: canvas.h:70
Definition: gui_component.h:72
std::shared_ptr< GUIThemePart_Impl > impl
Definition: gui_theme_part.h:166
GUI base component class.
Definition: gui_component.h:80
A GUI theme part represents a pseudo element in CSS.
Definition: gui_theme_part.h:53
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
Font class.
Definition: font.h:52
2D (width,height) size structure - Integer
Definition: size.h:157
bool is_null() const
Returns true if this object is invalid.
Definition: gui_theme_part.h:69