Dillo
ooffloatsmgr.hh
Go to the documentation of this file.
1 #ifndef __DW_OOFFLOATSMGR_HH__
2 #define __DW_OOFFLOATSMGR_HH__
3 
4 #include "outofflowmgr.hh"
5 
6 namespace dw {
7 
8 namespace oof {
9 
18 {
19  friend class WidgetInfo;
20 
21 private:
22  enum Side { LEFT, RIGHT };
23 
25  int oofmIndex;
26 
28 
30  {
31  private:
34 
35  protected:
37 
38  public:
39  WidgetInfo (OOFFloatsMgr *oofm, core::Widget *widget);
40 
41  inline core::Widget *getWidget () { return widget; }
42  };
43 
44  class Float: public WidgetInfo
45  {
46  public:
48  {
49  public:
50  int compare (Object *o1, Object *o2);
51  };
52 
54  {
55  public:
56  int compare (Object *o1, Object *o2);
57  };
58 
60  {
61  private:
63 
64  public:
66  { this->oofm = oofm; }
67  int compare(Object *o1, Object *o2);
68  };
69 
72  int index; // TODO Needed after SRDOP?
73  int yReq, yReal; // relative to container
76  bool dirty;
77 
79  OOFAwareWidget *generatingBlock, int externalIndex);
80 
82 
83  bool covers (int y, int h);
84  };
85 
99  {
100  private:
103 
104  public:
105  inline SortedFloatsVector (OOFFloatsMgr *oofm, Side side) :
106  lout::container::typed::Vector<Float> (1, false)
107  { this->oofm = oofm; this->side = side; }
108 
109  int findFloatIndex (OOFAwareWidget *lastGB, int lastExtIndex);
110  int find (int y, int start, int end);
111  int findFirst (int y, int h, OOFAwareWidget *lastGB, int lastExtIndex,
112  int *lastReturn);
113  int findLastBeforeSideSpanningIndex (int sideSpanningIndex);
114  void put (Float *vloat);
115 
118  inline int size ()
120  inline Float *get (int pos)
122  inline void clear ()
124  };
125 
126  class TBInfo: public WidgetInfo
127  {
128  public:
130  {
131  private:
133 
134  public:
135  inline ComparePosition (int oofmIndex) { this->oofmIndex = oofmIndex; }
136  int compare (Object *o1, Object *o2);
137  };
138 
139  int index; // position within "tbInfos"
140  int y; // used for sorting
141 
144 
145  // These two lists store all floats of a generator, in the order
146  // in which they are defined. Used for optimization
148 
149  TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock,
150  TBInfo *parent, int parentExtIndex);
151  ~TBInfo ();
152 
154  { return (OOFAwareWidget*)getWidget (); }
155  };
156 
158 
161 
165 
167 
169  int oldStartIndex, int diff);
171  int findTBInfo (int y);
172 
173  void sizeAllocateFloats (Side side);
174  int getGBWidthForAllocation (Float *vloat);
175  int calcFloatX (Float *vloat);
176 
177  void drawFloats (SortedFloatsVector *list, core::View *view,
178  core::Rectangle *area, core::DrawingContext *context);
181  *context);
182 
183  bool collidesV (Float *vloat, Float *other, int *yReal);
184  bool collidesH (Float *vloat, Float *other);
185 
186  void getFloatsListsAndSide (Float *vloat, SortedFloatsVector **listSame,
187  SortedFloatsVector **listOpp, Side *side);
188 
189  void getFloatsSize (core::Requisition *cbReq, Side side, int *width,
190  int *height);
191  void getFloatsExtremes (core::Extremes *cbExtr, Side side, int *minWidth,
192  int *maxWidth);
193 
197  { return getOOFAwareWidgetWhenRegistered (widget) != NULL; }
198 
199  int getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
200  int lastExtIndex);
201  bool hasFloat (Side side, int y, int h, OOFAwareWidget *lastGB,
202  int lastExtIndex);
203  int getFloatHeight (Side side, int y, int h, OOFAwareWidget *lastGB,
204  int lastExtIndex);
205 
206  int getClearPosition (OOFAwareWidget *widget, Side side);
207 
208  void ensureFloatSize (Float *vloat);
209 
210  inline static int createSubRefLeftFloat (int index) { return index << 1; }
211  inline static int createSubRefRightFloat (int index)
212  { return (index << 1) | 1; }
213 
214  inline static bool isSubRefLeftFloat (int ref)
215  { return ref != -1 && (ref & 1) == 0; }
216  inline static bool isSubRefRightFloat (int ref)
217  { return ref != -1 && (ref & 1) == 1; }
218 
219  inline static int getFloatIndexFromSubRef (int ref)
220  { return ref == -1 ? ref : (ref >> 1); }
221 
222 public:
223  OOFFloatsMgr (OOFAwareWidget *container, int oofmIndex);
224  ~OOFFloatsMgr ();
225 
226  void sizeAllocateStart (OOFAwareWidget *caller,
227  core::Allocation *allocation);
228  void sizeAllocateEnd (OOFAwareWidget *caller);
230  void draw (core::View *view, core::Rectangle *area,
231  core::DrawingContext *context);
232 
233  void markSizeChange (int ref);
234  void markExtremesChange (int ref);
235  core::Widget *getWidgetAtPoint (int x, int y,
237 
238  void addWidgetInFlow (OOFAwareWidget *textblock, OOFAwareWidget *parentBlock,
239  int externalIndex);
240  int addWidgetOOF (core::Widget *widget, OOFAwareWidget *generatingBlock,
241  int externalIndex);
242  void calcWidgetRefSize (core::Widget *widget,core::Requisition *size);
243  void moveExternalIndices (OOFAwareWidget *generatingBlock, int oldStartIndex,
244  int diff);
245 
246  void tellPosition1 (core::Widget *widget, int x, int y);
247  void tellPosition2 (core::Widget *widget, int x, int y);
248  void tellIncompletePosition1 (core::Widget *generator, core::Widget *widget,
249  int x, int y);
250  void tellIncompletePosition2 (core::Widget *generator, core::Widget *widget,
251  int x, int y);
252 
253  void getSize (core::Requisition *cbReq, int *oofWidth, int *oofHeight);
255  void getExtremes (core::Extremes *cbExtr,
256  int *oofMinWidth, int *oofMaxWidth);
257 
258  int getLeftBorder (int y, int h, OOFAwareWidget *lastGB, int lastExtIndex);
259  int getRightBorder (int y, int h, OOFAwareWidget *lastGB, int lastExtIndex);
260 
261  bool hasFloatLeft (int y, int h, OOFAwareWidget *lastGB, int lastExtIndex);
262  bool hasFloatRight (int y, int h, OOFAwareWidget *lastGB, int lastExtIndex);
263 
264  int getLeftFloatHeight (int y, int h, OOFAwareWidget *lastGB,
265  int lastExtIndex);
266  int getRightFloatHeight (int y, int h, OOFAwareWidget *lastGB,
267  int lastExtIndex);
268 
269  bool affectsLeftBorder (core::Widget *widget);
270  bool affectsRightBorder (core::Widget *widget);
271  bool mayAffectBordersAtAll ();
272 
273  int getClearPosition (OOFAwareWidget *textblock);
274 
275  bool dealingWithSizeOfChild (core::Widget *child);
276  int getAvailWidthOfChild (core::Widget *child, bool forceValue);
277  int getAvailHeightOfChild (core::Widget *child, bool forceValue);
278 
279  int getNumWidgets ();
280  core::Widget *getWidget (int i);
281 };
282 
283 } // namespace oof
284 
285 } // namespace dw
286 
287 #endif // __DW_OOFFLOATSMGR_HH__
OOFAwareWidget * getOOFAwareWidget()
Definition: ooffloatsmgr.hh:153
OOFFloatsMgr * oofm
Definition: ooffloatsmgr.hh:32
bool hasFloat(Side side, int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1161
void tellIncompletePosition1(core::Widget *generator, core::Widget *widget, int x, int y)
Definition: ooffloatsmgr.cc:807
int getBorder(Side side, int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1078
int getGBWidthForAllocation(Float *vloat)
int y
Definition: ooffloatsmgr.hh:140
WidgetInfo(OOFFloatsMgr *oofm, core::Widget *widget)
Definition: ooffloatsmgr.cc:36
void getExtremes(core::Extremes *cbExtr, int *oofMinWidth, int *oofMaxWidth)
Definition: ooffloatsmgr.cc:970
Typed version of container::untyped::Vector.
Definition: container.hh:425
void getFloatsSize(core::Requisition *cbReq, Side side, int *width, int *height)
Definition: ooffloatsmgr.cc:935
OOFFloatsMgr(OOFAwareWidget *container, int oofmIndex)
Definition: ooffloatsmgr.cc:321
core::Allocation containerAllocation
Definition: ooffloatsmgr.hh:27
OOFAwareWidget * generator
Definition: ooffloatsmgr.hh:70
int compare(Object *o1, Object *o2)
Definition: ooffloatsmgr.cc:128
Set at the top when getting the widget at the point.
Definition: types.hh:312
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
void sizeAllocateEnd(OOFAwareWidget *caller)
Definition: ooffloatsmgr.cc:378
void calcWidgetRefSize(core::Widget *widget, core::Requisition *size)
Definition: ooffloatsmgr.cc:596
int size()
Definition: ooffloatsmgr.hh:118
core::Widget * getWidget()
Definition: ooffloatsmgr.hh:41
core::Widget * getWidgetAtPoint(int x, int y, core::GettingWidgetAtPointContext *context)
Definition: ooffloatsmgr.cc:691
bool hasFloatLeft(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1143
Typed version of container::untyped::HashTable.
Definition: container.hh:514
OOFFloatsMgr * getOOFFloatsMgr()
Definition: ooffloatsmgr.hh:36
SortedFloatsVector * rightFloats
Definition: ooffloatsmgr.hh:157
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
int lastRightTBIndex
Definition: ooffloatsmgr.hh:166
int index
Definition: ooffloatsmgr.hh:139
bool collidesH(Float *vloat, Float *other)
Definition: ooffloatsmgr.cc:851
void put(Float *vloat)
Definition: ooffloatsmgr.cc:288
int externalIndex
Definition: ooffloatsmgr.hh:71
int findFirst(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex, int *lastReturn)
Definition: ooffloatsmgr.cc:243
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
core::Widget * getFloatWidgetAtPoint(SortedFloatsVector *list, int x, int y, core::GettingWidgetAtPointContext *context)
Definition: ooffloatsmgr.cc:703
int compare(Object *o1, Object *o2)
Definition: ooffloatsmgr.cc:294
bool hasFloatRight(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1152
int size()
Definition: container.hh:418
int sideSpanningIndex
Definition: ooffloatsmgr.hh:74
OutOfFlowMgr implementation dealing with floats.
Definition: ooffloatsmgr.hh:17
Used for other orders as the one defined by Comparable.
Definition: object.hh:66
Definition: ooffloatsmgr.hh:129
int getNumWidgets()
Definition: ooffloatsmgr.cc:1330
int oofmIndex
Definition: ooffloatsmgr.hh:25
Iterator< T > iterator()
Definition: container.hh:416
int calcFloatX(Float *vloat)
Return position of a float relative to the container.
Definition: ooffloatsmgr.cc:429
void moveExternalIndices(lout::container::typed::Vector< Float > *list, int oldStartIndex, int diff)
Definition: ooffloatsmgr.cc:609
TBInfo(OOFFloatsMgr *oofm, OOFAwareWidget *textblock, TBInfo *parent, int parentExtIndex)
Definition: ooffloatsmgr.cc:304
Definition: ooffloatsmgr.hh:98
static int createSubRefLeftFloat(int index)
Definition: ooffloatsmgr.hh:210
int yReal
Definition: ooffloatsmgr.hh:73
Definition: ooffloatsmgr.hh:29
~TBInfo()
Definition: ooffloatsmgr.cc:315
void sizeAllocateStart(OOFAwareWidget *caller, core::Allocation *allocation)
Definition: ooffloatsmgr.cc:364
int rightFloatsMark
Definition: ooffloatsmgr.hh:166
void addWidgetInFlow(OOFAwareWidget *textblock, OOFAwareWidget *parentBlock, int externalIndex)
Definition: ooffloatsmgr.cc:525
bool isOOFAwareWidgetRegistered(OOFAwareWidget *widget)
Definition: ooffloatsmgr.hh:196
Float(OOFFloatsMgr *oofm, core::Widget *widget, OOFAwareWidget *generatingBlock, int externalIndex)
Definition: ooffloatsmgr.cc:44
int getAvailWidthOfChild(core::Widget *child, bool forceValue)
Definition: ooffloatsmgr.cc:1318
core::Widget * widget
Definition: ooffloatsmgr.hh:33
TBInfo * parent
Definition: ooffloatsmgr.hh:142
bool affectsLeftBorder(core::Widget *widget)
Definition: ooffloatsmgr.cc:1237
void getFloatsListsAndSide(Float *vloat, SortedFloatsVector **listSame, SortedFloatsVector **listOpp, Side *side)
Definition: ooffloatsmgr.cc:887
void clear()
Definition: container.hh:443
int compare(Object *o1, Object *o2)
Definition: ooffloatsmgr.cc:122
Float * findFloatByWidget(core::Widget *widget)
Definition: ooffloatsmgr.cc:624
T * get(int pos) const
Definition: container.hh:441
Definition: types.hh:172
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
void containerSizeChangedForChildren()
Definition: ooffloatsmgr.cc:390
int getRightFloatHeight(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1181
SortedFloatsVector(OOFFloatsMgr *oofm, Side side)
Definition: ooffloatsmgr.hh:105
static bool isSubRefRightFloat(int ref)
Definition: ooffloatsmgr.hh:216
Vector(int initSize, bool ownerOfObjects)
Definition: container.hh:428
bool containerMustAdjustExtraSpace()
Definition: ooffloatsmgr.cc:965
Definition: ooffloatsmgr.hh:22
int findLastBeforeSideSpanningIndex(int sideSpanningIndex)
Definition: ooffloatsmgr.cc:280
void tellPosition1(core::Widget *widget, int x, int y)
Called before tellPosition2, see there for more.
Definition: ooffloatsmgr.cc:721
bool collidesV(Float *vloat, Float *other, int *yReal)
Definition: ooffloatsmgr.cc:819
The base class of all dillo widgets.
Definition: widget.hh:23
lout::container::typed::HashTable< lout::object::TypedPointer< dw::core::Widget >, Float > * floatsByWidget
Definition: ooffloatsmgr.hh:160
int parentExtIndex
Definition: ooffloatsmgr.hh:143
int index
Definition: ooffloatsmgr.hh:72
Set at the top when drawing.
Definition: types.hh:294
int findTBInfo(int y)
Definition: ooffloatsmgr.cc:668
Represents additional data for OOF containers.
Definition: outofflowmgr.hh:18
void tellIncompletePosition2(core::Widget *generator, core::Widget *widget, int x, int y)
Definition: ooffloatsmgr.cc:813
Definition: container.cc:27
static bool isSubRefLeftFloat(int ref)
Definition: ooffloatsmgr.hh:214
Definition: types.hh:179
void markExtremesChange(int ref)
Definition: ooffloatsmgr.cc:686
Base class for widgets which can act as container and generator for widgets out of flow...
Definition: oofawarewidget.hh:77
core::Widget * getWidget(int i)
Definition: ooffloatsmgr.cc:1335
bool dealingWithSizeOfChild(core::Widget *child)
Definition: ooffloatsmgr.cc:1313
bool covers(int y, int h)
Definition: ooffloatsmgr.cc:105
bool affectsRightBorder(core::Widget *widget)
Definition: ooffloatsmgr.cc:1242
int yReq
Definition: ooffloatsmgr.hh:73
Definition: ooffloatsmgr.hh:47
int find(int y, int start, int end)
Definition: ooffloatsmgr.cc:230
core::Requisition size
Definition: ooffloatsmgr.hh:75
void intoStringBuffer(lout::misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: ooffloatsmgr.cc:69
int getLeftBorder(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1060
bool mayAffectBordersAtAll()
Definition: ooffloatsmgr.cc:1247
OOFFloatsMgr * oofm
Definition: ooffloatsmgr.hh:62
TBInfo * getOOFAwareWidget(OOFAwareWidget *widget)
Definition: ooffloatsmgr.cc:1051
int getRightBorder(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1069
int oofmIndex
Definition: ooffloatsmgr.hh:132
Definition: ooffloatsmgr.hh:44
int lastLeftTBIndex
Definition: ooffloatsmgr.hh:166
int addWidgetOOF(core::Widget *widget, OOFAwareWidget *generatingBlock, int externalIndex)
Definition: ooffloatsmgr.cc:543
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
ComparePosition(int oofmIndex)
Definition: ooffloatsmgr.hh:135
Definition: ooffloatsmgr.hh:126
static int getFloatIndexFromSubRef(int ref)
Definition: ooffloatsmgr.hh:219
~OOFFloatsMgr()
Definition: ooffloatsmgr.cc:348
lout::container::typed::HashTable< lout::object::TypedPointer< OOFAwareWidget >, TBInfo > * tbInfosByOOFAwareWidget
Definition: ooffloatsmgr.hh:164
void tellPosition2(core::Widget *widget, int x, int y)
Called after tellPosition1.
Definition: ooffloatsmgr.cc:802
void clear()
Definition: ooffloatsmgr.hh:122
Definition: ooffloatsmgr.hh:22
int findFloatIndex(OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:184
void ensureFloatSize(Float *vloat)
Definition: ooffloatsmgr.cc:1281
Typed version of container::untyped::Iterator.
Definition: container.hh:373
int getFloatHeight(Side side, int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1187
lout::container::typed::Iterator< Float > iterator()
Definition: ooffloatsmgr.hh:116
lout::container::typed::Vector< Float > * leftFloats
Definition: ooffloatsmgr.hh:147
static int createSubRefRightFloat(int index)
Definition: ooffloatsmgr.hh:211
OOFAwareWidget * container
Definition: ooffloatsmgr.hh:24
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: ooffloatsmgr.cc:495
void getSize(core::Requisition *cbReq, int *oofWidth, int *oofHeight)
Definition: ooffloatsmgr.cc:910
int getClearPosition(OOFAwareWidget *widget, Side side)
Definition: ooffloatsmgr.cc:1252
int getAvailHeightOfChild(core::Widget *child, bool forceValue)
Definition: ooffloatsmgr.cc:1324
bool dirty
Definition: ooffloatsmgr.hh:76
lout::container::typed::Vector< TBInfo > * tbInfos
Definition: ooffloatsmgr.hh:162
lout::container::typed::Vector< Float > * rightFloats
Definition: ooffloatsmgr.hh:147
OOFFloatsMgr * oofm
Definition: ooffloatsmgr.hh:101
void sizeAllocateFloats(Side side)
Definition: ooffloatsmgr.cc:402
SortedFloatsVector * leftFloats
Definition: ooffloatsmgr.hh:157
A typed version of object::Pointer.
Definition: object.hh:115
Side side
Definition: ooffloatsmgr.hh:102
void markSizeChange(int ref)
Definition: ooffloatsmgr.cc:632
int compare(Object *o1, Object *o2)
Definition: ooffloatsmgr.cc:117
int leftFloatsMark
Definition: ooffloatsmgr.hh:166
void drawFloats(SortedFloatsVector *list, core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: ooffloatsmgr.cc:506
TBInfo * getOOFAwareWidgetWhenRegistered(OOFAwareWidget *widget)
Definition: ooffloatsmgr.cc:1040
void getFloatsExtremes(core::Extremes *cbExtr, Side side, int *minWidth, int *maxWidth)
Definition: ooffloatsmgr.cc:990
Side
Definition: ooffloatsmgr.hh:22
CompareGBAndExtIndex(OOFFloatsMgr *oofm)
Definition: ooffloatsmgr.hh:65
int getLeftFloatHeight(int y, int h, OOFAwareWidget *lastGB, int lastExtIndex)
Definition: ooffloatsmgr.cc:1175