PaintExample Class Reference

#include <PaintExample.h>

Inheritance diagram for PaintExample:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 PaintExample (WContainerWidget *root, bool showTitle=true)

Private Member Functions

void rotateShape (int v)
void scaleShape (int v)

Private Attributes

ShapesWidgetshapes_


Detailed Description

Definition at line 17 of file PaintExample.h.


Constructor & Destructor Documentation

PaintExample::PaintExample ( WContainerWidget root,
bool  showTitle = true 
)

Definition at line 17 of file PaintExample.C.

00018   : WContainerWidget(root)
00019 {
00020   std::string text;
00021   if (showTitle)
00022     text += "<h2>Paint example</h2>";
00023   text += 
00024     "<p>A simple example demonstrating cross-browser vector graphics."
00025     "</p>"
00026     "<p>The emweb logo below is painted using the Wt WPainter API from bezier paths, and "
00027     "rendered to the browser using inline SVG, inline VML or the "
00028     "HTML 5 &lt;canvas&gt; element."
00029     "</p>"
00030     "<p>"
00031     "The example also demonstrates the horizontal and vertical "
00032     "<a href=\"http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WSlider.html\" target=\"_blank\">"
00033     "WSlider</a> widgets. Here, the events of the WSlider"
00034     "widgets are used to scale and rotate the emweb logo."
00035     "</p>";
00036 
00037   new WText(text, this);
00038 
00039   WContainerWidget *emweb = new WContainerWidget(this);
00040   emweb->setMargin(WLength::Auto, Left | Right);
00041 
00042   WGridLayout *layout = new WGridLayout();
00043   emweb->setLayout(layout, AlignCenter | AlignTop);
00044 
00045   WSlider *scaleSlider = new WSlider(Horizontal);
00046   scaleSlider->setMinimum(0);
00047   scaleSlider->setMaximum(20);
00048   scaleSlider->setValue(10);
00049   scaleSlider->setTickInterval(5);
00050   scaleSlider->setTickPosition(WSlider::TicksBothSides);
00051   scaleSlider->resize(300, 50);
00052   scaleSlider->valueChanged().connect(SLOT(this, PaintExample::scaleShape));
00053 
00054   layout->addWidget(scaleSlider, 0, 1, AlignCenter | AlignMiddle);
00055 
00056   WSlider *rotateSlider = new WSlider(Vertical);
00057   rotateSlider->setMinimum(-30);
00058   rotateSlider->setMaximum(30);
00059   rotateSlider->setValue(0);
00060   rotateSlider->setTickInterval(10);
00061   rotateSlider->setTickPosition(WSlider::TicksBothSides);
00062   rotateSlider->resize(50, 400);
00063   rotateSlider->valueChanged().connect(SLOT(this, PaintExample::rotateShape));
00064 
00065   layout->addWidget(rotateSlider, 1, 0, AlignCenter | AlignMiddle);
00066 
00067   shapes_ = new ShapesWidget();
00068   shapes_->setAngle(0.0);
00069   shapes_->setRelativeSize(0.5);
00070   shapes_->setPreferredMethod(WPaintedWidget::InlineSvgVml);
00071 
00072   layout->addWidget(shapes_, 1, 1, AlignCenter | AlignMiddle);
00073 }


Member Function Documentation

void PaintExample::rotateShape ( int  v  )  [private]

Definition at line 75 of file PaintExample.C.

00076 {
00077   shapes_->setAngle(v / 2.0);
00078 
00079   // Being silly: test alternate rendering method
00080   shapes_->setPreferredMethod(v < 0 ? WPaintedWidget::InlineSvgVml
00081                               : WPaintedWidget::HtmlCanvas);
00082 }

void PaintExample::scaleShape ( int  v  )  [private]

Definition at line 84 of file PaintExample.C.

00085 {
00086   shapes_->setRelativeSize(0.1 + 0.9 * (v/20.0));
00087 }


Member Data Documentation

Definition at line 23 of file PaintExample.h.


The documentation for this class was generated from the following files:

Generated on Tue Sep 1 17:51:23 2009 for Wt by doxygen 1.5.6