コード例 #1
0
void
TabContainerView::AddTab(TabView* tab, int32 index)
{
	tab->SetContainerView(this);

	if (index == -1)
		index = GroupLayout()->CountItems() - 1;

	bool hasFrames = fController != NULL && fController->HasFrames();
	bool isFirst = index == 0 && hasFrames;
	bool isLast = index == GroupLayout()->CountItems() - 1 && hasFrames;
	bool isFront = fSelectedTab == NULL;
	tab->Update(isFirst, isLast, isFront);

	GroupLayout()->AddItem(index, tab->LayoutItem());

	if (isFront)
		SelectTab(tab);
	if (isLast) {
		TabLayoutItem* item
			= dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
		if (item)
			item->Parent()->SetIsLast(false);
	}

	SetFirstVisibleTabIndex(MaxFirstVisibleTabIndex());
	_ValidateTabVisibility();
}
コード例 #2
0
URLInputGroup::URLInputGroup(BMessage* goMessage)
	:
	BGroupView(B_HORIZONTAL, 0.0),
	fWindowActive(false)
{
	GroupLayout()->SetInsets(2, 2, 2, 2);

	fIconView = new PageIconView();
	GroupLayout()->AddView(fIconView, 0.0f);

	fTextView = new URLTextView(this);
	AddChild(fTextView);

	AddChild(new BSeparatorView(B_VERTICAL, B_PLAIN_BORDER));

// TODO: Fix in Haiku, no in-built support for archived BBitmaps from
// resources?
//	fGoButton = new BitmapButton("kActionGo", NULL);
	fGoButton = new BitmapButton(kGoBitmapBits, kGoBitmapWidth,
		kGoBitmapHeight, kGoBitmapFormat, goMessage);
	GroupLayout()->AddView(fGoButton, 0.0f);

	SetFlags(Flags() | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	SetLowColor(ViewColor());
	SetViewColor(B_TRANSPARENT_COLOR);

	SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
		B_ALIGN_VERTICAL_CENTER));
}
コード例 #3
0
ファイル: ToolBar.cpp プロジェクト: kodybrown/haiku
void
BToolBar::_Init()
{
	float inset = ceilf(be_control_look->DefaultItemSpacing() / 2);
	GroupLayout()->SetInsets(inset, 0, inset, 0);
	GroupLayout()->SetSpacing(1);

	SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED);
}
コード例 #4
0
TabView*
TabContainerView::RemoveTab(int32 index)
{
	TabLayoutItem* item
		= dynamic_cast<TabLayoutItem*>(GroupLayout()->RemoveItem(index));

	if (!item)
		return NULL;

	BRect dirty(Bounds());
	dirty.left = item->Frame().left;
	TabView* removedTab = item->Parent();
	removedTab->SetContainerView(NULL);

	if (removedTab == fLastMouseEventTab)
		fLastMouseEventTab = NULL;

	// Update tabs after or before the removed tab.
	bool hasFrames = fController != NULL && fController->HasFrames();
	item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index));
	if (item) {
		// This tab is behind the removed tab.
		TabView* tab = item->Parent();
		tab->Update(index == 0 && hasFrames,
			index == GroupLayout()->CountItems() - 2 && hasFrames,
			tab == fSelectedTab);
		if (removedTab == fSelectedTab) {
			fSelectedTab = NULL;
			SelectTab(tab);
		} else if (fController && tab == fSelectedTab)
			fController->TabSelected(index);
	} else {
		// The removed tab was the last tab.
		item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
		if (item) {
			TabView* tab = item->Parent();
			tab->Update(index == 0 && hasFrames,
				index == GroupLayout()->CountItems() - 2 && hasFrames,
				tab == fSelectedTab);
			if (removedTab == fSelectedTab) {
				fSelectedTab = NULL;
				SelectTab(tab);
			}
		}
	}

	Invalidate(dirty);
	_ValidateTabVisibility();

	return removedTab;
}
コード例 #5
0
TabContainerView::TabContainerView(Controller* controller)
	:
	BGroupView(B_HORIZONTAL, 0.0),
	fLastMouseEventTab(NULL),
	fMouseDown(false),
	fClickCount(0),
	fSelectedTab(NULL),
	fController(controller),
	fFirstVisibleTabIndex(0)
{
	SetFlags(Flags() | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	SetViewColor(B_TRANSPARENT_COLOR);
	GroupLayout()->SetInsets(kLeftTabInset, 0, 0, 1);
	GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue(), 0.0f);
}
コード例 #6
0
BToolbar::BToolbar(BRect frame, orientation ont)
	:
	BGroupView(ont),
	fOrientation(ont)
{
	float inset = ceilf(be_control_look->DefaultItemSpacing() / 2);
	GroupLayout()->SetInsets(inset, 0, inset, 0);
	GroupLayout()->SetSpacing(1);

	SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED);

	MoveTo(frame.LeftTop());
	ResizeTo(frame.Width(), frame.Height());
	SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
}
コード例 #7
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;
}
コード例 #8
0
ファイル: OpenGLView.cpp プロジェクト: SummerSnail2014/haiku
OpenGLView::OpenGLView()
	:
	BGroupView("OpenGLView", B_VERTICAL)
{

	BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
		BGL_RGB | BGL_DOUBLE);
	glView->Hide();
	AddChild(glView);

	glView->LockGL();

	float tabViewWidth = this->StringWidth("M") * 42;
	float tabViewHeight = this->StringWidth("M") * 16;

	BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
	tabView->SetExplicitMinSize(BSize(tabViewWidth, tabViewHeight));
	tabView->AddTab(new CapabilitiesView());
	tabView->AddTab(new ExtensionsView());

	glView->UnlockGL();

	GroupLayout()->SetSpacing(0);
	BLayoutBuilder::Group<>(this)
		.AddGroup(B_HORIZONTAL, 0)
			.Add(new GearsView())
			.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
				.SetInsets(0, B_USE_DEFAULT_SPACING,
					B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
				.Add(new InfoView())
				.Add(tabView)
				.End()
			.AddGlue()
			.End();
}
コード例 #9
0
void
TabContainerView::SelectTab(TabView* tab)
{
	if (tab == fSelectedTab)
		return;

	if (fSelectedTab)
		fSelectedTab->SetIsFront(false);

	fSelectedTab = tab;

	if (fSelectedTab)
		fSelectedTab->SetIsFront(true);

	if (fController != NULL) {
		int32 index = -1;
		if (fSelectedTab != NULL)
			index = GroupLayout()->IndexOfItem(tab->LayoutItem());

		if (!tab->LayoutItem()->IsVisible()) {
			SetFirstVisibleTabIndex(index);
		}

		fController->TabSelected(index);
	}
}
コード例 #10
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);
}
コード例 #11
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);
}
コード例 #12
0
void
TransportControlGroup::SetSymbolScale(float scale)
{
	if (scale == fSymbolScale)
		return;

	fSymbolScale = scale;

	if (fSeekSlider != NULL)
		fSeekSlider->SetSymbolScale(scale);
	if (fVolumeSlider != NULL) {
		fVolumeSlider->SetBarThickness(fVolumeSlider->PreferredBarThickness()
			* scale);
	}

	// Pick a symbol size based on the current system font size, but make
	// sure the size is uneven, so the pointy shapes have their middle on
	// a pixel instead of between two pixels.
	float symbolHeight = int(scale * be_plain_font->Size() / 1.33) | 1;

	if (fSkipBack != NULL)
		fSkipBack->SetSymbol(_CreateSkipBackwardsShape(symbolHeight));
	if (fSkipForward != NULL)
		fSkipForward->SetSymbol(_CreateSkipForwardShape(symbolHeight));
	if (fRewind != NULL)
		fRewind->SetSymbol(_CreateRewindShape(symbolHeight));
	if (fForward != NULL)
		fForward->SetSymbol(_CreateForwardShape(symbolHeight));
	if (fPlayPause != NULL) {
		fPlayPause->SetSymbols(_CreatePlayShape(symbolHeight),
			_CreatePauseShape(symbolHeight));
	}
	if (fStop != NULL)
		fStop->SetSymbol(_CreateStopShape(symbolHeight));
	if (fMute != NULL)
		fMute->SetSymbol(_CreateSpeakerShape(floorf(symbolHeight * 0.9)));

	// Figure out the visual insets of the slider bounds towards the slider
	// bar, and use that as insets for the rest of the layout.
	float barInset = 5.0f;
	if (fSeekSlider != NULL)
		barInset = fSeekSlider->BarFrame().left;
	float inset = barInset * scale;
	float hInset = 5.0f;
	if (fSeekSlider != NULL)
		hInset = inset - fSeekSlider->BarFrame().top;
	if (hInset < 0.0f)
		hInset = 0.0f;

	if (fSeekLayout != NULL) {
		fSeekLayout->SetInsets(inset - barInset, hInset, inset, 0);
		fSeekLayout->SetSpacing(inset - barInset);
	}
	fControlLayout->SetInsets(inset, hInset, inset, inset);
	fControlLayout->SetSpacing(inset - barInset);

	ResizeTo(Bounds().Width(), GroupLayout()->MinSize().height);
}
コード例 #13
0
void
TransportControlGroup::GetPreferredSize(float* _width, float* _height)
{
	BSize size = GroupLayout()->MinSize();
	if (_width != NULL)
		*_width = size.width;
	if (_height != NULL)
		*_height = size.height;
}
コード例 #14
0
ファイル: TabManager.cpp プロジェクト: AmirAbrams/haiku
	TabButtonContainer()
		:
		BGroupView(B_HORIZONTAL, 0.0)
	{
		SetFlags(Flags() | B_WILL_DRAW);
		SetViewColor(B_TRANSPARENT_COLOR);
		SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
		GroupLayout()->SetInsets(0, 6, 0, 0);
	}
