示例#1
0
void
HWindow::_InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);

	BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);
	stopbutton->SetExplicitSize(buttonsSize);

	// We need at least one view to trigger B_PULSE_NEEDED events which we will
	// intercept in DispatchMessage to trigger the buttons enabling or disabling.
	stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);

	BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);
	playbutton->SetExplicitSize(buttonsSize);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(fEventList)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(playbutton)
				.Add(stopbutton)
			.End()
		.End();

	// setup file menu
	_SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);

	_UpdateZoomLimits();
}
示例#2
0
void _OwqList::SelectionChanged()
{
	inherited::SelectionChanged();
	BRow*	selection = CurrentSelection();
	if( selection ) {
		if( mChange ) mChange->SetEnabled( true );
		if( mRemove ) mRemove->SetEnabled( true );
	} else {
		if( mChange ) mChange->SetEnabled( false );
		if( mRemove ) mRemove->SetEnabled( false );
	}
}
示例#3
0
void CPrefsDialog::UpdateFields()
{
	if (fNewOrCur->IndexOf(fNewOrCur->FindMarked()) == 1)
		GrabDocFont();
	else
		GrabNewFont();
	
	BButton *b;
	b = (BButton *)FindView("ok");
	b->SetEnabled(true);
	b = (BButton *)FindView("cancel");
	b->SetEnabled(true);
} /* CPrefsDialog::UpdateFields */
示例#4
0
bool CPrefsDialog::CancelClicked()
{
	char s[256];
	
	ResetFontSheet();
	
	SetOn("autorecalc", fAutoRecalc);
	SetOn("displayzero", fDisplayZero);
	
	s[1] = 0;
	s[0] = gDecimalPoint;
	SetText("decsep", s);
	s[0] = gThousandSeparator;
	SetText("thoussep", s);
	s[0] = gListSeparator;
	SetText("listsep", s);
	s[0] = gTimeSeparator;
	SetText("timesep", s);
	s[0] = gDateSeparator;
	SetText("datesep", s);
	fDMY->FindItem(gPrefs->GetPrefString("date order"))->SetMarked(true);
	SetOn("24 hours", g24Hours);
	SetOn("excel", gPrefs->GetPrefInt("Excel keys", 0));
	SetOn("grayselect", gPrefs->GetPrefInt("Select Gray", 0));
	SetOn(gPrefs->GetPrefInt("start with new", 1) ? "donew" : "doopen", B_CONTROL_ON);
	SetOn("formula starts with equal", gPrefs->GetPrefInt("formula starts with equal", 0));
	SetOn("dark gridlines", gPrefs->GetPrefInt("dark gridlines"));
	
	SetText("c_symbol", gPrefs->GetPrefString("c_symbol", "$"));
	SetOn(gPrefs->GetPrefInt("c_before", 1) ? "c_before" : "c_after", B_CONTROL_ON);
	SetOn("c_neg_par", gPrefs->GetPrefInt("c_neg_par", 1) ? B_CONTROL_ON : B_CONTROL_OFF);
	sprintf(s, "%d", gPrefs->GetPrefInt("c_digits"));
	SetText("c_digits", s);

	if (fPageSetup) FREE(fPageSetup);
	fPageSetup = (char *)Hex2Bin(gPrefs->GetPrefString("default page setup", ""), fPageSetupSize);
	
	SetOn("prgrid", fPrGrid);
	SetOn("prhead", fPrBorders);
	SetOn("dispgrid", fShGrid);
	SetOn("disphead", fShBorders);
	
	BButton *b;
	b = (BButton *)FindView("ok");
	b->SetEnabled(false);
	b = (BButton *)FindView("cancel");
	b->SetEnabled(false);
	
	return false;
} /* CPrefsDialog::CancelClicked */
示例#5
0
// Buttons are enabled or not depending on the selection in the list
// so each time you click in the list, this method is called to update the buttons
void NetListView::SelectionChanged(void)
{
	int32 index = CurrentSelection();

	BView *parent = Parent();
	
	if (index >= 0) {
		
		// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
		if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {												  
			
			BButton *settings = dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
			BButton *clear 	  = dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
			
			settings->SetEnabled(true);
			clear->SetEnabled(true);
		}
		else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
			
			BButton *restore = dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
			BButton *remove	 = dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
			
			restore ->SetEnabled(true);
			remove  ->SetEnabled(true);
		}
	}
	else {
		
		// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
		if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {												  
		
			BButton *settings=dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
			BButton *clear=dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
			
			settings->SetEnabled(false);
			clear->SetEnabled(false);
		}
		else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
		
			BButton *restore=dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
			BButton *remove=dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
			
			restore->SetEnabled(false);
			remove->SetEnabled(false);
		}
	}			
				
}
示例#6
0
void
FadeView::UpdateStatus()
{
	Window()->DisableUpdates();

	bool enabled = fEnableCheckBox->Value() == B_CONTROL_ON;
	fPasswordCheckBox->SetEnabled(enabled);
	fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0);
	fRunSlider->SetEnabled(enabled);
	fTurnOffSlider->SetEnabled(enabled && fTurnOffCheckBox->Value());
	fPasswordSlider->SetEnabled(enabled && fPasswordCheckBox->Value());
	fPasswordButton->SetEnabled(enabled && fPasswordCheckBox->Value());

	Window()->EnableUpdates();

	// Update the saved preferences
	fSettings.SetWindowFrame(Frame());
	fSettings.SetTimeFlags((enabled ? ENABLE_SAVER : 0)
		| (fTurnOffCheckBox->Value() ? fTurnOffScreenFlags : 0));
	fSettings.SetBlankTime(fRunSlider->Time());
	bigtime_t offTime = fTurnOffSlider->Time() - fSettings.BlankTime();
	fSettings.SetOffTime(offTime);
	fSettings.SetSuspendTime(offTime);
	fSettings.SetStandByTime(offTime);
	fSettings.SetBlankCorner(fFadeNow->Corner());
	fSettings.SetNeverBlankCorner(fFadeNever->Corner());
	fSettings.SetLockEnable(fPasswordCheckBox->Value());
	fSettings.SetPasswordTime(fPasswordSlider->Time());

	// TODO - Tell the password window to update its stuff
}
示例#7
0
MainView::MainView( BRect frame ) : BView (frame, "mainView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {

	SetViewColor(216, 216, 216);

	// nutzbare Größe
	frame.OffsetTo( 0.0, 0.0 );
	frame.InsetBy( 5.0, 5.0 );
	
	// Erstellen der beiden inneren Frames
	TopView* topView = new TopView( BRect( frame.left, frame.top, frame.right, frame.bottom - 72.0 - be_plain_font->Size() - be_bold_font->Size() ) );
	AddChild( topView );

	BottomView* bottomView = new BottomView( BRect( frame.left, frame.bottom - 67.0 - be_plain_font->Size() - be_bold_font->Size(), frame.right, frame.bottom - 43.0 ) );
	AddChild( bottomView );

	// StatusBar
	BStatusBar*	statusBar	= new BStatusBar( BRect(frame.left + 5.0, frame.bottom - be_plain_font->Size() - 23.0, frame.left + 400.0, frame.bottom), "statusBar", STATUS_STATUS, NULL);
	statusBar->SetText(STATUS_SELECT_FILES);
	statusBar->SetResizingMode(B_FOLLOW_BOTTOM);
	rgb_color color = { 70, 100, 180, 255};
	statusBar->SetBarColor(color);
	statusBar->SetBarHeight(14.0);
	AddChild(statusBar);
	
	// Do it! - Button
	BButton* DoItButton = new BButton( BRect ( frame.right - be_plain_font->StringWidth(STR_DO_IT) - 25.0, frame.bottom - 30.0, frame.right - 5.0 , frame.bottom - 5.0 ), "DoIt", STR_DO_IT, new BMessage(MSG_DO_IT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
	DoItButton->SetEnabled(false);
	AddChild(DoItButton);
};
示例#8
0
void
HWindow::_Pulse()
{
	BButton* stop = dynamic_cast<BButton*>(FindView("stop"));

	if (stop == NULL)
		return;

	if (fPlayer != NULL) {
		if (fPlayer->IsPlaying())
			stop->SetEnabled(true);
		else
			stop->SetEnabled(false);
	} else
		stop->SetEnabled(false);
}
示例#9
0
TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
		: BView(frame, name, resizingMode, flags)
{
	BFont font;

	BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
	btn->SetFontSize(20);
	AddChild(btn);

	btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
		btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
		btn->SetFontSize(24);
	}
	AddChild(btn);
	btn->ResizeToPreferred();

	btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
	btn->SetEnabled(false);
	AddChild(btn);
	btn->ResizeToPreferred();
}
// Stuff we can only do when the main view is attached to a window
void
OutputFormatView::AttachedToWindow()
{
	// Get the window and lock it
	the_window = Window();
	the_window->Lock();

	// Set some size limits on the window
	the_window->SetSizeLimits(
		200.0,
		32767.0,
		Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
		32767.0);
	// Set the target for messages sent to this view
	list_view->SetTarget(this);
	the_button->SetTarget(this);

	// Make the list view the keyboard focus
	list_view->MakeFocus();

	// Select the first item in the list,
	// and make its config view show up
	if (list_view->CountItems() > 0)
		list_view->Select(0);
	else
		the_button->SetEnabled(false);

	// Unlock the window
	the_window->Unlock();

	// Call the base class
	BView::AttachedToWindow();
}
示例#11
0
void
HWindow::Pulse()
{
	HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
	BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
	BButton* button = dynamic_cast<BButton*>(FindView("play"));
	BButton* stop = dynamic_cast<BButton*>(FindView("stop"));

	if (menufield == NULL || button == NULL || stop == NULL)
		return;

	if (row != NULL) {
		menufield->SetEnabled(true);

		const char* path = row->Path();
		if (path != NULL && strcmp(path, ""))
			button->SetEnabled(true);
		else
			button->SetEnabled(false);
	} else {
		menufield->SetEnabled(false);
		button->SetEnabled(false);
	}

	if (fPlayer != NULL) {
		if (fPlayer->IsPlaying())
			stop->SetEnabled(true);
		else
			stop->SetEnabled(false);
	} else
		stop->SetEnabled(false);
}
void
ProgressWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_UPDATE_STATUS_BAR:
			char count[100];
			snprintf(count, sizeof(count), "%" B_PRId32,
				(int32)fStatusBar->CurrentValue() + 1);

			fStatusBar->Update(1, NULL, count);
			break;

		case B_CANCEL:
			fAbortButton->SetEnabled(false);
			if (fQuitListener != NULL)
				*fQuitListener = true;
			break;

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
示例#13
0
void
HWindow::InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BGroupView* view = new BGroupView();
	BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
		| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"),
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);

	BButton* playbutton = new BButton("play", B_TRANSLATE("Play"),
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);

	const float kInset = be_control_look->DefaultItemSpacing();
	view->SetLayout(new BGroupLayout(B_HORIZONTAL));
	view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGlue()
		.End()
		.AddGroup(B_HORIZONTAL, kInset)
			.AddGlue()
			.Add(playbutton)
			.Add(stopbutton)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset)
	);

	box->AddChild(view);

	SetLayout(new BGroupLayout(B_HORIZONTAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.AddGroup(B_VERTICAL, kInset)
			.Add(fEventList)
			.Add(box)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset)
	);

	// setup file menu
	SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);
}
示例#14
0
bool CPrefsDialog::OKClicked()
{
	font_family defFamily;
	font_style defStyle;

	be_plain_font->GetFamilyAndStyle(&defFamily, &defStyle);
	gPrefs->SetPrefString("defdoc font family", fNewFontFamily);
	gPrefs->SetPrefString("defdoc font style", defStyle);
	gPrefs->SetPrefDouble("defdoc font size", fNewFontSize);

	be_bold_font->GetFamilyAndStyle(&defFamily, &defStyle);
	gPrefs->SetPrefString("border font family", fNewBFontFamily);
	gPrefs->SetPrefString("border font style", defStyle);
	gPrefs->SetPrefDouble("border font size", fNewBFontSize);

	gPrefs->SetPrefInt("decimal point", *GetText("decsep"));
	gPrefs->SetPrefInt("thousands separator", *GetText("thoussep"));
	gPrefs->SetPrefInt("list separator", *GetText("listsep"));
	gPrefs->SetPrefInt("date separator", *GetText("datesep"));
	gPrefs->SetPrefInt("time separator", *GetText("timesep"));
	gPrefs->SetPrefString("date order", fDMY->FindMarked()->Label());	
	gPrefs->SetPrefInt("24 hours", IsOn("24 hours"));
	gPrefs->SetPrefInt("Excel keys", IsOn("excel"));
	gPrefs->SetPrefInt("Select Gray", IsOn("grayselect"));
	gPrefs->SetPrefInt("start with new", IsOn("donew"));
	gWithEqualSign = IsOn("formula starts with equal");
	gPrefs->SetPrefInt("formula starts with equal", gWithEqualSign);
	gPrefs->SetPrefInt("dark gridlines", 	IsOn("dark gridlines"));
	if (gPrefs->GetPrefInt("dark gridlines", 0))
		gGridColor = 10;
	else
		gGridColor = 6;

	gPrefs->SetPrefString("c_symbol", GetText("c_symbol"));
	gPrefs->SetPrefInt("c_before", IsOn("c_before"));
	gPrefs->SetPrefInt("c_neg_par", IsOn("c_neg_par"));
	gPrefs->SetPrefInt("c_digits", atoi(GetText("c_digits")));

	if (fPageSetup)
	{
		char *ps = Bin2Hex(fPageSetup, fPageSetupSize);
		gPrefs->SetPrefString("default page setup", ps);
		FREE(ps);
	}

	BMessage msg(msg_WindowOptions);

	msg.AddString("docfamily", fDocFontFamily);
	msg.AddString("docstyle", "Roman");
	msg.AddFloat("docsize", fDocFontSize);
	msg.AddString("borderfamily", fDocBFontFamily);
	msg.AddString("borderstyle", "Bold");
	msg.AddFloat("bordersize", fDocBFontSize);
	msg.AddBool("autorecalc", IsOn("autorecalc"));
	msg.AddBool("displayzero", IsOn("displayzero"));
	msg.AddBool("dispgrid", IsOn("dispgrid"));
	msg.AddBool("disphead", IsOn("disphead"));
	msg.AddBool("prgrid", IsOn("prgrid"));
	msg.AddBool("prhead", IsOn("prhead"));
	
	fOwner->PostMessage(&msg, fOwner->GetCellView());

	BButton *b;
	b = (BButton *)FindView("ok");
	b->SetEnabled(false);
	b = (BButton *)FindView("cancel");
	b->SetEnabled(false);

	InitFormatter();

	return false;
} /* CPrefsDialog::OKClicked */
示例#15
0
	void SetControlEnable(bool enable)
	{
		if( mNameCtrl ) mNameCtrl->SetEnabled( enable );
		if( mFileButton ) mFileButton->SetEnabled( enable );
		if( mSkipBox ) mSkipBox->SetEnabled( enable );
	}
