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


C++ BGridLayout::AddItem方法代码示例

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


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

示例1: ContactFieldTextControl

	virtual void 	Visit(BStringContactField* field)
	{
		int count = fOwner->fControls.CountItems();
		BGridLayout* layout = fOwner->GridLayout();
		if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
			ContactFieldTextControl* control = new ContactFieldTextControl(field);

			layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
			layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
			fOwner->fControls.AddItem(control);
		} else {
			const char* label = 
				BContactField::ExtendedLabel(field);

			fOwner->fGroups = new BPopUpMenu(label);
			fOwner->fGroups->SetRadioMode(false);
			fOwner->BuildGroupMenu(field);

			BMenuField* field = new BMenuField("", "", fOwner->fGroups);
			BTextControl* control = new BTextControl("simpleGroup",
				NULL, NULL, NULL);

			field->SetEnabled(true);
			layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
			layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
			layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
			layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
		}
	}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:29,代码来源:PersonView.cpp

示例2: AttributeTextControl

void
PersonView::AddAttribute(const char* label, const char* attribute)
{
	// Check if this attribute has already been added.
	AttributeTextControl* control = NULL;
	for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
		if (fControls.ItemAt(i)->Attribute() == attribute) {
			return;
		}
	}

	control = new AttributeTextControl(label, attribute);
	fControls.AddItem(control);

	BGridLayout* layout = GridLayout();
	int32 row = fControls.CountItems();

	if (fCategoryAttribute == attribute) {
		// Special case the category attribute. The Group popup field will
		// be added as the label instead.
		fGroups = new BPopUpMenu(label);
		fGroups->SetRadioMode(false);
		BuildGroupMenu();

		BMenuField* field = new BMenuField("", "", fGroups);
		field->SetEnabled(true);
		layout->AddView(field, 1, row);

		control->SetLabel("");
		layout->AddView(control, 2, row);
	} else {
		layout->AddItem(control->CreateLabelLayoutItem(), 1, row);
		layout->AddItem(control->CreateTextViewLayoutItem(), 2, row);
	}

	SetAttribute(attribute, true);
}
开发者ID:looncraz,项目名称:haiku,代码行数:37,代码来源:PersonView.cpp

示例3: BPopUpMenu

StyleView::StyleView(BRect frame)
	:
	BView("style view", 0),
	fCommandStack(NULL),
	fCurrentColor(NULL),
	fStyle(NULL),
	fGradient(NULL),
	fIgnoreCurrentColorNotifications(false),
	fIgnoreControlGradientNotifications(false),
	fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// style type
	BMenu* menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
	BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_COLOR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Color"), message));
	message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_GRADIENT);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Gradient"), message));

	BGridLayout* layout = new BGridLayout(5, 5);
	SetLayout(layout);

	fStyleType = new BMenuField(B_TRANSLATE("Style type"), menu);

	// gradient type
	menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_LINEAR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Linear"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CIRCULAR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Radial"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_DIAMOND);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Diamond"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CONIC);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Conic"), message));

	fGradientType = new BMenuField(B_TRANSLATE("Gradient type"), menu);
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);

	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);

	layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
	layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);

	layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
	layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);

	layout->AddView(fGradientControl, 1, 3, 2);

	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);

	fStyleType->SetEnabled(false);
	fGradientType->SetEnabled(false);
	fGradientControl->SetEnabled(false);
	fGradientControl->Gradient()->AddObserver(this);
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:64,代码来源:StyleView.cpp

