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


C++ BButton类代码示例

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


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

示例1: BView

LoginView::LoginView(BRect rect, char *server, char *share) :
  BView(rect, "LoginView", B_FOLLOW_ALL, B_WILL_DRAW)
{
	strcpy(resource, share);
	strcat(resource, " on ");
	strcat(resource, server);

	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);
	BMimeType mime("application/x-vnd.Teldar-FileSharing");
	mime.GetIcon(icon, B_LARGE_ICON);

	BRect r(10, 72, 240, 92);
	user = new BTextControl(r, "User", "User:", "", NULL);
	user->SetDivider(55);
	AddChild(user);

	r.top = 97;
	r.bottom = r.top + 20;
	password = new BTextControl(r, "Password", "Password:", "", NULL);
	password->SetDivider(55);
	password->TextView()->HideTyping(true);
	AddChild(password);

	r.Set(LOGIN_PANEL_WIDTH - 160, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 90, LOGIN_PANEL_HEIGHT - 13);
	BButton *okBtn = new BButton(r, "OkayBtn", "Login", new BMessage(MSG_LOGIN_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	okBtn->MakeDefault(true);
	AddChild(okBtn);

	r.Set(LOGIN_PANEL_WIDTH - 80, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 10, LOGIN_PANEL_HEIGHT - 13);
	AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_LOGIN_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
}
开发者ID:HaikuArchives,项目名称:BeServed,代码行数:35,代码来源:LoginPanel.cpp

示例2: MAX

void
SetupView::AttachedToWindow()
{
	float width = MAX(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10;

	/* server name box */

	fServerAddress = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "<printer's hostname or address>", NULL);
	AddChild(fServerAddress);
	fServerAddress->SetDivider(width);

	/* queue name box */

	fQueuePort = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "9100", NULL);	// 9100 is default HP JetDirect port number
	AddChild(fQueuePort);
	fQueuePort->SetDivider(width);

	/* cancel */

	BButton* button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL));
	AddChild(button);

	/* ok */

	button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK));
	AddChild(button);
	button->MakeDefault(true);
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:28,代码来源:SetupWindow.cpp

示例3: BView

