LayoutBlockBox.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCORELAYOUTBLOCKBOX_H
00029 #define ROCKETCORELAYOUTBLOCKBOX_H
00030
00031 #include "LayoutLineBox.h"
00032 #include <Rocket/Core/Box.h>
00033 #include <Rocket/Core/Types.h>
00034
00035 namespace Rocket {
00036 namespace Core {
00037
00038 class LayoutBlockBoxSpace;
00039 class LayoutEngine;
00040
00045 class LayoutBlockBox
00046 {
00047 public:
00048 enum FormattingContext
00049 {
00050 BLOCK,
00051 INLINE
00052 };
00053
00054 enum CloseResult
00055 {
00056 OK,
00057 LAYOUT_SELF,
00058 LAYOUT_PARENT
00059 };
00060
00065 LayoutBlockBox(LayoutEngine* layout_engine, LayoutBlockBox* parent, Element* element);
00069 LayoutBlockBox(LayoutEngine* layout_engine, LayoutBlockBox* parent);
00071 ~LayoutBlockBox();
00072
00075 CloseResult Close();
00076
00080 bool CloseBlockBox(LayoutBlockBox* child);
00087 LayoutInlineBox* CloseLineBox(LayoutLineBox* child, LayoutInlineBox* overflow, LayoutInlineBox* overflow_chain);
00088
00093 LayoutBlockBox* AddBlockElement(Element* element);
00098 LayoutInlineBox* AddInlineElement(Element* element, const Box& box);
00100 void AddBreak();
00101
00103 bool AddFloatElement(Element* element);
00104
00109 void AddAbsoluteElement(Element* element);
00111 void CloseAbsoluteElements();
00112
00118 void PositionBox(Vector2f& box_position, float top_margin = 0, int clear_property = 0) const;
00124 void PositionBlockBox(Vector2f& box_position, const Box& box, int clear_property) const;
00130 void PositionLineBox(Vector2f& box_position, float& box_width, bool& wrap_content, const Vector2f& dimensions) const;
00131
00134 Element* GetElement() const;
00135
00138 LayoutBlockBox* GetParent() const;
00139
00142 const Vector2f& GetPosition() const;
00143
00146 LayoutBlockBox* GetOffsetParent() const;
00149 LayoutBlockBox* GetOffsetRoot() const;
00150
00153 Box& GetBox();
00156 const Box& GetBox() const;
00157
00158 void* operator new(size_t size);
00159 void operator delete(void* chunk);
00160
00161 private:
00162 struct AbsoluteElement
00163 {
00164 Element* element;
00165 Vector2f position;
00166 };
00167
00168
00169 CloseResult CloseInlineBlockBox();
00170
00171
00172 void PositionFloat(Element* element, float offset = 0);
00173
00174
00175
00176
00177 bool CatchVerticalOverflow(float cursor = -1);
00178
00179 typedef std::vector< AbsoluteElement > AbsoluteElementList;
00180 typedef std::vector< LayoutBlockBox* > BlockBoxList;
00181 typedef std::vector< LayoutLineBox* > LineBoxList;
00182
00183
00184 LayoutBlockBoxSpace* space;
00185
00186
00187 LayoutEngine* layout_engine;
00188
00189 Element* element;
00190
00191
00192 LayoutBlockBox* offset_root;
00193
00194 LayoutBlockBox* offset_parent;
00195
00196
00197 LayoutBlockBox* parent;
00198
00199
00200 FormattingContext context;
00201
00202
00203 Vector2f position;
00204
00205 Box box;
00206 float min_height;
00207 float max_height;
00208
00209 bool wrap_content;
00210
00211
00212 float box_cursor;
00213
00214
00215 BlockBoxList block_boxes;
00216
00217 AbsoluteElementList absolute_elements;
00218
00219
00220 LayoutInlineBox* interrupted_chain;
00221
00222 int overflow_x_property;
00223 int overflow_y_property;
00224
00225 bool vertical_overflow;
00226
00227
00228 LineBoxList line_boxes;
00229
00230 ElementList float_elements;
00231 };
00232
00233 }
00234 }
00235
00236 #endif