Wt examples 3.3.12
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ShapesWidget Class Reference

#include <ShapesWidget.h>

Inheritance diagram for ShapesWidget:
Inheritance graph
[legend]

Public Member Functions

 ShapesWidget (WContainerWidget *parent=0)
 
void setAngle (double angle)
 
double angle () const
 
void setRelativeSize (double size)
 
double relativeSize () const
 
- Public Member Functions inherited from Wt::WPaintedWidget
 WPaintedWidget (WContainerWidget *parent=0)
 
 ~WPaintedWidget ()
 
void setPreferredMethod (Method method)
 
Method preferredMethod () const
 
void update (WFlags< PaintFlag > flags=0)
 
virtual void resize (const WLength &width, const WLength &height)
 
void addArea (WAbstractArea *area)
 
void insertArea (int index, WAbstractArea *area)
 
void removeArea (WAbstractArea *area)
 
WAbstractAreaarea (int index) const
 
const std::vector< WAbstractArea * > areas () const
 
JSlotrepaintSlot ()
 
- Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget (WContainerWidget *parent=0)
 
EventSignal< WKeyEvent > & keyWentDown ()
 
EventSignal< WKeyEvent > & keyPressed ()
 
EventSignal< WKeyEvent > & keyWentUp ()
 
EventSignalenterPressed ()
 
EventSignalescapePressed ()
 
EventSignal< WMouseEvent > & clicked ()
 
EventSignal< WMouseEvent > & doubleClicked ()
 
EventSignal< WMouseEvent > & mouseWentDown ()
 
EventSignal< WMouseEvent > & mouseWentUp ()
 
EventSignal< WMouseEvent > & mouseWentOut ()
 
EventSignal< WMouseEvent > & mouseWentOver ()
 
EventSignal< WMouseEvent > & mouseMoved ()
 
EventSignal< WMouseEvent > & mouseDragged ()
 
EventSignal< WMouseEvent > & mouseWheel ()
 
EventSignal< WTouchEvent > & touchStarted ()
 
EventSignal< WTouchEvent > & touchEnded ()
 
EventSignal< WTouchEvent > & touchMoved ()
 
EventSignal< WGestureEvent > & gestureStarted ()
 
EventSignal< WGestureEvent > & gestureChanged ()
 
EventSignal< WGestureEvent > & gestureEnded ()
 
void setDraggable (const std::string &mimeType, WWidget *dragWidget=0, bool isDragWidgetOnly=false, WObject *sourceWidget=0)
 
void unsetDraggable ()
 
void setMouseOverDelay (int delay)
 
int mouseOverDelay () const
 
virtual void setPopup (bool popup)
 
virtual void load ()
 
virtual bool isEnabled () const
 
- Public Member Functions inherited from Wt::WWebWidget
 WWebWidget (WContainerWidget *parent=0)
 
virtual void setPositionScheme (PositionScheme scheme)
 
virtual PositionScheme positionScheme () const
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 
virtual WLength offset (Side s) const
 
virtual WLength width () const
 
virtual WLength height () const
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 
virtual WLength minimumWidth () const
 
virtual WLength minimumHeight () const
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 
virtual WLength maximumWidth () const
 
virtual WLength maximumHeight () const
 
virtual void setLineHeight (const WLength &height)
 
virtual WLength lineHeight () const
 
virtual void setFloatSide (Side s)
 
virtual Side floatSide () const
 
virtual void setClearSides (WFlags< Side > sides)
 
virtual WFlags< SideclearSides () const
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 
virtual WLength margin (Side side) const
 
virtual void setHiddenKeepsGeometry (bool enabled)
 
virtual bool hiddenKeepsGeometry () const
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 
virtual bool isHidden () const
 
virtual bool isVisible () const
 
virtual void setDisabled (bool disabled)
 
virtual bool isDisabled () const
 
virtual bool isPopup () const
 
virtual void setInline (bool isInline)
 
virtual bool isInline () const
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 
virtual WCssDecorationStyledecorationStyle ()
 
virtual void setStyleClass (const WString &styleClass)
 
virtual WString styleClass () const
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 
virtual bool hasStyleClass (const WString &styleClass) const
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength())
 
virtual AlignmentFlag verticalAlignment () const
 
virtual WLength verticalAlignmentLength () const
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 
virtual WString toolTip () const
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 
virtual WString attributeValue (const std::string &name) const
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 
virtual std::string javaScriptMember (const std::string &name) const
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 
virtual bool loaded () const
 
virtual void setId (const std::string &id)
 
virtual WWidgetfind (const std::string &name)
 
virtual WWidgetfindById (const std::string &id)
 
virtual void setSelectable (bool selectable)
 
virtual void doJavaScript (const std::string &javascript)
 
virtual const std::string id () const
 
void setLoadLaterWhenInvisible (bool)
 
std::string htmlTagName () const
 
void setHtmlTagName (const std::string &tag)
 
const std::vector< WWidget * > & children () const
 
SignalchildrenChanged ()
 
virtual void setCanReceiveFocus (bool enabled)
 
