예제 #1
0
	PinwheelWindow(BRect frame) 
		:
		BWindow(frame, "ALM Pinwheel", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
	{
		button1 = new BButton("1");
		button2 = new BButton("2");
		button3 = new BButton("3");
		button4 = new BButton("4");
		textView1 = new BTextView("textView1");
		textView1->SetText("5");	

		button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
		button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
		button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
		button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));

		// create a new BALMLayout and use  it for this window
		BALMLayout* layout = new BALMLayout(10, 10);

		BReference<XTab> xTabs[2];
		BReference<YTab> yTabs[2];
		layout->AddXTabs(xTabs, 2);
		layout->AddYTabs(yTabs, 2);

		BALM::BALMLayoutBuilder(this, layout)
			.SetInsets(5)
			.Add(textView1, xTabs[0], yTabs[0], xTabs[1], yTabs[1])
			.StartingAt(textView1)
				.AddAbove(button1, layout->Top(), layout->Left())
				.AddToRight(button2, layout->Right(), NULL, yTabs[1])
				.AddBelow(button3, layout->Bottom(), xTabs[0])
				.AddToLeft(button4, layout->Left(),  yTabs[0]);

		// alternative setup
		/*
		SetLayout(layout);

		layout->SetInsets(5.);

		// create extra tabs
		BReference<XTab> x1 = layout->AddXTab();
		BReference<XTab> x2 = layout->AddXTab();
		BReference<YTab> y1 = layout->AddYTab();
		BReference<YTab> y2 = layout->AddYTab();

		layout->AddView(button1, layout->Left(), layout->Top(), x2,
			y1);
		layout->AddView(button2, x2, layout->Top(), layout->Right(), y2);
		layout->AddView(button3, x1, y2, layout->Right(),
			layout->Bottom());
		layout->AddView(button4, layout->Left(), y1, x1, layout->Bottom());
		layout->AddView(textView1, x1, y1, x2, y2);
		*/

		// test size limits
		BSize min = layout->MinSize();
		BSize max = layout->MaxSize();
		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
	}
예제 #2
0
/**
 * Gets bottom inset between area and its content.
 */
float
Area::BottomInset() const
{
	if (fRightBottomInset.IsHeightSet())
		return fRightBottomInset.Height();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	return layout->InsetForTab(fBottom.Get());
}
예제 #3
0
/**
 * Gets right inset between area and its content.
 */
float
Area::RightInset() const
{
	if (fRightBottomInset.IsWidthSet())
		return fRightBottomInset.Width();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	return layout->InsetForTab(fRight.Get());
}
예제 #4
0
/**
 * Gets top inset between area and its content.
 */
float
Area::TopInset() const
{
	if (fLeftTopInset.IsHeightSet())
		return fLeftTopInset.Height();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	return layout->InsetForTab(fTop.Get());
}
예제 #5
0
/**
 * Gets left inset between area and its content.
 */
float
Area::LeftInset() const
{
	if (fLeftTopInset.IsWidthSet())
		return fLeftTopInset.Width();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	return layout->InsetForTab(fLeft.Get());
}
예제 #6
0
/**
 * Gets top inset between area and its content.
 */
float
Area::TopInset() const
{
	if (fTopLeftInset.IsHeightSet())
		return fTopLeftInset.Height();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	if (fTop.Get() == layout->Top())
		return layout->Inset();
	return layout->Spacing() / 2;
}
예제 #7
0
/**
 * Gets left inset between area and its content.
 */
float
Area::LeftInset() const
{
	if (fTopLeftInset.IsWidthSet())
		return fTopLeftInset.Width();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	if (fLeft.Get() == layout->Left())
		return layout->Inset();
	return layout->Spacing() / 2;
}
예제 #8
0
/**
 * Gets right inset between area and its content.
 */
float
Area::RightInset() const
{
	if (fRightBottomInset.IsWidthSet())
		return fRightBottomInset.Width();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	if (fRight.Get() == layout->Right())
		return layout->Inset();
	return layout->Spacing() / 2;
}
예제 #9
0
/**
 * Gets bottom inset between area and its content.
 */
