Exemple #1
0
PrefsWindow::PrefsWindow(void)
  : BWindow (BRect (88.0, 108.0, 0.0, 0.0),
      S_PREFSWIN_TITLE,
      B_TITLED_WINDOW,
      B_ASYNCHRONOUS_CONTROLS)
{
  GeneralPrefsView *generalView = new GeneralPrefsView(BRect(0.0, 0.0, 0.0, 0.0),
     "view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);

  ResizeTo(generalView->Bounds().Width(), generalView->Bounds().Height());

  BBox *box = new BBox (Bounds().InsetByCopy(-1,-1), "box", B_FOLLOW_ALL_SIDES);
  
  AddChild(box);

  box->AddChild(generalView);
  generalView->MoveTo ((box->Bounds().Width() - generalView->Bounds().Width()) / 2,
    (box->Bounds().Height() - generalView->Bounds().Height()) / 2);

  BRect prefsRect (vision_app->GetRect ("GenPrefWinRect"));
  if (prefsRect.Width() != 0.0 && prefsRect.Height() != 0.0)
  {
    ResizeTo (prefsRect.Width(), prefsRect.Height());
    MoveTo (prefsRect.left, prefsRect.top);
  }
}
Exemple #2
0
void
ModulesView::_OpenSaver()
{
	// create new screen saver preview & config

	BView* view = fPreviewView->AddPreview();
	fCurrentName = fSettings.ModuleName();
	fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings);
	BScreenSaver* saver = _ScreenSaver();

#ifdef __HAIKU__
	BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4);
#else
	BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
	rect.top += 14;
#endif
	fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);

	fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fSettingsBox->AddChild(fSettingsView);

	if (saver != NULL && fSaverRunner->Run() == B_OK)
		saver->StartConfig(fSettingsView);

	if (fSettingsView->ChildAt(0) == NULL) {
		// There are no settings at all, we add the module name here to
		// let it look a bit better at least.
		BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView,
			fSettings.ModuleName()[0] ? fSettings.ModuleName()
				: B_TRANSLATE("Blackness"),
				saver != NULL || !fSettings.ModuleName()[0]
					? B_TRANSLATE("No options available")
					: B_TRANSLATE("Could not load screen saver"));
	}
}
	void OpenGroup(const char* text)
	{
		if (text != NULL) {
			BBox* box = new BBox(GetControlBounds(), text);
			box->SetLabel(text);
			GetView()->AddChild(box);
			Push(box);
			box->ResizeTo(box->Bounds().Width(), kBoxHeight);
		}
	}
void
ModulesView::_OpenSaver()
{
	// create new screen saver preview & config

	BView* view = fPreviewView->AddPreview();
	fCurrentName = fSettings.ModuleName();
	fSaverRunner = new ScreenSaverRunner(view->Window(), view, fSettings);

#ifdef __HAIKU__
	BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4);
#else
	BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
	rect.top += 14;
#endif
	fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);

	fSettingsView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fSettingsBox->AddChild(fSettingsView);

	BScreenSaver* saver = ScreenSaver();
	if (saver != NULL && fSettingsView != NULL) {
		saver->StartConfig(fSettingsView);
		if (saver->StartSaver(view, true) == B_OK) {
			fPreviewView->HideNoPreview();
			fSaverRunner->Run();
		} else
			fPreviewView->ShowNoPreview();
	} else {
		// Failed to load OR this is the "Blackness" screensaver. Show a black
		// preview (this is what will happen in both cases when screen_blanker
		// runs).
		fPreviewView->HideNoPreview();
	}

	if (fSettingsView->ChildAt(0) == NULL) {
		// There are no settings at all, we add the module name here to
		// let it look a bit better at least.
		BPrivate::BuildDefaultSettingsView(fSettingsView,
			fSettings.ModuleName()[0] ? fSettings.ModuleName()
				: B_TRANSLATE("Blackness"),
				saver != NULL || !fSettings.ModuleName()[0]
					? B_TRANSLATE("No options available")
					: B_TRANSLATE("Could not load screen saver"));
	}
}
Exemple #5
0
BView* PrefsWindow::constructGeneralBox(BRect frame)
{
	BBox* generalBox = new BBox(frame);
	generalBox->SetLabel("General");
	
	float 	offset = 30.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f,
			cbheight = 14.0f,
			adjust = 5.0f
			;
			
	float controlX = (offset * 2.0f / 3.0f);
	BRect bubbleFrame = BRect(controlX, offset - adjust, offset + 150.0f, offset + cbheight - adjust);	
	
	ColourButton *bubbleColourButton = new ColourButton(bubbleFrame, GetPrefsMessage(K_BUBBLE_COLOUR), ColourConstants::K_BLACK, "Tooltips");
	generalBox->AddChild(bubbleColourButton);
		
	BRect recentDocsPathFrame(controlX, 50.0f, controlX + 150.0f, 70.0f);
	BCheckBox *showRecentDocsPath = new BCheckBox(recentDocsPathFrame, K_IS_RECENT_DOCS_SHOWN, "Show Path in Recent Docs", GetPrefsMessage(K_IS_RECENT_DOCS_SHOWN));
	generalBox->AddChild(showRecentDocsPath);
	
	BRect isActivationFrame(controlX, 80.0f, controlX + 190.0f, 100.0f);
	BCheckBox *isActivationOk = new BCheckBox(isActivationFrame, K_IS_ACTIVATION_OK, "Activate Window on Opening Docs", GetPrefsMessage(K_IS_ACTIVATION_OK));	
	generalBox->AddChild(isActivationOk);
	
	BRect recentDocsFrame(controlX, 110.0f, controlX + 150.0f, 120.0f);
	BTextControl *numRecentDocs = new BTextControl(recentDocsFrame, K_NUM_RECENT_DOCS, "Number of Recent Docs", "", GetPrefsMessage(K_NUM_RECENT_DOCS));
	numRecentDocs->SetDivider(120.0f);
	numRecentDocs->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	generalBox->AddChild(numRecentDocs);
	
	BRect insertDateFrame(controlX, 140.0f, controlX + 200.0f, 150.0f);
	BTextControl *insertDateFlags = new BTextControl(insertDateFrame, K_DATE_FLAGS, "Insert Date Flags", "", GetPrefsMessage(K_DATE_FLAGS));
	generalBox->AddChild(insertDateFlags);	
	
	BRect generalRect = generalBox->Bounds();
	BRect generalbtnRect(generalRect.right - bspacing - bwidth, generalRect.bottom - bspacing - bheight, generalRect.right - bspacing, generalRect.bottom - bspacing);
	BButton *resetGeneralDefaults = new BButton(generalbtnRect,"fResetGeneralDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS));
	generalBox->AddChild(resetGeneralDefaults);
	
	return generalBox;
}
Exemple #6
0
//! Create the controls for the "General" tab
void
ScreenSaverWindow::_SetupFadeTab(BRect rect)
{
	fFadeView = new FadeView(rect, B_TRANSLATE("General"), fSettings);

	float StringWidth1 = be_plain_font->StringWidth(B_TRANSLATE
		("Start screensaver"));
	float StringWidth2 = be_plain_font->StringWidth(B_TRANSLATE
		("Turn off screen"));
	float StringWidth3 = be_plain_font->StringWidth(B_TRANSLATE
		("Password lock"));
	
	float labelWidth = StringWidth1;
	if (labelWidth < StringWidth2)
		labelWidth = StringWidth2;
	if (labelWidth < StringWidth3)
		labelWidth = StringWidth3;

	labelWidth += 20.0f;

	font_height fontHeight;
	be_plain_font->GetHeight(&fontHeight);
	float textHeight = ceilf(fontHeight.ascent + fontHeight.descent);

	// taken from BRadioButton:
	float radioButtonOffset = 2 * floorf(textHeight / 2 - 2)
		+ floorf(textHeight / 2);

	fEnableCheckBox = new BCheckBox(BRect(0, 0, 1, 1), "EnableCheckBox",
		B_TRANSLATE("Enable screensaver"),
		new BMessage(kMsgEnableScreenSaverBox));
	fEnableCheckBox->ResizeToPreferred();

	rect.InsetBy(8, 8);
	BBox* box = new BBox(rect, "EnableScreenSaverBox", B_FOLLOW_ALL);
	box->SetLabel(fEnableCheckBox);
	fFadeView->AddChild(box);

	// Start Screensaver
	rect.left += radioButtonOffset + 6;
	rect.top = fEnableCheckBox->Bounds().bottom + 8.0f;
	rect.right = box->Bounds().right - 8;
	BStringView* stringView = new BStringView(rect, NULL,
		B_TRANSLATE("Start screensaver"));
	stringView->ResizeToPreferred();
	box->AddChild(stringView);

	rect.left += labelWidth - 4;
	fRunSlider = new TimeSlider(rect, "RunSlider", kMsgRunSliderChanged,
		kMsgRunSliderUpdate);
	float width, height;
	fRunSlider->GetPreferredSize(&width, &height);
	fRunSlider->ResizeTo(fRunSlider->Bounds().Width(), height);
	box->AddChild(fRunSlider);

	// Turn Off
	rect.left = 10;
	rect.OffsetBy(0, fRunSlider->Bounds().Height() + 4.0f);
	fTurnOffCheckBox = new BCheckBox(rect, "TurnOffScreenCheckBox",
		B_TRANSLATE("Turn off screen"), new BMessage(kMsgTurnOffCheckBox));
	fTurnOffCheckBox->ResizeToPreferred();
	box->AddChild(fTurnOffCheckBox);

	rect.top += 3;
	rect.left += radioButtonOffset + labelWidth;
	fTurnOffSlider = new TimeSlider(rect, "TurnOffSlider",
		kMsgTurnOffSliderChanged, kMsgTurnOffSliderUpdate);
	fTurnOffSlider->ResizeTo(fTurnOffSlider->Bounds().Width(), height);
	box->AddChild(fTurnOffSlider);

	rgb_color textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
		B_DISABLED_LABEL_TINT);
	BRect textRect(0, 0, fTurnOffSlider->Bounds().Width(), height);
	textRect.InsetBy(0, 3);
	fTurnOffNotSupported = new BTextView(rect, "not_supported",
		textRect, be_plain_font, &textColor, B_FOLLOW_ALL, B_WILL_DRAW);
	fTurnOffNotSupported->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTurnOffNotSupported->MakeEditable(false);
	fTurnOffNotSupported->MakeSelectable(false);
	fTurnOffNotSupported->SetText(
		B_TRANSLATE("Display Power Management Signaling not available"));

	fTurnOffNotSupported->ResizeTo(fTurnOffSlider->Bounds().Width(), height);
	box->AddChild(fTurnOffNotSupported);

	// Password
	rect.left = 10;
	rect.OffsetBy(0, fTurnOffSlider->Bounds().Height() + 4.0f);
	fPasswordCheckBox = new BCheckBox(rect, "PasswordCheckbox",
		B_TRANSLATE("Password lock"), new BMessage(kMsgPasswordCheckBox));
	fPasswordCheckBox->ResizeToPreferred();
	box->AddChild(fPasswordCheckBox);

	rect.top += 3;
	rect.left += radioButtonOffset + labelWidth;
	fPasswordSlider = new TimeSlider(rect, "PasswordSlider",
		kMsgPasswordSliderChanged, kMsgPasswordSliderUpdate);
	fPasswordSlider->ResizeTo(fPasswordSlider->Bounds().Width(), height);
	box->AddChild(fPasswordSlider);

	rect.OffsetBy(0, fTurnOffSlider->Bounds().Height() + 4.0f);
	rect.left = rect.right;
	fPasswordButton = new BButton(rect, "PasswordButton",
		B_TRANSLATE("Password" B_UTF8_ELLIPSIS),
		new BMessage(kMsgChangePassword), B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fPasswordButton->ResizeToPreferred();
	fPasswordButton->MoveBy(-fPasswordButton->Bounds().Width(), 0);
	box->AddChild(fPasswordButton);

	// Bottom

	float monitorHeight = 10 + textHeight * 3;
	float monitorWidth = monitorHeight * 4 / 3;
	rect.left = 11;
	rect.top = box->Bounds().Height() - 15 - monitorHeight;
	rect.right = rect.left + monitorWidth;
	rect.bottom = rect.top + monitorHeight;
	box->AddChild(fFadeNow = new ScreenCornerSelector(rect, "FadeNow",
		new BMessage(kMsgFadeCornerChanged), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM));

	rect.OffsetBy(monitorWidth + 10, 0);
	stringView = new BStringView(rect, NULL, B_TRANSLATE("Fade now when"),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	stringView->ResizeToPreferred();
	float maxWidth = stringView->Bounds().Width();
	box->AddChild(stringView);

	rect.OffsetBy(0, stringView->Bounds().Height());
	stringView = new BStringView(rect, NULL, B_TRANSLATE("mouse is here"),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	stringView->ResizeToPreferred();
	if (maxWidth < stringView->Bounds().Width())
		maxWidth = stringView->Bounds().Width();
	box->AddChild(stringView);

	rect.left += maxWidth + 20;
	rect.top = box->Bounds().Height() - 15 - monitorHeight;
	rect.right = rect.left + monitorWidth;
	rect.bottom = rect.top + monitorHeight;
	box->AddChild(fFadeNever = new ScreenCornerSelector(rect, "FadeNever",
		new BMessage(kMsgNeverFadeCornerChanged),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM));

	rect.OffsetBy(monitorWidth + 10, 0);
	stringView = new BStringView(rect, NULL,B_TRANSLATE("Don't fade when"),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	stringView->ResizeToPreferred();
	if (maxWidth < stringView->Bounds().Width())
		maxWidth = stringView->Bounds().Width();
	box->AddChild(stringView);

	rect.OffsetBy(0, stringView->Bounds().Height());
	stringView = new BStringView(rect, NULL, B_TRANSLATE("mouse is here"),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	stringView->ResizeToPreferred();
	if (maxWidth < stringView->Bounds().Width())
		maxWidth = stringView->Bounds().Width();
	box->AddChild(stringView);

	float size = rect.left + maxWidth + 40;
	if (fMinWidth < size)
		fMinWidth = size;
	size = fPasswordButton->Frame().bottom + box->Frame().top
		+ monitorHeight + 40 + textHeight * 2;
	if (fMinHeight < size)
		fMinHeight = size;
}
Exemple #7
0
BView* PrefsWindow::constructCommandBox(BRect frame)
{
	BBox* commandBox = new BBox(frame);
	commandBox->SetLabel("Commands");
	
	float 	offset = 30.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f,			
			globalTcOffset = 45.0f,		
			bitoffset = 45.0,
			secOffset = 170.0f
			;
				
	BRect textCtrlFrame(offset / 2.0f, offset, offset / 2.0f + 300.0f, offset + 20.0f);
	BStringView *textCtrlInfo = new BStringView(textCtrlFrame, "info", "The \'$\' represents the filename in filename.tex");
	commandBox->AddChild(textCtrlInfo);	
	
	BRect bitRect(offset / 2.0f, offset + globalTcOffset, offset / 2.0f + 31.0f, offset + 31.0f + globalTcOffset);
	BRect secCol(bitRect);	
	secCol.OffsetBy(secOffset, 0.0f);	
	secCol.OffsetBy(0.0f, bitoffset);	
	
	float	textCtrlWidth = 100.0f,
			textCtrlHeight = 20.0f,
			textCtrlCo = 6.0f
			;
			
	BRect bitctrlRect(offset / 2.0f + bitoffset, offset + textCtrlCo + globalTcOffset, offset / 2.0f + bitoffset + textCtrlWidth, textCtrlCo + offset + textCtrlHeight + globalTcOffset);		
	BRect secColCtrl(bitctrlRect);
	secColCtrl.OffsetBy(secOffset, 0.0f);
	secColCtrl.right += 50.0f;
	
	//tex to dvi
	BRect bitmapFrame(0.0f, 0.0f, 31.0f, 31.0f);	
	BBitmap	*texDviBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texDviBitmap->SetBits(IconTexToDVI, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texDviBitmap));
	
	BTextControl *texDviCtrl = new BTextControl(bitctrlRect, K_LATEX_CMD, NULL, "", GetPrefsMessage(K_LATEX_CMD));
	commandBox->AddChild(texDviCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//dvi to pdf
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* dviPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	dviPdfBitmap->SetBits(IconDVIToPDF, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, dviPdfBitmap));
	
	BTextControl *dviPdfCtrl = new BTextControl(bitctrlRect, K_DVIPDF_CMD, NULL, "",  GetPrefsMessage(K_DVIPDF_CMD));
	commandBox->AddChild(dviPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//dvi to ps
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* dviPsBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	dviPsBitmap->SetBits(IconDVIToPS, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, dviPsBitmap));
	
	BTextControl *dviPsCtrl = new BTextControl(bitctrlRect, K_DVIPS_CMD, NULL, "",  GetPrefsMessage(K_DVIPS_CMD));
	commandBox->AddChild(dviPsCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//ps to pdf
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* psPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	psPdfBitmap->SetBits(IconPSToPDF, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, psPdfBitmap));
	
	BTextControl *psPdfCtrl = new BTextControl(bitctrlRect, K_PS2PDF_CMD, NULL, "",  GetPrefsMessage(K_PS2PDF_CMD));
	commandBox->AddChild(psPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//tex to pdf
	bitRect.OffsetBy(0.0f, bitoffset);			
	BBitmap* texPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texPdfBitmap->SetBits(IconTexToPDF,3072,0,B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texPdfBitmap));
	
	BTextControl *texPdfCtrl = new BTextControl(bitctrlRect, K_PDFLATEX_CMD, NULL, "",  GetPrefsMessage(K_PDFLATEX_CMD));
	commandBox->AddChild(texPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//tex to html
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* texHtmlBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texHtmlBitmap->SetBits(IconTexToHTML, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texHtmlBitmap));
	
	BTextControl *texHtmlCtrl = new BTextControl(bitctrlRect, K_LATEX2HTML_CMD, NULL, "",  GetPrefsMessage(K_LATEX2HTML_CMD));
	commandBox->AddChild(texHtmlCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//ps
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* postScriptBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	postScriptBitmap->SetBits(IconPrevPS, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(secCol, postScriptBitmap));
	
	BTextControl *postScriptCtrl = new BTextControl(secColCtrl, K_POSTSCRIPT_CMD, NULL, "", GetPrefsMessage(K_POSTSCRIPT_CMD));
	commandBox->AddChild(postScriptCtrl);
		
	BRect comboxRect = commandBox->Bounds();
	BRect comboxbtnRect(comboxRect.right - bspacing - bwidth, comboxRect.bottom - bspacing - bheight, comboxRect.right - bspacing, comboxRect.bottom - bspacing);
	BButton *resetCommandDefaults = new BButton(comboxbtnRect,"resetCommandDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS));
	commandBox->AddChild(resetCommandDefaults);
	
	return commandBox;
}
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
	: BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
		"Application Type", B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
	fChangedProperties(0)
{
	// add the menu

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

	BMenu* menu = new BMenu("File");
	fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
	fSaveMenuItem->SetEnabled(false);
	menu->AddItem(fSaveMenuItem);
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
		NULL));
	item->SetEnabled(false);

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
		'W', B_COMMAND_KEY));
	menuBar->AddItem(menu);

	// Top view and signature

	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);

	rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
	fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
		new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
	fSignatureControl->SetModificationMessage(
		new BMessage(kMsgSignatureChanged));
	fSignatureControl->SetDivider(fSignatureControl->StringWidth(
		fSignatureControl->Label()) + 4.0f);
	float width, height;
	fSignatureControl->GetPreferredSize(&width, &height);
	fSignatureControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fSignatureControl);

	// filter out invalid characters that can't be part of a MIME type name
	BTextView* textView = fSignatureControl->TextView();
	textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
	const char* disallowedCharacters = "<>@,;:\"()[]?=";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	// "Application Flags" group

	BFont font(be_bold_font);
	font_height fontHeight;
	font.GetHeight(&fontHeight);

	width = font.StringWidth("Icon") + 16.0f;
	if (width < B_LARGE_ICON + 16.0f)
		width = B_LARGE_ICON + 16.0f;

	rect.top = fSignatureControl->Frame().bottom + 4.0f;
	rect.bottom = rect.top + 100.0f;
	rect.right -= width + 8.0f;
	BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	topView->AddChild(box);

	fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
		new BMessage(kMsgToggleAppFlags));
	fFlagsCheckBox->SetValue(B_CONTROL_ON);
	fFlagsCheckBox->ResizeToPreferred();
	box->SetLabel(fFlagsCheckBox);

	rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
	fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
		new BMessage(kMsgAppFlagsChanged));
	fSingleLaunchButton->ResizeToPreferred();
	box->AddChild(fSingleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fMultipleLaunchButton = new BRadioButton(rect, "multiple",
		"Multiple launch", new BMessage(kMsgAppFlagsChanged));
	fMultipleLaunchButton->ResizeToPreferred();
	box->AddChild(fMultipleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
		"Exclusive launch", new BMessage(kMsgAppFlagsChanged));
	fExclusiveLaunchButton->ResizeToPreferred();
	box->AddChild(fExclusiveLaunchButton);

	rect.top = fSingleLaunchButton->Frame().top;
	rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
	fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
		new BMessage(kMsgAppFlagsChanged));
	fArgsOnlyCheckBox->ResizeToPreferred();
	box->AddChild(fArgsOnlyCheckBox);

	rect.top += fArgsOnlyCheckBox->Bounds().Height();
	fBackgroundAppCheckBox = new BCheckBox(rect, "background",
		"Background app", new BMessage(kMsgAppFlagsChanged));
	fBackgroundAppCheckBox->ResizeToPreferred();
	box->AddChild(fBackgroundAppCheckBox);

	box->ResizeTo(box->Bounds().Width(),
		fExclusiveLaunchButton->Frame().bottom + 8.0f);

	// "Icon" group

	rect = box->Frame();