コード例 #15
0
TabView*
TabContainerView::TabAt(int32 index) const
{
	TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
		GroupLayout()->ItemAt(index));
	if (item)
		return item->Parent();
	return NULL;
}
コード例 #16
0
void
TabContainerView::SetTabLabel(int32 tabIndex, const char* label)
{
	TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
		GroupLayout()->ItemAt(tabIndex));
	if (item == NULL)
		return;

	item->Parent()->SetLabel(label);
}
コード例 #17
0
void
TabContainerView::SelectTab(int32 index)
{
	TabView* tab = NULL;
	TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
		GroupLayout()->ItemAt(index));
	if (item)
		tab = item->Parent();

	SelectTab(tab);
}
コード例 #18
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;
}
コード例 #19
0
ファイル: ToolBar.cpp プロジェクト: kodybrown/haiku
void
BToolBar::SetActionVisible(uint32 command, bool visible)
{
	BButton* button = _FindButton(command);
	if (button == NULL)
		return;
	for (int32 i = 0; BLayoutItem* item = GroupLayout()->ItemAt(i); i++) {
		if (item->View() != button)
			continue;
		item->SetVisible(visible);
		break;
	}
}
コード例 #20
0
float
TabContainerView::_AvailableWidthForTabs() const
{
	float width = Bounds().Width() - 10;
		// TODO: Don't really know why -10 is needed above.

	float left;
	float right;
	GroupLayout()->GetInsets(&left, NULL, &right, NULL);
	width -= left + right;

	return width;
}
コード例 #21
0
ファイル: ConfigView.cpp プロジェクト: looncraz/haiku
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 <*****@*****.**>.");

	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 <*****@*****.**>");

	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());		
}
コード例 #22
0
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)
		)
	;
}
コード例 #23
0
ファイル: SettingsViews.cpp プロジェクト: RTOSkit/haiku
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);

}
コード例 #24
0
OpenGLView::OpenGLView()
	:
	BGroupView("OpenGLView", B_VERTICAL)
{

	BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
		BGL_RGB | BGL_DOUBLE);
	glView->Hide();
	AddChild(glView);

	glView->LockGL();

    BMenu* menu = new BMenu(B_TRANSLATE("Automatic"));
    menu->SetRadioMode(true);
    menu->SetLabelFromMarked(true);
    menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"),
        new BMessage(MENU_AUTO_MESSAGE)));
    menu->AddSeparatorItem();
    menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"),
        new BMessage(MENU_SWRAST_MESSAGE)));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"),
        new BMessage(MENU_SWPIPE_MESSAGE)));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"),
        new BMessage(MENU_SWLLVM_MESSAGE)));
    BMenuField* menuField = new BMenuField("renderer",
        B_TRANSLATE("3D Rendering Engine:"), menu);
	// TODO:  Set current Renderer
	menuField->SetEnabled(false);

	BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
	tabView->AddTab(new InfoView());
	tabView->AddTab(new CapabilitiesView());
	tabView->AddTab(new ExtensionsView());

	glView->UnlockGL();

	GroupLayout()->SetSpacing(0);
	BLayoutBuilder::Group<>(this)
		.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.Add(menuField)
		.AddGroup(B_HORIZONTAL)
			.Add(tabView)
			.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0);
}
コード例 #25
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;
}
コード例 #26
0
ファイル: ControlView.cpp プロジェクト: SummerSnail2014/haiku
ControlView::ControlView()
	: BGroupView("ControlView", B_VERTICAL),
	fMessenger(NULL),
	fMessageRunner(NULL),
	fTextControl(NULL),
	fFontMenuField(NULL),
	fFontsizeSlider(NULL),
	fShearSlider(NULL),
	fRotationSlider(NULL),
	fSpacingSlider(NULL),
	fOutlineSlider(NULL),
	fAliasingCheckBox(NULL),
	fBoundingboxesCheckBox(NULL),
	fCyclingFontButton(NULL),
	fFontFamilyMenu(NULL),
	fDrawingModeMenu(NULL),
	fCycleFonts(false),
	fFontStyleindex(0)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	GroupLayout()->SetInsets(B_USE_WINDOW_SPACING);
}
コード例 #27
0
ファイル: SettingsViews.cpp プロジェクト: RTOSkit/haiku
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);

}
コード例 #28
0
ファイル: ToolBar.cpp プロジェクト: kodybrown/haiku
void
BToolBar::AddView(BView* view)
{
	GroupLayout()->AddView(view);
}
コード例 #29
0
ファイル: ToolBar.cpp プロジェクト: kodybrown/haiku
void
BToolBar::AddGlue()
{
	GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
}
コード例 #30
0
bool
DownloadProgressView::Init(BMessage* archive)
{
	fCurrentSize = 0;
	fExpectedSize = 0;
	fLastUpdateTime = 0;
	fBytesPerSecond = 0.0;
	for (size_t i = 0; i < kBytesPerSecondSlots; i++)
		fBytesPerSecondSlot[i] = 0.0;
	fCurrentBytesPerSecondSlot = 0;
	fLastSpeedReferenceSize = 0;
	fEstimatedFinishReferenceSize = 0;

	fProcessStartTime = fLastSpeedReferenceTime = fEstimatedFinishReferenceTime
		= system_time();

	SetViewColor(245, 245, 245);
	SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW);

	if (archive) {
		fStatusBar = new BStatusBar("download progress", fPath.Leaf());
		float value;
		if (archive->FindFloat("value", &value) == B_OK)
			fStatusBar->SetTo(value);
	} else
		fStatusBar = new BStatusBar("download progress", "Download");
	fStatusBar->SetMaxValue(100);
	fStatusBar->SetBarHeight(12);

	// fPath is only valid when constructed from archive (fDownload == NULL)
	BEntry entry(fPath.Path());

	if (archive) {
		if (!entry.Exists())
			fIconView = new IconView(archive);
		else
			fIconView = new IconView(entry);
	} else
		fIconView = new IconView();

	if (!fDownload && (fStatusBar->CurrentValue() < 100 || !entry.Exists()))
		fTopButton = new SmallButton("Restart", new BMessage(RESTART_DOWNLOAD));
	else {
		fTopButton = new SmallButton("Open", new BMessage(OPEN_DOWNLOAD));
		fTopButton->SetEnabled(fDownload == NULL);
	}
	if (fDownload)
		fBottomButton = new SmallButton("Cancel", new BMessage(CANCEL_DOWNLOAD));
	else {
		fBottomButton = new SmallButton("Remove", new BMessage(REMOVE_DOWNLOAD));
		fBottomButton->SetEnabled(fDownload == NULL);
	}

	fInfoView = new BStringView("info view", "");

	BGroupLayout* layout = GroupLayout();
	layout->SetInsets(8, 5, 5, 6);
	layout->AddView(fIconView);
	BView* verticalGroup = BGroupLayoutBuilder(B_VERTICAL, 3)
		.Add(fStatusBar)
		.Add(fInfoView)
		.TopView()
	;
	verticalGroup->SetViewColor(ViewColor());
	layout->AddView(verticalGroup);
	verticalGroup = BGroupLayoutBuilder(B_VERTICAL, 3)
		.Add(fTopButton)
		.Add(fBottomButton)
		.TopView()
	;
	verticalGroup->SetViewColor(ViewColor());
	layout->AddView(verticalGroup);

	BFont font;
	fInfoView->GetFont(&font);
	float fontSize = font.Size() * 0.8f;
	font.SetSize(max_c(8.0f, fontSize));
	fInfoView->SetFont(&font, B_FONT_SIZE);
	fInfoView->SetHighColor(tint_color(fInfoView->LowColor(),
		B_DARKEN_4_TINT));
	fInfoView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	return true;
}