float
Area::BottomInset() const
{
	if (fRightBottomInset.IsHeightSet())
		return fRightBottomInset.Height();

	BALMLayout* layout = static_cast<BALMLayout*>(fLayoutItem->Layout());
	if (fBottom.Get() == layout->Bottom())
		return layout->Inset();
	return layout->Spacing() / 2;
}
FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings)
	:
	BWindow(BRect(0, 0, 300, 300), B_TRANSLATE("IMAP Folders"),
		B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
		B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE | B_AVOID_FRONT),
	fSettings(settings)
{
	BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW);
	AddChild(rootView);
	rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	float spacing = be_control_look->DefaultItemSpacing();
	BALMLayout* layout = new BALMLayout(spacing);
	rootView->SetLayout(layout);
	layout->SetInset(spacing);

	fFolderListView = new EditListView(B_TRANSLATE("IMAP Folders"));
	fFolderListView->SetExplicitPreferredSize(BSize(B_SIZE_UNLIMITED,
		B_SIZE_UNLIMITED));
	fApplyButton = new BButton("Apply", B_TRANSLATE("Apply"),
		new BMessage(kMsgApplyButton));

	fQuotaView = new BStringView("quota view",
		B_TRANSLATE("Failed to fetch available storage."));
	fQuotaView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_CENTER));

	layout->AddView(fFolderListView, layout->Left(), layout->Top(),
		layout->Right(), layout->Bottom());

	GroupItem item = GroupItem(fQuotaView) / GroupItem(fFolderListView)
		/ (GroupItem(BSpaceLayoutItem::CreateGlue())
			| GroupItem(fApplyButton));
	layout->BuildLayout(item);

	PostMessage(kMsgInit);

	BSize min = layout->MinSize();
	BSize max = layout->MaxSize();
	SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());

	CenterIn(parent);
}
예제 #11
0
CustomizableFactoryWindow::CustomizableFactoryWindow(CustomizableRoster* roster)
	:
	BWindow(BRect(20, 220, 250, 500), "Add Component", B_FLOATING_WINDOW, 0)
{
	BALMLayout* layout = new BALMLayout(10.);
	SetLayout(layout);
	FactoryDragListView* listView = new FactoryDragListView(roster);
	layout->AddView(listView, layout->Left(), layout->Top(),
		layout->Right(), layout->Bottom());
}
	StatusWindow(const char* text)
		:
		BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK,
			B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE
				| B_AVOID_FRONT | B_NOT_RESIZABLE)
	{
		BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL,
			B_WILL_DRAW);
		AddChild(rootView);
		rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		float spacing = be_control_look->DefaultItemSpacing();
		BALMLayout* layout = new BALMLayout(spacing);
		rootView->SetLayout(layout);
		layout->SetInset(spacing);

		BStringView* string = new BStringView("text", text);
		layout->AddView(string, layout->Left(), layout->Top(), layout->Right(),
			layout->Bottom());
		BSize min = layout->MinSize();
		ResizeTo(min.Width(), min.Height());
		CenterOnScreen();
	}
