Example #1
0
quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width,
	string name, uint16* xpos, uint16* ypos)
{
	BStringView* sv = new BStringView(BRect((*xpos), (*ypos), 
		(*xpos) + width, (*ypos) + 10),
		(name + "Text").c_str(), name.c_str());
	BFont font;
	sv->GetFont(&font);
	font.SetSize(10);
	sv->SetFont(&font);
	AddChild(sv);
	BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10, 
		(*xpos) + width, (*ypos) + 10), (name + "Field").c_str(), 
		"", "", 0);
	(*xpos) += width;
	tc->SetDivider(0);
	AddChild(tc);
	BPopUpMenu* pu = new BPopUpMenu("", true, false);
	BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9, 
		(*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu);
	mf->SetDivider(0);
	AddChild(mf);
	(*xpos) += 30;
	
	return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv);
}
Example #2
0
bool
ResultWindow::AddLocationChanges(const char* location,
	const PackageList& packagesToInstall,
	const PackageSet& packagesAlreadyAdded,
	const PackageList& packagesToUninstall,
	const PackageSet& packagesAlreadyRemoved)
{
	BGroupView* locationGroup = new BGroupView(B_VERTICAL);
	ObjectDeleter<BGroupView> locationGroupDeleter(locationGroup);

	locationGroup->GroupLayout()->SetInsets(B_USE_SMALL_INSETS);

	rgb_color background = ui_color(B_LIST_BACKGROUND_COLOR);
	if ((fContainerView->CountChildren() & 1) != 0)
		background = tint_color(background, 1.04);
	locationGroup->SetViewColor(background);

	BStringView* locationView = new BStringView(NULL,
		BString().SetToFormat("in %s:", location));
	locationGroup->AddChild(locationView);
	locationView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	BFont locationFont;
	locationView->GetFont(&locationFont);
	locationFont.SetFace(B_BOLD_FACE);
	locationView->SetFont(&locationFont);

	BGroupLayout* packagesGroup = new BGroupLayout(B_VERTICAL);
	locationGroup->GroupLayout()->AddItem(packagesGroup);
	packagesGroup->SetInsets(20, 0, 0, 0);

	bool packagesAdded = _AddPackages(packagesGroup, packagesToInstall,
		packagesAlreadyAdded, true);
	packagesAdded |= _AddPackages(packagesGroup, packagesToUninstall,
		packagesAlreadyRemoved, false);

	if (!packagesAdded)
		return false;

	fContainerView->AddChild(locationGroup);
	locationGroupDeleter.Detach();

	return true;
}
void
TextDocumentTest::ReadyToRun()
{
	Init();
	BRect frame(50.0, 50.0, 749.0, 549.0);

	BWindow* window = new BWindow(frame, "Text document test",
		B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS);

	TextDocumentView* documentView = new TextDocumentView("text document view");

	BScrollView* scrollView = new BScrollView("text scroll view", documentView,
		false, true, B_NO_BORDER);
	BuildFontMenu();


	BToolBar* toolBar= new BToolBar();
	toolBar->AddAction(MENU_FILE_NEW,this,LoadIcon("document_new"));
	toolBar->AddAction(MENU_FILE_OPEN,this,LoadIcon("document_open"));
	toolBar->AddAction(MENU_FILE_SAVE,this,LoadIcon("document_save"));
	toolBar->AddSeparator();
	toolBar->AddView(new BButton("StyleList"));
	toolBar->AddView(fFontMenuField);
	toolBar->AddView(new BButton("Size"));
	toolBar->AddSeparator();
	toolBar->AddAction(FONTBOLD_MSG,this,LoadIcon("text_bold"),"Bold",NULL,false);
	toolBar->AddAction(FONTITALIC_MSG,this,LoadIcon("text_italic"),"Bold",NULL,true);;
	toolBar->AddAction(FONTUNDERLINE_MSG,this,LoadIcon("text_underline"),"Bold",NULL,true);;
	toolBar->AddSeparator();
	/*toolBar->AddView(new BButton("Left"));
	toolBar->AddView(new BButton("Center"));
	toolBar->AddView(new BButton("Right"));
	toolBar->AddView(new BButton("Block"));
	toolBar->AddSeparator();
	toolBar->AddView(new BButton("Inset Right"));
	toolBar->AddView(new BButton("Inset Left"));
	toolBar->AddSeparator();
	toolBar->AddView(new BButton("Bullet List"));
	toolBar->AddSeparator();*/
	
	
	
	toolBar->AddGlue();
	BToolBar* statusBar= new BToolBar();
	BFont* tmpFont	= new BFont();
	BStringView* stringView = new BStringView("firstStatus","Here will be the Status View");
	stringView->GetFont(tmpFont);
	tmpFont->SetSize(tmpFont->Size()-2);
	stringView->SetFont(tmpFont);
	statusBar->AddView(stringView);
	statusBar->AddSeparator();
	BLayoutBuilder::Group<>(window, B_VERTICAL,0)
		.Add(toolBar)
		.Add(scrollView)
		.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED))
		.Add(statusBar)

	;

	CharacterStyle regularStyle;

	float fontSize = regularStyle.Font().Size();

	ParagraphStyle paragraphStyle;
	paragraphStyle.SetJustify(true);
	paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.6f));
	paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f));

	CharacterStyle boldStyle(regularStyle);
	boldStyle.SetBold(true);

	CharacterStyle italicStyle(regularStyle);
	italicStyle.SetItalic(true);

	CharacterStyle italicAndBoldStyle(boldStyle);
	italicAndBoldStyle.SetItalic(true);

	CharacterStyle bigStyle(regularStyle);
	bigStyle.SetFontSize(24);
	bigStyle.SetBold(true);
	bigStyle.SetForegroundColor(255, 50, 50);

	TextDocumentRef document(new TextDocument(), true);

	Paragraph paragraph(paragraphStyle);
	paragraph.Append(TextSpan("This is a", regularStyle));
	paragraph.Append(TextSpan(" test ", bigStyle));
	paragraph.Append(TextSpan("to see if ", regularStyle));
	paragraph.Append(TextSpan("different", boldStyle));
	paragraph.Append(TextSpan(" character styles already work.", regularStyle));
	document->Append(paragraph);

	paragraphStyle.SetSpacingTop(8.0f);
	paragraphStyle.SetAlignment(ALIGN_CENTER);
	paragraphStyle.SetJustify(false);

	paragraph = Paragraph(paragraphStyle);
	paragraph.Append(TextSpan("Different alignment styles ", regularStyle));
	paragraph.Append(TextSpan("are", boldStyle));
	paragraph.Append(TextSpan(" supported as of now!", regularStyle));
	document->Append(paragraph);

	paragraphStyle.SetAlignment(ALIGN_RIGHT);
	paragraphStyle.SetJustify(true);

	paragraph = Paragraph(paragraphStyle);
	paragraph.Append(TextSpan("I am on the ", regularStyle));
	paragraph.Append(TextSpan("Right", boldStyle));
	paragraph.Append(TextSpan("Side", italicStyle));
	document->Append(paragraph);

	// Test a bullet list
	paragraphStyle.SetSpacingTop(8.0f);
	paragraphStyle.SetAlignment(ALIGN_LEFT);
	paragraphStyle.SetJustify(true);
	paragraphStyle.SetBullet(Bullet("->", 12.0f));
	paragraphStyle.SetLineInset(10.0f);

	paragraph = Paragraph(paragraphStyle);
	paragraph.Append(TextSpan("Even bullet lists are supported.", regularStyle));
	document->Append(paragraph);

	paragraph = Paragraph(paragraphStyle);
	paragraph.Append(TextSpan("The wrapping in ", regularStyle));
	paragraph.Append(TextSpan("this", italicStyle));

	paragraph.Append(TextSpan(" bullet item should look visually "
		"pleasing. And ", regularStyle));
	paragraph.Append(TextSpan("why", italicAndBoldStyle));
	paragraph.Append(TextSpan(" should it not?", regularStyle));
	document->Append(paragraph);