MainView::MainView( BRect frame ) : BView (frame, "mainView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {

	SetViewColor(216, 216, 216);

	// nutzbare Größe
	frame.OffsetTo( 0.0, 0.0 );
	frame.InsetBy( 5.0, 5.0 );
	
	// Erstellen der beiden inneren Frames
	TopView* topView = new TopView( BRect( frame.left, frame.top, frame.right, frame.bottom - 72.0 - be_plain_font->Size() - be_bold_font->Size() ) );
	AddChild( topView );

	BottomView* bottomView = new BottomView( BRect( frame.left, frame.bottom - 67.0 - be_plain_font->Size() - be_bold_font->Size(), frame.right, frame.bottom - 43.0 ) );
	AddChild( bottomView );

	// StatusBar
	BStatusBar*	statusBar	= new BStatusBar( BRect(frame.left + 5.0, frame.bottom - be_plain_font->Size() - 23.0, frame.left + 400.0, frame.bottom), "statusBar", STATUS_STATUS, NULL);
	statusBar->SetText(STATUS_SELECT_FILES);
	statusBar->SetResizingMode(B_FOLLOW_BOTTOM);
	rgb_color color = { 70, 100, 180, 255};
	statusBar->SetBarColor(color);
	statusBar->SetBarHeight(14.0);
	AddChild(statusBar);
	
	// Do it! - Button
	BButton* DoItButton = new BButton( BRect ( frame.right - be_plain_font->StringWidth(STR_DO_IT) - 25.0, frame.bottom - 30.0, frame.right - 5.0 , frame.bottom - 5.0 ), "DoIt", STR_DO_IT, new BMessage(MSG_DO_IT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
	DoItButton->SetEnabled(false);
	AddChild(DoItButton);
};
开发者ID:diversys,项目名称:PecoRename,代码行数:29,代码来源:MainView.cpp

示例4: InetHostView

		InetHostView(BRect rect) :
		  BView(rect, "InetHostView", B_FOLLOW_ALL, B_WILL_DRAW)
		{
			rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
			SetViewColor(gray);

			BRect bmpRect(0.0, 0.0, 31.0, 31.0);
			icon = new BBitmap(bmpRect, B_CMAP8);
			BMimeType mime("application/x-vnd.BeServed-inetserver");
			mime.GetIcon(icon, B_LARGE_ICON);

			BRect r(10, 52, 310, 72);
			editName = new BTextControl(r, "ShareName", "Name or Address:", "", NULL);
			editName->SetDivider(90);
			AddChild(editName);

			r.Set(155, 97, 225, 117);
			BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_HOST_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
			okBtn->MakeDefault(true);
			AddChild(okBtn);

			r.Set(235, 97, 310, 117);
			AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_HOST_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

			editName->MakeFocus();
		}
开发者ID:HaikuArchives,项目名称:BeServed,代码行数:26,代码来源:MyNetApp.cpp

示例5: LoadLayoutArchiveWindow

	LoadLayoutArchiveWindow(BRect frame) 
		:
		BWindow(frame, "Layout Loaded From Archive", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE
			| B_AUTO_UPDATE_SIZE_LIMITS)
	{
		fLayout = new BALMLayout(10, 10);
		BALM::BALMLayoutBuilder builder(this, fLayout);

		// Restore gui specifications. 
		BFile guiFile;
		_FindGUISpecifications(kGUIFileName, guiFile);

		LayoutArchive layoutArchive(fLayout);
		if (layoutArchive.RestoreFromFile(&guiFile) != B_OK) {
			BString text = "Can't find layout specification file: \"";
			text << kGUIFileName;
			text << "\"";
			BAlert* alert = new BAlert("Layout Specifications Not Found",
				text, "Quit");
			alert->Go();
			PostMessage(B_QUIT_REQUESTED);
		}

		// Access the views in the layout.

		BButton* button = layoutArchive.FindView<BButton>("ButtonTest");
		if (button != NULL)
			button->SetLabel("Hey");

		BRadioButton* radioButton
			= layoutArchive.FindView<BRadioButton>("RadioButtonTest");
		if (radioButton != NULL)
			radioButton->SetLabel("World");
	}
开发者ID:czeidler,项目名称:ALEditor,代码行数:34,代码来源:LoadLayoutArchive.cpp

示例6: BView

TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
		: BView(frame, name, resizingMode, flags)
{
	BFont font;

	BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
	btn->SetFontSize(20);
	AddChild(btn);

	btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
		btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
		btn->SetFontSize(24);
	}
	AddChild(btn);
	btn->ResizeToPreferred();

	btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
	btn->SetEnabled(false);
	AddChild(btn);
	btn->ResizeToPreferred();
}
开发者ID:D-os,项目名称:BeFree,代码行数:25,代码来源:button-test.cpp

示例7: BView

GroupPropertiesView::GroupPropertiesView(BRect rect, const char *name) :
    BView(rect, "GroupInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
    newGroup = name == NULL;
    strcpy(group, newGroup ? "unknown" : name);
    getGroupDesc(group, desc, sizeof(desc));

    rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
    SetViewColor(gray);

    BRect bmpRect(0.0, 0.0, 31.0, 31.0);
    icon = new BBitmap(bmpRect, B_CMAP8);
    BMimeType mime("application/x-vnd.Teldar-Group");
    mime.GetIcon(icon, B_LARGE_ICON);

    BRect r(10, 52, 200, 72);
    editName = new BTextControl(r, "GroupName", "Name:", group, NULL);
    editName->SetDivider(70);
    editName->SetEnabled(newGroup);
    AddChild(editName);

    r.Set(10, 77, 250, 97);
    editDesc = new BTextControl(r, "Description", "Description:", desc, NULL);
    editDesc->SetDivider(70);
    AddChild(editDesc);

    r.Set(205, 320, 275, 340);
    BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_GROUP_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    okBtn->MakeDefault(true);
    AddChild(okBtn);

    r.Set(285, 320, 360, 340);
    AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_GROUP_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

    r.Set(285, 125, 360, 145);
    AddChild(new BButton(r, "AddUserBtn", "Add", new BMessage(MSG_GROUP_ADD), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));

    r.Set(285, 155, 360, 175);
    removeBtn = new BButton(r, "RemoveBtn", "Remove", new BMessage(MSG_GROUP_REMOVE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    removeBtn->SetEnabled(false);
    AddChild(removeBtn);

    // Now add the membership list.
    CLVContainerView *listContView;
    r.Set(13, 125, 280 - B_V_SCROLL_BAR_WIDTH, 305);
    listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES,
                                       B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
                                       false, false, true, false, B_FANCY_BORDER);

    listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
                                      CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
    listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0));
    listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE));

    listView->SetSelectionMessage(new BMessage(MSG_MEMBER_SELECT));
    listView->SetInvocationMessage(new BMessage(MSG_LIST_DESELECT));

    AddGroupMembers(listView);
    AddChild(listContView);
}
开发者ID:HaikuArchives,项目名称:BeServed,代码行数:60,代码来源:GroupProperties.cpp

