示例#1
0
InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
	:
	BWindow(BRect(50, 50, 370, 350), "Interface Settings",
		B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
			| B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE)
{
	fNetworkSettings = settings;

	fTabView = new BTabView("settings_tabs");
	fTabView->SetTabWidth(B_WIDTH_FROM_LABEL);

	fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(MSG_IP_REVERT));

	fApplyButton = new BButton("save", B_TRANSLATE("Save"),
		new BMessage(MSG_IP_SAVE));
	SetDefaultButton(fApplyButton);

	_PopulateTabs();

	SetLayout(new BGroupLayout(B_VERTICAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
		.Add(fTabView)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fRevertButton)
			.AddGlue()
			.Add(fApplyButton)
		.End()
		.SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING,
			B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
	);
}
SaveIdea::SaveIdea(const BMessage &msg, const BMessenger &msgr, float mainX, float mainY, int currentID)
	:	BWindow(BRect(0, 0, 358, 60), "Save As", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE), updatetitleMessage(msg), updatetitleMessenger(msgr)
{
	// initialize controls
	AddShortcut(B_TAB, B_COMMAND_KEY, new BMessage(END_SAVE_IDEA));
	AddShortcut(B_ENTER, B_COMMAND_KEY, new BMessage(SAVE_IDEA));
	AddShortcut(B_ESCAPE, B_COMMAND_KEY, new BMessage(CANCEL_SAVE));
	SetDefaultButton(saveButton);
	BRect textFrame(0, 0, 300, 10);
	titleText = new BTextView(textFrame, NULL, textFrame, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
	titleText->MakeResizable(false);
	titleText->SetWordWrap(false);
	titleText->DisallowChar(B_ENTER);
	titleString = new BStringView(BRect(10, 10, 200, 30), NULL, "Enter Thought Title:");
	saveButton = new BButton(BRect(190, 50, 270, 75), NULL, "Save", new BMessage(SAVE_IDEA));
	cancelButton = new BButton(BRect(190, 50, 270, 75), NULL, "Cancel", new BMessage(CANCEL_SAVE));
	backView = new BView(Bounds(), "backview", B_FOLLOW_ALL, B_WILL_DRAW);
	backView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(backView);
	// gui layout builder
	backView->SetLayout(new BGroupLayout(B_HORIZONTAL, 0.0));
	backView->AddChild(BGridLayoutBuilder()
		.Add(titleString, 0, 0, 2, 1)
		.Add(titleText, 2, 0, 3, 1)
		.Add(cancelButton, 3, 1)
		.Add(saveButton, 4, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2, 1)
		.SetInsets(2, 5, 2, 2)
	);
	MoveTo(mainX, mainY); // move to window position
	
	currentideaID = currentID; // make current idea id available to 
}
示例#3
0
authwin::authwin(AuthManager *AManager,const char *title,http_request_info_st *req,const char *rlm,int32 method,bool upd)
	:BWindow(BRect(200,200,500,400),title,B_FLOATING_WINDOW,B_NOT_CLOSABLE|B_NOT_ZOOMABLE|B_NO_WORKSPACE_ACTIVATION|B_ASYNCHRONOUS_CONTROLS,B_CURRENT_WORKSPACE) {
	auth_manager=AManager;
	view=new authview(Bounds());
	update=upd;
	realm=rlm;
	request=req;
	printf("request: %p\nrequest auth_info: %p\n",request,request->auth_info);
	auth_method=method;
	AddChild(view);
	SetDefaultButton(view->ok);
	BString info;
	if (!update) {
		info << "You have been requested to provide a user name\n and password for \""<<realm<<"\".";
	} else {
		info << "You have been requested to provide a user name\n and password for \""<<realm<<"\".\nIncorrect user name or password.";
		if ((request->auth_info!=NULL) && (request->auth_info->auth_object!=NULL))
		{
			view->user->SetText(request->auth_info->auth_object->User());
			view->pass->SetText(request->auth_info->auth_object->Password());
		}
	}
		
	
	view->info->SetText(info.String());
	Show();
		
}
示例#4
0
void WelcomeScene::OnCreateWidgets() {

    // create widgets
    float maxX = SceneManager::GetInstance()->GetScreenAspect();
    float center = 0.5f * maxX;

    // create the static title
    NewWidget()->SetText(S_TITLE)->SetCenter(TITLE_POS)->SetTextColor(TITLE_COLOR)
            ->SetFontScale(TITLE_FONT_SCALE)->SetTransition(UiWidget::TRANS_FROM_TOP);

    // create the "play" button
    mPlayButtonId = NewWidget()->SetText(S_PLAY)->SetTextColor(BUTTON_COLOR)
            ->SetCenter(BUTTON_PLAY_POS)->SetSize(BUTTON_PLAY_SIZE)
            ->SetFontScale(BUTTON_PLAY_FONT_SCALE)->SetIsButton(true)
            ->SetTransition(UiWidget::TRANS_SCALE)->GetId();

    // story button
    mStoryButtonId = NewWidget()->SetTextColor(BUTTON_COLOR)->SetText(S_STORY)
            ->SetCenter(BUTTON_STORY_POS)->SetSize(BUTTON_SIDEBUTTON_SIZE)
            ->SetFontScale(BUTTON_FONT_SCALE)->SetIsButton(true)
            ->SetTransition(UiWidget::TRANS_FROM_RIGHT)->GetId();

    // about button
    mAboutButtonId = NewWidget()->SetTextColor(BUTTON_COLOR)->SetText(S_ABOUT)
            ->SetCenter(BUTTON_ABOUT_POS)->SetSize(BUTTON_SIDEBUTTON_SIZE)
            ->SetFontScale(BUTTON_FONT_SCALE)->SetIsButton(true)
            ->SetTransition(UiWidget::TRANS_FROM_RIGHT)->GetId();

    // "Play" button is the default button
    SetDefaultButton(mPlayButtonId);

    // enable/disable widgets as appropriate to signed in state
    UpdateWidgetStates();
}
 void DialogClientView::FocusWillChange(View* focused_before,
     View* focused_now)
 {
     NativeTextButton* new_default_button = NULL;
     if(focused_now && focused_now->GetClassName()==NativeTextButton::kViewClassName)
     {
         new_default_button = static_cast<NativeTextButton*>(focused_now);
     }
     else
     {
         // The focused view is not a button, get the default button from the
         // delegate.
         DialogDelegate* dd = GetDialogDelegate();
         if((dd->GetDefaultDialogButton() &
             ui::MessageBoxFlags::DIALOGBUTTON_OK) != 0)
         {
             new_default_button = ok_button_;
         }
         if((dd->GetDefaultDialogButton() &
             ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) != 0)
         {
             new_default_button = cancel_button_;
         }
     }
     SetDefaultButton(new_default_button);
 }
示例#6
0
TextRequestDialog::TextRequestDialog(const char *title, const char *information,
		const char *request, const char *text)
	: BWindow(kWindowRect, title, B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE, 0),
	fInvoker(NULL)
{
	BRect rect = Bounds();
	BView *backgroundView = new BView(rect, "background", B_FOLLOW_ALL_SIDES, 0);
	backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	rect.InsetBy(5, 5);
	rect.bottom = rect.top;
		// init
	
	if(information) {
		BRect textRect(rect);
		textRect.OffsetTo(0, 0);
		fTextView = new BTextView(rect, "TextView", textRect, B_FOLLOW_NONE,
			B_WILL_DRAW);
		fTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
		fTextView->MakeSelectable(false);
		fTextView->MakeEditable(false);
		fTextView->SetText(information);
		float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
		backgroundView->ResizeBy(0, textHeight + 5);
		ResizeBy(0, textHeight + 5);
		fTextView->ResizeBy(0, textHeight - textRect.Height());
		rect.bottom += textHeight + 5;
		backgroundView->AddChild(fTextView);
	} else
		fTextView = NULL;
	
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 20;
	fTextControl = new BTextControl(rect, "request", request, text, NULL);
	fTextControl->SetModificationMessage(new BMessage(kMsgUpdateControls));
	fTextControl->SetDivider(fTextControl->StringWidth(fTextControl->Label()) + 5);
	if(text && strlen(text) > 0)
		fTextControl->TextView()->SelectAll();
	
	rect.top = rect.bottom + 10;
	rect.bottom = rect.top + 25;
	rect.left = rect.right - kDefaultButtonWidth;
	BMessage message(kMsgButton);
	message.AddInt32("which", 1);
	fOKButton = new BButton(rect, "okButton", kLabelOK, new BMessage(message));
	rect.right = rect.left - 10;
	rect.left = rect.right - kDefaultButtonWidth;
	message.ReplaceInt32("which", 0);
	BButton *cancelButton = new BButton(rect, "cancelButton", kLabelCancel,
		new BMessage(message));
	backgroundView->AddChild(cancelButton);
	backgroundView->AddChild(fOKButton);
	backgroundView->AddChild(fTextControl);
	AddChild(backgroundView);
	
	fTextControl->MakeFocus(true);
	SetDefaultButton(fOKButton);
	
	UpdateControls();
}
示例#7
0
void FindDialog::SetTabs()
{
	text->SetTabOrder(NEXT_TAB_ORDER);
	findButton->SetTabOrder(NEXT_TAB_ORDER);
	closeButton->SetTabOrder(NEXT_TAB_ORDER);
	SetFocusChild(text);
	SetDefaultButton(findButton);
}
示例#8
0
文件: NamePanel.cpp 项目: DonCN/haiku
NamePanel::NamePanel(const char* label, const char* text, BWindow* window,
		BHandler* target, BMessage* message, const BSize& size)
	:
	Panel(BRect(B_ORIGIN, size), B_TRANSLATE("Name Panel"),
		B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE
			| B_AUTO_UPDATE_SIZE_LIMITS),
	fWindow(window),
	fTarget(target),
	fMessage(message)
{
	BButton* defaultButton = new BButton(B_TRANSLATE("OK"),
		new BMessage(MSG_PANEL_OK));
	BButton* cancelButton = new BButton(B_TRANSLATE("Cancel"),
		new BMessage(MSG_PANEL_CANCEL));
	fNameTC = new BTextControl(label, text, NULL);
	BLayoutItem* inputItem = fNameTC->CreateTextViewLayoutItem();
	inputItem->SetExplicitMinSize(
		BSize(fNameTC->StringWidth("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
			B_SIZE_UNSET));

	BLayoutBuilder::Group<>(this, B_VERTICAL, 10)
		.AddGlue()

		// controls
		.AddGroup(B_HORIZONTAL, 5)
			.AddStrut(5)

			// text control
			.Add(fNameTC->CreateLabelLayoutItem())
			.Add(inputItem)
			.AddStrut(5)
			.End()

		.AddGlue()

		// buttons
		.AddGroup(B_HORIZONTAL, 5)
			.AddGlue()
			.Add(cancelButton)
			.Add(defaultButton)
			.AddStrut(5)
			.End()

		.AddGlue();

	SetDefaultButton(defaultButton);
	fNameTC->MakeFocus(true);

	if (fWindow && fWindow->Lock()) {
		fSavedTargetWindowFeel = fWindow->Feel();
		if (fSavedTargetWindowFeel != B_NORMAL_WINDOW_FEEL)
			fWindow->SetFeel(B_NORMAL_WINDOW_FEEL);
		fWindow->Unlock();
	}	

	AddToSubset(fWindow);
}
示例#9
0
// --------------------------------------------------------------
NetworkSetupWindow::NetworkSetupWindow(const char *title)
    :
    BWindow(BRect(100, 100, 300, 300), title, B_TITLED_WINDOW,
           B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
    fAddonCount(0)
{
    // ---- Profiles section
    BMenu *profilesPopup = new BPopUpMenu("<none>");
    _BuildProfilesMenu(profilesPopup, kMsgProfileSelected);

    BMenuField *profilesMenuField = new BMenuField("profiles_menu",
            B_TRANSLATE("Profile:"), profilesPopup);

    profilesMenuField->SetFont(be_bold_font);
    profilesMenuField->SetEnabled(false);

    // ---- Settings section

    fPanel = new BTabView("showview_box");

    fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
                               new BMessage(kMsgApply));
    SetDefaultButton(fApplyButton);

    fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
                                new BMessage(kMsgRevert));
    // fRevertButton->SetEnabled(false);

    // Enable boxes resizing modes
    //fPanel->SetResizingMode(B_FOLLOW_ALL);

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

    AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
             .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
             .Add(profilesMenuField)
             .AddGlue()
             .End()
             .Add(fPanel)
             .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
             .Add(fRevertButton)
             .AddGlue()
             .Add(fApplyButton)
             .End()
             .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING,
                        B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
            );

    _BuildShowTabView(kMsgAddonShow);

    fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
                                     fMinAddonViewRect.Height()));

    fAddonView = NULL;

    CenterOnScreen();
}
示例#10
0
文件: Alert.cpp 项目: mmanley/Antares
BAlert::BAlert(BMessage* data)
	: BWindow(data)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;

	fTextView = (BTextView*)FindView("_tv_");

	fButtons[0] = (BButton*)FindView("_b0_");
	fButtons[1] = (BButton*)FindView("_b1_");
	fButtons[2] = (BButton*)FindView("_b2_");

	if (fButtons[2])
		SetDefaultButton(fButtons[2]);
	else if (fButtons[1])
		SetDefaultButton(fButtons[1]);
	else if (fButtons[0])
		SetDefaultButton(fButtons[0]);

	TAlertView* view = (TAlertView*)FindView("_master_");
	if (view)
		view->SetBitmap(_InitIcon());

	// Get keys
	char key;
	for (int32 i = 0; i < 3; ++i) {
		if (data->FindInt8("_but_key", i, (int8*)&key) == B_OK)
			fKeys[i] = key;
	}

	int32 temp;
	// Get alert type
	if (data->FindInt32("_atype", &temp) == B_OK)
		fMsgType = (alert_type)temp;

	// Get button width
	if (data->FindInt32("_but_width", &temp) == B_OK)
		fButtonWidth = (button_width)temp;

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
}
示例#11
0
CGoToLine::CGoToLine(BRect frame, const char *name, window_type type, int flags,
	BWindow *owner)
	: HDialog(frame, name, type, flags | B_NOT_RESIZABLE, owner)
{
	Create();
	Layout();

	SetDefaultButton(fOkButton);
	fLine->MakeFocus();
	Show();
} /* CGoToLine::CGoToLine */
示例#12
0
void CFtpDialog::Create(void)
{
	fMainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	// Server-Box
	fLoginBox = new HBox(fMainView, "", B_FOLLOW_RIGHT|B_FOLLOW_TOP);
	fServerName = new HTextControl(fLoginBox, "srvr");
	fServerName->SetModificationMessage(new BMessage(msg_ServerNameChanged));
	fServerName->SetTarget(this);
	fUserName = new HTextControl(fLoginBox, "user");
	fPassword = new HTextControl(fLoginBox, "pass");
	fPassword->TextView()->HideTyping(true);
	fUsePassive = new HCheckBox(fLoginBox, "pssv");
	fUsePassive->SetValue(gPrefs->GetPrefInt(prf_I_PassiveFtp, 1));
	fConnectButton = new HButton(fLoginBox, "cnct", 'cnct');

	fFileName = new HTextControl(fMainView, "name", 
								 B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM);

	// Buttons
	fCancelButton = new HButton(fMainView, "cncl", 'cncl', 
								B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM);
	fOkButton = new HButton(fMainView, "ok", 'ok  ', 
							B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM);

	// List
	fDirectoryField = new HMenuField(fMainView, "path");
	fShowDotted = new HCheckBox(fMainView, "dotf", 
								new BMessage(msg_ToggleDot),
								B_FOLLOW_RIGHT|B_FOLLOW_TOP);

	fListView = new BListView(Bounds(), "list", B_MULTIPLE_SELECTION_LIST, 
							  B_FOLLOW_ALL);
	fListView->SetInvocationMessage(new BMessage(msg_SelectedListItem));
	fListView->SetListType(B_MULTIPLE_SELECTION_LIST);
	fScrollView = new HScrollView(fMainView, "scrll", fListView, B_FOLLOW_ALL, 
								  B_FRAME_EVENTS, false, true);

	SetDefaultButton(fConnectButton);

	fServerName->SetText(gPrefs->GetPrefString(prf_S_LastFtpServer));
	fUserName->SetText(gPrefs->GetPrefString(prf_S_LastFtpUser));

	if (sfPassword.length())
		fPassword->SetText(sfPassword.c_str());

	if (strlen(GetText("srvr")) && strlen(GetText("user")))
		fPassword->MakeFocus();
	else
		fServerName->MakeFocus();

	fFileName->Hide();

} // CFtpDialog::Create
示例#13
0
文件: Alert.cpp 项目: tqh/haiku-efi
void
BAlert::AddButton(const char* label, char key)
{
	if (label == NULL || label[0] == '\0')
		return;

	BButton* button = _CreateButton(fButtons.size(), label);
	fButtons.push_back(button);
	fKeys.push_back(key);

	SetDefaultButton(button);
	fButtonLayout->AddView(button);
}
示例#14
0
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
								   SelectedColorMode mode,
								   BWindow* window,
								   BMessage* message, BHandler* target)
	: Panel(frame, "Pick a color",
			B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
			B_ASYNCHRONOUS_CONTROLS |
			B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE
			| B_AUTO_UPDATE_SIZE_LIMITS),
	  fWindow(window),
	  fMessage(message),
	  fTarget(target)
{
	SetTitle(B_TRANSLATE("Pick a color"));

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

	SetLayout(new BGroupLayout(B_VERTICAL));
		
	BButton* defaultButton = new BButton("ok button",
		B_TRANSLATE("OK"),
		new BMessage(MSG_DONE));
	BButton* cancelButton = new BButton("cancel button",
		B_TRANSLATE("Cancel"),
		new BMessage(MSG_CANCEL));

	BView* topView = new BGroupView(B_VERTICAL);

	const float inset = be_control_look->DefaultLabelSpacing();

	BLayoutBuilder::Group<>(topView, B_VERTICAL, 0.0f)
		.Add(fColorPickerView)
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(cancelButton)
			.Add(defaultButton)
			.SetInsets(inset, inset, inset, inset)
		.End()
	;

	SetDefaultButton(defaultButton);

	if (fWindow != NULL)
		AddToSubset(fWindow);
	else
		SetFeel(B_FLOATING_APP_WINDOW_FEEL);

	AddChild(topView);
}
示例#15
0
XSAboutWindow::XSAboutWindow() :
    BAF::Window(BRect(), "About...", B_TITLED_WINDOW,
                BAF::WIN_AUTO_SIZE | BAF::WIN_ESCAPE_TO_CLOSE)
{
    BAF::Button *button;
    BAF::Box *topview = new BAF::Box(NULL, B_PLAIN_BORDER, -1,
            new BAF::VGroup(B_ALIGN_CENTER,
                    new BAF::StringView("Wild Flower Cross Stitch"),
                    new BAF::StringView("Version 1.0"),
                    new BAF::UrlView("http://uscoffings.net", "http://uscoffings.net"),
                    button = new BAF::Button("OK", BAF_MSG_BUTTON_OKAY),
                    0
                    )
            );

    SetDefaultButton(button);
    AddChild(dynamic_cast<BView *>(topview));
    ResizeToPreferred();
    BAF::Layout::PosCenterOnScreen(this);
    Show();
}
示例#16
0
PrintingProgressWindow::PrintingProgressWindow(const char *text, BRect aRect, int32 pages)
	: BWindow(aRect, B_TRANSLATE("BePDF printing"),
		B_TITLED_WINDOW_LOOK,
		B_MODAL_APP_WINDOW_FEEL,
		B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_NOT_CLOSABLE|B_AUTO_UPDATE_SIZE_LIMITS) {
	mPages = pages; mPrintedPages = 0;
	mState = OK;

	BString s(B_TRANSLATE("BePDF printing document: "));
	s << text;
	// center window

	BStringView *stringView = new BStringView("stringView", s.String());

	mPageString = new BStringView("mPageString", B_TRANSLATE("Page:"));

	mProgress = new BStatusBar("mProgress");
	mProgress->SetMaxValue(1);

	mStop = new BButton("mStop", B_TRANSLATE("Stop"), new BMessage('STOP'));
	mAbort = new BButton("mAbort", B_TRANSLATE("Abort"), new BMessage('ABRT'));

	BLayoutBuilder::Group<>(this, B_HORIZONTAL)
		.SetInsets(B_USE_WINDOW_INSETS)
		.AddGroup(B_VERTICAL)
			.Add(stringView)
			.Add(mPageString)
			.Add(mProgress)
		.End()
		.AddGroup(B_VERTICAL)
			.Add(mStop)
			.Add(mAbort)
		.End();

	ResizeToPreferred();
	CenterOnScreen();

	SetDefaultButton(mStop);
	Show();
}
示例#17
0
FileChooser::FileChooser()
	: BWindow(BRect(0, 0, 330, 250), _T("Select file"), // "TCHOOSEFILEWINDOWTITLE"
			  B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE)
{

	sem = create_sem(0, "FileChooser");
	fileList = new BList();
	winView = new BView(Bounds(), "FileChooserView", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM,
						B_WILL_DRAW);
	winView->SetViewColor(216, 216, 216);
	listView = new BColumnListView(BRect(0, 42, 331, 251), "FileChooserCLV",
								   B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW);
	okB = new BButton(BRect(253, 7, 323, 34), "OK_Button", _T("Use"), new BMessage(OK_BUTTON_MSG),
					  B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	cancelB = new BButton(BRect(173, 7, 243, 34), "CANCEL_Button", _T("Cancel"),
						  new BMessage(B_QUIT_REQUESTED), B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	browseB = new BButton(BRect(85, 7, 155, 34), "SELECT_Button", _T("Browse"),
						  new BMessage(BROWSE_BUTTON_MSG), B_FOLLOW_TOP | B_FOLLOW_RIGHT);

	SetSizeLimits(330, 50000, 250, 50000);

	filepanel = NULL;
	listView->SetColor(B_COLOR_SELECTION, (rgb_color){90, 90, 90, 255});
	listView->SetColor(B_COLOR_NON_FOCUS_SELECTION, (rgb_color){150, 150, 150, 255});
	listView->SetColor(B_COLOR_BACKGROUND, (rgb_color){255, 255, 255, 255});
	listView->SetColor(B_COLOR_ROWS_1, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_2, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_3, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_4, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_5, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_6, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_7, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROWS_8, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColor(B_COLOR_ROW_DIVIDER, listView->Color(B_COLOR_BACKGROUND));
	listView->SetColorBands(8);
	listView->SetEditMode(false);
	listView->MakeFocus(false);
	listView->SetColumnFlags((column_flags)(B_ALLOW_COLUMN_MOVE | B_ALLOW_COLUMN_RESIZE |
											B_ALLOW_COLUMN_POPUP | B_ALLOW_COLUMN_REMOVE));
	listView->SetMouseTrackingEnabled(false);
	listView->SetSelectionMessage(new BMessage(SELECTION_MESSAGE));
	listView->SetSortingEnabled(true);
	listView->AddColumn(new BBitmapColumn(_T("Icon"), // "FILEICONCOLUMN_TITLE"
										  18, 18, 18, B_ALIGN_CENTER),
						ICON_FIELD);
	listView->AddColumn(new BFileColumn(_T("File name"), // "FILENAMECOLUMN_TITLE"
										200, 60, 900, 0, B_ALIGN_LEFT, false),
						FILENAME_FIELD);
	listView->AddColumn(new BSizeColumn(_T("Size"), // "SIZECOLUMN_TITLE"
										57, 20, 100, B_ALIGN_RIGHT),
						SIZE_FIELD);
	listView->ColumnAt(ICON_FIELD)->SetColumnFlags(B_ALLOW_COLUMN_NONE);
	listView->ColumnAt(ICON_FIELD)->SetShowHeading(false);
	listView->SetSortColumn(listView->ColumnAt(FILENAME_FIELD), false, true);
	listView->SetSelectionMode(B_SINGLE_SELECTION_LIST);
	listView->SetTarget(this);
	listView->SetInvocationMessage(new BMessage(OK_BUTTON_MSG));
	// AddChilds
	AddChild(winView);
	winView->AddChild(listView);
	winView->AddChild(okB);
	winView->AddChild(cancelB);
	winView->AddChild(browseB);
	okB->SetEnabled(false);
	SetDefaultButton(okB);

	BScreen* screen = new BScreen();
	MoveTo((int)((screen->Frame().Width() - Bounds().Width()) / 2),
		   (int)((screen->Frame().Height() - Bounds().Height()) / 2));
	delete screen;
}
示例#18
0
文件: Dialogs.cpp 项目: PyroOS/Pyro
ReplaceDialog::ReplaceDialog(const Rect& cFrame, Window* pcParent) : Window(cFrame, "replace_dialog", "Replace", WND_NO_ZOOM_BUT | WND_NO_DEPTH_BUT | WND_NOT_RESIZABLE)
{
    pcParentWindow=pcParent;		// We need to know the parent window so we can send messages back to it

    // Create the Layoutviews
    pcMainLayoutView=new LayoutView(GetBounds(),"", NULL,CF_FOLLOW_NONE);

    // Make the base Vertical LayoutNode
    pcHLayoutNode= new HLayoutNode("main_layout_node");

    // Create the InputNode
    pcInputNode= new VLayoutNode("input_layout_node");

    pcInputNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcInputNode, 1.0f));

    pcFindLabel=new StringView(Rect(0,0,0,0),"find_label","Find",ALIGN_LEFT,CF_FOLLOW_NONE,WID_WILL_DRAW);
    pcInputNode->AddChild(pcFindLabel);

    pcFindTextView= new TextView(Rect(0,0,0,0), "find_text_view", NULL, CF_FOLLOW_NONE);
    pcInputNode->AddChild(pcFindTextView);

    pcInputNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcInputNode, 1.0f));

    pcReplaceLabel=new StringView(Rect(0,0,0,0),"replace_label","Replace with",ALIGN_LEFT,CF_FOLLOW_NONE,WID_WILL_DRAW);
    pcInputNode->AddChild(pcReplaceLabel);

    pcReplaceTextView= new TextView(Rect(0,0,0,0), "replace_text_view", NULL, CF_FOLLOW_NONE);
    pcInputNode->AddChild(pcReplaceTextView);

    pcInputNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcInputNode, 1.0f));

    pcCaseCheckBox=new os::CheckBox(Rect(0,0,0,0),"case_checkbox", "Case Sensitive Search", new Message(M_VOID), CF_FOLLOW_NONE, WID_WILL_DRAW);
    pcInputNode->AddChild(pcCaseCheckBox);

    pcInputNode->SameWidth("find_label","find_text_view","replace_label","replace_text_view","case_checkbox",NULL);

    // Add a spacer to force the edit box to the top
    pcInputNode->AddChild(new VLayoutSpacer("spacer", 1));

    // Add a spacer on the far left
    pcHLayoutNode->AddChild(new HLayoutSpacer("spacer", 5.0f, 5.0f, pcHLayoutNode, 1.0f));
    pcHLayoutNode->AddChild(pcInputNode);

    // Add a spacer between the Edit box & the Buttons
    pcHLayoutNode->AddChild(new HLayoutSpacer("spacer", 5.0f, 5.0f, pcHLayoutNode, 1.0f));

    // Create the ButtonNode
    pcButtonNode= new VLayoutNode("button_layout_node");

    pcFindButton=new Button(Rect(0,0,0,0), "find_button", "Find", new Message(M_BUT_FIND_GO), CF_FOLLOW_NONE);
    pcButtonNode->AddChild(pcFindButton);
    pcButtonNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcButtonNode, 1.0f ) );

    pcNextButton=new Button(Rect(0,0,0,0), "find_next_button", "Find Next", new Message(M_BUT_FIND_NEXT), CF_FOLLOW_NONE);
    pcButtonNode->AddChild(pcNextButton);
    pcButtonNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcButtonNode, 1.0f ) );

    pcReplaceButton=new Button(Rect(0,0,0,0), "replace_button", "Replace", new Message(M_BUT_REPLACE_DO), CF_FOLLOW_NONE);
    pcButtonNode->AddChild(pcReplaceButton);
    pcButtonNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcButtonNode, 1.0f ) );

    pcCloseButton=new Button(Rect(0,0,0,0), "close_button", "Close", new Message(M_BUT_REPLACE_CLOSE), CF_FOLLOW_NONE);
    pcButtonNode->AddChild(pcCloseButton);
    pcButtonNode->AddChild(new VLayoutSpacer("spacer", 5.0f, 5.0f, pcButtonNode, 1.0f ) );

    pcButtonNode->SameWidth("find_button","find_next_button","replace_button","close_button", NULL);

    pcHLayoutNode->AddChild(pcButtonNode);

    // Add a spacer on the far right
    pcHLayoutNode->AddChild(new HLayoutSpacer("spacer", 5.0f, 5.0f, pcHLayoutNode, 1.0f));

    // Add the LayoutNodes to the layoutview
    pcMainLayoutView->SetRoot(pcHLayoutNode);

    // Add the View to the Window
    AddChild(pcMainLayoutView);

    // Set the focus
    SetFocusChild(pcFindTextView);
    SetDefaultButton(pcFindButton);
}
示例#19
0
bool AuthenticationPanel::getAuthentication(const BString& text,
    const BString& previousUser, const BString& previousPass,
	bool previousRememberCredentials, bool badPassword,
	BString& user, BString&  pass, bool* rememberCredentials)
{
	// Configure panel and layout controls.
	rgb_color infoColor = ui_color(B_PANEL_TEXT_COLOR);
	BRect textBounds(0, 0, 250, 200);
	BTextView* textView = new BTextView(textBounds, "text", textBounds,
	    be_plain_font, &infoColor, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
	textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	textView->SetText(text.String());
	textView->MakeEditable(false);
	textView->MakeSelectable(false);

    m_usernameTextControl->SetText(previousUser.String());
	m_passwordTextControl->TextView()->HideTyping(true);
	// Ignore the previous password, if it didn't work.
	if (!badPassword)
	    m_passwordTextControl->SetText(previousPass.String());
	m_hidePasswordCheckBox->SetValue(B_CONTROL_ON);
	m_rememberCredentialsCheckBox->SetValue(previousRememberCredentials);

	// create layout
	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));
	float spacing = be_control_look->DefaultItemSpacing();
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
	    .Add(BGridLayoutBuilder(0, spacing)
	        .Add(textView, 0, 0, 2)
	        .Add(m_usernameTextControl->CreateLabelLayoutItem(), 0, 1)
	        .Add(m_usernameTextControl->CreateTextViewLayoutItem(), 1, 1)
	        .Add(m_passwordTextControl->CreateLabelLayoutItem(), 0, 2)
	        .Add(m_passwordTextControl->CreateTextViewLayoutItem(), 1, 2)
	        .Add(BSpaceLayoutItem::CreateGlue(), 0, 3)
	        .Add(m_hidePasswordCheckBox, 1, 3)
	        .Add(m_rememberCredentialsCheckBox, 0, 4, 2)
	        .SetInsets(spacing, spacing, spacing, spacing)
	    )
	    .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
	    .Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
	        .AddGlue()
	        .Add(m_cancelButton)
	        .Add(m_okButton)
	        .SetInsets(spacing, spacing, spacing, spacing)
	    )
	);

	float textHeight = textView->LineHeight(0) * textView->CountLines();
	textView->SetExplicitMinSize(BSize(B_SIZE_UNSET, textHeight));

	SetDefaultButton(m_okButton);
	if (badPassword && previousUser.Length())
	    m_passwordTextControl->MakeFocus(true);
	else
	    m_usernameTextControl->MakeFocus(true);

    if (m_parentWindowFrame.IsValid())
        CenterIn(m_parentWindowFrame);
    else
        CenterOnScreen();

	// Start AuthenticationPanel window thread
	Show();

	// Let the window jitter, if the previous password was invalid
	if (badPassword)
		PostMessage(kMsgJitter);

	// Block calling thread
	// Get the originating window, if it exists, to let it redraw itself.
	BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
	if (window) {
		status_t err;
		for (;;) {
			do {
				err = acquire_sem_etc(m_exitSemaphore, 1, B_RELATIVE_TIMEOUT, 10000);
				// We've (probably) had our time slice taken away from us
			} while (err == B_INTERRUPTED);

			if (err != B_TIMED_OUT) {
				// Semaphore was finally released or nuked.
				break;
			}
			window->UpdateIfNeeded();
		}
	} else {
		// No window to update, so just hang out until we're done.
		while (acquire_sem(m_exitSemaphore) == B_INTERRUPTED) {
		}
	}

	// AuthenticationPanel wants to quit.
	Lock();

	user = m_usernameTextControl->Text();
	pass = m_passwordTextControl->Text();
	if (rememberCredentials)
        *rememberCredentials = m_rememberCredentialsCheckBox->Value() == B_CONTROL_ON;

    bool canceled = m_cancelled;
	Quit();
	// AuthenticationPanel object is TOAST here.
	return !canceled;
}
示例#20
0
void
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
	off_t size)
{
	// Setup the controls
	fSizeSlider = new SizeSlider("Slider", B_TRANSLATE("Partition size"), NULL,
		offset, offset + size);
	fSizeSlider->SetPosition(1.0);
	fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER));

	fSizeTextControl = new BTextControl("Size Control", "", "", NULL);
	for(int32 i = 0; i < 256; i++)
		fSizeTextControl->TextView()->DisallowChar(i);
	for(int32 i = '0'; i <= '9'; i++)
		fSizeTextControl->TextView()->AllowChar(i);
	_UpdateSizeTextControl();
	fSizeTextControl->SetModificationMessage(
		new BMessage(MSG_SIZE_TEXTCONTROL));

	fNameTextControl = new BTextControl("Name Control",
		B_TRANSLATE("Partition name:"),	"", NULL);
	if (!parent->SupportsChildName())
		fNameTextControl->SetEnabled(false);

	fTypePopUpMenu = new BPopUpMenu("Partition Type");

	int32 cookie = 0;
	BString supportedType;
	while (parent->GetNextSupportedChildType(&cookie, &supportedType)
			== B_OK) {
		BMessage* message = new BMessage(MSG_PARTITION_TYPE);
		message->AddString("type", supportedType);
		BMenuItem* item = new BMenuItem(supportedType, message);
		fTypePopUpMenu->AddItem(item);

		if (strcmp(supportedType, kPartitionTypeBFS) == 0)
			item->SetMarked(true);
	}

	fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
		fTypePopUpMenu);

	const float spacing = be_control_look->DefaultItemSpacing();
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
	layout->SetInsets(spacing, spacing, spacing, spacing);

	SetLayout(layout);

	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fSizeSlider)
		.Add(fSizeTextControl)
		.Add(BGridLayoutBuilder(0.0, 5.0)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
			.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
		)
	);

	status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR,
		&fEditor);
	if (err == B_OK && fEditor != NULL)
		AddChild(fEditor->View());
	else
		fEditor = NULL;

	BButton* okButton = new BButton(B_TRANSLATE("Create"),
		new BMessage(MSG_OK));
	AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
		.AddGlue()
		.Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL)))
		.Add(okButton)
	);
	SetDefaultButton(okButton);

	AddToSubset(fWindow);
	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
