当前位置: 首页>>代码示例>>C++>>正文


C++ BButton::MinSize方法代码示例

本文整理汇总了C++中BButton::MinSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::MinSize方法的具体用法?C++ BButton::MinSize怎么用?C++ BButton::MinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BButton的用法示例。


在下文中一共展示了BButton::MinSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BMessage

BButton*
ScreenWindow::_CreateColumnRowButton(bool columns, bool plus)
{
	BMessage* message = new BMessage(kMsgWorkspaceLayoutChanged);
	message->AddInt32("delta_x", columns ? (plus ? 1 : -1) : 0);
	message->AddInt32("delta_y", !columns ? (plus ? 1 : -1) : 0);

	BButton* button = new BButton(plus ? "+" : "-", message);
	button->SetFontSize(be_plain_font->Size() * 0.9);

	BSize size = button->MinSize();
	size.width = button->StringWidth("+") + 16;
	button->SetExplicitMinSize(size);
	button->SetExplicitMaxSize(size);

	fWorkspacesButtons[(columns ? 0 : 2) + (plus ? 1 : 0)] = button;
	return button;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:18,代码来源:ScreenWindow.cpp

示例2: ButtonAt

/*!	Tweaks the layout according to the configuration.
*/
void
BAlert::_Prepare()
{
	// Must have at least one button
	if (CountButtons() == 0)
		debugger("BAlerts must have at least one button.");

	float fontFactor = be_plain_font->Size() / 11.0f;

	if (fIconView->Bitmap() == NULL)
		fIconView->SetBitmap(_CreateTypeIcon());

	if (fButtonWidth == B_WIDTH_AS_USUAL) {
		float usualWidth = kButtonUsualWidth * fontFactor;

		for (int32 index = 0; index < CountButtons(); index++) {
			BButton* button = ButtonAt(index);
			if (button->MinSize().width < usualWidth)
				button->SetExplicitSize(BSize(usualWidth, B_SIZE_UNSET));
		}
	} else if (fButtonWidth == B_WIDTH_FROM_WIDEST) {
		// Get width of widest label
		float maxWidth = 0;
		for (int32 index = 0; index < CountButtons(); index++) {
			BButton* button = ButtonAt(index);
			float width;
			button->GetPreferredSize(&width, NULL);

			if (width > maxWidth)
				maxWidth = width;
		}
		for (int32 index = 0; index < CountButtons(); index++) {
			BButton* button = ButtonAt(index);
			button->SetExplicitSize(BSize(maxWidth, B_SIZE_UNSET));
		}
	}

	if (fButtonSpacing == B_OFFSET_SPACING && CountButtons() > 1) {
		// Insert some strut
		fButtonLayout->AddItem(1, BSpaceLayoutItem::CreateHorizontalStrut(
			kButtonOffsetSpacing * fontFactor));
	}

	// Position the alert so that it is centered vertically but offset a bit
	// horizontally in the parent window's frame or, if unavailable, the
	// screen frame.
	float minWindowWidth = (fButtonSpacing == B_OFFSET_SPACING
		? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor;
	GetLayout()->SetExplicitMinSize(BSize(minWindowWidth, B_SIZE_UNSET));

	ResizeToPreferred();

	// Return early if we've already been moved...
	if (Frame().left != 0 && Frame().right != 0)
		return;

	// otherwise center ourselves on-top of parent window/screen
	BWindow* parent = dynamic_cast<BWindow*>(BLooper::LooperForThread(
		find_thread(NULL)));
	const BRect frame = parent != NULL ? parent->Frame()
		: BScreen(this).Frame();

	MoveTo(static_cast<BWindow*>(this)->AlertPosition(frame));
		// Hidden by BAlert::AlertPosition()
}
开发者ID:tqh,项目名称:haiku-efi,代码行数:67,代码来源:Alert.cpp


注:本文中的BButton::MinSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。