Ejemplo n.º 1
0
void
TabContainerView::_UpdateTabVisibility()
{
	float availableWidth = _AvailableWidthForTabs();
	if (availableWidth < 0)
		return;
	float visibleTabsWidth = 0;

	bool canScrollTabsLeft = fFirstVisibleTabIndex > 0;
	bool canScrollTabsRight = false;

	BGroupLayout* layout = GroupLayout();
	int32 count = layout->CountItems() - 1;
	for (int32 i = 0; i < count; i++) {
		TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
			layout->ItemAt(i));
		if (i < fFirstVisibleTabIndex)
			item->SetVisible(false);
		else {
			float itemWidth = item->MinSize().width;
			bool visible = availableWidth >= visibleTabsWidth + itemWidth;
			item->SetVisible(visible && !canScrollTabsRight);
			visibleTabsWidth += itemWidth;
			if (!visible)
				canScrollTabsRight = true;
		}
	}
	fController->UpdateTabScrollability(canScrollTabsLeft, canScrollTabsRight);
}
Ejemplo n.º 2
0
void
TabContainerView::Draw(BRect updateRect)
{
	// Stroke separator line at bottom.
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	BRect frame(Bounds());
	SetHighColor(tint_color(base, B_DARKEN_2_TINT));
	StrokeLine(frame.LeftBottom(), frame.RightBottom());
	frame.bottom--;

	// Draw empty area before first tab.
	uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER;
	BRect leftFrame(frame.left, frame.top, kLeftTabInset, frame.bottom);
	be_control_look->DrawInactiveTab(this, leftFrame, updateRect, base, 0,
		borders);

	// Draw all tabs, keeping track of where they end.
	BGroupLayout* layout = GroupLayout();
	int32 count = layout->CountItems() - 1;
	for (int32 i = 0; i < count; i++) {
		TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
			layout->ItemAt(i));
		if (!item || !item->IsVisible())
			continue;
		item->Parent()->Draw(updateRect);
		frame.left = item->Frame().right + 1;
	}

	// Draw empty area after last tab.
	be_control_look->DrawInactiveTab(this, frame, updateRect, base, 0, borders);
}
Ejemplo n.º 3
0
void
BTabView::_LayoutContainerView(bool layouted)
{
	float borderWidth = _BorderWidth();
	if (layouted) {
		float topBorderOffset;
		switch (fBorderStyle) {
			default:
			case B_FANCY_BORDER:
				topBorderOffset = 1.0f;
				break;
			case B_PLAIN_BORDER:
				topBorderOffset = 0.0f;
				break;
			case B_NO_BORDER:
				topBorderOffset = -1.0f;
				break;
		}
		BGroupLayout* layout = dynamic_cast<BGroupLayout*>(GetLayout());
		if (layout) {
			layout->SetInsets(borderWidth, borderWidth + TabHeight()
				- topBorderOffset, borderWidth, borderWidth);
		}
	} else {
		BRect bounds = Bounds();

		bounds.top += TabHeight();
		bounds.InsetBy(borderWidth, borderWidth);

		fContainerView->MoveTo(bounds.left, bounds.top);
		fContainerView->ResizeTo(bounds.Width(), bounds.Height());
	}
}
Ejemplo n.º 4
0
int32
TabContainerView::MaxFirstVisibleTabIndex() const
{
	float availableWidth = _AvailableWidthForTabs();
	if (availableWidth < 0)
		return 0;
	float visibleTabsWidth = 0;

	BGroupLayout* layout = GroupLayout();
	int32 i = layout->CountItems() - 2;
	for (; i >= 0; i--) {
		TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
			layout->ItemAt(i));
		if (item == NULL)
			continue;

		float itemWidth = item->MinSize().width;
		if (availableWidth >= visibleTabsWidth + itemWidth)
			visibleTabsWidth += itemWidth;
		else {
			// The tab before this tab is the last one that can be visible.
			return i + 1;
		}
	}

	return 0;
}
Ejemplo n.º 5
0
PreviewView::PreviewView(const char* name)
	:
	BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fSaverView(NULL),
	fNoPreview(NULL)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	// We draw the "monitor" around the preview, hence the strange insets.
	layout->SetInsets(7, 6, 8, 12);
	SetLayout(layout);

	// A BStringView would be enough, if only it handled word wrapping.
	fNoPreview = new BTextView("no preview");
	fNoPreview->SetText(B_TRANSLATE("No preview available"));
	fNoPreview->SetFontAndColor(be_plain_font, B_FONT_ALL, &kWhite);
	fNoPreview->MakeEditable(false);
	fNoPreview->MakeResizable(false);
	fNoPreview->MakeSelectable(false);
	fNoPreview->SetViewColor(0, 0, 0);
	fNoPreview->SetLowColor(0, 0, 0);

	fNoPreview->Hide();

	BView* container = new BView("preview container", 0);
	container->SetLayout(new BCardLayout());
	AddChild(container);
	container->SetViewColor(0, 0, 0);
	container->SetLowColor(0, 0, 0);
	container->AddChild(fNoPreview);

	fNoPreview->SetHighColor(255, 255, 255);
	fNoPreview->SetAlignment(B_ALIGN_CENTER);
}
Ejemplo n.º 6
0
	void _AddSpaces(BPartition* partition, PartitionView* parentView)
	{
		// add any available space on the partition
		BPartitioningInfo info;
		if (partition->GetPartitioningInfo(&info) >= B_OK) {
			off_t parentSize = partition->Size();
			off_t offset;
			off_t size;
			for (int32 i = 0;
					info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK;
					i++) {
				// TODO: remove again once Disk Device API is fixed
				if (!is_valid_partitionable_space(size))
					continue;
				//
				double scale = (double)size / parentSize;
				partition_id id
					= fSpaceIDMap.SpaceIDFor(partition->ID(), offset);
				PartitionView* view = new PartitionView(B_TRANSLATE("<empty>"),
					scale, offset, parentView->Level() + 1, id);

				fViewMap.Put(id, view);
				BGroupLayout* layout = parentView->GroupLayout();
				layout->AddView(_FindInsertIndex(view, layout), view, scale);
			}
		}
	}