void
TeamMonitorWindow::UpdateList()
{
	bool changed = false;

	for (int32 i = 0; i < fListView->CountItems(); i++) {
		TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(i));
		if (item != NULL)
			item->SetFound(false);
	}

	int32 cookie = 0;
	team_info info;
	while (get_next_team_info(&cookie, &info) == B_OK) {
		if (info.team <=16)
			continue;

		bool found = false;
		for (int32 i = 0; i < fListView->CountItems(); i++) {
			TeamListItem* item
				= dynamic_cast<TeamListItem*>(fListView->ItemAt(i));
			if (item != NULL && item->GetInfo()->team == info.team) {
				item->SetFound(true);
				found = true;
			}
		}

		if (!found) {
			TeamListItem* item = new TeamListItem(info);

			fListView->AddItem(item,
				item->IsSystemServer() ? fListView->CountItems() : 0);
			item->SetFound(true);
			changed = true;
		}
	}

	for (int32 i = fListView->CountItems() - 1; i >= 0; i--) {
		TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(i));
		if (item != NULL && !item->Found()) {
			if (item == fDescriptionView->Item()) {
				fDescriptionView->SetItem(NULL);
				fKillButton->SetEnabled(false);
				fQuitButton->SetEnabled(false);
			}

			delete fListView->RemoveItem(i);
			changed = true;
		}
	}

	if (changed)
		fListView->Invalidate();

	bool desktopRunning = be_roster->IsRunning(kTrackerSignature)
		&& be_roster->IsRunning(kDeskbarSignature);
	if (!desktopRunning && fRestartButton->IsHidden()) {
		fRestartButton->Show();
		SetDefaultButton(fRestartButton);
		fRestartButton->Parent()->Layout(true);
	}

	fRestartButton->SetEnabled(!desktopRunning);
}
void
TeamMonitorWindow::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case SYSTEM_SHUTTING_DOWN:
			fQuitting = true;
			break;

		case kMsgUpdate:
			UpdateList();
			break;

		case kMsgCtrlAltDelPressed:
			bool keyDown;
			if (msg->FindBool("key down", &keyDown) != B_OK)
				break;

			fDescriptionView->CtrlAltDelPressed(keyDown);
			break;

		case kMsgDeselectAll:
			fListView->DeselectAll();
			break;

		case kMsgLaunchTerminal:
			be_roster->Launch("application/x-vnd.Haiku-Terminal");
			break;

		case TM_FORCE_REBOOT:
			_kern_shutdown(true);
			break;
			
		case TM_KILL_APPLICATION:
		{
			TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(
				fListView->CurrentSelection()));
			if (item != NULL) {
				kill_team(item->GetInfo()->team);
				UpdateList();
			}
			break;
		}
		case TM_QUIT_APPLICATION:
		{
			TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(
				fListView->CurrentSelection()));
			if (item != NULL) {
				QuitTeam(item);
			}
			break;
		}
		case kMsgQuitFailed:
			MarkUnquittableTeam(msg);
			break;

		case TM_RESTART_DESKTOP:
		{
			if (!be_roster->IsRunning(kTrackerSignature))
				be_roster->Launch(kTrackerSignature);
			if (!be_roster->IsRunning(kDeskbarSignature))
				be_roster->Launch(kDeskbarSignature);
			fRestartButton->Hide();
			SetDefaultButton(fCancelButton);
			break;
		}
		case TM_SELECTED_TEAM:
		{
			fKillButton->SetEnabled(fListView->CurrentSelection() >= 0);
			TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(
				fListView->CurrentSelection()));
			fDescriptionView->SetItem(item);
			fQuitButton->SetEnabled(item != NULL && item->IsApplication());
			break;
		}
		case TM_CANCEL:
			PostMessage(B_QUIT_REQUESTED);
			break;

		default:
			BWindow::MessageReceived(msg);
			break;
	}
}
void
AddPrinterDialog::_BuildGUI(int stage)
{
	// add a "printer name" input field
	fName = new BTextControl("printer_name", B_TRANSLATE("Printer name:"),
		B_EMPTY_STRING, NULL);
	fName->SetFont(be_bold_font);
	fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fName->SetModificationMessage(new BMessage(kNameChangedMsg));

	// add a "driver" popup menu field
	fPrinter = new BPopUpMenu(B_TRANSLATE("<pick one>"));
	BMenuField *printerMenuField = new BMenuField("drivers_list",
		B_TRANSLATE("Printer type:"), fPrinter);
	printerMenuField->SetAlignment(B_ALIGN_RIGHT);
	_FillMenu(fPrinter, "Print", kPrinterSelectedMsg);

	// add a "connected to" (aka transports list) menu field
	fTransport = new BPopUpMenu(B_TRANSLATE("<pick one>"));
	BMenuField *transportMenuField = new BMenuField("transports_list",
		B_TRANSLATE("Connected to:"), fTransport);
	transportMenuField->SetAlignment(B_ALIGN_RIGHT);
	_FillTransportMenu(fTransport);

	// add a "OK" button
	fOk = new BButton(NULL, B_TRANSLATE("Add"), new BMessage((uint32)B_OK),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);

	// add a "Cancel button
	BButton *cancel = new BButton(NULL, B_TRANSLATE("Cancel"),
		new BMessage(B_CANCEL));

	SetLayout(new BGridLayout());

	AddChild(BGridLayoutBuilder(0, 4)
		.Add(fName->CreateLabelLayoutItem(), 0, 0)
		.Add(fName->CreateTextViewLayoutItem(), 1, 0)
		.Add(printerMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(printerMenuField->CreateMenuBarLayoutItem(), 1, 1)
		.Add(transportMenuField->CreateLabelLayoutItem(), 0, 2)
		.Add(transportMenuField->CreateMenuBarLayoutItem(), 1, 2)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL)
			.AddGlue()
			.Add(cancel)
			.Add(fOk)
			, 0, 3, 2)
		.SetInsets(8, 8, 8, 8)
		);

	SetDefaultButton(fOk);
	fOk->MakeDefault(true);

	fName->MakeFocus(true);

	_Update();
