Wt examples  3.7.1
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 ()
 
 ~WPaintedWidget ()
 
void setPreferredMethod (RenderMethod method)
 
RenderMethod preferredMethod () const
 
void update (WFlags< PaintFlag > flags=None)
 
virtual void resize (const WLength &width, const WLength &height) override
 
void addArea (std::unique_ptr< WAbstractArea > area)
 
void insertArea (int index, std::unique_ptr< WAbstractArea > area)
 
std::unique_ptr< WAbstractArearemoveArea (WAbstractArea *area)
 
WAbstractAreaarea (int index) const
 
const std::vector< WAbstractArea *> areas () const
 
JSlotrepaintSlot ()
 
- Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget ()
 
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=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr)
 
void unsetDraggable ()
 
void setMouseOverDelay (int delay)
 
int mouseOverDelay () const
 
virtual void setPopup (bool popup) override
 
virtual void load () override
 
virtual bool isEnabled () const override
 
- Public Member Functions inherited from Wt::WWebWidget
 WWebWidget ()
 
virtual std::vector< WWidget *> children () const override
 
SignalchildrenChanged ()
 
virtual void setPositionScheme (PositionScheme scheme) override
 
virtual PositionScheme positionScheme () const override
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
 
virtual WLength offset (Side s) const override
 
virtual WLength width () const override
 
virtual WLength height () const override
 
virtual void setMinimumSize (const WLength &width, const WLength &height) override
 
virtual WLength minimumWidth () const override
 
virtual WLength minimumHeight () const override
 
virtual void setMaximumSize (const WLength &width, const WLength &height) override
 
virtual WLength maximumWidth () const override
 
virtual WLength maximumHeight () const override
 
virtual void setLineHeight (const WLength &height) override
 
virtual WLength lineHeight () const override
 
virtual void setFloatSide (Side s) override
 
virtual Side floatSide () const override
 
virtual void setClearSides (WFlags< Side > sides) override
 
virtual WFlags< SideclearSides () const override
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
 
virtual WLength margin (Side side) const override
 
virtual void setHiddenKeepsGeometry (bool enabled) override
 
virtual bool hiddenKeepsGeometry () const override
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
 
virtual bool isHidden () const override
 
virtual bool isVisible () const override
 
virtual void setDisabled (bool disabled) override
 
virtual bool isDisabled () const override
 
virtual bool isPopup () const override
 
virtual void setInline (bool isInline) override
 
virtual bool isInline () const override
 
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
 
virtual WCssDecorationStyledecorationStyle () override
 
virtual void setStyleClass (const WString &styleClass) override
 
virtual WString styleClass () const override
 
virtual void addStyleClass (const WString &styleClass, bool force=false) override
 
virtual void removeStyleClass (const WString &styleClass, bool force=false) override
 
virtual bool hasStyleClass (const WString &styleClass) const override
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) override
 
virtual AlignmentFlag verticalAlignment () const override
 
virtual WLength verticalAlignmentLength () const override
 
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
 
virtual WString toolTip () const override
 
virtual void refresh () override
 
virtual void setAttributeValue (const std::string &name, const WString &value) override
 
virtual WString attributeValue (const std::string &name) const override
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value) override
 
virtual std::string javaScriptMember (const std::string &name) const override
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args) override
 
virtual bool loaded () const override
 
virtual void setId (const std::string &id) override
 
virtual WWidgetfind (const std::string &name) override
 
virtual WWidgetfindById (const std::string &id) override
 
virtual void setSelectable (bool selectable) override
 
virtual void doJavaScript (const std::string &javascript) override
 
virtual const std::string id () const override
 
void setLoadLaterWhenInvisible (bool)
 
std::string htmlTagName () const
 
void setHtmlTagName (const std::string &tag)
 
virtual void setCanReceiveFocus (bool enabled) override
 
virtual bool canReceiveFocus () const override
 
virtual bool setFirstFocus () override
 
virtual void setFocus (bool focus) override
 
virtual bool hasFocus () const override
 
virtual void setTabIndex (int index) override
 
virtual int tabIndex () const override
 
