Dillo
oofawarewidget.hh
Go to the documentation of this file.
1 #ifndef __DW_OOFAWAREWIDGET_HH__
2 #define __DW_OOFAWAREWIDGET_HH__
3 
4 #include "core.hh"
5 #include "outofflowmgr.hh"
6 
7 namespace dw {
8 
9 namespace oof {
10 
78 {
79 protected:
81  static const char *OOFM_NAME[NUM_OOFM];
84 
86  {
87  private:
88  enum { NUM_SECTIONS = NUM_OOFM + 1 };
89  int sectionIndex; // 0 means in flow, otherwise OOFM index + 1
90  int index;
91 
92  int numParts (int sectionIndex, int numContentsInFlow = -1);
93  void getPart (int sectionIndex, int index, core::Content *content);
94 
95  protected:
96  virtual int numContentsInFlow () = 0;
97  virtual void getContentInFlow (int index, core::Content *content) = 0;
98 
99  void setValues (int sectionIndex, int index);
100  inline void cloneValues (OOFAwareWidgetIterator *other)
101  { other->setValues (sectionIndex, index); }
102 
103  inline bool inFlow () { return sectionIndex == 0; }
104  inline int getInFlowIndex () { assert (inFlow ()); return index; }
105  void highlightOOF (int start, int end, core::HighlightLayer layer);
106  void unhighlightOOF (int direction, core::HighlightLayer layer);
107  void getAllocationOOF (int start, int end, core::Allocation *allocation);
108 
109  public:
111  bool atEnd, int numContentsInFlow);
112 
115 
116  bool next ();
117  bool prev ();
118  };
119 
120  inline bool isParentRefOOF (int parentRef)
121  { return parentRef != -1 && (parentRef & PARENT_REF_OOFM_MASK); }
122 
123  inline int makeParentRefInFlow (int inFlowSubRef)
124  { return (inFlowSubRef << PARENT_REF_OOFM_BITS); }
126  { assert (!isParentRefOOF (parentRef));
127  return parentRef >> PARENT_REF_OOFM_BITS; }
128 
129  inline int makeParentRefOOF (int oofmIndex, int oofmSubRef)
130  { return (oofmSubRef << PARENT_REF_OOFM_BITS) | (oofmIndex + 1); }
132  { assert (isParentRefOOF (parentRef));
133  return parentRef >> PARENT_REF_OOFM_BITS; }
135  { assert (isParentRefOOF (parentRef));
136  return (parentRef & PARENT_REF_OOFM_MASK) - 1; }
138  { return outOfFlowMgr[getParentRefOOFIndex (parentRef)]; }
139 
140  inline bool isWidgetOOF (Widget *widget)
141  { return isParentRefOOF (widget->parentRef); }
142 
143  inline int getWidgetInFlowSubRef (Widget *widget)
144  { return getParentRefInFlowSubRef (widget->parentRef); }
145 
146  inline int getWidgetOOFSubRef (Widget *widget)
147  { return getParentRefOOFSubRef (widget->parentRef); }
148  inline int getWidgetOOFIndex (Widget *widget)
149  { return getParentRefOOFIndex (widget->parentRef); }
151  { return getParentRefOutOfFlowMgr (widget->parentRef); }
152 
156 
157  inline OutOfFlowMgr *searchOutOfFlowMgr (int oofmIndex)
158  { return oofContainer[oofmIndex] ?
159  oofContainer[oofmIndex]->outOfFlowMgr[oofmIndex] : NULL; }
160 
161  static int getOOFMIndex (Widget *widget);
162 
163  void initOutOfFlowMgrs ();
165  void (*splitHeightFun) (int, int*, int*));
168  void sizeAllocateEnd ();
170 
171  virtual void drawLevel (core::View *view, core::Rectangle *area, int level,
172  core::DrawingContext *context);
173  void drawOOF (core::View *view, core::Rectangle *area,
174  core::DrawingContext *context);
175 
176  Widget *getWidgetAtPoint (int x, int y,
178  virtual Widget *getWidgetAtPointLevel (int x, int y, int level,
180  *context);
181  Widget *getWidgetOOFAtPoint (int x, int y,
183 
184  static bool isOOFContainer (Widget *widget, int oofmIndex);
185 
186  void notifySetAsTopLevel();
187  void notifySetParent();
188 
189  void removeChild (Widget *child);
190 
192 
193 public:
194  enum {
197 
198  static int CLASS_ID;
199 
200  OOFAwareWidget ();
201  ~OOFAwareWidget ();
202 
203  static const char *stackingLevelText (int level);
204 
206  { return style->vloat != core::style::FLOAT_NONE; }
207 
209  { return IMPL_POS && style->position == core::style::POSITION_ABSOLUTE; }
211  { return IMPL_POS && style->position == core::style::POSITION_FIXED; }
213  { return IMPL_POS && style->position == core::style::POSITION_RELATIVE; }
214 
216  { return testStyleAbsolutelyPositioned (style) ||
218  testStyleFixedlyPositioned (style); }
219 
221  { // Second part is equivalent to testStylePositioned(), but we still keep
222  // the two seperately.
223  return testStyleFloat (style) || testStyleAbsolutelyPositioned (style)
225  || testStyleFixedlyPositioned (style); }
226 
227  static inline bool testWidgetFloat (Widget *widget)
228  { return testStyleFloat (widget->getStyle ()); }
229 
230  static inline bool testWidgetAbsolutelyPositioned (Widget *widget)
231  { return testStyleAbsolutelyPositioned (widget->getStyle ()); }
232  static inline bool testWidgetFixedlyPositioned (Widget *widget)
233  { return testStyleFixedlyPositioned (widget->getStyle ()); }
234  static inline bool testWidgetRelativelyPositioned (Widget *widget)
235  { return testStyleRelativelyPositioned (widget->getStyle ()); }
236 
237  static inline bool testWidgetPositioned (Widget *widget)
238  { return testStylePositioned (widget->getStyle ()); }
239 
240  static inline bool testWidgetOutOfFlow (Widget *widget)
241  { return testStyleOutOfFlow (widget->getStyle ()); }
242 
244  { return &requisitionWithoutOOF; }
245 
246  bool doesWidgetOOFInterruptDrawing (Widget *widget);
247 
248  void draw (core::View *view, core::Rectangle *area,
249  core::DrawingContext *context);
250 
254  virtual void updateReference (int ref);
255 
262  virtual void widgetRefSizeChanged (int externalIndex);
263 
267  virtual void clearPositionChanged ();
268 
273  virtual void oofSizeChanged (bool extremesChanged);
274 
279  virtual int getGeneratorX (int oofmIndex);
280 
285  virtual int getGeneratorY (int oofmIndex);
286 
296  virtual int getGeneratorWidth (int callerX, int callerWidth);
297 
298  virtual int getMaxGeneratorWidth ();
299 
300  virtual bool usesMaxGeneratorWidth ();
301 
302  virtual bool isPossibleOOFContainer (int oofmIndex);
303 
304  virtual bool isPossibleOOFContainerParent (int oofmIndex);
305 };
306 
307 } // namespace oof
308 
309 } // namespace dw
310 
311 #endif // __DW_OOFAWAREWIDGET_HH__
Content content
Definition: iterator.hh:26
bool isWidgetOOF(Widget *widget)
Definition: oofawarewidget.hh:140
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:146
Definition: oofawarewidget.hh:195
virtual bool adjustExtraSpaceWhenCorrectingRequisitionByOOF()
Definition: oofawarewidget.cc:616
static bool testStyleAbsolutelyPositioned(core::style::Style *style)
Definition: oofawarewidget.hh:208
Definition: style.hh:345
style::Style * style
Definition: widget.hh:130
void drawOOF(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: oofawarewidget.cc:447
Set at the top when getting the widget at the point.
Definition: types.hh:312
Definition: style.hh:347
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
int sectionIndex
Definition: oofawarewidget.hh:89
void removeChild(Widget *child)
Definition: oofawarewidget.cc:540
int getParentRefOOFSubRef(int parentRef)
Definition: oofawarewidget.hh:131
virtual void drawLevel(core::View *view, core::Rectangle *area, int level, core::DrawingContext *context)
Definition: oofawarewidget.cc:397
virtual int getMaxGeneratorWidth()
Definition: oofawarewidget.cc:594
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:140
Definition: oofawarewidget.hh:196
Widget * getWidgetAtPoint(int x, int y, core::GettingWidgetAtPointContext *context)
Definition: oofawarewidget.cc:456
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
Type
Definition: types.hh:199
virtual void oofSizeChanged(bool extremesChanged)
Definition: oofawarewidget.cc:563
int getWidgetOOFIndex(Widget *widget)
Definition: oofawarewidget.hh:148
void setValues(int sectionIndex, int index)
Definition: oofawarewidget_iterator.cc:55
Definition: oofawarewidget.hh:80
void correctRequisitionByOOF(core::Requisition *requisition, void(*splitHeightFun)(int, int *, int *))
Definition: oofawarewidget.cc:236
core::Requisition requisitionWithoutOOF
Definition: oofawarewidget.hh:155
OOFAwareWidget()
Definition: oofawarewidget.cc:43
virtual Widget * getWidgetAtPointLevel(int x, int y, int level, core::GettingWidgetAtPointContext *context)
Definition: oofawarewidget.cc:473
int index
Definition: oofawarewidget.hh:90
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: oofawarewidget.cc:386
void sizeAllocateEnd()
Definition: oofawarewidget.cc:350
OutOfFlowMgr * outOfFlowMgr[NUM_OOFM]
Definition: oofawarewidget.hh:154
FloatType vloat
Definition: style.hh:547
Instances of a sub class of may be compared (less, greater).
Definition: object.hh:41
Widget * getWidgetOOFAtPoint(int x, int y, core::GettingWidgetAtPointContext *context)
Definition: oofawarewidget.cc:526
oof::OutOfFlowMgr * getParentRefOutOfFlowMgr(int parentRef)
Definition: oofawarewidget.hh:137
virtual void clearPositionChanged()
Definition: oofawarewidget.cc:558
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
Definition: oofawarewidget.hh:195
int numParts(int sectionIndex, int numContentsInFlow=-1)
Definition: oofawarewidget_iterator.cc:69
OutOfFlowMgr * searchOutOfFlowMgr(int oofmIndex)
Definition: oofawarewidget.hh:157
bool extremesChanged()
Definition: widget.hh:440
virtual bool isPossibleOOFContainer(int oofmIndex)
Definition: oofawarewidget.cc:606
Definition: oofawarewidget.hh:196
Definition: oofawarewidget.hh:195
virtual int getGeneratorX(int oofmIndex)
Definition: oofawarewidget.cc:576
void notifySetParent()
This method is called after a widget has been added to a parent.
Definition: oofawarewidget.cc:185
int getParentRefInFlowSubRef(int parentRef)
Definition: oofawarewidget.hh:125
static const char * OOFM_NAME[NUM_OOFM]
Definition: oofawarewidget.hh:81
void getAllocationOOF(int start, int end, core::Allocation *allocation)
Definition: oofawarewidget_iterator.cc:238
Definition: oofawarewidget.hh:80
static const char * stackingLevelText(int level)
Definition: oofawarewidget.cc:71
virtual int getGeneratorWidth(int callerX, int callerWidth)
Definition: oofawarewidget.cc:588
int makeParentRefOOF(int oofmIndex, int oofmSubRef)
Definition: oofawarewidget.hh:129
static bool testStyleFixedlyPositioned(core::style::Style *style)
Definition: oofawarewidget.hh:210
core::Requisition * getRequisitionWithoutOOF()
Definition: oofawarewidget.hh:243
Definition: style.hh:613
int getParentRefOOFIndex(int parentRef)
Definition: oofawarewidget.hh:134
Definition: oofawarewidget.hh:196
static bool isOOFContainer(Widget *widget, int oofmIndex)
Definition: oofawarewidget.cc:127
void initOutOfFlowMgrs()
Definition: oofawarewidget.cc:205
int getWidgetInFlowSubRef(Widget *widget)
Definition: oofawarewidget.hh:143
void getPart(int sectionIndex, int index, core::Content *content)
Definition: oofawarewidget_iterator.cc:94
Definition: types.hh:172
void containerSizeChangedForChildrenOOF()
Definition: oofawarewidget.cc:357
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
int getWidgetOOFSubRef(Widget *widget)
Definition: oofawarewidget.hh:146
int makeParentRefInFlow(int inFlowSubRef)
Definition: oofawarewidget.hh:123
bool doesWidgetOOFInterruptDrawing(Widget *widget)
Definition: oofawarewidget.cc:364
oof::OutOfFlowMgr * getWidgetOutOfFlowMgr(Widget *widget)
Definition: oofawarewidget.hh:150
int compareTo(lout::object::Comparable *other)
Compare two objects, this and other.
Definition: oofawarewidget_iterator.cc:118
static bool testWidgetRelativelyPositioned(Widget *widget)
Definition: oofawarewidget.hh:234
void sizeAllocateStart(core::Allocation *allocation)
Definition: oofawarewidget.cc:342
OOFAwareWidget * oofContainer[NUM_OOFM]
Definition: oofawarewidget.hh:153
static bool testWidgetOutOfFlow(Widget *widget)
Definition: oofawarewidget.hh:240
The base class of all dillo widgets.
Definition: widget.hh:23
Set at the top when drawing.
Definition: types.hh:294
static bool testWidgetFloat(Widget *widget)
Definition: oofawarewidget.hh:227
Represents additional data for OOF containers.
Definition: outofflowmgr.hh:18
void intoStringBuffer(lout::misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: oofawarewidget_iterator.cc:109
bool isParentRefOOF(int parentRef)
Definition: oofawarewidget.hh:120
static bool testStyleFloat(core::style::Style *style)
Definition: oofawarewidget.hh:205
Definition: types.hh:197
virtual int getGeneratorY(int oofmIndex)
Definition: oofawarewidget.cc:582
bool next()
Move iterator forward and store content it.
Definition: oofawarewidget_iterator.cc:128
static int CLASS_ID
Definition: oofawarewidget.hh:198
Definition: types.hh:179
void notifySetAsTopLevel()
This method is called after a widget has been set as the top of a widget tree.
Definition: oofawarewidget.cc:86
Base class for widgets which can act as container and generator for widgets out of flow...
Definition: oofawarewidget.hh:77
Definition: oofawarewidget.hh:82
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:183
HighlightLayer
Definition: types.hh:42
Definition: oofawarewidget.hh:80
static bool testWidgetPositioned(Widget *widget)
Definition: oofawarewidget.hh:237
Definition: core.hh:16
virtual void getContentInFlow(int index, core::Content *content)=0
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
Definition: style.hh:367
Definition: oofawarewidget.hh:195
Widget * widget
Definition: iterator.hh:29
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
Definition: oofawarewidget.hh:80
virtual void widgetRefSizeChanged(int externalIndex)
Definition: oofawarewidget.cc:553
Widget()
Definition: widget.cc:67
virtual void updateReference(int ref)
Definition: oofawarewidget.cc:548
static bool testWidgetFixedlyPositioned(Widget *widget)
Definition: oofawarewidget.hh:232
OOFAwareWidgetIterator(OOFAwareWidget *widget, core::Content::Type mask, bool atEnd, int numContentsInFlow)
Definition: oofawarewidget_iterator.cc:37
Definition: oofawarewidget.hh:83
void correctExtremesByOOF(core::Extremes *extremes)
Definition: oofawarewidget.cc:306
virtual bool usesMaxGeneratorWidth()
Definition: oofawarewidget.cc:600
void cloneValues(OOFAwareWidgetIterator *other)
Definition: oofawarewidget.hh:100
Definition: oofawarewidget.hh:80
Position position
Definition: style.hh:552
int getInFlowIndex()
Definition: oofawarewidget.hh:104
static bool testStyleRelativelyPositioned(core::style::Style *style)
Definition: oofawarewidget.hh:212
Definition: oofawarewidget.hh:85
Definition: style.hh:346
void unhighlightOOF(int direction, core::HighlightLayer layer)
Definition: oofawarewidget_iterator.cc:231
static bool testWidgetAbsolutelyPositioned(Widget *widget)
Definition: oofawarewidget.hh:230
int parentRef
This value is defined by the parent widget, and used for incremential resizing.
Definition: widget.hh:175
static bool testStylePositioned(core::style::Style *style)
Definition: oofawarewidget.hh:215
bool prev()
Move iterator backward and store content it.
Definition: oofawarewidget_iterator.cc:177
~OOFAwareWidget()
Definition: oofawarewidget.cc:55
static int getOOFMIndex(Widget *widget)
Definition: oofawarewidget.cc:94
static bool testStyleOutOfFlow(core::style::Style *style)
Definition: oofawarewidget.hh:220
virtual bool isPossibleOOFContainerParent(int oofmIndex)
Definition: oofawarewidget.cc:611
void highlightOOF(int start, int end, core::HighlightLayer layer)
Definition: oofawarewidget_iterator.cc:225
Definition: oofawarewidget.hh:195
Content::Type mask
Definition: iterator.hh:30
bool inFlow()
Definition: oofawarewidget.hh:103