void
ExpanderWindow::_ExpandListingText()
{
	float delta = fLongestLine - fListingText->Frame().Width();

	if (delta > 0) {
		BScreen screen;
		BRect screenFrame = screen.Frame();

		if (Frame().right + delta > screenFrame.right)
			delta = screenFrame.right - Frame().right - 4.0f;

		ResizeBy(delta, 0.0f);
	}

	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);

	if (minWidth < Frame().Width() + delta) {
		// set the Zoom limit as the minimal required size
		SetZoomLimits(Frame().Width() + delta,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	} else {
		// set the zoom limit based on minimal window size allowed
		SetZoomLimits(minWidth,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	}
}
Ejemplo n.º 2
0
void
HWindow::_UpdateZoomLimits()
{
	const float kInset = be_control_look->DefaultItemSpacing();

	BSize size = fEventList->PreferredSize();
	SetZoomLimits(size.width + 2 * kInset + B_V_SCROLL_BAR_WIDTH,
		size.height + 5 * kInset + 2 * B_H_SCROLL_BAR_HEIGHT
			+ 2 * be_plain_font->Size() * 2.5);
}
Ejemplo n.º 3
0
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
CalcWindow::CalcWindow(BPoint pt)
		: BWindow(CalcView::TheRect(pt), "Calculator",
				  B_TITLED_WINDOW, B_NOT_H_RESIZABLE)
{
	BRect r = CalcView::TheRect();

	SetSizeLimits(r.right, r.right, r.bottom, r.bottom+CalcView::ExtraHeight());
	SetZoomLimits(r.right, r.bottom+CalcView::ExtraHeight());

	calc_view = new CalcView(r);
	AddChild(calc_view);

	BView *extraView = calc_view->AddExtra();
	AddChild(extraView);
}
ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
		BMessage* settings)
	:
	BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Expander"), B_TITLED_WINDOW,
		B_NORMAL_WINDOW_FEEL),
	fSourcePanel(NULL),
	fDestPanel(NULL),
	fSourceChanged(true),
	fListingThread(NULL),
	fListingStarted(false),
	fExpandingThread(NULL),
	fExpandingStarted(false),
	fSettings(*settings),
	fPreferences(NULL)
{
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
	SetLayout(layout);

	_AddMenuBar(layout);

	fDestButton = new BButton(B_TRANSLATE("Destination"),
		new BMessage(MSG_DEST));
	fSourceButton = new BButton(B_TRANSLATE("Source"),
		new BMessage(MSG_SOURCE));
	fExpandButton = new BButton(B_TRANSLATE("Expand"),
		new BMessage(MSG_EXPAND));

	BSize size = fDestButton->PreferredSize();
	size.width = max_c(size.width, fSourceButton->PreferredSize().width);
	size.width = max_c(size.width, fExpandButton->PreferredSize().width);

	fDestButton->SetExplicitMaxSize(size);
	fSourceButton->SetExplicitMaxSize(size);
	fExpandButton->SetExplicitMaxSize(size);

	fListingText = new BTextView("listingText");
	fListingText->SetText("");
	fListingText->MakeEditable(false);
	fListingText->SetStylable(false);
	fListingText->SetWordWrap(false);
	BFont font = be_fixed_font;
	fListingText->SetFontAndColor(&font);
	BScrollView* scrollView = new BScrollView("", fListingText,
		B_INVALIDATE_AFTER_LAYOUT, true, true);

	BView* topView = layout->View();
	const float spacing = be_control_look->DefaultItemSpacing();
	topView->AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.AddGroup(B_HORIZONTAL, spacing)
			.AddGroup(B_VERTICAL, 5.0)
				.Add(fSourceButton)
				.Add(fDestButton)
				.Add(fExpandButton)
			.End()
			.AddGroup(B_VERTICAL, spacing)
				.Add(fSourceText = new BTextControl(NULL, NULL,
					new BMessage(MSG_SOURCETEXT)))
				.Add(fDestText = new BTextControl(NULL, NULL,
					new BMessage(MSG_DESTTEXT)))
				.AddGroup(B_HORIZONTAL, spacing)
					.Add(fShowContents = new BCheckBox(
						B_TRANSLATE("Show contents"),
						new BMessage(MSG_SHOWCONTENTS)))
					.Add(fStatusView = new BStringView(NULL, NULL))
				.End()
			.End()
		.End()
		.Add(scrollView)
		.SetInsets(spacing, spacing, spacing, spacing)
	);

	size = topView->PreferredSize();
	fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing;

	ResizeTo(Bounds().Width(), fSizeLimit);
	SetSizeLimits(size.Width(), 32767.0f, fSizeLimit, fSizeLimit);
	SetZoomLimits(Bounds().Width(), fSizeLimit);
	fPreviousHeight = -1;

	Show();
}