// Stage == 0
// init_icon 64x114  Add a Local or Network Printer
//                   ------------------------------
//                   I would like to add a...
//                              Local Printer
//                              Network Printer
// ------------------------------------------------
//                                Cancel   Continue

// Add local printer:

// Stage == 1
// local_icon        Add a Local Printer
//                   ------------------------------
//                   Printer Name: ________________
//                   Printer Type: pick one
//                   Connected to: pick one
// ------------------------------------------------
//                                Cancel        Add

// This seems to be hard coded into the preferences dialog:
// Don't show Network transport add-on in Printer Type menu.
// If Printer Type == Preview disable Connect to popup menu.
// If Printer Type == Serial Port add a submenu to menu item
//    with names in /dev/ports (if empty remove item from menu)
// If Printer Type == Parallel Port add a submenu to menu item
//    with names in /dev/parallel (if empty remove item from menu)

// Printer Driver Setup

// Dialog Info
// Would you like to make X the default printer?
//                                        No Yes

// Add network printer:

// Dialog Info
// Apple Talk networking isn't currenty enabled. If you
// wish to install a network printer you should enable
// AppleTalk in the Network preferences.
//                               Cancel   Open Network

// Stage == 2

// network_icon      Add a Network Printer
//                   ------------------------------
//                   Printer Name: ________________
//                   Printer Type: pick one
//              AppleTalk Printer: pick one
// ------------------------------------------------
//                                Cancel        Add
}
示例#24
0
void CFtpDialog::Connect()
{
	try
	{
		if (fSocket >= 0)
		{
			if (fSocketFD) s_close(fSocketFD);
			closesocket(fSocket);
		}

		fSocket = socket(AF_INET, SOCK_STREAM, 0);
		if (fSocket < 0)
			THROW(("Failed to get socket: %s", strerror(errno)));

		fSocketFD = s_open(fSocket, "r+");
		FailNil(fSocketFD);

		SetDefaultButton(static_cast<BButton*>(FindView("ok  ")));

		struct hostent *host;
		if ((host = gethostbyname(GetText("srvr"))) == NULL)
		{
			fServerName->MarkAsInvalid(true);
			THROW(("Failed to get server address: %s", strerror(errno)));
		}

		struct sockaddr_in sa;
		sa.sin_family = AF_INET;
		sa.sin_port = htons(21);
		sa.sin_addr.s_addr = *(unsigned int *)host->h_addr;

		if (connect(fSocket, (struct sockaddr *)&sa, sizeof(sa)) < 0)
		{
			if (!(errno == ECONNREFUSED || errno == ETIMEDOUT || errno == ENETUNREACH))
				fServerName->MarkAsInvalid(true);

			THROW(("Failed to connect to the host: %s", strerror(errno)));
		}

		int state = 1;
		while (state)
		{
			GetReply();

			switch (state)
			{
				case 1:
					if (*fReply != '2')
						THROW(("Connect failed: %s", fReply));
					s_printf(fSocketFD, "user %s\r\n", GetText("user"));
					state = 2;
					break;

				case 2:
					if (*fReply == '3')
					{
						s_printf(fSocketFD, "pass %s\r\n", GetText("pass"));
						state = 3;
						break;
					}
					else if (*fReply != '2' && *fReply != '5')
						THROW(("Failed to login: %s", fReply));

					// fall thru

				case 3:
					if (*fReply == '5')
						THROW(("Incorrect username/password.\n%s", fReply));
					if (state == 3 && *fReply != '2')
						THROW(("Failed to login: %s", fReply));

					state = 0;
					break;
			}
		}

		gPrefs->SetPrefString(prf_S_LastFtpUser, GetText("user"));
		gPrefs->SetPrefString(prf_S_LastFtpServer, GetText("srvr"));
		sfPassword = GetText("pass");

		GetPWD();
	}
	catch (HErr& e)
	{
		e.DoError();
		s_close(fSocketFD); fSocketFD = NULL;
		closesocket(fSocket); fSocket = -1;

		SetDefaultButton(static_cast<BButton*>(FindView("cnct")));
	}

	if (fSocketFD)
		ListDirectory();
} // CFtpDialog::Connect
MultiRequesterWindow::MultiRequesterWindow(char *pattern,uint32 size,char *year,char *title,char *artist,char *album,char *comment,int8 *genre):
	MWindow(BRect(100,100,180,150),"mp3tag [multiple files]",B_TITLED_WINDOW,B_NOT_RESIZABLE),
	pattern_string(pattern),
	year_string(year),
	title_string(title),
	artist_string(artist),
	album_string(album),
	comment_string(comment),
	genre_byte(genre),
	len(size)
{
	topview=
	new VGroup
	(
		new MBorder(M_LABELED_BORDER,10,"pattern",
			new VGroup
			(
				new MStringView("Enter the patter by which your mp3 files are named."),
				new MStringView("/a = Artist name (30 chars)"),
				new MStringView("/t = song Title (30 chars)"),
				new MStringView("/n = album Name (30 chars)"),
				new MStringView("/c = comment (30 chars)"),
				new MStringView("/y = year (4 chars)"),
				new MStringView("/* = wildcard, can be anything"),
				pattern_check=new MCheckBox("use pattern matching",new BMessage(PATTERN_CHECK)),
				pattern_gadget=new MTextControl("pattern:","/a - /t.mp3"),
				0
			)
		),
		new MBorder(M_LABELED_BORDER,10,"set every tag to:",
			new HGroup
			(
				new VGroup
				(
					minimax(-1,-1,-1,-1),
					title_check=new MCheckBox("Title:",new BMessage(TITLE_CHECK)),
					artist_check=new MCheckBox("Artist:",new BMessage(ARTIST_CHECK)),
					album_check=new MCheckBox("Album:",new BMessage(ALBUM_CHECK)),
					comment_check=new MCheckBox("Comment:",new BMessage(COMMENT_CHECK)),
					year_check=new MCheckBox("Year:",new BMessage(YEAR_CHECK)),
					genre_check=new MCheckBox("Genre:",new BMessage(GENRE_CHECK)),
					0
				),
				new VGroup
				(
					title_gadget=new MTextControl("",""),
					artist_gadget=new MTextControl("",""),
					album_gadget=new MTextControl("",""),
					comment_gadget=new MTextControl("",""),
					year_gadget=new MTextControl("",""),
					genre_gadget=new MPopup("select",
	"Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal",
	"New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death Metal",
	"Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion",
	"Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel",
	"Noise","AlternRock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop",
	"Instrumental Rock","Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic",
	"Pop-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta","Top 40",
	"Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychadelic",
	"Rave","Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka",
	"Retro","Musical","Rock & Roll","Hard Rock", "Folk","Folk/Rock","National Folk","Swing",
	"Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock",
	"Progress. Rock","Psychadel. Rock","Symphonic Rock","Slow Rock","Big Band","Chorus",
	"Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music",
	"Sonata","Symphony","Booty Bass","Primus","P**n Groove","Satire",	"Unknown",0),
					0
				),
				0
			)
		),
		new HGroup
		(
			new MButton("Cancel",new BMessage(CANCEL_BUTTON)),
			ok_button=new MButton("Run",new BMessage(OK_BUTTON)),
			0
		),
		0
	);
	AddChild(dynamic_cast<BView*>(topview));
	SetDefaultButton(ok_button);
	year_gadget->SetEnabled(false);
	title_gadget->SetEnabled(false);
	artist_gadget->SetEnabled(false);
	album_gadget->SetEnabled(false);
	comment_gadget->SetEnabled(false);
	pattern_gadget->SetEnabled(false);

	genre_gadget->SetActive(0);
	genre_gadget->SetEnabled(false);
}
示例#26
0
文件: Alert.cpp 项目: mmanley/Antares
void
BAlert::_InitObject(const char* text, const char* button0, const char* button1,
	const char* button2, button_width buttonWidth, button_spacing spacing,
	alert_type type)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;
	fButtons[0] = fButtons[1] = fButtons[2] = NULL;
	fTextView = NULL;
	fKeys[0] = fKeys[1] = fKeys[2] = 0;
	fMsgType = type;
	fButtonWidth = buttonWidth;

	// Set up the "_master_" view
	TAlertView* view = new(std::nothrow) TAlertView(Bounds());
	if (view == NULL)
		return;

	AddChild(view);
	view->SetBitmap(_InitIcon());

	// Must have at least one button
	if (button0 == NULL) {
		debugger("BAlerts must have at least one button.");
		button0 = "";
	}

	// Set up the buttons

	int32 buttonCount = 1;
	view->AddChild(fButtons[0] = _CreateButton(0, button0));

	if (button1 != NULL) {
		view->AddChild(fButtons[1] = _CreateButton(1, button1));
		buttonCount++;
	}

	if (button2 != NULL) {
		view->AddChild(fButtons[2] = _CreateButton(2, button2));
		buttonCount++;
	}

	// Find the widest button only if the widest value needs to be known.

	if (fButtonWidth == B_WIDTH_FROM_WIDEST) {
		float maxWidth = 0;
		for (int i = 0; i < buttonCount; i++) {
			float width = fButtons[i]->Bounds().Width();
			if (width > maxWidth)
				maxWidth = width;
		}

		// resize buttons
		for (int i = 0; i < buttonCount; i++) {
			fButtons[i]->ResizeTo(maxWidth, fButtons[i]->Bounds().Height());
		}
	}

	float defaultButtonFrameWidth = -fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;
	SetDefaultButton(fButtons[buttonCount - 1]);
	defaultButtonFrameWidth += fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;

	// Layout buttons

	float fontFactor = be_plain_font->Size() / 11.0f;

	for (int i = buttonCount - 1; i >= 0; --i) {
		float x = -fButtons[i]->Bounds().Width();
		if (i + 1 == buttonCount)
			x += Bounds().right - kRightOffset + defaultButtonFrameWidth;
		else
			x += fButtons[i + 1]->Frame().left - kButtonSpacing;

		if (buttonCount > 1 && i == 0 && spacing == B_OFFSET_SPACING)
			x -= kButtonOffsetSpacing * fontFactor;

		fButtons[i]->MoveTo(x, fButtons[i]->Frame().top);
	}

	// Adjust the window's width, if necessary

	int32 iconLayoutScale = icon_layout_scale();
	float totalWidth = kRightOffset + fButtons[buttonCount - 1]->Frame().right
		- defaultButtonFrameWidth - fButtons[0]->Frame().left;
	if (view->Bitmap()) {
		totalWidth += (kIconStripeWidth + kWindowIconOffset) * iconLayoutScale;
	} else
		totalWidth += kWindowMinOffset;

	float width = (spacing == B_OFFSET_SPACING
		? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor;

	ResizeTo(max_c(totalWidth, width), Bounds().Height());

	// Set up the text view

	BRect textViewRect(kLeftOffset, kTopOffset,
		Bounds().right - kRightOffset,
		fButtons[0]->Frame().top - kTextButtonOffset);
	if (view->Bitmap())
		textViewRect.left = (kWindowIconOffset
			+ kIconStripeWidth) * iconLayoutScale - 2;

	fTextView = new(std::nothrow) BTextView(textViewRect, "_tv_",
		textViewRect.OffsetByCopy(B_ORIGIN),
		B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	if (fTextView == NULL)
		return;

	fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	fTextView->SetText(text, strlen(text));
	fTextView->MakeEditable(false);
	fTextView->MakeSelectable(false);
	fTextView->SetWordWrap(true);
	view->AddChild(fTextView);

	// Now resize the TextView vertically so that all the text is visible
	float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
	textViewRect.OffsetTo(0, 0);
	textHeight -= textViewRect.Height();
	ResizeBy(0, textHeight);
	fTextView->ResizeBy(0, textHeight);
	textViewRect.bottom += textHeight;
	fTextView->SetTextRect(textViewRect);

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));

	MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
}
示例#27
0
void
PrintOptionsWindow::Setup()
{
    BString value;
    enum PrintOptions::Option op = fCurrentOptions.Option();
    BRadioButton* rbFit;
    BRadioButton* rbZoom;
    BRadioButton* rbDpi;
    BRadioButton* rbResize;
    BBox* line;
    BButton* button;

    rbFit = AddRadioButton("fit_to_page", B_TRANSLATE("Fit image to page"),
                           kMsgFitToPageSelected, op == PrintOptions::kFitToPage);

    rbZoom = AddRadioButton("zoom_factor", B_TRANSLATE("Zoom factor in %:"),
                            kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);

    fZoomFactor = AddTextControl("zoom_factor_text", "",
                                 fCurrentOptions.ZoomFactor() * 100, kMsgZoomFactorChanged);

    rbDpi = AddRadioButton("dpi", B_TRANSLATE("DPI:"), kMsgDPISelected,
                           op == PrintOptions::kDPI);

    fDPI = AddTextControl("dpi_text", "", fCurrentOptions.DPI(),
                          kMsgDPIChanged);

    rbResize = AddRadioButton("width_and_height",
                              B_TRANSLATE("Resize to (in 1/72 inches):"), kMsgWidthAndHeightSelected,
                              op == PrintOptions::kWidth || op == PrintOptions::kHeight);

    fWidth = AddTextControl("width", B_TRANSLATE("Width:"),
                            fCurrentOptions.Width(), kMsgWidthChanged);

    fHeight = AddTextControl("height", B_TRANSLATE("Height: "),
                             fCurrentOptions.Height(), kMsgHeightChanged);

    line = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
                    B_FANCY_BORDER);
    line->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

    button = new BButton("job setup", B_TRANSLATE("Job setup"),
                         new BMessage(kMsgJobSetup));
    SetDefaultButton(button);

    const float spacing = be_control_look->DefaultItemSpacing();

    SetLayout(new BGroupLayout(B_HORIZONTAL));
    AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
             .Add(BGridLayoutBuilder()
                  .Add(rbFit, 0, 0)
                  .Add(rbZoom, 0, 1)
                  .Add(fZoomFactor, 1, 1)
                  .Add(rbDpi, 0, 2)
                  .Add(fDPI, 1, 2)
                  .Add(rbResize, 0, 3)
                 )
             .AddGroup(B_HORIZONTAL, spacing)
             .Add(fWidth)
             .Add(fHeight)
             .AddGlue()
             .SetInsets(22, 0, 0, 0)
             .End()
             .Add(line)
             .AddGroup(B_HORIZONTAL, 0)
             .Add(button)
             .End()
             .SetInsets(spacing, spacing, spacing, spacing)
            );
}
示例#28
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();
}
示例#29
0
void
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
	off_t size)
{
	// Setup the controls
	fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset,
		offset + size);
	fSizeSlider->SetPosition(1.0);

	fNameTextControl = new BTextControl("Name Control", TR("Partition name:"),
		"", NULL);
	if (!parent->SupportsChildName())
		fNameTextControl->SetEnabled(false);

	fTypePopUpMenu = new BPopUpMenu("Partition Type");

	int32 cookie = 0;
	BString supportedType;
	while (parent->GetNextSupportedChildType(&cookie, &supportedType)
			== B_OK) {
		BMessage* message = new BMessage(MSG_PARTITION_TYPE);
		message->AddString("type", supportedType);
		BMenuItem* item = new BMenuItem(supportedType, message);
		fTypePopUpMenu->AddItem(item);

		if (strcmp(supportedType, kPartitionTypeBFS) == 0)
			item->SetMarked(true);
	}

	fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu,
		NULL);

	const float spacing = be_control_look->DefaultItemSpacing();
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
	layout->SetInsets(spacing, spacing, spacing, spacing);

	SetLayout(layout);

	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fSizeSlider)
		.Add(BGridLayoutBuilder(0.0, 5.0)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
			.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
		)
	);

	parent->GetChildCreationParameterEditor(NULL, &fEditor);
	if (fEditor)
		AddChild(fEditor->View());

	BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK));
	AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
		.AddGlue()
		.Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
		.Add(okButton)
	);
	SetDefaultButton(okButton);

	AddToSubset(fWindow);
	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