/*	MarkupParser parser(regularStyle, paragraphStyle);

	TextDocumentRef document = parser.CreateDocumentFromMarkup(
		"== Text document test ==\n"
		"This is a test to see if '''different''' "
		"character styles already work.\n"
		"Different alignment styles '''are''' supported as of now!\n"
		" * Even bullet lists are supported.\n"
		" * The wrapping in ''this'' bullet item should look visually "
		"pleasing. And ''why'' should it not?\n"
	);*/

	documentView->SetTextDocument(document);
	documentView->SetTextEditor(TextEditorRef(new TextEditor(), true));
	documentView->MakeFocus();

	window->Show();
	FontPanel *fPanel = new FontPanel();
	fPanel->Show();	
}
Example #4
0
// constructor
NavigationInfoPanel::NavigationInfoPanel(BWindow* parent,
		const BMessage& message, const BMessenger& target)
	: BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK,
		B_FLOATING_SUBSET_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE)
	, fMessage(message)
	, fTarget(target)
{
	// create the interface and resize to fit

	BRect frame = Bounds();
	frame.InsetBy(5, 5);
	frame.bottom = frame.top + 15;

	// label string view
	fLabelView = new BStringView(frame, "label", kLabel,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fLabelView->ResizeToPreferred();
	frame = fLabelView->Frame();

	// target clip text control
	frame.OffsetBy(0, frame.Height() + 5);
	fTargetClipTC = new BTextControl(frame, "clip id",
		"Target Playlist ID", "", new BMessage(MSG_INVOKE),
		B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fTargetClipTC->ResizeToPreferred();
	frame = fTargetClipTC->Frame();

	// help string view
	frame.OffsetBy(0, frame.Height() + 5);
	BStringView* helpView = new BStringView(frame, "help",
		"Drag and drop a playlist clip here.",
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	BFont font;
	helpView->GetFont(&font);
	font.SetFace(B_ITALIC_FACE);
	font.SetSize(font.Size() * 0.9);
	helpView->SetFont(&font);
	helpView->SetAlignment(B_ALIGN_CENTER);
	helpView->ResizeToPreferred();

	// parent view
	frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame();
	frame.InsetBy(-5, -5);
	fInfoView = new InfoView(frame, this);
	fInfoView->AddChild(fLabelView);
	fInfoView->AddChild(fTargetClipTC);
	fInfoView->AddChild(helpView);

	// resize to fit and adjust size limits
	ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height());
	AddChild(fInfoView);
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	minWidth = Frame().Width();
	minHeight = maxHeight = Frame().Height();
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

	// modify the high color after the help view is attached to a window
	helpView->SetHighColor(tint_color(helpView->LowColor(),
		B_DISABLED_LABEL_TINT));
	helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE);
		// help the buggy BeOS BStringView (when text alignment != left...)

	fInfoView->SetEventMask(B_POINTER_EVENTS);

	// resize controls to the same (maximum) width
	float maxControlWidth = fLabelView->Frame().Width();
	maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width());
	maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width());
	fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height());
	fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height());
	helpView->ResizeTo(maxControlWidth, helpView->Frame().Height());

	// center above parent window
	BAutolock _(parent);
	frame = Frame();
	BRect parentFrame = parent->Frame();
	MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2,
		(parentFrame.top + parentFrame.bottom - frame.Height()) / 2);

	AddToSubset(parent);
}