예제 #13
0
area_ref
InsertionIntoEmptyArea::CreateTargetArea()
{
	BALMLayout* layout = fView->Layout();
	area_ref ref = fEmptyArea.to_ref(layout);

	BRect frame = TargetFrame();
	
	if (ref.left == NULL) {
		ref.left = layout->AddXTab();
		ref.left->SetValue(frame.left);
	}
	if (ref.top == NULL) {
		ref.top = layout->AddYTab();
		ref.top->SetValue(frame.top);
	}
	if (ref.right == NULL) {
		ref.right = layout->AddXTab();
		ref.right->SetValue(frame.right);
	}
	if (ref.bottom == NULL) {
		ref.bottom = layout->AddYTab();
		ref.bottom->SetValue(frame.bottom);
	}

	const double kPenalty = 5;
	// free positioning at freePosition
	if (fEmptyArea.left == -1 && fEmptyArea.right == -1) {
		Constraint* constraint = layout->AddConstraint(1, ref.left,
			LinearProgramming::kEQ, fFreePosition.x, kPenalty, kPenalty);
		constraint->SetLabel("_EditHelper");
	}
	if (fEmptyArea.top == -1 && fEmptyArea.bottom == -1) {
		Constraint* constraint = layout->AddConstraint(1, ref.top,
			LinearProgramming::kEQ, fFreePosition.y, kPenalty, kPenalty);
		constraint->SetLabel("_EditHelper");
	}
	return ref;
}
예제 #14
0
    TableDemoWindow(BRect frame)
        : BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
    {
        // create a new BALMLayout and use  it for this window
        BALMLayout* layout = new BALMLayout();
        SetLayout(layout);

        Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
        Row* r1 = layout->AddRow(layout->Top(), NULL);
        Row* r2 = layout->AddRow(r1->Bottom(), NULL);
        Row* r3 = layout->AddRow(r2->Bottom(), layout->Bottom());

        BButton* b1 = new BButton("A1");
        layout->AddView(b1, r1, c1);
        b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

        BButton* b2 = new BButton("A2");
        layout->AddView(b2, r2, c1);
        b2->SetExplicitAlignment(BAlignment(
                                     B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));

        BButton* b3 = new BButton("A3");
        layout->AddView(b3, r3, c1);
        b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));

        // test size limits
        BSize min = layout->MinSize();
        BSize max = layout->MaxSize();
        SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
    }
예제 #15
0
void
DataTranslationsWindow::_SetupViews()
{
	fConfigView = NULL;
	// This is NULL until a translator is
	// selected from the listview

	// Window box
	BView* mainView = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
	mainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(mainView);

	// Add the translators list view
	fTranslatorListView = new TranslatorListView(BRect(0, 0, 1, 1), "TransList",
		B_SINGLE_SELECTION_LIST);
	fTranslatorListView->SetSelectionMessage(new BMessage(kMsgSelectedTranslator));

	BScrollView *scrollView = new BScrollView("scroll_trans", fTranslatorListView,
    		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
    		false, true, B_FANCY_BORDER);

	// Box around the config and info panels
	fRightBox = new BBox("Right_Side");

	// Add the translator icon view
	fIconView = new IconView(BRect(0, 0, 31, 31), "Icon",
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);

	// Add the translator info button
	BButton *button = new BButton("STD", "Info" B_UTF8_ELLIPSIS,
		new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);

	// Add the translator name view
	fTranslatorNameView = new BStringView("TranName", "None");

	// Populate the translators list view
	_PopulateListView();

	// Build the layout
	BALMLayout *layout = new BALMLayout();
	mainView->SetLayout(layout);

	XTab *x1 = layout->AddXTab();
	XTab *x2 = layout->AddXTab();
	XTab *x3 = layout->AddXTab();
	YTab *y1 = layout->AddYTab();

	Area *leftArea = layout->AddArea(layout->Left(), layout->Top(),
		x1, layout->Bottom(), scrollView);
	leftArea->SetLeftInset(10);
	leftArea->SetTopInset(10);
	leftArea->SetBottomInset(10);

	Area *rightArea = layout->AddArea(x1, layout->Top(), layout->Right(), y1, fRightBox);
	rightArea->SetLeftInset(10);
	rightArea->SetTopInset(10);
	rightArea->SetRightInset(10);
	rightArea->SetBottomInset(10);

	Area *iconArea = layout->AddArea(x1, y1, x2, layout->Bottom(), fIconView);
	iconArea->SetLeftInset(10);
	iconArea->SetBottomInset(10);

	Area *infoButtonArea = layout->AddArea(x3, y1, layout->Right(), layout->Bottom(), button);
	infoButtonArea->SetRightInset(10);
	infoButtonArea->SetBottomInset(10);

	layout->AddConstraint(3.0, x1, -1.0, layout->Right(), OperatorType(EQ), 0.0);

	fTranslatorListView->MakeFocus();
	fTranslatorListView->Select(0);
}
예제 #16
0
파일: TableDemo.cpp 프로젝트: mariuz/haiku
	TableDemoWindow(BRect frame) 
		: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) 
	{	
		// create a new BALMLayout and use  it for this window
		BALMLayout* layout = new BALMLayout();
		SetLayout(layout);
		
		Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
		Row* r1 = layout->AddRow(layout->Top(), NULL);
		Row* r3 = layout->AddRow(NULL, layout->Bottom());
		r1->SetNext(r3);
		Row* r2 = layout->AddRow();
		r2->InsertAfter(r1);
		
		BButton* b1 = new BButton("A1");
		Area* a1 = layout->AddArea(r1, c1, b1);
		a1->SetHorizontalAlignment(B_ALIGN_LEFT);
		a1->SetVerticalAlignment(B_ALIGN_TOP);
		
		BButton* b2 = new BButton("A2");
		Area* a2 = layout->AddArea(r2, c1, b2);
		a2->SetHorizontalAlignment(B_ALIGN_HORIZONTAL_CENTER);
		a2->SetVerticalAlignment(B_ALIGN_VERTICAL_CENTER);
				
		BButton* b3 = new BButton("A3");
		Area* a3 = layout->AddArea(r3, c1, b3);
		a3->SetHorizontalAlignment(B_ALIGN_RIGHT);
		a3->SetVerticalAlignment(B_ALIGN_BOTTOM);
		
		r2->HasSameHeightAs(r1);
		r3->HasSameHeightAs(r1);
	}
