本文整理汇总了C++中ListBox::sizeForNumberOfLines方法的典型用法代码示例。如果您正苦于以下问题:C++ ListBox::sizeForNumberOfLines方法的具体用法?C++ ListBox::sizeForNumberOfLines怎么用?C++ ListBox::sizeForNumberOfLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox::sizeForNumberOfLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void DeprecatedRenderSelect::layout()
{
ASSERT(needsLayout());
ASSERT(minMaxKnown());
// ### maintain selection properly between type/size changes, and work
// out how to handle multiselect->singleselect (probably just select
// first selected one)
// calculate size
ListBox* w = static_cast<ListBox*>(m_widget);
int size = m_size;
// check if multiple and size was not given or invalid
// Internet Exploder sets size to min(number of elements, 4)
// Netscape seems to simply set it to "number of elements"
// the average of that is IMHO min(number of elements, 10)
// so I did that ;-)
if (size < 1)
size = min(static_cast<ListBox*>(m_widget)->count(), 10U);
// Let the widget tell us how big it wants to be.
IntSize s(w->sizeForNumberOfLines(size));
setIntrinsicWidth(s.width());
setIntrinsicHeight(s.height());
RenderFormElement::layout();
// and now disable the widget in case there is no <option> given
const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
bool foundOption = false;
for (unsigned i = 0; i < listItems.size() && !foundOption; i++)
foundOption = (listItems[i]->hasTagName(optionTag));
m_widget->setEnabled(foundOption && ! static_cast<HTMLSelectElement*>(node())->disabled());
}