本文整理汇总了C++中TableColumns::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TableColumns::empty方法的具体用法?C++ TableColumns::empty怎么用?C++ TableColumns::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableColumns
的用法示例。
在下文中一共展示了TableColumns::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTable
void GUITable::setTable(const TableOptions &options,
const TableColumns &columns,
std::vector<std::string> &content)
{
clear();
// Naming conventions:
// i is always a row index, 0-based
// j is always a column index, 0-based
// k is another index, for example an option index
// Handle a stupid error case... (issue #1187)
if (columns.empty()) {
TableColumn text_column;
text_column.type = "text";
TableColumns new_columns;
new_columns.push_back(text_column);
setTable(options, new_columns, content);
return;
}
// Handle table options
video::SColor default_color(255, 255, 255, 255);
s32 opendepth = 0;
for (size_t k = 0; k < options.size(); ++k) {
const std::string &name = options[k].name;
const std::string &value = options[k].value;
if (name == "color")
parseColorString(value, m_color, false);
else if (name == "background")
parseColorString(value, m_background, false);
else if (name == "border")
m_border = is_yes(value);
else if (name == "highlight")
parseColorString(value, m_highlight, false);
else if (name == "highlight_text")
parseColorString(value, m_highlight_text, false);
else if (name == "opendepth")
opendepth = stoi(value);
else
errorstream<<"Invalid table option: \""<<name<<"\""
<<" (value=\""<<value<<"\")"<<std::endl;
}
// Get number of columns and rows
// note: error case columns.size() == 0 was handled above
s32 colcount = columns.size();
assert(colcount >= 1);
// rowcount = ceil(cellcount / colcount) but use integer arithmetic
s32 rowcount = (content.size() + colcount - 1) / colcount;
assert(rowcount >= 0);
// Append empty strings to content if there is an incomplete row
s32 cellcount = rowcount * colcount;
while (content.size() < (u32) cellcount)
content.push_back("");
// Create temporary rows (for processing columns)
struct TempRow {
// Current horizontal position (may different between rows due
// to indent/tree columns, or text/image columns with width<0)
s32 x;
// Tree indentation level
s32 indent;
// Next cell: Index into m_strings or m_images
s32 content_index;
// Next cell: Width in pixels
s32 content_width;
// Vector of completed cells in this row
std::vector<Cell> cells;
// Stores colors and how long they last (maximum column index)
std::vector<std::pair<video::SColor, s32> > colors;
TempRow(): x(0), indent(0), content_index(0), content_width(0) {}
};
TempRow *rows = new TempRow[rowcount];
// Get em width. Pedantically speaking, the width of "M" is not
// necessarily the same as the em width, but whatever, close enough.
s32 em = 6;
if (m_font)
em = m_font->getDimension(L"M").Width;
s32 default_tooltip_index = allocString("");
std::map<s32, s32> active_image_indices;
// Process content in column-major order
for (s32 j = 0; j < colcount; ++j) {
// Check column type
ColumnType columntype = COLUMN_TYPE_TEXT;
if (columns[j].type == "text")
columntype = COLUMN_TYPE_TEXT;
else if (columns[j].type == "image")
columntype = COLUMN_TYPE_IMAGE;
else if (columns[j].type == "color")
columntype = COLUMN_TYPE_COLOR;
else if (columns[j].type == "indent")
columntype = COLUMN_TYPE_INDENT;
else if (columns[j].type == "tree")
columntype = COLUMN_TYPE_TREE;
//.........这里部分代码省略.........