SetTitleDialog::SetTitleDialog(const char* dialogTitle, const char* label,
	const char* toolTip)
	:
	BWindow(BRect(0, 0, 0, 0), dialogTitle, B_BORDERED_WINDOW_LOOK,
		B_FLOATING_APP_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
	fListener(NULL),
	fTitle(),
	fTitleUserDefined(false)
{
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(10, 10, 10, 10)
		.Add(fTitleTextControl = new BTextControl("title", label, "", NULL))
		.AddGroup(B_HORIZONTAL)
			.Add(fDefaultButton = new BButton("defaultButton",
				B_TRANSLATE("Use default"), new BMessage(kMessageDefault)))
			.AddGlue()
			.Add(fCancelButton = new BButton("cancelButton",
				B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)))
			.Add(fOKButton = new BButton("okButton", B_TRANSLATE("OK"),
				new BMessage(kMessageOK)));

	fTitleTextControl->SetToolTip(toolTip);

	fOKButton->MakeDefault(true);

	UpdateSizeLimits();
		// as a courtesy to our creator, who might want to place us
}
Ejemplo n.º 2
0
InfoWin::InfoWin(BPoint leftTop, Controller* controller)
	:
	BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1,
		leftTop.y + 300), B_TRANSLATE("File info"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE),
	fController(controller),
	fControllerObserver(new ControllerObserver(this,
		OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES))
{
	fIconView = new IconView("background", B_LARGE_ICON);

	fFilenameView = _CreateInfo("filename");
	BFont bigFont(be_plain_font);
	bigFont.SetSize(bigFont.Size() * 1.5f);
	fFilenameView->SetFont(&bigFont);

	// Create info views

	BStringView* containerLabel = _CreateLabel("containerLabel",
		B_TRANSLATE("Container"));
	fContainerInfo = _CreateInfo("container");

	fVideoSeparator = _CreateSeparator();
	fVideoLabel = _CreateLabel("videoLabel", B_TRANSLATE("Video"));
	fVideoFormatInfo = _CreateInfo("videoFormat");
	fVideoConfigInfo = _CreateInfo("videoConfig");
	fDisplayModeLabel = _CreateLabel("displayModeLabel",
		B_TRANSLATE("Display mode"));
	fDisplayModeInfo = _CreateInfo("displayMode");

	fAudioSeparator = _CreateSeparator();
	fAudioLabel = _CreateLabel("audioLabel", B_TRANSLATE("Audio"));
	fAudioFormatInfo = _CreateInfo("audioFormat");
	fAudioConfigInfo = _CreateInfo("audioConfig");

	BStringView* durationLabel = _CreateLabel("durationLabel",
		B_TRANSLATE("Duration"));
	fDurationInfo = _CreateInfo("duration");

	BStringView* locationLabel = _CreateLabel("locationLabel",
		B_TRANSLATE("Location"));
	fLocationInfo = _CreateInfo("location");

	fCopyrightSeparator = _CreateSeparator();
	fCopyrightLabel = _CreateLabel("copyrightLabel", B_TRANSLATE("Copyright"));
	fCopyrightInfo = _CreateInfo("copyright");

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGroup(B_HORIZONTAL)
			.Add(fIconView, 0)
			.Add(fFilenameView, 1)
			.End()
		.AddGrid(2, 13)
			.Add(containerLabel, 0, 0)
			.Add(fContainerInfo, 1, 0)
			.Add(fVideoSeparator, 0, 1)
			.Add(fVideoLabel, 0, 2)
			.Add(fVideoFormatInfo, 1, 2)
			.Add(fVideoConfigInfo, 1, 3)
			.Add(fDisplayModeLabel, 0, 4)
			.Add(fDisplayModeInfo, 1, 4)
			.Add(fAudioSeparator, 0, 5)
			.Add(fAudioLabel, 0, 6)
			.Add(fAudioFormatInfo, 1, 6)
			.Add(fAudioConfigInfo, 1, 7)
			.Add(_CreateSeparator(), 0, 8)
			.Add(durationLabel, 0, 9)
			.Add(fDurationInfo, 1, 9)
			.Add(_CreateSeparator(), 0, 10)
			.Add(locationLabel, 0, 11)
			.Add(fLocationInfo, 1, 11)
			.Add(fCopyrightSeparator, 0, 12)
			.Add(fCopyrightLabel, 0, 12)
			.Add(fCopyrightInfo, 1, 12)
			.SetColumnWeight(0, 0)
			.SetColumnWeight(1, 1)
			.SetSpacing(B_USE_DEFAULT_SPACING, 0)
			.SetExplicitMinSize(BSize(MIN_WIDTH, B_SIZE_UNSET));

	fController->AddListener(fControllerObserver);
	Update();

	UpdateSizeLimits();

	// Move window on screen if needed
	BScreen screen(this);
	if (screen.Frame().bottom < Frame().bottom)
		MoveBy(0, screen.Frame().bottom - Frame().bottom);
	if (screen.Frame().right < Frame().right)
		MoveBy(0, screen.Frame().right - Frame().right);

	Show();
}