コード例 #1
0
ConfigView::ConfigView()
	:	BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | B_FOLLOW_TOP,0)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// determine font height
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6;
	
	BRect frame(5,2,250,itemHeight + 2);
	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false);

	const char *notifyMethods[] = {
		MDR_DIALECT_CHOICE ("Beep","音"),
		MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"),
		MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"),
		MDR_DIALECT_CHOICE ("Central alert","窓(一括)"),
		"Central beep","Log window"};
	for (int32 i = 0,j = 1;i < 6;i++,j *= 2)
		menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod)));

	BMenuField *field = new BMenuField(frame,"notify",
		MDR_DIALECT_CHOICE ("Method:","方法:"),menu);
	field->ResizeToPreferred();
	field->SetDivider(field->StringWidth(
		MDR_DIALECT_CHOICE ("Method:","方法:")) + 6);
	AddChild(field);

	ResizeToPreferred();
}		
コード例 #2
0
/*!	\brief		Create drop-down menu for day-month-year order.
 *	\param[in]	frame	Frame for this control
 *	\param[in]	id		ID of the CalendarControl
 */
BMenuField*		CalendarModulePreferencesView::CreateDayMonthYearOrderChooser( BRect frame, const BString& id )
{
	BMenuItem* 	toAdd = NULL;
	BMessage*	toSend = NULL;
	
	CalendarModulePreferences* prefs = pref_GetPreferencesForCalendarModule( id );
	BPopUpMenu* dmyOrderMenu = new BPopUpMenu( "DmyOrderChooser" );
	if ( ( !prefs ) || ( !dmyOrderMenu ) ) {
		return NULL;
	}
	
	for ( int8 i = 0; i < DMY_ORDER_NUMBER_OF_ELEMENTS; ++i ) {
		toSend = new BMessage( kCalendarModuleDateOrderSelected );
		if ( !toSend ) { return NULL; }
		toSend->AddString( "Calendar module", id );
		toSend->AddInt8( "DayMonthYearOrder", i );
		
		toAdd = new BMenuItem( DmyOrderNames[ i ], toSend );
		if ( !toAdd ) { delete toSend; return NULL; }
		dmyOrderMenu->AddItem( toAdd );
		toAdd->SetTarget( this );
		if ( i == ( int8 )prefs->GetDayMonthYearOrder() ) {
			toAdd->SetMarked( true );
		}
	}
	
	BMenuField* toReturn = new BMenuField( frame,
											"Day-Month-Year order chooser",
											"Select the order for day, month and year:",
											dmyOrderMenu );
	if ( !toReturn ) {
		delete dmyOrderMenu;
		return NULL;
	}
	
	toReturn->ResizeToPreferred();
	
	return toReturn;
}	// <-- end of function CalendarModulePreferencesView::CreateDayMonthYearOrderChooser
コード例 #3
0
ファイル: TypeEditors.cpp プロジェクト: DonCN/haiku
BooleanEditor::BooleanEditor(BRect rect, DataEditor &editor)
	: TypeEditorView(rect, B_TRANSLATE("Boolean editor"), B_FOLLOW_NONE, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BPopUpMenu *menu = new BPopUpMenu("bool");
	BMessage *message;
	menu->AddItem(fFalseMenuItem = new BMenuItem("false",
		new BMessage(kMsgValueChanged)));
	menu->AddItem(fTrueMenuItem = new BMenuItem("true",
		message = new BMessage(kMsgValueChanged)));
	message->AddInt8("value", 1);

	BMenuField *menuField = new BMenuField(rect.InsetByCopy(5, 5),
		B_EMPTY_STRING, B_TRANSLATE("Boolean value:"), menu, B_FOLLOW_LEFT_RIGHT);
	menuField->SetDivider(StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	ResizeTo(menuField->Bounds().Width() + 10,
		menuField->Bounds().Height() + 10);

	_UpdateMenuField();

	AddChild(menuField);
}
コード例 #4
0
MainView::MainView(BRect frame) 
	:
	BView(frame, 
			NULL, 
			B_FOLLOW_TOP|B_FOLLOW_LEFT, 
			B_FRAME_EVENTS|B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE)
{
	this->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect tempRect = this->Bounds();
	tempRect.InsetBy(5, 5);
	
	CategoryListView* listView = new CategoryListView( tempRect, "list" );
	if ( !listView )
	{
		/* Panic! */
		exit(1);
	}
	
/*	tempRect.right -= B_V_SCROLL_BAR_WIDTH;
	tempRect.bottom -= B_H_SCROLL_BAR_HEIGHT;
	
	BListView* listView = new BListView(tempRect, "list");
	if (!listView) { exit(1); }
	
*/
	this->scrollView = new BScrollView("scroll",
			listView,
			B_FOLLOW_LEFT | B_FOLLOW_TOP,
			B_FRAME_EVENTS,
			true, true);

	if (!scrollView) { exit(1); }
	
	listView->SetScroller( scrollView );
/*	((BScrollBar*)(scrollView->ScrollBar(B_VERTICAL)))->SetSteps(5, 20);
	((BScrollBar*)(scrollView->ScrollBar(B_HORIZONTAL)))->SetSteps(5, 20);

	 
	BBitmap *icon = NULL;
	icon = CreateIcon(kBlue);
	IconListItem *item = new IconListItem(icon,
										  "Test1",
										  0,
										  false);											  
	if (!item) { exit(1); }
	
	listView->AddItem(item);
	
	icon = CreateIcon(kMagen);
	item = new IconListItem(icon,
						  "Test2",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);
	
	icon = CreateIcon(kWhite);
	item = new IconListItem(icon,
						  "White icon",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);
	
	icon = CreateIcon(kMedGray);
	item = new IconListItem(icon,
						  "Категория на русском",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);

	BString categoryName("Категория с именем из BString");
	icon = CreateIcon(kBlue);	
	item = new IconListItem(icon,
				categoryName.String(),
				0,
				false);
	if (!item) { exit(1); }
	listView->AddItem(item);
*/	
	rgb_color red = { 255, 0, 0, 255 };
	BString catName = "CategoryListItem";
	
	BListItem* listItem = new CategoryListItem( red, catName );
	if ( !listItem ) { exit(1); }
	listView->AddItem( listItem );
	
//	listView->ResizeToPreferred();
	
	
	BGroupLayout* layout = new BGroupLayout( B_VERTICAL );
	if (!layout ) { /* Panic! */  exit(1); }
	this->SetLayout( layout );
	layout->SetInsets( 5, 5, 5, 5 );
	
	layout->AddView( scrollView );
	
	CategoryMenu* catMenu = new CategoryMenu( "CatMenu", NULL );
	
	CategoryMenuItem* item1 = new CategoryMenuItem( catName, red, NULL );
	
	catMenu->AddItem( item1 );
	
	BString menuName("Categories");
	BMenuField* menuField = new BMenuField( BRect( 0, 0, 1, 1),
											"Menu field",
											menuName,
											catMenu );
	menuField->ResizeToPreferred();
	layout->AddView( menuField );
	
	
	// this->AddChild(scrollView);
	// FixupScrollbars();
}
コード例 #5
0
ファイル: FindWindow.cpp プロジェクト: AmirAbrams/haiku
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target,
		const BMessage* settings)
	: BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0);
	view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(view);

	int8 mode = kAsciiMode;
	if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
		settings->FindInt8("find_mode", &mode);

	// add the top widgets

	fMenu = new BPopUpMenu("mode");
	BMessage* message;
	BMenuItem* item;
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"),
		message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kAsciiMode);
	if (mode == kAsciiMode)
		item->SetMarked(true);
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", 
		"A menu item, as short as possible, noun is recommended if it is "
		"shorter than adjective."), message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kHexMode);
	if (mode == kHexMode)
		item->SetMarked(true);

	BRect rect = Bounds().InsetByCopy(5, 5);
	BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING,
		B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	view->AddChild(menuField);

	// add the bottom widgets

	BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"),
		new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->MoveTo(rect.right - button->Bounds().Width(),
		rect.bottom - button->Bounds().Height());
	view->AddChild(button);

	fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"),
		NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fCaseCheckBox->ResizeToPreferred();
	fCaseCheckBox->MoveTo(5, button->Frame().top);
	bool caseSensitive;
	if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
		if (settings == NULL
			|| settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
			caseSensitive = true;
	}
	fCaseCheckBox->SetValue(caseSensitive);
	view->AddChild(fCaseCheckBox);

	// and now those inbetween

	rect.top = menuField->Frame().bottom + 5;
	rect.bottom = fCaseCheckBox->Frame().top - 8;
	rect.InsetBy(2, 2);
	fTextView = new FindTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL);
	fTextView->SetWordWrap(true);
	fTextView->SetMode((find_mode)mode);
	fTextView->SetData(previous);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, false, false);
	view->AddChild(scrollView);

	ResizeTo(290, button->Frame().Height() * 3 + 30);

	SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width()
			+ 20, 32768, button->Frame().Height() * 3 + 10, 32768);
}
コード例 #6
0
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
	: BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
		"Application Type", B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
	fChangedProperties(0)
{
	// add the menu

	BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
	fSaveMenuItem->SetEnabled(false);
	menu->AddItem(fSaveMenuItem);
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
		NULL));
	item->SetEnabled(false);

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
		'W', B_COMMAND_KEY));
	menuBar->AddItem(menu);

	// Top view and signature

	BRect rect = Bounds();
	rect.top = menuBar->Bounds().Height() + 1.0f;
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
	fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
		new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
	fSignatureControl->SetModificationMessage(
		new BMessage(kMsgSignatureChanged));
	fSignatureControl->SetDivider(fSignatureControl->StringWidth(
		fSignatureControl->Label()) + 4.0f);
	float width, height;
	fSignatureControl->GetPreferredSize(&width, &height);
	fSignatureControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fSignatureControl);

	// filter out invalid characters that can't be part of a MIME type name
	BTextView* textView = fSignatureControl->TextView();
	textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
	const char* disallowedCharacters = "<>@,;:\"()[]?=";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	// "Application Flags" group

	BFont font(be_bold_font);
	font_height fontHeight;
	font.GetHeight(&fontHeight);

	width = font.StringWidth("Icon") + 16.0f;
	if (width < B_LARGE_ICON + 16.0f)
		width = B_LARGE_ICON + 16.0f;

	rect.top = fSignatureControl->Frame().bottom + 4.0f;
	rect.bottom = rect.top + 100.0f;
	rect.right -= width + 8.0f;
	BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	topView->AddChild(box);

	fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
		new BMessage(kMsgToggleAppFlags));
	fFlagsCheckBox->SetValue(B_CONTROL_ON);
	fFlagsCheckBox->ResizeToPreferred();
	box->SetLabel(fFlagsCheckBox);

	rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
	fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
		new BMessage(kMsgAppFlagsChanged));
	fSingleLaunchButton->ResizeToPreferred();
	box->AddChild(fSingleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fMultipleLaunchButton = new BRadioButton(rect, "multiple",
		"Multiple launch", new BMessage(kMsgAppFlagsChanged));
	fMultipleLaunchButton->ResizeToPreferred();
	box->AddChild(fMultipleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
		"Exclusive launch", new BMessage(kMsgAppFlagsChanged));
	fExclusiveLaunchButton->ResizeToPreferred();
	box->AddChild(fExclusiveLaunchButton);

	rect.top = fSingleLaunchButton->Frame().top;
	rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
	fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
		new BMessage(kMsgAppFlagsChanged));
	fArgsOnlyCheckBox->ResizeToPreferred();
	box->AddChild(fArgsOnlyCheckBox);

	rect.top += fArgsOnlyCheckBox->Bounds().Height();
	fBackgroundAppCheckBox = new BCheckBox(rect, "background",
		"Background app", new BMessage(kMsgAppFlagsChanged));
	fBackgroundAppCheckBox->ResizeToPreferred();
	box->AddChild(fBackgroundAppCheckBox);

	box->ResizeTo(box->Bounds().Width(),
		fExclusiveLaunchButton->Frame().bottom + 8.0f);

	// "Icon" group

	rect = box->Frame();
