Coverage Report

Created: 2025-07-23 06:40

/src/wt/src/Wt/WWebWidget.h
Line
Count
Source (jump to first uncovered line)
1
// This may look like C code, but it's really -*- C++ -*-
2
/*
3
 * Copyright (C) 2008 Emweb bv, Herent, Belgium.
4
 *
5
 * See the LICENSE file for terms of use.
6
 */
7
#ifndef WWEB_WIDGET_H_
8
#define WWEB_WIDGET_H_
9
10
#include <set>
11
#include <bitset>
12
13
#include <Wt/WString.h>
14
#include <Wt/WWidget.h>
15
#include <Wt/WEvent.h>
16
17
#ifdef WT_CNOR
18
#include <Wt/WJavaScript.h>
19
#endif // WT_CNOR
20
21
namespace Wt {
22
23
class WStringStream;
24
class WApplication;
25
26
/*! \brief Enumeration for a DOM element type.
27
 *
28
 * For internal use only.
29
 */
30
enum class DomElementType {
31
  A, BR, BUTTON, COL,
32
  COLGROUP,
33
  DIV, FIELDSET, FORM,
34
  H1, H2, H3, H4,
35
36
  H5, H6, IFRAME, IMG,
37
  INPUT, LABEL, LEGEND, LI,
38
  OL,
39
40
  OPTION, UL, SCRIPT, SELECT,
41
  SPAN, TABLE, TBODY, THEAD,
42
  TFOOT, TH, TD, TEXTAREA,
43
  OPTGROUP,
44
45
  TR, P, CANVAS,
46
  MAP, AREA, STYLE,
47
48
  OBJECT, PARAM,
49
50
  AUDIO, VIDEO, SOURCE,
51
52
  B, STRONG, EM, I, HR,
53
  DATALIST,
54
  UNKNOWN,
55
  OTHER
56
};
57
58
class WCssDecorationStyle;
59
class WContainerWidget;
60
class DomElement;
61
62
#ifndef WT_CNOR
63
template <typename... A> class JSignal;
64
#endif
65
66
#ifdef WT_TARGET_JAVA
67
struct HandleWidgetMethod {
68
  HandleWidgetMethod();
69
  HandleWidgetMethod(void (*)(WWidget*));
70
  void handle(WWidget *) const;
71
};
72
#endif // WT_TARGET_JAVA
73
74
/*! \class WWebWidget Wt/WWebWidget.h Wt/WWebWidget.h
75
 *  \brief A base class for widgets with an HTML counterpart.
76
 *
77
 * All descendants of %WWebWidget implement a widget which corresponds
78
 * almost one-on-one with an HTML element. These widgets provide most
79
 * capabilities of these HTML elements, but rarely make no attempt to
80
 * do anything more.
81
 *
82
 * \sa WCompositeWidget
83
 */
84
class WT_API WWebWidget : public WWidget
85
{
86
public:
87
  /*! \brief Construct a WebWidget.
88
   */
89
  WWebWidget();
90
  virtual ~WWebWidget() override;
91
92
  virtual std::vector<WWidget *> children() const override;
93
94
  /*! \brief %Signal emitted when children have been added or removed.
95
   *
96
   * \sa children()
97
   */
98
  Signal<>& childrenChanged();
99
100
  virtual void setPositionScheme(PositionScheme scheme) override;
101
  virtual PositionScheme positionScheme() const override;
102
  virtual void setOffsets(const WLength& offset,
103
                          WFlags<Side> sides = AllSides) override;
104
  virtual WLength offset(Side s) const override;
105
  virtual void resize(const WLength& width, const WLength& height) override;
106
  virtual WLength width() const override;
107
  virtual WLength height() const override;
108
  virtual void setMinimumSize(const WLength& width, const WLength& height) override;
109
  virtual WLength minimumWidth() const override;
110
  virtual WLength minimumHeight() const override;
111
  virtual void setMaximumSize(const WLength& width, const WLength& height) override;
112
  virtual WLength maximumWidth() const override;
113
  virtual WLength maximumHeight() const override;
114
  virtual void setLineHeight(const WLength& height) override;
115
  virtual WLength lineHeight() const override;
116
  virtual void setFloatSide(Side s) override;
117
  virtual Side floatSide() const override;
118
  virtual void setClearSides(WFlags<Side> sides) override;
119
  virtual WFlags<Side> clearSides() const override;
120
  virtual void setMargin(const WLength& margin, WFlags<Side> sides = AllSides)
121
    override;
122
  virtual WLength margin(Side side) const override;
123
  virtual void setHiddenKeepsGeometry(bool enabled) override;
124
  virtual bool hiddenKeepsGeometry() const override;
125
  virtual void setHidden(bool hidden, const WAnimation& animation = WAnimation()) override;
126
  virtual bool isHidden() const override;
127
  virtual bool isVisible() const override;
128
  virtual void setDisabled(bool disabled) override;
129
  virtual bool isDisabled() const override;
130
  virtual bool isEnabled() const override;
131
  virtual void setPopup(bool popup) override;
132
  virtual bool isPopup() const override;
133
  virtual void setInline(bool isInline) override;
134
  virtual bool isInline() const override;
135
  virtual void setDecorationStyle(const WCssDecorationStyle& style) override;
136
  virtual WCssDecorationStyle& decorationStyle() override;
137
  virtual const WCssDecorationStyle& decorationStyle() const override;
138
  virtual void setStyleClass(const WT_USTRING& styleClass) override;
139
  void setStyleClass(const char *styleClass);
140
  virtual WT_USTRING styleClass() const override;
141
  virtual void addStyleClass(const WT_USTRING& styleClass,
142
                             bool force = false) override;
143
  void addStyleClass(const char *styleClass, bool force = false);
144
  virtual void removeStyleClass(const WT_USTRING& styleClass,
145
                                bool force = false) override;
146
  void removeStyleClass(const char *styleClass, bool force = false);
147
  virtual bool hasStyleClass(const WT_USTRING& styleClass) const override;
148
  virtual void setVerticalAlignment(AlignmentFlag alignment,
149
                                    const WLength& length = WLength()) override;
150
  virtual AlignmentFlag verticalAlignment() const override;
151
  virtual WLength verticalAlignmentLength() const override;
152
  virtual void setToolTip(const WString& text,
153
                          TextFormat textFormat = TextFormat::Plain)
154
    override;
155
  virtual void setDeferredToolTip(bool enable,
156
                                  TextFormat textFormat = TextFormat::Plain)
157
    override;
158
  virtual WString toolTip() const override;
159
  /*! \brief Enable/disable whether tooltip is shown on hover
160
  
161
   * Allow to enable or disable whether the tooltip is shown when the 
162
   * WWebWidget is hovered over by the mouse.
163
   * 
164
   * \sa showToolTip(), hideToolTip()
165
   */
166
  void showToolTipOnHover(bool enable);
167
168
  /*! \brief Force tooltip to show.
169
   * 
170
   * When called, show the tooltip to the user until hideToolTip()
171
   * is called.
172
   * 
173
   * \sa hideToolTip()
174
   */
175
  void showToolTip();
176
177
  /*! \brief Hide the tooltip.
178
   * 
179
   * \sa showToolTip()
180
   */
181
  void hideToolTip();
182
183
  virtual void refresh() override;
184
  virtual void setAttributeValue(const std::string& name,
185
                                 const WT_USTRING& value) override;
186
  virtual WT_USTRING attributeValue(const std::string& name) const override;
187
  virtual void setJavaScriptMember(const std::string& name,
188
                                   const std::string& value) override;
189
  virtual std::string javaScriptMember(const std::string& name) const override;
190
  virtual void callJavaScriptMember(const std::string& name,
191
                                    const std::string& args) override;
192
  virtual void load() override;
193
  virtual bool loaded() const override;
194
  virtual int zIndex() const override;
195
196
  virtual void setId(const std::string& id) override;
197
  virtual WWidget *find(const std::string& name) override;
198
  virtual WWidget *findById(const std::string& id) override;
199
  virtual void setSelectable(bool selectable) override;
200
  virtual void doJavaScript(const std::string& javascript) override;
201
  virtual const std::string id() const override;
202
203
#ifdef WT_TARGET_JAVA
204
  /*! \brief Create DOM element for widget
205
   *
206
   * This is an internal function, and should not be called directly,
207
   * or be overridden!
208
   */
209
#endif
210
  virtual DomElement *createDomElement(WApplication *app);
211
#ifdef WT_TARGET_JAVA
212
  /*! \brief Get DOM changes for this widget
213
   *
214
   * This is an internal function, and should not be called directly,
215
   * or be overridden!
216
   */
217
#endif
218
  virtual void getDomChanges(std::vector<DomElement *>& result,
219
                             WApplication *app);
220
  virtual DomElementType domElementType() const = 0;
221
222
  DomElement *createStubElement(WApplication *app);
223
  DomElement *createActualElement(WWidget *self, WApplication *app);
224
225
  /*! \brief Change the way the widget is loaded when invisible.
226
   *
227
   * By default, invisible widgets are loaded only after visible content.
228
   * For tiny widgets this may lead to a performance loss, instead of the
229
   * expected increase, because they require many more DOM manipulations
230
   * to render, reducing the overall responsiveness of the application.
231
   *
232
   * Therefore, this is disabled for some widgets like WImage, or
233
   * empty WContainerWidgets.
234
   *
235
   * You may also want to disable deferred loading when JavaScript event
236
   * handling expects the widget to be loaded.
237
   *
238
   * Usually the default settings are fine, but you may want to change
239
   * the behaviour.
240
   *
241
   * \sa WApplication::setTwoPhaseRenderingThreshold()
242
   */
243
  void setLoadLaterWhenInvisible(bool);
244
245
  /*!
246
   * \brief returns the current html tag name
247
   *
248
   * \sa setHtmlTagName()
249
   */
250
  std::string htmlTagName() const;
251
252
  /*!
253
   * \brief set the custom HTML tag name
254
   *
255
   * The custom tag will replace the actual tag.
256
   * The tag is not tested to see if
257
   * it is a valid one and a closing tag will always be added.
258
   *
259
   * \sa htmlTagName()
260
   */
261
  void setHtmlTagName(const std::string & tag);
262
263
  static WString escapeText(const WString& text, bool newlinesToo = false);
264
  static std::string& escapeText(std::string& text, bool newlinestoo = false);
265
  static std::string& unescapeText(std::string& text);
266
#ifdef WT_TARGET_JAVA
267
  static std::string& doUnescapeText(std::string& text);
268
#endif // WT_TARGET_JAVA
269
  static bool removeScript(WString& text);
270
271
  /*! \brief Turn a CharEncoding::UTF8 encoded string into a JavaScript string literal
272
   *
273
   * The \p delimiter may be a single or double quote.
274
   */
275
  static std::string jsStringLiteral(const std::string& v,
276
                                     char delimiter = '\'');
277
  static std::string jsStringLiteral(const WString& v,
278
                                     char delimiter = '\'');
279
280
  static std::string resolveRelativeUrl(const std::string& url);
281
282
  void setFormObject(bool how);
283
  static bool canOptimizeUpdates();
284
  void setZIndex(int zIndex);
285
286
  bool isRendered() const;
287
288
  virtual void setCanReceiveFocus(bool enabled) override;
289
  virtual bool canReceiveFocus() const override;
290
  virtual bool setFirstFocus() override;
291
  virtual void setFocus(bool focus) override;
292
  virtual bool hasFocus() const override;
293
  virtual void setTabIndex(int index) override;
294
  virtual int tabIndex() const override;
295
296
  /*! \brief %Signal emitted when the widget lost focus.
297
   *
298
   * This signals is only emitted for a widget that canReceiveFocus()
299
   */
300
  EventSignal<>& blurred();
301
302
  /*! \brief %Signal emitted when the widget recieved focus.
303
   *
304
   * This signals is only emitted for a widget that canReceiveFocus()
305
   */
306
  EventSignal<>& focussed();
307
308
#ifndef WT_TARGET_JAVA
309
  using WWidget::setFocus;
310
#endif
311
312
  virtual bool scrollVisibilityEnabled() const final override;
313
  virtual void setScrollVisibilityEnabled(bool enabled) final override;
314
  virtual int scrollVisibilityMargin() const final override;
315
  virtual void setScrollVisibilityMargin(int margin) final override;
316
  virtual Signal<bool> &scrollVisibilityChanged() final override;
317
  virtual bool isScrollVisible() const final override;
318
319
  virtual void setThemeStyleEnabled(bool enabled) final override;
320
  virtual bool isThemeStyleEnabled() const final override;
321
322
  virtual void setObjectName(const std::string& name) override;
323
324
  virtual int baseZIndex() const final override;
325
  void setBaseZIndex(int zIndex);
326
327
protected:
328
  typedef std::map<std::string, WObject *> FormObjectsMap;
329
#ifndef WT_TARGET_JAVA
330
  typedef std::function<void (WWidget *)> HandleWidgetMethod;
331
#endif
332
333
  void repaint(WFlags<RepaintFlag> flags = None);
334
335
  virtual void iterateChildren(const HandleWidgetMethod& method) const;
336
  virtual void getFormObjects(FormObjectsMap& formObjects);
337
  virtual void doneRerender();
338
  virtual void updateDom(DomElement& element, bool all);
339
  virtual bool domCanBeSaved() const;
340
  virtual void propagateRenderOk(bool deep = true);
341
  virtual std::string renderRemoveJs(bool recursive) override;
342
343
  virtual void propagateSetEnabled(bool enabled) override;
344
  virtual void propagateSetVisible(bool visible) override;
345
  virtual bool isStubbed() const override;
346
  virtual void enableAjax() override;
347
348
  virtual void setHideWithOffsets(bool how = true) override;
349
  virtual WStatelessSlot *getStateless(Method method) override;
350
351
  WWidget *selfWidget();
352
353
  void doLoad(WWidget *w);
354
  void widgetAdded(WWidget *child);
355
  void widgetRemoved(WWidget *child, bool renderRemove);
356
357
#ifndef WT_TARGET_JAVA
358
  template <class Widget>
359
  std::unique_ptr<WWidget> manageWidget(std::unique_ptr<Widget>& managed,
360
                                        std::unique_ptr<Widget> w)
361
#else // WT_TARGET_JAVA
362
  std::unique_ptr<WWidget> manageWidget(std::unique_ptr<WWidget> managed, std::unique_ptr<WWidget> w)
363
#endif // WT_TARGET_JAVA
364
0
  {
365
0
    if (managed)
366
0
      widgetRemoved(managed.get(), true);
367
0
    std::unique_ptr<WWidget> result = std::move(managed);
368
0
    managed = std::move(w);
369
0
    if (managed)
370
0
      widgetAdded(managed.get());
371
0
    return result;
372
0
  }
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::Impl::MapWidget>(std::unique_ptr<Wt::Impl::MapWidget, std::default_delete<Wt::Impl::MapWidget> >&, std::unique_ptr<Wt::Impl::MapWidget, std::default_delete<Wt::Impl::MapWidget> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::WText>(std::unique_ptr<Wt::WText, std::default_delete<Wt::WText> >&, std::unique_ptr<Wt::WText, std::default_delete<Wt::WText> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::WImage>(std::unique_ptr<Wt::WImage, std::default_delete<Wt::WImage> >&, std::unique_ptr<Wt::WImage, std::default_delete<Wt::WImage> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::WWidget>(std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> >&, std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::WProgressBar>(std::unique_ptr<Wt::WProgressBar, std::default_delete<Wt::WProgressBar> >&, std::unique_ptr<Wt::WProgressBar, std::default_delete<Wt::WProgressBar> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::WInteractWidget>(std::unique_ptr<Wt::WInteractWidget, std::default_delete<Wt::WInteractWidget> >&, std::unique_ptr<Wt::WInteractWidget, std::default_delete<Wt::WInteractWidget> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::PaintedSlider>(std::unique_ptr<Wt::PaintedSlider, std::default_delete<Wt::PaintedSlider> >&, std::unique_ptr<Wt::PaintedSlider, std::default_delete<Wt::PaintedSlider> >)
Unexecuted instantiation: std::unique_ptr<Wt::WWidget, std::default_delete<Wt::WWidget> > Wt::WWebWidget::manageWidget<Wt::TickList>(std::unique_ptr<Wt::TickList, std::default_delete<Wt::TickList> >&, std::unique_ptr<Wt::TickList, std::default_delete<Wt::TickList> >)
373
374
  virtual void render(WFlags<RenderFlag> flags) override;
375
376
  virtual void signalConnectionsChanged() override;
377
378
  void beingDeleted();
379
380
private:
381
  /*
382
   * Booleans packed in a bitset.
383
   */
384
  static const int BIT_INLINE = 0;
385
  static const int BIT_HIDDEN = 1;
386
  static const int BIT_LOADED = 2;
387
  static const int BIT_RENDERED = 3;
388
  static const int BIT_STUBBED = 4;
389
  static const int BIT_FORM_OBJECT = 5;
390
  static const int BIT_FLEX_BOX = 6;
391
  static const int BIT_FLEX_BOX_CHANGED = 7;
392
  static const int BIT_GEOMETRY_CHANGED = 8;
393
  static const int BIT_HIDE_WITH_OFFSETS = 9;
394
  static const int BIT_BEING_DELETED = 10;
395
  static const int BIT_DONOT_STUB = 11;
396
  static const int BIT_FLOAT_SIDE_CHANGED = 12;
397
  static const int BIT_REPAINT_TO_AJAX = 13;
398
  static const int BIT_HIDE_WITH_VISIBILITY = 14;
399
  static const int BIT_HIDDEN_CHANGED = 15;
400
  static const int BIT_ENABLED = 16; // caches isEnabled() for WInteractWidget
401
  static const int BIT_TOOLTIP_CHANGED = 17;
402
  static const int BIT_MARGINS_CHANGED = 18;
403
  static const int BIT_STYLECLASS_CHANGED = 19;
404
  static const int BIT_SET_UNSELECTABLE = 20;
405
  static const int BIT_SET_SELECTABLE = 21;
406
  static const int BIT_SELECTABLE_CHANGED = 22;
407
  static const int BIT_WIDTH_CHANGED = 23;
408
  static const int BIT_HEIGHT_CHANGED = 24;
409
  static const int BIT_DISABLED = 25;
410
  static const int BIT_DISABLED_CHANGED = 26;
411
  static const int BIT_CONTAINS_LAYOUT = 27;
412
  static const int BIT_ZINDEX_CHANGED = 28;
413
  static const int BIT_TOOLTIP_DEFERRED = 29;
414
  static const int BIT_GOT_FOCUS        = 30;
415
  static const int BIT_TABINDEX_CHANGED = 31;
416
  static const int BIT_SCROLL_VISIBILITY_ENABLED = 32;
417
  // BIT_SCROLL_VISIBILITY_LOADED makes sure that scrollVisibility.remove is never
418
  // called for widgets that never had scroll visibility enabled
419
  static const int BIT_SCROLL_VISIBILITY_LOADED = 33;
420
  static const int BIT_IS_SCROLL_VISIBLE = 34; // tracks whether the widget is currently "scroll visible"
421
  // Tracks whether scroll visibility is enabled/disabled, and whether the
422
  // scroll visibility margin has been modified.
423
  static const int BIT_SCROLL_VISIBILITY_CHANGED = 35;
424
  static const int BIT_THEME_STYLE_DISABLED = 36;
425
  static const int BIT_OBJECT_NAME_CHANGED = 37;
426
  static const int BIT_PARENT_CHANGED = 38;
427
428
  static const int BIT_TOOLTIP_FORCE_SHOW = 39;
429
  static const int BIT_TOOLTIP_CLEAN_FORCE_SHOW = 40;
430
  static const int BIT_TOOLTIP_SHOW_ON_HOVER = 41;
431
432
433
  static const char *FOCUS_SIGNAL;
434
  static const char *BLUR_SIGNAL;
435
436
  static const int DEFAULT_BASE_Z_INDEX;
437
  static const int Z_INDEX_INCREMENT;
438
439
  std::string elementTagName_;
440
441
#ifndef WT_TARGET_JAVA
442
  static const std::bitset<42> AllChangeFlags;
443
#endif // WT_TARGET_JAVA
444
445
  void loadToolTip();
446
447
  /*
448
   * Frequently used attributes.
449
   */
450
  std::bitset<42> flags_;
451
  std::unique_ptr<WLength> width_;
452
  std::unique_ptr<WLength> height_;
453
454
  /*
455
   * id_ is separate instead of in OtherImpl,
456
   * because it is accessed when OtherImpl is being destroyed,
457
   * from the destructor of jsScrollVisibilityChanged_
458
   */
459
  std::unique_ptr<std::string> id_;
460
461
  /*
462
   * Data only stored transiently, during event handling.
463
   */
464
  struct TransientImpl {
465
    std::vector<std::string> childRemoveChanges_;
466
    std::vector<WT_USTRING> addedStyleClasses_, removedStyleClasses_;
467
    std::vector<std::string> attributesSet_;
468
469
    int addedChildren_;
470
    bool specialChildRemove_;
471
    WAnimation animation_;
472
473
    TransientImpl();
474
    ~TransientImpl();
475
  };
476
477
  std::unique_ptr<TransientImpl> transientImpl_;
478
479
  struct LayoutImpl {
480
    PositionScheme positionScheme_;
481
    Side floatSide_;
482
    WFlags<Side> clearSides_;
483
    WLength offsets_[4]; // left, right, top, bottom
484
    WLength minimumWidth_, minimumHeight_, maximumWidth_, maximumHeight_;
485
    int baseZIndex_;
486
    int        zIndex_; // -1 = wants popup
487
    AlignmentFlag verticalAlignment_;
488
    WLength verticalAlignmentLength_, margin_[4], lineHeight_;
489
490
    LayoutImpl();
491
  };
492
493
  std::unique_ptr<LayoutImpl> layoutImpl_;
494
495
  struct LookImpl {
496
    std::unique_ptr<WCssDecorationStyle> decorationStyle_;
497
    WT_USTRING styleClass_;
498
    std::unique_ptr<WString> toolTip_;
499
    TextFormat toolTipTextFormat_;
500
    JSignal<> loadToolTip_;
501
502
    LookImpl(WWebWidget *w);
503
    ~LookImpl();
504
  };
505
506
  mutable std::unique_ptr<LookImpl> lookImpl_;
507
508
  struct DropMimeType {
509
    WT_USTRING hoverStyleClass;
510
511
    DropMimeType();
512
    DropMimeType(const WT_USTRING& hoverStyleClass);
513
  };
514
515
  enum class JavaScriptStatementType {
516
    SetMember,
517
    CallMethod,
518
    Statement
519
  };
520
521
  struct OtherImpl {
522
    struct Member {
523
      std::string name;
524
      std::string value;
525
    };
526
527
    struct JavaScriptStatement {
528
      JavaScriptStatement(JavaScriptStatementType type,
529
                          const std::string& data);
530
531
      JavaScriptStatementType type;
532
      std::string data;
533
    };
534
535
    std::unique_ptr<std::string> elementTagName_;
536
    std::unique_ptr<std::map<std::string, WT_USTRING> > attributes_;
537
    std::unique_ptr<std::vector<Member> > jsMembers_;
538
    std::unique_ptr<std::vector<JavaScriptStatement> > jsStatements_;
539
    std::unique_ptr<JSignal<int, int> > resized_;
540
    int tabIndex_;
541
542
    // drag source id, drag mime type
543
    std::unique_ptr<JSignal<std::string, std::string, WMouseEvent> > dropSignal_;
544
    std::unique_ptr<JSignal<std::string, std::string, WTouchEvent> > dropSignal2_;
545
546
    typedef std::map<std::string, DropMimeType> MimeTypesMap;
547
    std::unique_ptr<MimeTypesMap> acceptedDropMimeTypes_;
548
    Signal<> childrenChanged_;
549
550
    int scrollVisibilityMargin_;
551
    Signal<bool> scrollVisibilityChanged_;
552
    std::unique_ptr<JSignal<bool> > jsScrollVisibilityChanged_;
553
554
    OtherImpl(WWebWidget *const self);
555
    ~OtherImpl();
556
  };
557
558
  std::unique_ptr<OtherImpl> otherImpl_;
559
560
  void renderOk();
561
  void calcZIndex();
562
563
  virtual bool needsToBeRendered() const override;
564
  virtual void getSDomChanges(std::vector<DomElement *>& result,
565
                              WApplication *app) override;
566
  void getSFormObjects(FormObjectsMap& formObjects);
567
568
  WWebWidget *parentWebWidget() const;
569
570
  /*
571
   * Drag & drop stuff.
572
   */
573
  bool setAcceptDropsImpl(const std::string& mimeType,
574
                          bool accept,
575
                          const WT_USTRING& hoverStyleClass);
576
  void setImplementLayoutSizeAware(bool aware);
577
  JSignal<int, int>& resized();
578
579
  void addJavaScriptStatement(JavaScriptStatementType type,
580
                              const std::string& data);
581
  int indexOfJavaScriptMember(const std::string& name) const;
582
  void declareJavaScriptMember(DomElement& element,
583
                               const std::string& name,
584
                               const std::string& value);
585
  WString storedToolTip() const;
586
  void undoSetFocus();
587
588
  void jsScrollVisibilityChanged(bool visible);
589
590
  void emitChildrenChanged();
591
592
protected:
593
  virtual void setParentWidget(WWidget *parent) override;
594
  void setRendered(bool rendered);
595
596
  void setId(DomElement *element, WApplication *app);
597
0
  virtual WWebWidget *webWidget() override { return this; }
598
599
  EventSignal<> *voidEventSignal(const char *name, bool create);
600
  EventSignal<WKeyEvent> *keyEventSignal(const char *name, bool create);
601
  EventSignal<WMouseEvent> *mouseEventSignal(const char *name, bool create);
602
  EventSignal<WScrollEvent> *scrollEventSignal(const char *name, bool create);
603
  EventSignal<WTouchEvent> *touchEventSignal(const char *name, bool create);
604
  EventSignal<WGestureEvent> *gestureEventSignal(const char *name, bool create);
605
606
  void updateSignalConnection(DomElement& element, EventSignalBase& signal,
607
                              const char *name, bool all);
608
609
  virtual void parentResized(WWidget *parent, WFlags<Orientation> directions);
610
  void containsLayout();
611
  void setFlexBox(bool enabled);
612
613
  /*
614
   * WWebWidget ended up with more friends than me...
615
   */
616
  friend class WebRenderer;
617
  friend class WebSession;
618
619
  friend class WApplication;
620
  friend class WCompositeWidget;
621
  friend class WContainerWidget;
622
  friend class WCssDecorationStyle;
623
  friend class WCssTemplateRule;
624
  friend class WDateEdit;
625
  friend class WDialog;
626
  friend class WFont;
627
  friend class WGLWidget;
628
  friend class WInteractWidget;
629
  friend class WLeafletMap;
630
  friend class JSlot;
631
  friend class WTable;
632
  friend class WViewWidget;
633
  friend class WWidget;
634
  friend class WTemplate;
635
  friend class WWidgetItem;
636
  friend class FlexLayoutImpl;
637
};
638
639
}
640
641
#endif // WWEB_WIDGET_H_