本文整理汇总了C++中CollapsedBorderValue::precedence方法的典型用法代码示例。如果您正苦于以下问题:C++ CollapsedBorderValue::precedence方法的具体用法?C++ CollapsedBorderValue::precedence怎么用?C++ CollapsedBorderValue::precedence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollapsedBorderValue
的用法示例。
在下文中一共展示了CollapsedBorderValue::precedence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareBorders
// The following rules apply for resolving conflicts and figuring out which border
// to use.
// (1) Borders with the 'border-style' of 'hidden' take precedence over all other conflicting
// borders. Any border with this value suppresses all borders at this location.
// (2) Borders with a style of 'none' have the lowest priority. Only if the border properties of all
// the elements meeting at this edge are 'none' will the border be omitted (but note that 'none' is
// the default value for the border style.)
// (3) If none of the styles are 'hidden' and at least one of them is not 'none', then narrow borders
// are discarded in favor of wider ones. If several have the same 'border-width' then styles are preferred
// in this order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', and the lowest: 'inset'.
// (4) If border styles differ only in color, then a style set on a cell wins over one on a row,
// which wins over a row group, column, column group and, lastly, table. It is undefined which color
// is used when two elements of the same type disagree.
static int compareBorders(const CollapsedBorderValue& border1, const CollapsedBorderValue& border2)
{
// Sanity check the values passed in. The null border have lowest priority.
if (!border2.exists()) {
if (!border1.exists())
return 0;
return 1;
}
if (!border1.exists())
return -1;
// Rule #1 above.
if (border2.style() == BHIDDEN) {
if (border1.style() == BHIDDEN)
return 0;
return -1;
}
if (border1.style() == BHIDDEN)
return 1;
// Rule #2 above. A style of 'none' has lowest priority and always loses to any other border.
if (border2.style() == BNONE) {
if (border1.style() == BNONE)
return 0;
return 1;
}
if (border1.style() == BNONE)
return -1;
// The first part of rule #3 above. Wider borders win.
if (border1.width() != border2.width())
return border1.width() < border2.width() ? -1 : 1;
// The borders have equal width. Sort by border style.
if (border1.style() != border2.style())
return border1.style() < border2.style() ? -1 : 1;
// The border have the same width and style. Rely on precedence (cell over row over row group, etc.)
if (border1.precedence() == border2.precedence())
return 0;
return border1.precedence() < border2.precedence() ? -1 : 1;
}