#ifdef __ANTARES__
	rect.top += box->TopBorderOffset();
#endif
	rect.left = rect.right + 8.0f;
	rect.right += width + 8.0f;
	float iconBoxWidth = rect.Width();
	box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	box->SetLabel("Icon");
#ifdef __ANTARES__
	box->MoveBy(0.0f, -box->TopBorderOffset());
	box->ResizeBy(0.0f, box->TopBorderOffset());
#endif
	topView->AddChild(box);

	rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f);
#ifdef __ANTARES__
	rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset()
		- rect.Height()) / 2.0f);
#else
	rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f);
#endif
	if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f)
		rect.top = fontHeight.ascent + fontHeight.descent + 4.0f;
	fIconView = new IconView(rect, "icon");
	fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
	box->AddChild(fIconView);

	// "Supported Types" group

	rect.top = box->Frame().bottom + 8.0f;
	rect.bottom = rect.top + box->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	typeBox->SetLabel("Supported types");
	topView->AddChild(typeBox);

	rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f);
	rect.top += ceilf(fontHeight.ascent);
	fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddType), B_FOLLOW_RIGHT);
	fAddTypeButton->ResizeToPreferred();
	fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width()
		- B_LARGE_ICON - 16.0f, 0.0f);
	typeBox->AddChild(fAddTypeButton);

	rect = fAddTypeButton->Frame();
	rect.OffsetBy(0, rect.Height() + 4.0f);
	fRemoveTypeButton = new BButton(rect, "remove type", "Remove",
		new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT);
	typeBox->AddChild(fRemoveTypeButton);

	rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.left = 10.0f;
	rect.top = 8.0f + ceilf(fontHeight.ascent);
	rect.bottom -= 2.0f;
		// take scrollview border into account
	fTypeListView = new SupportedTypeListView(rect, "type listview",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
		B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f);
	typeBox->AddChild(scrollView);

	rect.left = fRemoveTypeButton->Frame().right + 8.0f;
#ifdef __ANTARES__
	rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f;
#else
	rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f;
#endif
	rect.right = rect.left + B_LARGE_ICON - 1.0f;
	rect.bottom = rect.top + B_LARGE_ICON - 1.0f;
	fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged));
	typeBox->AddChild(fTypeIconView);

	// "Version Info" group

	rect.top = typeBox->Frame().bottom + 8.0f;
	rect.bottom = rect.top + typeBox->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
		// the resizing mode will later also be set to B_FOLLOW_BOTTOM
	box->SetLabel("Version info");
	topView->AddChild(box);

	BMenuField* menuField;
#if 0
	BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true);
	item = new BMenuItem("Version Info", NULL);
	item->SetMarked(true);
	popUpMenu->AddItem(item);
	item = new BMenuItem("System Version Info", NULL);
	popUpMenu->AddItem(item);

	menuField = new BMenuField(BRect(0, 0, 100, 15),
		"version kind", NULL, popUpMenu, true);
	menuField->ResizeToPreferred();
	box->SetLabel(menuField);
