2.9.1:
------
+All:
+
+- wxHTML: add support for table borders width (Laurent Humbertclaude).
+
i18n:
- Korean translations added (Sungkee Jung).
// returns background colour (of wxNullColour if none set), so that widgets can
// adapt to it:
wxColour GetBackgroundColour();
- void SetBorder(const wxColour& clr1, const wxColour& clr2) {m_UseBorder = true; m_BorderColour1 = clr1, m_BorderColour2 = clr2;}
+ void SetBorder(const wxColour& clr1, const wxColour& clr2, int border = 1) {m_Border = border; m_BorderColour1 = clr1, m_BorderColour2 = clr2;}
virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const;
virtual const wxHtmlCell* Find(int condition, const void* param) const;
bool m_UseBkColour;
wxColour m_BkColour;
// background color of this container
- bool m_UseBorder;
+ int m_Border;
+ // border size. Draw only if m_Border > 0
wxColour m_BorderColour1, m_BorderColour2;
// borders color of this container
int m_LastLayout;
Colour of top and left lines
@param clr2
Colour of bottom and right lines
+ @param border
+ Size of the border in pixels
*/
- void SetBorder(const wxColour& clr1, const wxColour& clr2);
+ void SetBorder(const wxColour& clr1, const wxColour& clr2, int border = 1);
/**
Sets the indentation (free space between borders of container and subcells).
<td>Really, a test!</td>
</tr>
</table>
+<TABLE BORDER="50">
+<TR>
+ <TD>1</TD>
+ <TD>2</TD>
+</TR>
+<TR>
+ <TD>3</TD>
+ <TD>4</TD>
+</TR>
+</TABLE>
+
+<TABLE BORDER="50" width="50%">
+<TR>
+ <TD>50%</TD>
+ <TD>2</TD>
+</TR>
+<TR>
+ <TD>3</TD>
+ <TD>4</TD>
+</TR>
+</TABLE>
+
+<TABLE BORDER="50" width="100%">
+<TR>
+ <TD>100%</TD>
+ <TD>2</TD>
+</TR>
+<TR>
+ <TD>3</TD>
+ <TD>4</TD>
+</TR>
+</TABLE>
+
+
+<TABLE BORDER="50" width="5%">
+<TR>
+ <TD>5%</TD>
+ <TD>2</TD>
+</TR>
+<TR>
+ <TD>3</TD>
+ <TD>4</TD>
+</TR>
+</TABLE>
+
+<TABLE BORDER="50" width="300">
+<TR>
+ <TD>300pix</TD>
+ <TD>2</TD>
+</TR>
+<TR>
+ <TD>3</TD>
+ <TD>4</TD>
+</TR>
+</TABLE><TABLE BORDER="1" width="300">
+<TR>
+ <TD>300pix</TD>
+ <TD>2</TD>
+</TR>
+</TABLE>
m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0;
m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT;
m_UseBkColour = false;
- m_UseBorder = false;
+ m_Border = 0;
m_MinHeight = 0;
m_MinHeightAlign = wxHTML_ALIGN_TOP;
m_LastLayout = -1;
dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
}
- if (m_UseBorder)
+ if (m_Border == 1)
{
+ // draw thin border using lines
wxPen mypen1(m_BorderColour1, 1, wxPENSTYLE_SOLID);
wxPen mypen2(m_BorderColour2, 1, wxPENSTYLE_SOLID);
dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal + m_Width - 1, ylocal + m_Height - 1);
dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
}
-
+ else if (m_Border> 0)
+ {
+ wxBrush mybrush1(m_BorderColour1, wxBRUSHSTYLE_SOLID);
+ wxBrush mybrush2(m_BorderColour2, wxBRUSHSTYLE_SOLID);
+
+ // draw upper left corner
+ // 0---------------5
+ // | /
+ // | 3-----------4
+ // | |
+ // | 2
+ // |/
+ // 1
+
+ wxPoint poly[6];
+ poly[0].x =m_PosX; poly[0].y = m_PosY ;
+ poly[1].x =m_PosX; poly[1].y = m_PosY + m_Height;
+ poly[2].x =m_PosX + m_Border; poly[2].y = poly[1].y - m_Border;
+ poly[3].x =poly[2].x ; poly[3].y = m_PosY + m_Border;
+ poly[4].x =m_PosX + m_Width - m_Border; poly[4].y = poly[3].y;
+ poly[5].x =m_PosX + m_Width; poly[5].y = m_PosY;
+
+ dc.SetBrush(mybrush1);
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.DrawPolygon(6, poly, x, y);
+
+ // draw lower right corner reusing point 1,2,4 and 5
+ // 5
+ // /|
+ // 4 |
+ // | |
+ // 2-----------3 |
+ // / |
+ // 1---------------0
+ dc.SetBrush(mybrush2);
+ poly[0].x = poly[5].x; poly[0].y = poly[1].y;
+ poly[3].x = poly[4].x; poly[3].y = poly[2].y;
+ dc.DrawPolygon(6, poly, x, y);
+
+ // smooth color transition like firefox
+ wxColour borderMediumColour(
+ (m_BorderColour1.Red() + m_BorderColour2.Red()) /2 ,
+ (m_BorderColour1.Green() + m_BorderColour2.Green()) /2 ,
+ (m_BorderColour1.Blue() + m_BorderColour2.Blue()) /2
+ );
+ wxPen mypen3(borderMediumColour, 1, wxPENSTYLE_SOLID);
+ dc.SetPen(mypen3);
+ dc.DrawLines(2, &poly[1], x, y - 1); // between 1 and 2
+ dc.DrawLines(2, &poly[4], x, y - 1); // between 4 and 5
+ }
if (m_Cells)
{
// draw container's contents:
protected:
/* These are real attributes: */
- // should we draw borders or not?
- bool m_HasBorders;
// number of columns; rows
int m_NumCols, m_NumRows;
// array of column information
: wxHtmlContainerCell(parent)
{
m_PixelScale = pixel_scale;
- m_HasBorders =
- (tag.HasParam(wxT("BORDER")) && tag.GetParam(wxT("BORDER")) != wxT("0"));
m_ColsInfo = NULL;
m_NumCols = m_NumRows = 0;
m_CellInfo = NULL;
m_Spacing = (int)(m_PixelScale * (double)m_Spacing);
m_Padding = (int)(m_PixelScale * (double)m_Padding);
- if (m_HasBorders)
- SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
+ if(tag.HasParam(wxT("BORDER")))
+ {
+ if(tag.GetParam("BORDER").IsEmpty())
+ m_Border = 1;
+ else
+ tag.GetParamAsInt(wxT("BORDER"), &m_Border);
+ }
+ if (m_Border == 1)
+ SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2, m_Border); // special case see wxHtmlContainerCell::Draw
+ else if (m_Border> 0)
+ SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2, (int)(m_PixelScale * (double)m_Border));
+ else
+ m_Border = 0;
+
}
if (bk.Ok())
cell->SetBackgroundColour(bk);
}
- if (m_HasBorders)
+ if (m_Border > 0)
cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1);
// vertical alignment:
else
m_MaxTotalWidth = m_MaxTotalWidth * 100 / (100 - percentage);
- m_MaxTotalWidth += (m_NumCols + 1) * m_Spacing;
+ m_MaxTotalWidth += (m_NumCols + 1) * m_Spacing + 2 * m_Border;
}
void wxHtmlTableCell::Layout(int w)
The algorithm tries to keep the table size less than w if possible.
*/
{
- int wpix = m_Width - (m_NumCols + 1) * m_Spacing;
+ int wpix = m_Width - (m_NumCols + 1) * m_Spacing - 2 * m_Border; // Available space for cell content
int i, j;
// 1a. setup fixed-width columns:
else
newWidth = newWidth * 100 / (100 - percentage);
- newWidth = wxMin(newWidth, w - (m_NumCols + 1) * m_Spacing);
+ newWidth = wxMin(newWidth, w - (m_NumCols + 1) * m_Spacing - 2 * m_Border);
wpix -= m_Width - newWidth;
m_Width = newWidth;
}
m_ColsInfo[i].pixwidth = wxMin(m_ColsInfo[i].width, 100) * wpix / 100;
// Make sure to leave enough space for the other columns
- int minRequired = 0;
+ int minRequired = m_Border;
for (j = 0; j < m_NumCols; j++)
{
if ((m_ColsInfo[j].units == wxHTML_UNITS_PERCENT && j > i) ||
wtemp -= m_ColsInfo[i].pixwidth;
}
- wpix = wtemp;
+ wpix = wtemp; // minimum cells width
// 1d. setup default columns (no width specification supplied):
// The algorithm assigns calculates the maximum possible width if line
for (i = j = 0; i < m_NumCols; i++)
if (m_ColsInfo[i].width == 0) j++;
- if (wpix < 0)
- wpix = 0;
+ if (wpix < m_Border)
+ wpix = m_Border;
// Assign widths
for (i = 0; i < m_NumCols; i++)
/* 2. compute positions of columns: */
{
- int wpos = m_Spacing;
+ int wpos = m_Spacing + m_Border;
for (int i = 0; i < m_NumCols; i++)
{
m_ColsInfo[i].leftpos = wpos;
}
// add the remaining space to the last column
- if (m_NumCols > 0 && wpos < m_Width)
- m_ColsInfo[m_NumCols-1].pixwidth += m_Width - wpos;
+ if (m_NumCols > 0 && wpos < m_Width - m_Border)
+ m_ColsInfo[m_NumCols-1].pixwidth += m_Width - wpos - m_Border;
}
/* 3. sub-layout all cells: */
int fullwid;
wxHtmlContainerCell *actcell;
- ypos[0] = m_Spacing;
+ ypos[0] = m_Spacing + m_Border;
for (actrow = 1; actrow <= m_NumRows; actrow++) ypos[actrow] = -1;
for (actrow = 0; actrow < m_NumRows; actrow++)
{
actcell->SetPos(m_ColsInfo[actcol].leftpos, ypos[actrow]);
}
}
- m_Height = ypos[m_NumRows];
+ m_Height = ypos[m_NumRows] + m_Border;
delete[] ypos;
}
if (m_NumCols > 0)
{
int twidth = m_ColsInfo[m_NumCols-1].leftpos +
- m_ColsInfo[m_NumCols-1].pixwidth + m_Spacing;
+ m_ColsInfo[m_NumCols-1].pixwidth + m_Spacing + m_Border;
if (twidth > m_Width)
m_Width = twidth;
}