Ejemplo n.º 7
0
	virtual void 	Visit(BStringContactField* field)
	{
		ContactFieldTextControl* control = new ContactFieldTextControl(field);
	//	BGridLayout* layout = fOwner->fInfoView->GridLayout();
		fOwner->GridLayout()->AddView(control, 0, fOwner->fControls.CountItems());

		BGroupLayout* controlLayout = (BGroupLayout*)control->GetLayout();
		controlLayout->AlignLayoutWith(fOwner->GridLayout(), B_VERTICAL);

		fOwner->fControls.AddItem(control);
	}
Ejemplo n.º 8
0
bool
TabContainerView::CanScrollRight() const
{
	BGroupLayout* layout = GroupLayout();
	int32 count = layout->CountItems() - 1;
	if (count > 0) {
		TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
			layout->ItemAt(count - 1));
		return !item->IsVisible();
	}
	return false;
}
Ejemplo n.º 9
0
CookieWindow::CookieWindow(BRect frame, BNetworkCookieJar& jar)
	:
	BWindow(frame, B_TRANSLATE("Cookie manager"), B_TITLED_WINDOW,
		B_NORMAL_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fCookieJar(jar)
{
	BGroupLayout* root = new BGroupLayout(B_HORIZONTAL, 0.0);
	SetLayout(root);

	fDomains = new BOutlineListView("domain list");
	root->AddView(new BScrollView("scroll", fDomains, 0, false, true), 1);

	fHeaderView = new BStringView("label",
		B_TRANSLATE("The cookie jar is empty!"));
	fCookies = new BColumnListView("cookie list", B_WILL_DRAW, B_FANCY_BORDER,
		false);

	int em = fCookies->StringWidth("M");
	int flagsLength = fCookies->StringWidth("Mhttps hostOnly" B_UTF8_ELLIPSIS);

	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Name"),
		20 * em, 10 * em, 50 * em, 0), 0);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Path"),
		10 * em, 10 * em, 50 * em, 0), 1);
	fCookies->AddColumn(new CookieDateColumn(B_TRANSLATE("Expiration"),
		fCookies->StringWidth("88/88/8888 88:88:88 AM")), 2);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Value"),
		20 * em, 10 * em, 50 * em, 0), 3);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Flags"),
		flagsLength, flagsLength, flagsLength, 0), 4);

	root->AddItem(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
		.SetInsets(5, 5, 5, 5)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fHeaderView)
			.AddGlue()
		.End()
		.Add(fCookies)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.SetInsets(5, 5, 5, 5)
#if 0
			.Add(new BButton("import", B_TRANSLATE("Import" B_UTF8_ELLIPSIS),
				NULL))
			.Add(new BButton("export", B_TRANSLATE("Export" B_UTF8_ELLIPSIS),
				NULL))
#endif
			.AddGlue()
			.Add(new BButton("delete", B_TRANSLATE("Delete"),
				new BMessage(COOKIE_DELETE))), 3);

	fDomains->SetSelectionMessage(new BMessage(DOMAIN_SELECTED));
}
Ejemplo n.º 10
0
NotificationView::NotificationView(NotificationWindow* win,
	BNotification* notification, bigtime_t timeout)
	:
	BView("NotificationView", B_WILL_DRAW),
	fParent(win),
	fNotification(notification),
	fTimeout(timeout),
	fRunner(NULL),
	fBitmap(NULL),
	fCloseClicked(false)
{
	if (fNotification->Icon() != NULL)
		fBitmap = new BBitmap(fNotification->Icon());

	if (fTimeout <= 0)
		fTimeout = fParent->Timeout() * 1000000;

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	SetLayout(layout);

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	switch (fNotification->Type()) {
		case B_IMPORTANT_NOTIFICATION:
			fStripeColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
			break;
		case B_ERROR_NOTIFICATION:
			fStripeColor = ui_color(B_FAILURE_COLOR);
			break;
		case B_PROGRESS_NOTIFICATION:
		{
			BStatusBar* progress = new BStatusBar("progress");
			progress->SetBarHeight(12.0f);
			progress->SetMaxValue(1.0f);
			progress->Update(fNotification->Progress());

			BString label = "";
			label << (int)(fNotification->Progress() * 100) << " %";
			progress->SetTrailingText(label);

			layout->AddView(progress);
		}
		// fall through.
		case B_INFORMATION_NOTIFICATION:
			fStripeColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
				B_DARKEN_1_TINT);
			break;
	}
}
/*!	
 *	\brief			Default constructor
 *	\param[in]	frame	The rectangle enclosing the view
 *	\param[in]	name	Name of the view. Will be passed to BView's constructor.
 *
 */