virtual bool canReceiveFocus () const
 
virtual bool setFirstFocus ()
 
virtual void setFocus (bool focus)
 
virtual bool hasFocus () const
 
virtual void setTabIndex (int index)
 
virtual int tabIndex () const
 
EventSignalblurred ()
 
EventSignalfocussed ()
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(final override)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(final override)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(final override)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(final override)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(final override)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(final override)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
virtual void removeChild (WObject *child)
 
void setFocus ()
 
virtual void setFocus (bool focus)=0
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 
std::string jsRef () const
 
void setFocus ()
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 
virtual void stopAcceptDrops (const std::string &mimeType)
 
virtual void setObjectName (const std::string &name)
 
virtual void htmlText (std::ostream &out)
 
bool isRendered () const
 
void hide ()
 
void animateHide (const WAnimation &animation)
 
void show ()
 
void animateShow (const WAnimation &animation)
 
void enable ()
 
void disable ()
 
bool layoutSizeAware () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
virtual std::string objectName () const
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Protected Member Functions

virtual void paintEvent (WPaintDevice *paintDevice)
 
- Protected Member Functions inherited from Wt::WPaintedWidget
WJavaScriptHandle< WTransformcreateJSTransform ()
 
WJavaScriptHandle< WBrushcreateJSBrush ()
 
WJavaScriptHandle< WPencreateJSPen ()
 
WJavaScriptHandle< WPainterPathcreateJSPainterPath ()
 
WJavaScriptHandle< WRectFcreateJSRect ()
 
WJavaScriptHandle< WPointFcreateJSPoint ()
 
virtual void layoutSizeChanged (int width, int height)
 
virtual Method getMethod () const
 
virtual WPaintDevicecreatePaintDevice () const
 
virtual void enableAjax ()
 
virtual void render (WFlags< RenderFlag > flags)
 
std::string objJsRef () const
 
- Protected Member Functions inherited from Wt::WInteractWidget
virtual void propagateSetEnabled (bool enabled)
 
- Protected Member Functions inherited from Wt::WWebWidget
virtual WStatelessSlot * getStateless (Method method)
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
 WWidget (WContainerWidget *parent=0)
 
virtual void dropEvent (WDropEvent dropEvent)
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 

Private Member Functions

void drawEmwebLogo (WPainter &p)
 
void drawEmwebE (WPainter &p)
 
void drawEmwebMW (WPainter &p)
 

Private Attributes

double angle_
 
double size_
 

Additional Inherited Members

- Public Types inherited from Wt::WPaintedWidget
enum  Method
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWebWidget
static WString escapeText (const WString &text, bool newlinesToo=false)
 
static std::string & escapeText (std::string &text, bool newlinestoo=false)
 
static bool removeScript (WString &text)
 
static std::string jsStringLiteral (const std::string &v, char delimiter='\'')
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Public Attributes inherited from Wt::WPaintedWidget
 InlineSvgVml
 
 HtmlCanvas
 
 PngImage
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

Detailed Description

Definition at line 19 of file ShapesWidget.h.

Constructor & Destructor Documentation

◆ ShapesWidget()

ShapesWidget::ShapesWidget ( WContainerWidget parent = 0)

Definition at line 24 of file ShapesWidget.C.

26 angle_(0),
27 size_(1)
28{
29 resize(710, 400);
30}
virtual void resize(const WLength &width, const WLength &height)
WWidget * parent() const

Member Function Documentation

◆ angle()

double ShapesWidget::angle ( ) const
inline

Definition at line 25 of file ShapesWidget.h.

25{ return angle_; }

◆ drawEmwebE()

void ShapesWidget::drawEmwebE ( WPainter p)
private

Definition at line 67 of file ShapesWidget.C.

68{
70
71 /* Path copied from our SVG for half of the E */
72
73 p.moveTo(46.835084,58.783624);
74 p.cubicTo(45.700172,58.783624,35.350098,58.911502,24.656354,63.283309);
75 p.cubicTo(8.7595992,69.78907,0,82.38499,0,98.809238);
76 p.cubicTo(0,115.20152,08.7595992,127.82141,24.656354,134.31119);
77 p.cubicTo(35.350098,138.69099,45.700172,138.81088,46.835084,138.81088);
78 p.lineTo(94.509362,138.81088);
79 p.lineTo(94.509362,117.58323);
80 p.lineTo(46.835084,117.58323);
81 p.cubicTo(46.811106,117.58323,39.466151,117.47134,32.608727,114.53815);
82 p.cubicTo(25.095932,111.34122,21.747144,106.47389,21.747144,98.809238);
83 p.cubicTo(21.747144,91.120612,25.095932,86.269265,32.608727,83.064338);
84 p.cubicTo(39.466151,80.123159,46.811106,80.027251,46.89103,80.027251);
85 p.lineTo(94.509362,80.027251);
86 p.lineTo(94.509362,58.783624);
87 p.lineTo(46.835084,58.783624);
88
89 painter.drawPath(p);
90
91 painter.save();
92 painter.translate(0,-58.783624);
93 painter.drawPath(p);
94 painter.restore();
95}
void moveTo(const WPointF &point)
void lineTo(const WPointF &point)
void cubicTo(const WPointF &c1, const WPointF &c2, const WPointF &endPoint)