예제 #17
0
void
InsertionIntoEmptyArea::MaximizeEmptyArea(area_ref& ref, BRect target, BRect ignore)
{
	BALMLayout* layout = fView->Layout();
	BRegion takenSpace = fView->fTakenSpace;
	takenSpace.Exclude(ignore);
	area_info areaInfo(ref, layout);
	// try to match the target

	XTab* left = ref.left;
	while (left->Value() > target.left) {
		left = layout->XTabAt(areaInfo.left - 1, true);
		if (left == NULL)
			break;
		area_ref newRef = ref;
		newRef.left = left;
		BRect frame = newRef.Frame();
		frame.InsetBy(1, 1);
		if (takenSpace.Intersects(frame))
			break;
		areaInfo.left -= 1;
		ref.left = left;
	}
	XTab* right = ref.right;
	while (right->Value() < target.right) {
		right = layout->XTabAt(areaInfo.right + 1, true);
		if (right == NULL)
			break;
		area_ref newRef = ref;
		newRef.right = right;
		BRect frame = newRef.Frame();
		frame.InsetBy(1, 1);
		if (takenSpace.Intersects(frame))
			break;
		areaInfo.right += 1;
		ref.right = right;
	}
	YTab* top = ref.top;
	while (top->Value() > target.top) {
		top = layout->YTabAt(areaInfo.top - 1, true);
		if (top == NULL)
			break;
		area_ref newRef = ref;
		newRef.top = top;
		BRect frame = newRef.Frame();
		frame.InsetBy(1, 1);
		if (takenSpace.Intersects(frame))
			break;
		areaInfo.top -= 1;
		ref.top = top;
	}
	YTab* bottom = ref.bottom;
	while (bottom->Value() < target.bottom) {
		bottom = layout->YTabAt(areaInfo.bottom + 1, true);
		if (bottom == NULL)
			break;
		area_ref newRef = ref;
		newRef.bottom = bottom;
		BRect frame = newRef.Frame();
		frame.InsetBy(1, 1);
		if (takenSpace.Intersects(frame))
			break;
		areaInfo.bottom += 1;
		ref.bottom = bottom;
	}

	// maximize further
	while (true) {
		BRect previousFrame = ref.Frame();
		
		left = layout->XTabAt(areaInfo.left - 1, true);
		right = layout->XTabAt(areaInfo.right + 1, true);
		top = layout->YTabAt(areaInfo.top - 1, true);
		bottom = layout->YTabAt(areaInfo.bottom + 1, true);

		float leftDelta = -1;
		if (left != NULL) {
			BRect newFrame(previousFrame);
			newFrame.left = left->Value();
			newFrame.InsetBy(1, 1);
			if (!takenSpace.Intersects(newFrame)) {
				leftDelta = previousFrame.Height()
					* (previousFrame.left - left->Value());
			}
		}
		float rightDelta = -1;
		if (right != NULL) {
			BRect newFrame(previousFrame);
			newFrame.right = right->Value();
			newFrame.InsetBy(1, 1);
			if (!takenSpace.Intersects(newFrame)) {
				rightDelta = previousFrame.Height()
					* (right->Value() - previousFrame.right);
			}
		}
		float topDelta = -1;
		if (top != NULL) {
			BRect newFrame(previousFrame);
			newFrame.top = top->Value();
			newFrame.InsetBy(1, 1);
			if (!takenSpace.Intersects(newFrame)) {
				topDelta = previousFrame.Width()
					* (previousFrame.top - top->Value());
			}
		}
		float bottomDelta = -1;
		if (bottom != NULL) {
			BRect newFrame(previousFrame);
			newFrame.bottom = bottom->Value();
			newFrame.InsetBy(1, 1);
			if (!takenSpace.Intersects(newFrame)) {
				bottomDelta = previousFrame.Width()
					* (bottom->Value() - previousFrame.bottom);
			}
		}
		if (leftDelta > 0 && leftDelta > rightDelta && leftDelta > topDelta
			&& leftDelta > bottomDelta) {
			ref.left = left;
			areaInfo.left = layout->IndexOf(left, true);
		} else if (rightDelta > 0 && rightDelta > topDelta
			&& rightDelta > bottomDelta) {
			ref.right = right;
			areaInfo.right = layout->IndexOf(right, true);
		} else if (topDelta > 0 && topDelta > bottomDelta) {
			ref.top = top;
			areaInfo.top = layout->IndexOf(top, true);
		} else if (bottomDelta > 0) {
			ref.bottom = bottom;
			areaInfo.bottom = layout->IndexOf(bottom, true);
		}

		BRect newFrame = ref.Frame();
		if (fuzzy_equal(previousFrame.Width(), newFrame.Width())
			&& fuzzy_equal(previousFrame.Height(), newFrame.Height()))
			break;
	}
}
MusicCollectionWindow::MusicCollectionWindow(BRect frame, const char* title)
	:
	BWindow(frame, title, B_DOCUMENT_WINDOW, B_AVOID_FRONT)
{
	BView* rootView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	AddChild(rootView);
	rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fQueryField = new BTextControl("Search: ", "", NULL);
	fQueryField->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
		B_ALIGN_USE_FULL_HEIGHT));
	fQueryField->SetModificationMessage(new BMessage(kMsgQueryInput));

	fCountView = new BStringView("Count View", "Count:");

	fFileListView = new MusicFileListView("File List View");
	fFileListView->SetInvocationMessage(new BMessage(kMsgItemInvoked));
	BScrollView* scrollView = new BScrollView("list scroll", fFileListView, 0,
		true, true, B_PLAIN_BORDER);

	float spacing = be_control_look->DefaultItemSpacing() / 2;
	BALMLayout* layout = new BALMLayout(spacing);
	layout->SetInset(spacing);
	rootView->SetLayout(layout);

	layout->AddView(fQueryField, layout->Left(), layout->Top());
	layout->AddViewToRight(fCountView, layout->Right());
	layout->AddView(scrollView, layout->Left(),
		layout->AreaFor(fQueryField)->Bottom(), layout->Right(),
		layout->Bottom());

	Area* area = layout->AreaFor(scrollView);
	area->SetLeftInset(0);
	area->SetRightInset(0);
	area->SetBottomInset(0);

	BSize min = layout->MinSize();
	BSize max = layout->MaxSize();
	SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());

	fEntryViewInterface = new ListViewListener<FileListItem>(fFileListView,
		fCountView);
	fQueryHandler = new QueryHandler(fEntryViewInterface);
	AddHandler(fQueryHandler);
	fQueryReader = new QueryReader(fQueryHandler);
	fQueryHandler->SetReadThread(fQueryReader);

	// start initial query
	PostMessage(kMsgQueryInput);
}