示例4: BMessage

	KeyRequestView()
		:
		BView("KeyRequestView", B_WILL_DRAW),
		fPassword(NULL)
	{
		SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

		BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL);
		if (rootLayout == NULL)
			return;

		SetLayout(rootLayout);

		BGridView* controls = new(std::nothrow) BGridView();
		if (controls == NULL)
			return;

		BGridLayout* layout = controls->GridLayout();

		float inset = ceilf(be_plain_font->Size() * 0.7);
		rootLayout->SetInsets(inset, inset, inset, inset);
		rootLayout->SetSpacing(inset);
		layout->SetSpacing(inset, inset);

		BStringView* label = new(std::nothrow) BStringView("keyringLabel",
			B_TRANSLATE("Keyring:"));
		if (label == NULL)
			return;

		int32 row = 0;
		layout->AddView(label, 0, row);

		fKeyringName = new(std::nothrow) BStringView("keyringName", "");
		if (fKeyringName == NULL)
			return;

		layout->AddView(fKeyringName, 1, row++);

		fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"), "", NULL);
		if (fPassword == NULL)
			return;

		BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem();
		layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
				"0123456789012345678901234567890123456789") + inset,
			B_SIZE_UNSET));

		layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row);
		layout->AddItem(layoutItem, 1, row++);

		BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL);
		if (buttons == NULL)
			return;

		fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"),
			new BMessage(kMessageCancel));
		buttons->GroupLayout()->AddView(fCancelButton);

		buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

		fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"),
			new BMessage(kMessageUnlock));
		buttons->GroupLayout()->AddView(fUnlockButton);

		BTextView* message = new(std::nothrow) BTextView("message");
		message->SetText(B_TRANSLATE("An application wants to access the "
			"keyring below, but it is locked with a passphrase. Please enter "
			"the passphrase to unlock the keyring.\n"
			"If you unlock the keyring, it stays unlocked until the system is "
			"shut down or the keyring is manually locked again.\n"
			"If you cancel this dialog the keyring will remain locked."));
		message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
		rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
		message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
		message->MakeEditable(false);
		message->MakeSelectable(false);
		message->SetWordWrap(true);

		rootLayout->AddView(message);
		rootLayout->AddView(controls);
		rootLayout->AddView(buttons);
	}
开发者ID:garodimb,项目名称:haiku,代码行数:82,代码来源:KeyRequestWindow.cpp

示例5: BMessage


