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


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

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


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

示例1: BMessage

void
HWindow::_InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);

	BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);
	stopbutton->SetExplicitSize(buttonsSize);

	// We need at least one view to trigger B_PULSE_NEEDED events which we will
	// intercept in DispatchMessage to trigger the buttons enabling or disabling.
	stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);

	BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);
	playbutton->SetExplicitSize(buttonsSize);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(fEventList)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(playbutton)
				.Add(stopbutton)
			.End()
		.End();

	// setup file menu
	_SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);

	_UpdateZoomLimits();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:55,代码来源:HWindow.cpp

示例2: messenger

ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project)
	:
	BWindow(frame, TR("Project settings"), B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fProject(project),
	fDirty(false)
{
	if (fProject == NULL)
		debugger("Bad project given to Project Settings window");

	fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE);

	BMessenger messenger(this);
	entry_ref projectFolderRef;
	BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef);
	fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef,
		B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter);

	fAutolock = new BAutolock(fProject);

	AddCommonFilter(new EscapeCancelFilter());

	fTargetText = new AutoTextControl("targetname", TR("Target name:"),
		fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED));

	BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type"));
	targetTypeMenu->AddItem(new BMenuItem(TR("Application"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Static library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"),
		new BMessage(M_SET_TARGET_TYPE)));

	fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu);
	SetToolTip(fTypeField, TR("The kind of program you want to build"));

	BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType());
	if (item != NULL)
		item->SetMarked(true);

	fIncludeList = new IncludeList(fProject->GetPath().GetFolder());
	SetToolTip(fIncludeList,
		TR("The folders you want Paladin to search for header files"));

	BScrollView* includeScrollView = new BScrollView("includescrollview",
		fIncludeList, B_WILL_DRAW, true, true);
	includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	includeScrollView->SetExplicitMinSize(
		BSize(be_plain_font->StringWidth("M") * 34.0f,
			be_plain_font->StringWidth("M") * 12.0f));

	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) {
		fIncludeList->AddItem(new BStringItem(
			fProject->LocalIncludeAt(i).Relative().String()));
	}

	float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f;

	BButton* addButton = new BButton("addbutton", TR("+"),
		new BMessage(M_SHOW_ADD_PATH));
	addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	addButton->SetToolTip(TR("Add a file to the include path list"));

	BButton* removeButton = new BButton("removebutton", TR("−"),
		new BMessage(M_REMOVE_PATH));
	removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	removeButton->SetToolTip(TR("Remove the selected path"));

	// general tab

	fGeneralView = new BView(TR("General"), B_WILL_DRAW);
	fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fTargetText->CreateLabelLayoutItem(), 0, 0)
			.Add(fTargetText->CreateTextViewLayoutItem(), 1, 0)

			.Add(fTypeField->CreateLabelLayoutItem(), 0, 1)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1)
				.Add(fTypeField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
			.End()
		.AddStrut(B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL, 2.0f)
			.Add(new BStringView("include paths", TR("Include paths:")))
			.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
				.Add(includeScrollView)
				.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
					.Add(addButton)
					.Add(removeButton)
					.AddGlue()
					.End()
				.End()
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();
//.........这里部分代码省略.........
开发者ID:ModeenF,项目名称:Paladin,代码行数:101,代码来源:ProjectSettingsWindow.cpp

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