00001 /* 00002 * This source file is part of libRocket, the HTML/CSS Interface Middleware 00003 * 00004 * For the latest information, see http://www.librocket.com 00005 * 00006 * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a copy 00009 * of this software and associated documentation files (the "Software"), to deal 00010 * in the Software without restriction, including without limitation the rights 00011 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 * copies of the Software, and to permit persons to whom the Software is 00013 * furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included in 00016 * all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00021 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00022 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00024 * THE SOFTWARE. 00025 * 00026 */ 00027 00028 #ifndef ROCKETCORELAYOUTINLINEBOX_H 00029 #define ROCKETCORELAYOUTINLINEBOX_H 00030 00031 #include <Rocket/Core/Box.h> 00032 00033 namespace Rocket { 00034 namespace Core { 00035 00036 class Element; 00037 class ElementText; 00038 class FontFaceHandle; 00039 class LayoutBlockBox; 00040 class LayoutLineBox; 00041 00046 class LayoutInlineBox 00047 { 00048 friend class LayoutInlineBoxText; 00049 00050 public: 00054 LayoutInlineBox(Element* element, const Box& box); 00057 LayoutInlineBox(LayoutInlineBox* chain); 00058 virtual ~LayoutInlineBox(); 00059 00062 void SetLine(LayoutLineBox* line); 00065 void SetParent(LayoutInlineBox* parent); 00066 00068 void Close(); 00069 00075 virtual LayoutInlineBox* FlowContent(bool first_box, float available_width, float right_spacing_width); 00076 00081 virtual void CalculateBaseline(float& ascender, float& descender); 00084 virtual void OffsetBaseline(float ascender); 00085 00088 virtual bool CanOverflow() const; 00091 bool IsLastChild() const; 00092 00095 const Vector2f& GetPosition() const; 00096 00099 void SetHorizontalPosition(float position); 00102 void SetVerticalPosition(float position); 00103 00105 virtual void PositionElement(); 00108 virtual void SizeElement(bool split); 00109 00112 int GetVerticalAlignProperty() const; 00113 00116 Element* GetElement(); 00117 00120 LayoutInlineBox* GetParent(); 00121 00124 const Box& GetBox() const; 00131 float GetHeight() const; 00134 float GetBaseline() const; 00135 00136 void* operator new(size_t size); 00137 void operator delete(void* chunk); 00138 00139 protected: 00142 FontFaceHandle* GetParentFont() const; 00145 float GetParentLineHeight() const; 00146 00147 // The box's element. 00148 Element* element; 00149 00150 // The line box's offset relative to its parent block box. 00151 Vector2f position; 00152 // The element's inline box. 00153 Box box; 00154 // The inline box's width; note that this is stored separately from the box dimensions. It is only used by 00155 // nesting inline boxes, such as HTML spans containing text. 00156 float width; 00157 // The inline box's height; note that this is stored separately from the box dimensions, as inline elements 00158 // don't necessarily have identical relationships between their box dimensions and line height. 00159 float height; 00160 00161 // The value of this box's element's vertical-align property. 00162 int vertical_align_property; 00163 // The baseline of the inline element. 00164 float baseline; 00165 00166 // The inline box's parent; this will be NULL if we're not a nested inline element. 00167 LayoutInlineBox* parent; 00168 // This inline box's line. 00169 LayoutLineBox* line; 00170 00171 std::vector< LayoutInlineBox* > children; 00172 00173 // The next link in our element's chain of inline boxes. 00174 LayoutInlineBox* chain; 00175 // True if we're a link in a chain of inline boxes flowing from previous lines. 00176 bool chained; 00177 }; 00178 00179 } 00180 } 00181 00182 #endif