示例8: max

void
LprSetupView::AttachedToWindow()
{
	float width = max(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10;

	/* server name box */

    // TODO remember previous value
	fServer = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0",
		NULL);
	AddChild(fServer);
	fServer->SetDivider(width);

	/* queue name box */

    // TODO remember previous value
	fQueue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU",
		NULL);
	AddChild(fQueue);
	fQueue->SetDivider(width);

	/* cancel */

	BButton *button = new BButton(CANCEL_RECT, "", CANCEL_TEXT,
		new BMessage(M_CANCEL));
	AddChild(button);

	/* ok */

	button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK));
	AddChild(button);
	button->MakeDefault(true);
}
开发者ID:DonCN,项目名称:haiku,代码行数:33,代码来源:LprSetupDlg.cpp

示例9: show_window

// show_window
void
show_window(BRect frame, const char* name)
{
	BWindow* window = new BWindow(frame, name,
								  B_TITLED_WINDOW,
								  B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);

	BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL,
							   B_WILL_DRAW/* | B_FULL_UPDATE_ON_RESIZE*/);

	window->AddChild(view);
	BRect b(0.0, 0.0, 50.0, 15.0);
	b.OffsetTo(5.0, view->Bounds().bottom - (b.Height() + 15.0));
	BButton* control = new BButton(b, "button", "Copy", new BMessage(MSG_COPY_BITS));
	view->AddChild(control);
	control->SetTarget(view);

	// test CopyBits() on top of children
	b = BRect(80, 130, 130, 160);
	BView* child = new BView(b, "some child", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, 0);
	child->SetViewColor(255, 0, 0);
	view->AddChild(child);

	b = BRect(136, 127, 158, 140);
	child = new BView(b, "some other child", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, 0);
	child->SetViewColor(255, 255, 0);
	view->AddChild(child);

	window->Show();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:31,代码来源:main.cpp

示例10: BWindow

Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx)
	: BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
{
	int y = 0;
	BFont font;
	BMenu *menu;
	
	this->parent = parent;
	menu = parent->GetMenu(menu_name);
	menu->GetFont(&font);
	for(int i = 1; i < menu->CountItems(); i++) {
		BMenuItem *item = menu->ItemAt(i);
		if(item->Message()) {
			BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); 
			font.SetSize(TEAROFF_FONT_SIZE);
			b->SetFont(&font);
			AddChild(b);
			y = y + TEAROFF_BUTTON_HEIGHT;
		}
	}
	this->ResizeTo(frame.IntegerWidth(), y);
	this->SetTitle(menu->Name());
	this->index = idx;
	delete menu;
}
开发者ID:brennanos,项目名称:XFile-Haiku,代码行数:25,代码来源:Tearoff.cpp

示例11: addon_init

status_t addon_init (uint32 index, becasso_addon_info *info)
{
	strcpy (info->name, "CaptureTest");
	strcpy (info->author, "Sander Stoks");
	strcpy (info->copyright, "© 1998-2001 ∑ Sum Software");
	strcpy (info->description, "Fake Capture add-on");
	info->type				= BECASSO_CAPTURE;
	info->index				= index;
	info->version			= 1;
	info->release			= 2;
	info->becasso_version	= 2;
	info->becasso_release	= 0;
	info->does_preview		= 0;
	info->flags				= 0;
	window = new CaptureWindow (BRect (100, 180, 100 + 188, 180 + 72));
	BView *bg = new BView (BRect (0, 0, 188, 72), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	bg->SetViewColor (LightGrey);
	window->AddChild (bg);
	BMessage *msg = new BMessage (CAPTURE_READY);
	msg->AddInt32 ("index", index);
	BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg);
	grab->SetTarget (be_app);
	bg->AddChild (grab);
	window->Run();
	return (0);
}
开发者ID:gedrin,项目名称:Becasso,代码行数:26,代码来源:CaptureTest.cpp

示例12: BWindow