#ifdef __ANTARES__
	rect.top += box->TopBorderOffset();
#endif
	rect.left = rect.right + 8.0f;
	rect.right += width + 8.0f;
	float iconBoxWidth = rect.Width();
	box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	box->SetLabel("Icon");
#ifdef __ANTARES__
	box->MoveBy(0.0f, -box->TopBorderOffset());
	box->ResizeBy(0.0f, box->TopBorderOffset());
#endif
	topView->AddChild(box);

	rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f);
#ifdef __ANTARES__
	rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset()
		- rect.Height()) / 2.0f);
#else
	rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f);
#endif
	if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f)
		rect.top = fontHeight.ascent + fontHeight.descent + 4.0f;
	fIconView = new IconView(rect, "icon");
	fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
	box->AddChild(fIconView);

	// "Supported Types" group

	rect.top = box->Frame().bottom + 8.0f;
	rect.bottom = rect.top + box->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	typeBox->SetLabel("Supported types");
	topView->AddChild(typeBox);

	rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f);
	rect.top += ceilf(fontHeight.ascent);
	fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddType), B_FOLLOW_RIGHT);
	fAddTypeButton->ResizeToPreferred();
	fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width()
		- B_LARGE_ICON - 16.0f, 0.0f);
	typeBox->AddChild(fAddTypeButton);

	rect = fAddTypeButton->Frame();
	rect.OffsetBy(0, rect.Height() + 4.0f);
	fRemoveTypeButton = new BButton(rect, "remove type", "Remove",
		new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT);
	typeBox->AddChild(fRemoveTypeButton);

	rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.left = 10.0f;
	rect.top = 8.0f + ceilf(fontHeight.ascent);
	rect.bottom -= 2.0f;
		// take scrollview border into account
	fTypeListView = new SupportedTypeListView(rect, "type listview",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
		B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f);
	typeBox->AddChild(scrollView);

	rect.left = fRemoveTypeButton->Frame().right + 8.0f;
