Пример #1
0
AlertView::AlertView(BRect frame, const char *name)
	: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
	// we will wait 12 seconds until we send a message
	fSeconds(12)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fBitmap = InitIcon();

	BRect rect(60, 8, 400, 36);
	BStringView *stringView = new BStringView(rect, NULL,
		"Do you wish to keep these settings?");
	stringView->SetFont(be_bold_font);
	stringView->ResizeToPreferred();
	AddChild(stringView);

	rect = stringView->Frame();
	rect.OffsetBy(0, rect.Height());
	fCountdownView = new BStringView(rect, "countdown", NULL);
	UpdateCountdownView();
	fCountdownView->ResizeToPreferred();
	AddChild(fCountdownView);

	BButton* keepButton = new BButton(rect, "keep", "Keep",
		new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	keepButton->ResizeToPreferred();
	AddChild(keepButton);

	BButton* button = new BButton(rect, "undo", "Undo",
		new BMessage(BUTTON_UNDO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	AddChild(button);

	// we're resizing ourselves to the right size
	// (but we're not implementing GetPreferredSize(), bad style!)
	float width = stringView->Frame().right;
	if (fCountdownView->Frame().right > width)
		width = fCountdownView->Frame().right;
	if (width < Bounds().Width())
		width = Bounds().Width();

	float height
		= fCountdownView->Frame().bottom + 24 + button->Bounds().Height();
	ResizeTo(width, height);

	keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(),
		Bounds().Height() - 8 - keepButton->Bounds().Height());
	button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8,
		keepButton->Frame().top);

	keepButton->MakeDefault(true);
}
Пример #2
0
StringInputWindow::StringInputWindow(const char *title, const char *text, BMessage msg,
									BMessenger target)
	:	DWindow(BRect(0,0,300,200),title,B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
		fMessage(msg),
		fMessenger(target)
{
	MakeCenteredOnShow(true);
	BView *top = GetBackgroundView();
	
	BRect r = Bounds().InsetByCopy(10,10);
	r.bottom = r.top + 10;
	BRect textRect = r.OffsetToCopy(0,0);
	textRect.InsetBy(10,10);
	fTextView = new BTextView(r,"paneltext",textRect,B_FOLLOW_LEFT | B_FOLLOW_TOP);
	top->AddChild(fTextView);
	fTextView->MakeEditable(false);
	fTextView->SetText(text);
	fTextView->ResizeTo(r.Width(), 20.0 + (fTextView->CountLines() * 
									fTextView->TextHeight(0,fTextView->TextLength())));
	fTextView->SetViewColor(top->ViewColor());
	
	fText = new BTextControl(BRect(10,10,11,11),"nametext","", "", new BMessage);
	top->AddChild(fText);
	fText->ResizeToPreferred();
	fText->ResizeTo(Bounds().Width() - 20,fText->Bounds().Height());
	fText->SetDivider(0.0);
	fText->MoveTo(10,fTextView->Frame().bottom + 10.0);
	
	r = fText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	BButton *cancel = new BButton(r,"cancel","Cancel",
									new BMessage(B_QUIT_REQUESTED));
	cancel->ResizeToPreferred();
	top->AddChild(cancel);
	
	ResizeTo(300, cancel->Frame().bottom + 10);
	cancel->MoveTo( Bounds().Width() - (cancel->Bounds().Width() * 2) - 20,
					cancel->Frame().top);
	
	r = cancel->Frame();
	r.OffsetBy(r.Width() + 10,0);
	BButton *open = new BButton(r,"ok","OK", new BMessage(M_INVOKE));
	top->AddChild(open);
	open->MakeDefault(true);
	fText->MakeFocus(true);
	
	open->MakeDefault(true);
}
Пример #3
0
DocInfoWindow::DocInfoWindow(BMessage *docInfo)
	: HWindow(BRect(0, 0, 400, 250), "Document Information", B_TITLED_WINDOW_LOOK,
		B_MODAL_APP_WINDOW_FEEL, B_NOT_MINIMIZABLE),
	fDocInfo(docInfo)
{
	BRect bounds(Bounds());
	BView *background = new BView(bounds, "bachground", B_FOLLOW_ALL, B_WILL_DRAW);
	background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(background);

	bounds.InsetBy(10.0, 10.0);
	BButton *button = new BButton(bounds, "ok", "OK", new BMessage(OK_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right - button->Bounds().Width(),
		bounds.bottom - button->Bounds().Height());

	BRect buttonFrame(button->Frame());
	button = new BButton(buttonFrame, "cancel", "Cancel", new BMessage(CANCEL_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(buttonFrame.left - (button->Bounds().Width() + 10.0),
		buttonFrame.top);

	bounds.bottom = buttonFrame.top - 10.0;

#if HAVE_FULLVERSION_PDF_LIB
	BString permissions;
	if (_DocInfo()->FindString("permissions", &permissions) == B_OK)
		fPermissions.Decode(permissions.String());

	BTabView *tabView = new BTabView(bounds, "tabView");
	_SetupDocInfoView(_CreateTabPanel(tabView, "Information"));
	_SetupPasswordView(_CreateTabPanel(tabView, "Password"));
	_SetupPermissionsView(_CreateTabPanel(tabView, "Permissions"));

	background->AddChild(tabView);
#else
	BBox* panel = new BBox(bounds, "top_panel", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER);

	_SetupDocInfoView(panel);
	background->AddChild(panel);
#endif

	if (fTable->ChildAt(0))
		fTable->ChildAt(0)->MakeFocus();

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);

	SetSizeLimits(400.0, 10000.0, 250.0, 10000.0);
}
Пример #4
0
PasswordWindow::PasswordWindow()
	: BWindow(BRect(100, 100, 400, 230), "Enter password",
		B_NO_BORDER_WINDOW_LOOK, kPasswordWindowFeel
			/* TODO: B_MODAL_APP_WINDOW_FEEL should also behave correctly */,
		B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
		| B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_ALL_WORKSPACES)
{
	BView* topView = new BView(Bounds(), "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	BRect bounds(Bounds());
	bounds.InsetBy(10.0, 10.0);

	BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
	topView->AddChild(customBox);
	customBox->SetLabel("Unlock screen saver");

	bounds.top += 10.0;
	fPassword = new BTextControl(bounds, "password", "Enter password:"******"VeryLongPasswordPossible", B_FOLLOW_NONE);
	customBox->AddChild(fPassword);
	fPassword->MakeFocus(true);
	fPassword->ResizeToPreferred();
	fPassword->TextView()->HideTyping(true);
	fPassword->SetDivider(be_plain_font->StringWidth("Enter password:"******"unlock", "Unlock",
		new BMessage(kMsgUnlock), B_FOLLOW_NONE);
	customBox->AddChild(button);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->SetTarget(NULL, be_app);

	BRect frame = fPassword->Frame();
	button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);
	customBox->ResizeTo(frame.right + 10.0,	button->Frame().bottom + 10.0);

	frame = customBox->Frame();
	ResizeTo(frame.right + 10.0, frame.bottom + 10.0);

	BScreen screen(this);
	MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2,
		screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2);
}
Пример #5
0
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target,
		const BMessage* settings)
	: BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0);
	view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(view);

	int8 mode = kAsciiMode;
	if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
		settings->FindInt8("find_mode", &mode);

	// add the top widgets

	fMenu = new BPopUpMenu("mode");
	BMessage* message;
	BMenuItem* item;
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"),
		message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kAsciiMode);
	if (mode == kAsciiMode)
		item->SetMarked(true);
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", 
		"A menu item, as short as possible, noun is recommended if it is "
		"shorter than adjective."), message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kHexMode);
	if (mode == kHexMode)
		item->SetMarked(true);

	BRect rect = Bounds().InsetByCopy(5, 5);
	BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING,
		B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	view->AddChild(menuField);

	// add the bottom widgets

	BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"),
		new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->MoveTo(rect.right - button->Bounds().Width(),
		rect.bottom - button->Bounds().Height());
	view->AddChild(button);

	fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"),
		NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fCaseCheckBox->ResizeToPreferred();
	fCaseCheckBox->MoveTo(5, button->Frame().top);
	bool caseSensitive;
	if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
		if (settings == NULL
			|| settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
			caseSensitive = true;
	}
	fCaseCheckBox->SetValue(caseSensitive);
	view->AddChild(fCaseCheckBox);

	// and now those inbetween

	rect.top = menuField->Frame().bottom + 5;
	rect.bottom = fCaseCheckBox->Frame().top - 8;
	rect.InsetBy(2, 2);
	fTextView = new FindTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL);
	fTextView->SetWordWrap(true);
	fTextView->SetMode((find_mode)mode);
	fTextView->SetData(previous);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, false, false);
	view->AddChild(scrollView);

	ResizeTo(290, button->Frame().Height() * 3 + 30);

	SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width()
			+ 20, 32768, button->Frame().Height() * 3 + 10, 32768);
}
Пример #6
0
FileTypesWindow::FileTypesWindow(const BMessage& settings)
	: BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
	fNewTypeWindow(NULL)
{
	bool showIcons;
	bool showRule;
	if (settings.FindBool("show_icons", &showIcons) != B_OK)
		showIcons = true;
	if (settings.FindBool("show_rule", &showRule) != B_OK)
		showRule = false;

	// add the menu

	BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS,
		NULL, 'N', B_COMMAND_KEY));
	item->SetEnabled(false);

	BMenu* recentsMenu = BRecentFilesList::NewFileListMenu("Open" B_UTF8_ELLIPSIS,
		NULL, NULL, be_app, 10, false, NULL, kSignature);
	item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel));
	item->SetShortcut('O', B_COMMAND_KEY);
	menu->AddItem(item);
	menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS,
		new BMessage(kMsgOpenApplicationTypesWindow)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("About FileTypes" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
		'Q', B_COMMAND_KEY));
	menu->SetTargetForItems(be_app);
	menuBar->AddItem(menu);

	menu = new BMenu("Settings");
	item = new BMenuItem("Show icons in list", new BMessage(kMsgToggleIcons));
	item->SetMarked(showIcons);
	item->SetTarget(this);
	menu->AddItem(item);

	item = new BMenuItem("Show recognition rule", new BMessage(kMsgToggleRule));
	item->SetMarked(showRule);
	item->SetTarget(this);
	menu->AddItem(item);
	menuBar->AddItem(menu);

	// MIME Types list

	BRect rect = Bounds();
	rect.top = menuBar->Bounds().Height() + 1.0f;
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddType), B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height());
	topView->AddChild(button);

	rect = button->Frame();
	rect.OffsetBy(rect.Width() + 8.0f, 0.0f);
	fRemoveTypeButton = new BButton(rect, "remove", "Remove",
		new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM);
	fRemoveTypeButton->ResizeToPreferred();
	topView->AddChild(fRemoveTypeButton);

	rect.bottom = rect.top - 10.0f;
	rect.top = 10.0f;
	rect.left = 10.0f;
	rect.right -= B_V_SCROLL_BAR_WIDTH + 2.0f;
	if (rect.right < 180)
		rect.right = 180;

	fTypeListView = new MimeTypeListView(rect, "typeview", NULL, showIcons, false,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("scrollview", fTypeListView,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	topView->AddChild(scrollView);

	// "Icon" group

	font_height plainHeight;
	be_plain_font->GetHeight(&plainHeight);
	float height = ceilf(plainHeight.ascent + plainHeight.descent
		+ plainHeight.leading) + 2.0f;

	BFont font(be_bold_font);
	float labelWidth = font.StringWidth("Icon");
	font_height boldHeight;
	font.GetHeight(&boldHeight);

	BRect innerRect;
	fIconView = new TypeIconView(innerRect, "icon",
		B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
	fIconView->ResizeToPreferred();

	rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH;
	rect.right = rect.left + max_c(fIconView->Bounds().Width(), labelWidth) + 16.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent)
		+ max_c(fIconView->Bounds().Height(),
			button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f;
	rect.top -= 2.0f;
	fIconBox = new BBox(rect);
	fIconBox->SetLabel("Icon");
	topView->AddChild(fIconBox);

	innerRect.left = 8.0f;
	innerRect.top = plainHeight.ascent + 3.0f
		+ (rect.Height() - boldHeight.ascent - fIconView->Bounds().Height()) / 2.0f;
	if (innerRect.top + fIconView->Bounds().Height() > fIconBox->Bounds().Height() - 6.0f)
		innerRect.top = fIconBox->Bounds().Height() - 6.0f - fIconView->Bounds().Height();
	fIconView->MoveTo(innerRect.LeftTop());
	fIconBox->AddChild(fIconView);

	// "File Recognition" group

	BRect rightRect(rect);
	rightRect.left = rect.right + 8.0f;
	rightRect.right = topView->Bounds().Width() - 8.0f;
	fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT);
	fRecognitionBox->SetLabel("File recognition");
	topView->AddChild(fRecognitionBox);

	innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL);
	fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT);
	fExtensionLabel->ResizeToPreferred();
	fRecognitionBox->AddChild(fExtensionLabel);

	innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f;
	innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT);
	fRecognitionBox->AddChild(fAddExtensionButton);

	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove",
		new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT);
	fRecognitionBox->AddChild(fRemoveExtensionButton);

	innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	innerRect.left = 10.0f;
	innerRect.top = fAddExtensionButton->Frame().top + 2.0f;
	innerRect.bottom = innerRect.bottom - 2.0f;
		// take scrollview border into account
	fExtensionListView = new ExtensionListView(innerRect, "listview ext",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT);
	fExtensionListView->SetSelectionMessage(new BMessage(kMsgExtensionSelected));
	fExtensionListView->SetInvocationMessage(new BMessage(kMsgExtensionInvoked));

	scrollView = new BScrollView("scrollview ext", fExtensionListView,
		B_FOLLOW_LEFT_RIGHT, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	fRecognitionBox->AddChild(scrollView);

	innerRect.left = 8.0f;
	innerRect.top = innerRect.bottom + 10.0f;
	innerRect.right = fRecognitionBox->Bounds().right - 8.0f;
	innerRect.bottom = innerRect.top + 20.0f;
	fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "",
		new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT);
	//fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f);
	fRuleControl->Hide();
	fRecognitionBox->AddChild(fRuleControl);

	// "Description" group

	rect.top = rect.bottom + 8.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f;
	rect.right = rightRect.right;
	fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	fDescriptionBox->SetLabel("Description");
	topView->AddChild(fDescriptionBox);

	innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "",
		B_FOLLOW_LEFT_RIGHT);
	labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f;
	fInternalNameView->SetDivider(labelWidth);
	fInternalNameView->SetEnabled(false);
	fInternalNameView->ResizeToPreferred();
	fDescriptionBox->AddChild(fInternalNameView);

	innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f);
	fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "",
		new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT);
	fTypeNameControl->SetDivider(labelWidth);
	fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fDescriptionBox->ResizeBy(0, fInternalNameView->Bounds().Height()
		+ fTypeNameControl->Bounds().Height() * 2.0f);
	fDescriptionBox->AddChild(fTypeNameControl);

	innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f);
	fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "",
		new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT);
	fDescriptionControl->SetDivider(labelWidth);
	fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fDescriptionBox->AddChild(fDescriptionControl);

	// "Preferred Application" group

	rect = fDescriptionBox->Frame();
	rect.top = rect.bottom + 8.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent)
		+ button->Bounds().Height() + 14.0f;
	fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	fPreferredBox->SetLabel("Preferred application");
	topView->AddChild(fPreferredBox);

	innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.left = innerRect.right - button->StringWidth(
		"Same as" B_UTF8_ELLIPSIS) - 24.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fSameAsButton = new BButton(innerRect, "same as",
		"Same as" B_UTF8_ELLIPSIS,
		new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT);
	fPreferredBox->AddChild(fSameAsButton);

	innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f);
	fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS,
		new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT);
	fPreferredBox->AddChild(fSelectButton);

	menu = new BPopUpMenu("preferred");
	menu->AddItem(item = new BMenuItem("None",
		new BMessage(kMsgPreferredAppChosen)));
	item->SetMarked(true);

	innerRect.right = innerRect.left - 6.0f;
	innerRect.left = 8.0f;

	fPreferredField = new BMenuField(innerRect, "preferred", NULL, menu, true,
		B_FOLLOW_LEFT_RIGHT);
	float width;
	fPreferredField->GetPreferredSize(&width, &height);
	fPreferredField->ResizeTo(innerRect.Width(), height);
	fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f);

	fPreferredBox->AddChild(fPreferredField);

	// "Extra Attributes" group

	rect.top = rect.bottom + 8.0f;
	rect.bottom = topView->Bounds().Height() - 8.0f;
	fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT
		| B_FOLLOW_TOP_BOTTOM);
	fAttributeBox->SetLabel("Extra attributes");
	topView->AddChild(fAttributeBox);

	innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fAddAttributeButton = new BButton(innerRect, "add attr",
		"Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(fAddAttributeButton);

	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove",
		new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(fRemoveAttributeButton);
/*
	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	button = new BButton(innerRect, "push attr", "Push Up",
		new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(button);
*/
	innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	innerRect.left = 10.0f;
	innerRect.top = 8.0f + ceilf(boldHeight.ascent);
	innerRect.bottom = fAttributeBox->Bounds().bottom - 10.0f;
		// take scrollview border into account
	fAttributeListView = new AttributeListView(innerRect, "listview attr",
		B_FOLLOW_ALL);
	fAttributeListView->SetSelectionMessage(new BMessage(kMsgAttributeSelected));
	fAttributeListView->SetInvocationMessage(new BMessage(kMsgAttributeInvoked));

	scrollView = new BScrollView("scrollview attr", fAttributeListView,
		B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	fAttributeBox->AddChild(scrollView);

	SetSizeLimits(rightRect.left + 72.0f + font.StringWidth("jpg")
		+ font.StringWidth(fRecognitionBox->Label()), 32767.0f,
		rect.top + 2.0f * button->Bounds().Height() + boldHeight.ascent
		+ 32.0f + menuBar->Bounds().Height(), 32767.0f);

	_SetType(NULL);
	_ShowSnifferRule(showRule);

	BMimeType::StartWatching(this);
}
Пример #7
0
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
	:	BlockingWindow(BRect(0, 0, 300, 200), "Job Setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE),
	fPrinterName(printerName),
	fSetupMsg(msg)
{
	if (printerName)
		SetTitle(BString(printerName).Append(" Job Setup").String());

	int32 firstPage;
	fSetupMsg->FindInt32("first_page", &firstPage);

	int32 lastPage;
	fSetupMsg->FindInt32("last_page", &lastPage);
	bool allPages = firstPage == 1 && lastPage == LONG_MAX;

	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);

	fAll = new BRadioButton(bounds, "allPages", "Print all pages",
		new BMessage(ALL_PAGES_MGS));
	panel->AddChild(fAll);
	fAll->ResizeToPreferred();
	fAll->SetValue(allPages);

	bounds.OffsetBy(0.0, fAll->Bounds().Height() + 10.0);
	fRange = new BRadioButton(bounds, "pagesRange", "Print pages:",
		new BMessage(RANGE_SELECTION_MSG));
	panel->AddChild(fRange);
	fRange->ResizeToPreferred();
	fRange->SetValue(!allPages);

	bounds.OffsetBy(0.0, fRange->Bounds().Height() + 5.0);
	BRect rect(bounds);
	rect.right = be_plain_font->StringWidth("From: SomeSpaceHere");
	fFrom = new BTextControl(rect, "from", "From:", "SomeSpaceHere", NULL);
	panel->AddChild(fFrom);
	fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fFrom->ResizeToPreferred();
	fFrom->SetDivider(be_plain_font->StringWidth("From: "));
	fFrom->SetEnabled(!allPages);

	rect = fFrom->Frame();
	fTo = new BTextControl(rect, "to", "To:", "SomeSpaceHere", NULL);
	panel->AddChild(fTo);
	fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fTo->SetDivider(be_plain_font->StringWidth("To: "));
	fTo->MoveTo(fFrom->Frame().right + 10.0, fTo->Frame().top);
	fTo->SetEnabled(!allPages);

	BString buffer;
	buffer << firstPage;
	fFrom->SetText(buffer.String());

	buffer = "";
	buffer << lastPage;
	fTo->SetText(buffer.String());

	for (uint32 i = 0; i < '0'; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	for (uint32 i = '9' + 1; i < 255; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	bounds.OffsetBy(0.0, fTo->Bounds().Height() + 10.0);
	BBox *line = new BBox(BRect(bounds.left - 5.0, bounds.top, bounds.right + 5.0,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
	panel->AddChild(line);

	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fTo->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
Пример #8
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	: HWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK,
 		B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 		B_NOT_ZOOMABLE),
	 fResult(B_ERROR),
	 fSetupMsg(msg),
	 fAdvancedSettings(*msg),
	 fPrinterDirName(printerName)
{
	fExitSem 	= create_sem(0, "PageSetup");

	if (printerName)
		SetTitle(BString(printerName).Append(" page setup").String());

	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
		label = "Letter";

	int32 compression;
	fSetupMsg->FindInt32("pdf_compression", &compression);

	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BString setting_value;
	if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
		setting_value = "1.3";

	// Load font settings
	fFonts = new Fonts();
	fFonts->CollectFonts();
	BMessage fonts;
	if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
		fFonts->SetTo(&fonts);

	// add a *dialog* background
	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);
	bounds.right = 230.0;
	bounds.bottom = 160.0;
	fMarginView = new MarginView(bounds, int32(width), int32(height), margin,
		MarginUnit(units));
	panel->AddChild(fMarginView);
	fMarginView->SetResizingMode(B_FOLLOW_NONE);

	BPopUpMenu* m = new BPopUpMenu("Page size");
	m->SetRadioMode(true);

	bounds.OffsetBy(bounds.Width() + 10.0, 5.0);
	float divider = be_plain_font->StringWidth("PDF compatibility: ");
	fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m);
	panel->AddChild(fPageSizeMenu);
	fPageSizeMenu->ResizeToPreferred();
	fPageSizeMenu->SetDivider(divider);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		m->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("Orientation");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0);
	fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m);
	panel->AddChild(fOrientationMenu);
	fOrientationMenu->ResizeToPreferred();
	fOrientationMenu->SetDivider(divider);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		m->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("PDF compatibility");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0);
	fPDFCompatibilityMenu = new BMenuField(bounds, "pdf_compatibility",
		"PDF compatibility:", m);
	panel->AddChild(fPDFCompatibilityMenu);
	fPDFCompatibilityMenu->ResizeToPreferred();
	fPDFCompatibilityMenu->SetDivider(divider);
	fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
		BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
		m->AddItem(item);
		if (setting_value == pdf_compatibility[i])
			item->SetMarked(true);
	}

	bounds.OffsetBy(0.0, fPDFCompatibilityMenu->Bounds().Height() + 10.0);
	fPDFCompressionSlider = new BSlider(bounds, "pdf_compression",
		"Compression:", NULL, 0, 9);
	panel->AddChild(fPDFCompressionSlider);
	fPDFCompressionSlider->SetLimitLabels("None", "Best");
	fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fPDFCompressionSlider->SetValue(compression);
	fPDFCompressionSlider->ResizeToPreferred();

	bounds = Bounds();
	bounds.InsetBy(5.0, 0.0);
	bounds.top = MAX(fPDFCompressionSlider->Frame().bottom,
		fMarginView->Frame().bottom) + 10.0;
	BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT);
	panel->AddChild(line);

	bounds.InsetBy(5.0, 0.0);
	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fPDFCompressionSlider->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BButton *button = new BButton(bounds, NULL, "Fonts" B_UTF8_ELLIPSIS,
		new BMessage(FONTS_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(fMarginView->Frame().left, bounds.top);

	bounds = button->Frame();
	button = new BButton(bounds, NULL, "Advanced" B_UTF8_ELLIPSIS,
		new BMessage(ADVANCED_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right + 10, bounds.top);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
// SavePanel class
SavePanel::SavePanel(const char* name,
					 BMessenger* target,
					 entry_ref* startDirectory,
					 uint32 nodeFlavors,
					 bool allowMultipleSelection,
					 BMessage* message,
					 BRefFilter* filter,
					 bool modal,
					 bool hideWhenDone)
	: BFilePanel(B_SAVE_PANEL, target, startDirectory,
				 nodeFlavors, allowMultipleSelection,
				 message, filter, modal, hideWhenDone),
	  BHandler(name),
	  fConfigWindow(NULL),
	  fFormatM(NULL),
	  fExportMode(EXPORT_MODE_ICON_RDEF)
{
	BWindow* window = Window();
	if (!window || !window->Lock())
		return;

	window->SetTitle(B_TRANSLATE("Save image"));

	// add this instance as BHandler to the window's looper
	window->AddHandler(this);
	
	// find a couple of important views and mess with their layout
	BView* background = Window()->ChildAt(0);
	BButton* cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
	BView* textview = background->FindView("text view");
	BScrollBar* hscrollbar = dynamic_cast<BScrollBar*>(background->FindView("HScrollBar"));

	if (!background || !cancel || !textview || !hscrollbar) {
		printf("SavePanel::SavePanel() - couldn't find necessary controls.\n");
		return;
	}

	_BuildMenu();

	BRect rect = textview->Frame();
	rect.top = cancel->Frame().top;
	font_height fh;
	be_plain_font->GetHeight(&fh);
	rect.bottom = rect.top + fh.ascent + fh.descent + 5.0;

	fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"),
								fFormatM, true,	
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
								B_WILL_DRAW | B_NAVIGABLE);
	fFormatMF->SetDivider(be_plain_font->StringWidth(
		B_TRANSLATE("Format")) + 7);
	fFormatMF->MenuBar()->ResizeToPreferred();
	fFormatMF->ResizeToPreferred();

	float height = fFormatMF->Bounds().Height() + 8.0;

	// find all the views that are in the way and
	// move up them up the height of the menu field
	BView *poseview = background->FindView("PoseView");
	if (poseview) poseview->ResizeBy(0, -height);
	BButton *insert = (BButton *)background->FindView("default button");
	if (hscrollbar) hscrollbar->MoveBy(0, -height);
	BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
	if (vscrollbar) vscrollbar->ResizeBy(0, -height);
	BView *countvw = (BView *)background->FindView("CountVw");
	if (countvw) countvw->MoveBy(0, -height);
	textview->MoveBy(0, -height);

#if HAIKU_TARGET_PLATFORM_DANO
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top + 2);
#else
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top);
#endif

	background->AddChild(fFormatMF);

	// Build the "Settings" button relative to the format menu
	rect = cancel->Frame();
	rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top);
	fSettingsB = new BButton(rect, "settings", 
							 B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
							 new BMessage(MSG_SETTINGS),
							 B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
							 B_WILL_DRAW | B_NAVIGABLE);
	fSettingsB->ResizeToPreferred();
	background->AddChild(fSettingsB);
	fSettingsB->SetTarget(this);

	textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left,
					   textview->Frame().Height());

	// Make sure the smallest window won't draw the "Settings" button over anything else
	float minWindowWidth = textview->Bounds().Width()
							+ cancel->Bounds().Width()
							+ (insert ? insert->Bounds().Width() : 0.0)
							+ 90;
	Window()->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
	if (Window()->Bounds().IntegerWidth() + 1 < minWindowWidth)
		Window()->ResizeTo(minWindowWidth, Window()->Bounds().Height());


	window->Unlock();
}
Пример #10
0
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj)
	:	DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE),
		fProject(proj),
		fDirty(false)
	
