Пример #1
0
status_t
DataTranslationsWindow::_ShowConfigView(int32 id)
{
	// Shows the config panel for the translator with the given id

	if (id < 0)
		return B_BAD_VALUE;

	BTranslatorRoster* roster = BTranslatorRoster::Default();

	if (fConfigView != NULL) {
		fRightBox->RemoveChild(fConfigView);
		delete fConfigView;
		fConfigView = NULL;
		fInfoText = NULL;
		if (fRelease != NULL) {
			fRelease->Release();
			fRelease = NULL;
		}
	}

	BMessage emptyMessage;
	BRect rect(0.0f, 0.0f, 200.0f, 233.0f);
	status_t result = roster->MakeConfigurationView(id, &emptyMessage,
		&fConfigView, &rect);

	if (result != B_OK)
		return result;

	fConfigView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
		// force config views to all have the same color
	fRightBox->AddChild(fConfigView);

	// for default 12pt font size: 597 ≈ (0.85 * 12 * 49)
	fConfigView->SetExplicitMinSize(
		BSize(ceilf(be_control_look->DefaultItemSpacing() * 49)
			- fTranslatorListView->Frame().Width(), B_SIZE_UNSET));

	// Make sure the translator's image doesn't get unloaded while we are still
	// showing a config view whose code is in the image
	fRelease = roster->AcquireTranslator(id);

	return B_OK;
}