Beispiel #1
0
/*!	Adds a menu populated with the keyboard layouts found in the passed
	in directory to the passed in menu. Each subdirectory in the passed
	in directory is added as a submenu recursively.
*/
void
KeymapWindow::_AddKeyboardLayoutMenu(BMenu* menu, BDirectory directory)
{
	entry_ref ref;

	while (directory.GetNextRef(&ref) == B_OK) {
		if (menu->FindItem(ref.name) != NULL)
			continue;

		BDirectory subdirectory;
		subdirectory.SetTo(&ref);
		if (subdirectory.InitCheck() == B_OK) {
			BMenu* submenu = new BMenu(B_TRANSLATE_NOCOLLECT(ref.name));

			_AddKeyboardLayoutMenu(submenu, subdirectory);
			menu->AddItem(submenu);
		} else {
			BMessage* message = new BMessage(kChangeKeyboardLayout);

			message->AddRef("ref", &ref);
			menu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(ref.name),
				message));
		}
	}
}
BMenuField*
ModifierKeysWindow::_CreateCommandMenuField()
{
	fCommandMenu = new BPopUpMenu(
		B_TRANSLATE_NOCOLLECT(_KeyToString(MENU_ITEM_COMMAND)), true, true);

	for (int32 key = MENU_ITEM_SHIFT; key <= MENU_ITEM_DISABLED; key++) {
		if (key == MENU_ITEM_SEPERATOR) {
			// add separator item
			BSeparatorItem* separator = new BSeparatorItem;
			fCommandMenu->AddItem(separator, MENU_ITEM_SEPERATOR);
			continue;
		}

		BMessage* message = new BMessage(kMsgUpdateModifier);
		message->AddInt32(_KeyToString(MENU_ITEM_COMMAND), key);
		BMenuItem* item = new BMenuItem(
			B_TRANSLATE_NOCOLLECT(_KeyToString(key)), message);
		fCommandMenu->AddItem(item, key);
	}

	fCommandMenu->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
		B_ALIGN_VERTICAL_UNSET));

	return new BMenuField(B_TRANSLATE_COMMENT("Command:",
		"Command key role name"), fCommandMenu);
}
void
BluetoothSettingsView::_BuildClassMenu()
{

	fClassMenu = new BPopUpMenu(B_TRANSLATE("Identify us as..."));
	BMessage* message;

	message = new BMessage(kMsgSetDeviceClassDesktop);
	BMenuItem* item
		= new BMenuItem(B_TRANSLATE_NOCOLLECT(kDesktopLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClassServer);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kServerLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClassLaptop);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kLaptopLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClassHandheld);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kHandheldLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClassSmartPhone);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kPhoneLabel), message);
	fClassMenu->AddItem(item);

}
void
BluetoothSettingsView::_BuildClassMenu()
{
	
	BMessage* message = NULL;
	BMenuItem* item = NULL;

	fClassMenu = new BPopUpMenu(B_TRANSLATE("Identify us as..."));

	message = new BMessage(kMsgSetDeviceClass);
	message->AddInt8("DeviceClass", 1);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kDesktopLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClass);
	message->AddInt8("DeviceClass", 2);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kServerLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClass);
	message->AddInt8("DeviceClass", 3);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kLaptopLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClass);
	message->AddInt8("DeviceClass", 4);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kHandheldLabel), message);
	fClassMenu->AddItem(item);

	message = new BMessage(kMsgSetDeviceClass);
	message->AddInt8("DeviceClass", 5);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kPhoneLabel), message);
	fClassMenu->AddItem(item);
}
Beispiel #5
0
const char *
Model::Name() const
{
	static const char* kRootNodeName = B_TRANSLATE_MARK("Disks");
	static const char* kTrashNodeName = B_TRANSLATE_MARK("Trash");
	static const char* kDesktopNodeName = B_TRANSLATE_MARK("Desktop");

	switch (fBaseType) {
		case kRootNode:
			return B_TRANSLATE_NOCOLLECT(kRootNodeName);

		case kVolumeNode:
			if (fVolumeName)
				return fVolumeName;
			break;
		case kTrashNode:
			return B_TRANSLATE_NOCOLLECT(kTrashNodeName);

		case kDesktopNode:
			return B_TRANSLATE_NOCOLLECT(kDesktopNodeName);

		default:
			break;

	}

	if (fHasLocalizedName && gLocalizedNamePreferred)
		return fLocalizedName.String();
	else
		return fEntryRef.name;
}
void
AntialiasingSettingsView::_SetCurrentAntialiasing()
{
	BMenuItem *item = fAntialiasingMenu->FindItem(
		fCurrentSubpixelAntialiasing
		? B_TRANSLATE_NOCOLLECT(kSubpixelLabel)
		: B_TRANSLATE_NOCOLLECT(kGrayscaleLabel));
	if (item != NULL)
		item->SetMarked(true);
	if (fCurrentSubpixelAntialiasing)
		fAverageWeightControl->SetEnabled(true);
}
Beispiel #7
0
void
KeymapWindow::_FillSystemMaps()
{
	BListItem* item;
	while ((item = fSystemListView->RemoveItem(static_cast<int32>(0))))
		delete item;

	// TODO: common keymaps!
	BPath path;
	if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
		return;

	path.Append("Keymaps");

	BDirectory directory;
	entry_ref ref;

	if (directory.SetTo(path.Path()) == B_OK) {
		while (directory.GetNextRef(&ref) == B_OK) {
			fSystemListView->AddItem(
				new KeymapListItem(ref, B_TRANSLATE_NOCOLLECT(ref.name)));
		}
	}

	fSystemListView->SortItems(&compare_key_list_items);
}
void
DefaultPartitionPage::_GetTimeoutLabel(int32 timeout, BString& label)
{
	const char* text = B_TRANSLATE_NOCOLLECT(get_label_for_timeout(timeout));
	label = B_TRANSLATE("Timeout: %s");
	label.ReplaceFirst("%s", text);
}
SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
	BMailAccountSettings& accountSettings)
	:
	BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
		| B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
		| B_MAIL_PROTOCOL_HAS_HOSTNAME
