libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ElementUtilities.h
Go to the documentation of this file.
1 /*
2  * This source file is part of libRocket, the HTML/CSS Interface Middleware
3  *
4  * For the latest information, see http://www.librocket.com
5  *
6  * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROCKETCOREELEMENTUTILITIES_H
29 #define ROCKETCOREELEMENTUTILITIES_H
30 
31 #include "Header.h"
32 #include "Box.h"
33 #include "WString.h"
34 #include "Types.h"
35 
36 namespace Rocket {
37 namespace Core {
38 
39 class Context;
40 class FontFaceHandle;
41 class RenderInterface;
42 
50 {
51 public:
53  {
54  TOP = 1 << 0,
55  BOTTOM = 1 << 1,
56  LEFT = 1 << 2,
57  RIGHT = 1 << 3,
58 
59  TOP_LEFT = TOP | LEFT,
60  TOP_RIGHT = TOP | RIGHT,
61  BOTTOM_LEFT = BOTTOM | LEFT,
62  BOTTOM_RIGHT = BOTTOM | RIGHT
63  };
64 
68  static Element* GetElementById(Element* root_element, const String& id);
73  static void GetElementsByTagName(ElementList& elements, Element* root_element, const String& tag);
78  static void GetElementsByClassName(ElementList& elements, Element* root_element, const String& class_name);
79 
83  static FontFaceHandle* GetFontFaceHandle(Element* element);
87  static int GetFontSize(Element* element);
91  static int GetLineHeight(Element* element);
96  static int GetStringWidth(Element* element, const WString& string);
97 
100  static void BindEventAttributes(Element* element);
101 
107  static bool GetClippingRegion(Vector2i& clip_origin, Vector2i& clip_dimensions, Element* element);
112  static bool SetClippingRegion(Element* element, Context* context = NULL);
116  static void ApplyActiveClipRegion(Context* context, RenderInterface* render_interface);
117 
122  static bool FormatElement(Element* element, const Vector2f& containing_block);
123 
129  static void BuildBox(Box& box, const Vector2f& containing_block, Element* element, bool inline_element = false);
130 
135  static bool PositionElement(Element* element, const Vector2f& offset);
141  static bool PositionElement(Element* element, const Vector2f& offset, PositionAnchor anchor);
142 };
143 
144 }
145 }
146 
147 #endif
#define NULL
Definition: Types.h:33
#define ROCKETCORE_API
Definition: Header.h:73
PositionAnchor
Definition: ElementUtilities.h:52
Definition: Box.h:43
Definition: Clipboard.h:33
Definition: WString.h:45
Definition: Context.h:62
Definition: StringBase.h:42
Definition: ElementUtilities.h:49
Definition: RenderInterface.h:48
Definition: Element.h:71
Definition: Vector2.h:43
std::vector< Element * > ElementList
Definition: Types.h:90