wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale) : wxHtmlContainerCell(parent) { m_PixelScale = pixel_scale; m_ColsInfo = NULL; m_NumCols = m_NumRows = 0; m_CellInfo = NULL; m_ActualCol = m_ActualRow = -1; /* scan params: */ if (tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg)) SetBackgroundColour(m_tBkg); m_tValign = tag.GetParam(wxT("VALIGN")); if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing)) m_Spacing = 2; if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding)) m_Padding = 3; m_Spacing = (int)(m_PixelScale * (double)m_Spacing); m_Padding = (int)(m_PixelScale * (double)m_Padding); 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; }
wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale) : 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_ActualCol = m_ActualRow = -1; /* scan params: */ if (tag.HasParam(wxT("BGCOLOR"))) { tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg); if (m_tBkg.Ok()) SetBackgroundColour(m_tBkg); } if (tag.HasParam(wxT("VALIGN"))) m_tValign = tag.GetParam(wxT("VALIGN")); else m_tValign = wxEmptyString; if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing)) m_Spacing = 2; if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding)) m_Padding = 3; 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); }
bool HP_TagHandler::HandleTag(const wxHtmlTag& tag) { if (tag.GetName() == wxT("UL")) { wxHtmlHelpDataItem *oldparent = m_parentItem; m_level++; m_parentItem = (m_count > 0) ? &(*m_data)[m_data->size()-1] : NULL; ParseInner(tag); m_level--; m_parentItem = oldparent; return true; } else if (tag.GetName() == wxT("OBJECT")) { m_name = m_page = wxEmptyString; ParseInner(tag); #if 0 if (!page.IsEmpty()) /* Valid HHW's file may contain only two object tags: <OBJECT type="text/site properties"> <param name="ImageType" value="Folder"> </OBJECT> or <OBJECT type="text/sitemap"> <param name="Name" value="main page"> <param name="Local" value="another.htm"> </OBJECT> We're interested in the latter. !page.IsEmpty() is valid condition because text/site properties does not contain Local param */ #endif if (tag.GetParam(wxT("TYPE")) == wxT("text/sitemap")) { wxHtmlHelpDataItem *item = new wxHtmlHelpDataItem(); item->parent = m_parentItem; item->level = m_level; item->id = m_id; item->page = m_page; item->name = m_name; item->book = m_book; m_data->Add(item); m_count++; } return true; } else { // "PARAM" if (m_name.empty() && tag.GetParam(wxT("NAME")) == wxT("Name")) m_name = tag.GetParam(wxT("VALUE")); if (tag.GetParam(wxT("NAME")) == wxT("Local")) m_page = tag.GetParam(wxT("VALUE")); if (tag.GetParam(wxT("NAME")) == wxT("ID")) tag.GetParamAsInt(wxT("VALUE"), &m_id); return false; } }
void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) { // Is this cell in new row? // VS: we can't do it in AddRow, see my comment there if (m_ActualCol == -1) { if (m_ActualRow + 1 > m_NumRows - 1) ReallocRows(m_ActualRow + 2); m_ActualRow++; } // cells & columns: do { m_ActualCol++; } while ((m_ActualCol < m_NumCols) && (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree)); if (m_ActualCol > m_NumCols - 1) ReallocCols(m_ActualCol + 1); int r = m_ActualRow, c = m_ActualCol; m_CellInfo[r][c].cont = cell; m_CellInfo[r][c].colspan = 1; m_CellInfo[r][c].rowspan = 1; m_CellInfo[r][c].flag = cellUsed; m_CellInfo[r][c].minheight = 0; m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP; /* scan for parameters: */ // id: wxString idvalue; if (tag.GetParamAsString(wxT("ID"), &idvalue)) { cell->SetId(idvalue); } // width: { int width = 0; bool wpercent = false; if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &width, wpercent)) { if (wpercent) { m_ColsInfo[c].width = width; m_ColsInfo[c].units = wxHTML_UNITS_PERCENT; } else { m_ColsInfo[c].width = (int)(m_PixelScale * (double)width); m_ColsInfo[c].units = wxHTML_UNITS_PIXELS; } } } // spanning: { tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan); tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan); // VS: the standard says this about col/rowspan: // "This attribute specifies the number of rows spanned by the // current cell. The default value of this attribute is one ("1"). // The value zero ("0") means that the cell spans all rows from the // current row to the last row of the table." All mainstream // browsers act as if 0==1, though, and so does wxHTML. if (m_CellInfo[r][c].colspan < 1) m_CellInfo[r][c].colspan = 1; if (m_CellInfo[r][c].rowspan < 1) m_CellInfo[r][c].rowspan = 1; if ((m_CellInfo[r][c].colspan > 1) || (m_CellInfo[r][c].rowspan > 1)) { int i, j; if (r + m_CellInfo[r][c].rowspan > m_NumRows) ReallocRows(r + m_CellInfo[r][c].rowspan); if (c + m_CellInfo[r][c].colspan > m_NumCols) ReallocCols(c + m_CellInfo[r][c].colspan); for (i = r; i < r + m_CellInfo[r][c].rowspan; i++) for (j = c; j < c + m_CellInfo[r][c].colspan; j++) m_CellInfo[i][j].flag = cellSpan; m_CellInfo[r][c].flag = cellUsed; } } //background color: { wxColour bk = m_rBkg; tag.GetParamAsColour(wxT("BGCOLOR"), &bk); if (bk.IsOk()) cell->SetBackgroundColour(bk); } if (m_Border > 0) cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1); // vertical alignment: { wxString valign; if (!tag.GetParamAsString(wxT("VALIGN"), &valign)) valign = m_tValign; valign.MakeUpper(); if (valign == wxT("TOP")) m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP; else if (valign == wxT("BOTTOM")) m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM; else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER; } // nowrap m_CellInfo[r][c].nowrap = tag.HasParam(wxT("NOWRAP")); cell->SetIndent(m_Padding, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); }