#ifdef USE_SSL
		| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
		)
{
#if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS)
	static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted");
	static const char* kSSLStr = B_TRANSLATE_MARK("SSL");
	static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS");
#endif

#ifdef USE_SSL
	AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr));
	AddFlavor(B_TRANSLATE(kSSLStr));
	AddFlavor(B_TRANSLATE(kSTARTTLSStr));
#endif

	AddAuthMethod(B_TRANSLATE("None"), false);
	AddAuthMethod(B_TRANSLATE("ESMTP"));
	AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);

	BTextControl *control = (BTextControl *)(FindView("host"));
	control->SetLabel(B_TRANSLATE("SMTP server:"));

	// Reset the dividers after changing one
	float widestLabel = 0;
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5);
	}
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			text->SetDivider(widestLabel);
	}

	BMenuField *field = (BMenuField *)(FindView("auth_method"));
	field->SetDivider(widestLabel);

	SetTo(settings);

	fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
		false, BPrivate::default_mail_out_directory().Path());
	fFileView->SetTo(&settings.Settings(), NULL);
	AddChild(fFileView);
	float w, h;
	BMailProtocolConfigView::GetPreferredSize(&w, &h);
	fFileView->MoveBy(0, h - 10);
	GetPreferredSize(&w, &h);
	ResizeTo(w, h);
}
void
AntialiasingSettingsView::_BuildAntialiasingMenu()
{
	fAntialiasingMenu = new BPopUpMenu(B_TRANSLATE("Antialiasing menu"));

	BMessage* message = new BMessage(kMsgSetAntialiasing);
	message->AddBool("antialiasing", false);

	BMenuItem* item
		= new BMenuItem(B_TRANSLATE_NOCOLLECT(kGrayscaleLabel), message);

	fAntialiasingMenu->AddItem(item);

	message = new BMessage(kMsgSetAntialiasing);
	message->AddBool("antialiasing", true);

	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kSubpixelLabel), message);

	fAntialiasingMenu->AddItem(item);
}
void
AntialiasingSettingsView::_BuildHintingMenu()
{
	fHintingMenu = new BPopUpMenu(B_TRANSLATE("Hinting menu"));

	BMessage* message = new BMessage(kMsgSetHinting);
	message->AddInt8("hinting", HINTING_MODE_OFF);
	fHintingMenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(kNoHintingLabel),
		message));

	message = new BMessage(kMsgSetHinting);
	message->AddInt8("hinting", HINTING_MODE_ON);
	fHintingMenu->AddItem(new BMenuItem(
		B_TRANSLATE_NOCOLLECT(kFullHintingLabel), message));

	message = new BMessage(kMsgSetHinting);
	message->AddInt8("hinting", HINTING_MODE_MONOSPACED_ONLY);
	fHintingMenu->AddItem(new BMenuItem(
		B_TRANSLATE_NOCOLLECT(kMonospacedHintingLabel), message));
}
void
BluetoothSettingsView::_BuildConnectionPolicy()
{
	BMessage* message = NULL;
	BMenuItem* item = NULL;

	fPolicyMenu = new BPopUpMenu(B_TRANSLATE("Policy..."));

	message = new BMessage(kMsgSetConnectionPolicy);
	message->AddInt8("Policy", 1);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kAllLabel), message);
	fPolicyMenu->AddItem(item);

	message = new BMessage(kMsgSetConnectionPolicy);
	message->AddInt8("Policy", 2);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kTrustedLabel), message);
	fPolicyMenu->AddItem(item);

	message = new BMessage(kMsgSetConnectionPolicy);
	message->AddInt8("Policy", 3);
	item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kAlwaysLabel), NULL);
	fPolicyMenu->AddItem(item);
}
status_t
PrintServerApp::GetSupportedSuites(BMessage* msg)
{
	msg->AddString("suites", "suite/vnd.OpenBeOS-printserver");

	static bool localized = false;
	if (!localized) {
		localized = true;
		for (int i = 0; prop_list[i].name != NULL; i ++)
			prop_list[i].usage = B_TRANSLATE_NOCOLLECT(prop_list[i].usage);
	}

	BPropertyInfo prop_info(prop_list);
	msg->AddFlat("messages", &prop_info);

	return Inherited::GetSupportedSuites(msg);
}
Beispiel #14
0
BString
ScreenshotWindow::_FindValidFileName(const char* name)
{
	BString baseName(name);

	if (!fExtension.IsEmpty())
		baseName.RemoveLast(fExtension);

	if (!fLastSelectedPath)
		return baseName;

	BPath orgPath(_GetDirectory());
	if (orgPath == NULL)
		return baseName;

	fExtension = fUtility.FileNameExtension(fImageFileType);

	BPath outputPath = orgPath;
	BString fileName;
	fileName << baseName << fExtension;
	outputPath.Append(fileName);

	if (!BEntry(outputPath.Path()).Exists())
		return fileName;

	if (baseName.FindFirst(B_TRANSLATE_NOCOLLECT(
			fUtility.sDefaultFileNameBase)) == 0)
		baseName.SetTo(fUtility.sDefaultFileNameBase);

	BEntry entry;
	int32 index = 1;

	do {
		fileName = "";
		fileName << baseName << index++ << fExtension;
		outputPath.SetTo(orgPath.Path());
		outputPath.Append(fileName);
		entry.SetTo(outputPath.Path());
	} while (entry.Exists());

	return fileName;
}
void
AntialiasingSettingsView::_SetCurrentHinting()
{
	const char* label;
	switch (fCurrentHinting) {
		case HINTING_MODE_OFF:
			label = kNoHintingLabel;
			break;
		case HINTING_MODE_ON:
			label = kFullHintingLabel;
			break;
		case HINTING_MODE_MONOSPACED_ONLY:
			label = kMonospacedHintingLabel;
			break;
		default:
			return;
	}

	BMenuItem *item = fHintingMenu->FindItem(B_TRANSLATE_NOCOLLECT(label));
	if (item != NULL)
		item->SetMarked(true);
}
SettingsView::SettingsView(MouseSettings& settings)
	: BBox("main_view"),
	fSettings(settings)
{
	// Add the "Mouse Type" pop up menu
	fTypeMenu = new BPopUpMenu("unknown");
	fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("1-Button"),
		new BMessage(kMsgMouseType)));
	fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("2-Button"),
		new BMessage(kMsgMouseType)));
	fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("3-Button"),
		new BMessage(kMsgMouseType)));

	BMenuField* typeField = new BMenuField(B_TRANSLATE("Mouse type:"),
		fTypeMenu);
	typeField->SetAlignment(B_ALIGN_RIGHT);

	// Create the "Double-click speed slider...
	fClickSpeedSlider = new BSlider("double_click_speed",
		B_TRANSLATE("Double-click speed"), new BMessage(kMsgDoubleClickSpeed),
		0, 1000, B_HORIZONTAL);
	fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fClickSpeedSlider->SetHashMarkCount(5);
	fClickSpeedSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	// Create the "Mouse Speed" slider...
	fMouseSpeedSlider = new BSlider("mouse_speed", B_TRANSLATE("Mouse speed"),
		new BMessage(kMsgMouseSpeed), 0, 1000, B_HORIZONTAL);
	fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fMouseSpeedSlider->SetHashMarkCount(7);
	fMouseSpeedSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	// Create the "Mouse Acceleration" slider...
	fAccelerationSlider = new BSlider("mouse_acceleration",
		B_TRANSLATE("Mouse acceleration"),
		new BMessage(kMsgAccelerationFactor), 0, 1000, B_HORIZONTAL);
	fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fAccelerationSlider->SetHashMarkCount(5);
	fAccelerationSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	// Mouse image...
	fMouseView = new MouseView(fSettings);

	// Create the "Double-click test area" text box...
	BTextControl* doubleClickTextControl = new BTextControl(NULL,
		B_TRANSLATE("Double-click test area"), NULL);
	doubleClickTextControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);

	// Add the "Mouse focus mode" pop up menu
	fFocusMenu = new BPopUpMenu(B_TRANSLATE("Click to focus and raise"));

	const char *focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"),
		B_TRANSLATE_MARK("Click to focus"),
		B_TRANSLATE_MARK("Focus follows mouse")};
	const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE,
										B_FOCUS_FOLLOWS_MOUSE};

	for (int i = 0; i < 3; i++) {
		BMessage* message = new BMessage(kMsgMouseFocusMode);
		message->AddInt32("mode", focusModes[i]);

		fFocusMenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(focusLabels[i]),
			message));
	}

	BMenuField* focusField = new BMenuField(B_TRANSLATE("Focus mode:"),
		fFocusMenu);
	focusField->SetAlignment(B_ALIGN_RIGHT);

	// Add the "Focus follows mouse mode" pop up menu
	fFocusFollowsMouseMenu = new BPopUpMenu(B_TRANSLATE("Normal"));

	const char *focusFollowsMouseLabels[] = {B_TRANSLATE_MARK("Normal"),
		B_TRANSLATE_MARK("Warp"), B_TRANSLATE_MARK("Instant warp")};
	const mode_focus_follows_mouse focusFollowsMouseModes[] =
		{B_NORMAL_FOCUS_FOLLOWS_MOUSE, B_WARP_FOCUS_FOLLOWS_MOUSE,
			B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE};

	for (int i = 0; i < 3; i++) {
		BMessage* message = new BMessage(kMsgFollowsMouseMode);
		message->AddInt32("mode_focus_follows_mouse",
			focusFollowsMouseModes[i]);

		fFocusFollowsMouseMenu->AddItem(new BMenuItem(
			B_TRANSLATE_NOCOLLECT(focusFollowsMouseLabels[i]), message));
	}

	BMenuField* focusFollowsMouseField = new BMenuField(
		"Focus follows mouse mode:", fFocusFollowsMouseMenu);
	focusFollowsMouseField->SetAlignment(B_ALIGN_RIGHT);

	// Add the "Click-through" check box
	fAcceptFirstClickBox = new BCheckBox(B_TRANSLATE("Accept first click"),
		new BMessage(kMsgAcceptFirstClick));

	// dividers
	BBox* hdivider = new BBox(
		BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
			B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
	hdivider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));

	BBox* vdivider = new BBox(
		BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
			B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
	vdivider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

	// Build the layout
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
		.AddGroup(B_HORIZONTAL, 10)
			.AddGroup(B_VERTICAL, 10, 1)
				.AddGroup(B_HORIZONTAL, 10)
					.AddGlue()
					.Add(typeField)
					.AddGlue()
				.End()
				.AddGlue()
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
					.AddGlue()
					.Add(fMouseView)
					.AddGlue()
				)
				.AddGlue()
				.Add(doubleClickTextControl)
			.End()
			.Add(hdivider)
			.AddGroup(B_VERTICAL, 5, 3)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
					.Add(fClickSpeedSlider)
				)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
					.Add(fMouseSpeedSlider)
				)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
					.Add(fAccelerationSlider)
				)
			.End()
		.End()
		.Add(vdivider)
		.AddGroup(B_HORIZONTAL, 10)
			.Add(focusField)
			.AddGlue()
			.AddGroup(B_VERTICAL, 0)
				.Add(fAcceptFirstClickBox)
			.End()
		.End()
		.SetInsets(5, 5, 5, 5)
	);
}
Beispiel #17
0
ScreenshotWindow::ScreenshotWindow(const Utility& utility, bool silent,
	bool clipboard)
	:
	BWindow(BRect(0, 0, 200.0, 100.0), B_TRANSLATE_SYSTEM_NAME("Screenshot"),
		B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AVOID_FRONT
			| B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS
			| B_CLOSE_ON_ESCAPE),
	fUtility(utility),
	fDelayControl(NULL),
	fScreenshot(NULL),
	fOutputPathPanel(NULL),
	fLastSelectedPath(NULL),
	fSettingsWindow(NULL),
	fDelay(0),
	fIncludeBorder(false),
	fIncludeCursor(false),
	fGrabActiveWindow(false),
	fOutputFilename(NULL),
	fExtension(""),
	fImageFileType(B_PNG_FORMAT)
{
	// _ReadSettings() needs a valid fOutputPathMenu
	fOutputPathMenu = new BMenu(B_TRANSLATE("Please select"));
	_ReadSettings();

	// _NewScreenshot() needs a valid fNameControl
	BString name(B_TRANSLATE_NOCOLLECT(fUtility.sDefaultFileNameBase));
	name << 1;
	name = _FindValidFileName(name.String());
	fNameControl = new BTextControl("", B_TRANSLATE("Name:"), name, NULL);

	// Check if fUtility contains valid data
	if (fUtility.wholeScreen == NULL) {
		_NewScreenshot(silent, clipboard, true);
		return;
	}

	fScreenshot = fUtility.MakeScreenshot(fIncludeCursor, fGrabActiveWindow,
		fIncludeBorder);

	fActiveWindow = new BCheckBox(B_TRANSLATE("Capture active window"),
		new BMessage(kActiveWindow));
	if (fGrabActiveWindow)
		fActiveWindow->SetValue(B_CONTROL_ON);

	fWindowBorder = new BCheckBox(B_TRANSLATE("Include window border"),
		new BMessage(kIncludeBorder));
	if (fIncludeBorder)
		fWindowBorder->SetValue(B_CONTROL_ON);
	if (!fGrabActiveWindow)
		fWindowBorder->SetEnabled(false);

	fShowCursor = new BCheckBox(B_TRANSLATE("Include mouse pointer"),
		new BMessage(kIncludeCursor));
	if (fIncludeCursor)
		fShowCursor->SetValue(B_CONTROL_ON);

	BString delay;
	delay << fDelay / 1000000;
	fDelayControl = new BTextControl("", B_TRANSLATE("Delay:"), delay.String(),
		NULL);
	_DisallowChar(fDelayControl->TextView());
	fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT);
	BStringView* seconds = new BStringView("", B_TRANSLATE("seconds"));
	seconds->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	BMenuField* menuLocation = new BMenuField(B_TRANSLATE("Save in:"),
		fOutputPathMenu);
	menuLocation->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	fTranslatorMenu = new BMenu(B_TRANSLATE("Please select"));
	_SetupTranslatorMenu();
	BMenuField* menuFormat = new BMenuField(B_TRANSLATE("Save as:"),
		fTranslatorMenu);
	menuFormat->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	BButton* showSettings =  new BButton("",
		B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kSettings));
	showSettings->SetExplicitAlignment(
		BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));

	BBox* divider = new BBox(B_FANCY_BORDER, NULL);
	divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

	BButton* saveScreenshot  = new BButton("", B_TRANSLATE("Save"),
		new BMessage(kSaveScreenshot));

	const float kSpacing = be_control_look->DefaultItemSpacing();
	const float kLabelSpacing = be_control_look->DefaultLabelSpacing();

	fPreview = new BView("preview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	BBox* previewBox = new BBox(B_FANCY_BORDER, fPreview);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
				B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
			.Add(previewBox)
			.AddGroup(B_VERTICAL, 0)
				.Add(fActiveWindow)
				.Add(fWindowBorder)
				.Add(fShowCursor)
				.AddStrut(kSpacing)
				.AddGrid(0.0, kSpacing / 2)
					.Add(fDelayControl->CreateLabelLayoutItem(), 0, 0)
					.Add(fDelayControl->CreateTextViewLayoutItem(), 1, 0)
					.Add(BSpaceLayoutItem::CreateHorizontalStrut(kLabelSpacing),
						2, 0)
					.Add(seconds, 3, 0)
					.Add(fNameControl->CreateLabelLayoutItem(), 0, 1)
					.Add(fNameControl->CreateTextViewLayoutItem(), 1, 1, 3, 1)
					.Add(menuLocation->CreateLabelLayoutItem(), 0, 2)
					.Add(menuLocation->CreateMenuBarLayoutItem(), 1, 2, 3, 1)
					.Add(menuFormat->CreateLabelLayoutItem(), 0, 3)
					.Add(menuFormat->CreateMenuBarLayoutItem(), 1, 3, 3, 1)
				.End()
				.AddStrut(kSpacing / 2)
				.Add(showSettings)
				.AddGlue()
			.End()
		.End()
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
			.Add(new BButton("", B_TRANSLATE("Copy to clipboard"),
				new BMessage(B_COPY)))
			.Add(new BButton("", B_TRANSLATE("New screenshot"),
				new BMessage(kNewScreenshot)))
			.AddGlue()
			.Add(saveScreenshot);

	saveScreenshot->MakeDefault(true);

	_UpdatePreviewPanel();
	_UpdateFilenameSelection();

	CenterOnScreen();
	Show();
}
Beispiel #18
0
APRView::APRView(const char* name)
	:
	BView(name, B_WILL_DRAW)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