//.........这里部分代码省略.........
	int32 layoutRow = 0;

	fButtonBarMenu = _BuildButtonBarMenu(*buttonBar);
	menu = new BMenuField("bar", B_TRANSLATE("Button bar:"), fButtonBarMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);

	fFontMenu = _BuildFontMenu(font);
	menu = new BMenuField("font", B_TRANSLATE("Font:"), fFontMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);

	fSizeMenu = _BuildSizeMenu(font);
	menu = new BMenuField("size", B_TRANSLATE("Size:"), fSizeMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);

	fColoredQuotesMenu = _BuildColoredQuotesMenu(fColoredQuotes);
	menu = new BMenuField("cquotes", B_TRANSLATE("Colored quotes:"),
		fColoredQuotesMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);

	fSpellCheckStartOnMenu = _BuildSpellCheckStartOnMenu(fSpellCheckStartOn);
	menu = new BMenuField("spellCheckStartOn",
		B_TRANSLATE("Initial spell check mode:"),
		fSpellCheckStartOnMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);

	fAutoMarkReadMenu = _BuildAutoMarkReadMenu(fAutoMarkRead);
	menu = new BMenuField("autoMarkRead",
		B_TRANSLATE("Automatically mark mail as read:"),
		fAutoMarkReadMenu);
	add_menu_to_layout(menu, interfaceLayout, layoutRow);
	// Mail Accounts

	layoutRow = 0;

	fAccountMenu = _BuildAccountMenu(fAccount);
	menu = new BMenuField("account", B_TRANSLATE("Default account:"),
		fAccountMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	fReplyToMenu = _BuildReplyToMenu(fReplyTo);
	menu = new BMenuField("replyTo", B_TRANSLATE("Reply account:"),
		fReplyToMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	// Mail Contents

	fReplyPreamble = new BTextControl("replytext",
		B_TRANSLATE("Reply preamble:"),
		*preamble, new BMessage(P_REPLY_PREAMBLE));
	fReplyPreamble->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	fReplyPreambleMenu = _BuildReplyPreambleMenu();
	menu = new BMenuField("replyPreamble", NULL, fReplyPreambleMenu);
	menu->SetExplicitMaxSize(BSize(27, B_SIZE_UNSET));

	mailLayout->AddItem(fReplyPreamble->CreateLabelLayoutItem(), 0, layoutRow);
	mailLayout->AddItem(fReplyPreamble->CreateTextViewLayoutItem(), 1,
		layoutRow);
	mailLayout->AddView(menu, 2, layoutRow);
	layoutRow++;

	fSignatureMenu = _BuildSignatureMenu(*sig);
	menu = new BMenuField("sig", B_TRANSLATE("Auto signature:"),
		fSignatureMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	fEncodingMenu = _BuildEncodingMenu(fEncoding);
	menu = new BMenuField("enc", B_TRANSLATE("Encoding:"), fEncodingMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	fWarnUnencodableMenu = _BuildWarnUnencodableMenu(fWarnUnencodable);
	menu = new BMenuField("warnUnencodable", B_TRANSLATE("Warn unencodable:"),
		fWarnUnencodableMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	fWrapMenu = _BuildWrapMenu(*wrap);
	menu = new BMenuField("wrap", B_TRANSLATE("Text wrapping:"), fWrapMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	fAttachAttributesMenu = _BuildAttachAttributesMenu(*attachAttributes);
	menu = new BMenuField("attachAttributes", B_TRANSLATE("Attach attributes:"),
		fAttachAttributesMenu);
	add_menu_to_layout(menu, mailLayout, layoutRow);

	SetLayout(new BGroupLayout(B_HORIZONTAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, kSpacing)
		.Add(interfaceBox)
		.Add(mailBox)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, kSpacing)
			.Add(fRevert)
			.AddGlue()
			.Add(cancelButton)
			.Add(okButton)
		)
		.SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
	);

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

示例6: winFrame

PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
    : BlockingWindow(BRect(0, 0, 100, 100), "Page setup",
                     B_TITLED_WINDOW_LOOK,
                     B_MODAL_APP_WINDOW_FEEL,
                     B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
                     | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
      fSetupMsg(msg),
      fPrinterDirName(printerName)
{
    if (printerName)
        SetTitle(BString(printerName).Append(" Page setup").String());

    // load orientation
    if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
        fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

    // load page rect
    BRect page;
    float width = letter_width;
    float height = letter_height;
    if (fSetupMsg->FindRect("preview:paper_rect", &page) == B_OK) {
        width = page.Width();
        height = page.Height();
    } else {
        page.Set(0, 0, width, height);
    }

    BString label;
    if (fSetupMsg->FindString("preview:paper_size", &label) != B_OK)
        label = "Letter";

    // Load units
    int32 units;
    if (fSetupMsg->FindInt32("units", &units) != B_OK)
        units = kUnitInch;

    // re-calculate the margin from the printable rect in points
    BRect margin = page;
    if (fSetupMsg->FindRect("preview:printable_rect", &margin) == B_OK) {
        margin.top -= page.top;
        margin.left -= page.left;
        margin.right = page.right - margin.right;
        margin.bottom = page.bottom - margin.bottom;
    } else {
        margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
    }


    fMarginView = new MarginView(int32(width), int32(height), margin,
                                 MarginUnit(units));

    BPopUpMenu* pageSizePopUpMenu = new BPopUpMenu("Page size");
    pageSizePopUpMenu->SetRadioMode(true);

    fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSizePopUpMenu);
    fPageSizeMenu->Menu()->SetLabelFromMarked(true);

    for (int32 i = 0; pageFormat[i].label != NULL; i++) {
        BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
        message->AddFloat("width", pageFormat[i].width);
        message->AddFloat("height", pageFormat[i].height);
        BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
        pageSizePopUpMenu->AddItem(item);

        if (label.Compare(pageFormat[i].label) == 0)
            item->SetMarked(true);
    }

    BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
    orientationPopUpMenu->SetRadioMode(true);

    fOrientationMenu = new BMenuField("orientation", "Orientation:",
                                      orientationPopUpMenu);
    fOrientationMenu->Menu()->SetLabelFromMarked(true);

    for (int32 i = 0; orientation[i].label != NULL; i++) {
        BMessage* message = new BMessage(ORIENTATION_CHANGED);
        message->AddInt32("orientation", orientation[i].orientation);
        BMenuItem* item = new BMenuItem(orientation[i].label, message);
        orientationPopUpMenu->AddItem(item);

        if (fCurrentOrientation == orientation[i].orientation)
            item->SetMarked(true);
    }

    float scale0;
    BString scale;
    if (fSetupMsg->FindFloat("scale", &scale0) == B_OK)
        scale << (int)scale0;
    else
        scale = "100";

    fScaleControl = new BTextControl("scale", "Scale [%]:",
                                     scale.String(), NULL);

    for (uint32 i = 0; i < '0'; i++)
        fScaleControl->TextView()->DisallowChar(i);

    for (uint32 i = '9' + 1; i < 255; i++)
        fScaleControl->TextView()->DisallowChar(i);
//.........这里部分代码省略.........
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:101,代码来源:PageSetupWindow.cpp

示例7: BMessage

void
VideoWindow::_BuildCaptureControls(BView* theView)
{
	// a view to hold the video image
	fVideoView = new BView("Video View", B_WILL_DRAW);
	fVideoView->SetExplicitMinSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y));
	fVideoView->SetExplicitMaxSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y));

	// Capture controls
	fCaptureSetupBox = new BBox("Capture Controls", B_WILL_DRAW);
	fCaptureSetupBox->SetLabel("Capture controls");

	BGridLayout *controlsLayout = new BGridLayout(kXBuffer, 0);
	controlsLayout->SetInsets(10, 15, 5, 5);
	fCaptureSetupBox->SetLayout(controlsLayout);

	fFileName = new BTextControl("File Name", "File name:",
		fFilenameSetting->Value(), new BMessage(msg_filename));
	fFileName->SetTarget(BMessenger(NULL, this));

	fImageFormatMenu = new BPopUpMenu("Image Format Menu");
	AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP);
	fImageFormatMenu->SetTargetForItems(this);

	if (fImageFormatSettings->Value()
		&& fImageFormatMenu->FindItem(fImageFormatSettings->Value()) != NULL) {
		fImageFormatMenu->FindItem(
			fImageFormatSettings->Value())->SetMarked(true);
	} else if (fImageFormatMenu->FindItem("JPEG image") != NULL)
		fImageFormatMenu->FindItem("JPEG image")->SetMarked(true);
	else
		fImageFormatMenu->ItemAt(0)->SetMarked(true);

	fImageFormatSelector = new BMenuField("Format", "Format:",
		fImageFormatMenu, NULL);

	fCaptureRateMenu = new BPopUpMenu("Capture Rate Menu");
	fCaptureRateMenu->AddItem(new BMenuItem("Every 15 seconds",
		new BMessage(msg_rate_15s)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 30 seconds",
		new BMessage(msg_rate_30s)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every minute",
		new BMessage(msg_rate_1m)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 5 minutes",
		new BMessage(msg_rate_5m)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 10 minutes",
		new BMessage(msg_rate_10m)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 15 minutes",
		new BMessage(msg_rate_15m)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 30 minutes",
		new BMessage(msg_rate_30m)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every hour",
		new BMessage(msg_rate_1h)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 2 hours",
		new BMessage(msg_rate_2h)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 4 hours",
		new BMessage(msg_rate_4h)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 8 hours",
		new BMessage(msg_rate_8h)));
	fCaptureRateMenu->AddItem(new BMenuItem("Every 24 hours",
		new BMessage(msg_rate_24h)));
	fCaptureRateMenu->AddItem(new BMenuItem("Never",
		new BMessage(msg_rate_never)));
	fCaptureRateMenu->SetTargetForItems(this);
	fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true);
	fCaptureRateSelector = new BMenuField("Rate", "Rate:",
		fCaptureRateMenu, NULL);

	controlsLayout->AddItem(fFileName->CreateLabelLayoutItem(), 0, 0);
	controlsLayout->AddItem(fFileName->CreateTextViewLayoutItem(), 1, 0);
	controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0, 1);
	controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1, 1);
	controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0, 2);
	controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1, 2);
	controlsLayout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 3, 2);

	// FTP setup box
	fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);

	fUploadClientMenu = new BPopUpMenu("Send to" B_UTF8_ELLIPSIS);
	for (int i = 0; kUploadClient[i]; i++) {
		BMessage *m = new BMessage(msg_upl_client);
		m->AddInt32("client", i);
		fUploadClientMenu->AddItem(new BMenuItem(kUploadClient[i], m));
	}
	fUploadClientMenu->SetTargetForItems(this);
	fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
	fUploadClientSelector = new BMenuField("UploadClient", NULL,
		fUploadClientMenu, NULL);

	fFtpSetupBox->SetLabel("Output");
	// this doesn't work with the layout manager
	// fFtpSetupBox->SetLabel(fUploadClientSelector);
	fUploadClientSelector->SetLabel("Type:");

	BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0);
	ftpLayout->SetInsets(10, 15, 5, 5);
	fFtpSetupBox->SetLayout(ftpLayout);

	fServerName = new BTextControl("Server", "Server:",
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:CodyCam.cpp

示例8: r


//.........这里部分代码省略.........
	layoutItem->SetExplicitMinSize( BSize( ( B_V_SCROLL_BAR_WIDTH * 2 ), r.Height() ) );
	gridLayout->SetMaxColumnWidth( 0, r.Width()-70 );
	gridLayout->SetMaxColumnWidth( 1, r.Width()-66 );
	
	// Add categories to the list
	PopulateCategoriesView();
	
	/* Creating the buttons */
	// Add new category button
	toSend = new BMessage( kAddNewCategory );
	addButton = new BButton( BRect( 0, 0, 1, 1), 
							 "Add category",
							 "Add category",
							 toSend,
							 B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !toSend || !addButton ) {
		/* Panic! */
		exit( 1 );
	}
	addButton->ResizeToPreferred();
	addButton->SetTarget( this );
	layoutItem = gridLayout->AddView( addButton, 1, 0, 1, 1 );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
	
	// Edit old category button
	toSend = new BMessage( kCategoryInvoked );
	editButton = new BButton( BRect( 0, 0, 1, 1), 
							 "Edit category",
							 "Edit category",
							 toSend,
							 B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !toSend || !editButton ) {
		/* Panic! */
		exit( 1 );
	}
	editButton->ResizeToPreferred();
	editButton->SetTarget( this );
	layoutItem = gridLayout->AddView( editButton, 1, 1, 1, 1 );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
	// Edit category button is disabled by default; 
	// it's enabled when user chooses a category in the list.
	editButton->SetEnabled( false );
	
	/* Creating the menu of merging a category */
	// Create a label
	BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
	if ( !groupLayout )
	{
		/* Panic! */
		exit( 1 );
	}
	gridLayout->AddItem( groupLayout, 1, 2, 1, 1 );
	groupLayout->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	
	mergeToLabel = new BStringView( BRect( 0, 0, 1, 1 ),
								"Merge to label",
								"Merge selected category into:" );
	if ( !mergeToLabel ) {
		/* Panic! */
		exit( 1 );
	}
	mergeToLabel->ResizeToPreferred();
	layoutItem = groupLayout->AddView( mergeToLabel );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	
	// Create the menu
	BMessage templateMessage( kMergeIntoCategory );
	listMenu = new CategoryMenu( "Select category to merge to:", true, &templateMessage );
	if ( !listMenu )
	{
		/* Panic! */
		exit( 1 );
	}	
	
	menuField = new BMenuField( mergeToLabel->Bounds(),
								"Merge to field",
								NULL,
								listMenu );
	if ( !menuField ) {
		/* Panic! */
		exit( 1 );
	}
	menuField->SetDivider( 0 );
	// Just like the "Edit" button above, the menu is initially disabled.
	menuField->SetEnabled( false );
	
	layoutItem = groupLayout->AddView( menuField );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
	
	for ( int index = 0; index < gridLayout->CountColumns(); ++index )
	{
		gridLayout->SetColumnWeight( index, 1 );
	}
	for ( int index = 0; index < gridLayout->CountRows(); ++index )
	{
		gridLayout->SetRowWeight( index, 1 );	
	}
	gridLayout->InvalidateLayout();
	
}	// <-- end of constructor of CategoryPreferencesView
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:101,代码来源:CategoryPreferencesView.cpp

