7 #include <Wt/WContainerWidget.h>
8 #include <Wt/WGridLayout.h>
9 #include <Wt/WSlider.h>
23 text +=
"<h2>Paint example</h2>";
26 "<p>A simple example demonstrating cross-browser vector graphics."
28 "<p>The emweb logo below is painted using the Wt WPainter API from "
29 "bezier paths, and rendered to the browser using inline SVG, inline VML "
30 "or the HTML 5 <canvas> element."
33 "The example also demonstrates the horizontal and vertical "
34 "<a href=\"http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WSlider.html\" target=\"_blank\">"
35 "WSlider</a> widgets. Here, "
36 "the events of the WSlider widgets are used to scale and rotate the "
40 "To demonstrate the different rendering methods, a different backend is used for positive or negative "
41 "angles (SVG or HTML canvas)."
44 this->
addWidget(std::make_unique<WText>(text));
47 emweb->
setMargin(WLength::Auto, Side::Left | Side::Right);
49 auto layout = std::make_unique<WGridLayout>();
52 std::unique_ptr<WSlider> scaleSlider(std::make_unique<WSlider>());
53 scaleSlider->setMinimum(0);
54 scaleSlider->setMaximum(20);
55 scaleSlider->setValue(10);
56 scaleSlider->setTickInterval(5);
57 scaleSlider->setTickPosition(WSlider::TicksBothSides);
58 scaleSlider->resize(300, 50);
61 layout_->addWidget(std::move(scaleSlider), 0, 1, AlignmentFlag::Center | AlignmentFlag::Middle);
63 auto rotateSlider = std::make_unique<WSlider>(Orientation::Vertical);
64 rotateSlider->setMinimum(-30);
65 rotateSlider->setMaximum(30);
66 rotateSlider->setValue(0);
67 rotateSlider->setTickInterval(10);
68 rotateSlider->setTickPosition(WSlider::TicksBothSides);
69 rotateSlider->resize(50, 400);
72 layout_->addWidget(std::move(rotateSlider), 1, 0, AlignmentFlag::Center | AlignmentFlag::Middle);
74 auto shapes = std::make_unique<ShapesWidget>();
80 layout_->addWidget(std::move(shapes), 1, 1,
81 AlignmentFlag::Center | AlignmentFlag::Middle);
90 : RenderMethod::HtmlCanvas);
PaintExample(bool showTitle=true)