TeamMonitorWindow::TeamMonitorWindow()
	:
	BWindow(BRect(0, 0, 350, 400), B_TRANSLATE("Team monitor"),
		B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
		B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
			| B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS,
		B_ALL_WORKSPACES),
	fQuitting(false),
	fUpdateRunner(NULL)
{
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	float inset = 10;
	layout->SetInsets(inset, inset, inset, inset);
	layout->SetSpacing(inset);
	SetLayout(layout);

	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fListView = new BListView("teams");
	fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM));

	BScrollView* scrollView = new BScrollView("scroll_teams", fListView,
		0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER);
	layout->AddView(scrollView);

	BGroupView* groupView = new BGroupView(B_HORIZONTAL);
	layout->AddView(groupView);

	fKillButton = new BButton("kill", B_TRANSLATE("Kill application"),
		new BMessage(TM_KILL_APPLICATION));
	groupView->AddChild(fKillButton);
	fKillButton->SetEnabled(false);
	
	fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"),
		new BMessage(TM_QUIT_APPLICATION));
	groupView->AddChild(fQuitButton);
	fQuitButton->SetEnabled(false);

	groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

	fDescriptionView = new TeamDescriptionView;
	layout->AddView(fDescriptionView);

	groupView = new BGroupView(B_HORIZONTAL);
	layout->AddView(groupView);

	BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"),
		new BMessage(TM_FORCE_REBOOT));
	groupView->GroupLayout()->AddView(forceReboot);

	BSpaceLayoutItem* glue = BSpaceLayoutItem::CreateGlue();
	glue->SetExplicitMinSize(BSize(inset, -1));
	groupView->GroupLayout()->AddItem(glue);

	fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
		new BMessage(TM_RESTART_DESKTOP));
	SetDefaultButton(fRestartButton);
	groupView->GroupLayout()->AddView(fRestartButton);

	glue = BSpaceLayoutItem::CreateGlue();
	glue->SetExplicitMinSize(BSize(inset, -1));
	groupView->GroupLayout()->AddItem(glue);

	fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
		new BMessage(TM_CANCEL));
	SetDefaultButton(fCancelButton);
	groupView->GroupLayout()->AddView(fCancelButton);

	BSize preferredSize = layout->View()->PreferredSize();
	if (preferredSize.width > Bounds().Width())
		ResizeTo(preferredSize.width, Bounds().Height());
	if (preferredSize.height > Bounds().Height())
		ResizeTo(Bounds().Width(), preferredSize.height);

	BRect screenFrame = BScreen(this).Frame();
	BPoint point;
	point.x = (screenFrame.Width() - Bounds().Width()) / 2;
	point.y = (screenFrame.Height() - Bounds().Height()) / 2;

	if (screenFrame.Contains(point))
		MoveTo(point);

	SetSizeLimits(Bounds().Width(), Bounds().Width() * 2,
		Bounds().Height(), screenFrame.Height());

	fRestartButton->Hide();

	AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY,
		new BMessage(kMsgLaunchTerminal));
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));

	gLocalizedNamePreferred
		= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();

	gTeamMonitorWindow = this;

	if (be_app->Lock()) {
		be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY,
			B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged));
		be_app->Unlock();
	}
}