◆ drawEmwebLogo()

void ShapesWidget::drawEmwebLogo ( WPainter p)
private

Definition at line 145 of file ShapesWidget.C.

146{
147 painter.save();
148 painter.setPen(NoPen);
149
150 /*
151 * The emweb logo can be drawn as 3 e's, and one combined m/w
152 */
153
154 // Emweb
155 painter.setBrush(black);
156 drawEmwebE(painter);
157
158 // emwEb
159 painter.save();
160 painter.translate(397, 0);
161 drawEmwebE(painter);
162
163 // emweB
164 painter.translate(210, 0);
165 painter.scale(-1, 1);
166 drawEmwebE(painter);
167
168 painter.restore();
169
170 // eMWeb
171 painter.setBrush(emweb);
172 drawEmwebMW(painter);
173
174 painter.restore();
175}
void drawEmwebMW(WPainter &p)
void drawEmwebE(WPainter &p)

◆ drawEmwebMW()

void ShapesWidget::drawEmwebMW ( WPainter p)
private

Definition at line 97 of file ShapesWidget.C.

98{
100
101 /* Path copied from our SVG for one fourth of the MW */
102
103 p.moveTo(120.59634,24.072913);
104 p.cubicTo(116.12064,34.518895,115.98477,44.605222,115.98477,45.732141);
105 p.lineTo(115.98477,138.81088);
106 p.lineTo(137.7399,138.81088);
107 p.lineTo(137.7399,45.732141);
108 p.cubicTo(137.7399,45.708164,137.83581,38.53904,140.84892,31.841463);
109 p.cubicTo(144.14176,24.512492,149.113,21.235634,156.98545,21.235634);
110 p.cubicTo(164.8499,21.235634,169.81314,24.512492,173.10599,31.841463);
111 p.cubicTo(176.10311,38.53904,176.215,45.708164,176.215,45.780095);
112 p.lineTo(176.215,70.41343);
113 p.lineTo(197.97014,70.41343);
114 p.lineTo(197.97014,45.732141);
115 p.cubicTo(197.97014,44.605222,197.83427,34.518895,193.35057,24.072913);
116 p.cubicTo(186.70894,8.5517985,173.77734,0,156.99344,0);
117 p.cubicTo(140.17756,0,127.25396,8.5517985,120.59634,24.072913);
118
119 /*
120 * Paint it four times, translated and inverted
121 */
122
123 painter.drawPath(p);
124
125 const double dx = 176. - 115.98477;
126
127 painter.save();
128
129 painter.translate(dx, 0);
130 painter.drawPath(p);
131
132 painter.translate(dx, 0);
133
134 painter.scale(-1, -1);
135 painter.translate(0, -138.81088);
136 painter.translate(-115.98477 - 197.95 - dx, 0);
137 painter.drawPath(p);
138
139 painter.translate(dx, 0);
140 painter.drawPath(p);
141
142 painter.restore();
143}

◆ paintEvent()

void ShapesWidget::paintEvent ( WPaintDevice paintDevice)
protectedvirtual

Implements Wt::WPaintedWidget.

Definition at line 52 of file ShapesWidget.C.

53{
54 WPainter painter(paintDevice);
55
56 painter.setShadow(WShadow(10, 10, WColor(0, 0, 0, 50), 10));
57 painter.setRenderHint(WPainter::Antialiasing);
58
59 painter.translate(width().value()/2, height().value()/2);
60 painter.rotate(angle_);
61 painter.scale(size_, size_);
62 painter.translate(-width().value()/2 + 50, -height().value()/2 + 150);
63
64 drawEmwebLogo(painter);
65}
void drawEmwebLogo(WPainter &p)
virtual WLength height() const
virtual WLength width() const

◆ relativeSize()

double ShapesWidget::relativeSize ( ) const
inline

Definition at line 28 of file ShapesWidget.h.

28{ return size_; }

◆ setAngle()

void ShapesWidget::setAngle ( double  angle)

Definition at line 32 of file ShapesWidget.C.

33{
34 angle = std::max(-30.0, std::min(30.0, angle));
35
36 if (angle_ != angle) {
37 angle_ = angle;
38 update();
39 }
40}
double angle() const
void update(WFlags< PaintFlag > flags=0)

◆ setRelativeSize()

void ShapesWidget::setRelativeSize ( double  size)

Definition at line 42 of file ShapesWidget.C.

43{
44 size = std::max(0.1, std::min(1.0, size));
45
46 if (size_ != size) {
47 size_ = size;
48 update();
49 }
50}

Member Data Documentation

◆ angle_

double ShapesWidget::angle_
private

Definition at line 34 of file ShapesWidget.h.

◆ size_

double ShapesWidget::size_
private

Definition at line 35 of file ShapesWidget.h.


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

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8