#endif

	rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent);
	rect.bottom = rect.top + height;
	fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL,
		NULL);
	fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth(
		fMajorVersionControl->Label()) + 4.0f);
	fMajorVersionControl->GetPreferredSize(&width, &height);
	width = 12.0f + fMajorVersionControl->StringWidth("99");
	fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMajorVersionControl);
	box->AddChild(fMajorVersionControl);

	rect.left = fMajorVersionControl->Frame().right + 1.0f;
	fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth(
		fMiddleVersionControl->Label()) + 4.0f);
	fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMiddleVersionControl);
	box->AddChild(fMiddleVersionControl);

	rect.left = fMiddleVersionControl->Frame().right + 1.0f;
	fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth(
		fMinorVersionControl->Label()) + 4.0f);
	fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMinorVersionControl);
	box->AddChild(fMinorVersionControl);

	fVarietyMenu = new BPopUpMenu("variety", true, true);
	fVarietyMenu->AddItem(new BMenuItem("Development", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Beta", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL));
	fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL));
	item->SetMarked(true);
	fVarietyMenu->AddItem(new BMenuItem("Final", NULL));

	rect.top--;
		// BMenuField oddity
	rect.left = fMinorVersionControl->Frame().right + 6.0f;
	menuField = new BMenuField(rect,
		"variety", NULL, fVarietyMenu, true);
	menuField->ResizeToPreferred();
	box->AddChild(menuField);

	rect.top++;
	rect.left = menuField->Frame().right;
	rect.right = rect.left + 30.0f;	
	fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL,
		NULL);
	fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth(
		fInternalVersionControl->Label()) + 4.0f);
	fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height);
	box->AddChild(fInternalVersionControl);

	rect = box->Bounds().InsetByCopy(8.0f, 0.0f);
	rect.top = fInternalVersionControl->Frame().bottom + 8.0f;
	fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:",
		NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	float labelWidth = fShortDescriptionControl->StringWidth(
		fShortDescriptionControl->Label()) + 4.0f;
	fShortDescriptionControl->SetDivider(labelWidth);
	fShortDescriptionControl->GetPreferredSize(&width, &height);
	fShortDescriptionControl->ResizeTo(rect.Width(), height);

	// TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says?
	version_info versionInfo;
	fShortDescriptionControl->TextView()->SetMaxBytes(sizeof(versionInfo.short_info));
	box->AddChild(fShortDescriptionControl);

	rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f);
	rect.right = rect.left + labelWidth;
	StringView* label = new StringView(rect, NULL, "Long description:", NULL);
	label->SetDivider(labelWidth);
	box->AddChild(label);

	rect.left = rect.right + 3.0f;
	rect.top += 1.0f;
	rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f;
	fLongDescriptionView = new TabFilteringTextView(rect, "long desc",
		rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
		| B_NAVIGABLE);
	fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));

	scrollView = new BScrollView("desc scrollview", fLongDescriptionView,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f);
	box->AddChild(scrollView);

	// Adjust window size and limits

	width = fInternalVersionControl->Frame().right + 16.0f;
	float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f;
	if (width > minWidth)
		minWidth = width;

	ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth,
		box->Frame().bottom + topView->Frame().top + 8.0f);
	SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f);
	typeBox->SetResizingMode(B_FOLLOW_ALL);
	box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);

	fSignatureControl->MakeFocus(true);

	BMimeType::StartWatching(this);
	_SetTo(entry);
}
NetworkWindow::NetworkWindow()
  : BWindow(BRect(0, 0, 435, 309),"Network",
			B_TITLED_WINDOW,B_NOT_ANCHORED_ON_ACTIVATE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE,
			B_CURRENT_WORKSPACE) 
{
	BScreen screen;
	
	BRect screenframe = screen.Frame(), bounds = Bounds(), workrect(0,0,1,1);
	float width,height;
	float screenx, screeny;
	
	screenx = ((screenframe.right + 1) / 2) - (bounds.right / 2) - 1;
	screeny = ((screenframe.bottom + 1) / 2) - (bounds.bottom / 2) - 1;
	MoveTo(screenx, screeny);
	
	fView = new BView(bounds,"View",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
	fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(fView);
	
	fRestart = new BButton(workrect,"Restart_Networking",
							"Restart Networking",new BMessage(kRestart_Networking_M),
							B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fRestart->GetPreferredSize(&width,&height);
	fRestart->ResizeTo(width,height);
	fRestart->MoveTo(10,bounds.bottom - 10 - height);
	
	// We fake the divider line by using a BBox. We have to call ConstrainClippingRegion
	// because otherwise we also see the corners drawn, which doesn't look nice
	BBox *vr = new BBox(BRect(width + 18, bounds.bottom - 11 - height, width + 19,
								bounds.bottom - 9),
						"vertical_rule", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fView->AddChild(vr);
	
	BRegion clipreg(vr->Bounds().InsetByCopy(0,2));
	vr->ConstrainClippingRegion(&clipreg);
	
	fRevert = new BButton(BRect(width + 25,bounds.bottom - 10 - height,width + 26,
								bounds.bottom - 10),
						"Revert","Revert", new BMessage(kRevert_M),
						B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fRevert->ResizeToPreferred();
	fRevert->SetEnabled(false);
	
	fSave = new BButton(workrect,"Save","Save",new BMessage(kSave_M),
						B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fSave->GetPreferredSize(&width,&height);
	fSave->ResizeTo(width,height);
	fSave->MoveTo(bounds.right - 10 - width, bounds.bottom - 10 - height);
	fSave->MakeDefault(true);
	fSave->SetEnabled(false);
	
	BBox *hr = new BBox(BRect(0,bounds.bottom - height - 20,bounds.right,
								bounds.bottom - height - 19),
						"horizontal_rule",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
	fView->AddChild(hr);
	
	workrect = Bounds();
	workrect.bottom = hr->Frame().top;
	workrect.top = 10;
	
	fTabView = new BTabView(workrect,"tab_view",B_WIDTH_FROM_WIDEST, B_FOLLOW_ALL);
	fTabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));	
	fView->AddChild(fTabView);
	bounds.bottom -= fTabView->TabHeight();

	fView->AddChild(fRestart);
	fView->AddChild(fRevert);	
	fView->AddChild(fSave);
	
	bounds = fTabView->Bounds();
	bounds.bottom -= fTabView->TabHeight();
	
	fIdentityView = new BView(bounds,"Identity",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
	fIdentityView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	fIdentity = new BTab();
	fTabView->AddTab(fIdentityView,fIdentity);
	
	// We can just pick a view to call StringWidth because we're not using anything
	// except the unaltered be_plain_font. Note that for each BTextControl pair we
	// just use the longer word of the two in order to save us some speed and code size
	float labelwidth = fTabView->StringWidth("Domain name: ");
	
	workrect.Set(10,20,11,21);
	fDomain = new BTextControl(workrect,"Domain_Name","Domain name:"," ",
							new BMessage(kSOMETHING_HAS_CHANGED_M));  
	
	// BTextControl::ResizeToPreferred() is a little strange for our purposes, so we
	// get the preferred size and ignore the width that we get.
	fDomain->GetPreferredSize(&width, &height);
	fDomain->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
	fDomain->SetDivider(labelwidth);
	
	workrect.left = 10;
	workrect.right = 11;
	workrect.top = height + 30;
	workrect.bottom = workrect.top + height;
	
	fHost = new BTextControl(workrect,"Host_Name","Host name:",NULL,
							new BMessage(kSOMETHING_HAS_CHANGED_M));   
	fHost->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
	fHost->SetDivider(labelwidth);
	
	labelwidth = fTabView->StringWidth("Secondary DNS: ");
	
	workrect.OffsetTo((bounds.right / 2),20);
	workrect.right = bounds.right - 30;
	fPrimaryDNS = new BTextControl(workrect,"Primary_DNS","Primary DNS:",
								NULL,new BMessage(kSOMETHING_HAS_CHANGED_M),
								B_FOLLOW_TOP | B_FOLLOW_RIGHT);  
	fPrimaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
	fPrimaryDNS->SetDivider(labelwidth);
	
	workrect.OffsetBy(0,height + 10);
	fSecondaryDNS = new BTextControl(workrect,"Secondary_DNS","Secondary DNS:",
								NULL,new BMessage(kSOMETHING_HAS_CHANGED_M),
								B_FOLLOW_TOP | B_FOLLOW_RIGHT);  
	fSecondaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);			
	fSecondaryDNS->SetDivider(labelwidth);
	
	fNames = new BBox(BRect(10,10,bounds.right - 10, (height * 2) + 50),
					"Names",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,B_WILL_DRAW | 
					B_FRAME_EVENTS);
	fIdentityView->AddChild(fNames);
	fNames->SetLabel("Names");
	
	fNames->AddChild(fDomain);
	fNames->AddChild(fHost);
	fNames->AddChild(fPrimaryDNS);
	fNames->AddChild(fSecondaryDNS);
	
	// BTextControl resizing operations don't do anything under R5 unless they
	// have an owner. To make things worse, BTabView does some of its BView hierarchy
	// stuff in AttachedToWindow such that if you add a tab before it's attached to 
	// a window, it won't be visible. :( As such, we make an extra call to 
	// AttachedToWindow to be assured that everything works the way it is intended.
	fTabView->AttachedToWindow();
	fDomain->ResizeTo( (bounds.right / 2) - 25, height);
	fHost->ResizeTo( (bounds.right / 2) - 25, height);
	
	workrect.left = 10;
	workrect.right = bounds.right - 10;
	workrect.top = fNames->Frame().bottom + 10;
	workrect.bottom = fIdentityView->Bounds().bottom - 15;
	fInterfaces = new BBox(workrect,"Network_Interfaces",B_FOLLOW_ALL,
						B_WILL_DRAW | B_FRAME_EVENTS); 
	fInterfaces->SetLabel("Network Interfaces");
	fIdentityView->AddChild(fInterfaces);
	
	workrect = fInterfaces->Bounds().InsetByCopy(5,5);
	fSettings = new BButton(BRect(0,0,1,1),"Settings","Settings" B_UTF8_ELLIPSIS,
							new BMessage(kSettings_M),
							B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fSettings->ResizeToPreferred();
	fSettings->MoveTo(workrect.right - 5 - fSettings->Bounds().Width(), 15);
	fInterfaces->AddChild(fSettings);
	
	workrect = fSettings->Frame();
	workrect.OffsetBy(0,workrect.Height()+5);
	
	fClear = new BButton(workrect,"Clear","Clear",new BMessage(kClear_M),
						B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fInterfaces->AddChild(fClear);
	
	workrect.OffsetBy(0,workrect.Height()+15);
	fCustom = new BButton(workrect,"Custom","Custom" B_UTF8_ELLIPSIS,new BMessage(kCustom_M),
							B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fInterfaces->AddChild(fCustom);
	
	if(workrect.bottom > fInterfaces->Bounds().bottom)
		ResizeBy(0,workrect.bottom - fInterfaces->Bounds().bottom + 10);
	
	workrect.left = 10;
	workrect.top = 20;
	workrect.right = fCustom->Frame().left - 15 - B_V_SCROLL_BAR_WIDTH;
	workrect.bottom = fCustom->Frame().bottom - 5;
	
	fInterfacesList = new NetListView(workrect,"Interfaces_List");	
	BScrollView *interfaces_scroller = new BScrollView("Interfaces_Scroller",
														fInterfacesList, B_FOLLOW_ALL,
														0, 0, 1, B_FANCY_BORDER);	
	fInterfaces->AddChild(interfaces_scroller);
	
	fServicesView = new BView(bounds,"Services",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
	fServicesView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fServices = new BTab();
	fTabView->AddTab(fServicesView,fServices);
	
	workrect.Set(10,10,11,11);
	fFTPServer = new BCheckBox(workrect,"FTP_Server","FTP Server",
								new BMessage(kSOMETHING_HAS_CHANGED_M));
	fFTPServer->GetPreferredSize(&width,&height);
	fFTPServer->ResizeTo(width,height);
	fServicesView->AddChild(fFTPServer);
	
	fTelnetServer = new BCheckBox(workrect,"Telnet_Server","Telnet Server",
								new BMessage(kSOMETHING_HAS_CHANGED_M));
	fTelnetServer->ResizeToPreferred();
	fTelnetServer->MoveTo(10,height + 15);
	fServicesView->AddChild(fTelnetServer);
	
	fLoginInfo = new BButton(workrect,"Login_Info","Login Info" B_UTF8_ELLIPSIS,
								new BMessage(kLogin_Info_M));
	fLoginInfo->ResizeToPreferred();
	fLoginInfo->MoveTo(10,(height * 2) + 25);
	fServicesView->AddChild(fLoginInfo);
	
	workrect = fLoginInfo->Frame();
	workrect.left -= 5;
	workrect.top = workrect.bottom + 10;
	workrect.bottom = workrect.top + 1;
	workrect.right += 70;
	BBox *hr2 = new BBox(workrect,"horizontal_rule2",B_FOLLOW_LEFT | B_FOLLOW_TOP);
	fServicesView->AddChild(hr2);
	
	
	fAppleTalk = new BCheckBox(workrect,"Apple_Talk","Apple Talk",
								new BMessage(kSOMETHING_HAS_CHANGED_M));
	fAppleTalk->ResizeToPreferred();
	fAppleTalk->MoveTo(10, workrect.bottom + 10);
	fServicesView->AddChild(fAppleTalk);
	
	fIPForwarding = new BCheckBox(workrect,"IP_Forwarding","IP Forwarding",
								new BMessage(kSOMETHING_HAS_CHANGED_M));
	fIPForwarding->ResizeToPreferred();
	fIPForwarding->MoveTo(10, fAppleTalk->Frame().bottom + 5);
	fServicesView->AddChild(fIPForwarding);
	
	workrect = bounds.InsetByCopy(10,10);
	workrect.bottom += 10;
	workrect.left = hr2->Frame().right + 10;
	fConfigurations = new BBox(workrect,"Configurations",B_FOLLOW_ALL,
								B_WILL_DRAW | B_FRAME_EVENTS); 							
	fConfigurations->SetLabel("Configurations");
	fServicesView->AddChild(fConfigurations);
	
	workrect = fConfigurations->Bounds();
	fBackup = new BButton(BRect(0,0,1,1),"Backup","Backup", new BMessage(kBackup_M));
	fBackup->GetPreferredSize(&width,&height);
	fBackup->ResizeTo(width,height);
	fBackup->MoveTo(workrect.right - width - 10,15);
	fConfigurations->AddChild(fBackup);
	
	fRestore = new BButton(BRect(0,0,width,height),"Restore","Restore",
							new BMessage(kRestore_M));
	fConfigurations->AddChild(fRestore);
	fRestore->MoveTo(workrect.right - width - 10, 20 + height);
	fRestore->SetEnabled(false);
	
	fRemove = new BButton(BRect(0,0,width,height),"Delete","Delete",
							new BMessage(kDelete_M));
	fRemove->MoveTo(workrect.right - width - 10, 25 + (height * 2));
	fRemove->SetEnabled(false);
	fConfigurations->AddChild(fRemove);

	workrect = fConfigurations->Bounds().InsetByCopy(15,15);
	workrect.top += 5;
	workrect.right = fBackup->Frame().left - 10 - B_V_SCROLL_BAR_WIDTH;
	fConfigurationsList = new NetListView(workrect,"Configurations_List");	
	BScrollView *configurations_scroller = new BScrollView("Configurations_Scroller",
														fConfigurationsList, 
														B_FOLLOW_ALL, 0, 0, 1,
														B_FANCY_BORDER);	
	fConfigurations->AddChild(configurations_scroller);
	
	LoadConfigEntries();
	LoadSettings();
	
	fTabView->AttachedToWindow();
}
Exemple #10
0
MenuWindow::MenuWindow(const char* name)
	: BWindow(BRect(60,60,60,60), name, B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	m_bUsingFullMenuBar = true;
	
	// menu bars
	BRect dummyFrame(0, 0, 0, 0);
	m_pFullMenuBar = new BMenuBar(dummyFrame, "Full Menu Bar");
	m_pHiddenMenuBar = new BMenuBar(dummyFrame, "Menu Bar w. Hidden User Menus");
	
	// File menu
	BMenu* pMenu = BuildFileMenu();
	if (pMenu) {
		m_pFullMenuBar->AddItem(pMenu);
	}
	pMenu = BuildFileMenu();
	if (pMenu) {
		m_pHiddenMenuBar->AddItem(pMenu);
	}
	
	// Test menu
	pMenu = m_testMenuBuilder.BuildTestMenu(B_MINI_ICON);
	if (pMenu) {
		m_pFullMenuBar->AddItem(pMenu);
	}
	pMenu = m_testMenuBuilder.BuildTestMenu(B_MINI_ICON);
	if (pMenu) {
		m_pHiddenMenuBar->AddItem(pMenu);
	}
	 
	// add child after menus are added so its initially
	// calculated app_server bounds take added menus into
	// account
	AddChild(m_pFullMenuBar);
	
	float menuHeight = m_pFullMenuBar->Bounds().Height();
	
	// Menu view
	m_pMenuView = new MenuView(B_FOLLOW_NONE); // don't follow window just yet!
	m_pMenuView->MoveBy(0, menuHeight + 1);
	AddChild(m_pMenuView);

	// Status view	
	BRect menuViewRect = m_pMenuView->Frame();
	float top = menuViewRect.bottom + 1;
	font_height plainHeight;
	be_plain_font->GetHeight(&plainHeight);
	
	// Simulate a vertical divider by making a BBox where only the top side
	// can be seen in the window.
	BRect boxFrame;
	boxFrame.Set(menuViewRect.left - 2, 
		top,
		menuViewRect.right + 2,
		top + plainHeight.ascent + plainHeight.descent + plainHeight.leading + 4);
	
	BBox* pStatusBox = new BBox(boxFrame);
	AddChild(pStatusBox);

	BRect statusFrame = pStatusBox->Bounds();
	statusFrame.InsetBy(2,2);	
	m_pStatusView = new BStringView(statusFrame, "Status View", STR_STATUS_DEFAULT,
		B_FOLLOW_ALL); // don't follow window just yet!
	m_pStatusView->SetViewColor(BKG_GREY);
	pStatusBox->AddChild(m_pStatusView);
	
	// Resize window dynamically to fit MenuView (and Status View)
	float windowWidth = m_pMenuView->Frame().right;
	float windowHeight = boxFrame.bottom - 4;
	ResizeTo(windowWidth, windowHeight);
}
DataView::DataView(BRect size)
	:
	BView(size, "DataView", B_FOLLOW_NONE, B_WILL_DRAW)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect r;
	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.bottom = 90;
	IconLabel* fileSystemLabel = new IconLabel(BRect(0, 0, 28 + be_bold_font->StringWidth(" Filesystem"), 19), " Filesystem", "datacd_16.png");
	fileSystemLabel->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fileSystemLabel->SetDrawingMode(B_OP_ALPHA);
	BBox* fileSystemBox = new BBox(r, "fFileSystemBox", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	fileSystemBox->SetLabel(fileSystemLabel);
	AddChild(fileSystemBox);
	r = fileSystemBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.right = 220;
	r.bottom = 25;
	BRadioButton* ISO9660Radio = new BRadioButton(r, "ISO-9660", "ISO-9660", new BMessage(DATA_ISO9660));
	if (!strcmp(DATA_STRING, " ") && IMAGE_TYPE == 0)
		ISO9660Radio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(ISO9660Radio);


	r.bottom += 15;
	r.top += 15;
	BRadioButton* windowsRadio = new BRadioButton(r, "ISO-9660 with long filenames", "ISO-9660 with long filenames", new BMessage(DATA_WINDOWS));
	if (!strcmp(DATA_STRING, "-D -l") && IMAGE_TYPE == 0)
		windowsRadio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(windowsRadio);

	r.bottom += 15;
	r.top += 15;
	BRadioButton* jolietRadio = new BRadioButton(r, "fJolietRadio", "Windows (Joliet)", new BMessage(DATA_JOLIET));
	if (!strcmp(DATA_STRING, "-l -D -J") && IMAGE_TYPE == 0)
		jolietRadio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(jolietRadio);

	r.bottom += 15;
	r.top += 15;
	fBeOSRadio = new BRadioButton(r, "Haiku", "Haiku (bfs)", new BMessage(DATA_BFS));
	if (IMAGE_TYPE == 1)
		fBeOSRadio->SetValue(B_CONTROL_ON);

	fileSystemBox->AddChild(fBeOSRadio);


	r = fileSystemBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.bottom = 25;
	r.left = 230;
	BRadioButton* rockRadio = new BRadioButton(r, "RockRidge (UNIX Multiuser)", "RockRidge (UNIX Singeluser)", new BMessage(DATA_ROCK));
	if (!strcmp(DATA_STRING, "-l -L -r") && IMAGE_TYPE == 0)
		rockRadio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(rockRadio);

	r.bottom += 15;
	r.top += 15;
	BRadioButton* realRockRadio = new BRadioButton(r, "Real RockRidge (UNIX Multiuser)", "Real RockRidge (UNIX Multiuser)", new BMessage(DATA_REALROCK));
	if (!strcmp(DATA_STRING, "-l -L -R") && IMAGE_TYPE == 0)
		realRockRadio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(realRockRadio);

	r.bottom += 15;
	r.top += 15;
	BRadioButton* macRadio = new BRadioButton(r, "fMacRadio", "Mac (hfs)", new BMessage(DATA_HFS));
	if (!strcmp(DATA_STRING, "-hfs") && IMAGE_TYPE == 0)
		macRadio->SetValue(B_CONTROL_ON);
	fileSystemBox->AddChild(macRadio);

	r.bottom += 15;
	r.top += 15;
	BRadioButton* ownRadio = new BRadioButton(r, "own", "Own (choose mkisofs options)", new BMessage(DATA_HFS));
//	if(!strcmp(DATA_STRING,"-hfs"))
//		fMacRadio->SetValue(B_CONTROL_ON);
	ownRadio->SetEnabled(false);
	fileSystemBox->AddChild(ownRadio);

	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.top = 95;
	r.right = r.right - 160;

	IconLabel* bootLabel = new IconLabel(BRect(0, 0, 19 + 
	                       be_bold_font->StringWidth(" El Torito Bootable CD"), 19), " El Torito Bootable CD", "bootcd_16.png");
	bootLabel->SetDrawingMode(B_OP_ALPHA);                       
	bootLabel->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BBox* bootBox = new BBox(r, "BootBox", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	bootBox->SetLabel(bootLabel);
	AddChild(bootBox);

	r = bootBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.bottom = r.top + 15;
	fBootableCDCheckBox = new BCheckBox(r, "fBootableCDCheckBox", "Enable BootableCD", new BMessage(BOOT_CHECKED));
	if (BOOTABLE)
		fBootableCDCheckBox->SetValue(B_CONTROL_ON);
	if (!VRCD)
		fBootableCDCheckBox->SetEnabled(false);

	bootBox->AddChild(fBootableCDCheckBox);

	r = bootBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 35;
	fChooseBootImageButton = new BButton(r, "fChooseBootImageButton", "Choose boot image", new BMessage(BOOT_FILE_PANEL));
	if (!BOOTABLE || !VRCD)
		fChooseBootImageButton->SetEnabled(false);
	bootBox->AddChild(fChooseBootImageButton);

	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.top = 135;
	r.left = r.right - 150;
	r.bottom = 165;

	AddChild(new BButton(r, "Change Volume Name", "Change Volume Name", new BMessage(CHANGE_VOL_NAME)));

	fFilePanel = new BFilePanel(B_OPEN_PANEL);
	fFilePanel->SetMessage(new BMessage(BOOT_CHANGE_IMAGE_NAME));
}
Exemple #12
0
TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
	: SettingsView(rect, "WindowsSettingsView")
{
	rect.OffsetTo(B_ORIGIN);

	font_height fontHeight;
	be_bold_font->GetHeight(&fontHeight);

	rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10;
	BBox *clockBox = new BBox(rect, "Clock");
	clockBox->SetLabel("Clock");
	AddChild(clockBox);

	rect.left = 8;
	rect.top = rect.bottom - 8;
	f24HrRadioButton = new BRadioButton(rect, "", "24 hour",
		new BMessage(kSettingsContentsModified));
	f24HrRadioButton->ResizeToPreferred();
	clockBox->AddChild(f24HrRadioButton);

	const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing;
	rect.OffsetBy(0, itemSpacing);

	f12HrRadioButton = new BRadioButton(rect, "", "12 hour",
		new BMessage(kSettingsContentsModified));
	f12HrRadioButton->ResizeToPreferred();
	clockBox->AddChild(f12HrRadioButton);

	float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f;
	clockBox->ResizeTo(width, clockBox->Bounds().Height()
		+ 3 * f12HrRadioButton->Frame().Height());

	rect = clockBox->Frame();
	rect.OffsetBy(rect.Width() + 8, 0);
	BBox *dateFormatBox = new BBox(rect, "Date order");
	dateFormatBox->SetLabel("Date order");
	AddChild(dateFormatBox);

	rect = f24HrRadioButton->Frame();
	fYMDRadioButton = new BRadioButton(rect, "", "Year-month-day",
		new BMessage(kSettingsContentsModified));
	fYMDRadioButton->ResizeToPreferred();
	dateFormatBox->AddChild(fYMDRadioButton);

	rect.OffsetBy(0, itemSpacing);

	fDMYRadioButton = new BRadioButton(rect, "", "Day-month-year",
		new BMessage(kSettingsContentsModified));
	fDMYRadioButton->ResizeToPreferred();
	dateFormatBox->AddChild(fDMYRadioButton);

	rect.OffsetBy(0, itemSpacing);

	fMDYRadioButton = new BRadioButton(rect, "", "Month-day-year",
		new BMessage(kSettingsContentsModified));
	fMDYRadioButton->ResizeToPreferred();
	dateFormatBox->AddChild(fMDYRadioButton);

	dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16,
		dateFormatBox->Bounds().Height());

	BPopUpMenu *menu = new BPopUpMenu("Separator");
	menu->AddItem(new BMenuItem("None", new BMessage(kSettingsContentsModified)));
	menu->AddItem(new BMenuItem("Space", new BMessage(kSettingsContentsModified)));
	menu->AddItem(new BMenuItem("-", new BMessage(kSettingsContentsModified)));
	menu->AddItem(new BMenuItem("/", new BMessage(kSettingsContentsModified)));
	menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified)));
	menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified)));

	rect.left = 0;
	rect.top = clockBox->Frame().bottom + 8;
	rect.right = Bounds().Width() - 8;
	rect.bottom = rect.top + itemSpacing;
	fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu);
	fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f);
	fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT);
	fSeparatorMenuField->ResizeToPreferred();
	AddChild(fSeparatorMenuField);

	rect.OffsetBy(0, itemSpacing + 10);

	BStringView *exampleView = new BStringView(rect, "", "Examples:");
	exampleView->ResizeToPreferred();
	AddChild(exampleView);

	rect.OffsetBy(0, itemSpacing);

	fLongDateExampleView = new BStringView(rect, "", "");
	fLongDateExampleView->ResizeToPreferred();
	AddChild(fLongDateExampleView);

	rect.OffsetBy(0, itemSpacing);

	fShortDateExampleView = new BStringView(rect, "", "");
	fShortDateExampleView->ResizeToPreferred();
	AddChild(fShortDateExampleView);

	_UpdateExamples();
}
void
CDPlayer::BuildGUI()
{
	fStopColor.red = 80;
	fStopColor.green = 164;
	fStopColor.blue = 80;
	fStopColor.alpha = 255;

	fPlayColor.red = 40;
	fPlayColor.green = 230;
	fPlayColor.blue = 40;
	fPlayColor.alpha = 255;

	BRect r(Bounds().InsetByCopy(10, 10));
	BBox *box = new BBox(r, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	AddChild(box);

	r = box->Bounds().InsetByCopy(10, 10);
	r.bottom = 25;

	float labelWidth, labelHeight;
	fCDTitle = new BStringView(r, "CDTitle", B_TRANSLATE("CD drive is empty"),
		B_FOLLOW_LEFT_RIGHT);
	fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
	fCDTitle->ResizeTo(r.Width(), labelHeight);
	box->AddChild(fCDTitle);

	r.bottom = r.top + labelHeight;
	r.OffsetBy(0, r.Height() + 5);

	fCurrentTrack = new BStringView(r, "TrackNumber",
		 "", B_FOLLOW_LEFT_RIGHT);
	box->AddChild(fCurrentTrack);

	r.OffsetBy(0, r.Height() + 5);
	r.right = r.left + (r.Width() / 2);
	fTrackTime = new BStringView(r, "TrackTime",
		 B_TRANSLATE("Track: 88:88 / 88:88"), B_FOLLOW_LEFT_RIGHT);
	fTrackTime->ResizeToPreferred();
	fTrackTime->SetText(B_TRANSLATE("Track: --:-- / --:--"));
	box->AddChild(fTrackTime);

	r.OffsetTo(fTrackTime->Frame().right + 5, r.top);
	fDiscTime = new BStringView(r, "DiscTime",
		B_TRANSLATE("Disc: 88:88 / 88:88"), B_FOLLOW_RIGHT);
	fDiscTime->ResizeToPreferred();
	fDiscTime->SetText(B_TRANSLATE("Disc: --:-- / --:--"));
	box->AddChild(fDiscTime);

	float maxWidth = max_c(fDiscTime->Frame().right, fCDTitle->Frame().right);

	box->ResizeTo(maxWidth + 5, fDiscTime->Frame().bottom + 10);

	fStop = new DrawButton(BRect(0, 0, 1, 1), "Stop",
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_down"),
		new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
	fStop->ResizeToPreferred();
	fStop->MoveTo(10, box->Frame().bottom + 15);
	fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,
		"stop_disabled"));
	AddChild(fStop);
	float stopTop = fStop->Frame().top;


	fPlay = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Play", 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"), 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up_on"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"), 
		new BMessage(M_PLAY), B_FOLLOW_NONE, B_WILL_DRAW);

	fPlay->ResizeToPreferred();
	fPlay->MoveTo(fStop->Frame().right + 2, stopTop);
	AddChild(fPlay);

	fPrevTrack = new DrawButton(BRect(0, 0, 1, 1), "PrevTrack",
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_down"),
		new BMessage(M_PREV_TRACK), 0, B_WILL_DRAW);
	fPrevTrack->ResizeToPreferred();
	fPrevTrack->MoveTo(fPlay->Frame().right + 40, stopTop);
	AddChild(fPrevTrack);

	fNextTrack = new DrawButton(BRect(0, 0, 1, 1), "NextTrack",
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_down"),
		new BMessage(M_NEXT_TRACK), 0, B_WILL_DRAW);
	fNextTrack->ResizeToPreferred();
	fNextTrack->MoveTo(fPrevTrack->Frame().right + 1, stopTop);
	AddChild(fNextTrack);

	fRewind = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "Rewind", 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_down"),
		new BMessage(M_REWIND), 0, B_WILL_DRAW);
	fRewind->ResizeToPreferred();
	fRewind->MoveTo(fNextTrack->Frame().right + 40, stopTop);
	AddChild(fRewind);

	fFastFwd = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "FastFwd", 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_down"),
		new BMessage(M_FFWD), 0, B_WILL_DRAW);
	fFastFwd->ResizeToPreferred();
	fFastFwd->MoveTo(fRewind->Frame().right + 1, stopTop);
	AddChild(fFastFwd);

	r.left = 10;
	r.right = fPlay->Frame().right;
	r.top = fStop->Frame().bottom + 14;
	r.bottom = r.top + 14;
	fVolumeSlider = new VolumeSlider(r, "VolumeSlider",
		0, 255, new BMessage(M_SET_VOLUME), this);
	AddChild(fVolumeSlider);

	fRepeat = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Repeat", 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_off"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"), 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_on"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"), 
		new BMessage(M_REPEAT), B_FOLLOW_NONE, B_WILL_DRAW);
	fRepeat->ResizeToPreferred();
	fRepeat->MoveTo(fPrevTrack->Frame().left, fVolumeSlider->Frame().top - 
		((fRepeat->Frame().Height() - fVolumeSlider->Frame().Height()) / 2));
	AddChild(fRepeat);

	fShuffle = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Shuffle", 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_off"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"), 
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_on"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"), 
		new BMessage(M_SHUFFLE), B_FOLLOW_NONE, B_WILL_DRAW);
	fShuffle->ResizeToPreferred();
	fShuffle->MoveTo(fRepeat->Frame().right + 2, fRepeat->Frame().top);
	AddChild(fShuffle);

	fEject = new DrawButton(BRect(0, 0, 1, 1), "Eject",
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "eject_up"),
		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "eject_down"),
		new BMessage(M_EJECT), 0, B_WILL_DRAW);
	fEject->ResizeToPreferred();
	fEject->MoveTo(fFastFwd->Frame().left, fShuffle->Frame().top);
	AddChild(fEject);

	ResizeTo(box->Frame().right + 10, fVolumeSlider->Frame().bottom + 10);	
}
Exemple #14
0
BView* PrefsWindow::constructToolbarBox(BRect frame)
{
	BBox* toolbarBox = new BBox(frame);
	toolbarBox->SetLabel("Toolbars");
	
	float	vertCbSpacing = 25.0f,
			offset = 30.0f,
			adjust = 5.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f
			;
	
	BRect checkboxRect = BRect((offset * 2.0f / 3.0f), offset - adjust,(offset * 2.0f/ 3.0f) + 150.0f, offset - adjust + vertCbSpacing - 5.0f);	
	
	BCheckBox *tbInvertCheck = new BCheckBox(checkboxRect, K_IS_TEXTBAR_INVERTED,"Invert Toolbar Colours", GetPrefsMessage(K_IS_TEXTBAR_INVERTED));
	bool isTexBarInverted = false;
	tbInvertCheck->SetValue(isTexBarInverted);
	toolbarBox->AddChild(tbInvertCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
		
	BCheckBox *tbGreekHiddenCheck = new BCheckBox(checkboxRect, K_IS_GREEK_HIDDEN,"Greek Letters", GetPrefsMessage(K_IS_GREEK_HIDDEN));
	bool isGreekHidden = false;
	tbGreekHiddenCheck->SetValue(isGreekHidden);
	toolbarBox->AddChild(tbGreekHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);	
	
	BCheckBox *tbBigHiddenCheck = new BCheckBox(checkboxRect, K_IS_BIG_HIDDEN,"Big Operators", GetPrefsMessage(K_IS_BIG_HIDDEN));
	bool isBigHidden = false;
	tbBigHiddenCheck->SetValue(isBigHidden);
	toolbarBox->AddChild(tbBigHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbBinaryHiddenCheck = new BCheckBox(checkboxRect, K_IS_BINARY_HIDDEN,"Binary Operators", GetPrefsMessage(K_IS_BINARY_HIDDEN));
	bool isBinaryHidden = false;
	tbBinaryHiddenCheck->SetValue(isBinaryHidden);
	toolbarBox->AddChild(tbBinaryHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbMiscHiddenCheck = new BCheckBox(checkboxRect, K_IS_MISC_HIDDEN,"Misc Symbols", GetPrefsMessage(K_IS_MISC_HIDDEN));
	bool isMiscHidden = false;
	tbMiscHiddenCheck->SetValue(isMiscHidden);
	toolbarBox->AddChild(tbMiscHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbBinRelHiddenCheck = new BCheckBox(checkboxRect, K_IS_BIN_REL_HIDDEN,"Binary Relations", GetPrefsMessage(K_IS_BIN_REL_HIDDEN));
	bool isBinHidden = false;
	tbBinRelHiddenCheck->SetValue(isBinHidden);
	toolbarBox->AddChild(tbBinRelHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbMMAHiddenCheck = new BCheckBox(checkboxRect, K_IS_MMA_HIDDEN,"Math Mode Accents", GetPrefsMessage(K_IS_MMA_HIDDEN));
	bool isMMAHidden = false;
	tbMMAHiddenCheck->SetValue(isMMAHidden);
	toolbarBox->AddChild(tbMMAHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbIntlHiddenCheck = new BCheckBox(checkboxRect, K_IS_INT_HIDDEN,"International", GetPrefsMessage(K_IS_INT_HIDDEN));
	bool isIntlHidden = false;
	tbIntlHiddenCheck->SetValue(isIntlHidden);
	toolbarBox->AddChild(tbIntlHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbTypeFaceHiddenCheck = new BCheckBox(checkboxRect, K_IS_TYPE_FACE_HIDDEN,"Type Faces", GetPrefsMessage(K_IS_TYPE_FACE_HIDDEN));
	bool isTypeFaceHidden = false;
	tbTypeFaceHiddenCheck->SetValue(isTypeFaceHidden);
	toolbarBox->AddChild(tbTypeFaceHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);
	
	BCheckBox *tbFunctionHiddenCheck = new BCheckBox(checkboxRect, K_IS_FUNCTION_HIDDEN,"Functions", GetPrefsMessage(K_IS_FUNCTION_HIDDEN));
	bool isFunctionHidden = false;
	tbFunctionHiddenCheck->SetValue(isFunctionHidden);
	toolbarBox->AddChild(tbFunctionHiddenCheck);
	checkboxRect.OffsetBy(0, vertCbSpacing);		

	BRect toolbarRect = toolbarBox->Bounds();
	BRect toolbarbtnRect(toolbarRect.right-bspacing-bwidth,toolbarRect.bottom-bspacing-bheight,toolbarRect.right-bspacing,toolbarRect.bottom-bspacing);
	BButton *resetToolbarDefaults = new BButton(toolbarbtnRect,"resetToolbarDefaults","Defaults", new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS));
	toolbarBox->AddChild(resetToolbarDefaults);
	
	return toolbarBox;
}
Exemple #15
0
BView* PrefsWindow::constructColourBox(BRect frame)
{
	BBox* colourBox = new BBox(frame);
	colourBox->SetLabel("TexView");

	float	offset = 30.0f,
			texViewWidth = 280.0f,
			texHeight = 200.0f,
			adjust = 5.0f,
			cbheight = 14.0f,
			cbspacing = 10.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f	
			;
			
	BRect bounds = colourBox->Bounds();
	
	float texViewX1 = bounds.right - texViewWidth - (offset * 2.0f / 3.0f);
	float texViewX2 = bounds.right - (offset * 2.0f / 3.0f) - B_V_SCROLL_BAR_WIDTH;
	BRect texViewRect(texViewX1, offset - adjust, texViewX2, offset + texHeight - adjust);	
	BRect texViewTextRect(texViewRect);
		
	/*TexView *texView = new TexView(texViewRect, texViewTextRect, prefs);
	BString sampleText = "Welcome to \\betex!\\\\\n%This is a Comment\n$Phe\\alpha r the Calculus$\n\\subsection{About \\betex}\n\\betex is \\textbf{cool}!\\\\\n``To Be Or Not To Be\'\'\n";
	texView->SetText(sampleText.String(),sampleText.Length());
	texView->MakeEditable(false);
	texView->MakeSelectable(false);
	
	BScrollView *texViewScroll = new BScrollView("textViewScroll", texView, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, false, true, B_FANCY_BORDER);
	texViewScroll->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	colourBox->AddChild(texViewScroll);	
	texView->SetTextRect(texView->Bounds());*/	
	
	//fg colour button
	BRect ccRect((offset*2/3),offset-adjust,offset+150,offset+cbheight-adjust);	
	rgb_color fgColour;
	ColourButton *fgColourButton = new ColourButton(ccRect, GetPrefsMessage(K_FG_COLOUR), fgColour," Text");
	colourBox->AddChild(fgColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color bgColour;
	ColourButton *bgColourButton = new ColourButton(ccRect, GetPrefsMessage(K_BG_COLOUR), bgColour, "Background");
	colourBox->AddChild(bgColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color genericCmdColour;
	ColourButton *genericCmdColourButton = new ColourButton(ccRect, GetPrefsMessage(K_GEN_CMD_COLOUR), genericCmdColour, "Generic Commands");
	colourBox->AddChild(genericCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color formatCmdColour;
	ColourButton *formatCmdColourButton  = new ColourButton(ccRect, GetPrefsMessage(K_FORMAT_CMD_COLOUR), formatCmdColour, "Formatting Commands");
	colourBox->AddChild(formatCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color specialCmdColour;
	ColourButton *specialCmdColourButton = new ColourButton(ccRect, GetPrefsMessage(K_SPECIAL_CMD_COLOUR), specialCmdColour, "Special Commands");
	colourBox->AddChild(specialCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color mathModeColour;
	ColourButton *mathModeColourButton = new ColourButton(ccRect, GetPrefsMessage(K_MATH_MODE_COLOUR), mathModeColour, "Math Mode");
	colourBox->AddChild(mathModeColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color commaColour;
	ColourButton *commaColourButton = new ColourButton(ccRect, GetPrefsMessage(K_COMMA_COLOUR), commaColour, "Quotation Marks");
	colourBox->AddChild(commaColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color commentColour;
	ColourButton *commentColourButton = new ColourButton(ccRect,GetPrefsMessage(K_COMMENT_COLOUR),commentColour,"Comments");
	colourBox->AddChild(commentColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color puncSymbolColour;
	ColourButton *puncSymbolColourButton = new ColourButton(ccRect,GetPrefsMessage(K_PUNC_SYMBOL_COLOUR),puncSymbolColour,"Punctuation / Symbols");
	colourBox->AddChild(puncSymbolColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	//rgb_color htmlColour;
	//ColourButton *htmlColourButton = new ColourButton(ccRect,GetPrefsMessage(K_HTML_COLOUR), htmlColour,"Urls");
	//colourBox->AddChild(htmlColourButton);
	
	BRect cbRect = colourBox->Bounds();
	BRect cbbtnRect(cbRect.right - bspacing - bwidth, cbRect.bottom - bspacing - bheight, cbRect.right - bspacing, cbRect.bottom - bspacing);
	BButton *resetColourDefaults = new BButton(cbbtnRect,"fResetColorDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS));
	colourBox->AddChild(resetColourDefaults);
	
	float	sliderWidth = 300.0f,
			vertOffset = 50.0f,
			minVal = 5.0f,
			maxVal = 30.0f
			;		
	BRect sliderFrame(ccRect.left, ccRect.top + vertOffset, ccRect.left + sliderWidth, ccRect.top + vertOffset + 100.0f);
	BSlider *fontSizeSlider = new BSlider(sliderFrame, K_FONT_SIZE, "Font Size", GetPrefsMessage(K_FONT_SIZE), minVal, maxVal);
	colourBox->AddChild(fontSizeSlider);
	
	fontSizeSlider->SetBarColor(ui_color(B_WINDOW_TAB_COLOR));
	fontSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fontSizeSlider->SetHashMarkCount(26);
	float fontSize = 12.0f;
	fontSizeSlider->SetValue(fontSize);
	fontSizeSlider->SetLimitLabels("Small","Large");
	fontSizeSlider->SetModificationMessage(GetPrefsMessage(K_FONT_SIZE));
		
	rgb_color fire_r = {223,0,50};
	const rgb_color* fillcolor = &fire_r;
	fontSizeSlider->UseFillColor(true,fillcolor);
	
	return colourBox;
}
Exemple #16
0
AddWindow::AddWindow() :
	BWindow(BRect(250,70,640,270),"AddWindow", B_MODAL_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_ASYNCHRONOUS_CONTROLS)
{

	
	BButton*		but;
	BButton*		but2;
	
	BFont font=*(be_plain_font);
	

	BRect r(Bounds());
	
	BBox *box = new BBox(r,"url_bbox", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW, B_FANCY_BORDER);
	box->SetBorder(B_PLAIN_BORDER);
	
	AddChild(box);
	BRect	rect(0, 0, 390, 165);
	
	BMessage templ;
	templ.AddString("name", "Add subscription");
	BMessage settings;
	settings.AddString("name", "rss_url");
	settings.AddString("description", "Feed URL");
	settings.AddInt32("type", B_STRING_TYPE);
	settings.AddBool("multi_line", true);
	templ.AddMessage("setting", &settings);
	BMessage values;

	text = new PBox(rect, templ, values, "rss_url");
	text->SetBorder(B_PLAIN_BORDER);
	
	box->AddChild(text);
	
	
	
	addrect = box->Bounds();
	addrect.InsetBy(25, 20);
	addrect.top = addrect.bottom - 12;
	addrect.left = addrect.right - font.StringWidth(_T("Cancel")) - 30;
	box->AddChild(but = new BButton(addrect,"",_T("Cancel"),new BMessage('can')));
	
	addrect.right = addrect.left - 15;
	addrect.left = addrect.right - font.StringWidth(_T("Add")) - 30;
	box->AddChild(but2 = new BButton(addrect,"",_T("Add"),new BMessage('sav')));


	//controlliamo se c'e' qualcosa nella clipboard?
	const char *clip_text = NULL;
	bool	addButton = false;
	int32 textLen;
	BString url;
	BMessage *clip = (BMessage *)NULL;
	if (be_clipboard->Lock() ){
		clip = be_clipboard->Data();
		
		if ( clip && ( clip->FindData("text/plain", B_MIME_TYPE,(const void **)&clip_text, &textLen) == B_OK )){
		url.SetTo(clip_text,textLen);
		
		if(url.FindFirst("http://") == 0)
			addButton = true;
		else
		if(url.FindFirst("pcast://") == 0)
			addButton = true;
		else
		if(url.FindFirst("feed://") == 0)
			addButton = true;
		}	
		be_clipboard->Unlock();
	} 
	
	if(addButton==true){
		addrect.right = addrect.left - 15;
		addrect.left = addrect.right - font.StringWidth(_T("Paste")) - 30;
		BMessage* msg=new BMessage('past');
		msg->AddString("url",url);
		BButton* clip_but;
		box->AddChild(clip_but = new BButton(addrect,"",_T("Paste"),msg));
	}
	
	MoveTo(BPAlert::AlertPosition(Bounds().Width(),Bounds().Height()));
	
	
	BTextView *textView = (BTextView*)FindView("rss_url");
	if (textView){
		textView->MakeFocus(true);
	}
}
AudioView::AudioView(BRect size)
	:
	BView(size, "AudioView", B_FOLLOW_NONE, B_WILL_DRAW)
{
	BRect r, r2;
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	IconLabel* advLabel = new IconLabel(BRect(0, 0, 19 + be_bold_font->StringWidth(" Audio Options (see help before change options)"), 19), 
							" Audio Options (see help before change options)", "audiocd_16.png");
	advLabel->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	advLabel->SetDrawingMode(B_OP_ALPHA);
	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.bottom = 80;
	BBox* advOptionsBox = new BBox(r, "fAdvOptionsBox", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	advOptionsBox->SetLabel(advLabel);
	AddChild(advOptionsBox);


	r = advOptionsBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.right = 120;
	r.bottom = 25;
	fPadCheckBox = new BCheckBox(r, "pad", "Padding", new BMessage(AUDIO_PAD));
	if (!strncmp(PAD, "-pad", 4))
		fPadCheckBox->SetValue(B_CONTROL_ON);

	advOptionsBox->AddChild(fPadCheckBox);

	r.bottom += 15;
	r.top += 15;
	r.right = 120;
	fNoFixCheckBox = new BCheckBox(r, "nofix", "No fixate", new BMessage(AUDIO_NOFIX));
	if (!strncmp(NOFIX, "-nofix", 6))
		fNoFixCheckBox->SetValue(B_CONTROL_ON);

	advOptionsBox->AddChild(fNoFixCheckBox);

	r.bottom += 15;
	r.top += 15;
	fPreEmpCheckBox = new BCheckBox(r, "preemp", "Preemp", new BMessage(AUDIO_PREEMP));
	if (!strncmp(PREEMP, "-preemp", 7))
		fPreEmpCheckBox->SetValue(B_CONTROL_ON);

	advOptionsBox->AddChild(fPreEmpCheckBox);

	r = advOptionsBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.left = 125;
	r.bottom = 25;

	fSwabCheckBox = new BCheckBox(r, "swab", "Swab", new BMessage(AUDIO_SWAB));
	if (!strncmp(SWAB, "-swab", 5))
		fSwabCheckBox->SetValue(B_CONTROL_ON);

	advOptionsBox->AddChild(fSwabCheckBox);


	// Info box
	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.top = 85;
	BBox* infoBox = new BBox(r, "Info", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	infoBox->SetLabel("Audio Info");
	AddChild(infoBox);

	r = infoBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	r2 = r;
	r2.InsetBy(2.0, 2.0);
	BTextView* infoTextView = new BTextView(r, "infoTextView", r2, B_FOLLOW_NONE, B_WILL_DRAW);
	infoTextView->MakeEditable(false);
	infoTextView->SetStylable(true);
	BScrollView* infoScrollView = new BScrollView("infoScrollView", infoTextView, B_FOLLOW_NONE, 0, false, true, B_FANCY_BORDER);
	infoBox->AddChild(infoScrollView);
	infoTextView->SetFontAndColor(be_fixed_font, B_FONT_ALL, &darkblue);
	infoTextView->Insert("Here will be some AudioInfo in the future like what codecs there are on the system.");
}
Exemple #18
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);
}
Exemple #19
0
// constructor
ObjectWindow::ObjectWindow(BRect frame, const char* name)
	: BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
			  B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{
	BRect b(Bounds());

	b.bottom = b.top + 8;
	BMenuBar* menuBar = new BMenuBar(b, "menu bar");
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	menuBar->AddItem(menu);

	menu->AddItem(new BMenu("Submenu"));

	BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
										'Q');
	menu->AddItem(menuItem);

	b = Bounds();
	b.top = menuBar->Bounds().bottom + 1;
	b.right = ceilf((b.left + b.right) / 2.0);
	BBox* bg = new BBox(b, "bg box", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW,
		B_PLAIN_BORDER);

	AddChild(bg);
	bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// object view occupies the right side of the window
	b.left = b.right + 1.0;
	b.right = Bounds().right - B_V_SCROLL_BAR_WIDTH;
	b.bottom -= B_H_SCROLL_BAR_HEIGHT;
	fObjectView = new ObjectView(b, "object view", B_FOLLOW_ALL,
								 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	// wrap a scroll view around the object view
	BScrollView* scrollView = new BScrollView("object scroller", fObjectView,
		B_FOLLOW_ALL, 0, true, true, B_NO_BORDER);

	if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_VERTICAL)) {
		scrollBar->SetRange(0.0, fObjectView->Bounds().Height());
		scrollBar->SetProportion(0.5);
	}
	if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_HORIZONTAL)) {
		scrollBar->SetRange(0.0, fObjectView->Bounds().Width());
		scrollBar->SetProportion(0.5);
	}
	AddChild(scrollView);

	b = bg->Bounds();
	// controls occupy the left side of the window
	b.InsetBy(5.0, 5.0);
	BBox* controlGroup = new BBox(b, "controls box",
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);

	controlGroup->SetLabel("Controls");
	bg->AddChild(controlGroup);

	b = controlGroup->Bounds();
	b.top += controlGroup->InnerFrame().top;
	b.bottom = b.top + 25.0;
	b.InsetBy(10.0, 10.0);
	b.right = b.left + b.Width() / 2.0 - 5.0;

	// new button
	fNewB = new BButton(b, "new button", "New Object",
		new BMessage(MSG_NEW_OBJECT));
	controlGroup->AddChild(fNewB);
	SetDefaultButton(fNewB);

	// clear button
	b.OffsetBy(0, fNewB->Bounds().Height() + 5.0);
	fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR));
	controlGroup->AddChild(fClearB);

	// object type radio buttons
	BMessage* message;
	BRadioButton* radioButton;

	b.OffsetBy(0, fClearB->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_LINE);
	radioButton = new BRadioButton(b, "radio 1", "Line", message);
	controlGroup->AddChild(radioButton);

	radioButton->SetValue(B_CONTROL_ON);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_RECT);
	radioButton = new BRadioButton(b, "radio 2", "Rect", message);
	controlGroup->AddChild(radioButton);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_ROUND_RECT);
	radioButton = new BRadioButton(b, "radio 3", "Round Rect", message);
	controlGroup->AddChild(radioButton);

	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	message = new BMessage(MSG_SET_OBJECT_TYPE);
	message->AddInt32("type", OBJECT_ELLIPSE);
	radioButton = new BRadioButton(b, "radio 4", "Ellipse", message);
	controlGroup->AddChild(radioButton);

	// drawing mode
	BPopUpMenu* popupMenu = new BPopUpMenu("<pick>");

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_COPY);
	popupMenu->AddItem(new BMenuItem("Copy", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_OVER);
	popupMenu->AddItem(new BMenuItem("Over", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_INVERT);
	popupMenu->AddItem(new BMenuItem("Invert", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_BLEND);
	popupMenu->AddItem(new BMenuItem("Blend", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_SELECT);
	popupMenu->AddItem(new BMenuItem("Select", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_ERASE);
	popupMenu->AddItem(new BMenuItem("Erase", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_ADD);
	popupMenu->AddItem(new BMenuItem("Add", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_SUBTRACT);
	popupMenu->AddItem(new BMenuItem("Subtract", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_MIN);
	popupMenu->AddItem(new BMenuItem("Min", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_MAX);
	popupMenu->AddItem(new BMenuItem("Max", message));

	message = new BMessage(MSG_SET_DRAWING_MODE);
	message->AddInt32("mode", B_OP_ALPHA);
	BMenuItem* item = new BMenuItem("Alpha", message);
	item->SetMarked(true);
	popupMenu->AddItem(item);

	b.OffsetBy(0, radioButton->Bounds().Height() + 10.0);
	fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode:",
		popupMenu);

	controlGroup->AddChild(fDrawingModeMF);

	fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(
		fDrawingModeMF->Label()) + 10.0);
	
	// color control
	b.OffsetBy(0, fDrawingModeMF->Bounds().Height() + 10.0);
	fColorControl = new BColorControl(b.LeftTop(), B_CELLS_16x16, 8,
		"color control", new BMessage(MSG_SET_COLOR));
	controlGroup->AddChild(fColorControl);
	
	// alpha text control
	b.OffsetBy(0, fColorControl-> Bounds().Height() + 5.0);
	fAlphaTC = new BTextControl(b, "alpha text control", "Alpha:", "",
		new BMessage(MSG_SET_COLOR));
	controlGroup->AddChild(fAlphaTC);

	// divide text controls the same
    float mWidth = fDrawingModeMF->StringWidth(fDrawingModeMF->Label());
    float aWidth = fAlphaTC->StringWidth(fAlphaTC->Label());
    
    float width = max_c(mWidth, aWidth) + 20.0;
	fDrawingModeMF->SetDivider(width);
	fAlphaTC->SetDivider(width);

	// fill check box
	b.OffsetBy(0, fAlphaTC->Bounds().Height() + 5.0);
	fFillCB = new BCheckBox(b, "fill check box", "Fill",
		new BMessage(MSG_SET_FILL_OR_STROKE));
	controlGroup->AddChild(fFillCB);

	// pen size text control
	b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
	b.bottom = b.top + 10.0;//35;
	fPenSizeS = new BSlider(b, "width slider", "Width:", NULL, 1, 100,
		B_TRIANGLE_THUMB);
	fPenSizeS->SetLimitLabels("1", "100");
	fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE));
	fPenSizeS->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fPenSizeS->SetHashMarkCount(10);

	controlGroup->AddChild(fPenSizeS);

	// list view with objects
	b = controlGroup->Bounds();
	b.top += controlGroup->InnerFrame().top;
	b.InsetBy(10.0, 10.0);
	b.left = b.left + b.Width() / 2.0 + 6.0;
	b.right -= B_V_SCROLL_BAR_WIDTH;
    b.bottom = fDrawingModeMF->Frame().top - 10.0;

	fObjectLV = new ObjectListView(b, "object list", B_SINGLE_SELECTION_LIST);
	fObjectLV->SetSelectionMessage(new BMessage(MSG_OBJECT_SELECTED));

	// wrap a scroll view around the list view
	scrollView = new BScrollView("list scroller", fObjectLV,
		B_FOLLOW_NONE, 0, false, true, B_FANCY_BORDER);
	controlGroup->AddChild(scrollView);

	// enforce some size limits
	float minWidth = controlGroup->Frame().Width() + 30.0;
	float minHeight = fPenSizeS->Frame().bottom
		+ menuBar->Bounds().Height() + 15.0;
	float maxWidth = minWidth * 4.0;
	float maxHeight = minHeight + 100;
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

	ResizeTo(max_c(frame.Width(), minWidth), max_c(frame.Height(), minHeight));

	_UpdateControls();
}
/*!	
 *	\brief			Create box for selection of the weekend days
 *	\note			Additionally, select the color for weekends and weekdays
 *	\param[in]	frame	Enclosing rectangle.
 *	\param[in]	id		Reference to name of the selected Calendar module.
 *	\returns		Pointer to all-set-up BBox. Or NULL in case of error.
 */
BBox*	CalendarModulePreferencesView::CreateWeekendSelectionBox( BRect frame,
															  const BString &id )
{
	/*!	\par	Notes on implementation:
	 *			It's not all that straightforward - to create this selection box.
	 *			The problem is that number of days in week is dependent on the
	 *			Calendar Module, therefore the frame rectangle must be divided
	 *			properly. We should take into account the possibility that there's
	 *			not enough place for all days in the submitted frame.
	 *
	 *	\par	
	 *			The solution will be as follows:
	 *			Let number of days in week be N. I create two columns and 
	 *			several rows (the number depends on N). Days in week will be
	 *			proceeded in the order <em>as Calendar Module supplies them</em>.
	 *			The days occupy both columns, and are located in rows
	 *			[0, (ceiling of (N/2)) ). Days returned from CalendarModule are
	 *			placed as follows: days from 0 to (ceiling of (N/2)-1) in the left
	 *			column, days from (ceiling of (N/2)-1) to (N-1) in right column.
	 *
	 *	\par	
	 *			There will be an empty cell in the right column, if number
	 *			of days in week is odd, (which is usually the case).
	 */
	frame.InsetBySelf( 5, 0 );
	BMessage* 	toSend = NULL;
	BCheckBox* 	dayCheckBox = NULL;
	BString		tempString;
	BLayoutItem*	layoutItem = NULL;
	CalendarModulePreferences* prefs = NULL;
	CalendarModule*	calModule = NULL;
	int height = 0;		//!< this is used to resize the BBox to proper size
	
	calModule = utl_FindCalendarModule( id );
	if ( calModule == NULL ) {
		/* Error */
		utl_Deb = new DebuggerPrintout( "Did not succeed to find the calendar module." );
		return NULL;
	}
	// Get the data on days of week
	uint32 daysInWeek = ( uint32 )( calModule->GetDaysInWeek() );
	map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();

	
	/* Obtain the current Calendar Module preferences */
	prefs = pref_GetPreferencesForCalendarModule( id );
	if ( !prefs ) {
		utl_Deb = new DebuggerPrintout( "Did not succeed to find the preferences for the calendar module." );
		return NULL;
	}
	
	// At this point, "pref" points to current preferences of this calendar module.
	
	BList* weekends = prefs->GetWeekends();		// Get info on currently selected weekends
	
	// Prepare the item to be returned
	BBox*	enclosingBox = new BBox( frame, "Weekend selector" );
	if ( !enclosingBox )
	{
		/* Panic! */
		exit(1);
	}
	enclosingBox->SetLabel( "Select the non-working days (weekends)" );

	// Prepare the layout to be used
	BGridLayout* layout = new BGridLayout();
	if ( !layout)
	{
		/* Panic! */
		exit(1);
	}	
	enclosingBox->SetLayout( layout );
	layout->SetInsets( 10, 15, 10, 5 );
	layout->SetVerticalSpacing( 1 );
	
	/* indexX is 0 for left column or 1 for right column.
	 * indexY is 0 for topmost row, 1 for second from top row, etc.
	 * Max value for indexY = (ceiling of (N/2)).
	 */
	int indexX = 0, indexY = 0;
	
	for (uint32 day = prefs->GetFirstDayOfWeek(), i = 0; i < ( uint32 )daysInWeek; ++i )
	{
		/* Creating the message to be sent */
		toSend = new BMessage( kCalendarModuleWeekendDaySelected );
		if ( !toSend )
		{
			/* Panic! */
			exit(1);
		}
		toSend->AddInt32( "Weekday const", day );
		toSend->AddString( "Calendar module", id );

		/* Set the name of the checkbox.
		 * This is used to identify if the checkbox was checked or unchecked.
		 */
		tempString.SetTo( "Weekday" );
		tempString << day;
		
		/* Creating the checkbox */
		dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
									 tempString.String(),
									 weekdayNames[ day ].longName.String(),
									 toSend );
		if (!dayCheckBox)
		{
			// Panic!
			exit(1);
		}
		dayCheckBox->ResizeToPreferred();
		
		// Check if the checkbox should be checked
		if ( weekends->HasItem( ( void* )day ) ) {
			dayCheckBox->SetValue( 1 );
		} else {
			dayCheckBox->SetValue( 0 );
		}
		
		/* Adding the item to the BBox */
		layoutItem = layout->AddView( dayCheckBox, indexX, indexY );
		if ( layoutItem )
		{
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
//			layoutItem->SetExplicitMaxSize( BSize( (int )dayCheckBox->Bounds().Width(), (int )dayCheckBox->Bounds().Height() ) );
			layout->SetMaxRowHeight( indexY, (int )dayCheckBox->Bounds().Height() + 10 );
			layout->SetRowWeight( indexY, 0 );
		}
		
		/* Advancing to the next cell in grid */
		// If arrived to the last item in the first column, advancing to second
		// The +1 is needed because i starts from 0, but days are starting from 1
		if ( ( i + 1 ) == ( unsigned int )( ( daysInWeek + 1 ) / 2 ) )
		{
			indexX = 1;	
			indexY = 0;
		}
		else 	// Staying in the same column, but advancing down
		{
			++indexY;	
		}
		
		/* Advancing to the next day */
		( day == daysInWeek ) ? day = kSunday : ++day;
		
	}	// <-- end of "for (all days in week)"
	
	// Resizing the BBox to the correct size.
	// Note: dayCheckBox is surely not NULL; if it were, we would exit earlier.
	height =(int )( ( dayCheckBox->Bounds().Height() + 5           ) * ( int )( ( daysInWeek + 1 ) / 2 ) - 5 );
	// Formula:	    ( ^height of one checkbox^       + ^separator^ ) * ( ^number of days in column^      ) - ^one unneeded extra separator^
	
	enclosingBox->ResizeTo( enclosingBox->Bounds().Width() - 10, ( int )height );
//	layout->SetExplicitMaxSize( BSize( enclosingBox->Bounds().Width() - 5, ( int )height + 25 ) );
	
	return enclosingBox;
}
Exemple #21
0
void BeKESAMainWindow::initTab4(BTabView *tv) {
	BTab *tab;
	BBox *box;
	BRect r,s,sl,sr;

	r = tv->Bounds();
	r.InsetBy(5,10);
	BView *view = new BView(r, "viewtab4", B_FOLLOW_ALL_SIDES, 0);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	tab = new BTab(view);
	tv->AddTab(view, tab);
	tab->SetLabel("Teren/Gleba");

	r = view->Bounds();
	r.top = 10; r.left = 10; r.right -= 10;
	r.bottom = r.top + 140;
	box = new BBox(r, "box4x1");
	box->SetLabel("Dostępność terenu");
	view->AddChild(box);

	sl = box->Bounds();
	sl.InsetBy(10,20);
	sl.right = sl.left + sl.Width()/2;
	sl.bottom = sl.top + 20;

	BPopUpMenu *menu;
	BMenuItem *item;
	BMessage *msg;
	menu = new BPopUpMenu("t3mzabudowa");
	msg = new BMessage(TC4Z); msg->AddInt32("_item", 0);
	item = new BMenuItem("[brak]", msg); item->SetMarked(true); menu->AddItem(item);
	t3zabitems[0] = item;
	msg = new BMessage(TC4Z); msg->AddInt32("_item", 1);
	item = new BMenuItem("niezabudowany", msg); menu->AddItem(item);
	t3zabitems[1] = item;
	msg = new BMessage(TC4Z); msg->AddInt32("_item", 2);
	item = new BMenuItem("średniozabudowany", msg); menu->AddItem(item);
	t3zabitems[2] = item;
	msg = new BMessage(TC4Z); msg->AddInt32("_item", 3);
	item = new BMenuItem("zabudowany", msg); menu->AddItem(item);
	t3zabitems[3] = item;
	BMenuField *t3zabudowa = new BMenuField(sl, "t3zabudowa", "Dostępność", menu, B_FOLLOW_LEFT, B_WILL_DRAW);
	t3zabudowa->SetDivider(100);
	box->AddChild(t3zabudowa);

	s = box->Bounds();
	s.InsetBy(10,20);
	s.top = s.top + sl.Height() + 5;
	s.right = s.left + s.Width()/3;
	s.bottom = s.top + 20;
	sl = s;
	s.OffsetBy(s.Width(), 0);
	sr = s;
	sr.OffsetBy(s.Width(), 0);
	t3tl = new BCheckBox(sl, "t3tl", "las", new BMessage(TC4));
	t3ts = new BCheckBox(s,  "t3ts", "sad", new BMessage(TC4));
	t3tp = new BCheckBox(sr, "t3tp", "park", new BMessage(TC4));
	sl.OffsetBy(0,20); s.OffsetBy(0,20); sr.OffsetBy(0,20);
	t3to = new BCheckBox(sl, "t3to", "pole orne", new BMessage(TC4));
	t3ta = new BCheckBox(s,  "t3ta", "łąka", new BMessage(TC4));
	t3tr = new BCheckBox(sr, "t3tr", "ter. roln. prywatny", new BMessage(TC4));
	sl.OffsetBy(0,20); s.OffsetBy(0,20); sr.OffsetBy(0,20);
	t3te = new BCheckBox(sl, "t3te", "ter. roln. społeczny", new BMessage(TC4));
	t3tz = new BCheckBox(s,  "t3tz", "teren przemysłowy", new BMessage(TC4));

	box->AddChild(t3tl); box->AddChild(t3ts); box->AddChild(t3tp);
	box->AddChild(t3to); box->AddChild(t3ta); box->AddChild(t3tr);
	box->AddChild(t3te); box->AddChild(t3tz);

	s = box->Bounds();
	s.InsetBy(10,20);
	sl.right = sl.left + s.Width();
	sl.OffsetBy(0,25);
	t3tokr = new BTextControl(sl, "t3tokr", "Okr. bliższe", NULL, new BMessage(TC4));
	t3tokr->SetDivider(100);
	box->AddChild(t3tokr);

	r.top += 145; r.bottom += 100;
	box = new BBox(r, "box4x2");
	box->SetLabel("Gleba");
	view->AddChild(box);

	sl = box->Bounds();
	sl.InsetBy(10,20);
	sl.right = sl.left + sl.Width()/3;
	sl.bottom = sl.top + 20;
	s = sl; s.OffsetBy(sl.Width(),0);
	sr = s; sr.OffsetBy(sl.Width(),0);
	sl.OffsetBy(0,10); sr.OffsetBy(0,10);

	menu = new BPopUpMenu("t3mkam");
	msg = new BMessage(TC4K); msg->AddInt32("_item", 0);
	item = new BMenuItem("[brak]", msg); item->SetMarked(true); menu->AddItem(item);
	t3kamitems[0] = item;
	msg = new BMessage(TC4K); msg->AddInt32("_item", 1);
	item = new BMenuItem("mała", msg); menu->AddItem(item);
	t3kamitems[1] = item;
	msg = new BMessage(TC4K); msg->AddInt32("_item", 2);
	item = new BMenuItem("średnia", msg); menu->AddItem(item);
	t3kamitems[2] = item;
	msg = new BMessage(TC4K); msg->AddInt32("_item", 3);
	item = new BMenuItem("duża", msg); menu->AddItem(item);
	t3kamitems[3] = item;
	BMenuField *t3kamienie = new BMenuField(sl, "t3kamienie", "Kamienistość", menu, B_FOLLOW_LEFT, B_WILL_DRAW);
	t3kamienie->SetDivider(70);
	box->AddChild(t3kamienie);

	t3gp = new BCheckBox(s, "t3gp", "piaszczysta", new BMessage(TC4));
	s.OffsetBy(0,20);
	t3gg = new BCheckBox(s, "t3gg", "gliniasta", new BMessage(TC4));
	t3gt = new BCheckBox(sr, "t3gt", "torfowo-bagnista", new BMessage(TC4));

	box->AddChild(t3gp); box->AddChild(t3gg); box->AddChild(t3gt);

	s = box->Bounds();
	s.InsetBy(10,20);
	sl.right = sl.left + s.Width();
	sl.OffsetBy(0,35);
	t3gokr = new BTextControl(sl, "t3gokr", "Okr. specj.", NULL, new BMessage(TC4));
	t3gokr->SetDivider(100);
	box->AddChild(t3gokr);

	updateTab4();
}
AutomountSettingsPanel::AutomountSettingsPanel(BRect frame, 
	BMessage *settings, AutoMounter *target)
	:	BBox(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
			| B_NAVIGABLE_JUMP, B_PLAIN_BORDER),
		fTarget(target)
{
	SetViewColor(kLightGray);

	BRect checkBoxRect(Bounds());

	BRect boxRect(Bounds());
	boxRect.InsetBy(10, 15);
	boxRect.bottom = boxRect.top + 85;
	BBox *box = new BBox(boxRect, "autoMountBox", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
	box->SetLabel("Automatic Disk Mounting:");
	AddChild(box);

	checkBoxRect = box->Bounds();
	checkBoxRect.InsetBy(10, 18);
	
	checkBoxRect.bottom = checkBoxRect.top + 20;

	scanningDisabledCheck = new BRadioButton(checkBoxRect, "scanningOff",
		"Don't Automount", new BMessage(kAutomountSettingsChanged));
	box->AddChild(scanningDisabledCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	autoMountAllBFSCheck = new BRadioButton(checkBoxRect, "autoBFS",
		"All BeOS Disks", new BMessage(kAutomountSettingsChanged));
	box->AddChild(autoMountAllBFSCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	autoMountAllCheck = new BRadioButton(checkBoxRect, "autoAll",
		"All Disks", new BMessage(kAutomountSettingsChanged));
	box->AddChild(autoMountAllCheck);
	

	boxRect.OffsetTo(boxRect.left, boxRect.bottom + 15);
	boxRect.bottom = boxRect.top + 105;
	box = new BBox(boxRect, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
			| B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
	box->SetLabel("Disk Mounting During Boot:");
	AddChild(box);

	checkBoxRect = box->Bounds();
	checkBoxRect.InsetBy(10, 18);
	
	checkBoxRect.bottom = checkBoxRect.top + 20;
	initialDontMountCheck = new BRadioButton(checkBoxRect, "initialNone",
		"Only The Boot Disk", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialDontMountCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountRestoreCheck = new BRadioButton(checkBoxRect, "initialRestore",
		"Previously Mounted Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountRestoreCheck);
	
	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountAllBFSCheck = new BRadioButton(checkBoxRect, "initialBFS",
		"All BeOS Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountAllBFSCheck);
	
	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountAllCheck = new BRadioButton(checkBoxRect, "initialAll",
		"All Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountAllCheck);

	
	BRect buttonRect(Bounds());
	buttonRect.InsetBy(15, 15);
	buttonRect.SetLeftTop(buttonRect.RightBottom() - kSmallButtonSize);
	fDone = new BButton(buttonRect, "done", "Done", new BMessage(kDone));

	buttonRect.OffsetTo(buttonRect.left - 15 - buttonRect.Width(), buttonRect.top);
	buttonRect.left = buttonRect.left - 60;
	fMountAllNow = new BButton(buttonRect, "mountAll", "Mount all disks now",
		new BMessage(kMountAllNow));

	AddChild(fMountAllNow);

	AddChild(fDone);
	fDone->MakeDefault(true);

	bool result;
	if (settings->FindBool("autoMountAll", &result) == B_OK && result)
		autoMountAllCheck->SetValue(1);
	else if (settings->FindBool("autoMountAllBFS", &result) == B_OK && result)
		autoMountAllBFSCheck->SetValue(1);
	else
		scanningDisabledCheck->SetValue(1);

	if (settings->FindBool("suspended", &result) == B_OK && result)
		scanningDisabledCheck->SetValue(1);
		
	if (settings->FindBool("initialMountAll", &result) == B_OK && result)
		initialMountAllCheck->SetValue(1);
	else if (settings->FindBool("initialMountRestore", &result) == B_OK && result)
		initialMountRestoreCheck->SetValue(1);
	else if (settings->FindBool("initialMountAllBFS", &result) == B_OK && result)
		initialMountAllBFSCheck->SetValue(1);
	else
		initialDontMountCheck->SetValue(1);
	
}
Exemple #23
0
BView* SeqPrefWin::NewFileView(BRect bounds, const BMessage& prefs) const
{
	BView*		v = new BView( bounds, FILE_STR, B_FOLLOW_ALL, 0 );
	if( !v ) return v;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float		fh = view_font_height(v);
	float		bfh = bold_font_height();
	float		openH = bfh + 5 + fh + 5 + fh + 5 + fh;
	/* The Remember Open Songs preference.
	 */
	float		w = v->StringWidth("Remember open songs") + 25;
	BRect		f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
	BCheckBox*	cb = new BCheckBox( f, REMEMBER_OPEN_STR, "Remember open songs", new BMessage(REMEMBER_OPEN_MSG) );
	if( cb ) {
		bool	b;
		if( prefs.FindBool(REMEBER_OPEN_SONGS_PREF, &b) != B_OK ) b = false;
		cb->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
		v->AddChild( cb );
	}
	/* The Skin preference.
	 */
	BMenu*		menu = new BMenu("skin_menu");
	BMessage	skinMsg(CHANGE_SKIN_MSG);
	BMenuItem*	item = new BMenuItem( "Default", new BMessage(CHANGE_SKIN_TO_DEFAULT_MSG) );
	item->SetMarked(true);
	menu->AddItem(item);
	menu->AddSeparatorItem();
	menu->SetLabelFromMarked(true);
	if( seq_make_skin_menu(menu, &skinMsg) == B_OK ) {
		const char*	label = "Choose skin:";
		f.Set(f.left, f.bottom + 8, bounds.right - 5, f.bottom + 8 + fh + 10);
		BMenuField*	field = new BMenuField(f, "skin_field", label, menu);
		if (field) {
			field->SetDivider( v->StringWidth(label) + 10 );
			v->AddChild(field);
		} else delete menu;
	} else delete menu;

	/* The Open New Songs preferences.
	 */
	f.Set(bounds.left + 5, f.bottom + 10, bounds.right - 5, f.bottom + 10 + openH + 10);
	BBox*		box = new BBox( f,
								"open_new_songs",
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if( box ) {
		box->SetLabel( "Open New Songs" );
		BRect		boxB = box->Bounds();
		BRect		sf(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.top + 5 + bfh + fh);
		const char*	choice;
		if( prefs.FindString(OPEN_NEW_SONG_PREF, &choice) != B_OK ) choice = 0;
		BRadioButton*	button = new BRadioButton( sf, OPEN_BLANK_STR, "Blank", new BMessage(OPEN_BLANK_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "blank") == 0 ) button->SetValue( B_CONTROL_ON );
			box->AddChild( button );
		}
		sf.OffsetBy( 0, 5 + fh );
		button = new BRadioButton( sf, OPEN_FOUR_STR, "With two channels of each device", new BMessage(OPEN_FOUR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "channels") == 0 ) button->SetValue( B_CONTROL_ON );
			box->AddChild( button );
		}
		sf.OffsetBy( 0, 5 + fh );
		button = new BRadioButton( sf, OPEN_FILE_STR, "From file: <click to select>", new BMessage(OPEN_FILE_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "file") == 0 ) button->SetValue( B_CONTROL_ON );
			entry_ref	ref;
			if( prefs.FindRef(OPEN_NEW_SONG_FILE_PREF, &ref) == B_OK )
				button->SetLabel( label_for_open_new_from_file(&ref).String() );
			box->AddChild( button );
		}
		v->AddChild( box );
		f.OffsetBy(0, f.bottom - f.top + 10 );
	}
	/* The Open From Query preferences
	 */
	f.bottom = bounds.bottom - 27;
	box = new BBox( f, "open_from_query", B_FOLLOW_ALL);
	if( box ) {
		box->SetLabel("Open From Query");

		BRect			boxB = box->Bounds();
		BRect			tableF(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.bottom - 35);
		mOwqTable = new _OwqList( tableF, mPreferences );
		if( mOwqTable ) {
			mOwqTable->SetLatchWidth( 0 );
			box->AddChild( mOwqTable );
			mOwqTable->AddColumn( new BStringColumn(ON_STR, 40, 20, 100, B_TRUNCATE_END), 0 );
			mOwqTable->AddColumn( new BStringColumn(NAME_STR, 100, 20, 150, B_TRUNCATE_END), 1 );
			mOwqTable->AddColumn( new BStringColumn(QUERY_STR, 180, 20, 450, B_TRUNCATE_MIDDLE), 2 );
//			mOwqTable->AddColumn( new BStringColumn(SKIP_TOP_LEVEL_STR, 100, 20, 250, B_TRUNCATE_END), 3 );
			mOwqTable->SetSortColumn(mOwqTable->ColumnAt(1), false, true);
//			mOwqTable->SetSortColumn(mOwqTable->ColumnAt(), true, true);
			mOwqTable->SetSelectionMode( B_SINGLE_SELECTION_LIST );

			BRect		bF(tableF.left, tableF.bottom + 5, tableF.left + 55, tableF.Height() - 10);
			BButton*	add = new BButton( bF, "owq_add", "Add", new BMessage(OWQ_INVOKE_ADD), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( add ) box->AddChild( add );
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	change = new BButton( bF, "owq_change", "Change", new BMessage(OWQ_CHANGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( change ) {
				change->SetEnabled( false );
				box->AddChild( change );
			}
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	remove = new BButton( bF, "owq_remove", "Remove", new BMessage(OWQ_REMOVE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( remove ) {
				remove->SetEnabled( false );
				box->AddChild( remove );
			}
			mOwqTable->SetButtons( add, change, remove );
		}
		v->AddChild( box );
	}
	return v;
}
CDRWView::CDRWView(BRect size)
	:
	BView(size, "CDRWView", B_FOLLOW_NONE, B_WILL_DRAW)
{
	BRect r;
	char temp_char[100];
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	// CDRW BOX
	IconLabel* CDRWLabel = new IconLabel(BRect(0, 0, 19 + be_bold_font->StringWidth(""), 19), "", "cd_16.png");
	CDRWLabel->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	CDRWLabel->SetDrawingMode(B_OP_ALPHA);
	r = Bounds();
	r.InsetBy(5.0, 5.0);
	r.bottom = r.top + 160;
	BBox* CDRWBox = new BBox(r, "CDRWBox", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	CDRWBox->SetLabel(CDRWLabel);
	AddChild(CDRWBox);

	// BlankMenu (CDRWBOX)
	r = CDRWBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 25;
	fBlankMenu = new BMenu("Select");
	fBlankMenu->SetLabelFromMarked(true);
	BMenuField* blankMenuField = new BMenuField(r, "blank", "Blank:", fBlankMenu);
	blankMenuField->SetDivider(be_plain_font->StringWidth("Blank:  "));
	CDRWBox->AddChild(blankMenuField);

	fBlankMenu->AddItem(new BMenuItem("Full", new BMessage(BLANK_FULL)));
	fBlankMenu->AddItem(new BMenuItem("Fast", new BMessage(BLANK_FAST)));
	fBlankMenu->AddItem(new BMenuItem("Session", new BMessage(BLANK_SESSION)));
	fBlankMenu->AddItem(new BMenuItem("Track", new BMessage(BLANK_TRACK)));
	fBlankMenu->AddItem(new BMenuItem("Track tail", new BMessage(BLANK_TRACK_TAIL)));
	fBlankMenu->AddItem(new BMenuItem("Unreserve", new BMessage(BLANK_UNRES)));
	fBlankMenu->AddItem(new BMenuItem("Unclose", new BMessage(BLANK_UNCLOSE)));

	r = CDRWBox->Bounds();
	r.left = 150;
	r.right = 278;
	r.top = 60;
	r.bottom = 128;
	IconLabel* BGLabel1 = new IconLabel(r, "", "cdrw_64.png");  //cdrw_64.png
	BGLabel1->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BGLabel1->SetDrawingMode(B_OP_BLEND);
	CDRWBox->AddChild(BGLabel1);
	IconLabel* BGLabel2 = new IconLabel(r, "", "erase_64.png"); //erase_64.png
	BGLabel2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BGLabel2->SetDrawingMode(B_OP_BLEND);
	CDRWBox->AddChild(BGLabel2);


	// BlankSpeed
	r = CDRWBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 15;
	r.left = 155;
	r.right = 270;
	sprintf(temp_char,"Blank Speed [%dx]", BLANK_SPD);
	fBlankSpeedSlider = new BSlider(r, "BlankSpeed", temp_char, new BMessage(BLANK_SPEED_CHANGE), 0, 5, B_BLOCK_THUMB, B_FOLLOW_NONE);
	fBlankSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fBlankSpeedSlider->SetHashMarkCount(6);
	fBlankSpeedSlider->SetValue((int32)(BLANK_SPD / 2) - 1);
	CDRWBox->AddChild(fBlankSpeedSlider);

	// BlankButton
	r = CDRWBox->Bounds();
	r.InsetBy(5.0, 5.0);
	r.top += 10;
	r.bottom = r.top + 50;
	r.left = 330;
	r.right = 415;
	fBlankButton = new BButton(r, "BlankButton", "Blank!", new BMessage(BLANK_IT_NOW));
	CDRWBox->AddChild(fBlankButton);
}
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));
}
Exemple #26
0
PPPStatusView::PPPStatusView(BRect rect, ppp_interface_id id)
	: BView(rect, "PPPStatusView", B_FOLLOW_NONE, B_PULSE_NEEDED),
	fInterface(id)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	rect = Bounds();
	rect.InsetBy(5, 5);
	rect.left = rect.right - 80;
	rect.bottom = rect.top + 25;
	fButton = new BButton(rect, "DisconnectButton", kLabelDisconnect,
		new BMessage(kMsgDisconnect));
	
	rect.right = rect.left - 10;
	rect.left = rect.right - 80;
	rect.top += 5;
	rect.bottom = rect.top + 15;
	fTime = new BStringView(rect, "Time", "");
	fTime->SetAlignment(B_ALIGN_RIGHT);
	fTime->SetFont(be_fixed_font);
	rect.right = rect.left - 10;
	rect.left = 5;
	BStringView *connectedSince = new BStringView(rect, "ConnectedSince",
		kLabelConnectedSince);
	connectedSince->SetFont(be_fixed_font);
	
	rect = Bounds();
	rect.InsetBy(5, 5);
	rect.top += 35;
	rect.right = rect.left + (rect.Width() - 5) / 2;
	BBox *received = new BBox(rect, "Received");
	received->SetLabel(kLabelReceived);
	rect = received->Bounds();
	rect.InsetBy(10, 15);
	rect.bottom = rect.top + 15;
	fBytesReceived = new BStringView(rect, "BytesReceived", "");
	fBytesReceived->SetAlignment(B_ALIGN_RIGHT);
	fBytesReceived->SetFont(be_fixed_font);
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 15;
	fPacketsReceived = new BStringView(rect, "PacketsReceived", "");
	fPacketsReceived->SetAlignment(B_ALIGN_RIGHT);
	fPacketsReceived->SetFont(be_fixed_font);
	
	rect = received->Frame();
	rect.OffsetBy(rect.Width() + 5, 0);
	BBox *sent = new BBox(rect, "sent");
	sent->SetLabel(kLabelSent);
	rect = received->Bounds();
	rect.InsetBy(10, 15);
	rect.bottom = rect.top + 15;
	fBytesSent = new BStringView(rect, "BytesSent", "");
	fBytesSent->SetAlignment(B_ALIGN_RIGHT);
	fBytesSent->SetFont(be_fixed_font);
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 15;
	fPacketsSent = new BStringView(rect, "PacketsSent", "");
	fPacketsSent->SetAlignment(B_ALIGN_RIGHT);
	fPacketsSent->SetFont(be_fixed_font);
	
	received->AddChild(fBytesReceived);
	received->AddChild(fPacketsReceived);
	sent->AddChild(fBytesSent);
	sent->AddChild(fPacketsSent);
	
	AddChild(fButton);
	AddChild(fTime);
	AddChild(connectedSince);
	AddChild(received);
	AddChild(sent);
	
	ppp_interface_info_t info;
	fInterface.GetInterfaceInfo(&info);
	fConnectedSince = info.info.connectedSince;
}
Exemple #27
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);
}
Exemple #28
0
void
ModulesView::_OpenSaver()
{
	// create new screen saver preview & config

	BView* view = fPreviewView->AddPreview();
	fCurrentName = fSettings.ModuleName();
	fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings);
	BScreenSaver* saver = _ScreenSaver();

#ifdef __HAIKU__
	BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4);
#else
	BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
	rect.top += 14;
#endif
	fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);
	fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fSettingsBox->AddChild(fSettingsView);

	if (saver != NULL) {
		fSaverRunner->Run();
		saver->StartConfig(fSettingsView);
	}

	if (fSettingsView->ChildAt(0) == NULL) {
		// There are no settings at all, we add the module name here to
		// let it look a bit better at least.
		BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView,
			fSettings.ModuleName()[0] ? fSettings.ModuleName() :
			B_TRANSLATE("Blackness"), saver || !fSettings.ModuleName()[0]
				? B_TRANSLATE("No options available") :
				B_TRANSLATE("Could not load screen saver"));
	}

	ScreenSaverWindow* window = dynamic_cast<ScreenSaverWindow*>(Window());
	if (window == NULL)
		return;

	// find the minimal size of the settings view

	float right = 0, bottom = 0;
	int32 i = 0;
	while ((view = fSettingsView->ChildAt(i++)) != NULL) {
		// very simple heuristic...
		float viewRight = view->Frame().right;
		if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf))
				== B_FOLLOW_LEFT_RIGHT) {
			float width, height;
			view->GetPreferredSize(&width, &height);
			viewRight = view->Frame().left + width / 2;
		} else if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf))
				== B_FOLLOW_RIGHT)
			viewRight = 8 + view->Frame().Width();

		float viewBottom = view->Frame().bottom;
		if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0))
				== B_FOLLOW_TOP_BOTTOM) {
			float width, height;
			view->GetPreferredSize(&width, &height);
			viewBottom = view->Frame().top + height;
		} else if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0))
				== B_FOLLOW_BOTTOM)
			viewBottom = 8 + view->Frame().Height();

		if (viewRight > right)
			right = viewRight;
		if (viewBottom > bottom)
			bottom = viewBottom;
	}

	if (right < kMinSettingsWidth)
		right = kMinSettingsWidth;
	if (bottom < kMinSettingsHeight)
		bottom = kMinSettingsHeight;

	BPoint leftTop = fSettingsView->LeftTop();
	fSettingsView->ConvertToScreen(&leftTop);
	window->ConvertFromScreen(&leftTop);
	window->SetMinimalSizeLimit(leftTop.x + right + 16,
		leftTop.y + bottom + 16);
}