#if 0
	fDecorMenu = new BMenu("Window Style");
	int32 decorCount = fDecorUtil->CountDecorators();
	DecorInfo* decor = NULL;
	if (decorCount > 1) {
		for (int32 i = 0; i < decorCount; i++) {
			decor = fDecorUtil->GetDecorator(i);
			if (!decor)
				continue;
			fDecorMenu->AddItem(new BMenuItem(decor->Name().String(),
				new BMessage(DECORATOR_CHANGED)));
		}

		BMenuField* field = new BMenuField("Window Style", fDecorMenu);
		// TODO: use this menu field.
	}
	BMenuItem* marked = fDecorMenu->ItemAt(fDecorUtil->IndexOfCurrentDecorator());
	if (marked)
		marked->SetMarked(true);
	else {
		marked = fDecorMenu->FindItem("Default");
		if (marked)
			marked->SetMarked(true);
	}
#endif

	LoadSettings();

	// Set up list of color attributes
	fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);

	fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true);
	fScrollView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	int32 count = color_description_count();
	for (int32 i = 0; i < count; i++) {
		const ColorDescription& description = *get_color_description(i);
		const char* text = B_TRANSLATE_NOCOLLECT(description.text);
		color_which which = description.which;
		fAttrList->AddItem(new ColorWhichItem(text, which, ui_color(which)));
	}

	BRect wellrect(0, 0, 50, 50);
	fColorPreview = new ColorPreview(wellrect, new BMessage(COLOR_DROPPED), 0);
	fColorPreview->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
		B_ALIGN_BOTTOM));

	fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0,
		"picker", new BMessage(UPDATE_COLOR));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(fScrollView, 10.0)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fColorPreview)
			.Add(fPicker)
			.End()
		.SetInsets(B_USE_WINDOW_SPACING);

	fColorPreview->Parent()->SetExplicitMaxSize(
		BSize(B_SIZE_UNSET, fPicker->Bounds().Height()));
	fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
}