CalendarModulePreferencesView::CalendarModulePreferencesView( BRect frame )
	:
	BView( BRect( frame.left, frame.top, frame.right, frame.bottom-10 ), 
		 "Calendar Module Preferences",
		 B_FOLLOW_LEFT | B_FOLLOW_TOP,
		 B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS )
{
	BRect tempFrame = this->Bounds();	// Got the boundaries
	
	this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	tempFrame.InsetBySelf( 5, 5 );
	tempFrame.bottom -= 10;
	
	/* Add the chooser for the calendar modules */
	BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
	if ( !groupLayout ) {
		/* Panic! */
		exit( 1 );
	}
	groupLayout->SetSpacing( 2 );
	this->SetLayout( groupLayout );
	
	// Create the menu with all supported calendar modules
	calendarModules = PopulateModulesMenu();
	if ( ! calendarModules ) {
		/* Panic! */
		exit ( 1 );
	}
	
	calendarModuleSelector = new BMenuField( BRect( 0, 0, this->Bounds().Width() - 10, 1 ),
											 "Calendar Modules selector",
											 "Calendar module:",
											 calendarModules,
											 B_FOLLOW_H_CENTER | B_FOLLOW_TOP );
	if ( !calendarModuleSelector ) {
		/* Panic! */
		exit ( 1 );
	}
	
	calendarModuleSelector->ResizeToPreferred();
	
	// Add the menu with all calendar modules to the layout
	BLayoutItem* layoutItem = groupLayout->AddView( 0, calendarModuleSelector, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
	}
	
	// Relayout
	groupLayout->Relayout();
}	// <-- end of constructor for CalendarModulePreferencesView
Ejemplo n.º 12
0
ToolTipView::ToolTipView(BToolTip* tip)
	:
	BView("tool tip", B_WILL_DRAW | B_FRAME_EVENTS),
	fToolTip(tip),
	fHidden(false)
{
	fToolTip->AcquireReference();
	SetViewColor(ui_color(B_TOOL_TIP_BACKGROUND_COLOR));

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	layout->SetInsets(5, 5, 5, 5);
	SetLayout(layout);

	AddChild(fToolTip->View());
}
Ejemplo n.º 13
0
SpaceBarSettingsView::SpaceBarSettingsView()
	:
	SettingsView("SpaceBarSettingsView")
{
	fSpaceBarShowCheckBox = new BCheckBox("",
		B_TRANSLATE("Show space bars on volumes"),
		new BMessage(kUpdateVolumeSpaceBar));

	BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
	menu->SetFont(be_plain_font);

	BMenuItem* item;
	menu->AddItem(item = new BMenuItem(
		B_TRANSLATE("Used space color"),
		new BMessage(kSpaceBarSwitchColor)));
	item->SetMarked(true);
	fCurrentColor = 0;
	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Free space color"),
		new BMessage(kSpaceBarSwitchColor)));
	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Warning space color"),
		new BMessage(kSpaceBarSwitchColor)));

	BBox* box = new BBox("box");
	box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));

	fColorControl = new BColorControl(BPoint(8,
			fColorPicker->Bounds().Height() + 8 + kItemExtraSpacing),
		B_CELLS_16x16, 1, "SpaceColorControl",
		new BMessage(kSpaceBarColorChanged));
	fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
	box->AddChild(fColorControl);

	const float spacing = be_control_look->DefaultItemSpacing();

	BGroupLayout* layout = GroupLayout();
	layout->SetOrientation(B_VERTICAL);
	layout->SetSpacing(0);
	BGroupLayoutBuilder(layout)
		.Add(fSpaceBarShowCheckBox)
		.Add(box)
		.AddGlue()
		.SetInsets(spacing, spacing, spacing, spacing);

}
Ejemplo n.º 14
0
TabView*
TabContainerView::_TabAt(const BPoint& where) const
{
	BGroupLayout* layout = GroupLayout();
	int32 count = layout->CountItems() - 1;
	for (int32 i = 0; i < count; i++) {
		TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(layout->ItemAt(i));
		if (item == NULL || !item->IsVisible())
			continue;
		// Account for the fact that the tab frame does not contain the
		// visible bottom border.
		BRect frame = item->Frame();
		frame.bottom++;
		if (frame.Contains(where))
			return item->Parent();
	}
	return NULL;
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
NetworkView::NetworkView()
	:
	BView("NetworkView", 0, NULL)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));


	// build the GUI
	BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
	SetLayout(rootLayout);

	//BGridView* controlsGroup = new BGridView();
	//BGridLayout* layout = controlsGroup->GridLayout();

	// insets
	/*
	float inset = ceilf(be_plain_font->Size() * 0.7);
	rootLayout->SetInsets(inset, inset, inset, inset);
	rootLayout->SetSpacing(inset);
	layout->SetSpacing(inset, inset);
	*/
	// available network lists



	// button group
	BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL);

	fRefreshButton = new BButton(B_TRANSLATE("Refresh"),
		new BMessage(kMsgRefresh));
	fRefreshButton->SetEnabled(false);
	buttonGroup->GroupLayout()->AddView(fRefreshButton);

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

	fNewNetworkButton = new BButton(B_TRANSLATE("New Network"), new BMessage(kMsgNewNetwork));
	fNewNetworkButton->SetEnabled(false);
	buttonGroup->GroupLayout()->AddView(fNewNetworkButton);

	//rootLayout->AddView(controlsGroup);
	rootLayout->AddView(buttonGroup);
}
Ejemplo n.º 17
0
DiskView::DiskView(const BRect& frame, uint32 resizeMode,
		SpaceIDMap& spaceIDMap)
	:
	Inherited(frame, "diskview", resizeMode,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fDiskCount(0),
	fDisk(NULL),
	fSpaceIDMap(spaceIDMap),
	fPartitionLayout(new PartitionLayout(this, fSpaceIDMap))
{
	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset);
	SetLayout(layout);

	SetViewColor(B_TRANSPARENT_COLOR);
	SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_2_TINT);
	SetLowUIColor(B_PANEL_BACKGROUND_COLOR, 1.221f);

#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
	PartitionView* view;
	float scale = 1.0;
	view = new PartitionView("Disk", scale, 0, 0, -1);
	layout->AddView(view, scale);

	layout = view->GroupLayout();

	scale = 0.3;
	view = new PartitionView("Primary", scale, 1, 50, -1);
	layout->AddView(view, scale);
	scale = 0.7;
	view = new PartitionView("Extended", scale, 1, 100, -1);
	layout->AddView(view, scale);

	layout = view->GroupLayout();

	scale = 0.2;
	view = new PartitionView("Logical", scale, 2, 200, -1);
	layout->AddView(view, scale);

	scale = 0.5;
	view = new PartitionView("Logical", scale, 2, 250, -1);
	layout->AddView(view, scale);

	scale = 0.005;
	view = new PartitionView("Logical", scale, 2, 290, -1);
	layout->AddView(view, scale);

	scale = 0.295;
	view = new PartitionView("Logical", scale, 2, 420, -1);
	layout->AddView(view, scale);
#endif
}
Ejemplo n.º 18
0
VolumeWindow::VolumeWindow(BRect frame, bool dontBeep, int32 volumeWhich)
	: BWindow(frame, "VolumeWindow", B_BORDERED_WINDOW_LOOK,
		B_FLOATING_ALL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK
		| B_AUTO_UPDATE_SIZE_LIMITS, 0),
	fUpdatedCount(0)
{
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL);
	layout->SetInsets(5, 5, 5, 5);

	BBox* box = new BBox("sliderbox");
	box->SetLayout(layout);
	box->SetBorder(B_PLAIN_BORDER);
	AddChild(box);

	BSlider* slider = new VolumeControl(volumeWhich, !dontBeep,
		new BMessage(kMsgVolumeChanged));
	slider->SetModificationMessage(new BMessage(kMsgVolumeUpdate));
	box->AddChild(slider);

	slider->SetTarget(this);
	ResizeTo(300, 50);

	// Make sure it's not outside the screen.
	const int32 kMargin = 3;
	BRect windowRect = Frame();
	BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
	if (screenFrame.right < windowRect.right + kMargin)
		MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
	if (screenFrame.bottom < windowRect.bottom + kMargin)
		MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom);
	if (screenFrame.left > windowRect.left - kMargin)
		MoveBy(kMargin + screenFrame.left - windowRect.left, 0);
	if (screenFrame.top > windowRect.top - kMargin)
		MoveBy(0, kMargin + screenFrame.top - windowRect.top);
}
Ejemplo n.º 19
0
	virtual bool Visit(BPartition* partition, int32 level)
	{
		if (!partition->Parent()
			|| !fViewMap.ContainsKey(partition->Parent()->ID()))
			return false;

		// calculate size factor within parent frame
		off_t offset = partition->Offset();
//		off_t parentOffset = partition->Parent()->Offset();
		off_t size = partition->Size();
		off_t parentSize = partition->Parent()->Size();
		double scale = (double)size / parentSize;

		BString name = partition->ContentName();
		if (name.Length() == 0) {
			if (partition->CountChildren() > 0)
				name << partition->Type();
			else {
				char buffer[64];
				snprintf(buffer, 64, B_TRANSLATE("Partition %ld"),
					partition->ID());
				name << buffer;
			}
		}
		partition_id id = partition->ID();
		PartitionView* view = new PartitionView(name.String(), scale, offset,
			level, id);
		view->SetSelected(id == fSelectedPartition);
		PartitionView* parent = fViewMap.Get(partition->Parent()->ID());
		BGroupLayout* layout = parent->GroupLayout();
		layout->AddView(_FindInsertIndex(view, layout), view, scale);

		fViewMap.Put(partition->ID(), view);
		_AddSpaces(partition, view);

		return false;
	}
Ejemplo n.º 20
0
void
add_status_bars(BGridLayout* layout, int32& row)
{
	BBox* box = new BBox(B_FANCY_BORDER, NULL);
	box->SetLabel("Info");

	BGroupLayout* boxLayout = new BGroupLayout(B_VERTICAL, kInset);
	boxLayout->SetInsets(kInset, kInset + box->TopBorderOffset(), kInset,
		kInset);
	box->SetLayout(boxLayout);

	BStatusBar* statusBar = new BStatusBar("status bar", "Status",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(0);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	statusBar = new BStatusBar("status bar", "Progress",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(40);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	statusBar = new BStatusBar("status bar", "Lifespan of capitalism",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(100);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	layout->AddView(box, 0, row, 4);

	row++;
}
/*!	\brief			Clears interface of previously selected Calendar Module prefs
 *	\details		Used in destructor and in move from one Calendar Module to another.
 */
void 			CalendarModulePreferencesView::ClearOldInterface()
{
	BGroupLayout* layout = ( BGroupLayout* )( BView::GetLayout() );
	BBox*		 tempBBox = NULL;
	BMenuField*	 tempMenuField = NULL;

	// Clean up old interface items if they existed
	if ( ( tempBBox = ( BBox* )this->FindView( "Weekend selector" ) ) != NULL )
	{
		layout->RemoveView( tempBBox );
		tempBBox->RemoveSelf();
		delete tempBBox;
	}
	
	if ( ( tempBBox = ( BBox* )this->FindView( "Color selector" ) ) != NULL )
	{
		layout->RemoveView( tempBBox );
		tempBBox->RemoveSelf();
		delete tempBBox;
	}
	
	if ( ( tempMenuField = ( BMenuField* )this->FindView( "First day of week chooser" ) ) != NULL )
	{
		layout->RemoveView( tempMenuField );
		tempMenuField->RemoveSelf();
		delete tempMenuField;
	}
	
	if ( ( tempMenuField = ( BMenuField* )this->FindView( "Day-Month-Year order chooser" ) ) != NULL )
	{
		layout->RemoveView( tempMenuField );
		tempMenuField->RemoveSelf();
		delete tempMenuField;
	}
	
}	// <-- end of function CalendarModulePreferencesView::ClearOldInterface()
Ejemplo n.º 22
0
TrashSettingsView::TrashSettingsView()
	:
	SettingsView("TrashSettingsView")
{
	fDontMoveFilesToTrashCheckBox = new BCheckBox("",
		B_TRANSLATE("Don't move files to Trash"),
			new BMessage(kDontMoveFilesToTrashChanged));

	fAskBeforeDeleteFileCheckBox = new BCheckBox("",
		B_TRANSLATE("Ask before delete"),
			new BMessage(kAskBeforeDeleteFileChanged));

	const float spacing = be_control_look->DefaultItemSpacing();

	BGroupLayout* layout = GroupLayout();
	layout->SetOrientation(B_VERTICAL);
	layout->SetSpacing(0);
	BGroupLayoutBuilder(layout)
		.Add(fDontMoveFilesToTrashCheckBox)
		.Add(fAskBeforeDeleteFileCheckBox)
		.AddGlue()
		.SetInsets(spacing, spacing, spacing, spacing);

}
Ejemplo n.º 23
0
SettingsView::SettingsView(Core* core)
	:
	BView("SettingsView", B_WILL_DRAW, 0),
	fCore(core)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// Engines entry
	BBox* audioBox = new BBox("audiobox");
	audioBox->SetLabel("Engines");

	BGroupLayout* audioLayout = new BGroupLayout(B_VERTICAL);
	audioLayout->SetInsets(10, audioBox->TopBorderOffset() * 2 + 10, 10, 10);
	audioBox->SetLayout(audioLayout);

	fEngines[0] = new BRadioButton("sine", "Sine",
		_ButtonMsg(CRONO_SINE_ENGINE));
	audioLayout->AddView(fEngines[0]);

	fEngines[1] = new BRadioButton("triangle", "Triangle",
		_ButtonMsg(CRONO_TRIANGLE_ENGINE));
	audioLayout->AddView(fEngines[1]);

	fEngines[2] = new BRadioButton("sawtooth", "Sawtooth",
		_ButtonMsg(CRONO_SAWTOOTH_ENGINE));
	audioLayout->AddView(fEngines[2]);

	fEngines[3] = new BRadioButton("file", "File Engine",
		_ButtonMsg(CRONO_FILE_ENGINE));
	audioLayout->AddView(fEngines[3]);

	fSoundEntry = new BTextControl("Soundfile", "Soundfile",
		gCronoSettings.SoundFileLocation, new BMessage(MSG_SET), B_WILL_DRAW);
	fSoundEntry->SetDivider(70);
	fSoundEntry->SetAlignment(B_ALIGN_CENTER, B_ALIGN_CENTER);
	audioLayout->AddView(fSoundEntry);
	fSoundEntry->SetEnabled(false);

	fDefaultsButton = new BButton("Defaults", new BMessage(MSG_DEFAULTS));

	BLayoutBuilder::Group<>(this, B_VERTICAL, 5)
		.AddGroup(B_VERTICAL)
			.Add(audioBox, 0)
		.End()
		.AddGroup(B_HORIZONTAL)
			.Add(fDefaultsButton, 0)
		.End();

	_SetEngine(fCore->Engine());
}
Ejemplo n.º 24
0
void
GroupListView::SetModel(GroupListModel* model)
{
	// TODO: remove all previous
	// TODO: add change mechanism
	// TODO: use a "virtual" BGroupLayout (ie. one that create its layout items
	//		on the fly).
	fModel = model;

	std::map<addr_t, BGroupLayout*> groupMap;

	int32 groupCount = model->CountGroups();
	for (int groupIndex = 0; groupIndex < groupCount; groupIndex++) {
		BGroupLayout* groupItem = new BGroupLayout(B_VERTICAL, 0);
		groupItem->SetVisible(false);
		AddChild(groupItem);

		void* group = model->GroupAt(groupIndex);
		groupMap[(addr_t)group] = groupItem;
		groupItem->AddItem(new RendererLayoutItem(this, groupIndex, group,
			fGroupRenderer));
	}

	int32 itemCount = model->CountItems();
	for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) {
		void* group = model->GroupForItemAt(itemIndex);
		if (group == NULL)
			continue;

		BGroupLayout* groupItem = groupMap[(addr_t)group];
		if (groupItem == NULL)
			continue;

		groupItem->SetVisible(true);

		RendererLayoutItem* rendererItem = new RendererLayoutItem(this,
			itemIndex, model->ItemAt(itemIndex), fItemRenderer);
		groupItem->AddItem(rendererItem);
	}
}
Ejemplo n.º 25
0
CronoView::CronoView()
	:
	BView("CronoView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fAccentsList(false)
{
    fReplicated = false;

	// Core
	fCore = new Core();

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	rgb_color barColor = { 0, 200, 0 };
	rgb_color fillColor = { 240, 240, 240 };


	_BuildMenu();

	// Volume slider
	BBox* volBox = new BBox("volbox");
	volBox->SetLabel("Volume");

	BGroupLayout* volLayout = new BGroupLayout(B_VERTICAL);
	volLayout->SetInsets(10, volBox->TopBorderOffset() * 2 + 10, 10, 10);
	volBox->SetLayout(volLayout);
	
	fVolumeSlider = new VolumeSlider("",
		0, 1000, DEFAULT_VOLUME, new BMessage(MSG_VOLUME));

	fVolumeSlider->SetLimitLabels("Min", "Max");
	fVolumeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fVolumeSlider->SetHashMarkCount(20);
	fVolumeSlider->SetValue((int32)fCore->Volume()*10);
	fVolumeSlider->UseFillColor(true, &fillColor);
	fVolumeSlider->SetPosition(gCronoSettings.CronoVolume);
	fVolumeSlider->SetLabel(BString() << gCronoSettings.CronoVolume);
	volLayout->AddView(fVolumeSlider);

	// Speed Slider & TextControl
	BBox* speedBox = new BBox("speedbox");
	speedBox->SetLabel("BPM");
	BGroupLayout* speedLayout = new BGroupLayout(B_HORIZONTAL);
	speedLayout->SetInsets(10, speedBox->TopBorderOffset() * 2 + 10, 10, 10);
	speedBox->SetLayout(speedLayout);

	fSpeedSlider = new VolumeSlider("",
		MIN_SPEED, MAX_SPEED, DEFAULT_SPEED, new BMessage(MSG_SPEED_SLIDER));

	fSpeedSlider->SetLimitLabels(BString() << MIN_SPEED,
		BString() << MAX_SPEED);

	fSpeedSlider->SetKeyIncrementValue(5);
	fSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fSpeedSlider->SetHashMarkCount(15);
	fSpeedSlider->SetValue(fCore->Speed());
	fSpeedSlider->UseFillColor(true, &fillColor);
	_UpdateTempoName(gCronoSettings.Speed);

	fSpeedEntry = new BTextControl("", "", BString() << gCronoSettings.Speed,
		new BMessage(MSG_SPEED_ENTRY), B_WILL_DRAW);

	fSpeedEntry->SetDivider(70);
	fSpeedEntry->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
	fSpeedEntry->SetExplicitSize(BSize(35, 20));

	speedLayout->AddView(fSpeedSlider);
	speedLayout->AddView(fSpeedEntry);

	// Meter buttons
	BBox* tempoBox = new BBox("tempoBox");
	tempoBox->SetLabel("Tempo");

	for(int i = 0; i < 5; i++)
		fTempoRadios[i] = new BRadioButton("", "",
			new BMessage(MSG_METER_RADIO));

	fTempoRadios[0]->SetLabel("1/4");
	fTempoRadios[1]->SetLabel("2/4");
	fTempoRadios[2]->SetLabel("3/4");
	fTempoRadios[3]->SetLabel("4/4");
	fTempoRadios[4]->SetLabel("Other");

	fTempoRadios[fCore->Meter()]->SetValue(1);

	fTempoEntry = new BTextControl("", "", "4",
		new BMessage(MSG_METER_ENTRY), B_WILL_DRAW);

	fTempoEntry->SetDivider(70);

	if (fTempoRadios[4]->Value() == 1)
		fTempoEntry->SetEnabled(true);
	else
		fTempoEntry->SetEnabled(false);		

	fAccentsView = new BGroupView(B_HORIZONTAL, 0);

	BLayoutBuilder::Group<>(tempoBox, B_VERTICAL, 0)
		.SetInsets(10, tempoBox->TopBorderOffset() * 2 + 10, 10, 10)
		.AddGroup(B_HORIZONTAL, 0)
			.Add(fTempoRadios[0])
			.Add(fTempoRadios[1])
			.Add(fTempoRadios[2])
			.Add(fTempoRadios[3])
			.Add(fTempoRadios[4])
			.Add(fTempoEntry)
			.AddGlue()
		.End()
		.Add(fAccentsView)
		.AddGlue()
	.End();

	if (gCronoSettings.AccentTable == true)
		_ShowTable(true);

	fStartButton = new BButton("Start", new BMessage(MSG_START));						
	fStartButton->MakeDefault(true);	
	fStopButton = new BButton("Stop", new BMessage(MSG_STOP));							

#ifdef CRONO_REPLICANT_ACTIVE
	// Dragger
	BRect frame(Bounds());
	frame.left = frame.right - 7;
	frame.top = frame.bottom - 7;
	BDragger *dragger = new BDragger(frame, this,
		B_FOLLOW_RIGHT | B_FOLLOW_TOP); 
#endif

	// Create view
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.Add(fMenuBar)
		.Add(volBox)
		.Add(speedBox)
		.Add(tempoBox)
		.AddGroup(B_HORIZONTAL)
			.Add(fStartButton)
			.Add(fStopButton)
		.End()
#ifdef CRONO_REPLICANT_ACTIVE
		.Add(dragger)
#endif
		.End();
}
Ejemplo n.º 26
0
SettingsWindow::SettingsWindow(BRect frame)
 	:
 	BWindow(frame, B_TRANSLATE("MediaPlayer settings"), B_FLOATING_WINDOW_LOOK,
 		B_FLOATING_ALL_WINDOW_FEEL,
 		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
 			| B_AUTO_UPDATE_SIZE_LIMITS)
{
	const float kSpacing = be_control_look->DefaultItemSpacing();

	BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 2);
	settingsBox->SetLayout(settingsLayout);
	BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 2);
	buttonBox->SetLayout(buttonLayout);

	BStringView* playModeLabel = new BStringView("stringViewPlayMode",
		B_TRANSLATE("Play mode"));
	BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions",
		B_TRANSLATE("View options"));
	BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg",
		B_TRANSLATE("Volume of background clips"));
	BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
	playModeLabel->SetExplicitAlignment(alignment);
	playModeLabel->SetFont(be_bold_font);
	viewOptionsLabel->SetExplicitAlignment(alignment);
	viewOptionsLabel->SetFont(be_bold_font);
	bgMoviesModeLabel->SetExplicitAlignment(alignment);
	bgMoviesModeLabel->SetFont(be_bold_font);

	fAutostartCB = new BCheckBox("chkboxAutostart",
		B_TRANSLATE("Automatically start playing"),
		new BMessage(M_SETTINGS_CHANGED));

	fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies",
		B_TRANSLATE("Close window after playing video"),
		new BMessage(M_SETTINGS_CHANGED));
	fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds",
		B_TRANSLATE("Close window after playing audio"),
		new BMessage(M_SETTINGS_CHANGED));

	fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
		B_TRANSLATE("Loop video"),
		new BMessage(M_SETTINGS_CHANGED));
	fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
		B_TRANSLATE("Loop audio"),
		new BMessage(M_SETTINGS_CHANGED));

	fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
		B_TRANSLATE("Use hardware video overlays if available"),
		new BMessage(M_SETTINGS_CHANGED));
	fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
		B_TRANSLATE("Scale movies smoothly (non-overlay mode)"),
		new BMessage(M_SETTINGS_CHANGED));

	fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls",
		B_TRANSLATE("Scale controls in full screen mode"),
		new BMessage(M_SETTINGS_CHANGED));

	fSubtitleSizeOP = new BOptionPopUp("subtitleSize",
		B_TRANSLATE("Subtitle size:"), new BMessage(M_SETTINGS_CHANGED));
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Small"), mpSettings::SUBTITLE_SIZE_SMALL);
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Medium"), mpSettings::SUBTITLE_SIZE_MEDIUM);
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Large"), mpSettings::SUBTITLE_SIZE_LARGE);

	fSubtitlePlacementOP = new BOptionPopUp("subtitlePlacement",
		B_TRANSLATE("Subtitle placement:"), new BMessage(M_SETTINGS_CHANGED));
	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of video"),
		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO);
	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of screen"),
		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN);

	fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		B_TRANSLATE("Full volume"), new BMessage(M_SETTINGS_CHANGED));

	fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume",
		B_TRANSLATE("Low volume"), new BMessage(M_SETTINGS_CHANGED));

	fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		B_TRANSLATE("Muted"), new BMessage(M_SETTINGS_CHANGED));

	fRevertB = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(M_SETTINGS_REVERT));

	BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
		new BMessage(M_SETTINGS_CANCEL));

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

	// Build the layout
	BGroupLayout* volumeGroup;
	BGroupLayout* startGroup;
	BGroupLayout* playGroup;
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddGroup(settingsLayout)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
				B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
			.Add(playModeLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.GetLayout(&playGroup)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.GetLayout(&startGroup)
					.Add(fAutostartCB)
					.AddGrid(kSpacing, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 0)
						.Add(fCloseWindowMoviesCB, 1, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 1)
						.Add(fCloseWindowSoundsCB, 1, 1)
					.End()
					.Add(fLoopMoviesCB)
					.Add(fLoopSoundsCB)
				.End()
			.End()
			.AddStrut(kSpacing)

			.Add(viewOptionsLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.Add(fUseOverlaysCB)
					.Add(fScaleBilinearCB)
					.Add(fScaleFullscreenControlsCB)
					.Add(fSubtitleSizeOP)
					.Add(fSubtitlePlacementOP)
				.End()
			.End()
			.AddStrut(kSpacing)

			.Add(bgMoviesModeLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.GetLayout(&volumeGroup)
					.Add(fFullVolumeBGMoviesRB)
					.Add(fHalfVolumeBGMoviesRB)
					.Add(fMutedVolumeBGMoviesRB)
				.End()
			.End()
			.AddStrut(kSpacing)
		.End()
		.AddGroup(buttonLayout)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
			.Add(fRevertB)
			.AddGlue()
			.Add(cancelButton)
			.Add(okButton);

	startGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	playGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	volumeGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
}
Ejemplo n.º 27
0
ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
	:
	BWindow(BRect(100, 150, 500, 500), "Extended battery info", B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT |
		B_ASYNCHRONOUS_CONTROLS),
	fDriverInterface(interface),
	fSelectedView(NULL)
{
	fDriverInterface->AcquireReference();

	BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(view);

	BGroupLayout* mainLayout = new BGroupLayout(B_VERTICAL);
	mainLayout->SetSpacing(10);
	mainLayout->SetInsets(10, 10, 10, 10);
	view->SetLayout(mainLayout);

	BRect rect = Bounds();
	rect.InsetBy(5, 5);
	BBox *infoBox = new BBox(rect, "Power status box");
	infoBox->SetLabel("Battery info");
	BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL);
	infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10);
	infoLayout->SetSpacing(10);
	infoBox->SetLayout(infoLayout);
	mainLayout->AddView(infoBox);

	BGroupView* batteryView = new BGroupView(B_VERTICAL);
	batteryView->GroupLayout()->SetSpacing(10);
	infoLayout->AddView(batteryView);

	// create before the battery views
	fBatteryInfoView = new BatteryInfoView();

	BGroupLayout* batteryLayout = batteryView->GroupLayout();
	BRect batteryRect(0, 0, 50, 30);
	for (int i = 0; i < interface->GetBatteryCount(); i++) {
		ExtPowerStatusView* view = new ExtPowerStatusView(interface,
			batteryRect, B_FOLLOW_NONE, i, this);
		view->SetExplicitMaxSize(BSize(70, 80));
		view->SetExplicitMinSize(BSize(70, 80));

		batteryLayout->AddView(view);
		fBatteryViewList.AddItem(view);
		fDriverInterface->StartWatching(view);
		if (!view->IsCritical())
			fSelectedView = view;
	}

	batteryLayout->AddItem(BSpaceLayoutItem::CreateGlue());

	infoLayout->AddView(fBatteryInfoView);

	if (!fSelectedView && fBatteryViewList.CountItems() > 0)
		fSelectedView = fBatteryViewList.ItemAt(0);
	fSelectedView->Select();

	BSize size = mainLayout->PreferredSize();
	ResizeTo(size.width, size.height);
}
Ejemplo n.º 28
0
	KeyRequestView()
		:
		BView("KeyRequestView", B_WILL_DRAW),
		fPassword(NULL)
	{
		SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

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

		SetLayout(rootLayout);

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

		BGridLayout* layout = controls->GridLayout();

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

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

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

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

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

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

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

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

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

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

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

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

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

		rootLayout->AddView(message);
		rootLayout->AddView(controls);
		rootLayout->AddView(buttons);
	}
Ejemplo n.º 29
0
void
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
	off_t size)
{
	// Setup the controls
	fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset,
		offset + size);
	fSizeSlider->SetPosition(1.0);

	fNameTextControl = new BTextControl("Name Control", TR("Partition name:"),
		"", NULL);
	if (!parent->SupportsChildName())
		fNameTextControl->SetEnabled(false);

	fTypePopUpMenu = new BPopUpMenu("Partition Type");

	int32 cookie = 0;
	BString supportedType;
	while (parent->GetNextSupportedChildType(&cookie, &supportedType)
			== B_OK) {
		BMessage* message = new BMessage(MSG_PARTITION_TYPE);
		message->AddString("type", supportedType);
		BMenuItem* item = new BMenuItem(supportedType, message);
		fTypePopUpMenu->AddItem(item);

		if (strcmp(supportedType, kPartitionTypeBFS) == 0)
			item->SetMarked(true);
	}

	fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu,
		NULL);

	const float spacing = be_control_look->DefaultItemSpacing();
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
	layout->SetInsets(spacing, spacing, spacing, spacing);

	SetLayout(layout);

	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fSizeSlider)
		.Add(BGridLayoutBuilder(0.0, 5.0)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
			.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
		)
	);

	parent->GetChildCreationParameterEditor(NULL, &fEditor);
	if (fEditor)
		AddChild(fEditor->View());

	BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK));
	AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
		.AddGlue()
		.Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
		.Add(okButton)
	);
	SetDefaultButton(okButton);

	AddToSubset(fWindow);
	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
