Example #1
0
RipView::RipView(const BRect &frame, CDAudioDevice *cd)
	: BView(frame,"ripview",B_FOLLOW_ALL,B_WILL_DRAW),
	fRipThread(-1)
{
	abort_thread = create_sem(1,"rip_abort_sem");
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	fStop = new BButton(BRect(0,0,1,1),"stop",_T("Stop"),new BMessage(M_STOP),
						B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fStop->ResizeToPreferred();
	fStop->MoveTo(Bounds().right - 5 - fStop->Bounds().Width(),
					Bounds().bottom - 5 - fStop->Bounds().Height());
	AddChild(fStop);
	
	BRect r(5,5,Bounds().right - 5,30);
	fProgressBar = new BStatusBar(r,"progressbar");
	fProgressBar->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	AddChild(fProgressBar);
	
	r.Set(5,fProgressBar->Frame().bottom+15,Bounds().right - 5, fProgressBar->Frame().bottom+35);
	BStringView *listLabel = new BStringView(r,"listlabel",_T("Songs to be Converted:"));
	AddChild(listLabel);
	
	r.Set(5,listLabel->Frame().bottom+5,Bounds().right - 5 - B_V_SCROLL_BAR_WIDTH, fStop->Frame().top - 10);
	fRipList = new BListView(r,"riplist",B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL);
		
	BScrollView *ripsv = new BScrollView("ripsv",fRipList, B_FOLLOW_ALL,0,false,true);
	AddChild(ripsv);
}
void
Window::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgShowAlert:
		{
			int32 count = fCountSlider->Value();

			BAlert* alert = new BAlert("Test title", "Lorem ipsum dolor sit "
				"amet, consectetur adipiscing elit. Suspendisse vel iaculis "
				"quam. Donec faucibus erat nunc, ac ullamcorper justo sodales.",
				"short 1", count > 1 ? "a bit longer 2" : NULL,
				count > 2 ? "very very long button 3" : NULL,
				_ButtonWidth(), _ButtonSpacing(), _AlertType());
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			int result = alert->Go();
			if (result < 0) {
				fLastStringView->SetText("Canceled alert");
			} else {
				fLastStringView->SetText(BString().SetToFormat(
					"Pressed button %d", result + 1).String());
			}
			break;
		}
		default:
			BWindow::MessageReceived(message);
	}
}
Example #3
0
WonderBrushView::WonderBrushView(const BRect &frame, const char *name,
	uint32 resize, uint32 flags, TranslatorSettings *settings)
	:	BView(frame, name, resize, flags),
		fSettings(settings)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

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

	char version[100];
	sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WBI_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_MINOR_VERSION(WBI_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_REVISION_VERSION(
			WBI_TRANSLATOR_VERSION)), __DATE__);

	BStringView *versionView  = new BStringView("version", version);
	BStringView *copyrightView  = new BStringView("copyright", kWBICopyright);
	BStringView *copyright2View  = new BStringView("copyright2", B_TRANSLATE("written by:"));
	BStringView *copyright3View  = new BStringView("copyright3", kAuthor);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(titleView)
		.Add(versionView)
		.Add(copyrightView)
		.AddGlue()
		.Add(copyright2View)
		.Add(copyright3View);
}
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
	:
	BView(name, 0),
	fDecorInfoButton(NULL),
	fDecorMenuField(NULL),
	fDecorMenu(NULL)
{
	// Decorator menu
	_BuildDecorMenu();
	fDecorMenuField = new BMenuField("decorator",
		B_TRANSLATE("Decorator:"), fDecorMenu);

	fDecorInfoButton = new BButton(B_TRANSLATE("About"),
		new BMessage(kMsgDecorInfo));

	// scroll bar arrow style
	BBox* arrowStyleBox = new BBox("arrow style");
	arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));

	fSavedDoubleArrowsValue = _DoubleScrollBarArrows();

	fArrowStyleSingle = new FakeScrollBar(true, false,
		new BMessage(kMsgArrowStyleSingle));
	fArrowStyleDouble = new FakeScrollBar(true, true,
		new BMessage(kMsgArrowStyleDouble));

	BView* arrowStyleView;
	arrowStyleView = BLayoutBuilder::Group<>()
		.AddGroup(B_VERTICAL, 1)
			.Add(new BStringView("single", B_TRANSLATE("Single:")))
			.Add(fArrowStyleSingle)
			.AddStrut(B_USE_DEFAULT_SPACING)
			.Add(new BStringView("double", B_TRANSLATE("Double:")))
			.Add(fArrowStyleDouble)
			.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.End()
		.View();
	arrowStyleBox->AddChild(arrowStyleView);
	arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_CENTER));
	arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	BStringView* scrollBarLabel
		= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
	scrollBarLabel->SetExplicitAlignment(
		BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	// control layout
	BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
		.Add(fDecorInfoButton, 2, 0)
		.Add(scrollBarLabel, 0, 1)
		.Add(arrowStyleBox, 1, 1)
		.AddGlue(0, 2)
		.SetInsets(B_USE_WINDOW_SPACING);

	// TODO : Decorator Preview Image?
}
Example #5
0
PPDConfigView::PPDConfigView(BRect bounds, const char *name, uint32 resizeMask, uint32 flags) 
	: BView(bounds, name, resizeMask, flags) 
	, fPPD(NULL)
{	
	// add category outline list view	
	bounds.OffsetTo(0, 0);
	BRect listBounds(bounds.left + kLeftMargin, bounds.top + kTopMargin, 
		bounds.right - kHorizontalSpace, bounds.bottom - kBottomMargin);
	listBounds.right -= B_V_SCROLL_BAR_WIDTH;
	listBounds.bottom -= B_H_SCROLL_BAR_HEIGHT;

	BStringView* label = new BStringView(listBounds, "printer-settings", "Printer Settings:");
	AddChild(label);
	label->ResizeToPreferred();
	
	listBounds.top += label->Bounds().bottom + 5;

	// add details view
	fDetails = new BView(listBounds, "details", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	fDetails->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	BScrollView* scrollView = new BScrollView("details-scroll-view", 
		fDetails, B_FOLLOW_ALL_SIDES, 0, true, true);

	AddChild(scrollView);
}
Example #6
0
bool
ResultWindow::_AddPackages(BGroupLayout* packagesGroup,
	const PackageList& packages, const PackageSet& ignorePackages, bool install)
{
	bool packagesAdded = false;

	for (int32 i = 0; BSolverPackage* package = packages.ItemAt(i);
		i++) {
		if (ignorePackages.find(package) != ignorePackages.end())
			continue;

		BString text;
		if (install) {
			text.SetToFormat("install package %s from repository %s\n",
				package->Info().FileName().String(),
				package->Repository()->Name().String());
		} else {
			text.SetToFormat("uninstall package %s\n",
				package->VersionedName().String());
		}

		BStringView* packageView = new BStringView(NULL, text);
		packagesGroup->AddView(packageView);
		packageView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

		packagesAdded = true;
	}

	return packagesAdded;
}
Example #7
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 #8
0
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags)
	: BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BStringView *titleView = new BStringView("title",
		B_TRANSLATE("Rich Text Format (RTF) translator"));
	titleView->SetFont(be_bold_font);


	char version[256];
	snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"),
		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_REVISION_VERSION(
			RTF_TRANSLATOR_VERSION)), __DATE__);
	BStringView *versionView = new BStringView("version", version);
	BStringView *copyrightView = new BStringView(
		"Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc.");
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(titleView)
		.Add(versionView)
		.Add(copyrightView)
		.AddGlue();
}
Example #9
0
ServiceView::ServiceView(const char* name, const char* executable,
	const char* title, const char* description, BNetworkSettings& settings)
	:
	BView("service", 0),
	fName(name),
	fExecutable(executable),
	fSettings(settings)
{
	BStringView* titleView = new BStringView("service", title);
	titleView->SetFont(be_bold_font);
	titleView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	BTextView* descriptionView = new BTextView("description");
	descriptionView->SetText(description);
	descriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	descriptionView->MakeEditable(false);

	fEnableButton = new BButton("toggler", B_TRANSLATE("Enable"),
		new BMessage(kMsgToggleService));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(titleView)
		.Add(descriptionView)
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fEnableButton);

	SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
	_UpdateEnableButton();

	fWasEnabled = IsEnabled();
}
Example #10
0
void 
Shelf::StartConfig(BView *view) 
{
	PRINT(("%p:%s()\n", this, __FUNCTION__));
	fInConfig = true;

	BStringView* titleString = new BStringView("Title",
		B_TRANSLATE("Shelf"));
	titleString->SetFont(be_bold_font);

	BStringView* copyrightString = new BStringView("Copyright",
		B_TRANSLATE("© 2012 François Revol."));

	BTextView* helpText = new BTextView("Help Text");
	helpText->MakeEditable(false);
	helpText->SetViewColor(view->ViewColor());
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	helpText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	BString help;
	help << B_TRANSLATE("Drop replicants on the full-screen window "
		"behind the preferences panel.");
	//help << "\n\n";
	//help << B_TRANSLATE("You can also drop colors.");
	helpText->SetText(help.String());

	BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_HALF_ITEM_SPACING)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(titleString)
		.Add(copyrightString)
		.AddStrut(roundf(be_control_look->DefaultItemSpacing() / 2))
		.Add(helpText)
		.AddGlue()
	.End();

	BScreen screen;
	fConfigWindow = new BWindow(screen.Frame(), "Shelf Config",
		B_UNTYPED_WINDOW, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
		| B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS);

	BView *shelfView = new BView(fConfigWindow->Bounds(), "ShelfView", 
		B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS);
	shelfView->SetViewColor(216, 216, 216, 0);

	fConfigWindow->AddChild(shelfView);

	fShelfData.Seek(SEEK_SET, 0LL);
	fShelf = new BShelf(&fShelfData, shelfView);
	fShelf->SetDisplaysZombies(true);
	fShelfData.Seek(SEEK_SET, 0LL);

	// start the Looper
	fConfigWindow->Show();

	fConfigWindow->Lock();
	fConfigWindow->SendBehind(view->Window());
	fConfigWindow->Unlock();

	//"\nDrop replicants on me!"
} 
Example #11
0
void Clock::StartConfig(BView *view)
{
	tview = new BStringView(BRect(10, 10, 200, 35), B_EMPTY_STRING, "Simple Clock");
	tview->SetFont(be_bold_font);
	tview->SetFontSize(15);
	view->AddChild(tview);
	view->AddChild(new BStringView(BRect(10, 40, 200, 65), B_EMPTY_STRING, " Ver 0.1, ©3dEyes**"));
}
void
MidiPlayerWindow::CreateViews()
{
	// Set up needed views
	scopeView = new ScopeView;

	showScope = new BCheckBox("showScope", B_TRANSLATE("Scope"),
		new BMessage(MSG_SHOW_SCOPE));
	showScope->SetValue(B_CONTROL_ON);

	CreateInputMenu();
	CreateReverbMenu();

	volumeSlider = new BSlider("volumeSlider", NULL, NULL, 0, 100,
		B_HORIZONTAL);
	rgb_color col = { 152, 152, 255 };
	volumeSlider->UseFillColor(true, &col);
	volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME));

	playButton = new BButton("playButton", B_TRANSLATE("Play"),
		new BMessage(MSG_PLAY_STOP));
	playButton->SetEnabled(false);

	BBox* divider = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
		B_FANCY_BORDER);
	divider->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, 1));

	BStringView* volumeLabel = new BStringView(NULL, B_TRANSLATE("Volume:"));
	volumeLabel->SetAlignment(B_ALIGN_LEFT);
	volumeLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

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

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
		.Add(scopeView)
		.Add(BGridLayoutBuilder(10, 10)
			.Add(BSpaceLayoutItem::CreateGlue(), 0, 0)
			.Add(showScope, 1, 0)

			.Add(reverbMenu->CreateLabelLayoutItem(), 0, 1)
			.Add(reverbMenu->CreateMenuBarLayoutItem(), 1, 1)

			.Add(inputMenu->CreateLabelLayoutItem(), 0, 2)
			.Add(inputMenu->CreateMenuBarLayoutItem(), 1, 2)

			.Add(volumeLabel, 0, 3)
			.Add(volumeSlider, 1, 3)
		)
		.AddGlue()
		.Add(divider)
		.AddGlue()
		.Add(playButton)
		.AddGlue()
		.SetInsets(5, 5, 5, 5)
	);
}
Example #13
0
void 
TSignatureView::AttachedToWindow()
{
	BRect	rect = Bounds();
	float	name_text_length = StringWidth(kNameText);
	float	sig_text_length = StringWidth(kSigText);
	float	divide_length;

	if (name_text_length > sig_text_length)
		divide_length = name_text_length;
	else
		divide_length = sig_text_length;

	rect.InsetBy(8,0);
	rect.top+= 8;
	
	fName = new TNameControl(rect, kNameText, new BMessage(NAME_FIELD));
	AddChild(fName);

	fName->SetDivider(divide_length + 10);
	fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	rect.OffsetBy(0,fName->Bounds().Height()+5);
	rect.bottom = rect.top + kSigHeight;
	rect.left = fName->TextView()->Frame().left;

	BRect text = rect;
	text.OffsetTo(10,0);
	fTextView = new TSigTextView(rect, text);
	BScrollView *scroller = new BScrollView("SigScroller", fTextView, B_FOLLOW_ALL, 0, false, true);
	AddChild(scroller);
	scroller->ResizeBy(-1 * scroller->ScrollBar(B_VERTICAL)->Frame().Width() - 9, 0);
	scroller->MoveBy(7,0);

	/* back up a bit to make room for the label */

	rect = scroller->Frame();
	BStringView *stringView = new BStringView(rect, "SigLabel", kSigText);
	AddChild(stringView);

	float tWidth, tHeight;
	stringView->GetPreferredSize(&tWidth, &tHeight);

	/* the 5 is for the spacer in the TextView */

	rect.OffsetBy(-1 *(tWidth) - 5, 0);
	rect.right = rect.left + tWidth;
	rect.bottom = rect.top + tHeight;

	stringView->MoveTo(rect.LeftTop());
	stringView->ResizeTo(rect.Width(), rect.Height());

	/* Resize the View to the correct height */
	scroller->SetResizingMode(B_FOLLOW_NONE);
	ResizeTo(Frame().Width(), scroller->Frame().bottom + 8);
	scroller->SetResizingMode(B_FOLLOW_ALL);
}
Example #14
0
BView*
AboutView::_CreateLabel(const char* name, const char* label)
{
	BStringView* labelView = new BStringView(name, label);
	labelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	labelView->SetFont(be_bold_font);
	return labelView;
}
Example #15
0
File: Box.cpp Project: D-os/BeFree
const char*
BBox::Label() const
{
	if (fLabelView == NULL) return NULL;

	BStringView *strView = cast_as(fLabelView, BStringView);
	if (strView == NULL) return NULL;

	return strView->Text();
}
void MainWindow::setupUi()
{
    BRect frame(100, 100, 500, 400);
    _win = new BWindow(frame, "Retrospring for BeOS", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
    frame.Set(10, 10, 11, 11);
    BStringView *label = new BStringView(frame, "rs_label", "Welcome to Retrospring!");
    label->ResizeToPreferred();
    _win->AddChild(label);
    _win->Show();
}
Example #17
0
BStringView*
InfoWin::_CreateInfo(const char* name)
{
	BStringView* view = new BStringView(name, "");
	view->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
	view->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	view->SetTruncation(B_TRUNCATE_SMART);

	return view;
}
Example #18
0
AskName::AskName():
	BWindow(BRect(100, 100, 500, 200), "Enter your name",
		B_TITLED_WINDOW,	
		B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
		| B_NOT_MINIMIZABLE),
	Text(NULL),
	text(NULL)
{
BView *back;
BButton * Accept;
BTextView *TV;
BStringView *str;


	const char *names[] =
	{
		"BeOS forever!",
		"BShisen Rules!",
		"Thanks Sheppy",
		"Say NO to drugs!",
		"Say NO to piracy!",
		"Say YES to BeOS!",
		"Just say \"BShisen\"",
		"Say YES to BShisen!",
	};

	back = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	back->SetViewColor(216, 216, 216);
	AddChild(back);
	
	str = new BStringView(BRect(10, 10, 390, 25), "",
		"Congratulations!  Enter your name for posterity.");
	
	str->SetFont(be_bold_font);
	back->AddChild(str);
	
	Accept = new BButton( BRect(10, 60+5, 90, 75+5), "Accept",
		"Accept", new BMessage(ACCEPT_BUTTON));
	Accept->MakeDefault(true);
	back->AddChild(Accept);

	Text = new BTextControl(BRect(10, 35, 390, 50), "",
		"Your Name", "", NULL);
	
	Text->SetDivider(Text->StringWidth("Your Name "));


	TV = Text->TextView();
	TV->SetMaxBytes(31);	

	Text->SetText(REGISTERED ? names[rand() % 8] : "I Want To Register!");

	back->AddChild(Text);
	Text->MakeFocus(true);
}
Example #19
0
InfoView::InfoView()
	:
	BGroupView(B_TRANSLATE("Information"), B_HORIZONTAL)
{
	BStringView* rendererView = new BStringView(NULL,
		(const char*)glGetString(GL_RENDERER));
	rendererView->SetExplicitAlignment(kLabelAlignment);
	rendererView->SetFont(be_bold_font);

	BStringView* vendorNameView = new BStringView(NULL,
		(const char*)glGetString(GL_VENDOR));
		vendorNameView->SetExplicitAlignment(kLabelAlignment);

	BStringView* glVersionView = new BStringView(NULL,
		(const char*)glGetString(GL_VERSION));
	glVersionView->SetExplicitAlignment(kLabelAlignment);

	BString apiString("GLU ");
	apiString << (const char*)gluGetString(GLU_VERSION);
	apiString << ", GLUT ";
	apiString << (int32)GLUT_API_VERSION;
	BStringView* apiVersionView = new BStringView(NULL, apiString.String());
	apiVersionView->SetExplicitAlignment(kLabelAlignment);

	BLayoutBuilder::Group<>(this)
		.AddGroup(B_VERTICAL, 0)
			.Add(rendererView)
			.Add(vendorNameView)
			.Add(glVersionView)
			.Add(apiVersionView)
			.End();
}
Example #20
0
status_t
PLabel::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BStringView *backend = (BStringView*)fView;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("Alignment") == 0)
		((EnumProperty*)prop)->SetValue(backend->Alignment());
	else if (str.ICompare("Text") == 0)
		((StringProperty*)prop)->SetValue(backend->Text());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::GetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}