示例9: PageView

/**
 * _ConstructGUI()
 *
 * Creates the GUI for the View. MUST be called AFTER the View is attached to
 *	the Window, or will crash and/or create strange behaviour
 *
 * @param none
 * @return void
 */
void
MarginView::_ConstructGUI()
{
	fPage = new PageView();
	fPage->SetViewColor(ViewColor());

	fPageSize = new BStringView("pageSize", "?x?");

	BString str;
	// Create text fields

	// top
	str << fMargins.top/fUnitValue;
	fTop = new BTextControl("top", "Top:", str.String(), NULL);

	fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
	fTop->SetTarget(this);
	_AllowOnlyNumbers(fTop, kNumCount);

	//left
    str = "";
	str << fMargins.left/fUnitValue;
	fLeft = new BTextControl("left", "Left:", str.String(), NULL);

	fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
	fLeft->SetTarget(this);
	_AllowOnlyNumbers(fLeft, kNumCount);

	//bottom
    str = "";
	str << fMargins.bottom/fUnitValue;
	fBottom = new BTextControl("bottom", "Bottom:", str.String(), NULL);

	fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
	fBottom->SetTarget(this);
	_AllowOnlyNumbers(fBottom, kNumCount);

	//right
    str = "";
	str << fMargins.right/fUnitValue;
	fRight = new BTextControl("right", "Right:", str.String(), NULL);

	fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
	fRight->SetTarget(this);
	_AllowOnlyNumbers(fRight, kNumCount);

	// Create Units popup

	BPopUpMenu *menu = new BPopUpMenu("units");
	BMenuField *units = new BMenuField("units", "Units:", menu);

	BMenuItem *item;
	// Construct menu items
	for (int32 i = 0; kUnitNames[i] != NULL; i++) {
		BMessage *msg = new BMessage(MARGIN_UNIT_CHANGED);
		msg->AddInt32("marginUnit", kUnitMsg[i]);
		menu->AddItem(item = new BMenuItem(kUnitNames[i], msg));
		item->SetTarget(this);
		if (fMarginUnit == kUnitMsg[i])
			item->SetMarked(true);
	}

	BGridView* settings = new BGridView();
	BGridLayout* settingsLayout = settings->GridLayout();
	settingsLayout->AddItem(fTop->CreateLabelLayoutItem(), 0, 0);
	settingsLayout->AddItem(fTop->CreateTextViewLayoutItem(), 1, 0);
	settingsLayout->AddItem(fLeft->CreateLabelLayoutItem(), 0, 1);
	settingsLayout->AddItem(fLeft->CreateTextViewLayoutItem(), 1, 1);
	settingsLayout->AddItem(fBottom->CreateLabelLayoutItem(), 0, 2);
	settingsLayout->AddItem(fBottom->CreateTextViewLayoutItem(), 1, 2);
	settingsLayout->AddItem(fRight->CreateLabelLayoutItem(), 0, 3);
	settingsLayout->AddItem(fRight->CreateTextViewLayoutItem(), 1, 3);
	settingsLayout->AddItem(units->CreateLabelLayoutItem(), 0, 4);
	settingsLayout->AddItem(units->CreateMenuBarLayoutItem(), 1, 4);
	settingsLayout->SetSpacing(0, 0);

	BGroupView* groupView = new BGroupView(B_HORIZONTAL, 10);
	BGroupLayout* groupLayout = groupView->GroupLayout();
	groupLayout->AddView(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(fPage)
		.Add(fPageSize)
		.SetInsets(0, 0, 0, 0)
		.TopView()
	);
	groupLayout->AddView(settings);
	groupLayout->SetInsets(5, 5, 5, 5);

	AddChild(groupView);

	UpdateView(MARGIN_CHANGED);
}
开发者ID:looncraz,项目名称:haiku,代码行数:100,代码来源:MarginView.cpp