示例#16
0
BView* SeqPrefWin::NewFileView(BRect bounds, const BMessage& prefs) const
{
	BView*		v = new BView( bounds, FILE_STR, B_FOLLOW_ALL, 0 );
	if( !v ) return v;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float		fh = view_font_height(v);
	float		bfh = bold_font_height();
	float		openH = bfh + 5 + fh + 5 + fh + 5 + fh;
	/* The Remember Open Songs preference.
	 */
	float		w = v->StringWidth("Remember open songs") + 25;
	BRect		f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
	BCheckBox*	cb = new BCheckBox( f, REMEMBER_OPEN_STR, "Remember open songs", new BMessage(REMEMBER_OPEN_MSG) );
	if( cb ) {
		bool	b;
		if( prefs.FindBool(REMEBER_OPEN_SONGS_PREF, &b) != B_OK ) b = false;
		cb->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
		v->AddChild( cb );
	}
	/* The Skin preference.
	 */
	BMenu*		menu = new BMenu("skin_menu");
	BMessage	skinMsg(CHANGE_SKIN_MSG);
	BMenuItem*	item = new BMenuItem( "Default", new BMessage(CHANGE_SKIN_TO_DEFAULT_MSG) );
	item->SetMarked(true);
	menu->AddItem(item);
	menu->AddSeparatorItem();
	menu->SetLabelFromMarked(true);
	if( seq_make_skin_menu(menu, &skinMsg) == B_OK ) {
		const char*	label = "Choose skin:";
		f.Set(f.left, f.bottom + 8, bounds.right - 5, f.bottom + 8 + fh + 10);
		BMenuField*	field = new BMenuField(f, "skin_field", label, menu);
		if (field) {
			field->SetDivider( v->StringWidth(label) + 10 );
			v->AddChild(field);
		} else delete menu;
	} else delete menu;

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

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

			BRect		bF(tableF.left, tableF.bottom + 5, tableF.left + 55, tableF.Height() - 10);
			BButton*	add = new BButton( bF, "owq_add", "Add", new BMessage(OWQ_INVOKE_ADD), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( add ) box->AddChild( add );
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	change = new BButton( bF, "owq_change", "Change", new BMessage(OWQ_CHANGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( change ) {
				change->SetEnabled( false );
				box->AddChild( change );
			}
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	remove = new BButton( bF, "owq_remove", "Remove", new BMessage(OWQ_REMOVE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( remove ) {
				remove->SetEnabled( false );
				box->AddChild( remove );
			}
			mOwqTable->SetButtons( add, change, remove );
		}
		v->AddChild( box );
	}
	return v;
}
示例#17
0
void
HWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_OTHER_MESSAGE:
		{
			BMenuField* menufield
				= dynamic_cast<BMenuField*>(FindView("filemenu"));
			if (menufield == NULL)
				return;
			BMenu* menu = menufield->Menu();

			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				BPath path(row->Path());
				if (path.InitCheck() != B_OK) {
					BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
					if (item != NULL)
						item->SetMarked(true);
				} else {
					BMenuItem* item = menu->FindItem(path.Leaf());
					if (item != NULL)
						item->SetMarked(true);
				}
			}
			fFilePanel->Show();
			break;
		}

		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		{
			entry_ref ref;
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
				BMenuField* menufield
					= dynamic_cast<BMenuField*>(FindView("filemenu"));
				if (menufield == NULL)
					return;
				BMenu* menu = menufield->Menu();

				// check audio file
				BNode node(&ref);
				BNodeInfo ninfo(&node);
				char type[B_MIME_TYPE_LENGTH + 1];
				ninfo.GetType(type);
				BMimeType mtype(type);
				BMimeType superType;
				mtype.GetSupertype(&superType);
				if (superType.Type() == NULL
					|| strcmp(superType.Type(), "audio") != 0) {
					beep();
					BAlert* alert = new BAlert("",
						B_TRANSLATE("This is not an audio file."),
						B_TRANSLATE("OK"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
					break;
				}

				// add file item
				BMessage* msg = new BMessage(M_ITEM_MESSAGE);
				BPath path(&ref);
				msg->AddRef("refs", &ref);
				BMenuItem* menuitem = menu->FindItem(path.Leaf());
				if (menuitem == NULL)
					menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
				// refresh item
				fEventList->SetPath(BPath(&ref).Path());
				// check file menu
				if (menuitem != NULL)
					menuitem->SetMarked(true);
			}
			break;
		}

		case M_PLAY_MESSAGE:
		{
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				const char* path = row->Path();
				if (path != NULL) {
					entry_ref ref;
					::get_ref_for_path(path, &ref);
					delete fPlayer;
					fPlayer = new BFileGameSound(&ref, false);
					fPlayer->StartPlaying();
				}
			}
			break;
		}

		case M_STOP_MESSAGE:
		{
			if (fPlayer == NULL)
				break;
			if (fPlayer->IsPlaying()) {
				fPlayer->StopPlaying();
				delete fPlayer;
				fPlayer = NULL;
			}
			break;
		}

		case M_EVENT_CHANGED:
		{
			const char* path;
			BMenuField* menufield
				= dynamic_cast<BMenuField*>(FindView("filemenu"));
			if (menufield == NULL)
				return;
			BMenu* menu = menufield->Menu();

			if (message->FindString("path", &path) == B_OK) {
				BPath path(path);
				if (path.InitCheck() != B_OK) {
					BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
					if (item != NULL)
						item->SetMarked(true);
				} else {
					BMenuItem* item = menu->FindItem(path.Leaf());
					if (item != NULL)
						item->SetMarked(true);
				}

				HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
				BButton* button = dynamic_cast<BButton*>(FindView("play"));
				if (row != NULL) {
					menufield->SetEnabled(true);

					const char* path = row->Path();
					if (path != NULL && strcmp(path, ""))
						button->SetEnabled(true);
					else
						button->SetEnabled(false);
				} else {
					menufield->SetEnabled(false);
					button->SetEnabled(false);
				}
			}
			break;
		}

		case M_ITEM_MESSAGE:
		{
			entry_ref ref;
			if (message->FindRef("refs", &ref) == B_OK) {
				fEventList->SetPath(BPath(&ref).Path());
				_UpdateZoomLimits();
			}
			break;
		}

		case M_NONE_MESSAGE:
		{
			fEventList->SetPath(NULL);
			break;
		}

		default:
			BWindow::MessageReceived(message);
	}
}
示例#18
0
void
TFilePanel::AdjustButton()
{
	// adjust button state
	BButton* button = dynamic_cast<BButton*>(FindView("default button"));
	if (button == NULL)
		return;

	BTextControl* textControl
		= dynamic_cast<BTextControl*>(FindView("text view"));
	BObjectList<BPose>* selectionList = fPoseView->SelectionList();
	BString buttonText = fButtonText;
	bool enabled = false;

	if (fIsSavePanel && textControl != NULL) {
		enabled = textControl->Text()[0] != '\0';
		if (fPoseView->IsFocus()) {
			fPoseView->ShowSelection(true);
			if (selectionList->CountItems() == 1) {
				Model* model = selectionList->FirstItem()->TargetModel();
				if (model->ResolveIfLink()->IsDirectory()) {
					enabled = true;
					buttonText = B_TRANSLATE("Open");
				} else {
					// insert the name of the selected model into
					// the text field
					textControl->SetText(model->Name());
					textControl->MakeFocus(true);
				}
			}
		} else
			fPoseView->ShowSelection(false);
	} else {
		int32 count = selectionList->CountItems();
		if (count) {
			enabled = true;

			// go through selection list looking at content
			for (int32 index = 0; index < count; index++) {
				Model* model = selectionList->ItemAt(index)->TargetModel();

				uint32 modelFlavor = GetLinkFlavor(model, false);
				uint32 linkFlavor = GetLinkFlavor(model, true);

				// if only one item is selected and we're not in dir
				// selection mode then we don't disable button ever
				if ((modelFlavor == B_DIRECTORY_NODE
						|| linkFlavor == B_DIRECTORY_NODE)
					&& count == 1)
				  break;

				if ((fNodeFlavors & modelFlavor) == 0
					&& (fNodeFlavors & linkFlavor) == 0) {
		    		enabled = false;
					break;
				}
			}
		}
	}

	button->SetLabel(buttonText.String());
	button->SetEnabled(enabled);
}
示例#19
0
ConfigWindow::ConfigWindow()
		: BWindow(BRect(200.0, 200.0, 640.0, 640.0),
				  "E-mail", B_TITLED_WINDOW,
				  B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
		fLastSelectedAccount(NULL),
		fSaveSettings(false)
{
	/*** create controls ***/

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

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

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

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

	// accounts listview

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

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

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

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

	MakeHowToView();

	// general settings

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// about page

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

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

	// save/cancel/revert buttons

	top->AddChild(tabView);

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

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

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

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

	LoadSettings();

	fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
}
示例#20
0
ConfigWindow::ConfigWindow()
	:
	BWindow(BRect(100, 100, 600, 540), B_TRANSLATE_SYSTEM_NAME("E-mail"),
		B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fLastSelectedAccount(NULL),
	fSaveSettings(false)
{
	BTabView* tabView = new BTabView("tab");
	tabView->SetBorder(B_NO_BORDER);

	// accounts listview

	BView* view = new BView("accounts", 0);
	tabView->AddTab(view);
	tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));

	fAccountsListView = new AccountsListView(this);
	fAccountsListView->SetExplicitPreferredSize(BSize(
		fAccountsListView->StringWidth("W") * 22, B_SIZE_UNSET));

	BButton* addButton = new BButton(NULL, B_TRANSLATE("Add"),
		new BMessage(kMsgAddAccount));
	fRemoveButton = new BButton(NULL, B_TRANSLATE("Remove"),
		new BMessage(kMsgRemoveAccount));

	fConfigView = new BView(NULL, 0);
	fConfigView->SetLayout(new BGroupLayout(B_VERTICAL));
	fConfigView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
	fConfigView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	BScrollView* scroller = new BScrollView(NULL, fAccountsListView, 0,
		false, true);

	BLayoutBuilder::Group<>(view, B_HORIZONTAL)
		.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
			B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL)
			.Add(scroller)
			.AddGroup(B_HORIZONTAL)
				.Add(addButton)
				.Add(fRemoveButton)
			.End()
		.End()
		.Add(fConfigView, 2.0f);

	_ReplaceConfigView(_BuildHowToView());

	// general settings

	view = new BView("general", 0);
	view->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
	tabView->AddTab(view);
	tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings"));

	fCheckMailCheckBox = new BCheckBox("check", B_TRANSLATE("Check every"),
		NULL);
	fIntervalControl = new BTextControl("time", B_TRANSLATE("minutes"), NULL,
		NULL);

	BPopUpMenu* statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
	const char* statusModes[] = {
		B_TRANSLATE_COMMENT("Never", "show status window"),
		B_TRANSLATE("While sending"),
		B_TRANSLATE("While sending and receiving")};
	for (size_t i = 0; i < sizeof(statusModes) / sizeof(statusModes[0]); i++) {
		BMessage* msg = new BMessage(kMsgShowStatusWindowChanged);
		BMenuItem* item = new BMenuItem(statusModes[i], msg);
		statusPopUp->AddItem(item);
		msg->AddInt32("ShowStatusWindow", i);
	}

	fStatusModeField = new BMenuField("show status",
		B_TRANSLATE("Show notifications:"), statusPopUp);

	BMessage* msg = new BMessage(B_REFS_RECEIVED);
	BButton* editMenuButton = new BButton(B_EMPTY_STRING,
		B_TRANSLATE("Edit mailbox menu…"), msg);
	editMenuButton->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
		editMenuButton->SetEnabled(false);

	BLayoutBuilder::Group<>(view, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
			B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
//		.AddGlue()
		.AddGroup(B_HORIZONTAL, 0.f)
			.AddGlue()
			.Add(fCheckMailCheckBox)
			.AddStrut(be_control_look->DefaultLabelSpacing())
			.Add(fIntervalControl->CreateTextViewLayoutItem())
			.AddStrut(be_control_look->DefaultLabelSpacing())
			.Add(fIntervalControl->CreateLabelLayoutItem())
			.AddGlue()
		.End()
		.AddGroup(B_HORIZONTAL, 0.f)
			.AddGlue()
			.Add(fStatusModeField->CreateLabelLayoutItem())
			.Add(fStatusModeField->CreateMenuBarLayoutItem())
			.AddGlue()
		.End()
		.Add(editMenuButton)
		.AddGlue();

	// save/revert buttons

	BButton* applyButton = new BButton("apply", B_TRANSLATE("Apply"),
		new BMessage(kMsgSaveSettings));
	BButton* revertButton = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(kMsgRevertSettings));

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(0, B_USE_DEFAULT_SPACING, 0, B_USE_WINDOW_SPACING)
		.Add(tabView)
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL, 0)
			.Add(revertButton)
			.AddGlue()
			.Add(applyButton)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, 0);

	_LoadSettings();

	fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
	fAccountsListView->MakeFocus(true);

	ResizeToPreferred();
	CenterOnScreen();
}
示例#21
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);
}
示例#22
0
void PecoApp::DoIt() {

	if (NothingToDo()) return;
	
	FileListItem	*ListItem;
	
	BAlert	*myAlert	= new BAlert(NULL, MESSAGE_REALLY_DOIT, STR_CONTINUE, STR_CANCEL);
	if (myAlert->Go() == 1) return;
		for (int32 i = 0; (ListItem = (FileListItem *)fListView->ItemAt(i)) != NULL; i++ ) {
		if (ListItem->fErrorStatus == 1 ) {
			BAlert	*myAlert	= new BAlert(NULL, MESSAGE_WILL_HAVE_PROBS, STR_CONTINUE, STR_CANCEL);
			if (myAlert->Go() == 1) return;
			break;
		}
	}

	bool 	noerror = true, nomoreerrors=false, canceled=false;

	fWindow->Lock();
	fStatusBar->SetText(STATUS_RENAMING);
	fStatusBar->SetMaxValue(fList->CountItems());

	BButton		*okButton = (BButton *)fWindow->FindView("DoIt");
	okButton->SetEnabled(false);
	
	BTextControl* 	pfadView = (BTextControl *)fWindow->FindView("pfadView");
	BString	Pfad(pfadView->Text());
	fWindow->Unlock();
	
	BString	AlterName, NeuerName;
	BEntry	Datei;
	
	for (int32 i = 0; (ListItem = (FileListItem *)fListView->ItemAt(i)) != NULL; i++ ) {
		fWindow->Lock();
		fStatusBar->Update(1);
		fWindow->Unlock();
		if (canceled) { ListItem->fErrorStatus=0; continue; }
		if (ListItem->fNewName.String() != "" ) {
			AlterName = Pfad; AlterName.Append("/").Append(ListItem->fName);
			NeuerName = Pfad; NeuerName.Append("/").Append(ListItem->fNewName);
			Datei.SetTo(AlterName.String());
			if ( Datei.Rename(NeuerName.String()) != B_OK ) {
				ListItem->fErrorStatus=1;
				fWindow->Lock();
				fListView->InvalidateItem(i);
				fWindow->Unlock();

				if (!nomoreerrors) {
					noerror = false;

					BString		ErrorMessage(MESSAGE_HAVE_PROBLEM);
					ErrorMessage.ReplaceFirst("%1", ListItem->fName.String());
					ErrorMessage.ReplaceFirst("%2", ListItem->fNewName.String());
					
					BAlert	*myAlert	= new BAlert(NULL, ErrorMessage.String(), STR_CANCEL, STR_CONTINUE, STR_CONTINUE_WO_MSG, B_WIDTH_AS_USUAL, B_WARNING_ALERT);

					int32	result = myAlert->Go();
					if (result == 0) { canceled = true; continue; }
					if (result == 2) nomoreerrors = true;
				}
				
			} else {
			
				fWindow->Lock();
				ListItem->SetName(ListItem->fNewName);
				ListItem->SetNewName("");
				fListView->InvalidateItem(i);
				fWindow->Unlock();

			}
		}
	}

//	NoRenamer();

	fWindow->Lock();
	fStatusBar->Reset(STATUS_STATUS);
	fWindow->Unlock();

	if (noerror) MakeList();
	else {
		fStatusBar->SetText(STATUS_DIDIT_BAD);

		BAlert	*myAlert	= new BAlert(NULL, MESSAGE_MARKED_FILES, STR_OK);
		myAlert->Go();
	}
	
}