Example #21
0
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));
}
Example #22
0
SetKeyWindow::SetKeyWindow(BPoint p, int32 i, BView *v) : BWindow(BRect(p.x,p.y,p.x,p.y),Language.get("SET_KEY_WINDOW"), B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
	, index(i), parent(v)
{
	BRect r(0,0,300,150);
	ResizeTo(r.Width(), r.Height());
	MoveBy(-r.Width()/2, -r.Height()/2);

	BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	r.InsetBy(8,8);
	r.bottom = r.top+19;
	BStringView *st;
	r.right = r.left + be_bold_font->StringWidth(Language.get("KEY_SETTINGS_FOR"));
	view->AddChild(st = new BStringView(r, NULL, Language.get("KEY_SETTINGS_FOR") ));
	st->SetFont(be_bold_font);
	r.left = r.right+8;
	r.right = Bounds().right-8;
	view->AddChild(new BStringView(r, NULL, Language.get(KeyBind.GetID(index)) ));
	
	// request the installed message
	key = KeyBind.GetKey( KeyBind.GetID(index) );
	key2 = KeyBind.GetKeyAlt( KeyBind.GetID(index) );
	mod = KeyBind.GetMod( KeyBind.GetID(index) );
	mod2 = KeyBind.GetModAlt( KeyBind.GetID(index) );
	message = KeyBind.GetMessage( KeyBind.GetID(index) );
	menu = KeyBind.IsMenuItem( KeyBind.GetID(index) );

	r.OffsetBy(0,30);
	r.left = 8;
	float x = 8 + MAX( be_plain_font->StringWidth(Language.get("PRIMARY")), be_plain_font->StringWidth(Language.get("ALTERNATE")));
	
	r.right = Bounds().right -96;
	view->AddChild(control1 = new KeyControl(r, Language.get("PRIMARY"), key, mod, menu));
	control1->SetDivider(x);
	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR1)) );
	r.OffsetBy(0,30);
	view->AddChild(control2 = new KeyControl(r, Language.get("ALTERNATE"), key2, mod2, false));
	control2->SetDivider(x);
	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR2)) );

	r = Bounds();
	r.InsetBy(8,8);
	r.top = r.bottom - 23;
	r.left = r.right - 80;
	view->AddChild(new BButton(r, NULL, Language.get("APPLY"), new BMessage(SET)) );
	r.OffsetBy(-(r.Width()+8), 0);
	view->AddChild(new BButton(r, NULL, Language.get("CANCEL"), new BMessage(B_QUIT_REQUESTED)) );

	AddChild(view);
	Run();
	Show();
}
Example #23
0
BStringView*
InfoWin::_CreateLabel(const char* name, const char* label)
{
	static const rgb_color kLabelColor = tint_color(
		ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT);

	BStringView* view = new BStringView(name, label);
	view->SetAlignment(B_ALIGN_RIGHT);
	view->SetHighColor(kLabelColor);

	return view;
}
Example #24
0
void
TeamDescriptionView::SetItem(TeamListItem* item)
{
	fItem = item;

	if (item == NULL) {
		int32 styleStart = 0;
		int32 styleEnd = 0;
		BString text;

		text.SetToFormat(fInfoString, fSeconds);
		fInfoTextView->SetText(text);
		if (fRebootRunner != NULL && fSeconds < 4) {
			styleStart = text.FindLast('\n');
			styleEnd = text.Length();
		}

		if (styleStart != styleEnd && fInfoTextView != NULL) {
			BFont font;
			fInfoTextView->GetFont(&font);
			font.SetFace(B_BOLD_FACE);
			fInfoTextView->SetStylable(true);
			fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
		}
	} else {
		fTeamName->SetText(item->Path()->Path());

		if (item->IsSystemServer()) {
			if (fSysComponent->IsHidden(fSysComponent))
				fSysComponent->Show();
		} else {
			if (!fSysComponent->IsHidden(fSysComponent))
				fSysComponent->Hide();
		}

		if (item->IsRefusingToQuit()) {
			if (fQuitOverdue->IsHidden(fQuitOverdue))
				fQuitOverdue->Show();
		} else {
			if (!fQuitOverdue->IsHidden(fQuitOverdue))
				fQuitOverdue->Hide();
		}

		fIconView->SetIcon(item->Path()->Path());
	}

	if (fLayout == NULL)
		return;

	if (item == NULL)
		fLayout->SetVisibleItem((int32)0);
	else
		fLayout->SetVisibleItem((int32)1);

	Invalidate();
}
Example #25
0
AlertView::AlertView(BRect frame, const char *name)
	: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
	// we will wait 12 seconds until we send a message
	fSeconds(12)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fBitmap = InitIcon();

	BRect rect(60, 8, 400, 36);
	BStringView *stringView = new BStringView(rect, NULL,
		"Do you wish to keep these settings?");
	stringView->SetFont(be_bold_font);
	stringView->ResizeToPreferred();
	AddChild(stringView);

	rect = stringView->Frame();
	rect.OffsetBy(0, rect.Height());
	fCountdownView = new BStringView(rect, "countdown", NULL);
	UpdateCountdownView();
	fCountdownView->ResizeToPreferred();
	AddChild(fCountdownView);

	BButton* keepButton = new BButton(rect, "keep", "Keep",
		new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	keepButton->ResizeToPreferred();
	AddChild(keepButton);

	BButton* button = new BButton(rect, "undo", "Undo",
		new BMessage(BUTTON_UNDO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	AddChild(button);

	// we're resizing ourselves to the right size
	// (but we're not implementing GetPreferredSize(), bad style!)
	float width = stringView->Frame().right;
	if (fCountdownView->Frame().right > width)
		width = fCountdownView->Frame().right;
	if (width < Bounds().Width())
		width = Bounds().Width();

	float height
		= fCountdownView->Frame().bottom + 24 + button->Bounds().Height();
	ResizeTo(width, height);

	keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(),
		Bounds().Height() - 8 - keepButton->Bounds().Height());
	button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8,
		keepButton->Frame().top);

	keepButton->MakeDefault(true);
}
Example #26
0
ConfigView::ConfigView(TranslatorSettings *settings)
	: BGroupView("ICNSTranslator Settings", B_VERTICAL, 0)
{
	fSettings = settings;

	BStringView *titleView = new BStringView("title", B_TRANSLATE("Apple icon translator"));
	titleView->SetFont(be_bold_font);

	char version[256];
	sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
		int(B_TRANSLATION_MAJOR_VERSION(ICNS_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(ICNS_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(ICNS_TRANSLATOR_VERSION)),
		__DATE__);

	BStringView *versionView = new BStringView("version", version);


	BStringView *copyrightView = new BStringView("copyright",
		B_UTF8_COPYRIGHT "2005-2006 Haiku Inc.");

	BStringView *copyright2View = new BStringView("my_copyright",
		B_UTF8_COPYRIGHT "2012 Gerasim Troeglazov <[email protected]>.");

	BStringView *infoView = new BStringView("support_sizes",
		B_TRANSLATE("Valid sizes: 16, 32, 48, 128, 256, 512, 1024"));

	BStringView *info2View  = new BStringView("support_colors",
		B_TRANSLATE("Valid colors: RGB32, RGBA32"));
	
	BStringView *copyright3View  = new BStringView("copyright3",
		"libicns v0.8.1\n");

	BStringView *copyright4View  = new BStringView("copyright4",
		"2001-2012 Mathew Eis <[email protected]>");

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(titleView)
		.Add(versionView)
		.Add(copyrightView)
		.Add(copyright2View)
		.AddGlue()
		.Add(infoView)
		.Add(info2View)
		.AddGlue()
		.Add(copyright3View)
		.Add(copyright4View);

	SetExplicitPreferredSize(GroupLayout()->MinSize());		
}
// This is used to provide a consistent look for the settings view for screen 
// savers without any configuration.
void
BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info)
{
	BRect rect(15, 15, 20, 20);
	BStringView* stringView = new BStringView(rect, "module", moduleName);
	stringView->SetFont(be_bold_font);
	stringView->ResizeToPreferred();
	view->AddChild(stringView);

	rect.OffsetBy(0, stringView->Bounds().Height() + 4);
	stringView = new BStringView(rect, "info", info);
	stringView->ResizeToPreferred();
	view->AddChild(stringView);
}
Example #28
0
BView *
LibraryWindow::AddHeader(BPoint location, const char *label)
{
	Lock();
	BRect r(location.x,location.y,location.x + 1, location.y + 1);
	BStringView *header = new BStringView(r,"header",label);
	fCheckList->AddChild(header);
	header->SetFont(be_bold_font);
	header->SetHighColor(0,0,255);
	header->ResizeToPreferred();
	Unlock();
	
	return header;
}
Example #29
0
status_t
PLabel::SetProperty(const char *name, PValue *value, const int32 &index)
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
		return B_READ_ONLY;
	
	BStringView *backend = (BStringView*)fView;
	
	BoolValue boolval;
	CharValue charval;
	ColorValue colorval;
	FloatValue floatval;
	IntValue intval;
	PointValue pointval;
	RectValue rectval;
	StringValue stringval;
	
	status_t status = prop->SetValue(value);
	if (status != B_OK)
		return status;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("Alignment") == 0)
	{
		prop->GetValue(&intval);
		backend->SetAlignment((alignment)*intval.value);
	}
	else if (str.ICompare("Text") == 0)
	{
		prop->GetValue(&stringval);
		backend->SetText(*stringval.value);
	}
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::SetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}
void
UninstallView::_InitView()
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fAppList = new BListView("pkg_list", B_SINGLE_SELECTION_LIST);
	fAppList->SetSelectionMessage(new BMessage(P_MSG_SELECT));
	BScrollView* scrollView = new BScrollView("list_scroll", fAppList,
		0, false, true, B_NO_BORDER);

	BStringView* descriptionLabel = new BStringView("desc_label",
		B_TRANSLATE("Package description"));
	descriptionLabel->SetFont(be_bold_font);

	fDescription = new BTextView("description", B_WILL_DRAW);
	fDescription->MakeSelectable(false);
	fDescription->MakeEditable(false);
	fDescription->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fDescription->SetText(fNoPackageSelectedString);

	fButton = new BButton("removal", B_TRANSLATE("Remove"),
		new BMessage(P_MSG_REMOVE));
	fButton->SetEnabled(false);

	const float spacing = be_control_look->DefaultItemSpacing();

	BGroupLayoutBuilder builder(GroupLayout());
	builder.Add(scrollView)
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_VERTICAL)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
				.Add(descriptionLabel)
				.AddGlue()
			)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
				.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
				.Add(fDescription)
			)
			.SetInsets(spacing, spacing, spacing, spacing)
		)
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_HORIZONTAL)
			.AddGlue()
			.Add(fButton)
			.SetInsets(spacing, spacing, spacing, spacing)
		)
	;
}