{
	if (!fProject)
		debugger("Bad project given to Project Settings window");
	
	fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE);
	
	BMessenger msgr(this);
	entry_ref projfolder_ref;
	BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref);
	fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE,
								true, new BMessage(M_ADD_PATH),fRefFilter);
	
	fAutolock = new BAutolock(fProject);
	
	AddCommonFilter(new EscapeCancelFilter());
	
	BView *top = GetBackgroundView();
	
	BRect r(Bounds());
	fTabView = new BTabView(r,"tabview");
	top->AddChild(fTabView);
	
	r.InsetBy(5,5);
	r.bottom -= fTabView->TabHeight();
	
	BRect bounds = r.OffsetToCopy(0,0);
	
	fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW);
	fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTabView->AddTab(fGeneralView);
	
	r.right -= 10.0;
	fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"),
										fProject->GetTargetName(),
										new BMessage(M_TARGET_NAME_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fGeneralView->AddChild(fTargetText);
	
	float pwidth, pheight;
	fTargetText->GetPreferredSize(&pwidth, &pheight);
	fTargetText->ResizeTo(r.Width(),pheight);
	r.bottom = r.top + pheight;
	fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0);
	
	r = fTargetText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	
	BMenu *menu = new BMenu(TR("Target Type"));
	menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE)));
	
	r.right = (bounds.right - 5.0) / 2.0;
	r.bottom = r.top + 25;
	fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu);
	fGeneralView->AddChild(fTypeField);
	fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0);
	
	SetToolTip(fTypeField,TR("The kind of program you want to build"));
	
	menu->SetTargetForItems(this);
	menu->SetLabelFromMarked(true);
	
	BMenuItem *item = menu->ItemAt(fProject->TargetType());
	if (item)
		item->SetMarked(true);
	
	r.OffsetBy(0,r.Height() + 10.0);
	
	BStringView *label = new BStringView(r,"label",TR("Include Paths:"));
	label->ResizeToPreferred();
	fGeneralView->AddChild(label);
	
	r = label->Frame();
	r.OffsetBy(0,r.Height() + 5.0);
	
	// We create a button now so that the list expands to fill the entire window
	// while leaving space for the two buttons at the bottom. Note that we do not
	// actually add the button to the window until later to preserve proper
	// keyboard navigation order
	BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"),
								new BMessage(M_SHOW_ADD_PATH),
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	add->ResizeToPreferred();
	add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height());
	
	r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH;
	r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT;
	fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder());
	BScrollView *scrollView = new BScrollView("scrollview",fIncludeList,
											B_FOLLOW_ALL,0, true, true);
	scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fGeneralView->AddChild(scrollView);
	
	float width = 0.0;
	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++)
	{
		BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String());
		float strwidth = fIncludeList->StringWidth(item->Text());
		width = MAX(width, strwidth);
		fIncludeList->AddItem(item);
	}
	
	if (width > fIncludeList->Bounds().Width())
	{
		BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL);
		hbar->SetRange(0.0, width - fIncludeList->Bounds().Width());
	}
	
	SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files"));
	
	fGeneralView->AddChild(add);
	
	BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"),
								new BMessage(M_REMOVE_PATH), 
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	remove->ResizeToPreferred();
	remove->MoveTo(add->Frame().right + 10.0, add->Frame().top);
	fGeneralView->AddChild(remove);
	
	r = bounds;
	fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW);
	fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTabView->AddTab(fBuildView);
	
	menu = new BMenu(TR("Optimization"));
	menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE)));
	
	r.right = (bounds.right - 5.0) / 2.0;
	r.bottom = r.top + 25;
	fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu);
	fBuildView->AddChild(fOpField);
	fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0);
	
	SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked."));
	
	menu->SetTargetForItems(this);
	menu->SetLabelFromMarked(true);
	
	item = menu->ItemAt(fProject->OpLevel());
	if (item)
		item->SetMarked(true);
	
	r.right = bounds.right - 10.0;
	r.OffsetTo(5, fOpField->Frame().bottom + 5);
	fOpSizeBox = new BCheckBox(r,"opsizebox",TR("Optimize for size over speed"),
								new BMessage(M_TOGGLE_OPSIZE));
	fOpSizeBox->ResizeToPreferred();
	fBuildView->AddChild(fOpSizeBox);
	r = fOpSizeBox->Frame();
	if (fProject->OpForSize())
		fOpSizeBox->SetValue(B_CONTROL_ON);
	
	if (fProject->Debug())
	{
		fOpField->SetEnabled(false);
		fOpSizeBox->SetEnabled(false);
	}
	
	r.OffsetBy(0, r.Height() + 10);
	fDebugBox = new BCheckBox(r,"debugbox",TR("Build debugging information"),
								new BMessage(M_TOGGLE_DEBUG));
	fDebugBox->ResizeToPreferred();
	if (fProject->Debug())
		fDebugBox->SetValue(B_CONTROL_ON);
	fBuildView->AddChild(fDebugBox);
	SetToolTip(fDebugBox,TR("Check this if you want to use your program in a debugger during development."
							"You'll want to rebuild your project after change this."));
	
	r.OffsetBy(0, r.Height());
	fProfileBox = new BCheckBox(r,"profilebox",TR("Build profiling information"),
								new BMessage(M_TOGGLE_PROFILE));
	fProfileBox->ResizeToPreferred();
	if (fProject->Profiling())
		fProfileBox->SetValue(B_CONTROL_ON);
	fBuildView->AddChild(fProfileBox);
	SetToolTip(fProfileBox,TR("Check this if you want to use your program "
								"with gprof or bprof for profiling."));
	
	
	r.OffsetBy(0, r.Height() + 10.0);
	r.right = bounds.right - 10.0;
	fCompileText = new AutoTextControl(r,"extracc","Extra Compiler Options:",
										fProject->ExtraCompilerOptions(),
										new BMessage(M_CCOPTS_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fBuildView->AddChild(fCompileText);
	fCompileText->SetDivider(fCompileText->StringWidth(fCompileText->Label()) + 5.0);
	SetToolTip(fCompileText,TR("Extra GCC flags you wish included when each file is compiled."));
	
	r = fCompileText->Frame();
	r.OffsetBy(0,r.Height() + 10);
	fLinkText = new AutoTextControl(r,"extrald",TR("Extra Linker Options:"),
										fProject->ExtraLinkerOptions(),
										new BMessage(M_LDOPTS_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fBuildView->AddChild(fLinkText);
	fLinkText->SetDivider(fCompileText->Divider());
	SetToolTip(fLinkText,TR("Extra GCC linker flags you wish included when your project is linked."));
	
	fTabView->Select(0L);
	
	fBuildView->ResizeTo(fGeneralView->Bounds().Width(),fGeneralView->Bounds().Height());

	fTargetText->MakeFocus(true);
}
Пример #11
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	:	BlockingWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE),
	fSetupMsg(msg),
	fPrinterDirName(printerName)
{
	if (printerName)
		SetTitle(BString(printerName).Append(" Page setup").String());

	// load orientation
	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	// load page rect
	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("preview:paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("preview:paper_size", &label) != B_OK)
		label = "Letter";

	// Load units
	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("preview:printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);
	bounds.right = 230.0;
	bounds.bottom = 160.0;
	fMarginView = new MarginView(bounds, int32(width), int32(height), margin,
		MarginUnit(units));
	panel->AddChild(fMarginView);
	fMarginView->SetResizingMode(B_FOLLOW_NONE);

	BPopUpMenu* m = new BPopUpMenu("Page size");
	m->SetRadioMode(true);

	bounds.OffsetBy(bounds.Width() + 10.0, 5.0);
	float divider = be_plain_font->StringWidth("Orientation: ");
	fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m);
	panel->AddChild(fPageSizeMenu);
	fPageSizeMenu->ResizeToPreferred();
	fPageSizeMenu->SetDivider(divider);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		m->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("Orientation");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0);
	fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m);
	panel->AddChild(fOrientationMenu);
	fOrientationMenu->ResizeToPreferred();
	fOrientationMenu->SetDivider(divider);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		m->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	float scale0;
	BString scale;
	if (fSetupMsg->FindFloat("scale", &scale0) == B_OK)
		scale << (int)scale0;
	else
		scale = "100";

	bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0);
	bounds.right -= 30.0;
	fScaleControl = new BTextControl(bounds, "scale", "Scale [%]:",
		scale.String(), NULL);
	panel->AddChild(fScaleControl);
	fScaleControl->ResizeToPreferred();
	fScaleControl->SetDivider(divider);

	for (uint32 i = 0; i < '0'; i++)
		fScaleControl->TextView()->DisallowChar(i);

	for (uint32 i = '9' + 1; i < 255; i++)
		fScaleControl->TextView()->DisallowChar(i);

	fScaleControl->TextView()->SetMaxBytes(3);

	bounds = Bounds();
	bounds.InsetBy(5.0, 0.0);
	bounds.top =
		MAX(fScaleControl->Frame().bottom, fMarginView->Frame().bottom) + 10.0;
	BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT);
	panel->AddChild(line);

	bounds.InsetBy(5.0, 0.0);
	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fScaleControl->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