#ifdef __ANTARES__
	rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f;
#else
	rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f;
#endif
	rect.right = rect.left + B_LARGE_ICON - 1.0f;
	rect.bottom = rect.top + B_LARGE_ICON - 1.0f;
	fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged));
	typeBox->AddChild(fTypeIconView);

	// "Version Info" group

	rect.top = typeBox->Frame().bottom + 8.0f;
	rect.bottom = rect.top + typeBox->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
		// the resizing mode will later also be set to B_FOLLOW_BOTTOM
	box->SetLabel("Version info");
	topView->AddChild(box);

	BMenuField* menuField;
#if 0
	BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true);
	item = new BMenuItem("Version Info", NULL);
	item->SetMarked(true);
	popUpMenu->AddItem(item);
	item = new BMenuItem("System Version Info", NULL);
	popUpMenu->AddItem(item);

	menuField = new BMenuField(BRect(0, 0, 100, 15),
		"version kind", NULL, popUpMenu, true);
	menuField->ResizeToPreferred();
	box->SetLabel(menuField);
#endif

	rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent);
	rect.bottom = rect.top + height;
	fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL,
		NULL);
	fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth(
		fMajorVersionControl->Label()) + 4.0f);
	fMajorVersionControl->GetPreferredSize(&width, &height);
	width = 12.0f + fMajorVersionControl->StringWidth("99");
	fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMajorVersionControl);
	box->AddChild(fMajorVersionControl);

	rect.left = fMajorVersionControl->Frame().right + 1.0f;
	fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth(
		fMiddleVersionControl->Label()) + 4.0f);
	fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMiddleVersionControl);
	box->AddChild(fMiddleVersionControl);

	rect.left = fMiddleVersionControl->Frame().right + 1.0f;
	fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth(
		fMinorVersionControl->Label()) + 4.0f);
	fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMinorVersionControl);
	box->AddChild(fMinorVersionControl);

	fVarietyMenu = new BPopUpMenu("variety", true, true);
	fVarietyMenu->AddItem(new BMenuItem("Development", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Beta", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL));
	fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL));
	item->SetMarked(true);
	fVarietyMenu->AddItem(new BMenuItem("Final", NULL));

	rect.top--;
		// BMenuField oddity
	rect.left = fMinorVersionControl->Frame().right + 6.0f;
	menuField = new BMenuField(rect,
		"variety", NULL, fVarietyMenu, true);
	menuField->ResizeToPreferred();
	box->AddChild(menuField);

	rect.top++;
	rect.left = menuField->Frame().right;
	rect.right = rect.left + 30.0f;	
	fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL,
		NULL);
	fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth(
		fInternalVersionControl->Label()) + 4.0f);
	fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height);
	box->AddChild(fInternalVersionControl);

	rect = box->Bounds().InsetByCopy(8.0f, 0.0f);
	rect.top = fInternalVersionControl->Frame().bottom + 8.0f;
	fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:",
		NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	float labelWidth = fShortDescriptionControl->StringWidth(
		fShortDescriptionControl->Label()) + 4.0f;
	fShortDescriptionControl->SetDivider(labelWidth);
	fShortDescriptionControl->GetPreferredSize(&width, &height);
	fShortDescriptionControl->ResizeTo(rect.Width(), height);

	// TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says?
	version_info versionInfo;
	fShortDescriptionControl->TextView()->SetMaxBytes(sizeof(versionInfo.short_info));
	box->AddChild(fShortDescriptionControl);

	rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f);
	rect.right = rect.left + labelWidth;
	StringView* label = new StringView(rect, NULL, "Long description:", NULL);
	label->SetDivider(labelWidth);
	box->AddChild(label);

	rect.left = rect.right + 3.0f;
	rect.top += 1.0f;
	rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f;
	fLongDescriptionView = new TabFilteringTextView(rect, "long desc",
		rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
		| B_NAVIGABLE);
	fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));

	scrollView = new BScrollView("desc scrollview", fLongDescriptionView,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f);
	box->AddChild(scrollView);

	// Adjust window size and limits

	width = fInternalVersionControl->Frame().right + 16.0f;
	float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f;
	if (width > minWidth)
		minWidth = width;

	ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth,
		box->Frame().bottom + topView->Frame().top + 8.0f);
	SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f);
	typeBox->SetResizingMode(B_FOLLOW_ALL);
	box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);

	fSignatureControl->MakeFocus(true);

	BMimeType::StartWatching(this);
	_SetTo(entry);
}
コード例 #7
0
ファイル: DocInfoWindow.cpp プロジェクト: mariuz/haiku
void
DocInfoWindow::_SetupDocInfoView(BBox* panel)
{
	BRect bounds(panel->Bounds());
#if HAVE_FULLVERSION_PDF_LIB
	bounds.InsetBy(10.0, 10.0);
#endif

	// add list of keys
	fKeyList = new BMenu("Delete Key");
	BMenuField *menu = new BMenuField(bounds, "delete", "", fKeyList,
		B_FOLLOW_BOTTOM);
	panel->AddChild(menu);
	menu->SetDivider(0);

#ifdef __HAIKU__
	menu->ResizeToPreferred();
	menu->MoveTo(bounds.left, bounds.bottom - menu->Bounds().Height());
#else
	menu->ResizeTo(menu->StringWidth("Delete Key") + 15.0, 25.0);
	menu->MoveTo(bounds.left, bounds.bottom - 25.0);
#endif

	const char* title[6] = { "Title", "Author", "Subject", "Keywords", "Creator",
		NULL };	// PDFlib sets these: "Producer", "CreationDate", not "ModDate"
	BMenu* defaultKeys = new BMenu("Default Keys");
	for (int32 i = 0; title[i] != NULL; ++i)
		defaultKeys->AddItem(new BMenuItem(title[i], new BMessage(DEFAULT_KEY_MSG)));

	BRect frame(menu->Frame());
	menu = new BMenuField(frame, "add", "", defaultKeys, B_FOLLOW_BOTTOM);
	panel->AddChild(menu);
	menu->SetDivider(0);

#ifdef __HAIKU__
	menu->ResizeToPreferred();
	menu->MoveBy(frame.Width() + 10.0, 0.0);
#else
	menu->ResizeTo(menu->StringWidth("Default Keys") + 15.0, 25.0);
	menu->MoveBy(menu->Bounds().Width() + 10.0, 0.0);
#endif

	frame = menu->Frame();
	frame.left = frame.right + 10.0;
	frame.right = bounds.right;
	BTextControl *add = new BTextControl(frame, "add", "Add Key:", "",
		new BMessage(ADD_KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
	panel->AddChild(add);

	float width, height;
	add->GetPreferredSize(&width, &height);
	add->ResizeTo(bounds.right - frame.left, height);
	add->SetDivider(be_plain_font->StringWidth("Add Key: "));

	bounds.bottom = frame.top - 10.0;
	bounds.right -= B_V_SCROLL_BAR_WIDTH;
	bounds.InsetBy(2.0, 2.0);
	fTable = new BView(bounds, "table", B_FOLLOW_ALL, B_WILL_DRAW);
	fTable->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fTableScrollView = new BScrollView("scroll_table", fTable, B_FOLLOW_ALL, 0,
		false, true);
	panel->AddChild(fTableScrollView);

	BMessage docInfo;
	fDocInfo->FindMessage("doc_info", &docInfo);

	// fill table
	_BuildTable(docInfo);
}
コード例 #8
0
ファイル: RecipeEditor.cpp プロジェクト: HaikuArchives/Recibe
RecipeEditor::RecipeEditor(const BRect &frame, const BMessenger &msgr,
						const int32 &number, const char *category)
 :	BWindow(frame,"Add Recipe",B_FLOATING_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
 			B_ASYNCHRONOUS_CONTROLS),
 	fMessenger(msgr),
 	fNumber(number),
 	fCategory(category)
{
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
	AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP));
	
	BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW);
	back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(back);
	
	fCategories = new BMenu("Categories");
	CppSQLite3Query query = DBQuery("select category from categories order by category;",
									"RecipeEditor:get categories");
	while(!query.eof())
	{
		BString cat(DeescapeIllegalCharacters(query.getStringField(0)));
		BMessage *menumsg = new BMessage(M_CATEGORY_CHANGED);
		menumsg->AddString("name",cat);
		fCategories->AddItem(new BMenuItem(cat.String(),menumsg));
		query.nextRow();
	}
	fCategories->SetRadioMode(true);
	fCategories->SetLabelFromMarked(true);
	if(fCategories->CountItems()>0)
		fCategories->ItemAt(0)->SetMarked(true);
	BRect r(10,10,10 + fCategories->MaxContentWidth(),11);
	BMenuField *field = new BMenuField(r,"field","Category",fCategories,
										B_FOLLOW_LEFT | B_FOLLOW_TOP,
										B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
	back->AddChild(field);
	field->ResizeToPreferred();
	r = field->Frame();
	
	if(category)
	{
		BMenuItem *marked = fCategories->FindItem(category);
		if(marked)
			marked->SetMarked(true);
	}
	else
	{
		BMenuItem *marked = fCategories->ItemAt(0L);
		if(marked)
			marked->SetMarked(true);
	}
	
	r.OffsetBy(0,r.Height() + 10);
	fNameBox = new AutoTextControl(r,"namebox","Name: ",NULL,NULL,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
									B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
									B_NAVIGABLE_JUMP);
	fNameBox->SetEscapeCancel(true);
	fNameBox->SetDivider(be_plain_font->StringWidth("Name ") + 5);
	back->AddChild(fNameBox);
	fNameBox->ResizeToPreferred();
	r = fNameBox->Frame();
	r.right = Bounds().right - 10;
	fNameBox->ResizeTo(r.Width(), r.Height());
	
	r.OffsetBy(0,r.Height() + 10);
	BStringView *label = new BStringView(r,"inglabel","Ingredients:");
	back->AddChild(label);
	
	r.OffsetBy(0,r.Height() + 10);
	r.bottom = r.top + 100;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	
	BRect textrect = r.OffsetToCopy(0,0);
	textrect.InsetBy(10,10);
	fIngredientBox = new BTextView(r, "ingredients", textrect, B_FOLLOW_ALL,
									B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
									B_NAVIGABLE_JUMP);
	fIngredientBox->SetDoesUndo(true);
	
	
	BScrollView *ingredscroll = new BScrollView("ingredients_scroller",fIngredientBox,
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true);
	back->AddChild(ingredscroll);
	
	r = ingredscroll->Frame();
	
	label = new BStringView(BRect(10,10,11,11),"dirlabel","Directions:");
	label->ResizeToPreferred();
	label->MoveTo(10, r.bottom + 10);
	back->AddChild(label);
	
	r.OffsetBy(0,r.Height() + 20 + label->Frame().Height());
	r.right -= B_V_SCROLL_BAR_WIDTH;
	textrect = r.OffsetToCopy(0,0);
	textrect.InsetBy(10,10);
	fDirectionsBox = new BTextView(r, "directions", textrect, B_FOLLOW_ALL,
									B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
									B_NAVIGABLE_JUMP);
	fDirectionsBox->SetDoesUndo(true);
	
	BScrollView *dirscroll = new BScrollView("directions_scroller",fDirectionsBox,
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true);
	back->AddChild(dirscroll);
	
	
	fOK = new BButton(BRect(10,10,11,11),"ok","Cancel", new BMessage(M_ADD_RECIPE),
							B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	fOK->ResizeToPreferred();
	fOK->SetLabel("OK");
	fOK->MoveTo(Bounds().right - fOK->Bounds().Width() - 10,
				Bounds().bottom - fOK->Bounds().Height() - 10);
	r = fOK->Frame();
	back->AddChild(fOK);
	
	r.OffsetBy(-r.Width() - 10, 0);
	fCancel = new BButton(r,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED),
						B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	back->AddChild(fCancel);
	
	field->MakeFocus(true);
	
	ResizeTo(Bounds().Width(),
			fDirectionsBox->Parent()->Frame().bottom + 20 + fOK->Bounds().Height());
	
	dirscroll->SetResizingMode(B_FOLLOW_ALL);
	
	// This is the part that's different for editing a recipe as opposed to
	// just adding one to the database
	if(number >= 0 && category)
	{
		SetTitle("Edit Recipe");
		BString name, ingredients, directions;
		if(GetRecipe(number,category,name,ingredients,directions))
		{
			BMenuItem *item = fCategories->FindItem(category);
			if(item)
				item->SetMarked(true);
			
			fNameBox->SetText(name.String());
			fIngredientBox->SetText(ingredients.String());
			fDirectionsBox->SetText(directions.String());
			fOK->SetMessage(new BMessage(M_EDIT_RECIPE));
		}
	}
	
	AddShortcut(B_ENTER, B_COMMAND_KEY, new BMessage(fOK->Command()));
}
コード例 #9
0
ScreenWindow::ScreenWindow(ScreenSettings* settings)
	:
	BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Screen"),
		B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
		| B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES),
	fIsVesa(false),
	fBootWorkspaceApplied(false),
	fOtherRefresh(NULL),
	fScreenMode(this),
	fUndoScreenMode(this),
	fModified(false)
{
	BScreen screen(this);

	accelerant_device_info info;
	if (screen.GetDeviceInfo(&info) == B_OK
		&& !strcasecmp(info.chipset, "VESA"))
		fIsVesa = true;

	_UpdateOriginal();
	_BuildSupportedColorSpaces();
	fActive = fSelected = fOriginal;

	fSettings = settings;

	// we need the "Current Workspace" first to get its height

	BPopUpMenu *popUpMenu = new BPopUpMenu(B_TRANSLATE("Current workspace"),
		true, true);
	fAllWorkspacesItem = new BMenuItem(B_TRANSLATE("All workspaces"),
		new BMessage(WORKSPACE_CHECK_MSG));
	popUpMenu->AddItem(fAllWorkspacesItem);
	BMenuItem *item = new BMenuItem(B_TRANSLATE("Current workspace"),
		new BMessage(WORKSPACE_CHECK_MSG));

	popUpMenu->AddItem(item);
	fAllWorkspacesItem->SetMarked(true);

	BMenuField* workspaceMenuField = new BMenuField("WorkspaceMenu", NULL,
		popUpMenu);
	workspaceMenuField->ResizeToPreferred();

	// box on the left with workspace count and monitor view

	BBox* screenBox = new BBox("screen box");
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 5.0);
	layout->SetInsets(10, 10, 10, 10);
	screenBox->SetLayout(layout);

	fMonitorInfo = new BStringView("monitor info", "");
	screenBox->AddChild(fMonitorInfo);

	fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0),
		"monitor", screen.Frame().IntegerWidth() + 1,
		screen.Frame().IntegerHeight() + 1);
	screenBox->AddChild(fMonitorView);

	fColumnsControl = new BTextControl(B_TRANSLATE("Columns:"), "0",
		new BMessage(kMsgWorkspaceColumnsChanged));
	fRowsControl = new BTextControl(B_TRANSLATE("Rows:"), "0",
		new BMessage(kMsgWorkspaceRowsChanged));

	screenBox->AddChild(BLayoutBuilder::Grid<>(5.0, 5.0)
		.Add(new BStringView("", B_TRANSLATE("Workspaces")), 0, 0, 3)
		.AddTextControl(fColumnsControl, 0, 1, B_ALIGN_RIGHT)
		.AddGroup(B_HORIZONTAL, 0, 2, 1)
			.Add(_CreateColumnRowButton(true, false))
			.Add(_CreateColumnRowButton(true, true))
			.End()
		.AddTextControl(fRowsControl, 0, 2, B_ALIGN_RIGHT)
		.AddGroup(B_HORIZONTAL, 0, 2, 2)
			.Add(_CreateColumnRowButton(false, false))
			.Add(_CreateColumnRowButton(false, true))
			.End()
		.View());

	fBackgroundsButton = new BButton("BackgroundsButton",
		B_TRANSLATE("Set background" B_UTF8_ELLIPSIS),
		new BMessage(BUTTON_LAUNCH_BACKGROUNDS_MSG));
	fBackgroundsButton->SetFontSize(be_plain_font->Size() * 0.9);
	screenBox->AddChild(fBackgroundsButton);

	// box on the right with screen resolution, etc.

	BBox* controlsBox = new BBox("controls box");
	controlsBox->SetLabel(workspaceMenuField);
	BGroupView* outerControlsView = new BGroupView(B_VERTICAL, 10.0);
	outerControlsView->GroupLayout()->SetInsets(10, 10, 10, 10);
	controlsBox->AddChild(outerControlsView);

	fResolutionMenu = new BPopUpMenu("resolution", true, true);

	uint16 maxWidth = 0;
	uint16 maxHeight = 0;
	uint16 previousWidth = 0;
	uint16 previousHeight = 0;
	for (int32 i = 0; i < fScreenMode.CountModes(); i++) {
		screen_mode mode = fScreenMode.ModeAt(i);

		if (mode.width == previousWidth && mode.height == previousHeight)
			continue;

		previousWidth = mode.width;
		previousHeight = mode.height;
		if (maxWidth < mode.width)
			maxWidth = mode.width;
		if (maxHeight < mode.height)
			maxHeight = mode.height;

		BMessage* message = new BMessage(POP_RESOLUTION_MSG);
		message->AddInt32("width", mode.width);
		message->AddInt32("height", mode.height);

		BString name;
		name << mode.width << " x " << mode.height;

		fResolutionMenu->AddItem(new BMenuItem(name.String(), message));
	}

	fMonitorView->SetMaxResolution(maxWidth, maxHeight);

	fResolutionField = new BMenuField("ResolutionMenu",
		B_TRANSLATE("Resolution:"), fResolutionMenu);

	fColorsMenu = new BPopUpMenu("colors", true, false);

	for (int32 i = 0; i < kColorSpaceCount; i++) {
		if ((fSupportedColorSpaces & (1 << i)) == 0)
			continue;

		BMessage* message = new BMessage(POP_COLORS_MSG);
		message->AddInt32("bits_per_pixel", kColorSpaces[i].bits_per_pixel);
		message->AddInt32("space", kColorSpaces[i].space);

		BMenuItem* item = new BMenuItem(kColorSpaces[i].label, message);
		if (kColorSpaces[i].space == screen.ColorSpace())
			fUserSelectedColorSpace = item;

		fColorsMenu->AddItem(item);
	}

	fColorsField = new BMenuField("ColorsMenu", B_TRANSLATE("Colors:"),
		fColorsMenu);

	fRefreshMenu = new BPopUpMenu("refresh rate", true, true);

	float min, max;
	if (fScreenMode.GetRefreshLimits(fActive, min, max) != B_OK) {
		// if we couldn't obtain the refresh limits, reset to the default
		// range. Constraints from detected monitors will fine-tune this
		// later.
		min = kRefreshRates[0];
		max = kRefreshRates[kRefreshRateCount - 1];
	}

	if (min == max) {
		// This is a special case for drivers that only support a single
		// frequency, like the VESA driver
		BString name;
		refresh_rate_to_string(min, name);
		BMessage *message = new BMessage(POP_REFRESH_MSG);
		message->AddFloat("refresh", min);
		BMenuItem *item = new BMenuItem(name.String(), message);
		fRefreshMenu->AddItem(item);
		item->SetEnabled(false);
	} else {
		monitor_info info;
		if (fScreenMode.GetMonitorInfo(info) == B_OK) {
			min = max_c(info.min_vertical_frequency, min);
			max = min_c(info.max_vertical_frequency, max);
		}

		for (int32 i = 0; i < kRefreshRateCount; ++i) {
			if (kRefreshRates[i] < min || kRefreshRates[i] > max)
				continue;

			BString name;
			name << kRefreshRates[i] << " " << B_TRANSLATE("Hz");

			BMessage *message = new BMessage(POP_REFRESH_MSG);
			message->AddFloat("refresh", kRefreshRates[i]);

			fRefreshMenu->AddItem(new BMenuItem(name.String(), message));
		}

		fOtherRefresh = new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
			new BMessage(POP_OTHER_REFRESH_MSG));
		fRefreshMenu->AddItem(fOtherRefresh);
	}

	fRefreshField = new BMenuField("RefreshMenu", B_TRANSLATE("Refresh rate:"),
		fRefreshMenu);

	if (_IsVesa())
		fRefreshField->Hide();

	// enlarged area for multi-monitor settings
	{
		bool dummy;
		uint32 dummy32;
		bool multiMonSupport;
		bool useLaptopPanelSupport;
		bool tvStandardSupport;

		multiMonSupport = TestMultiMonSupport(&screen) == B_OK;
		useLaptopPanelSupport = GetUseLaptopPanel(&screen, &dummy) == B_OK;
		tvStandardSupport = GetTVStandard(&screen, &dummy32) == B_OK;

		// even if there is no support, we still create all controls
		// to make sure we don't access NULL pointers later on

		fCombineMenu = new BPopUpMenu("CombineDisplays",
			true, true);

		for (int32 i = 0; i < kCombineModeCount; i++) {
			BMessage *message = new BMessage(POP_COMBINE_DISPLAYS_MSG);
			message->AddInt32("mode", kCombineModes[i].mode);

			fCombineMenu->AddItem(new BMenuItem(kCombineModes[i].name,
				message));
		}

		fCombineField = new BMenuField("CombineMenu",
			B_TRANSLATE("Combine displays:"), fCombineMenu);

		if (!multiMonSupport)
			fCombineField->Hide();

		fSwapDisplaysMenu = new BPopUpMenu("SwapDisplays",
			true, true);

		// !order is important - we rely that boolean value == idx
		BMessage *message = new BMessage(POP_SWAP_DISPLAYS_MSG);
		message->AddBool("swap", false);
		fSwapDisplaysMenu->AddItem(new BMenuItem(B_TRANSLATE("no"), message));

		message = new BMessage(POP_SWAP_DISPLAYS_MSG);
		message->AddBool("swap", true);
		fSwapDisplaysMenu->AddItem(new BMenuItem(B_TRANSLATE("yes"), message));

		fSwapDisplaysField = new BMenuField("SwapMenu",
			B_TRANSLATE("Swap displays:"), fSwapDisplaysMenu);

		if (!multiMonSupport)
			fSwapDisplaysField->Hide();

		fUseLaptopPanelMenu = new BPopUpMenu("UseLaptopPanel",
			true, true);

		// !order is important - we rely that boolean value == idx
		message = new BMessage(POP_USE_LAPTOP_PANEL_MSG);
		message->AddBool("use", false);
		fUseLaptopPanelMenu->AddItem(new BMenuItem(B_TRANSLATE("if needed"),
			message));

		message = new BMessage(POP_USE_LAPTOP_PANEL_MSG);
		message->AddBool("use", true);
		fUseLaptopPanelMenu->AddItem(new BMenuItem(B_TRANSLATE("always"),
			message));

		fUseLaptopPanelField = new BMenuField("UseLaptopPanel",
			B_TRANSLATE("Use laptop panel:"), fUseLaptopPanelMenu);

		if (!useLaptopPanelSupport)
			fUseLaptopPanelField->Hide();

		fTVStandardMenu = new BPopUpMenu("TVStandard", true, true);

		// arbitrary limit
		uint32 i;
		for (i = 0; i < 100; ++i) {
			uint32 mode;
			if (GetNthSupportedTVStandard(&screen, i, &mode) != B_OK)
				break;

			BString name = tv_standard_to_string(mode);

			message = new BMessage(POP_TV_STANDARD_MSG);
			message->AddInt32("tv_standard", mode);

			fTVStandardMenu->AddItem(new BMenuItem(name.String(), message));
		}

		fTVStandardField = new BMenuField("tv standard",
			B_TRANSLATE("Video format:"), fTVStandardMenu);
		fTVStandardField->SetAlignment(B_ALIGN_RIGHT);

		if (!tvStandardSupport || i == 0)
			fTVStandardField->Hide();
	}

	BLayoutBuilder::Group<>(outerControlsView)
		.AddGrid(5.0, 5.0)
			.AddMenuField(fResolutionField, 0, 0, B_ALIGN_RIGHT)
			.AddMenuField(fColorsField, 0, 1, B_ALIGN_RIGHT)
			.AddMenuField(fRefreshField, 0, 2, B_ALIGN_RIGHT)
			.AddMenuField(fCombineField, 0, 3, B_ALIGN_RIGHT)
			.AddMenuField(fSwapDisplaysField, 0, 4, B_ALIGN_RIGHT)
			.AddMenuField(fUseLaptopPanelField, 0, 5, B_ALIGN_RIGHT)
			.AddMenuField(fTVStandardField, 0, 6, B_ALIGN_RIGHT)
		.End();

	// TODO: we don't support getting the screen's preferred settings
	/* fDefaultsButton = new BButton(buttonRect, "DefaultsButton", "Defaults",
		new BMessage(BUTTON_DEFAULTS_MSG));*/

	fApplyButton = new BButton("ApplyButton", B_TRANSLATE("Apply"),
		new BMessage(BUTTON_APPLY_MSG));
	fApplyButton->SetEnabled(false);
	BLayoutBuilder::Group<>(outerControlsView)
		.AddGlue()
			.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fApplyButton);

	fRevertButton = new BButton("RevertButton", B_TRANSLATE("Revert"),
		new BMessage(BUTTON_REVERT_MSG));
	fRevertButton->SetEnabled(false);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 10.0)
		.SetInsets(10, 10, 10, 10)
		.AddGroup(B_HORIZONTAL, 10.0)
			.AddGroup(B_VERTICAL)
				.AddStrut(floor(controlsBox->TopBorderOffset() / 16) - 1)
				.Add(screenBox)
			.End()
			.Add(controlsBox)
		.End()
		.AddGroup(B_HORIZONTAL, 10.0)
			.Add(fRevertButton)
			.AddGlue();

	_UpdateControls();
	_UpdateMonitor();
}
コード例 #10
0
ファイル: MarginView.cpp プロジェクト: mariuz/haiku
/**
 * _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()
{
	BString str;
	// Create text fields
	BRect r(Frame().Width() - be_plain_font->StringWidth("Top#") - kWidth,
			kOffsetY, Frame().Width() - kOffsetX, kWidth);

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

	fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
	fTop->SetDivider(be_plain_font->StringWidth("Top#"));
	fTop->SetTarget(this);
	_AllowOnlyNumbers(fTop, kNumCount);
	AddChild(fTop);




	//left
	r.OffsetBy(0, kOffsetY);
	r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - kWidth;
    str = "";
	str << fMargins.left/fUnitValue;
	fLeft = new BTextControl( r, "left", "Left:", str.String(), NULL,
				B_FOLLOW_RIGHT);

	fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
	fLeft->SetDivider(be_plain_font->StringWidth("Left#"));
	fLeft->SetTarget(this);
	_AllowOnlyNumbers(fLeft, kNumCount);
	AddChild(fLeft);




	//bottom
	r.OffsetBy(0, kOffsetY);
	r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - kWidth;
    str = "";
	str << fMargins.bottom/fUnitValue;
	fBottom = new BTextControl( r, "bottom", "Bottom:", str.String(), NULL,
				B_FOLLOW_RIGHT);

	fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
	fBottom->SetDivider(be_plain_font->StringWidth("Bottom#"));
	fBottom->SetTarget(this);

	_AllowOnlyNumbers(fBottom, kNumCount);
	AddChild(fBottom);




	//right
	r.OffsetBy(0, kOffsetY);
	r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - kWidth;
    str = "";
	str << fMargins.right/fUnitValue;
	fRight = new BTextControl( r, "right", "Right:", str.String(), NULL,
				B_FOLLOW_RIGHT);

	fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
	fRight->SetDivider(be_plain_font->StringWidth("Right#"));
	fRight->SetTarget(this);
	_AllowOnlyNumbers(fRight, kNumCount);
	AddChild(fRight);



// Create Units popup
	r.OffsetBy(-kOffsetX, kOffsetY);
	r.right += kOffsetY;

	BPopUpMenu *menu = new BPopUpMenu("units");
	BMenuField *mf = new BMenuField(r, "units", "Units", menu,
			B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
	mf->ResizeToPreferred();
	mf->SetDivider(be_plain_font->StringWidth("Units#"));

	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);
	}
	AddChild(mf);

	// calculate the sizes for drawing page view
	_CalculateViewSize(MARGIN_CHANGED);
}
コード例 #11
0
/*!	\brief		Create drop-down menu for week start day.
 */
