Coverage Report

Created: 2025-07-23 06:40

/src/wt/src/Wt/StdLayoutImpl.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 STD_LAYOUT_IMPL_H_
8
#define STD_LAYOUT_IMPL_H_
9
10
#include "StdLayoutItemImpl.h"
11
#include "Wt/WLayoutImpl.h"
12
13
namespace Wt {
14
15
class WLayout;
16
17
/*! \class StdLayoutImpl Wt/StdLayoutImpl.h Wt/StdLayoutImpl.h
18
 *  \brief An abstract base class for implementing layout managers.
19
 *  
20
 * \sa StdLayoutItemImpl, WLayout
21
 */
22
class WT_API StdLayoutImpl : public StdLayoutItemImpl, public WLayoutImpl
23
{
24
public:
25
  /*! \brief Constructor.
26
   * 
27
   * Creates a new StdLayoutImpl for the given WLayout.
28
   */
29
  StdLayoutImpl(WLayout *layout);
30
31
  /*! \brief Destructor.
32
   */
33
  virtual ~StdLayoutImpl();
34
35
  /*! \brief Updates the DomElements in the WLayout.
36
   * 
37
   * This function should update the DomElements in the WLayout. This
38
   * means creating DomElements for newly added StdLayoutItemImpl,
39
   * deleting DomElements from deleted StdLayoutItemImpl and updating
40
   * the placement and size of the DomElements.
41
   */
42
  virtual void updateDom(DomElement& parent) = 0;
43
44
  /*! \brief Called when a WLayoutItem in the WLayout is resized.
45
   * 
46
   * When a WLayoutItem is resized, it may be necessary to update the
47
   * whole layout. Items may have moved in such a way, that it would
48
   * push other items of screen, requiring other items to adapt to it.
49
   * 
50
   * If it returns \p true, a subsequent updateDom() may be necessary.
51
   * 
52
   * \sa WContainerWidget::updateDomChildren()
53
   */
54
  virtual bool itemResized(WLayoutItem *item) = 0;
55
56
  /*! \brief Called when the parent is resized.
57
   * 
58
   * When the parent is resized, it may be necessary to update the whole
59
   * layout. More or less items could not potentially fit in the layout, 
60
   * or the layout's boundaries may have changed.
61
   * 
62
   * If it returns \p true, a subsequent updateDom() may be necessary.
63
   * 
64
   * \sa updateDom(), WContainerWidget::parentResized()
65
   */
66
  virtual bool parentResized() = 0;
67
68
  //! Returns the WLayout as a WLayoutItem.
69
  WLayoutItem *layoutItem() const override;
70
71
  /*! \brief Updates the layout.
72
   * 
73
   * By default, this will trigger a call to updateDom().
74
   * 
75
   * \note Several calls to update() may happens before updateDom() is
76
   * called.
77
   * 
78
   * \sa updateDom()
79
   */
80
  void update() override;
81
82
protected:
83
84
  //! Returns the WLayout.
85
0
  WLayout *layout() const { return layout_; }
86
87
  /*! \brief Returns a WLayoutItem implementation.
88
   * 
89
   * Returns a WLayoutItem implementation if the implementation is a
90
   * subclass of StdLayoutItemImpl. Otherwise returns \p nullptr.
91
   */
92
  static StdLayoutItemImpl *getImpl(WLayoutItem *item);
93
94
private:
95
  WLayout *layout_;
96
};
97
98
}
99
100
#endif // STD_LAYOUT_IMPL_H_