Пример #12
0
void OptionsPanel :: AttachedToWindow( void )
{
	SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ) ;
	
	BRect fr ;
	if( Parent() )
		fr = Parent()->Frame() ;
	else
		fr = Window()->Frame() ;
	
	fr.top = Frame().top ;
	fr.right = fr.Width() ;
	fr.left = 0 ;  
	fr.bottom = fr.top + 5 ; // Set Later
			
	MoveTo( fr.left, fr.top ) ;
	ResizeTo( fr.Width(), fr.Height() ) ;

	font_height fh ;
	GetFontHeight( &fh ) ;
	
	BRect r ;
	
	r.top = 5 ;
	r.left = fr.Width() * 2/3 ;

	r.right   = r.left + ( r.Height() * 2 ) + 1  ; 
	r.bottom  = r.top + 10 ;
	
	BButton * addButton = new
					BButton( r, "Add", "+",
							  new BMessage( Messages::AddPanel ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( addButton ) ;

	float h , w ;
	addButton->GetPreferredSize( &h, &w ) ;
	if( h > w )
		h = w ;
	else
		w = h ;
	addButton->ResizeTo( w, h ) ;
	
	r.left += ( w + 4 ) ;
	r.right += ( w + 4 ) ; 
	BButton * rmButton = new BButton( r, "Remove", "-",
							  new BMessage( Messages::RemovePanel ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( rmButton ) ;
	rmButton->ResizeTo( w, h ) ;

	r.left = 10 ;
	r.top = addButton->Frame().bottom + 2 ;

	r.right   = r.left + 10 ; 
	r.bottom  = r.top + 10 ;
	
	fpMaxDepthCheck = new BCheckBox( r, "depth_check", kMaxDepthString ,
							NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( fpMaxDepthCheck ) ;
	fpMaxDepthCheck->ResizeToPreferred() ;

	r = fpMaxDepthCheck->Frame() ;
 	float centre = r.top + r.Height()/2 ;

	r.left   = r.right + 5 ;
	r.top    = centre - (fh.ascent + fh.descent + fh.leading) * 3/4 ;
	r.bottom = centre + (fh.ascent + fh.descent + fh.leading) * 3/4 ;
	r.right  = r.left + StringWidth( "xx37xx" ) ;

	fpMaxDepthEdit = new EditBox( r, "depth_edit", B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( fpMaxDepthEdit ) ;

	r.top    = r.bottom + 7 ;
	r.bottom = r.top + 20 ;
	r.left   = 10 ;
	r.right  = r.left + 50 ;
	
	BButton * settingsButton = new BButton( r, "settings", "Settings" B_UTF8_ELLIPSIS,
								new BMessage( Messages::Settings ) ,
								B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( settingsButton ) ;
	settingsButton->ResizeToPreferred() ;
	settingsButton->SetTarget( Window() ) ;
		
	r.right = fr.Width() - 25 ;
	r.left  = r.right - 50 ;

	fpFindButton = new BButton( r, "go", "Find",
							  new BMessage( Messages::StartFind ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( fpFindButton ) ;
	fpFindButton->ResizeToPreferred() ;
	r = fpFindButton->Frame() ;
	fpFindButton->MoveTo( fr.Width() - 20 - r.Width(), r.top ) ;
	fpFindButton->SetTarget( Window() ) ;
	fpFindButton->MakeDefault(true) ;

	r = fpFindButton->Frame() ;
	r.bottom = r.top - 3 ;
	r.top = r.bottom - 8 ;
	fpPoleFrame = new ColouredView( r, "pole_frame" ) ;
	fpPoleFrame->SetViewColor( Colours::Grey60 ) ;
	AddChild( fpPoleFrame ) ;

	r.OffsetTo( 1 , 1 ) ;
	fpBarberPole = new BarberPole( r, "pole", B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	fpBarberPole->SetHighColor( WaitBarDisabledHighColor  ) ;
	fpBarberPole->SetLowColor ( WaitBarDisabledLowColor ) ;
	fpPoleFrame->AddChild( fpBarberPole ) ;
	fpPoleFrame->Hide() ;

	r = fpFindButton->Frame() ;

	fr.bottom = fr.top + r.bottom + 8 ;
	ResizeTo( fr.Width(), fr.Height() ) ;

	fr = addButton->Frame() ;
	addButton->MoveTo( r.left + 10, fr.top ) ;
	rmButton ->MoveTo( r.left + 17 + fr.Width(), fr.top ) ;
}
Пример #13
0
// constructor
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
                                   selected_color_mode mode,
                                   BWindow* window,
                                   BMessage* message, BHandler* target)
    : Panel(frame, "Pick Color",
            B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
            B_ASYNCHRONOUS_CONTROLS |
            B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE),
      fWindow(window),
      fMessage(message),
      fTarget(target)
{
    SetTitle(B_TRANSLATE("Pick a color"));

    fColorPickerView = new ColorPickerView("color picker", color, mode);

#if LIB_LAYOUT
    MButton* defaultButton = new MButton(B_TRANSLATE("OK"),
                                         new BMessage(MSG_DONE), this);

    // interface layout
    BView* topView = new VGroup (
        fColorPickerView,
        new MBorder (
            M_RAISED_BORDER, 5, "buttons",
            new HGroup (
                new Space(minimax(0.0, 0.0, 10000.0, 10000.0, 5.0)),
                new MButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                            this),
                new Space(minimax(5.0, 0.0, 10.0, 10000.0, 1.0)),
                defaultButton,
                new Space(minimax(2.0, 0.0, 2.0, 10000.0, 0.0)),
                0
            )
        ),
        0
    );
#else // LIB_LAYOUT
    frame = BRect(0, 0, 40, 15);
    BButton* defaultButton = new BButton(frame, "ok button",
                                         B_TRANSLATE("OK"), new BMessage(MSG_DONE),
                                         B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    defaultButton->ResizeToPreferred();
    BButton* cancelButton = new BButton(frame, "cancel button",
                                        B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                                        B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    cancelButton->ResizeToPreferred();

    frame.bottom = frame.top + (defaultButton->Frame().Height() + 16);
    frame.right = frame.left + fColorPickerView->Frame().Width();
    BBox* buttonBox = new BBox(frame, "button group",
                               B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM,
                               B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
                               B_PLAIN_BORDER);

    ResizeTo(frame.Width(),
             fColorPickerView->Frame().Height() + frame.Height() + 1);

    frame = Bounds();
    BView* topView = new BView(frame, "bg", B_FOLLOW_ALL, 0);
    topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    buttonBox->MoveTo(frame.left, frame.bottom - buttonBox->Frame().Height());

    defaultButton->MoveTo(frame.right - defaultButton->Frame().Width() - 10,
                          frame.top + 8);
    buttonBox->AddChild(defaultButton);

    cancelButton->MoveTo(defaultButton->Frame().left - 10
                         - cancelButton->Frame().Width(),
                         frame.top + 8);
    buttonBox->AddChild(cancelButton);

    topView->AddChild(fColorPickerView);
    topView->AddChild(buttonBox);
#endif // LIB_LAYOUT

    SetDefaultButton(defaultButton);

    if (fWindow)
        AddToSubset(fWindow);
    else
        SetFeel(B_FLOATING_APP_WINDOW_FEEL);

    AddChild(topView);
}
Пример #14
0
// --------------------------------------------------
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
	:	HWindow(BRect(0, 0, 320, 160), "Job Setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE)
{
	fSetupMsg	= msg;
	fExitSem 	= create_sem(0, "JobSetup");
	fResult 	= B_ERROR;
	
	if (printerName) {
		BString	title;
		title << printerName << " Job Setup";
		SetTitle(title.String());
		fPrinterName = printerName;
	}
	
	// ---- Ok, build a default job setup user interface
	BRect			r;
	BBox			*panel;
	BBox			*line;
	BButton	 		*ok;
	BButton			*cancel;
	BStringView		*sv;
	float			x, y, w, h;
	float			indent;
	int32           copies;
	int32           firstPage;
	int32           lastPage;
	bool            allPages;
	char            buffer[80];
	
	// PrinterDriver ensures that property exists
	fSetupMsg->FindInt32("copies",     &copies);
	fSetupMsg->FindInt32("first_page", &firstPage);
	fSetupMsg->FindInt32("last_page",  &lastPage);
	BMessage doc_info;
	if (B_OK != fSetupMsg->FindMessage("doc_info", &doc_info)) {
		// default fields
		doc_info.AddString("Author", "");
		doc_info.AddString("Subject", "");
		doc_info.AddString("Keywords", "");
		fSetupMsg->AddMessage("doc_info", &doc_info);
	}
	AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
	
	allPages = firstPage == 1 && lastPage == MAX_INT32;

	r = Bounds();

	// add a *dialog* background
	panel = new BBox(r, "top_panel", B_FOLLOW_ALL, 
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
		B_PLAIN_BORDER);

	const int kMargin = 6;

	//const char *kCopiesLabel				= "Copies:";
	const char *kCopiesLabelExtraSpace		= "Copies:##";
	const char *kPagesRangeLabel			= "Pages:";
	const char *kAllPagesLabel				= "All";
	const char *kPagesRangeSelectionLabel	= "";
	const char *kFromLabel					= "From:";
	const char *kFromLabelExtraSpace		= "From:##";
	const char *kToLabel					= "To:";
	const char *kToLabelExtraSpace			= "To:##";

	r = panel->Bounds();

	x = r.left + kMargin;
	y = r.top + kMargin;
	
	
	// add a "copies" input field

/* Simon: temporarily removed this code
	sprintf(buffer, "%d", (int)copies);
	fCopies = new BTextControl(BRect(x, y, x+100, y+20), "copies", kCopiesLabel,
								buffer, new BMessage(NB_COPIES_MSG));
	fCopies->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fCopies->ResizeToPreferred();
	fCopies->GetPreferredSize(&w, &h);
	panel->AddChild(fCopies);
	
	y += h + kMargin;	// "new line"
*/
	// add a "pages" label
	sv = new BStringView(BRect(x, y, x+100, y+20), "pages_range", kPagesRangeLabel);
	panel->AddChild(sv);
	sv->ResizeToPreferred();
	sv->GetPreferredSize(&w, &h);

	// align "copies" textcontrol field on the "allPages" radiobutton bellow...
	indent = be_plain_font->StringWidth(kCopiesLabelExtraSpace);
	w += kMargin;
	if ( w > indent )
		indent = w;
	// fCopies->SetDivider(indent);

	x += indent;

	// add a "all" radiobutton
	fAll = new BRadioButton(BRect(x, y, x+100, y+20), "all_pages", kAllPagesLabel,
						new BMessage(ALL_PAGES_MGS));
	fAll->ResizeToPreferred();
	fAll->GetPreferredSize(&w, &h);
	fAll->SetValue(allPages);
	panel->AddChild(fAll);

	y += h + kMargin;	// "new line"

	// add a range selection raddiobutton
	fRange = new BRadioButton(BRect(x, y, x+100, y+20), "pages_range_selection", kPagesRangeSelectionLabel,
						new BMessage(RANGE_SELECTION_MSG));
	fRange->ResizeToPreferred();
	fRange->GetPreferredSize(&w, &h);
	fRange->SetValue(!allPages);
	panel->AddChild(fRange);

	x += w + kMargin;
	
	// add a "from" field
	if (allPages) { 
		buffer[0] = 0;
	} else {
		sprintf(buffer, "%d", (int)firstPage);
	}
	fFrom = new BTextControl(BRect(x, y, x+100, y+20), "from_field", kFromLabel, buffer,
							new BMessage(RANGE_FROM_MSG));
	fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fFrom->SetDivider(be_plain_font->StringWidth(kFromLabelExtraSpace));
	fFrom->ResizeToPreferred();
	fFrom->GetPreferredSize(&w, &h);
	panel->AddChild(fFrom);

	x += w + kMargin;
	
	// add a "to" field
	if (allPages) {
		buffer[0] = 0;
	} else {
		sprintf(buffer, "%d", (int)lastPage);
	} 
	fTo = new BTextControl(BRect(x, y, x+100, y+20), "to_field", kToLabel, buffer,
							new BMessage(RANGE_TO_MSG));
	fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fTo->SetDivider(be_plain_font->StringWidth(kToLabelExtraSpace));
	fTo->ResizeToPreferred();
	fTo->GetPreferredSize(&w, &h);
	panel->AddChild(fTo);

	y += h + kMargin + kMargin;	// "new line"
	x = r.left + kMargin;

	// add a separator line...
	line = new BBox(BRect(r.left, y - 1, r.right, y), NULL,
						 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
	panel->AddChild(line);

	y += 2 + kMargin + kMargin;	// "new line"

	// add a "OK" button, and make it default
	ok 	= new BButton(BRect(x, y, x+100, y+20), NULL, "OK", new BMessage(OK_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	ok->MakeDefault(true);
	ok->ResizeToPreferred();
	ok->GetPreferredSize(&w, &h);
	x = r.right - w - kMargin;
	ok->MoveTo(x, ok->Frame().top);	// put the ok bottom at bottom right corner
	panel->AddChild(ok);

	// add a "Cancel" button	
	cancel 	= new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	cancel->ResizeToPreferred();
	cancel->GetPreferredSize(&w, &h);
	cancel->MoveTo(x - w - kMargin, y);	// put cancel button left next the ok button
	panel->AddChild(cancel);

	// add a "DocInfo" button	
	BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG), 
		B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	button->GetPreferredSize(&w, &h);
	button->ResizeToPreferred();
	button->MoveTo(8, y);
	panel->AddChild(button);

	// Finally, add our panel to window
	AddChild(panel);
	
	// Auto resize window
	ResizeTo(ok->Frame().right + kMargin, ok->Frame().bottom + kMargin);
}
Пример #15
0
ConfigWindow::ConfigWindow()
		: BWindow(BRect(200.0, 200.0, 640.0, 640.0),
				  "E-mail", B_TITLED_WINDOW,
				  B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
		fLastSelectedAccount(NULL),
		fSaveSettings(false)
{
	/*** create controls ***/

	BRect rect(Bounds());
	BView *top = new BView(rect,NULL,B_FOLLOW_ALL,0);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(top);

	// determine font height
	font_height fontHeight;
	top->GetFontHeight(&fontHeight);
	int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5;

	rect.InsetBy(5,5);	rect.bottom -= 11 + height;
	BTabView *tabView = new BTabView(rect,NULL);

	BView *view,*generalView;
	rect = tabView->Bounds();  rect.bottom -= tabView->TabHeight() + 4;
	tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0));
	tabView->TabAt(0)->SetLabel(MDR_DIALECT_CHOICE ("Accounts","アカウント"));
	view->SetViewColor(top->ViewColor());

	// accounts listview

	rect = view->Bounds().InsetByCopy(8,8);
	rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
	rect.bottom -= height + 12;
	fAccountsListView = new AccountsListView(rect);
	view->AddChild(new BScrollView(NULL,fAccountsListView,B_FOLLOW_ALL,0,false,true));
	rect.right += B_V_SCROLL_BAR_WIDTH;

	rect.top = rect.bottom + 8;  rect.bottom = rect.top + height;
	BRect sizeRect = rect;
	sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Add","追加"));
	view->AddChild(new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Add","追加"),
		new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM));

	sizeRect.left = sizeRect.right+3;
	sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Remove","削除"));
	view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Remove","削除"),
		new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM));

	// accounts config view
	rect = view->Bounds();
	rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16;
	rect.right -= 10;
	view->AddChild(fConfigView = new CenterContainer(rect));

	MakeHowToView();

	// general settings

	rect = tabView->Bounds();	rect.bottom -= tabView->TabHeight() + 4;
	tabView->AddTab(view = new CenterContainer(rect));
	tabView->TabAt(1)->SetLabel(MDR_DIALECT_CHOICE ("General","一般"));

	rect = view->Bounds().InsetByCopy(8,8);
	rect.right -= 1;	rect.bottom = rect.top + height * 5 + 15;
	BBox *box = new BBox(rect);
	box->SetLabel(MDR_DIALECT_CHOICE ("Retrieval Frequency","メールチェック間隔"));
	view->AddChild(box);

	rect = box->Bounds().InsetByCopy(8,8);
	rect.top += 7;	rect.bottom = rect.top + height + 5;
	BRect tile = rect.OffsetByCopy(0,1);
	int32 labelWidth = (int32)view->StringWidth(MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"))+6;
	tile.right = 80 + labelWidth;
	fIntervalControl = new BTextControl(tile,"time",MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"),
	NULL,NULL);
	fIntervalControl->SetDivider(labelWidth);
	box->AddChild(fIntervalControl);

	BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
	const char *frequencyStrings[] = {
		MDR_DIALECT_CHOICE ("Never","チェックしない"),
		MDR_DIALECT_CHOICE ("Minutes","分毎チェック"),
		MDR_DIALECT_CHOICE ("Hours","時間毎チェック"),
		MDR_DIALECT_CHOICE ("Days","日間毎チェック")};
	BMenuItem *item;
	for (int32 i = 0;i < 4;i++)
	{
		frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged)));
		if (i == 1)
			item->SetMarked(true);
	}
	tile.left = tile.right + 5;  tile.right = rect.right;
	tile.OffsetBy(0,-1);
	fIntervalUnitField = new BMenuField(tile,"frequency", B_EMPTY_STRING, frequencyPopUp);
	fIntervalUnitField->SetDivider(0.0);
	box->AddChild(fIntervalUnitField);

	rect.OffsetBy(0,height + 9);	rect.bottom -= 2;
	fPPPActiveCheckBox = new BCheckBox(rect,"ppp active",
		MDR_DIALECT_CHOICE ("only when PPP is active","PPP接続中時のみ"), NULL);
	box->AddChild(fPPPActiveCheckBox);
	
	rect.OffsetBy(0,height + 9);	rect.bottom -= 2;
	fPPPActiveSendCheckBox = new BCheckBox(rect,"ppp activesend",
		MDR_DIALECT_CHOICE ("Queue outgoing mail when PPP is inactive","PPP切断時、送信メールを送信箱に入れる"), NULL);
	box->AddChild(fPPPActiveSendCheckBox);

	rect = box->Frame();  rect.bottom = rect.top + 4*height + 20;
	box = new BBox(rect);
	box->SetLabel(MDR_DIALECT_CHOICE ("Status Window","送受信状況の表示"));
	view->AddChild(box);

	BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
	const char *statusModes[] = {
		MDR_DIALECT_CHOICE ("Never","表示しない"),
		MDR_DIALECT_CHOICE ("While Sending","送信時"),
		MDR_DIALECT_CHOICE ("While Sending / Fetching","送受信時"),
		MDR_DIALECT_CHOICE ("Always","常に表示")};
	BMessage *msg;
	for (int32 i = 0;i < 4;i++)
	{
		statusPopUp->AddItem(item = new BMenuItem(statusModes[i],msg = new BMessage(kMsgShowStatusWindowChanged)));
		msg->AddInt32("ShowStatusWindow",i);
		if (i == 0)
			item->SetMarked(true);
	}
	rect = box->Bounds().InsetByCopy(8,8);
	rect.top += 7;	rect.bottom = rect.top + height + 5;
	labelWidth = (int32)view->StringWidth(
		MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:")) + 8;
	fStatusModeField = new BMenuField(rect,"show status",
		MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:"),
	statusPopUp);
	fStatusModeField->SetDivider(labelWidth);
	box->AddChild(fStatusModeField);

	BPopUpMenu *lookPopUp = new BPopUpMenu(B_EMPTY_STRING);
	const char *windowLookStrings[] = {
		MDR_DIALECT_CHOICE ("Normal, With Tab","タブ付通常"),
		MDR_DIALECT_CHOICE ("Normal, Border Only","ボーダーのみ通常"),
		MDR_DIALECT_CHOICE ("Floating","フローティング"),
		MDR_DIALECT_CHOICE ("Thin Border","細いボーダー"),
		MDR_DIALECT_CHOICE ("No Border","ボーダー無し")};
	for (int32 i = 0;i < 5;i++)
	{
		lookPopUp->AddItem(item = new BMenuItem(windowLookStrings[i],msg = new BMessage(kMsgStatusLookChanged)));
		msg->AddInt32("StatusWindowLook",i);
		if (i == 0)
			item->SetMarked(true);
	}
	rect.OffsetBy(0, height + 6);
	fStatusLookField = new BMenuField(rect,"status look",
		MDR_DIALECT_CHOICE ("Window Look:","ウィンドウ外観:"),lookPopUp);
	fStatusLookField->SetDivider(labelWidth);
	box->AddChild(fStatusLookField);

	BPopUpMenu *workspacesPopUp = new BPopUpMenu(B_EMPTY_STRING);
	workspacesPopUp->AddItem(item = new BMenuItem(
		MDR_DIALECT_CHOICE ("Current Workspace","使用中ワークスペース"),
		msg = new BMessage(kMsgStatusWorkspaceChanged)));
	msg->AddInt32("StatusWindowWorkSpace", 0);
	workspacesPopUp->AddItem(item = new BMenuItem(
		MDR_DIALECT_CHOICE ("All Workspaces","全てのワークスペース"),
		msg = new BMessage(kMsgStatusWorkspaceChanged)));
	msg->AddInt32("StatusWindowWorkSpace", -1);

	rect.OffsetBy(0,height + 6);
	fStatusWorkspaceField = new BMenuField(rect,"status workspace",
		MDR_DIALECT_CHOICE ("Window visible on:","表示場所:"),workspacesPopUp);
	fStatusWorkspaceField->SetDivider(labelWidth);
	box->AddChild(fStatusWorkspaceField);

	rect = box->Frame();  rect.bottom = rect.top + 3*height + 13;
	box = new BBox(rect);
	box->SetLabel(MDR_DIALECT_CHOICE ("Deskbar Icon","デスクバーアイコンリンク"));
	view->AddChild(box);

	rect = box->Bounds().InsetByCopy(8,8);
	rect.top += 7;	rect.bottom = rect.top + height + 5;
	BStringView *stringView = new BStringView(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE (
		"The menu links are links to folders in a real folder like the Be menu.",
		"デスクバーで表示する項目の設定"));
	box->AddChild(stringView);
	stringView->SetAlignment(B_ALIGN_CENTER);
	stringView->ResizeToPreferred();
	// BStringView::ResizeToPreferred() changes the width, so that the
	// alignment has no effect anymore
	stringView->ResizeTo(rect.Width(), stringView->Bounds().Height());

	rect.left += 100;  rect.right -= 100;
	rect.OffsetBy(0,height + 1);
	BButton *button = new BButton(rect,B_EMPTY_STRING,
		MDR_DIALECT_CHOICE ("Configure Menu Links","メニューリンクの設定"),
		msg = new BMessage(B_REFS_RECEIVED));
	box->AddChild(button);
	button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));

	BPath path;
	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	path.Append("Mail/Menu Links");
	BEntry entry(path.Path());
	if (entry.InitCheck() == B_OK && entry.Exists()) {
		entry_ref ref;
		entry.GetRef(&ref);
		msg->AddRef("refs", &ref);
	}
	else
		button->SetEnabled(false);

	rect = box->Frame();  rect.bottom = rect.top + 2*height + 6;
	box = new BBox(rect);
	box->SetLabel(MDR_DIALECT_CHOICE ("Misc.","その他の設定"));
	view->AddChild(box);

	rect = box->Bounds().InsetByCopy(8,8);
	rect.top += 7;	rect.bottom = rect.top + height + 5;
	fAutoStartCheckBox = new BCheckBox(rect,"start daemon",
		MDR_DIALECT_CHOICE ("Auto-Start Mail Daemon","Mail Daemonを自動起動"),NULL);
	box->AddChild(fAutoStartCheckBox);

	// about page

	rect = tabView->Bounds();	rect.bottom -= tabView->TabHeight() + 4;
	tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0));
	tabView->TabAt(2)->SetLabel(MDR_DIALECT_CHOICE ("About","情報"));
	view->SetViewColor(top->ViewColor());

	AboutTextView *about = new AboutTextView(rect);
	about->SetViewColor(top->ViewColor());
	view->AddChild(about);

	// save/cancel/revert buttons

	top->AddChild(tabView);

	rect = tabView->Frame();
	rect.top = rect.bottom + 5;  rect.bottom = rect.top + height + 5;
	BButton *saveButton = new BButton(rect,"save",
		MDR_DIALECT_CHOICE ("Save","保存"),
		new BMessage(kMsgSaveSettings));
	float w,h;
	saveButton->GetPreferredSize(&w,&h);
	saveButton->ResizeTo(w,h);
	saveButton->MoveTo(rect.right - w, rect.top);
	top->AddChild(saveButton);

	BButton *cancelButton = new BButton(rect,"cancel",
		MDR_DIALECT_CHOICE ("Cancel","中止"),
		new BMessage(kMsgCancelSettings));
	cancelButton->GetPreferredSize(&w,&h);
	cancelButton->ResizeTo(w,h);
#ifdef HAVE_APPLY_BUTTON
	cancelButton->MoveTo(saveButton->Frame().left - w - 5,rect.top);
#else
	cancelButton->MoveTo(saveButton->Frame().left - w - 20,rect.top);
#endif
	top->AddChild(cancelButton);

#ifdef HAVE_APPLY_BUTTON
	BButton *applyButton = new BButton(rect,"apply",
		MDR_DIALECT_CHOICE ("Apply","適用"),
		new BMessage(kMsgApplySettings));
	applyButton->GetPreferredSize(&w,&h);
	applyButton->ResizeTo(w,h);
	applyButton->MoveTo(cancelButton->Frame().left - w - 20,rect.top);
	top->AddChild(applyButton);
#endif

	BButton *revertButton = new BButton(rect,"revert",
		MDR_DIALECT_CHOICE ("Revert","復元"),
		new BMessage(kMsgRevertSettings));
	revertButton->GetPreferredSize(&w,&h);
	revertButton->ResizeTo(w,h);
#ifdef HAVE_APPLY_BUTTON
	revertButton->MoveTo(applyButton->Frame().left - w - 5,rect.top);
#else
	revertButton->MoveTo(cancelButton->Frame().left - w - 6,rect.top);
#endif
	top->AddChild(revertButton);

	LoadSettings();

	fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
}
Пример #16
0
void 
PasswordWindow::_Setup()
{
	BRect bounds = Bounds();
	BView* topView = new BView(bounds, "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	bounds.InsetBy(10.0, 10.0);
	fUseNetwork = new BRadioButton(bounds, "useNetwork", "Use network password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	topView->AddChild(fUseNetwork);
	fUseNetwork->ResizeToPreferred();
	fUseNetwork->MoveBy(10.0, 0.0);

	bounds.OffsetBy(0.0, fUseNetwork->Bounds().Height());
	BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
	topView->AddChild(customBox);

	fUseCustom = new BRadioButton(BRect(), "useCustom", "Use custom password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	customBox->SetLabel(fUseCustom);
	fUseCustom->ResizeToPreferred();

	fPasswordControl = new BTextControl(bounds, "passwordControl", "Password:"******"confirmControl", 
		"Confirm password:"******"VeryLongPasswordPossible", B_FOLLOW_NONE);
	customBox->AddChild(fConfirmControl);
	fConfirmControl->TextView()->HideTyping(true);
	fConfirmControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	float width, height;
	fConfirmControl->GetPreferredSize(&width, &height);
	fPasswordControl->ResizeTo(width, height);
	fConfirmControl->ResizeTo(width, height);
	
	float divider = be_plain_font->StringWidth("Confirm password:"******"done", "Done", new BMessage(kMsgDone));
	topView->AddChild(button);
	button->ResizeToPreferred();

	BRect frame = customBox->Frame();
	button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);

	frame = button->Frame();
	button->MakeDefault(true);

	button = new BButton(frame, "cancel", "Cancel", new BMessage(B_CANCEL));
	topView->AddChild(button);
	button->ResizeToPreferred();
	button->MoveBy(-(button->Bounds().Width() + 10.0), 0.0);

	ResizeTo(customBox->Frame().right + 10.0, frame.bottom + 10.0);
}
Пример #17
0
ConfigWindow::ConfigWindow()
    :
    BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
           B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
    fLastSelectedAccount(NULL),
    fSaveSettings(false)
{
    // create controls

    BRect rect(Bounds());
    BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0);
    top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    AddChild(top);

    // determine font height
    font_height fontHeight;
    top->GetFontHeight(&fontHeight);
    int32 height = (int32)(fontHeight.ascent + fontHeight.descent
                           + fontHeight.leading) + 5;

    rect.InsetBy(5, 5);
    rect.bottom -= 11 + height;
    BTabView *tabView = new BTabView(rect, NULL);

    BView *view;
    rect = tabView->Bounds();
    rect.bottom -= tabView->TabHeight() + 4;
    tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
    tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));
    view->SetViewColor(top->ViewColor());

    // accounts listview

    rect = view->Bounds().InsetByCopy(8, 8);
    rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
    rect.bottom -= height + 12;
    fAccountsListView = new AccountsListView(rect);
    view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0,
                                   false, true));
    rect.right += B_V_SCROLL_BAR_WIDTH;

    rect.top = rect.bottom + 8;
    rect.bottom = rect.top + height;
    BRect sizeRect = rect;
    sizeRect.right = sizeRect.left + 30 + view->StringWidth(
                         B_TRANSLATE("Add"));
    view->AddChild(new BButton(sizeRect, NULL, B_TRANSLATE("Add"),
                               new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));

    sizeRect.left = sizeRect.right+3;
    sizeRect.right = sizeRect.left + 30 + view->StringWidth(
                         B_TRANSLATE("Remove"));
    view->AddChild(fRemoveButton = new BButton(
        sizeRect, NULL, B_TRANSLATE("Remove"),
        new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));

    // accounts config view
    rect = view->Bounds();
    rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16;
    rect.right -= 10;
    view->AddChild(fConfigView = new CenterContainer(rect));

    MakeHowToView();

    // general settings

    rect = tabView->Bounds();
    rect.bottom -= tabView->TabHeight() + 4;
    tabView->AddTab(view = new CenterContainer(rect));
    tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings"));

    rect = view->Bounds().InsetByCopy(8, 8);
    rect.right -= 1;
    rect.bottom = rect.top + height * 5 + 15;
    BBox *box = new BBox(rect);
    box->SetLabel(B_TRANSLATE("Mail checking"));
    view->AddChild(box);

    rect = box->Bounds().InsetByCopy(8, 8);
    rect.top += 7;
    rect.bottom = rect.top + height + 5;
    BRect tile = rect.OffsetByCopy(0, 1);
    int32 labelWidth = (int32)view->StringWidth(B_TRANSLATE("Check every")) + 6;
    tile.right = 80 + labelWidth;
    fIntervalControl = new BTextControl(tile, "time",
                                        B_TRANSLATE("Check every"), NULL, NULL);
    fIntervalControl->SetDivider(labelWidth);
    box->AddChild(fIntervalControl);

    BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
    const char *frequencyStrings[] = {
        B_TRANSLATE("never"),
        B_TRANSLATE("minutes"),
        B_TRANSLATE("hours"),
        B_TRANSLATE("days")
    };
    BMenuItem *item;
    for (int32 i = 0; i < 4; i++) {
        frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],
                new BMessage(kMsgIntervalUnitChanged)));
        if (i == 1)
            item->SetMarked(true);
    }
    tile.left = tile.right + 5;
    tile.right = rect.right;
    tile.OffsetBy(0,-1);
    fIntervalUnitField = new BMenuField(tile, "frequency", B_EMPTY_STRING,
                                        frequencyPopUp);
    fIntervalUnitField->SetDivider(0.0);
    box->AddChild(fIntervalUnitField);

    rect.OffsetBy(0,height + 9);
    rect.bottom -= 2;
    fPPPActiveCheckBox = new BCheckBox(rect, "ppp active",
                                       B_TRANSLATE("Only when dial-up is connected"), NULL);
    box->AddChild(fPPPActiveCheckBox);

    rect.OffsetBy(0,height + 9);
    rect.bottom -= 2;
    fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend",
                                           B_TRANSLATE("Schedule outgoing mail when dial-up is disconnected"),
                                           NULL);
    box->AddChild(fPPPActiveSendCheckBox);

    // Miscellaneous settings box

    rect = box->Frame();
    rect.bottom = rect.top + 3 * height + 30;
    box = new BBox(rect);
    box->SetLabel(B_TRANSLATE("Miscellaneous"));
    view->AddChild(box);

    BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
    const char *statusModes[] = {
        B_TRANSLATE("Never"),
        B_TRANSLATE("While sending"),
        B_TRANSLATE("While sending and receiving"),
        B_TRANSLATE("Always")
    };
    BMessage *msg;
    for (int32 i = 0; i < 4; i++) {
        statusPopUp->AddItem(item = new BMenuItem(statusModes[i],
                msg = new BMessage(kMsgShowStatusWindowChanged)));
        msg->AddInt32("ShowStatusWindow", i);
        if (i == 0)
            item->SetMarked(true);
    }
    rect = box->Bounds().InsetByCopy(8,8);
    rect.top += 7;
    rect.bottom = rect.top + height + 5;
    labelWidth
        = (int32)view->StringWidth(
              B_TRANSLATE("Show connection status window:"))	+ 8;
    fStatusModeField = new BMenuField(rect, "show status",
                                      B_TRANSLATE("Show connection status window:"), statusPopUp);
    fStatusModeField->SetDivider(labelWidth);
    box->AddChild(fStatusModeField);

    rect = fStatusModeField->Frame();;
    rect.OffsetBy(0, rect.Height() + 10);
    BButton *button = new BButton(rect, B_EMPTY_STRING,
                                  B_TRANSLATE("Edit mailbox menu…"),
                                  msg = new BMessage(B_REFS_RECEIVED));
    button->ResizeToPreferred();
    box->AddChild(button);
    button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));

    BPath path;
    find_directory(B_USER_SETTINGS_DIRECTORY, &path);
    path.Append("Mail/Menu Links");
    BEntry entry(path.Path());
    if (entry.InitCheck() == B_OK && entry.Exists()) {
        entry_ref ref;
        entry.GetRef(&ref);
        msg->AddRef("refs", &ref);
    }
    else
        button->SetEnabled(false);

    rect = button->Frame();
    rect.OffsetBy(rect.Width() + 30,0);
    fAutoStartCheckBox = new BCheckBox(rect, "start daemon",
                                       B_TRANSLATE("Start mail services on startup"), NULL);
    fAutoStartCheckBox->ResizeToPreferred();
    box->AddChild(fAutoStartCheckBox);

    // save/revert buttons

    top->AddChild(tabView);

    rect = tabView->Frame();
    rect.top = rect.bottom + 5;
    rect.bottom = rect.top + height + 5;
    BButton *saveButton = new BButton(rect, "apply", B_TRANSLATE("Apply"),
                                      new BMessage(kMsgSaveSettings));
    float w,h;
    saveButton->GetPreferredSize(&w, &h);
    saveButton->ResizeTo(w, h);
    saveButton->MoveTo(rect.right - w, rect.top);
    top->AddChild(saveButton);

    BButton *revertButton = new BButton(rect, "revert", B_TRANSLATE("Revert"),
                                        new BMessage(kMsgRevertSettings));
    revertButton->GetPreferredSize(&w, &h);
    revertButton->ResizeTo(w,h);
    revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top);
    top->AddChild(revertButton);

    LoadSettings();
    // this will also move our window to the stored position

    fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
    fAccountsListView->MakeFocus(true);
}
Пример #18
0
FastTraxWindow :: FastTraxWindow( entry_ref * ref  )
:	BWindow( BRect( 20, 50, 40, 100 ) , "FastTraX",
		B_MODAL_WINDOW_LOOK , B_NORMAL_WINDOW_FEEL , B_NOT_RESIZABLE )