示例10: BMessage

PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	: HWindow(BRect(0, 0, 200, 100), "Page setup", B_TITLED_WINDOW_LOOK,
 		B_MODAL_APP_WINDOW_FEEL,
 		B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
			| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
	 fResult(B_ERROR),
	 fSetupMsg(msg),
	 fAdvancedSettings(*msg),
	 fPrinterDirName(printerName)
{
	fExitSem = create_sem(0, "PageSetup");

	if (printerName)
		SetTitle(BString(printerName).Append(" page setup").String());

	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
		label = "Letter";

	int32 compression;
	fSetupMsg->FindInt32("pdf_compression", &compression);

	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BString setting_value;
	if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
		setting_value = "1.3";

	// Load font settings
	fFonts = new Fonts();
	fFonts->CollectFonts();
	BMessage fonts;
	if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
		fFonts->SetTo(&fonts);

	fMarginView = new MarginView(int32(width), int32(height), margin,
		MarginUnit(units));

	BPopUpMenu* pageSize = new BPopUpMenu("Page size");
	pageSize->SetRadioMode(true);

	fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSize);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		pageSize->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
	orientationPopUpMenu->SetRadioMode(true);

	fOrientationMenu = new BMenuField("orientation", "Orientation:",
		orientationPopUpMenu);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		orientationPopUpMenu->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility");
	compatibility->SetRadioMode(true);
//.........这里部分代码省略.........
开发者ID:DonCN,项目名称:haiku,代码行数:101,代码来源:PageSetupWindow.cpp

示例11: BMessage

// --------------------------------------------------
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
	:	HWindow(BRect(0, 0, 100, 100), "Job Setup",
			B_TITLED_WINDOW_LOOK,
			B_MODAL_APP_WINDOW_FEEL,
			B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
				| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{
	fSetupMsg = msg;
	fExitSem = create_sem(0, "JobSetup");
	fResult	= B_ERROR;
	
	if (printerName) {
		BString	title;
		title << printerName << " Job Setup";
		SetTitle(title.String());
		fPrinterName = printerName;
	}
	
	// PrinterDriver ensures that property exists
	int32 firstPage;
	fSetupMsg->FindInt32("first_page", &firstPage);
	int32 lastPage;
	fSetupMsg->FindInt32("last_page",  &lastPage);

	BMessage doc_info;
	if (fSetupMsg->FindMessage("doc_info", &doc_info) != B_OK) {
		// default fields
		doc_info.AddString("Author", "");
		doc_info.AddString("Subject", "");
		doc_info.AddString("Keywords", "");
		fSetupMsg->AddMessage("doc_info", &doc_info);
	}
	AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
	
	bool allPages = firstPage == 1 && lastPage == MAX_INT32;

	fAll = new BRadioButton("allPages", "Print all pages",
		new BMessage(ALL_PAGES_MGS));
	fAll->SetValue(allPages);

	fRange = new BRadioButton("pagesRange", "Print pages:",
		new BMessage(RANGE_SELECTION_MSG));
	fRange->SetValue(!allPages);

	fFrom = new BTextControl("from", "From:", "SomeSpaceHere", NULL);
	fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fFrom->SetEnabled(!allPages);

	fTo = new BTextControl("to", "To:", "", NULL);
	fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fTo->SetEnabled(!allPages);

	BString buffer;
	buffer << firstPage;
	fFrom->SetText(buffer.String());

	buffer = "";
	buffer << lastPage;
	fTo->SetText(buffer.String());

	for (uint32 i = 0; i < '0'; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	for (uint32 i = '9' + 1; i < 255; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	BBox *separator = new BBox("separator");
	separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

	BButton *documentInfo = new BButton("documentInfo",
		"Document"  B_UTF8_ELLIPSIS,
		new BMessage(DOC_INFO_MSG));

	BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));

	BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
	ok->MakeDefault(true);

	BGridView* settings = new BGridView();
	BGridLayout* settingsLayout = settings->GridLayout();
	settingsLayout->AddItem(fFrom->CreateLabelLayoutItem(), 0, 0);
	settingsLayout->AddItem(fFrom->CreateTextViewLayoutItem(), 1, 0);
	settingsLayout->AddItem(fTo->CreateLabelLayoutItem(), 0, 1);
	settingsLayout->AddItem(fTo->CreateTextViewLayoutItem(), 1, 1);
	settingsLayout->SetSpacing(0, 0);

	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(fAll)
		.Add(fRange)
		.Add(settings)
		.AddGlue()
		.Add(separator)
		.AddGroup(B_HORIZONTAL, 10, 1.0f)
			.Add(documentInfo)
//.........这里部分代码省略.........
开发者ID:DonCN,项目名称:haiku,代码行数:101,代码来源:JobSetupWindow.cpp

示例12: BPopUpMenu

// constructor
StyleView::StyleView(BRect frame)
	:
#ifdef __HAIKU__
	BView("style view", 0),
#else
	BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS),
#endif
	fCommandStack(NULL),
	fCurrentColor(NULL),
	fStyle(NULL),
	fGradient(NULL),
	fIgnoreCurrentColorNotifications(false),
	fIgnoreControlGradientNotifications(false),
	fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// style type
	BMenu* menu = new BPopUpMenu("<unavailable>");
	BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_COLOR);
	menu->AddItem(new BMenuItem("Color", message));
	message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_GRADIENT);
	menu->AddItem(new BMenuItem("Gradient", message));

