Wt examples  4.10.4
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:
[legend]

Public Member Functions

 ShapesWidget ()
 
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
 
void setFocus ()
 
virtual void setFocus (bool focus)=0
 
- 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) override
 
- 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 ( )

Definition at line 25 of file ShapesWidget.C.

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

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 68 of file ShapesWidget.C.

69 {
70  WPainterPath p;
71 
72  /* Path copied from our SVG for half of the E */
73 
74  p.moveTo(46.835084,58.783624);
75  p.cubicTo(45.700172,58.783624,35.350098,58.911502,24.656354,63.283309);
76  p.cubicTo(8.7595992,69.78907,0,82.38499,0,98.809238);
77  p.cubicTo(0,115.20152,08.7595992,127.82141,24.656354,134.31119);
78  p.cubicTo(35.350098,138.69099,45.700172,138.81088,46.835084,138.81088);
79  p.lineTo(94.509362,138.81088);
80  p.lineTo(94.509362,117.58323);
81  p.lineTo(46.835084,117.58323);
82  p.cubicTo(46.811106,117.58323,39.466151,117.47134,32.608727,114.53815);
83  p.cubicTo(25.095932,111.34122,21.747144,106.47389,21.747144,98.809238);
84  p.cubicTo(21.747144,91.120612,25.095932,86.269265,32.608727,83.064338);
85  p.cubicTo(39.466151,80.123159,46.811106,80.027251,46.89103,80.027251);
86  p.lineTo(94.509362,80.027251);
87  p.lineTo(94.509362,58.783624);
88  p.lineTo(46.835084,58.783624);
89 
90  painter.drawPath(p);
91 
92  painter.save();
93  painter.translate(0,-58.783624);
94  painter.drawPath(p);
95  painter.restore();
96 }
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 146 of file ShapesWidget.C.

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

◆ drawEmwebMW()

void ShapesWidget::drawEmwebMW ( WPainter p)
private

Definition at line 98 of file ShapesWidget.C.

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

◆ paintEvent()

void ShapesWidget::paintEvent ( WPaintDevice paintDevice)
overrideprotectedvirtual

Implements Wt::WPaintedWidget.

Definition at line 53 of file ShapesWidget.C.

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

◆ 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 33 of file ShapesWidget.C.

34 {
35  angle = std::max(-30.0, std::min(30.0, angle));
36 
37  if (angle_ != angle) {
38  angle_ = angle;
39  update();
40  }
41 }
double angle() const
Definition: ShapesWidget.h:25
void update(WFlags< PaintFlag > flags=None)

◆ setRelativeSize()

void ShapesWidget::setRelativeSize ( double  size)

Definition at line 43 of file ShapesWidget.C.

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

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: