本文整理汇总了C++中Layout::MinimumColumnWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Layout::MinimumColumnWidth方法的具体用法?C++ Layout::MinimumColumnWidth怎么用?C++ Layout::MinimumColumnWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::MinimumColumnWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveButton
void RadioButtonGroup::RemoveButton(StateButton* button)
{
std::size_t index = NO_BUTTON;
for (std::size_t i = 0; i < m_button_slots.size(); ++i) {
if (m_button_slots[i].button == button) {
index = i;
break;
}
}
assert(index < m_button_slots.size());
const int CELLS_PER_BUTTON = m_expand_buttons ? 1 : 2;
Layout* layout = GetLayout();
layout->Remove(m_button_slots[index].button);
for (std::size_t i = index + 1; i < m_button_slots.size(); ++i) {
layout->Remove(m_button_slots[i].button);
if (m_orientation == VERTICAL) {
layout->Add(m_button_slots[i].button, i * CELLS_PER_BUTTON - CELLS_PER_BUTTON, 0);
layout->SetRowStretch(i * CELLS_PER_BUTTON - CELLS_PER_BUTTON, layout->RowStretch(i * CELLS_PER_BUTTON));
layout->SetMinimumRowHeight(i * CELLS_PER_BUTTON - CELLS_PER_BUTTON, layout->MinimumRowHeight(i * CELLS_PER_BUTTON));
} else {
layout->Add(m_button_slots[i].button, 0, i * CELLS_PER_BUTTON - CELLS_PER_BUTTON);
layout->SetColumnStretch(i * CELLS_PER_BUTTON - CELLS_PER_BUTTON, layout->ColumnStretch(i * CELLS_PER_BUTTON));
layout->SetMinimumColumnWidth(i * CELLS_PER_BUTTON - CELLS_PER_BUTTON, layout->MinimumColumnWidth(i * CELLS_PER_BUTTON));
}
}
m_button_slots[index].connection.disconnect();
m_button_slots.erase(m_button_slots.begin() + index);
if (m_button_slots.empty()) {
layout->ResizeLayout(1, 1);
} else {
if (m_orientation == VERTICAL)
layout->ResizeLayout(layout->Rows() - CELLS_PER_BUTTON, 1);
else
layout->ResizeLayout(1, layout->Columns() - CELLS_PER_BUTTON);
}
if (index == m_checked_button)
m_checked_button = NO_BUTTON;
else if (index <= m_checked_button)
--m_checked_button;
Reconnect();
}
示例2: InsertButton
void RadioButtonGroup::InsertButton(std::size_t index, StateButton* bn)
{
assert(index <= m_button_slots.size());
if (!m_expand_buttons) {
Pt min_usable_size = bn->MinUsableSize();
bn->Resize(Pt(std::max(bn->Width(), min_usable_size.x), std::max(bn->Height(), min_usable_size.y)));
}
Pt bn_sz = bn->Size();
Layout* layout = GetLayout();
if (!layout) {
layout = new Layout(X0, Y0, ClientWidth(), ClientHeight(), 1, 1);
SetLayout(layout);
}
const int CELLS_PER_BUTTON = m_expand_buttons ? 1 : 2;
const int X_STRETCH = (m_expand_buttons && m_expand_buttons_proportionally) ? Value(bn_sz.x) : 1;
const int Y_STRETCH = (m_expand_buttons && m_expand_buttons_proportionally) ? Value(bn_sz.y) : 1;
if (m_button_slots.empty()) {
layout->Add(bn, 0, 0);
if (m_expand_buttons) {
if (m_orientation == VERTICAL)
layout->SetRowStretch(0, Y_STRETCH);
else
layout->SetColumnStretch(0, X_STRETCH);
}
} else {
if (m_orientation == VERTICAL) {
layout->ResizeLayout(layout->Rows() + CELLS_PER_BUTTON, 1);
layout->SetRowStretch(layout->Rows() - CELLS_PER_BUTTON, Y_STRETCH);
} else {
layout->ResizeLayout(1, layout->Columns() + CELLS_PER_BUTTON);
layout->SetColumnStretch(layout->Columns() - CELLS_PER_BUTTON, X_STRETCH);
}
for (std::size_t i = m_button_slots.size() - 1; index <= i; --i) {
layout->Remove(m_button_slots[i].button);
layout->Add(m_button_slots[i].button,
m_orientation == VERTICAL ? i * CELLS_PER_BUTTON + CELLS_PER_BUTTON : 0,
m_orientation == VERTICAL ? 0 : i * CELLS_PER_BUTTON + CELLS_PER_BUTTON);
if (m_orientation == VERTICAL)
layout->SetMinimumRowHeight(i * CELLS_PER_BUTTON + CELLS_PER_BUTTON, layout->MinimumRowHeight(i * CELLS_PER_BUTTON));
else
layout->SetMinimumColumnWidth(i * CELLS_PER_BUTTON + CELLS_PER_BUTTON, layout->MinimumColumnWidth(i * CELLS_PER_BUTTON));
}
layout->Add(bn, m_orientation == VERTICAL ? index * CELLS_PER_BUTTON : 0, m_orientation == VERTICAL ? 0 : index * CELLS_PER_BUTTON);
}
if (m_orientation == VERTICAL)
layout->SetMinimumRowHeight(index * CELLS_PER_BUTTON, bn_sz.y);
else
layout->SetMinimumColumnWidth(index * CELLS_PER_BUTTON, bn_sz.x);
m_button_slots.insert(m_button_slots.begin() + index, ButtonSlot(bn));
if (m_checked_button != NO_BUTTON && index <= m_checked_button)
++m_checked_button;
Reconnect();
}