#ifdef __HAIKU__
	BGridLayout* layout = new BGridLayout(5, 5);
	SetLayout(layout);

	fStyleType = new BMenuField( "Style type", menu, NULL);

#else
	frame.OffsetTo(B_ORIGIN);
	frame.InsetBy(5, 5);
	frame.bottom = frame.top + 15;

	fStyleType = new BMenuField(frame, "style type", "Style type",
		menu, true);
	AddChild(fStyleType);

	float width;
	float height;
	fStyleType->MenuBar()->GetPreferredSize(&width, &height);
	fStyleType->MenuBar()->ResizeTo(width, height);
	fStyleType->ResizeTo(frame.Width(), height + 6);
	fStyleType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fStyleType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
#endif // __HAIKU__

	// gradient type
	menu = new BPopUpMenu("<unavailable>");
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_LINEAR);
	menu->AddItem(new BMenuItem("Linear", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CIRCULAR);
	menu->AddItem(new BMenuItem("Radial", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_DIAMOND);
	menu->AddItem(new BMenuItem("Diamond", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CONIC);
	menu->AddItem(new BMenuItem("Conic", message));

#if __HAIKU__
	fGradientType = new BMenuField("Gradient type", menu, NULL);
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);

	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);

	layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
	layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);

	layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
	layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);

	layout->AddView(fGradientControl, 1, 3, 2);

	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);

#else // !__HAIKU__
	frame.OffsetBy(0, fStyleType->Frame().Height() + 6);
	fGradientType = new BMenuField(frame, "gradient type", "Gradient type",
		menu, true);
	AddChild(fGradientType);

	fGradientType->MenuBar()->GetPreferredSize(&width, &height);
	fGradientType->MenuBar()->ResizeTo(width, height);
	fGradientType->ResizeTo(frame.Width(), height + 6);
	fGradientType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fGradientType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);

	// create gradient control
	frame.top = fGradientType->Frame().bottom + 8;
	frame.right = Bounds().right - 5;
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR),
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:StyleView.cpp


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