EventSignalblurred ()
 
EventSignalfocussed ()
 
virtual bool scrollVisibilityEnabled () const final override
 
virtual void setScrollVisibilityEnabled (bool enabled) final override
 
virtual int scrollVisibilityMargin () const final override
 
virtual void setScrollVisibilityMargin (int margin) final override
 
virtual Signal< bool > & scrollVisibilityChanged () final override
 
virtual bool isScrollVisible () const final override
 
virtual void setThemeStyleEnabled (bool enabled) final override
 
virtual bool isThemeStyleEnabled () const final override
 
virtual void setObjectName (const std::string &name) override
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
std::unique_ptr< WWidgetremoveFromParent ()
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation 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 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
void addChild (std::unique_ptr< WObject > child)
 
Child * addChild (std::unique_ptr< Child > child)
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 
std::unique_ptr< Child > removeChild (Child *child)
 
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)
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 
virtual ~observable ()
 
auto bindSafe (void(C::*method)(Args...)) noexcept
 
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 
auto bindSafe (const Function &function) noexcept
 

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) override
 
virtual RenderMethod getMethod () const
 
virtual std::unique_ptr< WPaintDevicecreatePaintDevice () const
 
virtual void enableAjax () override
 
virtual void render (WFlags< RenderFlag > flags) override
 
std::string objJsRef () const
 
- Protected Member Functions inherited from Wt::WInteractWidget
virtual void propagateSetEnabled (bool enabled) override
 
- Protected Member Functions inherited from Wt::WWebWidget
virtual WStatelessSlot * getStateless (Method method) override
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
 WWidget ()
 
virtual void dropEvent (WDropEvent dropEvent)
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
void scheduleRender (WFlags< RepaintFlag > flags=None)
 

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::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWebWidget
static std::string jsStringLiteral (const std::string &v, char delimiter='\'')
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 

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.

25  : WPaintedWidget(parent),
26  angle_(0),
27  size_(1)
28 {
29  resize(710, 400);
30 }
double size_
Definition: ShapesWidget.h:35
virtual void resize(const WLength &width, const WLength &height) override
double angle_
Definition: ShapesWidget.h:34

Member Function Documentation

◆ angle()

double ShapesWidget::angle ( ) const
inline

Definition at line 25 of file ShapesWidget.h.

25 { return angle_; }
double angle_
Definition: ShapesWidget.h:34

◆ drawEmwebE()

void ShapesWidget::drawEmwebE ( WPainter p)
private

Definition at line 67 of file ShapesWidget.C.

68 {
69  WPainterPath p;
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 cubicTo(const WPointF &c1, const WPointF &c2, const WPointF &endPoint)
void lineTo(const WPointF &point)
void moveTo(const WPointF &point)

◆ 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 drawEmwebE(WPainter &p)
Definition: ShapesWidget.C:67
void drawEmwebMW(WPainter &p)
Definition: ShapesWidget.C:97

◆ drawEmwebMW()

void ShapesWidget::drawEmwebMW ( WPainter p)
private

Definition at line 97 of file ShapesWidget.C.

98 {
99  WPainterPath p;
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 }
void cubicTo(const WPointF &c1, const WPointF &c2, const WPointF &endPoint)
void lineTo(const WPointF &point)
void moveTo(const WPointF &point)

◆ 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 }
double size_
Definition: ShapesWidget.h:35
virtual WLength height() const override
void drawEmwebLogo(WPainter &p)
Definition: ShapesWidget.C:145
virtual WLength width() const override
double angle_
Definition: ShapesWidget.h:34

◆ relativeSize()

double ShapesWidget::relativeSize ( ) const
inline

Definition at line 28 of file ShapesWidget.h.

28 { return size_; }
double size_
Definition: ShapesWidget.h:35

◆ 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 }
void update(WFlags< PaintFlag > flags=None)
double angle() const
Definition: ShapesWidget.h:25
double angle_
Definition: ShapesWidget.h:34

◆ 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 }
void update(WFlags< PaintFlag > flags=None)
double size_
Definition: ShapesWidget.h:35

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 Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13