Ejemplo n.º 30
0
void
MainWindow::_CreateGUI()
{
    SetLayout(new BGroupLayout(B_HORIZONTAL));

    BGridLayout* layout = new BGridLayout();
    layout->SetSpacing(0, 0);
    BView* rootView = new BView("root view", 0, layout);
    AddChild(rootView);
    rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    BGroupView* leftTopView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftTopView, 0, 0);

    // views along the left side
    leftTopView->AddChild(_CreateMenuBar());

    float splitWidth = 13 * be_plain_font->Size();
    BSize minSize = leftTopView->MinSize();
    splitWidth = std::max(splitWidth, minSize.width);
    leftTopView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));
    leftTopView->SetExplicitMinSize(BSize(splitWidth, B_SIZE_UNSET));

    BGroupView* iconPreviews = new BGroupView(B_HORIZONTAL);
    iconPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    iconPreviews->GroupLayout()->SetSpacing(5);

    // icon previews
    fIconPreview16Folder = new IconView(BRect(0, 0, 15, 15),
                                        "icon preview 16 folder");
    fIconPreview16Menu = new IconView(BRect(0, 0, 15, 15),
                                      "icon preview 16 menu");
    fIconPreview16Menu->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));

    fIconPreview32Folder = new IconView(BRect(0, 0, 31, 31),
                                        "icon preview 32 folder");
    fIconPreview32Desktop = new IconView(BRect(0, 0, 31, 31),
                                         "icon preview 32 desktop");
    fIconPreview32Desktop->SetLowColor(ui_color(B_DESKTOP_COLOR));

    fIconPreview64 = new IconView(BRect(0, 0, 63, 63), "icon preview 64");
    fIconPreview64->SetLowColor(ui_color(B_DESKTOP_COLOR));


    BGroupView* smallPreviews = new BGroupView(B_VERTICAL);
    smallPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    smallPreviews->GroupLayout()->SetSpacing(5);

    smallPreviews->AddChild(fIconPreview16Folder);
    smallPreviews->AddChild(fIconPreview16Menu);

    BGroupView* mediumPreviews = new BGroupView(B_VERTICAL);
    mediumPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    mediumPreviews->GroupLayout()->SetSpacing(5);

    mediumPreviews->AddChild(fIconPreview32Folder);
    mediumPreviews->AddChild(fIconPreview32Desktop);

