|
From: CVS C. to T. <the...@li...> - 2012-02-26 16:33:03
|
Revision: 677
http://themis.svn.sourceforge.net/themis/?rev=677&view=rev
Author: mark_hellegers
Date: 2012-02-26 16:32:55 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------
- Improved table support. The columns should now be equal in size when no attribute like colspan has been set.
- Switched the default display type to inline. Added debugging output, so we know when we fall back to the default.
- Added a few more styles, so block elements still display correctly.
Modified Paths:
--------------
trunk/themis/makefile
trunk/themis/modules/CSSParser/html4.css
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableDisplayView.hpp
Added Paths:
-----------
trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.hpp
trunk/themis/modules/CSSRenderer/TableGroupDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableGroupDisplayView.hpp
trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.hpp
trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.hpp
Modified: trunk/themis/makefile
===================================================================
--- trunk/themis/makefile 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/makefile 2012-02-26 16:32:55 UTC (rev 677)
@@ -239,6 +239,10 @@
CSSRenderer/TableDisplayView.cpp \
CSSRenderer/TableRowDisplayView.cpp \
CSSRenderer/TableCellDisplayView.cpp \
+ CSSRenderer/TableGroupDisplayView.cpp \
+ CSSRenderer/TableFooterGroupDisplayView.cpp \
+ CSSRenderer/TableHeaderGroupDisplayView.cpp \
+ CSSRenderer/TableRowGroupDisplayView.cpp \
CSSRenderer/NoneDisplayView.cpp
#make install directories as necessary
Modified: trunk/themis/modules/CSSParser/html4.css
===================================================================
--- trunk/themis/modules/CSSParser/html4.css 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSParser/html4.css 2012-02-26 16:32:55 UTC (rev 677)
@@ -20,28 +20,35 @@
CODE { display: inline }
SCRIPT { display: none }
STYLE { display: none }
+META { display: none }
+LINK { display: none }
+TITLE { display: none }
HEAD { display: none }
P { margin-bottom: 5px }
-H1 { font-size: 2em;
+CENTER { display: block }
+H1 { font-size: 2.5em;
margin-bottom: 5px}
-H2 { font-size: 1.5em;
+H2 { font-size: 2em;
margin-bottom: 5px}
-H3 { font-size: 1.1em;
+H3 { font-size: 1.5em;
margin-bottom: 5px}
+H4 { font-size: 1.1em;
+ margin-bottom: 5px}
+UL { display: block }
+OL { display: block }
LI { display: block;
list-style-type: square}
-TABLE { display: table;
- border-style: solid;
- border-width: 1px; }
-TBODY { display: table-row-group;
- border-style: solid;
- border-width: 1px; }
-THEAD { display: table-row-group;
- border-style: solid;
- border-width: 1px; }
-TR { display: table-row;
- border-style: solid;
- border-width: 1px }
+HR { display: block }
+DL { display: block }
+DT { display: block }
+DD { display: block }
+SELECT { display: block }
+OPTION { display: block }
+TABLE { display: table;}
+TBODY { display: table-row-group;}
+THEAD { display: table-header-group;}
+TFOOT { display: table-footer-group;}
+TR { display: table-row;}
TD { display: table-cell;
border-style: solid;
border-width: 1px;
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -65,6 +65,9 @@
#include "InlineDisplayView.hpp"
#include "BlockDisplayView.hpp"
#include "TableDisplayView.hpp"
+#include "TableRowGroupDisplayView.hpp"
+#include "TableHeaderGroupDisplayView.hpp"
+#include "TableFooterGroupDisplayView.hpp"
#include "TableRowDisplayView.hpp"
#include "TableCellDisplayView.hpp"
#include "NoneDisplayView.hpp"
@@ -136,18 +139,18 @@
for (unsigned int i = 0; i < length; i++) {
TNodePtr child = children->item(i);
if (child->getNodeType() == ELEMENT_NODE) {
+ CSSView * childView = NULL;
TElementPtr element = shared_static_cast<TElement>(child);
CSSStyleDeclarationPtr style = mStyleSheets->getComputedStyle(element);
if (style.get()) {
CSSValuePtr value = style->getPropertyCSSValue("display");
- // Default to block in case it doesn't exist.
- TDOMString valueString = "block";
+ // Default to inline in case it doesn't exist.
+ TDOMString valueString = "inline";
if (value.get()) {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
valueString = primitiveValue->getStringValue();
}
// printf("Display property value: %s\n", valueString.c_str());
- CSSView * childView = NULL;
if (valueString == "inline") {
childView = new InlineDisplayView(aBaseView,
child,
@@ -159,7 +162,19 @@
mColor,
mFont);
}
- else if ((valueString == "table") || (valueString == "table-row-group")) {
+ else if (valueString == "block") {
+ childView = new BlockDisplayView(
+ aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
+ }
+ else if (valueString == "table") {
childView = new TableDisplayView(aBaseView,
child,
mStyleSheets,
@@ -170,6 +185,42 @@
mColor,
mFont);
}
+ else if (valueString == "table-row-group") {
+ childView = new TableRowGroupDisplayView(
+ aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
+ }
+ else if (valueString == "table-header-group") {
+ childView = new TableHeaderGroupDisplayView(
+ aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
+ }
+ else if (valueString == "table-footer-group") {
+ childView = new TableFooterGroupDisplayView(
+ aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
+ }
else if (valueString == "table-row") {
childView = new TableRowDisplayView(aBaseView,
child,
@@ -204,19 +255,32 @@
mFont);
}
else {
- // The default is a block element
- childView = new BlockDisplayView(aBaseView,
- child,
- mStyleSheets,
- style,
- mRect,
- mSiteId,
- mUrlId,
- mColor,
- mFont);
+ // The default is an inline element
+ printf("Currently unsupported display type: %s. Defaulting to inline...\n", valueString.c_str());
+ childView = new InlineDisplayView(aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
}
- mChildren.push_back(childView);
}
+ else {
+ printf("No style specified for %s. Defaulting to inline...\n", element->getTagName().c_str());
+ childView = new InlineDisplayView(aBaseView,
+ child,
+ mStyleSheets,
+ style,
+ mRect,
+ mSiteId,
+ mUrlId,
+ mColor,
+ mFont);
+ }
+ mChildren.push_back(childView);
}
else if (child->getNodeType() == TEXT_NODE) {
// Quick fix. Take a look at what would be elegant.
@@ -793,3 +857,37 @@
}
}
+
+void CSSView :: SetWidth(float aWidth) {
+
+ mRequestedWidth = aWidth;
+
+}
+
+float CSSView :: GetChildWidth(unsigned int aIndex) {
+
+ float result = 0;
+
+ if (aIndex < mChildren.size()) {
+ CSSView * childView = mChildren[aIndex];
+ result = childView->Bounds().Width();
+ }
+
+ return result;
+
+}
+
+void CSSView :: SetChildWidth(float aWidth, unsigned int aIndex) {
+
+ if (aIndex < mChildren.size()) {
+ CSSView * childView = mChildren[aIndex];
+ childView->SetWidth(aWidth);
+ }
+
+}
+
+unsigned int CSSView :: GetLength() const {
+
+ return mChildren.size();
+
+}
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -102,6 +102,7 @@
string mListStyleType;
bool mDisplay;
bool mBlock;
+ float mRequestedWidth;
void ApplyStyle(const TElementPtr aElement,
const CSSStyleDeclarationPtr aStyle);
@@ -129,6 +130,10 @@
BPoint aStartingPoint);
void SplitText();
void RetrieveResources();
+ void SetWidth(float aRequestedWidth);
+ float GetChildWidth(unsigned int aIndex);
+ void SetChildWidth(float aWidth, unsigned int aIndex);
+ unsigned int GetLength() const;
};
#endif
Modified: trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -60,6 +60,7 @@
mDisplay = true;
mBlock = false;
+ mRequestedWidth = -1;
}
@@ -72,4 +73,9 @@
CSSView::Layout(aRect, aStartingPoint);
+ if (mRequestedWidth > -1) {
+ mRect.right = mRect.left + mRequestedWidth;
+ mEndPoint.x = mRect.right;
+ }
+
}
Modified: trunk/themis/modules/CSSRenderer/TableDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableDisplayView.cpp 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSRenderer/TableDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -38,6 +38,7 @@
// CSS Renderer headers
#include "TableDisplayView.hpp"
+#include "TableGroupDisplayView.hpp"
TableDisplayView :: TableDisplayView(CSSRendererView * aBaseView,
TNodePtr aNode,
@@ -67,9 +68,115 @@
}
+void TableDisplayView :: LayoutChildren(
+ BRect aRect,
+ BPoint aStartingPoint) {
+
+ unsigned int length = mChildren.size();
+ BPoint startingPoint = aStartingPoint;
+ BRect restRect = aRect;
+ float maxRight = 0;
+
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ // Only layout those children that are actually displayed.
+ if (childView->IsDisplayed()) {
+ // Don't care if the child is a block or not, children will be positioned below to each other.
+ startingPoint = BPoint(restRect.left, restRect.top);
+ // Do the layout for the child.
+ childView->Layout(restRect, startingPoint);
+ BRect rect2 = childView->Bounds();
+ // Set the top of the remaining rect to the bottom of the child,
+ // because the space above is already taken by the child.
+ restRect.top = rect2.bottom;
+ if (rect2.right > restRect.right) {
+ // The child used more space than was available. We can use that space now as well
+ // for any remaining children.
+ restRect.right = rect2.right;
+ mRect.right = rect2.right;
+ }
+ // What is the maximum horizontal space being taken up by one of the children?
+ if (rect2.right > maxRight) {
+ maxRight = rect2.right;
+ }
+ }
+ }
+
+ if (maxRight > 0) {
+ // Only set it in case we found something.
+ mRect.right = maxRight;
+ }
+ else {
+ mRect.right = mRect.left;
+ }
+ mRect.bottom = restRect.top;
+
+}
+
void TableDisplayView :: Layout(BRect aRect,
BPoint aStartingPoint) {
- CSSView::Layout(aRect, aStartingPoint);
+ mRects.clear();
+ mRect = aRect;
+ // Always set the top of the rect to the one from the starting point as that is definitely correct.
+ mRect.top = aStartingPoint.y;
+ BRect restRect = mRect;
+ // If we are drawing a border around this element, make sure there is less space for the content.
+ restRect.InsetBy(mBorderWidth, mBorderWidth);
+ // Set the endpoint to the starting point, as that is the minimum endpoint
+ mEndPoint = aStartingPoint;
+ // Assume we don't need any horizontal space. The children will determine the space needed.
+// mRect.right = mRect.left;
+ // In case we need to draw something before drawing any children, move the children.
+ if (mListStyleType == "square") {
+ mListStyleRect.left = restRect.left + 2;
+ mListStyleRect.right = restRect.left + 7;
+ mListStyleRect.top = restRect.top + 2;
+ mListStyleRect.bottom = restRect.top + 7;
+ restRect.left += 12;
+ mEndPoint.x += 12;
+ }
+ // Layout the children.
+ LayoutChildren(restRect, mEndPoint);
+ unsigned int length = mChildren.size();
+ vector<float> widths;
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ TableGroupDisplayView * childGroupView = dynamic_cast<TableGroupDisplayView *> (childView);
+ if (childGroupView) {
+ unsigned int childLength = childGroupView->GetColLength();
+ for (unsigned int j = 0; j < childLength; j++) {
+ if (j >= widths.size()) {
+ widths.push_back(childGroupView->GetColWidth(j));
+ }
+ else if (childGroupView->GetColWidth(j) > widths[j]) {
+ widths[j] = childGroupView->GetColWidth(j);
+ }
+ }
+ }
+ }
+
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ TableGroupDisplayView * childGroupView = dynamic_cast<TableGroupDisplayView *> (childView);
+ if (childGroupView) {
+ unsigned int childLength = childGroupView->GetColLength();
+ for (unsigned int j = 0; j < childLength; j++) {
+ childGroupView->SetColWidth(widths[j], j);
+ }
+ }
+ }
+
+ // Do another layout the children based on the new col widths.
+ LayoutChildren(restRect, mEndPoint);
+
+ // Add any margins
+ mRect.bottom += mMarginBottom;
+ mRect.right += mMarginRight;
+ mEndPoint.Set(mRect.right, mRect.bottom);
+ mRects.push_back(mRect);
+ //mRect.right = restRect.right;
+
}
+
Modified: trunk/themis/modules/CSSRenderer/TableDisplayView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableDisplayView.hpp 2012-02-25 10:58:44 UTC (rev 676)
+++ trunk/themis/modules/CSSRenderer/TableDisplayView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -70,6 +70,11 @@
class TableDisplayView : public CSSView {
+ private:
+ void LayoutChildren(
+ BRect aRect,
+ BPoint aStartingPoint);
+
public:
TableDisplayView(CSSRendererView * aBaseView,
TNodePtr aNode,
@@ -81,8 +86,9 @@
rgb_color aColor,
BFont * aFont = NULL);
~TableDisplayView();
- virtual void Layout(BRect aRect,
- BPoint aStartingPoint);
+ virtual void Layout(
+ BRect aRect,
+ BPoint aStartingPoint);
};
#endif
Added: trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.cpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,78 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableFooterGroupDisplayView implementation
+ See TableFooterGroupDisplayView.hpp for more information
+
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// CSS Renderer headers
+#include "TableFooterGroupDisplayView.hpp"
+
+TableFooterGroupDisplayView :: TableFooterGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont)
+ : TableGroupDisplayView(
+ aBaseView,
+ aNode,
+ aStyleSheets,
+ aStyle,
+ aRect,
+ aSiteId,
+ aUrlId,
+ aColor,
+ aFont) {
+
+ mDisplay = true;
+ mBlock = false;
+
+}
+
+TableFooterGroupDisplayView :: ~TableFooterGroupDisplayView() {
+
+}
+
+void TableFooterGroupDisplayView :: Layout(
+ BRect aRect,
+ BPoint aStartingPoint) {
+
+ TableGroupDisplayView::Layout(aRect, aStartingPoint);
+
+}
Added: trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.hpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableFooterGroupDisplayView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableFooterroupDisplayView
+ Renders css table-footer-group display elements
+
+ Mark Hellegers (ma...@fi...)
+ 25-02-2012
+
+*/
+
+#ifndef TABLEFOOTERGROUPDISPLAYVIEW_HPP
+#define TABLEFOOTERGROUPDISPLAYVIEW_HPP
+
+// Standard C++ headers
+#include <vector>
+#include <string>
+
+// BeOS headers
+#include <Handler.h>
+#include <Rect.h>
+#include <Point.h>
+
+// DOM headers
+#include "DOMSupport.h"
+
+// DOM Style headers
+#include "CSSStyleSheet.hpp"
+#include "CSSStyleDeclaration.hpp"
+
+// CSSRenderer headers
+#include "TableGroupDisplayView.hpp"
+#include "TextBox.hpp"
+
+// Declarations used
+class BFont;
+class CSSRendererView;
+class CSSStyleContainer;
+
+// Namespaces used
+using std::vector;
+using std::string;
+
+class TableFooterGroupDisplayView : public TableGroupDisplayView {
+
+ public:
+ TableFooterGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont = NULL);
+ ~TableFooterGroupDisplayView();
+ virtual void Layout(
+ BRect aRect,
+ BPoint aStartingPoint);
+};
+
+#endif
Added: trunk/themis/modules/CSSRenderer/TableGroupDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableGroupDisplayView.cpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableGroupDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,191 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 26, 2012
+*/
+
+/* TableGroupDisplayView implementation
+ See TableGroupDisplayView.hpp for more information
+
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// CSS Renderer headers
+#include "TableGroupDisplayView.hpp"
+
+TableGroupDisplayView :: TableGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont)
+ : CSSView(
+ aBaseView,
+ aNode,
+ aStyleSheets,
+ aStyle,
+ aRect,
+ aSiteId,
+ aUrlId,
+ aColor,
+ aFont) {
+
+ mDisplay = true;
+ mBlock = false;
+
+}
+
+TableGroupDisplayView :: ~TableGroupDisplayView() {
+
+}
+
+void TableGroupDisplayView :: Layout(
+ BRect aRect,
+ BPoint aStartingPoint) {
+
+ mRects.clear();
+ mRect = aRect;
+ // Always set the top of the rect to the one from the starting point as that is definitely correct.
+ mRect.top = aStartingPoint.y;
+ BRect restRect = mRect;
+ // If we are drawing a border around this element, make sure there is less space for the content.
+ restRect.InsetBy(mBorderWidth, mBorderWidth);
+ // Set the endpoint to the starting point, as that is the minimum endpoint
+ mEndPoint = aStartingPoint;
+ // Assume we don't need any horizontal space. The children will determine the space needed.
+// mRect.right = mRect.left;
+ // In case we need to draw something before drawing any children, move the children.
+ if (mListStyleType == "square") {
+ mListStyleRect.left = restRect.left + 2;
+ mListStyleRect.right = restRect.left + 7;
+ mListStyleRect.top = restRect.top + 2;
+ mListStyleRect.bottom = restRect.top + 7;
+ restRect.left += 12;
+ mEndPoint.x += 12;
+ }
+ // Layout the children.
+ unsigned int length = mChildren.size();
+ BPoint startingPoint = mEndPoint;
+ float maxRight = 0;
+
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ // Only layout those children that are actually displayed.
+ if (childView->IsDisplayed()) {
+ // Don't care if the child is a block or not, children will be positioned below to each other.
+ startingPoint = BPoint(restRect.left, restRect.top);
+ // Do the layout for the child.
+ childView->Layout(restRect, startingPoint);
+ BRect rect2 = childView->Bounds();
+ mEndPoint = childView->GetEndPoint();
+ // Set the top of the remaining rect to the bottom of the child,
+ // because the space above is already taken by the child.
+ restRect.top = rect2.bottom;
+ if (rect2.right > restRect.right) {
+ // The child used more space than was available. We can use that space now as well
+ // for any remaining children.
+ restRect.right = rect2.right;
+ mRect.right = rect2.right;
+ }
+ // What is the maximum horizontal space being taken up by one of the children?
+ if (rect2.right > maxRight) {
+ maxRight = rect2.right;
+ }
+ // The next child will have to start at the left of the parent rect and just below this block.
+ startingPoint = BPoint(restRect.left, restRect.top);
+ }
+ }
+ if (maxRight > 0) {
+ // Only set it in case we found something.
+ mRect.right = maxRight;
+ }
+ else {
+ mRect.right = mRect.left;
+ }
+ mRect.bottom = restRect.top;
+// mRect.PrintToStream();
+
+ // Add any margins
+
+ mRect.bottom += mMarginBottom;
+ mRect.right += mMarginRight;
+ mEndPoint.Set(mRect.right, mRect.bottom);
+ mRects.push_back(mRect);
+
+ // Check the widths of the table cells of the rows.
+ mColWidths.clear();
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ unsigned int childLength = childView->GetLength();
+ for (unsigned int j = 0; j < childLength; j++) {
+ if (j >= mColWidths.size()) {
+ mColWidths.push_back(childView->GetChildWidth(j));
+ }
+ else if (childView->GetChildWidth(j) > mColWidths[j]) {
+ mColWidths[j] = childView->GetChildWidth(j);
+ }
+ }
+ }
+
+}
+
+float TableGroupDisplayView :: GetColWidth(unsigned int aIndex) {
+
+ float result = -1;
+
+ if (aIndex < mColWidths.size()) {
+ result = mColWidths[aIndex];
+ }
+
+ return result;
+
+}
+
+void TableGroupDisplayView :: SetColWidth(float aWidth, unsigned int aIndex) {
+
+ unsigned int length = mChildren.size();
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ unsigned int childLength = childView->GetLength();
+ if (aIndex < childLength) {
+ childView->SetChildWidth(aWidth, aIndex);
+ }
+ }
+
+}
+
+unsigned int TableGroupDisplayView :: GetColLength() const {
+
+ return mColWidths.size();
+
+}
Added: trunk/themis/modules/CSSRenderer/TableGroupDisplayView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableGroupDisplayView.hpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableGroupDisplayView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,96 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 26, 2012
+*/
+
+/* TableGroupDisplayView
+ Base class for the *-row-group display elements
+
+ Mark Hellegers (ma...@fi...)
+ 26-02-2012
+
+*/
+
+#ifndef TABLEGROUPDISPLAYVIEW_HPP
+#define TABLEGROUPDISPLAYVIEW_HPP
+
+// Standard C++ headers
+#include <vector>
+#include <string>
+
+// BeOS headers
+#include <Handler.h>
+#include <Rect.h>
+#include <Point.h>
+
+// DOM headers
+#include "DOMSupport.h"
+
+// DOM Style headers
+#include "CSSStyleSheet.hpp"
+#include "CSSStyleDeclaration.hpp"
+
+// CSSRenderer headers
+#include "CSSView.hpp"
+#include "TextBox.hpp"
+
+// Declarations used
+class BFont;
+class CSSRendererView;
+class CSSStyleContainer;
+
+// Namespaces used
+using std::vector;
+using std::string;
+
+class TableGroupDisplayView : public CSSView {
+
+ private:
+ vector<float> mColWidths;
+
+ public:
+ TableGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont = NULL);
+ ~TableGroupDisplayView();
+ virtual void Layout(
+ BRect aRect,
+ BPoint aStartingPoint);
+ float GetColWidth(unsigned int aIndex);
+ void SetColWidth(float aWidth, unsigned int aIndex);
+ unsigned int GetColLength() const;
+};
+
+#endif
Added: trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.cpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,78 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableHeaderGroupDisplayView implementation
+ See TableHeaderGroupDisplayView.hpp for more information
+
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// CSS Renderer headers
+#include "TableHeaderGroupDisplayView.hpp"
+
+TableHeaderGroupDisplayView :: TableHeaderGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont)
+ : TableGroupDisplayView(
+ aBaseView,
+ aNode,
+ aStyleSheets,
+ aStyle,
+ aRect,
+ aSiteId,
+ aUrlId,
+ aColor,
+ aFont) {
+
+ mDisplay = true;
+ mBlock = false;
+
+}
+
+TableHeaderGroupDisplayView :: ~TableHeaderGroupDisplayView() {
+
+}
+
+void TableHeaderGroupDisplayView :: Layout(
+ BRect aRect,
+ BPoint aStartingPoint) {
+
+ TableGroupDisplayView::Layout(aRect, aStartingPoint);
+
+}
Added: trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.hpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableHeaderGroupDisplayView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableHeaderGroupDisplayView
+ Renders css table-header-group display elements
+
+ Mark Hellegers (ma...@fi...)
+ 25-02-2012
+
+*/
+
+#ifndef TABLEHEADERGROUPDISPLAYVIEW_HPP
+#define TABLEHEADERGROUPDISPLAYVIEW_HPP
+
+// Standard C++ headers
+#include <vector>
+#include <string>
+
+// BeOS headers
+#include <Handler.h>
+#include <Rect.h>
+#include <Point.h>
+
+// DOM headers
+#include "DOMSupport.h"
+
+// DOM Style headers
+#include "CSSStyleSheet.hpp"
+#include "CSSStyleDeclaration.hpp"
+
+// CSSRenderer headers
+#include "TableGroupDisplayView.hpp"
+#include "TextBox.hpp"
+
+// Declarations used
+class BFont;
+class CSSRendererView;
+class CSSStyleContainer;
+
+// Namespaces used
+using std::vector;
+using std::string;
+
+class TableHeaderGroupDisplayView : public TableGroupDisplayView {
+
+ public:
+ TableHeaderGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont = NULL);
+ ~TableHeaderGroupDisplayView();
+ virtual void Layout(
+ BRect aRect,
+ BPoint aStartingPoint);
+};
+
+#endif
Added: trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.cpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.cpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,78 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableRowGroupDisplayView implementation
+ See TableRowGroupDisplayView.hpp for more information
+
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// CSS Renderer headers
+#include "TableRowGroupDisplayView.hpp"
+
+TableRowGroupDisplayView :: TableRowGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont)
+ : TableGroupDisplayView(
+ aBaseView,
+ aNode,
+ aStyleSheets,
+ aStyle,
+ aRect,
+ aSiteId,
+ aUrlId,
+ aColor,
+ aFont) {
+
+ mDisplay = true;
+ mBlock = false;
+
+}
+
+TableRowGroupDisplayView :: ~TableRowGroupDisplayView() {
+
+}
+
+void TableRowGroupDisplayView :: Layout(
+ BRect aRect,
+ BPoint aStartingPoint) {
+
+ TableGroupDisplayView::Layout(aRect, aStartingPoint);
+
+}
Added: trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.hpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/TableRowGroupDisplayView.hpp 2012-02-26 16:32:55 UTC (rev 677)
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2012 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: Februari 25, 2012
+*/
+
+/* TableRowGroupDisplayView
+ Renders css table-row-group display elements
+
+ Mark Hellegers (ma...@fi...)
+ 25-02-2012
+
+*/
+
+#ifndef TABLEROWGROUPDISPLAYVIEW_HPP
+#define TABLEROWGROUPDISPLAYVIEW_HPP
+
+// Standard C++ headers
+#include <vector>
+#include <string>
+
+// BeOS headers
+#include <Handler.h>
+#include <Rect.h>
+#include <Point.h>
+
+// DOM headers
+#include "DOMSupport.h"
+
+// DOM Style headers
+#include "CSSStyleSheet.hpp"
+#include "CSSStyleDeclaration.hpp"
+
+// CSSRenderer headers
+#include "TableGroupDisplayView.hpp"
+#include "TextBox.hpp"
+
+// Declarations used
+class BFont;
+class CSSRendererView;
+class CSSStyleContainer;
+
+// Namespaces used
+using std::vector;
+using std::string;
+
+class TableRowGroupDisplayView : public TableGroupDisplayView {
+
+ public:
+ TableRowGroupDisplayView(
+ CSSRendererView * aBaseView,
+ TNodePtr aNode,
+ CSSStyleContainer * aStyleSheets,
+ CSSStyleDeclarationPtr aStyle,
+ BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
+ rgb_color aColor,
+ BFont * aFont = NULL);
+ ~TableRowGroupDisplayView();
+ virtual void Layout(
+ BRect aRect,
+ BPoint aStartingPoint);
+};
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|