Boost.UI
User Interface Boost library
|
Go to the documentation of this file.
8 #ifndef BOOST_UI_PAINTER_HPP
9 #define BOOST_UI_PAINTER_HPP
13 #ifdef BOOST_HAS_PRAGMA_ONCE
23 #include <boost/noncopyable.hpp>
24 #include <boost/core/scoped_enum.hpp>
27 #include <boost/range/begin.hpp>
28 #include <boost/range/end.hpp>
29 #include <boost/range/size.hpp>
51 BOOST_SCOPED_ENUM_DECLARE_END(
line_cap)
53 BOOST_SCOPED_ENUM_DECLARE_BEGIN(
line_join)
71 painter(detail::painter_impl* impl);
79 { save_raw();
return *
this; }
83 { restore_raw();
return *
this; }
87 { scale_raw(x, y);
return *
this; }
91 { rotate_raw(angle);
return *
this; }
95 { translate_raw(x, y);
return *
this; }
99 {
return translate(p.
x(), p.
y()); }
104 { fill_color_raw(c);
return *
this; }
108 { stroke_color_raw(c);
return *
this; }
112 { clear_rect_raw(x, y, width, height);
return *
this; }
124 {
return clear_rect(point1.
x(), point1.
y(), point2.
x() - point1.
x(), point2.
y() - point1.
y()); }
129 { fill_rect_raw(x, y, width, height);
return *
this; }
141 {
return fill_rect(point1.
x(), point1.
y(), point2.
x() - point1.
x(), point2.
y() - point1.
y()); }
146 { stroke_rect_raw(x, y, width, height);
return *
this; }
158 {
return stroke_rect(point1.
x(), point1.
y(), point2.
x() - point1.
x(), point2.
y() - point1.
y()); }
163 { fill_text_raw(text, x, y);
return *
this; }
167 {
return fill_text(text, p.
x(), p.
y()); }
172 { draw_image_raw(img, dx, dy);
return *
this; }
176 {
return draw_image(img, p.
x(), p.
y()); }
181 { begin_path_raw();
return *
this; }
185 { fill_raw();
return *
this; }
189 { stroke_raw();
return *
this; }
193 { line_width_raw(width);
return *
this; }
197 { line_cap_raw(lc);
return *
this; }
201 { line_join_raw(lj);
return *
this; }
204 template <
class Iterator>
207 std::vector<gcoord_type> segments;
208 std::copy(first, last, std::back_inserter(segments));
209 line_dash_raw(segments);
213 template <
class Range>
215 {
return line_dash(boost::begin(r), boost::end(r)); }
217 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
221 std::vector<gcoord_type> segments;
222 segments.reserve(list.size());
223 std::copy(list.begin(), list.end(), std::back_inserter(segments));
224 line_dash_raw(segments);
237 { font_raw(f);
return *
this; }
244 { close_path_raw();
return *
this; }
248 { move_to_raw(x, y);
return *
this; }
252 {
return move_to(p.
x(), p.
y()); }
257 { line_to_raw(x, y);
return *
this; }
261 {
return line_to(p.
x(), p.
y()); }
267 { quadratic_curve_to_raw(cpx, cpy, x, y);
return *
this; }
271 {
return quadratic_curve_to(cp.
x(), cp.
y(), p.
x(), p.
y()); }
278 { bezier_curve_to_raw(cp1x, cp1y, cp2x, cp2y, x, y);
return *
this; }
284 {
return bezier_curve_to(cp1.
x(), cp1.
y(), cp2.
x(), cp2.
y(), p.
x(), p.
y()); }
290 { arc_raw(x, y, radius, start_angle, end_angle, anticlockwise);
return *
this; }
295 {
return arc(p.
x(), p.
y(), radius, start_angle, end_angle, anticlockwise); }
300 { rect_raw(x, y, w, h);
return *
this; }
312 {
return rect(point1.
x(), point1.
y(), point2.
x() - point1.
x(), point2.
y() - point1.
y()); }
330 void fill_color_raw(
const color& c);
331 void stroke_color_raw(
const color& c);
337 void begin_path_raw();
343 void line_dash_raw(
const std::vector<gcoord_type>& segments);
344 void reset_line_dash_raw();
346 void close_path_raw();
358 detail::painter_impl* m_impl;
394 #endif // BOOST_UI_PAINTER_HPP
painter & line_dash(const Range &r)
Sets line dashes.
Definition: painter.hpp:214
painter & line_dash(nullopt_t)
Resets line dashes.
Definition: painter.hpp:231
painter & bezier_curve_to(gcoord_type cp1x, gcoord_type cp1y, gcoord_type cp2x, gcoord_type cp2y, gcoord_type x, gcoord_type y)
Creates cubic Bezier curve with control points (cp1x, cp1y) and (cp2x, cp2y)
Definition: painter.hpp:275
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
painter & fill_rect(const basic_point< T > &point, const basic_size< T > &size)
Paints the given rectangle onto the painter, using the current fill style.
Definition: painter.hpp:136
basic_size< painter::gcoord_type > gsize
2D size geometry coordinates
Definition: painter.hpp:381
painter & quadratic_curve_to(gcoord_type cpx, gcoord_type cpy, gcoord_type x, gcoord_type y)
Creates quadratic Bezier curve with control point (cpx, cpy)
Definition: painter.hpp:265
T y() const
Returns y coordinate.
Definition: coord.hpp:179
painter & font(const ui::font &f)
Sets font.
Definition: painter.hpp:236
void * native_handle_type
Implementation-defined painter type.
Definition: painter.hpp:315
painter & line_width(gcoord_type width)
Sets line width (default is 1)
Definition: painter.hpp:192
basic_rect< coord_type > rect
2D rectangle coordinates
Definition: coord.hpp:424
painter & draw_image(const image &img, gcoord_type dx, gcoord_type dy)
Draws the given image onto the painter.
Definition: painter.hpp:171
2D point data structure with custom coordinates type
Definition: coord.hpp:119
painter & line_to(const basic_point< T > &p)
Connects the last point in the subpath to the specified point using a straight line.
Definition: painter.hpp:260
painter & clear_rect(const basic_point< T > &point1, const basic_point< T > &point2)
Clears all pixels on the painter in the given rectangle to transparent black.
Definition: painter.hpp:123
painter & fill_rect(const basic_rect< T > &r)
Paints the given rectangle onto the painter, using the current fill style.
Definition: painter.hpp:132
painter & quadratic_curve_to(const basic_point< T > &cp, const basic_point< T > &p)
Creates quadratic Bezier curve with control point (cpx, cpy)
Definition: painter.hpp:270
painter & stroke_color(const color &c)
Sets the current color used for filling shapes.
Definition: painter.hpp:107
painter & line_to(gcoord_type x, gcoord_type y)
Connects the last point in the subpath to the specified point using a straight line.
Definition: painter.hpp:256
painter & bezier_curve_to(const basic_point< T > &cp1, const basic_point< T > &cp2, const basic_point< T > &p)
Creates cubic Bezier curve with control points (cp1x, cp1y) and (cp2x, cp2y)
Definition: painter.hpp:281
T width() const
Returns width.
Definition: coord.hpp:372
Boost C++ libraries namespace.
Definition: window.hpp:19
painter & arc(gcoord_type x, gcoord_type y, gcoord_type radius, gcoord_type start_angle, gcoord_type end_angle, bool anticlockwise=false)
Creates an arc.
Definition: painter.hpp:288
painter & clear_rect(const basic_rect< T > &r)
Clears all pixels on the painter in the given rectangle to transparent black.
Definition: painter.hpp:115
painter & stroke_rect(gcoord_type x, gcoord_type y, gcoord_type width, gcoord_type height)
Paints the box that outlines the given rectangle onto the painter, using the current stroke style.
Definition: painter.hpp:145
painter & stroke_rect(const basic_rect< T > &r)
Paints the box that outlines the given rectangle onto the painter, using the current stroke style.
Definition: painter.hpp:149
state_saver(painter &c)
Saves current painter state in the stack.
Definition: painter.hpp:370
painter & scale(gcoord_type x, gcoord_type y)
Adds scaling transformation.
Definition: painter.hpp:86
T height() const
Returns height.
Definition: coord.hpp:383
@ round
semi-circle with the diameter equal to the line width is added
painter & fill_rect(const basic_point< T > &point1, const basic_point< T > &point2)
Paints the given rectangle onto the painter, using the current fill style.
Definition: painter.hpp:140
double gcoord_type
Graphics coordinates signed number type.
Definition: painter.hpp:75
painter & stroke_rect(const basic_point< T > &point1, const basic_point< T > &point2)
Paints the box that outlines the given rectangle onto the painter, using the current stroke style.
Definition: painter.hpp:157
basic_point< painter::gcoord_type > gpoint
2D point geometry coordinates
Definition: painter.hpp:385
T x() const
Returns x coordinate.
Definition: coord.hpp:171
String class and operations.
T x() const
Returns x coordinate.
Definition: coord.hpp:352
painter & stroke_rect(const basic_point< T > &point, const basic_size< T > &size)
Paints the box that outlines the given rectangle onto the painter, using the current stroke style.
Definition: painter.hpp:153
painter & fill_text(const uistring &text, const basic_point< T > &p)
Fills the given text at the given position.
Definition: painter.hpp:166
painter & move_to(const basic_point< T > &p)
Creates a new subpath with the specified point as its first (and only) point.
Definition: painter.hpp:251
line_cap
Enumaration of line endings types.
Definition: painter.hpp:44
painter & translate(gcoord_type x, gcoord_type y)
Adds translation transformation.
Definition: painter.hpp:94
painter & move_to(gcoord_type x, gcoord_type y)
Creates a new subpath with the specified point as its first (and only) point.
Definition: painter.hpp:247
painter & rotate(gcoord_type angle)
Adds rotation transformation.
Definition: painter.hpp:90
painter & translate(const basic_point< T > &p)
Adds translation transformation.
Definition: painter.hpp:98
painter & close_path()
Connects the last point to the first point in the subpath.
Definition: painter.hpp:243
@ butt
no additional line cap is added
line_join
Enumaration of line join types.
Definition: painter.hpp:55
painter & draw_image(const image &img, const basic_point< T > &p)
Draws the given image onto the painter.
Definition: painter.hpp:175
const T & height() const
Retruns height.
Definition: coord.hpp:74
painter & fill_color(const color &c)
Sets the current color used for filling shapes.
Definition: painter.hpp:103
basic_rect< painter::gcoord_type > grect
2D rectangle geometry coordinates
Definition: painter.hpp:389
const T & width() const
Retruns width.
Definition: coord.hpp:71
painter & line_join(ui::line_join lj)
Sets type of line join, default value is miter.
Definition: painter.hpp:200
Saves state in the constructor and restores it in the destructor.
Definition: painter.hpp:366
2D size of object data structure with custom coordinates type
Definition: coord.hpp:48
painter & save()
Push state.
Definition: painter.hpp:78
T y() const
Returns y coordinate.
Definition: coord.hpp:362
Widget for drawing.
Definition: canvas.hpp:29
painter & line_dash(std::initializer_list< T > list)
Sets line dashes.
Definition: painter.hpp:219
painter & fill_text(const uistring &text, gcoord_type x, gcoord_type y)
Fills the given text at the given position.
Definition: painter.hpp:162
painter & restore()
Pop state.
Definition: painter.hpp:82
painter & begin_path()
Resets the current path.
Definition: painter.hpp:180
painter & clear_rect(const basic_point< T > &point, const basic_size< T > &size)
Clears all pixels on the painter in the given rectangle to transparent black.
Definition: painter.hpp:119
painter & rect(const basic_rect< T > &r)
Creates rectangular closed subpath.
Definition: painter.hpp:303
2D rectangle plane figure data structure with custom coordinates type
Definition: coord.hpp:259
painter & line_dash(Iterator first, Iterator last)
Sets line dashes.
Definition: painter.hpp:205
painter & rect(const basic_point< T > &point, const basic_size< T > &size)
Creates rectangular closed subpath.
Definition: painter.hpp:307
Color class.
Definition: color.hpp:31
painter & line_cap(ui::line_cap lc)
Sets type of line endings, default value is butt.
Definition: painter.hpp:196
~state_saver()
Restores painter state from the stack.
Definition: painter.hpp:373
painter & stroke()
Strokes the current path.
Definition: painter.hpp:188
2D graphics rendering painter
Definition: painter.hpp:69
painter & arc(const basic_point< T > &p, gcoord_type radius, gcoord_type start_angle, gcoord_type end_angle, bool anticlockwise=false)
Creates an arc.
Definition: painter.hpp:293
painter & fill_rect(gcoord_type x, gcoord_type y, gcoord_type width, gcoord_type height)
Paints the given rectangle onto the painter, using the current fill style.
Definition: painter.hpp:128
Image class.
Definition: image.hpp:28
painter & rect(const basic_point< T > &point1, const basic_point< T > &point2)
Creates rectangular closed subpath.
Definition: painter.hpp:311
painter & fill()
Fills the current path.
Definition: painter.hpp:184
painter & rect(gcoord_type x, gcoord_type y, gcoord_type w, gcoord_type h)
Creates rectangular closed subpath.
Definition: painter.hpp:299
Font class.
Definition: font.hpp:30
painter & clear_rect(gcoord_type x, gcoord_type y, gcoord_type width, gcoord_type height)
Clears all pixels on the painter in the given rectangle to transparent black.
Definition: painter.hpp:111
painter & reset_line_dash()
Resets line dashes.
Definition: painter.hpp:232