//	iconPreviews->AddChild(fIconPreview48);

    iconPreviews->AddChild(smallPreviews);
    iconPreviews->AddChild(mediumPreviews);
    iconPreviews->AddChild(fIconPreview64);
    iconPreviews->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));

    leftTopView->AddChild(iconPreviews);


    BGroupView* leftSideView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftSideView, 0, 1);
    leftSideView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));

    // path menu and list view
    BMenuBar* menuBar = new BMenuBar("path menu bar");
    menuBar->AddItem(fPathMenu);
    leftSideView->AddChild(menuBar);

    fPathListView = new PathListView(BRect(0, 0, splitWidth, 100),
                                     "path list view", new BMessage(MSG_PATH_SELECTED), this);

    BView* scrollView = new BScrollView("path list scroll view",
                                        fPathListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // shape list view
    menuBar = new BMenuBar("shape menu bar");
    menuBar->AddItem(fShapeMenu);
    leftSideView->AddChild(menuBar);

    fShapeListView = new ShapeListView(BRect(0, 0, splitWidth, 100),
                                       "shape list view", new BMessage(MSG_SHAPE_SELECTED), this);
    scrollView = new BScrollView("shape list scroll view",
                                 fShapeListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // transformer list view
    menuBar = new BMenuBar("transformer menu bar");
    menuBar->AddItem(fTransformerMenu);
    leftSideView->AddChild(menuBar);

    fTransformerListView = new TransformerListView(BRect(0, 0, splitWidth, 100),
            "transformer list view");
    scrollView = new BScrollView("transformer list scroll view",
                                 fTransformerListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // property list view
    menuBar = new BMenuBar("property menu bar");
    menuBar->AddItem(fPropertyMenu);
    leftSideView->AddChild(menuBar);

    fPropertyListView = new IconObjectListView();

    // scroll view around property list view
    ScrollView* propScrollView = new ScrollView(fPropertyListView,
            SCROLL_VERTICAL, BRect(0, 0, splitWidth, 100), "property scroll view",
            B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER,
            BORDER_RIGHT);
    leftSideView->AddChild(propScrollView);

    BGroupLayout* topSide = new BGroupLayout(B_HORIZONTAL);
    topSide->SetSpacing(0);
    BView* topSideView = new BView("top side view", 0, topSide);
    layout->AddView(topSideView, 1, 0);

    // canvas view
    BRect canvasBounds = BRect(0, 0, 200, 200);
    fCanvasView = new CanvasView(canvasBounds);

    // scroll view around canvas view
    canvasBounds.bottom += B_H_SCROLL_BAR_HEIGHT;
    canvasBounds.right += B_V_SCROLL_BAR_WIDTH;
    ScrollView* canvasScrollView = new ScrollView(fCanvasView, SCROLL_VERTICAL
            | SCROLL_HORIZONTAL | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS,
            canvasBounds, "canvas scroll view", B_FOLLOW_NONE,
            B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER);
    layout->AddView(canvasScrollView, 1, 1);

    // views along the top

    BGroupLayout* styleGroup = new BGroupLayout(B_VERTICAL, 0);
    BView* styleGroupView = new BView("style group", 0, styleGroup);
    topSide->AddView(styleGroupView);

    // style list view
    menuBar = new BMenuBar("style menu bar");
    menuBar->AddItem(fStyleMenu);
    styleGroup->AddView(menuBar);

    fStyleListView = new StyleListView(BRect(0, 0, splitWidth, 100),
                                       "style list view", new BMessage(MSG_STYLE_SELECTED), this);
    scrollView = new BScrollView("style list scroll view", fStyleListView,
                                 B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    scrollView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNLIMITED));
    styleGroup->AddView(scrollView);

    // style view
    fStyleView = new StyleView(BRect(0, 0, 200, 100));
    topSide->AddView(fStyleView);

    // swatch group
    BGroupLayout* swatchGroup = new BGroupLayout(B_VERTICAL);
    swatchGroup->SetSpacing(0);
    BView* swatchGroupView = new BView("swatch group", 0, swatchGroup);
    topSide->AddView(swatchGroupView);

    menuBar = new BMenuBar("swatches menu bar");
    menuBar->AddItem(fSwatchMenu);
    swatchGroup->AddView(menuBar);

    fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100));
    swatchGroup->AddView(fSwatchGroup);

    swatchGroupView->SetExplicitMaxSize(swatchGroupView->MinSize());

    // make sure the top side has fixed height
    topSideView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                                          swatchGroupView->MinSize().height));
}