Exemple #1
0
	PartitionView(const char* name, float weight, off_t offset,
			int32 level, partition_id id)
		:
		BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE),
		fID(id),
		fWeight(weight),
		fOffset(offset),
		fLevel(level),
		fSelected(false),
		fMouseOver(false),
		fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset))
	{
		SetLayout(fGroupLayout);

		SetViewColor(B_TRANSPARENT_COLOR);
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		base = tint_color(base, B_LIGHTEN_2_TINT);
		base = tint_color(base, 1 + 0.13 * (level - 1));
		SetLowColor(base);
		SetHighColor(tint_color(base, B_DARKEN_1_TINT));

		BFont font;
		GetFont(&font);
		font.SetSize(ceilf(font.Size() * 0.85));
		font.SetRotation(90.0);
		SetFont(&font);

		fGroupLayout->SetInsets(kLayoutInset, kLayoutInset + font.Size(),
			kLayoutInset, kLayoutInset);

		SetExplicitMinSize(BSize(font.Size() + 6, 30));
	}
HVIFView::HVIFView(const char* name, uint32 flags, TranslatorSettings *settings)
	:
	BView(name, flags, new BGroupLayout(B_VERTICAL)),
	fSettings(settings)
{
	BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL);

	BStringView* title= new BStringView("title",
		B_TRANSLATE("Native Haiku icon format translator"));
	title->SetFont(be_bold_font);
	title->SetExplicitAlignment(labelAlignment);

	char versionString[256];
	snprintf(versionString, sizeof(versionString), 
		B_TRANSLATE("Version %d.%d.%d, %s"),
		int(B_TRANSLATION_MAJOR_VERSION(HVIF_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(HVIF_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(HVIF_TRANSLATOR_VERSION)),
		__DATE__);
	BStringView* version = new BStringView("version", versionString);
	version->SetExplicitAlignment(labelAlignment);

	BStringView* copyright = new BStringView("copyright",
		B_UTF8_COPYRIGHT"2009 Haiku Inc.");
	copyright->SetExplicitAlignment(labelAlignment);


	int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE);
	BString label = B_TRANSLATE("Render size:");
	label << " " << renderSize;

	fRenderSize = new BSlider("renderSize", label.String(),
		NULL, 1, 32, B_HORIZONTAL);
	fRenderSize->SetValue(renderSize / 8);
	fRenderSize->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fRenderSize->SetHashMarkCount(16);
	fRenderSize->SetModificationMessage(
		new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED));
	fRenderSize->SetExplicitAlignment(labelAlignment);

	float padding = 5.0f;
	BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
		.SetInsets(padding)
		.Add(title)
		.Add(version)
		.Add(copyright)
		.Add(fRenderSize)
		.AddGlue();

 	BFont font;
 	GetFont(&font);
 	SetExplicitPreferredSize(
		BSize((font.Size() * 270) / 12, (font.Size() * 100) / 12));
}
TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings)
	:
	BView(name, flags),
	fSettings(settings)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

 	fTitle = new BStringView("title", B_TRANSLATE("TGA Image Translator"));
 	fTitle->SetFont(be_bold_font);

 	char detail[100];
 	sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"),
 		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)),
 		static_cast<int>(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)),
 		static_cast<int>(B_TRANSLATION_REVISION_VERSION(
 			TGA_TRANSLATOR_VERSION)), __DATE__);
 	fDetail = new BStringView("detail", detail);
 	fWrittenBy = new BStringView("writtenby",
 		B_TRANSLATE("Written by the Haiku Translation Kit Team"));

 	fpchkIgnoreAlpha = new BCheckBox(B_TRANSLATE("Ignore TGA alpha channel"),
		new BMessage(CHANGE_IGNORE_ALPHA));
 	int32 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0;
 	fpchkIgnoreAlpha->SetValue(val);
 	fpchkIgnoreAlpha->SetViewColor(ViewColor());

 	fpchkRLE = new BCheckBox(B_TRANSLATE("Save with RLE Compression"),
		new BMessage(CHANGE_RLE));
 	val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0;
 	fpchkRLE->SetValue(val);
 	fpchkRLE->SetViewColor(ViewColor());

 	// Build the layout
 	SetLayout(new BGroupLayout(B_HORIZONTAL));

 	AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
 		.Add(fTitle)
 		.Add(fDetail)
 		.AddGlue()
 		.Add(fpchkIgnoreAlpha)
 		.Add(fpchkRLE)
 		.AddGlue()
 		.Add(fWrittenBy)
 		.AddGlue()
 		.SetInsets(5, 5, 5, 5)
 	);

 	BFont font;
 	GetFont(&font);
 	SetExplicitPreferredSize(BSize((font.Size() * 333)/12,
 		(font.Size() * 200)/12));
}
Exemple #4
0
void
BMenuItem::DrawContent()
{
	MenuPrivate menuPrivate(fSuper);
	menuPrivate.CacheFontInfo();

	fSuper->MovePenBy(0, menuPrivate.Ascent());
	BPoint lineStart = fSuper->PenLocation();

	float labelWidth, labelHeight;
	GetContentSize(&labelWidth, &labelHeight);

	fSuper->SetDrawingMode(B_OP_OVER);

	float frameWidth = fBounds.Width();
	if (menuPrivate.State() == MENU_STATE_CLOSED) {
		float rightMargin, leftMargin;
		menuPrivate.GetItemMargins(&leftMargin, NULL, &rightMargin, NULL);
		frameWidth = fSuper->Frame().Width() - (rightMargin + leftMargin);
	}

	// truncate if needed
	if (frameWidth > labelWidth)
		fSuper->DrawString(fLabel);
	else {
		char *truncatedLabel = new char[strlen(fLabel) + 4];
		TruncateLabel(frameWidth, truncatedLabel);
		fSuper->DrawString(truncatedLabel);
		delete[] truncatedLabel;
	}

	if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) {
		float escapements[fTriggerIndex + 1];
		BFont font;
		fSuper->GetFont(&font);

		font.GetEscapements(fLabel, fTriggerIndex + 1, escapements);

		for (int32 i = 0; i < fTriggerIndex; i++)
			lineStart.x += escapements[i] * font.Size();

		lineStart.x--;
		lineStart.y++;

		BPoint lineEnd(lineStart);
		lineEnd.x += escapements[fTriggerIndex] * font.Size();

		fSuper->StrokeLine(lineStart, lineEnd);
	}
}
Exemple #5
0
PieView::PieView(BVolume* volume)
	:
	BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_SUBPIXEL_PRECISE),
	fWindow(NULL),
	fScanner(NULL),
	fVolume(volume),
	fMouseOverInfo(),
	fClicked(false),
	fDragging(false),
	fUpdateFileAt(false)
{
	fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false);
	fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL),
		kIdxGetInfo);
	fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Open"), NULL),
		kIdxOpen);

	fFileUnavailableMenu = new BPopUpMenu(kEmptyStr, false, false);
	BMenuItem* item = new BMenuItem(B_TRANSLATE("file unavailable"), NULL);
	item->SetEnabled(false);
	fFileUnavailableMenu->AddItem(item);

	BFont font;
	GetFont(&font);
	font.SetSize(ceilf(font.Size() * 1.33));
	font.SetFace(B_BOLD_FACE);
	SetFont(&font);

	struct font_height fh;
	font.GetHeight(&fh);
	fFontHeight = ceilf(fh.ascent) + ceilf(fh.descent) + ceilf(fh.leading);
}
void
TeamsColumn::InitTextMargin(BView* parent)
{
	BFont font;
	parent->GetFont(&font);
	sTextMargin = ceilf(font.Size() * 0.8);
}
Exemple #7
0
void NetListView::FrameResized(float width, float height)
{
	BListView::FrameResized(width, height);
	//Ensure the bevel on the right is drawn properly
	if(width < oldWidth)
		oldWidth = width;
	PushState();
	BRect invalRect(oldWidth, 0, oldWidth, height);
	ConvertFromParent(&invalRect);
	BRegion lineRegion(invalRect);
	ConstrainClippingRegion(&lineRegion);
	Draw(invalRect);
	oldWidth = width;
	PopState();
	
	//Do word wrapping
	BFont curFont;
	GetFont(&curFont);
	float itemWidth = Bounds().Width();
	float wrapWidth = (itemWidth - 6)/curFont.Size();
	for(int itemNum = 0; itemNum < CountItems(); itemNum++)
	{
		NetListItem* item = (NetListItem*)(Items()[itemNum]);
		item->SetWidth(itemWidth);
		item->CalcWordWrap(wrapWidth);
	}
	//DoForEach(UpdateItem, (void*)this);
	Invalidate();
	
	BListView::FrameResized(width, height);
}
Exemple #8
0
void CSelectionView::ChooseFont()
{
	CFontMetrics metrics = gFontSizeTable[fCellView->BorderFontID()];
	BFont myFont = metrics.Font();
	font_height fi;
	
	do
	{
		myFont.GetHeight(&fi);
		if (fi.ascent + fi.descent <= Bounds().Height())
			break;
		
		float size = myFont.Size();
		myFont.SetSize(size - 1);
		myFont.GetHeight(&fi);
		if (fi.ascent + fi.descent <= Bounds().Height())
			break;

		myFont.SetSize(size - 2);
		myFont.GetHeight(&fi);
		if (fi.ascent + fi.descent <= Bounds().Height())
			break;
		
		myFont = be_plain_font;
		myFont.GetHeight(&fi);
		if (fi.ascent + fi.descent <= Bounds().Height())
			break;
		
		// uh, oh, trouble...
	}
	while (false);

	SetFont(&myFont);
	Invalidate();
} /* CSelectionView::ChooseFont */	
Exemple #9
0
/* virtual */
void
HeaderListItem::DrawItem(BView *owner, BRect itemRect, bool drawEverthing)
{
	owner->SetDrawingMode(B_OP_COPY);

	owner->PushState();
	if (IsSelected()) {
		rgb_color lowColor = owner->LowColor();
		owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT));
		owner->FillRect(itemRect);
	}

	owner->PopState();

	itemRect.InsetBy(0, 1);
	owner->StrokeRect(itemRect);

	itemRect.InsetBy(1, 0);

	owner->SetDrawingMode(B_OP_OVER);

	BFont font;
	owner->GetFont(&font);
	float baseLine = itemRect.top + (itemRect.IntegerHeight() / 2 + font.Size() / 2);

	for (int32 c = 0; c < sizeof(fLabels) / sizeof(fLabels[0]); c++) {
		owner->MovePenTo(itemRect.left + 1 + (fRect.Width() + kDistance) * c, baseLine);
		owner->DrawString(fLabels[c]);
	}
}
BudgetWindow::BudgetWindow(const BRect &frame)
 :	BWindow(frame,TRANSLATE("Budget"), B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
 	fIncomeGrid(13,0),
 	fSpendingGrid(13,0)
{
	fBackView = new BView("background",B_WILL_DRAW);
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
		.SetInsets(0)
		.Add(fBackView)
	.End();
	fBackView->SetViewColor(240,240,240);

	fBar = new BMenuBar("menubar");
	fBar->AddItem(new BMenuItem(TRANSLATE("Recalculate All"),new BMessage(M_BUDGET_RECALCULATE)));
	fBar->AddItem(new BMenuItem(TRANSLATE("Set All to Zero"),new BMessage(M_BUDGET_ZERO)));

	BuildBudgetSummary();
	BuildStatsAndEditor();
	BuildCategoryList();

	BFont font;
	BLayoutBuilder::Group<>(fCatBox, B_VERTICAL, 0.0f)
		.SetInsets(10, font.Size() * 1.3, 10, 10)
		.Add(fAmountLabel)
		.Add(fAmountBox)
		.AddGrid(B_USE_DEFAULT_SPACING, 1.0f)
			.Add(fMonthly, 0, 0)
			.Add(fWeekly, 1, 0)
			.Add(fQuarterly, 0, 1)
			.Add(fAnnually, 1, 1)
		.End()	
	.End();
	fAmountBox->SetText("");

	fAmountBox->GetFilter()->SetMessenger(new BMessenger(this));

	if(gDatabase.CountBudgetEntries()==0)
		GenerateBudget(false);

	RefreshBudgetGrid();
	RefreshCategories();
	RefreshBudgetSummary();
	fCategoryList->MakeFocus(true);
	
	BLayoutBuilder::Group<>(fBackView, B_VERTICAL, 0.0f)
		.SetInsets(0)
		.Add(fBar)
		.AddGroup(B_VERTICAL)
			.SetInsets(10, 10, 10, 10)
			.AddGroup(B_HORIZONTAL)
				.Add(fCategoryList)
				.AddGroup(B_VERTICAL)
					.Add(fCatBox)
					.Add(fCatStat)
				.End()
			.End()
			.Add(fBudgetSummary)
		.End()
	.End();	
}
Exemple #11
0
void
KeyControl::DrawKey(BRect r, const char* c)
{
	BFont font;
	GetFont(&font);

	SetHighColor(240,240,240);

	StrokeLine(BPoint(r.left, r.top), BPoint(r.right-1, r.top));
	StrokeLine(BPoint(r.left, r.top+1), BPoint(r.left, r.bottom));
	SetHighColor(128,128,128);

	StrokeLine(BPoint(r.left+1, r.bottom), BPoint(r.right, r.bottom));
	StrokeLine(BPoint(r.right, r.bottom-1), BPoint(r.right, r.top));
	SetHighColor(192,192,192);

	r.InsetBy(1,1);
	
	FillRect(r);
	SetHighColor(0,0,0);
	SetLowColor(192,192,192);

	DrawString(c,
		BPoint((r.left+r.right)/2.0f-font.StringWidth(c)/2.0f +1.0f,
		r.top+font.Size()));

	SetLowColor(255,255,255);
}
Exemple #12
0
void
KeyItem::DrawKey(BView* view, BRect r, const char *c)
{
	BFont font;
	view->GetFont(&font);

	view->SetHighColor(240,240,240);
	view->StrokeLine(BPoint(r.left, r.top), BPoint(r.right-1, r.top));
	view->StrokeLine(BPoint(r.left, r.top+1), BPoint(r.left, r.bottom));
	view->SetHighColor(128,128,128);

	view->StrokeLine(BPoint(r.left+1, r.bottom),
		BPoint(r.right, r.bottom));

	view->StrokeLine(BPoint(r.right, r.bottom-1 ), BPoint(r.right, r.top));
	view->SetHighColor(192,192,192);

	r.InsetBy(1,1);

	view->FillRect(r);
	view->SetHighColor(0,0,0);
	view->SetLowColor(192,192,192);
	view->DrawString(c, BPoint((r.left+r.right)/2.0f
		- font.StringWidth(c)/2.0f +1.0f, r.top+font.Size()-2.0f) );

	if (IsSelected())
		view->SetLowColor(150,190,230);
	else
		view->SetLowColor(255,255,255);
}
Exemple #13
0
void
TermWindow::MenusBeginning()
{
	TermView* view = _ActiveTermView();

	// Syncronize Encode Menu Pop-up menu and Preference.
	const BCharacterSet* charset
		= BCharacterSetRoster::GetCharacterSetByConversionID(view->Encoding());
	if (charset != NULL) {
		BString name(charset->GetPrintName());
		const char* mime = charset->GetMIMEName();
		if (mime)
			name << " (" << mime << ")";

		BMenuItem* item = fEncodingMenu->FindItem(name);
		if (item != NULL)
			item->SetMarked(true);
	}

	BFont font;
	view->GetTermFont(&font);

	float size = font.Size();

	fDecreaseFontSizeMenuItem->SetEnabled(size > kMinimumFontSize);
	fIncreaseFontSizeMenuItem->SetEnabled(size < kMaximumFontSize);

	BWindow::MenusBeginning();
}
ConfigView::ConfigView(uint32 flags)
	: BView("EXRTranslator Settings", flags)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BStringView *fTitle = new BStringView("title",
		B_TRANSLATE("EXR image translator"));
	fTitle->SetFont(be_bold_font);

	char version[256];
	sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
		int(B_TRANSLATION_MAJOR_VERSION(EXR_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(EXR_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(EXR_TRANSLATOR_VERSION)),
		__DATE__);
	BStringView *fVersion = new BStringView("version", version);

	BStringView *fCopyright = new BStringView("copyright",
		B_UTF8_COPYRIGHT "2008 Haiku Inc.");

	BStringView *fCopyright2 = new BStringView("copyright2",
		B_TRANSLATE("Based on OpenEXR (http://www.openexr.com)"));

	BStringView *fCopyright3 = new BStringView("copyright3",
		B_UTF8_COPYRIGHT "2006, Industrial Light & Magic,");

	BStringView *fCopyright4 = new BStringView("copyright4",
		B_TRANSLATE("a division of Lucasfilm Entertainment Company Ltd"));

	// Build the layout
    BLayoutBuilder::Group<>(this, B_VERTICAL, 7)
		.SetInsets(5)
        .Add(fTitle)
		.Add(fVersion)
		.AddGlue()
		.Add(fCopyright)
		.Add(fCopyright2)
		.AddGlue()
		.Add(fCopyright3)
		.Add(fCopyright4)
		.AddGlue();

	BFont font;
	GetFont(&font);
	SetExplicitPreferredSize(BSize(font.Size() * 400 / 12,
		font.Size() * 200 / 12));
}
Exemple #15
0
void
BColorControl::_SetCellSize(float size)
{
	BFont font;
	GetFont(&font);
	fCellSize = std::max(kMinCellSize,
		ceilf(size * font.Size() / kDefaultFontSize));
}
Exemple #16
0
float
DataView::FontSize() const
{
	BFont font;
	GetFont(&font);

	return font.Size();
}
Exemple #17
0
	SmallButton(const char* label, BMessage* message = NULL)
		:
		BButton(label, message)
	{
		BFont font;
		GetFont(&font);
		float size = ceilf(font.Size() * 0.8);
		font.SetSize(max_c(8, size));
		SetFont(&font, B_FONT_SIZE);
	}
Exemple #18
0
// SetFont
void
Painter::SetFont(const BFont& font)
{
	//fFont.SetFamilyAndStyle(font.GetFamily(), font.GetStyle());
	fFont.SetSpacing(font.Spacing());
	fFont.SetShear(font.Shear());
	fFont.SetRotation(font.Rotation());
	fFont.SetSize(font.Size());
	
	_UpdateFont();
}
Exemple #19
0
static BCheckBox*
create_check_box(const char* label, const char* name)
{
	BMessage* message = new BMessage(MSG_FILTER_SELECTED);
	message->AddString("name", name);
	BCheckBox* checkBox = new BCheckBox(label, message);
	BFont font;
	checkBox->GetFont(&font);
	font.SetSize(ceilf(font.Size() * 0.75));
	checkBox->SetFont(&font);
	return checkBox;
}
Exemple #20
0
void
KeyItem::DrawItem(BView* view, BRect rect, bool all)
{
	BFont font;
	view->GetFont(&font);

	// Draw the Outline
	if (fId == -1) {			
		if (IsSelected())
			view->SetLowColor(150,190,230);
		else
			view->SetLowColor(255,255,255);

		view->FillRect(rect, B_SOLID_LOW);
		view->SetHighColor(0,0,0);
		view->SetFont(be_bold_font);
		view->DrawString(Text(), BPoint(rect.left+5, rect.top+font.Size()));
		view->SetFont(&font);
		return;
	}

	const char* key;

	BStringItem::DrawItem(view, rect, all);

	view->SetHighColor(240,240,240);
	view->StrokeLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom));
	view->SetHighColor(0,0,0);

	float x = rect.left + rect.Width()/2 +(font.Size()+4)*3;	// max 3 combinations

	DrawMods(view, BRect( x - font.Size() - 6, rect.top+1, x -4, rect.bottom-1), fMod);

	if (fKey >' ' && fKey < 'a') {
		view->DrawChar( fKey, BPoint( x, rect.top +font.Size() ));
	} else if (fKey) {
		key = _KeyLabel(fKey);
		DrawKey(view, BRect(x-2, rect.top+1, x+font.StringWidth(key)+2, rect.bottom-1), key);
	}
}
Exemple #21
0
ConfigView::ConfigView(uint32 flags)
	: BView(kShortName2, flags)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	BStringView *fTitle = new BStringView("title", B_TRANSLATE("RAW image translator"));
	fTitle->SetFont(be_bold_font);

	char version[256];
	sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
		int(B_TRANSLATION_MAJOR_VERSION(RAW_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(RAW_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(RAW_TRANSLATOR_VERSION)),
		__DATE__);
	BStringView *fVersion = new BStringView("version", version);

	BStringView *fCopyright = new BStringView("copyright",
		B_UTF8_COPYRIGHT "2007-2009 Haiku Inc.");

	BStringView *fCopyright2 = new BStringView("copyright2",
		B_TRANSLATE("Based on Dave Coffin's dcraw 8.63"));

	BStringView *fCopyright3 = new BStringView("copyright3",
		B_UTF8_COPYRIGHT "1997-2007 Dave Coffin");

	// Build the layout
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(fTitle)
		.Add(fVersion)
		.Add(fCopyright)
		.AddGlue()
		.Add(fCopyright2)
		.Add(fCopyright3);

	BFont font;
	GetFont(&font);
	SetExplicitPreferredSize(BSize((font.Size() * 233)/12, (font.Size() * 200)/12));
}
Exemple #22
0
void
AboutWindow::Show()
{
    BAlert* alert = new BAlert("About" B_UTF8_ELLIPSIS, fText->String(), "Close");
    BTextView* view = alert->TextView();
    BFont font;
    view->SetStylable(true);
    view->GetFont(&font);
    font.SetFace(B_BOLD_FACE);
    font.SetSize(font.Size() * 1.7f);
    view->SetFontAndColor(0, fAppName->Length(), &font);
    alert->Go();
}
Exemple #23
0
AboutView::AboutView(const char* appName, const char* signature)
	:
	BGroupView("AboutView", B_VERTICAL)
{
	fNameView = new BStringView("name", appName);
	BFont font;
	fNameView->GetFont(&font);
	font.SetFace(B_BOLD_FACE);
	font.SetSize(font.Size() * 2.0);
	fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE
		| B_FONT_FLAGS);

	fVersionView = new BStringView("version",
		_GetVersionFromSignature(signature));

	fInfoView = new BTextView("info", B_WILL_DRAW);
	fInfoView->SetExplicitMinSize(BSize(210.0, 160.0));
	fInfoView->MakeEditable(false);
	fInfoView->SetWordWrap(true);
	fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0);
	fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
	fInfoView->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR));
	fInfoView->SetStylable(true);

	BScrollView* infoViewScroller = new BScrollView(
		"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
		false, true, B_PLAIN_BORDER);

	fStripeView = new StripeView(_GetIconFromSignature(signature));

	const char* ok = B_TRANSLATE_MARK("Ok");
	BButton* closeButton = new BButton("ok",
		gSystemCatalog.GetString(ok, "AboutWindow"),
		new BMessage(B_QUIT_REQUESTED));

	GroupLayout()->SetSpacing(0);
	BLayoutBuilder::Group<>(this)
		.AddGroup(B_HORIZONTAL, 0)
			.Add(fStripeView)
			.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
				.SetInsets(0, B_USE_DEFAULT_SPACING,
					B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
				.Add(fNameView)
				.Add(fVersionView)
				.Add(infoViewScroller)
				.Add(closeButton)
				.End()
			.AddGlue()
			.End();
}
CamStatusView::CamStatusView(Controller* controller)
	:
	BView("CamStatusView", B_WILL_DRAW|B_PULSE_NEEDED),
	fController(controller),
	fStringView(NULL),
	fBitmapView(NULL),
	fEncodingStringView(NULL),
	fStatusBar(NULL),
	fNumFrames(0),
	fRecording(false),
	fPaused(false),
	fRecordingBitmap(NULL),
	fPauseBitmap(NULL)
{
	BCardLayout* cardLayout = new BCardLayout();
	SetLayout(cardLayout);
	BRect bitmapRect(0, 0, kBitmapSize, kBitmapSize);
	fRecordingBitmap = new BBitmap(bitmapRect, B_RGBA32);
	fPauseBitmap = new BBitmap(bitmapRect, B_RGBA32);
	
	BView* statusView = BLayoutBuilder::Group<>()
		.SetInsets(0)
		.Add(fEncodingStringView = new BStringView("stringview", kEncodingString))
		.Add(fStatusBar = new BStatusBar("", ""))
		.View();

	fStatusBar->SetExplicitMinSize(BSize(100, 20));

	BView* layoutView = BLayoutBuilder::Group<>()
		.SetInsets(0)
		.Add(fBitmapView = new SquareBitmapView("bitmap view"))
		.Add(fStringView = new BStringView("cam string view", ""))
		.View();

	cardLayout->AddView(layoutView);
	cardLayout->AddView(statusView);
	
	fBitmapView->SetBitmap(NULL);
	
	BFont font;
	GetFont(&font);
	float scaledSize = kBitmapSize * (capped_size(font.Size()) / 12);
	fBitmapView->SetExplicitMinSize(BSize(scaledSize, scaledSize));
	fBitmapView->SetExplicitMaxSize(BSize(scaledSize, scaledSize));
	fBitmapView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
	
	fStringView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
	
	cardLayout->SetVisibleItem(int32(0));
}
Exemple #25
0
void
WizardPageView::MakeHeading(BTextView* view)
{
	const char* text = view->Text();
	const char* firstLineEnd = strchr(text, '\n');
	if (firstLineEnd != NULL) {
		int indexFirstLineEnd = firstLineEnd - text;
		BFont font;
		view->GetFont(&font);
		font.SetSize(ceil(font.Size() * 1.2));
		font.SetFace(B_BOLD_FACE);
		view->SetFontAndColor(0, indexFirstLineEnd, &font);
	}
}
Exemple #26
0
void
BMenuItem::_DrawShortcutSymbol()
{
	BMenu *menu = Menu();
	BFont font;
	menu->GetFont(&font);
	BPoint where = ContentLocation();
	where.x = fBounds.right - font.Size();

	if (fSubmenu)
		where.x -= fBounds.Height() - 3;

	const float ascent = MenuPrivate(fSuper).Ascent();
	if (fShortcutChar < B_SPACE && kUTF8ControlMap[(int)fShortcutChar])
		_DrawControlChar(fShortcutChar, where + BPoint(0, ascent));
	else
		fSuper->DrawChar(fShortcutChar, where + BPoint(0, ascent));

	where.y += (fBounds.Height() - 11) / 2 - 1;
	where.x -= 4;

	if (fModifiers & B_COMMAND_KEY) {
		const BBitmap *command = MenuPrivate::MenuItemCommand();
		const BRect &rect = command->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(command, where);
	}

	if (fModifiers & B_CONTROL_KEY) {
		const BBitmap *control = MenuPrivate::MenuItemControl();
		const BRect &rect = control->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(control, where);
	}

	if (fModifiers & B_OPTION_KEY) {
		const BBitmap *option = MenuPrivate::MenuItemOption();
		const BRect &rect = option->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(option, where);
	}

	if (fModifiers & B_SHIFT_KEY) {
		const BBitmap *shift = MenuPrivate::MenuItemShift();
		const BRect &rect = shift->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(shift, where);
	}
}
Exemple #27
0
// constructor
Font::Font(const BFont& font)
	: fFamily("")
	, fStyle("")
	, fSize(font.Size())
	, fRotation(font.Rotation())
	, fShear(font.Shear())
	, fFalseBoldWidth(0.0)
	, fHinting(true)
	, fKerning(true)
	, fSpacing(font.Spacing())
	, fCachedFontHeightValid(true)
{
	font_family family;
	font_style style;
	font.GetFamilyAndStyle(&family, &style);
	fFamily = family;
	fStyle = style;
	font.GetHeight(&fCachedFontHeight);
}
Exemple #28
0
status_t
CharacterWindow::_SaveSettings()
{
	BFile file;
	status_t status = _OpenSettings(file, B_WRITE_ONLY | B_CREATE_FILE
		| B_ERASE_FILE);
	if (status < B_OK)
		return status;

	BMessage settings('chrm');
	status = settings.AddRect("window frame", Frame());
	if (status != B_OK)
		return status;

	if (status == B_OK) {
		status = settings.AddBool("show private blocks",
			fCharacterView->IsShowingPrivateBlocks());
	}
	if (status == B_OK) {
		status = settings.AddBool("show contained blocks only",
			fCharacterView->IsShowingContainedBlocksOnly());
	}

	if (status == B_OK) {
		BFont font = fCharacterView->CharacterFont();
		status = settings.AddInt32("font size", font.Size());

		font_family family;
		font_style style;
		if (status == B_OK)
			font.GetFamilyAndStyle(&family, &style);
		if (status == B_OK)
			status = settings.AddString("font family", family);
		if (status == B_OK)
			status = settings.AddString("font style", style);
	}

	if (status == B_OK)
		status = settings.Flatten(&file);

	return status;
}
BString
BStatusView::_StatusString(float availableSpace, float fontSize,
	float* _width)
{
	BFont font;
	GetFont(&font);
	float oldSize = font.Size();
	font.SetSize(fontSize);
	SetFont(&font, B_FONT_SIZE);

	BString status;
	if (sShowSpeed) {
		status = _SpeedStatusString(availableSpace, _width);
	} else
		status = _TimeStatusString(availableSpace, _width);

	font.SetSize(oldSize);
	SetFont(&font, B_FONT_SIZE);
	return status;
}
Exemple #30
0
void
OverlayView::OverlayAboutRequested()
{
	BAlert *alert = new BAlert("about",
		"OverlayImage\n"
		"Copyright 1999-2010\n\n\t"
		"originally by Seth Flaxman\n\t"
		"modified by Hartmuth Reh\n\t"
		"further modified by Humdinger\n",
		"OK");	
	BTextView *view = alert->TextView();
	BFont font;
	view->SetStylable(true);
	view->GetFont(&font);
	font.SetSize(font.Size() + 7.0f);
	font.SetFace(B_BOLD_FACE);
	view->SetFontAndColor(0, 12, &font);
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);	
	alert->Go();
}