TStatusWindow::TStatusWindow(BRect rect, BMessenger target, const char* status)
	: BWindow(rect, "", B_MODAL_WINDOW, B_NOT_RESIZABLE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(view);

	BRect r(STATUS_FIELD_H, STATUS_FIELD_V,
		STATUS_FIELD_WIDTH, STATUS_FIELD_V + STATUS_FIELD_HEIGHT);

	fStatus = new BTextControl(r, "", STATUS_TEXT, status, new BMessage(STATUS));
	view->AddChild(fStatus);

	fStatus->SetDivider(fStatus->StringWidth(STATUS_TEXT) + 6);
	fStatus->BTextControl::MakeFocus(true);

	r.Set(S_OK_BUTTON_X1, S_OK_BUTTON_Y1, S_OK_BUTTON_X2, S_OK_BUTTON_Y2);
	BButton *button = new BButton(r, "", S_OK_BUTTON_TEXT, new BMessage(OK));
	view->AddChild(button);
	button->MakeDefault(true);

	r.Set(S_CANCEL_BUTTON_X1, S_CANCEL_BUTTON_Y1, S_CANCEL_BUTTON_X2, S_CANCEL_BUTTON_Y2);
	button = new BButton(r, "", S_CANCEL_BUTTON_TEXT, new BMessage(CANCEL));
	view->AddChild(button);

	Show();
}
开发者ID:DonCN,项目名称:haiku,代码行数:28,代码来源:Status.cpp

示例13: BMessage

BButton*
BAlert::_CreateButton(int32 which, const char* label)
{
	BMessage* message = new BMessage(kAlertButtonMsg);
	if (message == NULL)
		return NULL;

	message->AddInt32("which", which);

	BRect rect;
	rect.top = Bounds().bottom - kBottomOffset;
	rect.bottom = rect.top;

	char name[32];
	snprintf(name, sizeof(name), "_b%ld_", which);

	BButton* button = new(std::nothrow) BButton(rect, name, label, message,
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	if (button == NULL)
		return NULL;

	float width, height;
	button->GetPreferredSize(&width, &height);

	if (fButtonWidth == B_WIDTH_AS_USUAL) {
		float fontFactor = be_plain_font->Size() / 11.0f;
		width = max_c(width, kButtonUsualWidth * fontFactor);
	}

	button->ResizeTo(width, height);
	button->MoveBy(0.0f, -height);
	return button;
}
开发者ID:mmanley,项目名称:Antares,代码行数:33,代码来源:Alert.cpp

示例14: BButton

void AboutBoxView::AttachedToWindow()
{
	BRect rect;
	rect.Set(110, 50, 175, 55);
	BButton *button = new BButton(rect, "", "OK", new BMessage(kMsgOK));
	AddChild(button);
	button->MakeDefault(true);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:8,代码来源:AboutBox.cpp

示例15: FriendWindow

	FriendWindow(BRect frame) 
		:
		BWindow(frame, "ALM Friend Test", B_TITLED_WINDOW,
			B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS),
		fLayout2(NULL),
		fBoom(NULL),
		fLeft(NULL),
		fTop(NULL),
		fRight(NULL),
		fBottom(NULL)
	{
		BButton* button1 = _MakeButton("friends!");
		BButton* button2 = _MakeButton("friends!");
		BButton* button3 = _MakeButton("friends!");

		BButton* button4 = _MakeButton("friends!");
		BButton* button5 = _MakeButton("friends!");
		BButton* button6 = _MakeButton("friends!");

		BALMLayout* layout1 = new BALMLayout(10, 10);
		BView* almView1 = _MakeALMView(layout1);

		BReference<XTab> xTabs[2];
		layout1->AddXTabs(xTabs, 2);

		BALM::BALMLayoutBuilder(layout1)
			.Add(button1, layout1->Left(), layout1->Top(),
				xTabs[0], layout1->Bottom())
			.StartingAt(button1)
				.AddToRight(button2, xTabs[1])
				.AddToRight(button3, layout1->Right());

		fLayout2 = new BALMLayout(10, 10, layout1);
		BView* almView2 = _MakeALMView(fLayout2);

		BALM::BALMLayoutBuilder(fLayout2)
			.Add(button4, fLayout2->Left(), fLayout2->Top(), xTabs[0])
			.StartingAt(button4)
				.AddBelow(button5, NULL, xTabs[1], fLayout2->Right())
				.AddBelow(button6, fLayout2->Bottom(), xTabs[0]);

		fLeft = fLayout2->Left();
		fBottom = fLayout2->BottomOf(button5);
		fTop = fLayout2->BottomOf(button4);
		fRight = xTabs[1];

		layout1->AreaFor(button2)->SetContentAspectRatio(1.0f);
		fLayout2->Solver()->AddConstraint(-1.0f, layout1->Left(), 1.0f, xTabs[0],
			LinearProgramming::kLE, 90.0f);

		BButton* archiveButton = new BButton("clone", new BMessage('arcv'));
		archiveButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
				B_SIZE_UNSET));
		BLayoutBuilder::Group<>(this, B_VERTICAL)
			.Add(almView1->GetLayout())
			.Add(almView2->GetLayout())
			.Add(archiveButton);
	}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:58,代码来源:FriendLayout.cpp


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