,	fNameStr(NULL)
,	fContainsStr(NULL)
,	fSettingsWindow(NULL)
{
	// Load the settings
	fSettingsWindow = new SettingsWindow ;
	fSettingsWindow->Hide();
	fSettingsWindow->Show();
	
	BView	* topView ,
	     	* rightView ;
	BRect 	r ;
	
	float	mainWidth = 0;
	float	mainHeight = 0;
	
	topView = new ColouredView( BRect(0,0,50,20) , "top",
	                	B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ) ;

	rightView = new ColouredView( BRect(50,0,70,100) , "right",
	                	B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ) ;

	fNameView = new ColouredView( BRect(0,20,50,100) , "name",
	                	B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ) ;
	fFileView = new ColouredView( BRect(0,20,50,100) , "file",
	                	B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ) ;
	fDateView = new ColouredView( BRect(0,20,50,100) , "date",
	                	B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ) ;

	AddChild( topView ) ;
	AddChild( fNameView ) ;
	AddChild( fFileView ) ;
	AddChild( fDateView ) ;
	AddChild( rightView ) ;

	topView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ) ;
	rightView->SetViewColor( ui_color( B_MENU_BACKGROUND_COLOR ) ) ;
	fNameView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ) ;
	fFileView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ) ;
	fDateView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ) ;
	
	//=================================================================
	// Right View
	//=================================================================
	BButton * button ;
	button = new BButton( BRect( 7,5,20,15 ) , "exit", "Close",  
		new BMessage( B_QUIT_REQUESTED )  ) ;
	rightView->AddChild( button ) ;
	button->ResizeToPreferred() ;
	r = button->Frame() ;
	r.OffsetTo( r.left, r.bottom + 7 ) ;

	button = new BButton( r , "about", "About",  
		new BMessage( B_ABOUT_REQUESTED ) ) ;
	rightView->AddChild( button ) ;
	button->ResizeToPreferred() ;
	r = button->Frame() ;
	r.OffsetTo( r.left, r.bottom + 7 ) ;

	button = new BButton( r , "settings", "Settings",  
		new BMessage( Messages::SettingsRequested ) ) ;
	rightView->AddChild( button ) ;
	button->ResizeToPreferred() ;
	r = button->Frame() ;
	r.OffsetTo( r.left, r.bottom + 7 ) ;
	
	rightView->ResizeTo( r.right + 7 , r.bottom + 7 ) ;
	fFindButton = new BButton( r , "find", "Find",  
		new BMessage( Messages::StartFind ) , B_FOLLOW_LEFT | B_FOLLOW_BOTTOM ) ;
	rightView->AddChild( fFindButton ) ;
	fFindButton->ResizeToPreferred() ;
	fFindButton->MakeDefault( true ) ;

	//=================================================================
	// Top View
	//=================================================================
	fNameButton = new SlimButton( BRect( 7, 2, 25, 13 ) , "name", "Name",
		new BMessage( Messages::SetTab | 'N' ) ) ;
	topView->AddChild( fNameButton ) ;
	fNameButton->ResizeToPreferred() ;
	r = fNameButton->Frame() ;	
	r.OffsetTo( r.right + 7 , r.top ) ;

	fFileButton = new SlimButton( r , "file", "File",
		new BMessage( Messages::SetTab | 'F' ) ) ;
	topView->AddChild( fFileButton ) ;
	fFileButton->ResizeToPreferred() ;
	r = fFileButton->Frame() ;
	r.OffsetTo( r.right + 7 , r.top ) ;
	
	fDateButton = new SlimButton( r , "date", "Date",
		new BMessage( Messages::SetTab | 'D' ) ) ;
	topView->AddChild( fDateButton ) ;
	fDateButton->ResizeToPreferred() ;
	r = fDateButton->Frame() ;
	
	topView->ResizeTo( r.right + 7, r.bottom + 3 ) ;
	
	float width , top ;

	//=================================================================
	// Name Main View
	//=================================================================
	fpFolder = new TraxFolderPopUp( BRect( 5, 7, 15, 10 ), "location", "Find in:" ) ;
	fpFolder->InitFolders( ref ) ;
	fNameView->AddChild( fpFolder ) ;
	fpFolder->ResizeToPreferred() ;
	fpFolder->SetViewColor( fNameView->ViewColor() ) ;
	fpFolder->SetLowColor( fNameView->ViewColor() ) ;
	fpFolder->SetChoice( gSettings.fDefaultFolder ) ;
	r = fpFolder->Frame() ;
	width = r.right ;
	
	top = r.bottom + 10 ;
	fpName = new BTextControl( BRect( 5, top, r.right * 2, top + 10 ) ,
				"name", "Named:", "", NULL ) ;
	fNameView->AddChild( fpName ) ;
	fpName->ResizeToPreferred() ;
	fpName->SetDivider( fpName->StringWidth( "Named: " ) ) ;
	fpName->MakeFocus( true ) ;
	r = fpName->Frame() ;
	width = MathUtils::max( width, r.right ) ;

	top = r.bottom + 10 ;
	fpSubDirs = new BCheckBox( BRect( 5, top, 15, top + 10 ) ,
				"subdirs", "Include Sub-Directories", NULL ) ;
	fNameView->AddChild( fpSubDirs ) ;
	fpSubDirs->ResizeToPreferred() ;
	fpSubDirs->SetValue(1) ;
	r = fpSubDirs->Frame() ;
	width = MathUtils::max( width, r.right ) ;
	fNameView->ResizeTo( width + 10, r.bottom + 10 ) ;
	r = fNameView->Frame() ;
	
	mainWidth  = MathUtils::max( mainWidth, r.right ) ;
	mainHeight = MathUtils::max( mainHeight, r.bottom ) ;
	
	//=================================================================
	// File Main View
	//=================================================================
	fpContaining = new BTextControl( BRect( 3, 3, 10, 10 ) ,
				"containing", "Containing Text:", "", NULL ) ;
	fFileView->AddChild( fpContaining ) ;
	width = fpContaining->StringWidth( "Containing Text:" ) ;
	width *= 2.5 ;
	fpContaining->ResizeTo( width , 10 ) ;
	fpContaining->ResizeToPreferred() ;
	r = fpContaining->Frame() ;
	
	top = r.bottom + 7 ;
	StaticString * sv = new StaticString( BRect( 3, 3, 50, 10 ) , "kb",
							"kB" ) ;
	sv -> ResizeToPreferred() ;
	r = sv->Frame() ;
	width -= (r.Width() + 3) ;

	fpSizeGT = new BTextControl(
				BRect( 3, top, width - 3, top + 10 ) ,
				"size", "Size at least: ", "", NULL ) ;
	fFileView->AddChild( fpSizeGT ) ;
	fpSizeGT->ResizeToPreferred() ;
	fpSizeGT->SetDivider( fpContaining->Divider() ) ;
	r = fpSizeGT->Frame() ;
	fpSizeGT->ResizeTo( width - 6, r.Height() ) ;
	r = fpSizeGT->Frame() ;

	top = r.bottom - sv->Frame().Height() ;
	sv->MoveTo( width , top ) ;
	fFileView->AddChild( sv ) ;
	
	top = r.bottom + 4 ;
	sv = new StaticString( BRect( 3, 3, 50, 10 ) , "kb",
							"kB" ) ;
	sv -> ResizeToPreferred() ;
	r = sv->Frame() ;

	fpSizeLT = new BTextControl(
				BRect( 3, top, width - 3, top + 10 ) ,
				"size", "Size less than: ", "", NULL ) ;
	fFileView->AddChild( fpSizeLT ) ;
	fpSizeLT->ResizeToPreferred() ;
	fpSizeLT->SetDivider( fpContaining->Divider() ) ;
	r = fpSizeLT->Frame() ;
	fpSizeLT->ResizeTo( width - 6, r.Height() ) ;
	r = fpSizeLT->Frame() ;

	top = r.bottom - sv->Frame().Height() ;
	sv->MoveTo( width , top ) ;
	fFileView->AddChild( sv ) ;

	width = sv->Frame().right ;
	top = r.bottom + 7 ;
	fpKind = new StringPopUp( BRect( 3, top, width, top + 10 ) ,
				"kind", "Kind:  ") ;
	fpKind->AddStrings( sizeof(kKindStr)/sizeof(kKindStr[0]), kKindStr) ; 
	fFileView->AddChild( fpKind ) ;
	fpKind->ResizeToPreferred() ;
	r = fpKind->Frame() ;

	width = MathUtils::max( r.right, fpContaining->Frame().right ) ;
	fFileView->ResizeTo( width + 10, r.bottom + 10 ) ;

	r = fFileView->Frame() ;
	mainWidth  = MathUtils::max( mainWidth, r.right ) ;
	mainHeight = MathUtils::max( mainHeight, r.bottom ) ;
	
	//=================================================================
	// Date Main View
	//=================================================================
	sv = new StaticString( BRect( 3, 3, 50, 10 ) , "mod_string",
							"Modified " ) ;
	sv -> ResizeToPreferred() ;
	fDateView->AddChild( sv ) ;
	sv->SetViewColor( fDateView->ViewColor() ) ;
	sv->SetLowColor( fDateView->ViewColor() ) ;
	r = sv->Frame() ;
	width = r.right ;
	
	fpModAfter  = new BTextControl( BRect( width, 3, r.right * 2, 10 ) ,
				"mod_after", "after:", "", NULL ) ;
	fDateView->AddChild( fpModAfter ) ;
	fpModAfter->ResizeToPreferred() ;
	r = fpModAfter->Frame() ;

	fpModBefore = new BTextControl( BRect( width, r.bottom + 3, r.right * 2, r.bottom + 10 ) ,
				"mod_before", "before:", "", NULL ) ;
	fDateView->AddChild( fpModBefore ) ;
	fpModBefore->ResizeToPreferred() ;

	width = fpModBefore->StringWidth( "before: " ) ;
	fpModAfter ->ResizeTo( width * 4, r.Height() ) ;
	fpModBefore->ResizeTo( width * 4, r.Height() ) ;

	fpModAfter ->SetDivider( width ) ;
	fpModBefore->SetDivider( width ) ;

	r = fpModAfter->Frame() ;
	sv->MoveTo( 3, r.bottom - sv->Frame().Height()/3 ) ;

	r = fpModBefore->Frame() ;
	top = r.bottom + 5 ;
	r = sv->Frame() ;
	width = r.right ;
	sv = new StaticString( BRect( 3, top, 50, top + 5 ) , "cre_string",
							"Created " ) ;
	sv -> ResizeToPreferred() ;
	fDateView->AddChild( sv ) ;
	sv->SetViewColor( fDateView->ViewColor() ) ;
	sv->SetLowColor( fDateView->ViewColor() ) ;
	
	fpCreAfter  = new BTextControl( BRect( width, top, r.right * 2, top + 5 ) ,
				"cre_after", "after:", "", NULL ) ;
	fDateView->AddChild( fpCreAfter ) ;
	fpCreAfter->ResizeToPreferred() ;
	r = fpCreAfter->Frame() ;

	fpCreBefore = new BTextControl( BRect( width, r.bottom + 3, r.right * 2, r.bottom + 10 ) ,
				"cre_before", "before:", "", NULL ) ;
	fDateView->AddChild( fpCreBefore ) ;
	fpCreBefore->ResizeToPreferred() ;

	width = fpCreBefore->StringWidth( "before: " ) ;
	fpCreAfter ->ResizeTo( width * 4, r.Height() ) ;
	fpCreBefore->ResizeTo( width * 4, r.Height() ) ;

	fpCreAfter ->SetDivider( width ) ;
	fpCreBefore->SetDivider( width ) ;

	r = fpCreAfter->Frame() ;
	sv->MoveTo( 3, r.bottom - sv->Frame().Height()/3 ) ;

	r = fpCreBefore->Frame() ;
	fDateView->ResizeTo( r.right + 10, r.bottom + 10 ) ;

	r = fDateView->Frame() ;
	mainWidth  = MathUtils::max( mainWidth, r.right ) ;
	mainHeight = MathUtils::max( mainHeight, r.bottom ) ;

	//=================================================================
	// Fit Together
	//=================================================================
	float middle = MathUtils::max( topView->Frame().right , mainWidth ) ;
	float bottom = MathUtils::max( rightView->Frame().bottom , mainHeight ) ;

	width = middle - 10 ;
	fpFolder->ResizeTo( width, fpFolder->Frame().Height() ) ;	
	fpName->ResizeTo(   width, fpName  ->Frame().Height() ) ;	
	fNameView->ResizeTo( width + 10, r.bottom + 10 ) ;

	float height = bottom - topView->Frame().bottom ;

	topView->ResizeTo( middle, topView->Frame().Height() ) ;	
	rightView->MoveTo( middle + 5, 0 ) ;
	rightView->ResizeTo( rightView->Frame().Width(), bottom ) ;
	fNameView->MoveTo( 0, topView->Frame().bottom + 3) ;
	fNameView->ResizeTo( middle, height ) ;
	fFileView->MoveTo( 0, topView->Frame().bottom + 3) ;
	fFileView->ResizeTo( middle, height ) ;
	fDateView->MoveTo( 0, topView->Frame().bottom + 3) ;
	fDateView->ResizeTo( middle, height ) ;

	//=================================================================
	// Resize Window
	//=================================================================
	ResizeTo( rightView->Frame().right , rightView->Frame().bottom ) ;
	BView * bar ;
	bar = new BarView( BRect( middle,0,middle+4,bottom), "bar1" ) ;
	AddChild( bar ) ;
	bar = new RidgeView( BRect( 0, topView->Frame().bottom, middle-1, topView->Frame().bottom + 2 ), "bar2", B_HORIZONTAL ) ;
	AddChild( bar ) ;
	
	fCurrentView = fNameView ;
	fDisabledButton = fNameButton ;
	fNameButton->SetEnabled( false ) ;
	fFileView->Hide() ;
	fDateView->Hide() ;
}