示例#1
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;
}
示例#2
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);
}