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 class CSSPropertyValue;
52 
54 class CL_API_GUI GUIThemePart
55 {
58 public:
60  GUIThemePart();
61 
63  GUIThemePart(GUIComponent *parent, const std::string &tag_name);
65 
68 public:
70  bool is_null() const { return !impl; }
71 
73  void throw_if_null() const;
74 
76  const CSSComputedValues &get_css_values() const;
77 
79  Font get_font() const;
80 
82  std::string get_tag_name() const;
83 
85  std::string get_id() const;
86 
88  bool get_class(const std::string &name) const;
89 
91  std::vector<std::string> get_classes() const;
92 
94  bool get_pseudo_class(const std::string &name) const;
95 
97  std::vector<std::string> get_pseudo_classes() const;
98 
100  Size get_css_size() const;
101 
103  int get_css_width() const;
104 
106  int get_css_height() const;
107 
109  Rect get_render_text_span_box(Canvas &canvas, const std::string &str, const Rect &content_rect) const;
110 
112  Rect get_render_text_box(Canvas &canvas, const std::string &str, const Rect &content_rect) const;
113 
115  Size get_render_text_size(Canvas &canvas, const std::string &str) const;
116 
118  Rect get_content_box(const Rect &render_box_rect) const;
119 
121  Rect get_content_shrink_box() const;
122 
124  Rect get_border_box(const Rect &content_box_rect) const;
125 
127  std::string get_property(const std::string &property, const std::string &default_value) const;
128 
130  int get_property_int(const std::string &property, const std::string &default_value) const;
132 
135 public:
137  void render_box(Canvas &canvas, const Rect &border_box);
138 
140  void set_tag_name(const std::string &name);
141 
145  bool set_class(const std::string &name, bool enable);
146 
148  void set_id(const std::string &name);
149 
153  void set_style(const std::string &name);
154 
156  void set_style(const CSSPropertyValue &value, bool enable);
157 
161  bool set_pseudo_class(const std::string &name, bool enable);
162 
163  Rect render_text_span(Canvas &canvas, const std::string &text, const Rect &content_rect);
164  Rect render_text(Canvas &canvas, const std::string &text, const Rect &content_box);
165  Rect render_text(Canvas &canvas, const std::string &text, const Rect &content_box, int baseline);
166 
168  VerticalTextPosition get_vertical_text_align(Canvas &canvas, const Rect &content_rect);
169 
171 
174 public:
175  std::shared_ptr<GUIThemePart_Impl> impl;
177 };
178 
179 }
Definition: css_computed_values.h:58
2D Graphics Canvas
Definition: canvas.h:70
Definition: gui_component.h:73
std::shared_ptr< GUIThemePart_Impl > impl
Definition: gui_theme_part.h:175
GUI base component class.
Definition: gui_component.h:81
A GUI theme part represents a pseudo element in CSS.
Definition: gui_theme_part.h:54
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
Definition: css_property_value.h:41
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:70