/*******************************************************
*   Our wonderful BWindow, ya its kewl like that.
*   we dont do much here but set up the menubar and 
*   let the view take over.  We also nead some message
*   redirection and handling
*******************************************************/
ToolTipWindow::ToolTipWindow() : BWindow(BRect(0,0,100,19),"Tool Tip",
      B_NO_BORDER_WINDOW_LOOK,
      B_FLOATING_ALL_WINDOW_FEEL,
      B_ASYNCHRONOUS_CONTROLS|B_NOT_RESIZABLE|B_AVOID_FRONT|B_AVOID_FOCUS){
   
   Looper()->SetName(TOOL_TIP_WINDOW);
   
   BView *v = new BView(Bounds(),"",B_FOLLOW_ALL,0);
   v->SetViewColor(255,255,120);
   AddChild(v);
   
   BRect b = v->Bounds();
   b.Set(b.left-1,b.top-1,b.right+1,b.bottom+1);
   BBox *bb = new BBox(b,"",B_FOLLOW_ALL);
   v->AddChild(bb);
   
   b = bb->Frame();
   b.InsetBy(1,1);
   b.left = 4;
   b.bottom --;
   tipv = new BStringView(b,"","...",B_FOLLOW_ALL);
   tipv->SetAlignment(B_ALIGN_CENTER);
   bb->AddChild(tipv);
   
   Run();
}
Exemple #2
0
PasswordWindow::PasswordWindow()
	: BWindow(BRect(100, 100, 400, 230), "Enter password",
		B_NO_BORDER_WINDOW_LOOK, kPasswordWindowFeel
			/* TODO: B_MODAL_APP_WINDOW_FEEL should also behave correctly */,
		B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
		| B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_ALL_WORKSPACES)
{
	BView* topView = new BView(Bounds(), "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

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

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

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

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

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

	BScreen screen(this);
	MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2,
		screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2);
}
Exemple #3
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);
}
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));
}
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 #7
0
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
		AttributeItem* attributeItem)
	: BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
		B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
			| B_ASYNCHRONOUS_CONTROLS),
	fTarget(target),
	fMimeType(mimeType.Type())
{
	if (attributeItem != NULL)
		fAttribute = *attributeItem;

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

	rect.InsetBy(8.0f, 8.0f);
	fPublicNameControl = new BTextControl(rect, "public", "Attribute name:",
		fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT);
	fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));

	float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f;
	fPublicNameControl->SetDivider(labelWidth);
	fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	float width, height;
	fPublicNameControl->GetPreferredSize(&width, &height);
	fPublicNameControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fPublicNameControl);

	rect = fPublicNameControl->Frame();
	rect.OffsetBy(0.0f, rect.Height() + 5.0f);
	fAttributeControl = new BTextControl(rect, "internal", "Internal name:",
		fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT);
	fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fAttributeControl->SetDivider(labelWidth);
	fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of an attribute
	BTextView* textView = fAttributeControl->TextView();
	const char* disallowedCharacters = "/";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	topView->AddChild(fAttributeControl);

	fTypeMenu = new BPopUpMenu("type");
	BMenuItem* item = NULL;
	for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgTypeChosen);
		message->AddInt32("type", kTypeMap[i].type);

		item = new BMenuItem(kTypeMap[i].name, message);
		fTypeMenu->AddItem(item);

		if (kTypeMap[i].type == fAttribute.Type())
			item->SetMarked(true);
	}

	rect.OffsetBy(0.0f, rect.Height() + 4.0f);
	BMenuField* menuField = new BMenuField(rect, "types",
		"Type:", fTypeMenu);
	menuField->SetDivider(labelWidth);
	menuField->SetAlignment(B_ALIGN_RIGHT);
	menuField->GetPreferredSize(&width, &height);
	menuField->ResizeTo(rect.Width(), height);
	topView->AddChild(menuField);

	rect.OffsetBy(0.0f, rect.Height() + 4.0f);
	rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f;
	BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT);
	topView->AddChild(box);

	fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible",
		new BMessage(kMsgVisibilityChanged));
	fVisibleCheckBox->SetValue(fAttribute.Visible());
	fVisibleCheckBox->ResizeToPreferred();
	box->SetLabel(fVisibleCheckBox);

	labelWidth -= 8.0f;

	BMenu* menu = new BPopUpMenu("display as");
	for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgDisplayAsChosen);
		if (kDisplayAsMap[i].identifier != NULL) {
			message->AddString("identifier", kDisplayAsMap[i].identifier);
			for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
				message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
			}
		}

		item = new BMenuItem(kDisplayAsMap[i].name, message);
		menu->AddItem(item);

		if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs()))
			item->SetMarked(true);
	}

	rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height());
	rect.right -= 18.0f;
	fDisplayAsMenuField = new BMenuField(rect, "display as",
		"Display as:", menu);
	fDisplayAsMenuField->SetDivider(labelWidth);
	fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT);
	fDisplayAsMenuField->ResizeTo(rect.Width(), height);
	box->AddChild(fDisplayAsMenuField);

	fEditableCheckBox = new BCheckBox(rect, "editable", "Editable",
		new BMessage(kMsgAttributeUpdated), B_FOLLOW_RIGHT);
	fEditableCheckBox->SetValue(fAttribute.Editable());
	fEditableCheckBox->ResizeToPreferred();
	fEditableCheckBox->MoveTo(rect.right - fEditableCheckBox->Bounds().Width(),
		rect.top + (fDisplayAsMenuField->Bounds().Height()
		- fEditableCheckBox->Bounds().Height()) / 2.0f);
	box->AddChild(fEditableCheckBox);

	rect.OffsetBy(0.0f, menuField->Bounds().Height() + 4.0f);
	rect.bottom = rect.top + fPublicNameControl->Bounds().Height();
	fSpecialControl = new BTextControl(rect, "special", "Special:",
		display_as_parameter(fAttribute.DisplayAs()), NULL,
		B_FOLLOW_LEFT_RIGHT);
	fSpecialControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fSpecialControl->SetDivider(labelWidth);
	fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fSpecialControl->SetEnabled(false);
	box->AddChild(fSpecialControl);

	char text[64];
	snprintf(text, sizeof(text), "%ld", fAttribute.Width());
	rect.OffsetBy(0.0f, fSpecialControl->Bounds().Height() + 4.0f);
	fWidthControl = new BTextControl(rect, "width", "Width:",
		text, NULL, B_FOLLOW_LEFT_RIGHT);
	fWidthControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fWidthControl->SetDivider(labelWidth);
	fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of a width
	textView = fWidthControl->TextView();
	for (int32 i = 0; i < 256; i++) {
		if (!isdigit(i))
			textView->DisallowChar(i);
	}
	textView->SetMaxBytes(4);

	box->AddChild(fWidthControl);

	const struct alignment_map {
		int32		alignment;
		const char*	name;
	} kAlignmentMap[] = {
		{B_ALIGN_LEFT, "Left"},
		{B_ALIGN_RIGHT, "Right"},
		{B_ALIGN_CENTER, "Center"},
		{0, NULL}
	};

	menu = new BPopUpMenu("alignment");
	for (int32 i = 0; kAlignmentMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgAlignmentChosen);
		message->AddInt32("alignment", kAlignmentMap[i].alignment);

		item = new BMenuItem(kAlignmentMap[i].name, message);
		menu->AddItem(item);

		if (kAlignmentMap[i].alignment == fAttribute.Alignment())
			item->SetMarked(true);
	}

	rect.OffsetBy(0.0f, menuField->Bounds().Height() + 1.0f);
	fAlignmentMenuField = new BMenuField(rect, "alignment",
		"Alignment:", menu);
	fAlignmentMenuField->SetDivider(labelWidth);
	fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT);
	fAlignmentMenuField->ResizeTo(rect.Width(), height);
	box->AddChild(fAlignmentMenuField);
	box->ResizeBy(0.0f, fAlignmentMenuField->Bounds().Height() * 2.0f
		+ fVisibleCheckBox->Bounds().Height());

	fAcceptButton = new BButton(rect, "add", item ? "Done" : "Add",
		new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fAcceptButton->ResizeToPreferred();
	fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
		Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
	fAcceptButton->SetEnabled(false);
	topView->AddChild(fAcceptButton);

	BButton* button = new BButton(rect, "cancel", "Cancel",
		new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
		fAcceptButton->Frame().top);
	topView->AddChild(button);

	ResizeTo(labelWidth * 4.0f + 24.0f, box->Frame().bottom
		+ button->Bounds().Height() + 20.0f);
	SetSizeLimits(fEditableCheckBox->Bounds().Width() + button->Bounds().Width()
		+ fAcceptButton->Bounds().Width() + labelWidth + 24.0f,
		32767.0f, Frame().Height(), Frame().Height());

	fAcceptButton->MakeDefault(true);
	fPublicNameControl->MakeFocus(true);

	target->PlaceSubWindow(this);
	AddToSubset(target);
}
Exemple #8
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();
}
Exemple #9
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 #10
0
void 
PasswordWindow::_Setup()
{
	BRect bounds = Bounds();
	BView* topView = new BView(bounds, "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

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

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

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

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

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

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

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

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

	ResizeTo(customBox->Frame().right + 10.0, frame.bottom + 10.0);
}
Exemple #11
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;
}
// constructor
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
                                   selected_color_mode mode,
                                   BWindow* window,
                                   BMessage* message, BHandler* target)
    : Panel(frame, "Pick Color",
            B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
            B_ASYNCHRONOUS_CONTROLS |
            B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE),
      fWindow(window),
      fMessage(message),
      fTarget(target)
{
    SetTitle(B_TRANSLATE("Pick a color"));

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

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

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

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

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

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

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

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

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

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

    SetDefaultButton(defaultButton);

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

    AddChild(topView);
}
Exemple #13
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);	
}