BMenuField*		CalendarModulePreferencesView::CreateWeekStartDayChooser( BRect frame, const BString& id )
{
	BMenuItem* 	toAdd = NULL;
	BMessage*	toSend = NULL;
	
	CalendarModule* calModule = utl_FindCalendarModule( id );
	if ( calModule == NULL ) {
		/* Error */
		return NULL;
	}

	CalendarModulePreferences* calModule_prefs = pref_GetPreferencesForCalendarModule( id );
	if ( !calModule_prefs ) {
		return NULL;
	}
	
	map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();

	BPopUpMenu* startDayChooserMenu = new BPopUpMenu( "First day of week" );
	if ( !startDayChooserMenu )
	{
		return NULL;
	}
	
	uint32	currentlySelectedStartingDay = calModule_prefs->GetFirstDayOfWeek(),
			daysInWeek = ( uint32 )( calModule->GetDaysInWeek() );
	
	// Pass on all days in week
	for ( uint32 i = kSunday; i <= daysInWeek; ++i ) {
		
		toSend = new BMessage( kCalendarModuleFirstDayOfWeekSelected );
		if ( ! toSend ) { /* Panic! */
			exit( 1 );
		}
		
		toSend->AddInt32( "Day", i );
		toSend->AddString( "Calendar module", id );
		
		toAdd = new BMenuItem( weekdayNames[ i ].longName.String(),
							   toSend );
		if ( !toAdd ) {
			/* Panic! */
			exit( 1 );
		}
		toAdd->SetTarget( this );
		startDayChooserMenu->AddItem( toAdd );
		if ( i == currentlySelectedStartingDay ) {
			toAdd->SetMarked( true );
		}
	}	// <-- end of pass on all days in week
	
	BMenuField* startDayChooser = new BMenuField( frame,
												  "First day of week chooser",
												  "Select first day of week:",
												  startDayChooserMenu );
	
	if ( ! startDayChooser ) {
		/* Panic! */
		delete startDayChooserMenu;
		return NULL;
	}
	
	startDayChooser->ResizeToPreferred();

	return startDayChooser;
	
}	// <-- end of function CalendarModulePreferencesView::CreateWeekStartDayChooser
コード例 #12
0
ファイル: CatBrowser.cpp プロジェクト: HaikuArchives/Recibe
CatBrowser::CatBrowser(const BRect &frame, const BMessenger &msgr,
						const char *category, bool editmode)
 :	BWindow(frame,"Recipe Browser",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS),
 	fMessenger(msgr),
 	fCategoryCount(-1),
 	fCurrentPage(-1),
 	fEditMode(editmode)
{
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
	AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP));
	
	BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW);
	back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(back);
	
	fCategories = new BMenu("Categories");
	CppSQLite3Query query = DBQuery("select category from categories order by category;",
									"FindWindow:get categories");
	while(!query.eof())
	{
		BString cat(DeescapeIllegalCharacters(query.getStringField(0)));
		fCategories->AddItem(new BMenuItem(cat.String(),new BMessage(M_SET_CATEGORY)));
		query.nextRow();
	}
	fCategories->SetRadioMode(true);
	fCategories->SetLabelFromMarked(true);
	if(fCategories->CountItems()>0)
		fCategories->ItemAt(0)->SetMarked(true);
	BRect r(10,10,10 + fCategories->MaxContentWidth(),11);
	BMenuField *field = new BMenuField(r,"field","Category",fCategories);
	back->AddChild(field);
	field->ResizeToPreferred();
	r = field->Frame();
	
	BMenuItem *marked = fCategories->FindItem(category);
	if(marked)
		marked->SetMarked(true);
	
	r.OffsetBy(0,r.Height() + 10);
	r.right = Bounds().right - 10 - B_V_SCROLL_BAR_WIDTH;
	r.bottom = Bounds().bottom - 10;
	
	fList = new BListView(r, "newlist", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	fList->SetInvocationMessage(new BMessage(M_SET_RECIPE));
	BScrollView *newscroll = new BScrollView("newscroll",fList,
											B_FOLLOW_ALL, 0, false, true);
	back->AddChild(newscroll);
	
	fBack = new BButton(BRect(10,10,11,11),"back","Back", new BMessage(M_RESULTS_BACK),
					B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	fBack->ResizeToPreferred();
	fBack->ResizeTo(be_plain_font->StringWidth("Back") + 15,fBack->Frame().Height());
	fBack->MoveTo(10,Bounds().bottom - fBack->Bounds().Height() - 10);
	r = fBack->Frame();
	back->AddChild(fBack);
	fBack->SetEnabled(false);
	
	r.OffsetBy(r.Width() + 5, 0);
	fNext = new BButton(r,"next","Next", new BMessage(M_RESULTS_NEXT),
					B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	back->AddChild(fNext);
	fNext->SetEnabled(false);
	
	fClose = new BButton(BRect(10,10,11,11),"close","View Recipe", new BMessage(B_QUIT_REQUESTED),
					B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	fClose->ResizeToPreferred();
	fClose->SetLabel("Close");
	fClose->MoveTo(Bounds().right - fClose->Bounds().Width() - 10,r.top);
	r = fClose->Frame();
	fClose->MakeDefault(true);
	
	r.OffsetBy(-r.Width() - 10, 0);
	fOpen = new BButton(r,"openrecipe","View Recipe",new BMessage(M_SET_RECIPE),
						B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	
	back->AddChild(fOpen);
	back->AddChild(fClose);
	
	fList->MakeFocus(true);
	
	r = fList->Parent()->Frame();
	r.bottom = fClose->Frame().top - 10;
	fList->Parent()->ResizeTo(r.Width(),r.Height());
	
	float controlwidth = (fBack->Frame().Width() * 2) + (fOpen->Frame().Width() * 2) + 65;
	if( Frame().Width() < controlwidth )
		ResizeTo(controlwidth, Frame().Height());
	
	if(fEditMode)
	{
		// This hidden mode (Command-Click on the browser menu item) is for doing
		// massive edits on the database
		fList->SetListType(B_MULTIPLE_SELECTION_LIST);
		fList->SetSelectionMessage(new BMessage(M_SET_RECIPE));
		
		BMenu *editmenu = new BMenu("Edit");
		editmenu->AddItem(new BMenuItem("Mass Recategorize",new BMessage(M_SHOW_RECAT)));
		editmenu->AddItem(new BMenuItem("Delete Recipe",new BMessage(M_DELETE_RECIPE)));
		
		r.Set(10,10,10 + be_plain_font->StringWidth("Edit") + 25,11);
		r.OffsetTo(Bounds().right - 10 - r.Width(), 10);
		BMenuField *editfield = new BMenuField(r,"editfield","Edit",editmenu,
											B_FOLLOW_RIGHT | B_FOLLOW_TOP);
		editfield->SetDivider(0);
		back->AddChild(editfield);
		
		fSortString = " order by number ";
	}
	
	PostMessage(M_SET_CATEGORY);
}