예제 #1
0
void
FadeView::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kMsgRunSliderChanged:
		case kMsgRunSliderUpdate:
			if (fRunSlider->Value() > fTurnOffSlider->Value())
				fTurnOffSlider->SetValue(fRunSlider->Value());

			if (fRunSlider->Value() > fPasswordSlider->Value())
				fPasswordSlider->SetValue(fRunSlider->Value());
			break;

		case kMsgTurnOffSliderChanged:
		case kMsgTurnOffSliderUpdate:
			if (fRunSlider->Value() > fTurnOffSlider->Value())
				fRunSlider->SetValue(fTurnOffSlider->Value());
			break;

		case kMsgPasswordSliderChanged:
		case kMsgPasswordSliderUpdate:
			if (fPasswordSlider->Value() < fRunSlider->Value())
				fRunSlider->SetValue(fPasswordSlider->Value());
			break;

		case kMsgTurnOffCheckBox:
			fTurnOffSlider->SetEnabled(
				fTurnOffCheckBox->Value() == B_CONTROL_ON);
			break;
	}

	switch (message->what) {
		case kMsgRunSliderChanged:
		case kMsgTurnOffSliderChanged:
		case kMsgPasswordSliderChanged:
		case kMsgPasswordCheckBox:
		case kMsgEnableScreenSaverBox:
		case kMsgFadeCornerChanged:
		case kMsgNeverFadeCornerChanged:
			UpdateStatus();
			fSettings.Save();
			break;

		default:
			BView::MessageReceived(message);
	}
}
예제 #2
0
BView *PrefsWindow::create_volumes_pane(void)
{
	BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_VOLUMES_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW);
	pane->SetViewColor(fill_color);
	float right = pane->Bounds().right-10;

	const char *str;
	int32 index = 0;
	volume_list = new VolumeListView(BRect(15, 10, pane->Bounds().right-30, 113), "volumes");
	while ((str = PrefsFindString("disk", index++)) != NULL)
		volume_list->AddItem(new BStringItem(str));
	volume_list->SetSelectionMessage(new BMessage(MSG_VOLUME_SELECTED));
	volume_list->SetInvocationMessage(new BMessage(MSG_VOLUME_INVOKED));
	pane->AddChild(new BScrollView("volumes_border", volume_list, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));

	pane->AddChild(new BButton(BRect(10, 118, pane->Bounds().right/3, 138), "add_volume", GetString(STR_ADD_VOLUME_BUTTON), new BMessage(MSG_ADD_VOLUME)));
	pane->AddChild(new BButton(BRect(pane->Bounds().right/3, 118, pane->Bounds().right*2/3, 138), "create_volume", GetString(STR_CREATE_VOLUME_BUTTON), new BMessage(MSG_CREATE_VOLUME)));
	pane->AddChild(new BButton(BRect(pane->Bounds().right*2/3, 118, pane->Bounds().right-11, 138), "remove_volume", GetString(STR_REMOVE_VOLUME_BUTTON), new BMessage(MSG_REMOVE_VOLUME)));

	extfs_control = new PathControl(true, BRect(10, 145, right, 160), "extfs", GetString(STR_EXTFS_CTRL), PrefsFindString("extfs"), NULL);
	extfs_control->SetDivider(90);
	pane->AddChild(extfs_control);

	BMenuField *menu_field;
	BPopUpMenu *menu = new BPopUpMenu("");
	menu_field = new BMenuField(BRect(10, 165, right, 180), "bootdriver", GetString(STR_BOOTDRIVER_CTRL), menu);
	menu_field->SetDivider(90);
	menu->AddItem(new BMenuItem(GetString(STR_BOOT_ANY_LAB), new BMessage(MSG_BOOT_ANY)));
	menu->AddItem(new BMenuItem(GetString(STR_BOOT_CDROM_LAB), new BMessage(MSG_BOOT_CDROM)));
	pane->AddChild(menu_field);
	int32 i32 = PrefsFindInt32("bootdriver");
	BMenuItem *item;
	if (i32 == 0) {
		if ((item = menu->FindItem(GetString(STR_BOOT_ANY_LAB))) != NULL)
			item->SetMarked(true);
	} else if (i32 == CDROMRefNum) {
		if ((item = menu->FindItem(GetString(STR_BOOT_CDROM_LAB))) != NULL)
			item->SetMarked(true);
	}

	nocdrom_checkbox = new BCheckBox(BRect(10, 185, right, 200), "nocdrom", GetString(STR_NOCDROM_CTRL), new BMessage(MSG_NOCDROM));
	pane->AddChild(nocdrom_checkbox);
	nocdrom_checkbox->SetValue(PrefsFindBool("nocdrom") ? B_CONTROL_ON : B_CONTROL_OFF);

	return pane;
}
예제 #3
0
status_t
ProtocolSettings::Save(const char* account, BView* parent)
{
	if (!parent)
		debugger("Couldn't save protocol's settings GUI on a NULL parent!");

	BMessage* settings = new BMessage();

	BMessage cur;
	for (int32 i = 0; fTemplate->FindMessage("setting", i, &cur) == B_OK; i++) {
		const char* name = cur.FindString("name");

		// Skip NULL names
		if (!name)
			continue;

		int32 type = -1;
		if (cur.FindInt32("type", &type) != B_OK)
			continue;

		BView* view = parent->FindView(name);
		if (!view)
			continue;

		BTextControl* textControl
			= dynamic_cast<BTextControl*>(view);
		if (textControl) {
			switch (type) {
				case B_STRING_TYPE:
					settings->AddString(name, textControl->Text());
					break;
				case B_INT32_TYPE:
					settings->AddInt32(name, atoi(textControl->Text()));
					break;
				default:
					return B_ERROR;
			}
		}

		BMenuField* menuField
			= dynamic_cast<BMenuField*>(view);
		if (menuField) {
			BMenuItem* item = menuField->Menu()->FindMarked();
			if (!item)
				return B_ERROR;

			switch (type) {
				case B_STRING_TYPE:
					settings->AddString(name, item->Label());
					break;
				case B_INT32_TYPE:
					settings->AddInt32(name, atoi(item->Label()));
					break;
				default:
					return B_ERROR;
			}
		}

		BCheckBox* checkBox
			= dynamic_cast<BCheckBox*>(view);
		if (checkBox)
			settings->AddBool(name, (checkBox->Value() == B_CONTROL_ON));

		NotifyingTextView* textView
			= dynamic_cast<NotifyingTextView*>(view);
		if (textView)
			settings->AddString(name, textView->Text());
	}

	return _Save(account, settings);
}
예제 #4
0
bool BContainer::GetElementStr(BItem* element,CString* str)
{
	BCheckBox* boolItem;
	BEdit*	editItem;
	BCombo* comboItem;
	BFile* fileItem;
	BButton* buttonItem;
	CString temp;
	GML::Utils::GString gStrTemp;
	

	UINT someUIntValue;
	int	someIntValue;
	double someDoubleValue;


	switch(element->elementType)
	{
	case GML::Utils::AttributeList::BOOLEAN:
		boolItem = (BCheckBox*)element;
		if(boolItem->IsChecked())
			str->Format("%s=True;",boolItem->label);
		else
			str->Format("%s=False;",boolItem->label);
		return true;

	case GML::Utils::AttributeList::UINT32:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToUInt32(&someUIntValue))
			return false;
		str->Format("%s=%u;",editItem->label,someUIntValue);
		return true;
	case GML::Utils::AttributeList::INT32:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToInt32(&someIntValue))
			return false;
		str->Format("%s=%d;",editItem->label,someIntValue);
		return true;
	
	case GML::Utils::AttributeList::DOUBLE:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToDouble(&someDoubleValue))
			return false;
		str->Format("%s=%lf;",editItem->label,someDoubleValue);
		return true;	
	case GML::Utils::AttributeList::STRING:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		if(temp.Compare("")==0)
		{
			return false;			
		}
		str->Format("%s=%s;",editItem->label,temp);
		return true;

	case TYPE_COMBO:
		comboItem = (BCombo*)element;
		comboItem->GetSelectedItem(temp);
		str->Format("%s=%s;",comboItem->label,temp);
		return true;
	case TYPE_FILE:
		fileItem = (BFile*)element;
		fileItem->GetText(temp);
		str->Format("%s=%s;",fileItem->label,temp);
		return true;
	case TYPE_ELEMENT_HEADER:
		buttonItem = (BButton*)element;
		buttonItem->GetString(&temp);
		str->Format("%s",temp);
		return true;
	}

	return false;
}
예제 #5
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;
}
예제 #6
0
BView* PreferencesWindow::_CreateConnectionPage(float spacing)
{
/*
	BStringView* addingLabel 		= new BStringView("", B_TRANSLATE("Adding"));
	BStringView* downloadingLabel 	= new BStringView("", B_TRANSLATE("Downloading"));
	//BStringView* seedingLabel 	= new BStringView("", B_TRANSLATE("Seeding Limits"));
	
	addingLabel->SetFont(be_bold_font);
	downloadingLabel->SetFont(be_bold_font);
*/
	BStringView* peerPortLabel = new BStringView("", B_TRANSLATE("Peer Port"));
	BStringView* limitsLabel = new BStringView("", B_TRANSLATE("Limits"));
	BStringView* otherLabel = new BStringView("", B_TRANSLATE("Other"));
	peerPortLabel->SetFont(be_bold_font);
	limitsLabel->SetFont(be_bold_font);
	otherLabel->SetFont(be_bold_font);
	

	BStringView* fListeningPortLabel = new BStringView("", B_TRANSLATE("Incoming port:"));
	BStringView* fMaxConnectionLabel = new BStringView("", B_TRANSLATE("Max connections:"));
	BStringView* fTorrentMaxConnectionLabel	= new BStringView("", B_TRANSLATE("Connected peers limit:"));
	//BStringView* fTorrentUploadSlotsLabel = new BStringView("", B_TRANSLATE("Connected peers per torrent limit:"));

	
	
	fListeningPort = new BTextControl("_name", NULL, "", NULL);
	fRandomPort = new BButton("", B_TRANSLATE("Random"), new BMessage(MSG_INCOMING_PORT_RANDOM_BEHAVIOR_CHANGED));
	fApplyPort = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_INCOMING_PORT_BEHAVIOR_CHANGED));
	fEnableForwardingPort = new BCheckBox("", B_TRANSLATE("Enable UPnP / NAT-PMP port forwarding"), new BMessage(MSG_PORT_FORWARDING_BEHAVIOR_CHANGED));	
	fMaxConnection = new BTextControl("_name", "", "", NULL);
	fApplyMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_BEHAVIOR_CHANGED));
	fTorrentMaxConnection = new BTextControl("_name", "", "", NULL);
	fApplyTorrentMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_PER_TORRENT_BEHAVIOR_CHANGED));
	//BTextControl* fTorrentUploadSlots = new BTextControl("_name", "", "", NULL);
	BCheckBox* fEnableDHTValue = new BCheckBox("", B_TRANSLATE("Enable Distributed Hash Table (DHT)"), new BMessage(MSG_DISTRIBUTED_HASH_TABLE_BEHAVIOR_CHANGED));
	BCheckBox* fEnablePEXValue = new BCheckBox("", B_TRANSLATE("Enable Bit Torrent Peer EXchange (PEX)"), new BMessage(MSG_TORRENT_PEER_EXCHANGE_BEHAVIOR_CHANGED));
	BCheckBox* fEnableUTPValue = new BCheckBox("", B_TRANSLATE("Enable Micro Transport Protocol (" UTF8_GREEK_MU_LETTER "TP)"), new BMessage(MSG_MICRO_TRANSPORT_PROTOCOL_BEHAVIOR_CHANGED));
	BCheckBox* fEnableLPDValue = new BCheckBox("", B_TRANSLATE("Enable Local Peer Discovery (LPD)"), new BMessage(MSG_LOCAL_PEER_DISCOVERY_BEHAVIOR_CHANGED));
	
	//
	BPopUpMenu* menu = new BPopUpMenu("");
	
	
	fEncryptionMenuItem[0] = new BMenuItem(B_TRANSLATE("Off"), _CreateEncryptionMenuMessage(0));
	fEncryptionMenuItem[1] = new BMenuItem(B_TRANSLATE("Enabled"), _CreateEncryptionMenuMessage(1));
	fEncryptionMenuItem[2] = new BMenuItem(B_TRANSLATE("Required"), _CreateEncryptionMenuMessage(2));
	
	menu->AddItem(fEncryptionMenuItem[0]);
	menu->AddItem(fEncryptionMenuItem[1]);
	menu->AddItem(fEncryptionMenuItem[2]);
	
	fEncryptionMenu = new BMenuField("", B_TRANSLATE("Encryption:"), menu);
	
	//
	BString textBuffer;	
	
	textBuffer << (int32)fTorrentPreferences->IncomingPort();
	fListeningPort->SetText(textBuffer);
	
	textBuffer = B_EMPTY_STRING;
	textBuffer << (int32)fTorrentPreferences->PeerLimit();
	fMaxConnection->SetText(textBuffer);
	
	textBuffer = B_EMPTY_STRING;
	textBuffer << (int32)fTorrentPreferences->PeerLimitPerTorrent();
	fTorrentMaxConnection->SetText(textBuffer);
	
	//textBuffer << (int32)fTorrentPreferences->IncomingPort();
	//fTorrentUploadSlots->SetText(textBuffer);
	

	fEnableForwardingPort->SetValue(fTorrentPreferences->PortForwardingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableDHTValue->SetValue(fTorrentPreferences->DistributedHashTableEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnablePEXValue->SetValue(fTorrentPreferences->PeerExchangeEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableUTPValue->SetValue(fTorrentPreferences->MicroTransportProtocolEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableLPDValue->SetValue(fTorrentPreferences->LocalPeerDiscoveryEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEncryptionMenuItem[fTorrentPreferences->EncryptionMode()]->SetMarked(true);
	
	//
	fListeningPort->SetExplicitMaxSize(BSize(60, 40));
	fMaxConnection->SetExplicitMaxSize(BSize(60, 40));
	fTorrentMaxConnection->SetExplicitMaxSize(BSize(60, 40));
	//fTorrentUploadSlots->SetExplicitMaxSize(BSize(60, 40));
	
	//
	//
	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(peerPortLabel)
		.Add(BGridLayoutBuilder(-1, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fListeningPortLabel, 0, 0)
			//.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 1, 0)
			.Add(fListeningPort, 1, 0)
			.Add(fRandomPort, 2, 0)
			.Add(fApplyPort, 3, 0)
			
			//.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 3, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 4, 0)
			
			//
			.Add(fEnableForwardingPort, 0, 1, 3, 1)
			
			//
		)
		.Add(limitsLabel)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fMaxConnectionLabel, 0, 0)
			.Add(fMaxConnection, 1, 0)
			.Add(fApplyMaxConnection, 2, 0)
			// padding
			//.Add(BSpaceLayoutItem::CreateGlue(), 3, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 4, 0)
			
			//
			.Add(fTorrentMaxConnectionLabel, 0, 1)
			.Add(fTorrentMaxConnection, 1, 1)
			.Add(fApplyTorrentMaxConnection, 2, 1)
			//
			//.Add(fTorrentUploadSlotsLabel, 0, 2)
			//.Add(fTorrentUploadSlots, 1, 2)
		)
		.Add(otherLabel)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fEnableDHTValue, 0, 0, 3, 1)
			.Add(fEnablePEXValue, 0, 1, 3, 1)
			.Add(fEnableUTPValue, 0, 2, 3, 1)
			.Add(fEnableLPDValue, 0, 3, 3, 1)
			
			
			//
			.Add(fEncryptionMenu->CreateLabelLayoutItem(), 0, 4)
			.Add(fEncryptionMenu->CreateMenuBarLayoutItem(), 1, 4)
		)
		.SetInsets(spacing, spacing, spacing, spacing)
		.TopView()
	;
	view->SetName("Connection");
	return view;
}
예제 #7
0
//calculate the view positions of all the MatrixLayoutItems
//on the items list with offsets based upon matrixLeft
//and matrixTop
void 
LayoutMatrix	::	Calc(	const float paramMatrixLeft,  
							const float paramMatrixTop,
							sem_id paramSemID) 
{
	int32 numItems = mpItemsList->CountItems();
	if (!numItems) return;
	if (acquire_sem(paramSemID) != B_NO_ERROR)
	{
		warning(myPrefs->FailAqSem);
		return;
	}
	bool hasPopUpMenu = false;
	TextItem *	scratchTextItem;
	for (	int i = 0;
			i < numItems;
			i++)
	{
		((LayoutMatrixItem *)(mpItemsList->ItemAt(i)))->Calc();
	}
	float widest = 0;
	float tallest = 0;
	int32 index = 0;
	for (	int i = 0;
			i < numItems;
			i++)
	{
		LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
		if (lmi->mfWidthPref > widest) 
		{
			widest = lmi->mfWidthPref;
		}
		if (lmi->mfHeightPref > tallest) 
		{
			tallest = lmi->mfHeightPref;
		}
	}
	if (mui32Flags & SAMESIZE) 
	{//SAMESIZE makes all items the same size as the largest
		index = 0;
		//Resize all items to match largest:
		for (	uint32 i = 0;
				i < mui32Rows;
				i++) 
		{
			for (	uint32 j = 0;
					j < mui32Columns;
					j++) 
			{
				LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
				switch (lmi->mui32Kind)
				{
					case KIND_MYSPACER:
					{
						MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
						if (scratchMySpacer->mbSAMEFromWidest)
						{
							scratchMySpacer->ResizeTo(widest, tallest);
						}
					}
					break;
					case KIND_MYBUTTON:
					{
						BButton * scratchMyButton = (BButton *)lmi->mpItem;
						scratchMyButton->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYSLIDER:
					{
						BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
						scratchMySlider->ResizeTo(widest, tallest);
					}
					break;
					case KIND_STRINGDRAWER:
					{
						BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
						scratchMyStringView->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYCHECKBOX:
					{
						BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
						scratchMyCheckBox->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYPICTUREBUTTON:
					{
						BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
						scratchMyPictureButton->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYCOLORCONTROL:
					{
						BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
						scratchMyColorControl->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYSTATUSBAR:
					{
						BStatusBar * scratchMyStatusBar = (BStatusBar *)lmi->mpItem;
						scratchMyStatusBar->ResizeTo(widest, tallest);
					}
					break;
					case KIND_UINT32CONTROL:
					{
						UInt32Control * scratchUInt32Control = (UInt32Control *)lmi->mpItem;
						scratchUInt32Control->ResizeTo(widest, tallest);
					}
					break;
					case KIND_FLOATCONTROL:
					{
						FloatControl * scratchFloatControl = (FloatControl *)lmi->mpItem;
						scratchFloatControl->ResizeTo(widest, tallest);
					}
					break;
					case KIND_STRINGCONTROL:
					{
						StringControl * scratchStringControl = (StringControl *)lmi->mpItem;
						scratchStringControl->ResizeTo(widest, tallest);
					}
					break;
				}
			}
		}
	}
	index = 0;
	//move every item based upon size and padding:
	const float hpad = 2;//horizontal spacing between items
	const float vpad = 2;//vertical spacing between items
	float localLeft;
	float localTop = vpad + paramMatrixTop;
	float excessRight = 0, excessRightHold = 0;
	float excessBottom = 0, excessBottomHold = 0;
	for (	uint32 ii = 0;
			ii < mui32Rows;
			ii++) 
	{
		localLeft = paramMatrixLeft + hpad;
		float columnRight = 0;
		excessBottom = 0;
		for (	uint32 jj = 0;
				jj < mui32Columns;
				jj++) 
		{
			excessRight = 0;
			LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
			switch (lmi->mui32Kind) 
			{
				case KIND_MYPOPUPMENU:
				{
					hasPopUpMenu = true;
					MyPopUpMenu * scratchPopUpMenu = (MyPopUpMenu *)lmi->mpItem;
					scratchPopUpMenu->mfLabelLeft = localLeft;
					excessRightHold = lmi->mfWidthPref + scratchPopUpMenu->mfLabelWidth;
					scratchPopUpMenu->SetLeft(localLeft);
					scratchPopUpMenu->mfLabelTop = localTop;
					if ((scratchPopUpMenu->mfHeight + 9) > scratchPopUpMenu->mfLabelHeight)
					{
						excessBottomHold = scratchPopUpMenu->mfHeight + 10;
					}
					else
					{
						excessBottomHold = scratchPopUpMenu->mfLabelHeight + 1;
					}
				}
				break;
				case KIND_MYTEXTVIEW:
				{
					BTextView * scratchTextView = (BTextView *)lmi->mpItem;
					scratchTextView->MoveTo(localLeft, localTop);
					excessRightHold = ((MyTextView *)scratchTextView)->mfWidth;
					excessBottomHold = ((MyTextView *)scratchTextView)->mfHeight;
				}
				break;
				case KIND_MYLISTVIEW:
				{
					BListView * scratchListView = (BListView *)lmi->mpItem;
					scratchListView->MoveTo(localLeft, localTop);
					((BListView *)(lmi->mpItem))->GetPreferredSize(&excessRightHold, &excessBottomHold);
				}
				break;
				case KIND_MYBUTTON:
				{
					BButton * scratchMyButton = (BButton *)lmi->mpItem;
					scratchMyButton->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYSLIDER:
				{
					BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
					scratchMySlider->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYSPACER:
				{
					MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
					if (	(mui32Flags & SAMESIZE) 
							&& 
							scratchMySpacer->mbSAMEFromWidest)
					{
						excessRightHold = widest;
						excessBottomHold = tallest;
					}
					else
					{
						excessRightHold = scratchMySpacer->mfPreferredWidth;
						excessBottomHold = scratchMySpacer->mfPreferredHeight;
					}
				}
				break;
				case KIND_MYRADIOVIEW:
				{
					MyRadioView * scratchRadioView = (MyRadioView *)lmi->mpItem;
					scratchRadioView->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_STRINGDRAWER:
				{
					BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
					TextItem * scratchTextItem = ((MyStringDrawer *)lmi->mpItem)->GetTextItem();
					scratchTextItem->mfLeft = localLeft;
					scratchTextItem->mfTop = localTop + lmi->mfHeightPref - ((MyStringDrawer *)lmi->mpItem)->mfDescender - vpad;
					scratchMyStringView->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYCHECKBOX:
				{
					BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
					scratchMyCheckBox->MoveTo(localLeft, localTop + 1);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref + 1;
				}
				break;
				case KIND_MYPICTUREBUTTON:
				{
					BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
					scratchMyPictureButton->MoveTo(localLeft, localTop);
					excessRightHold = scratchMyPictureButton->Bounds().Width() + 1;
					excessBottomHold = scratchMyPictureButton->Bounds().Height() + 1;
				}
				break;
				case KIND_MYCOLORCONTROL:
				{
					BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
					scratchMyColorControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
					;
				}
				break;
				case KIND_MYSTATUSBAR:
				{
					MyStatusBar * scratchMyStatusBar = (MyStatusBar *)lmi->mpItem;
					scratchMyStatusBar->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_UINT32CONTROL:
				{
					UInt32Control * scratchUInt32Control = (UInt32Control *)lmi->mpItem;
					scratchUInt32Control->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_FLOATCONTROL:
				{
					FloatControl * scratchFloatControl = (FloatControl *)lmi->mpItem;
					scratchFloatControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_STRINGCONTROL:
				{
					StringControl * scratchStringControl = (StringControl *)lmi->mpItem;
					scratchStringControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_TEXT:
					scratchTextItem = (TextItem *)lmi->mpItem;
					scratchTextItem->mfLeft = localLeft;
					scratchTextItem->mfTop = localTop + lmi->mfHeightPref;
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				break;
				case KIND_COLORWELL:
					((ColorWell *)lmi->mpItem)->mfLabelLeft = localLeft;
					((ColorWell *)lmi->mpItem)->SetLeft(((ColorWell *)lmi->mpItem)->GetLeft() + localLeft);
					excessRightHold = lmi->mfWidthPref;
					((ColorWell *)lmi->mpItem)->mfLabelTop = localTop;
					((ColorWell *)lmi->mpItem)->SetTop(((ColorWell *)lmi->mpItem)->GetTop() + localTop);
					excessBottomHold = lmi->mfHeightPref;
				break;
				case KIND_INT8GADGET:
				case KIND_UINT8GADGET:
				case KIND_INT16GADGET:
				case KIND_UINT16GADGET:
				case KIND_INT32GADGET:
				case KIND_UINT32GADGET:
				case KIND_INT64GADGET:
				case KIND_UINT64GADGET:
				case KIND_FLOATGADGET:
				case KIND_HEXGADGET:
				case KIND_STRINGGADGET:
					((GadgetBase *)lmi->mpItem)->mfLabelLeft = localLeft;
					((GadgetBase *)lmi->mpItem)->SetLeft(((GadgetBase *)lmi->mpItem)->GetLeft() + localLeft);
					excessRightHold = lmi->mfWidthPref;
					((GadgetBase *)lmi->mpItem)->mfLabelTop = localTop;
					((GadgetBase *)lmi->mpItem)->SetTop(((GadgetBase *)lmi->mpItem)->GetTop() + localTop);
					excessBottomHold = lmi->mfHeightPref + 1;
				break;
			}
			if (mui32Flags & SAMESIZE)
			{
				excessRightHold = widest;
				excessBottomHold = tallest;
			}
			excessRightHold += hpad;
			if (excessRightHold > excessRight)
			{
				excessRight = excessRightHold;
			}
			localLeft += excessRight;
			if (mui32Columns - 1) 
			{
				if (jj != (mui32Columns - 1)) 
				{
					if (localLeft > columnRight) 
					{
						columnRight = localLeft;
					}
				}
				else 
				{
					columnRight = localLeft;
				}
			}
			else 
			{
				if (localLeft > columnRight) 
				{
					columnRight = localLeft;
				}
			}
			//mfRight is stored so that another MatrixLayout
			//can know where a previous one ended up
			if (excessBottomHold > excessBottom)
			{
				excessBottom = excessBottomHold;
			}
		}
		if (columnRight > mfRight)
		{
			mfRight = columnRight;
		}
		excessBottomHold += vpad;
		localTop += excessBottom;
		if (mui32Rows - 1) 
		{
			if (ii != (mui32Rows - 1)) 
			{
				if (localTop > mfBottom) 
				{
					mfBottom = localTop;
				}
			}
			else 
			{
				mfBottom = localTop;
			}
		}
		else 
		{
			if (localTop > mfBottom) 
			{
				mfBottom = localTop;
			}
		}
		//mfBottom is stored so that another MatrixLayout
		//can know where a previous one ended up
	}
	if (hasPopUpMenu)
	{
		mfRight += 30;
	}
	release_sem(paramSemID);
}//end
예제 #8
0
NetworkWindow::NetworkWindow()
	:
	BWindow(BRect(100, 100, 400, 400), B_TRANSLATE("Network"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fServicesItem(NULL),
	fDialUpItem(NULL),
	fOtherItem(NULL)
{
	// Profiles section
#if ENABLE_PROFILES
	BPopUpMenu* profilesPopup = new BPopUpMenu("<none>");
	_BuildProfilesMenu(profilesPopup, kMsgProfileSelected);

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

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

	// Settings section

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

	BMessage* message = new BMessage(kMsgToggleReplicant);
	BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
		B_TRANSLATE("Show network status in Deskbar"), message);
	showReplicantCheckBox->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	showReplicantCheckBox->SetValue(_IsReplicantInstalled());

	fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_NAVIGABLE);
	fListView->SetSelectionMessage(new BMessage(kMsgItemSelected));

	BScrollView* scrollView = new BScrollView("ScrollView", fListView,
		0, false, true);
	scrollView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	fAddOnShellView = new BView("add-on shell", 0,
		new BGroupLayout(B_VERTICAL));
	fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fInterfaceView = new InterfaceView();

	// Build the layout
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)

#if ENABLE_PROFILES
		.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
			.Add(profilesMenuField)
			.AddGlue()
		.End()
#endif
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(scrollView)
			.Add(fAddOnShellView)
			.End()
		.Add(showReplicantCheckBox)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fRevertButton)
			.AddGlue()
		.End();

	gNetworkWindow = this;

	_ScanInterfaces();
	_ScanAddOns();
	_UpdateRevertButton();

	fListView->Select(0);
	_SelectItem(fListView->ItemAt(0));
		// Call this manually, so that CenterOnScreen() below already
		// knows the final window size.

	// Set size of the list view from its contents
	float width;
	float height;
	fListView->GetPreferredSize(&width, &height);
	width += 2 * be_control_look->DefaultItemSpacing();
	fListView->SetExplicitSize(BSize(width, B_SIZE_UNSET));
	fListView->SetExplicitMinSize(BSize(width, std::min(height, 400.f)));

	CenterOnScreen();

	fSettings.StartMonitoring(this);
	start_watching_network(B_WATCH_NETWORK_INTERFACE_CHANGES
		| B_WATCH_NETWORK_LINK_CHANGES | B_WATCH_NETWORK_WLAN_CHANGES, this);
}
예제 #9
0
BView *PrefsWindow::create_graphics_pane(void)
{
	BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_GRAPHICS_SOUND_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW);
	pane->SetViewColor(fill_color);
	float right = pane->Bounds().right-10;

	const char *mode_str = PrefsFindString("screen");
	int width = 512, height = 384;
	scr_mode_bit = 0;
	display_type = DISPLAY_WINDOW;
	if (mode_str) {
		if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2)
			display_type = DISPLAY_WINDOW;
		else if (sscanf(mode_str, "scr/%d", &scr_mode_bit) == 1)
			display_type = DISPLAY_SCREEN;
	}

	BMenuField *menu_field;
	BMenuItem *item;
	BPopUpMenu *menu;

	menu = new BPopUpMenu("");
	menu_field = new BMenuField(BRect(10, 5, right, 20), "videotype", GetString(STR_VIDEO_TYPE_CTRL), menu);
	menu_field->SetDivider(120);
	menu->AddItem(item = new BMenuItem(GetString(STR_WINDOW_LAB), new BMessage(MSG_VIDEO_WINDOW)));
	if (display_type == DISPLAY_WINDOW)
		item->SetMarked(true);
	menu->AddItem(item = new BMenuItem(GetString(STR_FULLSCREEN_LAB), new BMessage(MSG_VIDEO_SCREEN)));
	if (display_type == DISPLAY_SCREEN)
		item->SetMarked(true);
	pane->AddChild(menu_field);

	menu = new BPopUpMenu("");
	frameskip_menu = new BMenuField(BRect(10, 26, right, 41), "frameskip", GetString(STR_FRAMESKIP_CTRL), menu);
	frameskip_menu->SetDivider(120);
	menu->AddItem(new BMenuItem(GetString(STR_REF_5HZ_LAB), new BMessage(MSG_REF_5HZ)));
	menu->AddItem(new BMenuItem(GetString(STR_REF_7_5HZ_LAB), new BMessage(MSG_REF_7_5HZ)));
	menu->AddItem(new BMenuItem(GetString(STR_REF_10HZ_LAB), new BMessage(MSG_REF_10HZ)));
	menu->AddItem(new BMenuItem(GetString(STR_REF_15HZ_LAB), new BMessage(MSG_REF_15HZ)));
	menu->AddItem(new BMenuItem(GetString(STR_REF_30HZ_LAB), new BMessage(MSG_REF_30HZ)));
	pane->AddChild(frameskip_menu);
	int32 i32 = PrefsFindInt32("frameskip");
	if (i32 == 12) {
		if ((item = menu->FindItem(GetString(STR_REF_5HZ_LAB))) != NULL)
			item->SetMarked(true);
	} else if (i32 == 8) {
		if ((item = menu->FindItem(GetString(STR_REF_7_5HZ_LAB))) != NULL)
			item->SetMarked(true);
	} else if (i32 == 6) {
		if ((item = menu->FindItem(GetString(STR_REF_10HZ_LAB))) != NULL)
			item->SetMarked(true);
	} else if (i32 == 4) {
		if ((item = menu->FindItem(GetString(STR_REF_15HZ_LAB))) != NULL)
			item->SetMarked(true);
	} else if (i32 == 2) {
		if ((item = menu->FindItem(GetString(STR_REF_30HZ_LAB))) != NULL)
			item->SetMarked(true);
	}

	display_x_ctrl = new NumberControl(BRect(10, 48, right / 2, 66), 118, "width", GetString(STR_DISPLAY_X_CTRL), width, NULL);
	pane->AddChild(display_x_ctrl);
	display_y_ctrl = new NumberControl(BRect(10, 69, right / 2, 87), 118, "height", GetString(STR_DISPLAY_Y_CTRL), height, NULL);
	pane->AddChild(display_y_ctrl);

	menu = new BPopUpMenu("");
	scr_mode_menu = new BMenuField(BRect(10, 26, right, 41), "screenmode", GetString(STR_SCREEN_MODE_CTRL), menu);
	scr_mode_menu->SetDivider(120);
	for (int i=0; scr_mode[i].mode_mask; i++) {
		menu->AddItem(item = new BMenuItem(GetString(scr_mode[i].str), new BMessage(MSG_SCREEN_MODE + i)));
		if (scr_mode[i].mode_mask & (1 << scr_mode_bit))
			item->SetMarked(true);
	}
	pane->AddChild(scr_mode_menu);

	nosound_checkbox = new BCheckBox(BRect(10, 90, right, 105), "nosound", GetString(STR_NOSOUND_CTRL), new BMessage(MSG_NOSOUND));
	pane->AddChild(nosound_checkbox);
	nosound_checkbox->SetValue(PrefsFindBool("nosound") ? B_CONTROL_ON : B_CONTROL_OFF);

	hide_show_graphics_ctrls();
	return pane;
}
/*!	\brief		Main function of the View.
 *	\details	Receives and parses the messages and updates the preferences if needed.
 *	\param[in]	in		The message to be parsed.
 */
void 		CalendarModulePreferencesView::MessageReceived( BMessage* in )
{
	CalendarModulePreferences* prefs = NULL;
	uint32	tempUint32 = 0;
	int8	tempInt8 = 0;
	int tempInt = 0;
	BString sb;
	BAlert* alert = NULL;
	BCheckBox* cb = NULL;
	BMessage* toSend;
	CalendarModule* calModule = NULL;
	CategoryListView* catListView = NULL;
	CategoryListItem* catListItem = NULL;
	Category receivedFromUpdate( BString("") );
	ColorUpdateWindow*	cuWindow = NULL;
	bool weekend, weekday, viewer, service;
	
	switch ( in->what )
	{
		case kCalendarModuleChosen:
			
			if ( B_OK != in->FindString( "Module ID" , &sb ) )
				return BView::MessageReceived( in );
			BuildInterfaceForModule( sb );
			break;

		case kCalendarModuleFirstDayOfWeekSelected:
			
			if ( ( B_OK != in->FindString( "Calendar module", &sb ) ) 		||
				 ( B_OK != in->FindInt32( "Day", ( int32* )&tempUint32 ) )	||
				 ( ( prefs = pref_GetPreferencesForCalendarModule( sb ) ) == NULL ) )
			{
				// Can't update - don't know what the module is!
				BView::MessageReceived( in );
			}
		
			prefs->SetFirstDayOfWeek( tempUint32 );
			
			// Refresh the view
			BuildInterfaceForModule( sb );
			
			break;
		
		case kCalendarModuleWeekendDaySelected:
		
			if ( ( B_OK != in->FindString( "Calendar module", &sb ) ) 		||
				 ( B_OK != in->FindInt32( "Weekday const", ( int32* )&tempUint32 ) )	||
				 ( ( prefs = pref_GetPreferencesForCalendarModule( sb ) ) == NULL ) )
			{
				// Can't update - don't know what the module is!
				BView::MessageReceived( in );
			}
			calModule = utl_FindCalendarModule( sb );			
			
			sb.SetTo( "Weekday" );
			sb << tempUint32;
			
			if ( B_OK != ( cb = ( BCheckBox* )this->FindView( sb.String() ) ) )
				BView::MessageReceived( in );
			
			if ( cb->Value() == 0 )		// Deselected - removing from weekends
			{
				prefs->RemoveFromWeekends( tempUint32 );
			} else {					// Selected - adding to weekends
				prefs->AddToWeekends( tempUint32 );
			}
			
			// :)
			if ( calModule ) {
				if ( prefs->GetNumberOfWeekends() == calModule->GetDaysInWeek() ) {
					alert = new BAlert( "I envy you!",
										"Wow! Nice week you have! I really envy you!",
										":)",
										NULL,
										NULL,
										B_WIDTH_AS_USUAL,
										B_EVEN_SPACING,
										B_IDEA_ALERT );
					if ( alert )
						alert->Go();
				}
			}
			
			break;
			
		case ( kCategoryInvoked ):
		
			catListView = dynamic_cast< CategoryListView* >( this->FindView( "Colors list view" ) );
			if ( !catListView ) {
				break;
			}
		
			// Modifying currently existing category
			tempInt = catListView->CurrentSelection();
			if ( tempInt < 0 )
			{
				break;
			}
			catListItem = ( CategoryListItem* )catListView->ItemAt( tempInt );
			toSend = new BMessage( kColorSelected );
			if ( toSend ) {
				in->FindString( "Calendar module", &sb );
				toSend->AddString( "Calendar module", sb );
			}
			
			cuWindow = new ColorUpdateWindow( Category( catListItem->GetLabel(), catListItem->GetColor() ),
											 false,		// Name shouldn't be edited
											 "Edit category",
											 ( BHandler* )this,
											 this->Looper(),
											 toSend );
			break;
			
		case ( kCalendarModuleDateOrderSelected ):
			if ( ( B_OK != in->FindString( "Calendar module", &sb ) ) ||
				 ( ( prefs = pref_GetPreferencesForCalendarModule( sb ) ) == NULL ) ||
				 ( B_OK != in->FindInt8( "DayMonthYearOrder", ( int8* )&tempInt8 ) ) )
			{
				return BView::MessageReceived( in );
			}
			
			prefs->SetDayMonthYearOrder( ( DmyOrder )tempInt8 );
			
			break;
		case ( kColorSelected ):	// Intentional fall-through
		case ( kColorReverted ):
			catListView = dynamic_cast< CategoryListView* >( this->FindView( "Colors list view" ) );
			if ( !catListView ) {
				break;
			}
		
			in->FindString( "Calendar module", &sb );
			in->FindString( "New string", &receivedFromUpdate.categoryName );
			in->FindInt32( "New color", ( int32* )&tempUint32 );
			
			prefs = pref_GetPreferencesForCalendarModule( sb );
				 
			if ( prefs == NULL )
			{
				return BView::MessageReceived( in );
			}
			
			receivedFromUpdate.categoryColor = RepresentUint32AsColor( tempUint32 );
			
			// If the received category name is empty, don't change anything.
			if ( receivedFromUpdate.categoryName == "" )
			{
				in->FindString( "Original string", &receivedFromUpdate.categoryName );
			}
			
			catListItem = new CategoryListItem( receivedFromUpdate );
			if ( ! catListItem )
			{
				/* Panic! */
				exit( 1 );	
			}
			catListView->AddItem( catListItem );

			// It's time to update the preferences
			if ( B_ERROR == receivedFromUpdate.categoryName.IFindFirst( "weekend" ) ) {
				weekend = false;
			} else {
				weekend = true;
			}
			if ( B_ERROR == receivedFromUpdate.categoryName.IFindFirst( "weekday" ) ) {
				weekday = false;
			} else {
				weekday = true;
			}
			if ( B_ERROR == receivedFromUpdate.categoryName.IFindFirst( "viewer" ) ) {
				viewer = false;
			} else {
				viewer = true;
			}
			if ( B_ERROR == receivedFromUpdate.categoryName.IFindFirst( "service" ) ) {
				service = false;
			} else {
				service = true;
			}
			
			if ( prefs ) {
				if ( weekend ) {
					prefs->SetWeekendsColor( receivedFromUpdate.categoryColor, viewer );
				} else if ( weekday ) {
					prefs->SetWeekdaysColor( receivedFromUpdate.categoryColor, viewer );
				} else if ( service ) {
					prefs->SetServiceItemsColor( receivedFromUpdate.categoryColor, viewer );
				} else {
					utl_Deb = new DebuggerPrintout( "Didn't find the type of color to update!" );
				}
			}
			else
			{
				utl_Deb = new DebuggerPrintout( "Didn't find the preferences to update!" );
			}
			
			break;
		
		default:
			BView::MessageReceived( in );
		
	};	// <-- end of "switch( the "what" field )"
	
}	// <-- end of CalendarModulePrerefencesView::MessageReceived
예제 #11
0
void
MouseWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgDefaults: {
			// reverts to default settings
			fSettings.Defaults();
			fSettingsView->UpdateFromSettings();

			fDefaultsButton->SetEnabled(false);
			fRevertButton->SetEnabled(fSettings.IsRevertable());
			break;
		}

		case kMsgRevert: {
			// revert to last settings
			fSettings.Revert();
			fSettingsView->UpdateFromSettings();

			fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
			fRevertButton->SetEnabled(false);
			break;
		}

		case kMsgMouseType:
		{
			int32 type;
			if (message->FindInt32("index", &type) == B_OK) {
				fSettings.SetMouseType(++type);
				fSettingsView->SetMouseType(type);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgMouseFocusMode:
		{
			int32 mode;
			if (message->FindInt32("mode", &mode) == B_OK) {
				fSettings.SetMouseMode((mode_mouse)mode);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
				fSettingsView->fFocusFollowsMouseMenu->SetEnabled(
					mode == B_FOCUS_FOLLOWS_MOUSE);
				fSettingsView->fAcceptFirstClickBox->SetEnabled(
					mode != B_FOCUS_FOLLOWS_MOUSE);
			}
			break;
		}

		case kMsgFollowsMouseMode:
		{
			int32 mode;
			if (message->FindInt32("mode_focus_follows_mouse", &mode)
				== B_OK) {
				fSettings.SetFocusFollowsMouseMode(
					(mode_focus_follows_mouse)mode);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgAcceptFirstClick:
		{
			BHandler *handler;
			if (message->FindPointer("source",
				reinterpret_cast<void**>(&handler)) == B_OK) {
				bool acceptFirstClick = false;
				BCheckBox *acceptFirstClickBox =
					dynamic_cast<BCheckBox*>(handler);
				if (acceptFirstClickBox)
					acceptFirstClick = acceptFirstClickBox->Value()
						== B_CONTROL_ON;
				fSettings.SetAcceptFirstClick(acceptFirstClick);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgDoubleClickSpeed:
		{
			int32 value;
			if (message->FindInt32("be:value", &value) == B_OK) {
				// slow = 1000000, fast = 0
				fSettings.SetClickSpeed(value * 1000);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgMouseSpeed:
		{
			int32 value;
			if (message->FindInt32("be:value", &value) == B_OK) {
				// slow = 8192, fast = 524287
				fSettings.SetMouseSpeed((int32)pow(2,
					value * 6.0 / 1000) * 8192);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgAccelerationFactor:
		{
			int32 value;
			if (message->FindInt32("be:value", &value) == B_OK) {
				// slow = 0, fast = 262144
				fSettings.SetAccelerationFactor((int32)pow(
					value * 4.0 / 1000, 2) * 16384);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
			}
			break;
		}

		case kMsgMouseMap:
		{
			int32 index;
			int32 button;
			if (message->FindInt32("index", &index) == B_OK
				&& message->FindInt32("button", &button) == B_OK) {
				int32 mapping = B_PRIMARY_MOUSE_BUTTON;
				switch (index) {
					case 1:
						mapping = B_SECONDARY_MOUSE_BUTTON;
						break;
					case 2:
						mapping = B_TERTIARY_MOUSE_BUTTON;
						break;
				}

				fSettings.SetMapping(button, mapping);
				fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
				fRevertButton->SetEnabled(fSettings.IsRevertable());
				fSettingsView->MouseMapUpdated();
			}
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
/*!	\brief		Updates targets of all controls currently in the view.
 *	\details	BView::AttachToWindow(), among other things, modifies the targets
 *				of controls to point to main looper of the application. This is
 *				not desirable way. This function corrects it.
 */
void		CalendarModulePreferencesView::UpdateTargetting( void )
{
	BCheckBox* tempCheckBox = NULL;
	int i, limit;

	// Updating calendar chooser part
	BMenuItem* menuItem = NULL;
	if ( calendarModules ) {
		limit = calendarModules->CountItems();
		for ( i = 0; i < limit; ++i )
		{
			menuItem = dynamic_cast< BMenuItem* >( calendarModules->ItemAt( i ) );
			if ( menuItem )
				menuItem->SetTarget( this );
		}
	}

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

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

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

		/* Set the name of the checkbox.
		 * This is used to identify if the checkbox was checked or unchecked.
		 */
		tempString.SetTo( "Weekday" );
		tempString << day;
		
		/* Creating the checkbox */
		dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
									 tempString.String(),
									 weekdayNames[ day ].longName.String(),
									 toSend );
		if (!dayCheckBox)
		{
			// Panic!
			exit(1);
		}
		dayCheckBox->ResizeToPreferred();
		
		// Check if the checkbox should be checked
		if ( weekends->HasItem( ( void* )day ) ) {
			dayCheckBox->SetValue( 1 );
		} else {
			dayCheckBox->SetValue( 0 );
		}
		
		/* Adding the item to the BBox */
		layoutItem = layout->AddView( dayCheckBox, indexX, indexY );
		if ( layoutItem )
		{
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
//			layoutItem->SetExplicitMaxSize( BSize( (int )dayCheckBox->Bounds().Width(), (int )dayCheckBox->Bounds().Height() ) );
			layout->SetMaxRowHeight( indexY, (int )dayCheckBox->Bounds().Height() + 10 );
			layout->SetRowWeight( indexY, 0 );
		}
		
		/* Advancing to the next cell in grid */
		// If arrived to the last item in the first column, advancing to second
		// The +1 is needed because i starts from 0, but days are starting from 1
		if ( ( i + 1 ) == ( unsigned int )( ( daysInWeek + 1 ) / 2 ) )
		{
			indexX = 1;	
			indexY = 0;
		}
		else 	// Staying in the same column, but advancing down
		{
			++indexY;	
		}
		
		/* Advancing to the next day */
		( day == daysInWeek ) ? day = kSunday : ++day;
		
	}	// <-- end of "for (all days in week)"
	
	// Resizing the BBox to the correct size.
	// Note: dayCheckBox is surely not NULL; if it were, we would exit earlier.
	height =(int )( ( dayCheckBox->Bounds().Height() + 5           ) * ( int )( ( daysInWeek + 1 ) / 2 ) - 5 );
	// Formula:	    ( ^height of one checkbox^       + ^separator^ ) * ( ^number of days in column^      ) - ^one unneeded extra separator^
	
	enclosingBox->ResizeTo( enclosingBox->Bounds().Width() - 10, ( int )height );
//	layout->SetExplicitMaxSize( BSize( enclosingBox->Bounds().Width() - 5, ( int )height + 25 ) );
	
	return enclosingBox;
}
예제 #14
0
// --------------------------------------------------------------
NetworkSetupWindow::NetworkSetupWindow(const char *title)
	:
	BWindow(BRect(100, 100, 600, 600), title, B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMenu 		*show_menu;
	BMenu		*profiles_menu;
	BMenuField 	*menu_field;
	BBox 		*top_box, *bottom_box, *line;	// *group
	BButton		*button;
	BCheckBox 	*check;
	BRect		r;
	float		x, w, h;
	float		size, min_size = 360;

	// TODO: cleanup this mess!
	show_menu = new BPopUpMenu("<please select me!>");
	_BuildShowMenu(show_menu, SHOW_MSG);
	
#define H_MARGIN	10
#define V_MARGIN	10
#define SMALL_MARGIN	3

	// Resize the window to minimal width
	ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, Bounds().Height());

	top_box = new BBox(Bounds(), NULL, B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	AddChild(top_box); 

	r = top_box->Bounds();
	r.InsetBy(H_MARGIN, V_MARGIN);

	// ---- Profiles section
	profiles_menu = new BPopUpMenu("<none>");
	menu_field = new BMenuField(r, "profiles_menu", PROFILE_LABEL, 
		profiles_menu);

	menu_field->SetFont(be_bold_font);
	menu_field->SetDivider(be_bold_font->StringWidth(PROFILE_LABEL "#"));
	top_box->AddChild(menu_field);
	menu_field->ResizeToPreferred();
	menu_field->GetPreferredSize(&w, &h);

	size = w;

	button = new BButton(r, "manage_profiles", MANAGE_PROFILES_LABEL,
					new BMessage(MANAGE_PROFILES_MSG),
					B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	button->GetPreferredSize(&w, &h);
	button->ResizeToPreferred();
	button->MoveTo(r.right - w, r.top);
	top_box->AddChild(button);
	
	size += SMALL_MARGIN + w;
	
	min_size = max_c(min_size, (H_MARGIN + size + H_MARGIN));
	
	r.top += h + V_MARGIN;

	// ---- Separator line between Profiles section and Settings section
	line = new BBox(BRect(r.left, r.top, r.right, r.top + 1), NULL,
						 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
	top_box->AddChild(line);

	_BuildProfilesMenu(profiles_menu, SELECT_PROFILE_MSG);

	r.top += 2 + V_MARGIN;

	// ---- Settings section

	// Make the show popup field half the whole width and centered
	menu_field = new BMenuField(r, "show_menu", SHOW_LABEL, show_menu);
	menu_field->SetFont(be_bold_font);
	menu_field->SetDivider(be_bold_font->StringWidth(SHOW_LABEL "#"));
	top_box->AddChild(menu_field);

	menu_field->ResizeToPreferred();
	menu_field->GetPreferredSize(&w, &h);
	r.top += h+1 + V_MARGIN;
	
	min_size = max_c(min_size, (H_MARGIN + w + H_MARGIN));
	

	r = fMinAddonViewRect.OffsetByCopy(H_MARGIN, r.top);
	fPanel = new BBox(r, "showview_box", B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	top_box->AddChild(fPanel);
	top_box->ResizeTo(Bounds().Width(), r.bottom + 1 + V_MARGIN);

	// ---- Bottom globals buttons section
	r = Bounds();
	r.top = top_box->Frame().bottom + 1;
	bottom_box = new BBox(r, NULL, B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	AddChild(bottom_box); 

	r.OffsetTo(0, 0);
	r.InsetBy(H_MARGIN, V_MARGIN);

	check = new BCheckBox(r, "dont_touch", DONT_TOUCH_LABEL,
					new BMessage(DONT_TOUCH_MSG),
					B_FOLLOW_TOP | B_FOLLOW_LEFT);
	check->GetPreferredSize(&w, &h);
	check->ResizeToPreferred();
	check->SetValue(B_CONTROL_ON);
	check->MoveTo(H_MARGIN, r.top);
	bottom_box->AddChild(check);
	
	size = w;

	button = new BButton(r, "apply_now", APPLY_NOW_LABEL,
					new BMessage(APPLY_NOW_MSG),
					B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	button->GetPreferredSize(&w, &h);
	button->ResizeToPreferred();
	x = r.right - w;
	button->MoveTo(x, r.top);
	bottom_box->AddChild(button);

	fApplyNowButton = button;
	
	size += SMALL_MARGIN + w;
	
	button = new BButton(r, "revert", REVERT_LABEL, new BMessage(REVERT_MSG), 
		B_FOLLOW_TOP | B_FOLLOW_RIGHT);
		
	button->GetPreferredSize(&w, &h);
	button->ResizeToPreferred();
	button->MoveTo(x - w - SMALL_MARGIN, r.top);
	bottom_box->AddChild(button);

	fRevertButton = button;
	fRevertButton->SetEnabled(false);

	size += SMALL_MARGIN + w;

	min_size = max_c(min_size, (H_MARGIN + size + H_MARGIN));
	
	r.bottom = r.top + h;
	r.InsetBy(-H_MARGIN, -V_MARGIN);
	
	bottom_box->ResizeTo(Bounds().Width(), r.Height());

	// Resize window to enclose top and bottom boxes
	ResizeTo(Bounds().Width(), bottom_box->Frame().bottom);
	
	// Enable boxes resizing modes
	top_box->SetResizingMode(B_FOLLOW_ALL);
	fPanel->SetResizingMode(B_FOLLOW_ALL);
	bottom_box->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);

	// Set default/minimal window size
	ResizeTo(min_size, Bounds().Height());
	SetSizeLimits(min_size, 20000, Bounds().Height(), 20000);	
	
	fAddonView = NULL;
}
예제 #15
0
bool 
JobSetupView::UpdateJobData()
{
	fJobData->SetShowPreview(fPreview->Value() == B_CONTROL_ON);
	fJobData->SetColor(Color());
	if (IsHalftoneConfigurationNeeded()) {
		fJobData->SetGamma(Gamma());
		fJobData->SetInkDensity(InkDensity());
		fJobData->SetDitherType(DitherType());
	}

	int first_page;
	int last_page;

	if (B_CONTROL_ON == fAll->Value()) {
		first_page = 1;
		last_page  = -1;
	} else {
		first_page = atoi(fFromPage->Text());
		last_page  = atoi(fToPage->Text());
	}

	fJobData->SetFirstPage(first_page);
	fJobData->SetLastPage(last_page);

	fJobData->SetPaperSource(PaperSource());

	fJobData->SetNup(GetID(gNups, sizeof(gNups) / sizeof(gNups[0]),
		fNup->FindMarked()->Label(), 1));

	if (fPrinterCap->Supports(PrinterCap::kPrintStyle)) {
		fJobData->SetPrintStyle((B_CONTROL_ON == fDuplex->Value())
			? JobData::kDuplex : JobData::kSimplex);
	}

	fJobData->SetCopies(atoi(fCopies->Text()));

	fJobData->SetCollate(B_CONTROL_ON == fCollate->Value());
	fJobData->SetReverse(B_CONTROL_ON == fReverse->Value());

	JobData::PageSelection pageSelection = JobData::kAllPages;
	if (fOddNumberedPages->Value() == B_CONTROL_ON)
		pageSelection = JobData::kOddNumberedPages;
	if (fEvenNumberedPages->Value() == B_CONTROL_ON)
		pageSelection = JobData::kEvenNumberedPages;
	fJobData->SetPageSelection(pageSelection);
	
	{
		std::map<PrinterCap::CapID, BPopUpMenu*>::iterator it =
			fDriverSpecificPopUpMenus.begin();
		for(; it != fDriverSpecificPopUpMenus.end(); it++) {
			PrinterCap::CapID category = it->first;
			BPopUpMenu* popUpMenu = it->second;
			const char* key = fPrinterCap->FindCap(
				PrinterCap::kDriverSpecificCapabilities, (int)category)->Key();
			const char* label = popUpMenu->FindMarked()->Label();
			const char* value = static_cast<const EnumCap*>(fPrinterCap->
				FindCap(category, label))->Key();
			fJobData->Settings().SetString(key, value);
		}
	}

	{
		std::map<string, BCheckBox*>::iterator it =
			fDriverSpecificCheckBoxes.begin();
		for(; it != fDriverSpecificCheckBoxes.end(); it++) {
			const char* key = it->first.c_str();
			BCheckBox* checkBox = it->second;
			bool value = checkBox->Value() == B_CONTROL_ON;
			fJobData->Settings().SetBoolean(key, value);
		}
	}

	{
		std::map<PrinterCap::CapID, IntRange>::iterator it =
			fDriverSpecificIntSliders.begin();
		for(; it != fDriverSpecificIntSliders.end(); it++) {
			IntRange& range = it->second;
			fJobData->Settings().SetInt(range.Key(), range.Value());
		}
	}

	{
		std::map<PrinterCap::CapID, DoubleRange>::iterator it =
			fDriverSpecificDoubleSliders.begin();
		for(; it != fDriverSpecificDoubleSliders.end(); it++) {
			DoubleRange& range = it->second;
			fJobData->Settings().SetDouble(range.Key(), range.Value());
		}
	}

	fJobData->Save();
	return true;
}
예제 #16
0
void PrefsWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case MSG_OK: {				// "Start" button clicked
			read_volumes_prefs();
			read_memory_prefs();
			read_graphics_prefs();
			SavePrefs();
			send_quit_on_close = false;
			PostMessage(B_QUIT_REQUESTED);
			be_app->PostMessage(ok_message);
			break;
		}

		case MSG_CANCEL:			// "Quit" button clicked
			send_quit_on_close = false;
			PostMessage(B_QUIT_REQUESTED);
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;

		case B_ABOUT_REQUESTED: {	// "About" menu item selected
			ShowAboutWindow();
			break;
		}

		case MSG_ZAP_PRAM:			// "Zap PRAM File" menu item selected
			ZapPRAM();
			break;

		case MSG_VOLUME_INVOKED: {	// Double-clicked on volume name, toggle read-only flag
			int selected = volume_list->CurrentSelection();
			if (selected >= 0) {
				const char *str = PrefsFindString("disk", selected);
				BStringItem *item = (BStringItem *)volume_list->RemoveItem(selected);
				delete item;
				char newstr[256];
				if (str[0] == '*')
					strcpy(newstr, str+1);
				else {
					strcpy(newstr, "*");
					strcat(newstr, str);
				}
				PrefsReplaceString("disk", newstr, selected);
				volume_list->AddItem(new BStringItem(newstr), selected);
				volume_list->Select(selected);
			}
			break;
		}

		case MSG_ADD_VOLUME:
			add_volume_panel->Show();
			break;

		case MSG_CREATE_VOLUME:
			create_volume_panel->Show();
			break;

		case MSG_ADD_VOLUME_PANEL: {
			entry_ref ref;
			if (msg->FindRef("refs", &ref) == B_NO_ERROR) {
				BEntry entry(&ref, true);
				BPath path;
				entry.GetPath(&path);
				if (entry.IsFile()) {
					PrefsAddString("disk", path.Path());
					volume_list->AddItem(new BStringItem(path.Path()));
				} else if (entry.IsDirectory()) {
					BVolume volume;
					if (path.Path()[0] == '/' && strchr(path.Path()+1, '/') == NULL && entry.GetVolume(&volume) == B_NO_ERROR) {
						int32 i = 0;
						dev_t d;
						fs_info info;
						while ((d = next_dev(&i)) >= 0) {
							fs_stat_dev(d, &info);
							if (volume.Device() == info.dev) {
								PrefsAddString("disk", info.device_name);
								volume_list->AddItem(new BStringItem(info.device_name));
							}
						}
					}
				}
			}
			break;
		}

		case MSG_CREATE_VOLUME_PANEL: {
			entry_ref dir;
			if (msg->FindRef("directory", &dir) == B_NO_ERROR) {
				BEntry entry(&dir, true);
				BPath path;
				entry.GetPath(&path);
				path.Append(msg->FindString("name"));

				create_volume_panel->Window()->Lock();
				BView *background = create_volume_panel->Window()->ChildAt(0);
				NumberControl *v = (NumberControl *)background->FindView("hardfile_size");
				int size = v->Value();

				char cmd[1024];
				sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", path.Path(), size);
				int ret = system(cmd);
				if (ret == 0) {
					PrefsAddString("disk", path.Path());
					volume_list->AddItem(new BStringItem(path.Path()));
				} else {
					sprintf(cmd, GetString(STR_CREATE_VOLUME_WARN), strerror(ret));
					WarningAlert(cmd);
				}
			}
			break;
		}

		case MSG_REMOVE_VOLUME: {
			int selected = volume_list->CurrentSelection();
			if (selected >= 0) {
				PrefsRemoveItem("disk", selected);
				BStringItem *item = (BStringItem *)volume_list->RemoveItem(selected);
				delete item;
				volume_list->Select(selected);
			}
			break;
		}

		case MSG_BOOT_ANY:
			PrefsReplaceInt32("bootdriver", 0);
			break;

		case MSG_BOOT_CDROM:
			PrefsReplaceInt32("bootdriver", CDROMRefNum);
			break;

		case MSG_NOCDROM:
			PrefsReplaceBool("nocdrom", nocdrom_checkbox->Value() == B_CONTROL_ON);
			break;

		case MSG_VIDEO_WINDOW:
			display_type = DISPLAY_WINDOW;
			hide_show_graphics_ctrls();
			break;

		case MSG_VIDEO_SCREEN:
			display_type = DISPLAY_SCREEN;
			hide_show_graphics_ctrls();
			break;

		case MSG_REF_5HZ:
			PrefsReplaceInt32("frameskip", 12);
			break;

		case MSG_REF_7_5HZ:
			PrefsReplaceInt32("frameskip", 8);
			break;

		case MSG_REF_10HZ:
			PrefsReplaceInt32("frameskip", 6);
			break;

		case MSG_REF_15HZ:
			PrefsReplaceInt32("frameskip", 4);
			break;

		case MSG_REF_30HZ:
			PrefsReplaceInt32("frameskip", 2);
			break;

		case MSG_NOSOUND:
			PrefsReplaceBool("nosound", nosound_checkbox->Value() == B_CONTROL_ON);
			break;

		case MSG_SER_A: {
			BMenuItem *source = NULL;
			msg->FindPointer("source", (void **)&source);
			if (source)
				PrefsReplaceString("seriala", source->Label());
			break;
		}

		case MSG_SER_B: {
			BMenuItem *source = NULL;
			msg->FindPointer("source", (void **)&source);
			if (source)
				PrefsReplaceString("serialb", source->Label());
			break;
		}

		case MSG_ETHER:
			if (ether_checkbox->Value() == B_CONTROL_ON)
				PrefsReplaceString("ether", "yes");
			else
				PrefsRemoveItem("ether");
			break;

		case MSG_UDPTUNNEL:
			PrefsReplaceBool("udptunnel", udptunnel_checkbox->Value() == B_CONTROL_ON);
			hide_show_serial_ctrls();
			break;

		case MSG_RAMSIZE:
			PrefsReplaceInt32("ramsize", ramsize_slider->Value() * 1024 * 1024);
			break;

		case MSG_MODELID_5:
			PrefsReplaceInt32("modelid", 5);
			break;

		case MSG_MODELID_14:
			PrefsReplaceInt32("modelid", 14);
			break;

		case MSG_CPU_68020:
			PrefsReplaceInt32("cpu", 2);
			PrefsReplaceBool("fpu", false);
			break;

		case MSG_CPU_68020_FPU:
			PrefsReplaceInt32("cpu", 2);
			PrefsReplaceBool("fpu", true);
			break;

		case MSG_CPU_68030:
			PrefsReplaceInt32("cpu", 3);
			PrefsReplaceBool("fpu", false);
			break;

		case MSG_CPU_68030_FPU:
			PrefsReplaceInt32("cpu", 3);
			PrefsReplaceBool("fpu", true);
			break;

		case MSG_CPU_68040:
			PrefsReplaceInt32("cpu", 4);
			PrefsReplaceBool("fpu", true);
			break;

		default: {
			// Screen mode messages
			if ((msg->what & 0xffff0000) == MSG_SCREEN_MODE) {
				int m = msg->what & 0xffff;
				uint32 mask = scr_mode[m].mode_mask;
				for (int i=0; i<32; i++)
					if (mask & (1 << i))
						scr_mode_bit = i;
			} else
				BWindow::MessageReceived(msg);
		}
	}
}
예제 #17
0
//------------------------------------------------------------------------------
void WindowEditor::InitFlagsBoxes()
{
	BRect work = Bounds();
	work.left = 10;
	work.top = 100;
	work.bottom -= 5;
	work.right -= 10;
	work.right -= 10;
	int i = 20;
	int inc = 10;
	BBox* box = new BBox(work, "flags");
	BCheckBox* cbox;
	BMessage* msg;
	box->SetLabel("Window Flags");
	uint32 flags = fWindowInfo.flags;
	bool longLabel;

	for (int index = 0; WindowFlags[index].name; ++index)
	{
		longLabel = strlen(WindowFlags[index].label) > 20;
		// First column of checkboxes
		msg = new BMessage(MSG_WINDOW_SET_FLAG);
		msg->AddInt32("flags", WindowFlags[index].flag);
		cbox = new BCheckBox(BRect(10, i, longLabel ? 210 : 125, i + inc),
							 WindowFlags[index].name, WindowFlags[index].label, msg);
		fFlagBoxes.push_back(cbox);
		box->AddChild(cbox);
		if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
		{
			cbox->SetValue(B_CONTROL_ON);
		}

		// We skip to the next row as needed to make room for long labels
		if (!longLabel && WindowFlags[index + 1].name)
		{
			++index;
			// Second column of checkboxes
			msg = new BMessage(MSG_WINDOW_SET_FLAG);
			msg->AddInt32("flags", WindowFlags[index].flag);
			cbox = new BCheckBox(BRect(130, i, 210, i + inc),
								 WindowFlags[index].name,
								 WindowFlags[index].label,
								 msg);
			fFlagBoxes.push_back(cbox);
			box->AddChild(cbox);
			if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
			{
				cbox->SetValue(B_CONTROL_ON);
			}
		}

		i += inc * 2;
	}
#if 0
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	msg->AddInt32("flags",B_NOT_MOVABLE);
	box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"nmov","Movable",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	msg->AddInt32("flags",B_NOT_CLOSABLE);
	box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"clos","Closable",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_NOT_ZOOMABLE);
	box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"zoom","Zoomable",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	msg->AddInt32("flags",B_NOT_MINIMIZABLE);
	box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"mini","Minimizable",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_NOT_H_RESIZABLE);
	box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"hres","Horizontally Resizable",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_NOT_V_RESIZABLE);
	box->AddChild(new BCheckBox(BRect(10,i,125,i+inc),"vres","Vertically Resizable",msg));
	menubox = new BCheckBox(BRect(130,i,210,i+inc),"menus","Menu Bar",new BMessage(MSG_WINDOW_ADD_MENU));
	box->AddChild(menubox);
	if (fWindowInfo.has_menu)
		menubox->SetValue(B_CONTROL_ON);
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_OUTLINE_RESIZE);
	box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"roiw","Resize with Outline Instead of Window",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_WILL_ACCEPT_FIRST_CLICK);
	box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"wafc","Will Accept First Click",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_AVOID_FRONT);
	box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"avfr","Avoid Front",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	msg->AddInt32("flags",B_AVOID_FOCUS);
	box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"avfo","Avoid Focus",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_NO_WORKSPACE_ACTIVATION);
	box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"nwoa","Do Not Activate Workspace",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_NOT_ANCHORED_ON_ACTIVATE);
	box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"brcu","Bring Window To Current Workspace",msg));
	msg = new BMessage(MSG_WINDOW_SET_FLAG);
	i+= inc*2;
	msg->AddInt32("flags",B_ASYNCHRONOUS_CONTROLS);
	box->AddChild(new BCheckBox(BRect(10,i,210,+inc),"async","Asynchronous Controls (Should Be On)",msg));
#endif
#if 0
	if (!(flags & B_NOT_MOVABLE))
		((BCheckBox *)(box->ChildAt(0)))->SetValue(B_CONTROL_ON);
	if (!(flags & B_NOT_CLOSABLE))
		((BCheckBox *)(box->ChildAt(1)))->SetValue(B_CONTROL_ON);
	if (!(flags & B_NOT_ZOOMABLE))
		((BCheckBox *)(box->ChildAt(2)))->SetValue(B_CONTROL_ON);
	if (!(flags & B_NOT_MINIMIZABLE))
		((BCheckBox *)(box->ChildAt(3)))->SetValue(B_CONTROL_ON);
	if (!(flags & B_NOT_H_RESIZABLE))
		((BCheckBox *)(box->ChildAt(4)))->SetValue(B_CONTROL_ON);
	if (!(flags & B_NOT_V_RESIZABLE))
		((BCheckBox *)(box->ChildAt(5)))->SetValue(B_CONTROL_ON);
	if (flags & B_OUTLINE_RESIZE)
		((BCheckBox *)(box->ChildAt(7)))->SetValue(B_CONTROL_ON);
	if (flags & B_WILL_ACCEPT_FIRST_CLICK)
		((BCheckBox *)(box->ChildAt(8)))->SetValue(B_CONTROL_ON);
	if (flags & B_AVOID_FRONT)
		((BCheckBox *)(box->ChildAt(9)))->SetValue(B_CONTROL_ON);
	if (flags & B_AVOID_FOCUS)
		((BCheckBox *)(box->ChildAt(10)))->SetValue(B_CONTROL_ON);
	if (flags & B_NO_WORKSPACE_ACTIVATION)
		((BCheckBox *)(box->ChildAt(11)))->SetValue(B_CONTROL_ON);
	if (flags & B_NOT_ANCHORED_ON_ACTIVATE)
		((BCheckBox *)(box->ChildAt(12)))->SetValue(B_CONTROL_ON);
	if (flags & B_ASYNCHRONOUS_CONTROLS)
		((BCheckBox *)(box->ChildAt(13)))->SetValue(B_CONTROL_ON);
#endif

	AddChild(box);

	cbox = (BCheckBox*)FindView("menus");
	if (cbox)
	{
		cbox->SetValue(fWindowInfo.has_menu);
		cbox->SetMessage(new BMessage(MSG_WINDOW_ADD_MENU));
	}
}
예제 #18
0
//----------------Real code----------------------
BMailProtocolConfigView::BMailProtocolConfigView(uint32 options_mask)
	:
	BView (BRect(0,0,100,20), "protocol_config_view", B_FOLLOW_LEFT
		| B_FOLLOW_TOP, B_WILL_DRAW),
	fBodyDownloadConfig(NULL)
{
	BRect rect(5,5,245,25);
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// determine font height
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	sItemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13;
	rect.bottom = rect.top - 2 + sItemHeight;

	if (options_mask & B_MAIL_PROTOCOL_HAS_HOSTNAME)
		AddChild(AddTextField(rect, "host", B_TRANSLATE("Mail server:")));

	if (options_mask & B_MAIL_PROTOCOL_HAS_USERNAME)
		AddChild(AddTextField(rect, "user", B_TRANSLATE("Username:"******"pass",
			B_TRANSLATE("Password:"******"flavor", B_TRANSLATE("Connection type:")));

	if (options_mask & B_MAIL_PROTOCOL_HAS_AUTH_METHODS)
		AddChild(AddMenuField(rect, "auth_method", B_TRANSLATE("Login type:")));

	// set divider
	float width = FindWidestLabel(this);
	for (int32 i = CountChildren();i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			text->SetDivider(width + 6);
	}

	if (options_mask & B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER) {
		AddChild(AddCheckBox(rect, "leave_mail_on_server",
			B_TRANSLATE("Leave mail on server"), new BMessage('lmos')));
		BCheckBox* box = AddCheckBox(rect, "delete_remote_when_local",
			B_TRANSLATE("Remove mail from server when deleted"));
		box->SetEnabled(false);
		AddChild(box);
	}

	if (options_mask & B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD) {
		fBodyDownloadConfig = new BodyDownloadConfig();
		fBodyDownloadConfig->MoveBy(0, rect.bottom + 5);
		AddChild(fBodyDownloadConfig);
	}

	// resize views
	float height;
	GetPreferredSize(&width,&height);
	ResizeTo(width,height);
	for (int32 i = CountChildren();i-- > 0;) {
		// this doesn't work with BTextControl, does anyone know why? -- axeld.
		if (BView *view = ChildAt(i))
			view->ResizeTo(width - 10,view->Bounds().Height());
	}
}
예제 #19
0
void YabWindow::MessageReceived(BMessage *message)
{
	// if(message) message->PrintToStream();
	switch(message->what)
	{
		case YABBUTTON:
			{
				BString tmpMessage("");
                        	BButton *myButtonPressed;
                        	message->FindPointer("source",(void **) &myButtonPressed);
				tmpMessage += myButtonPressed->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABSUBMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu()->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Supermenu()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABTEXTCONTROL:
			{
				BString tmpMessage("");
				BTextControl *myTextControl;
                        	message->FindPointer("source",(void **) &myTextControl);
				tmpMessage += myTextControl->Name();
				tmpMessage += ":";
				tmpMessage += myTextControl->Text();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABCHECKBOX:
			{
				BString tmpMessage("");
				BCheckBox *myCheckBox;
                        	message->FindPointer("source",(void **) &myCheckBox);
				tmpMessage += myCheckBox->Name();
				tmpMessage += ":";
				if(myCheckBox->Value()==B_CONTROL_ON)
					tmpMessage += "ON|";
				else
					tmpMessage += "OFF|";
				messageString += tmpMessage;
			}
			break;
		case YABRADIOBUTTON:
			{
				BString tmpMessage("");
				BRadioButton *myRadioButton;
                        	message->FindPointer("source",(void **) &myRadioButton);
				tmpMessage += myRadioButton->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABLISTBOXINVOKE:
			{
				BListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->CurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
					tmpMessage << i+1;
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABLISTBOXSELECT:
			{
				BListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->CurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
					tmpMessage << i+1;
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABDROPBOX:
			{
				BString tmpMessage("");
				BMenuItem *myMenuItem;
				message->FindPointer("source",(void **) &myMenuItem);
				tmpMessage += (myMenuItem->Menu())->Supermenu()->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenuItem->Label();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABSLIDER:
			{
				BString tmpMessage("");
                        	BSlider *mySlider;
                        	message->FindPointer("source",(void **) &mySlider);
				tmpMessage += mySlider->Name();
				tmpMessage += ":";
				tmpMessage << mySlider->Value();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABCOLORCONTROL:
			{
				rgb_color col;
				BString tmpMessage("");
                        	BColorControl *myCControl;
                        	message->FindPointer("source",(void **) &myCControl);
				tmpMessage += myCControl->Name();
				tmpMessage += ":";
				col = myCControl->ValueAsColor();
				tmpMessage << col.red << ":" << col.green << ":" << col.blue;
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABTREEBOXINVOKE:
			{
				BOutlineListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->FullListCurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					tmpMessage << i+1;
					/*
					int n = tmpMessage.Length();
					BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
					while(superitem)
					{
						BString t("");
						t << ((BStringItem*)superitem)->Text() << ":";
						tmpMessage.Insert(t,n);
						superitem = myList->Superitem(superitem);
					}
					tmpMessage += txt;*/
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABTREEBOXSELECT:
			{
				BOutlineListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->FullListCurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					tmpMessage << i+1;
					/*
					int n = tmpMessage.Length();
					BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
					while(superitem)
					{
						BString t("");
						t << ((BStringItem*)superitem)->Text() << ":";
						tmpMessage.Insert(t,n);
						superitem = myList->Superitem(superitem);
					}
					tmpMessage += txt;*/
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABFILEBOXSELECT:
			{
				BColumnListView *myList;
				message->FindPointer("source",(void **) &myList);
				BRow *myRow = NULL;
				if(myList) myRow = myList->CurrentSelection();
				if(myRow)
				{
				//	if(!myList->IsFocus()) myList->MakeFocus();
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					tmpMessage << myList->IndexOf(myRow)+1; 
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABFILEBOXINVOKE:
			{
				BColumnListView *myList;
				message->FindPointer("source",(void **) &myList);
				BRow *myRow = NULL;
				if(myList) myRow = myList->CurrentSelection();
				if(myRow)
				{
				//	if(!myList->IsFocus()) myList->MakeFocus();
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					tmpMessage << myList->IndexOf(myRow)+1; 
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABSHORTCUT:
			{
				const char* myMsg;
				if(message->FindString("shortcut", &myMsg) == B_OK)
				{
					messageString += myMsg;
					messageString += "|";
				}
			}
			break;
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
void
PartitionsPage::_FillPartitionsView(BView* view)
{
	// show | name | type | size | path

	int32 rowNumber = 0;

	BMessage message;
	for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
			i++, rowNumber++) {
		// get partition data
		bool show;
		BString name;
		BString type;
		BString path;
		int64 size;
		message.FindBool("show", &show);
		message.FindString("name", &name);
		message.FindString("type", &type);
		message.FindString("path", &path);
		message.FindInt64("size", &size);

		// check box
		BCheckBox* checkBox = new BCheckBox("show", "",
			_CreateControlMessage(kMessageShow, i));
		if (show)
			checkBox->SetValue(1);

		// name
		BTextControl* nameControl = new BTextControl("name", "",
			name.String(), _CreateControlMessage(kMessageName, i));
		nameControl->SetExplicitMinSize(BSize(StringWidth("WWWWWWWWWWWWWW"),
			B_SIZE_UNSET));

		// size
		BString sizeText;
		_CreateSizeText(size, &sizeText);
		sizeText << ", " << type.String();
		BStringView* typeView = new BStringView("type", sizeText.String());
		typeView->SetExplicitAlignment(
			BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));

		// path
		BStringView* pathView = new BStringView("path", path.String());
		pathView->SetExplicitAlignment(
			BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));

		if (rowNumber > 0) {
			BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout())
				.Add(new BSeparatorView(B_HORIZONTAL), 0, rowNumber, 4, 1)
				.SetRowWeight(rowNumber, 0);
			rowNumber++;
		}

		BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout())
			.Add(checkBox, 0, rowNumber, 1, 2)
			.Add(nameControl, 1, rowNumber, 1, 2)
			.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 2, rowNumber)
			.Add(typeView, 3, rowNumber)
			.Add(pathView, 3, rowNumber + 1)
			.SetRowWeight(rowNumber + 1, 1);
		rowNumber++;
	}
}
예제 #21
0
BView* PreferencesWindow::_CreateTorrentsPage(float spacing)
{
	BStringView* addingLabel 		= new BStringView("", B_TRANSLATE("Adding"));
	BStringView* downloadingLabel 	= new BStringView("", B_TRANSLATE("Downloading"));
	//BStringView* seedingLabel 	= new BStringView("", B_TRANSLATE("Seeding Limits"));
	
	addingLabel->SetFont(be_bold_font);
	downloadingLabel->SetFont(be_bold_font);
	
	//
	//
	//
	//fAutoAddTorrentsFrom = new BCheckBox("auto_add_torrents_from",
	//	B_TRANSLATE("Automatically add torrents from:"), 
	//	new BMessage(MSG_ADD_TORRENT_FROM_FOLDER_CHANGED));
	//fAutoAddTorrentsFrom->SetValue(B_CONTROL_OFF);
	//
	//
	//fAutoAddTorrentsFromFolder = new FolderSelect("auto_add_torrents_from_folder",
	//	NULL, "/test/path"/*new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)*/);
	//
	//fAutoAddTorrentsFromFolder->SetEnabled(false);


	BCheckBox* fShowOptionsDialog = new BCheckBox("Show options dialog",
		B_TRANSLATE("Show options dialog"),
		NULL /*new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)*/);
	fShowOptionsDialog->SetValue(B_CONTROL_OFF);
	
	BCheckBox* fStartWhenAdded = new BCheckBox("start_when_added",
		B_TRANSLATE("Start when added"),
		new BMessage(MSG_START_WHEN_ADDED_BEHAVIOR_CHANGED));
	fStartWhenAdded->SetValue(fTorrentPreferences->StartWhenAddedEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	fIncompleteFileNaming = new BCheckBox("incomplete_file_naming",
		B_TRANSLATE("Append \".part\" to incomplete files' names"), 
		new BMessage(MSG_INCOMPLETE_FILENAMING_BEHAVIOR_CHANGED));
	fIncompleteFileNaming->SetValue(fTorrentPreferences->IncompleteFileNamingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	BStringView* fTorrentSaveLocation = new BStringView("", B_TRANSLATE("Save to Location:"));
	fTorrentSaveLocationPath = new FolderSelect("download_folder_select", 
		fTorrentPreferences->DownloadFolder(), new BMessage(MSG_DOWNLOAD_FOLDER_BEHAVIOR_CHANGED));
		
	fIncompleteDirEnabled = new BCheckBox("incomplete_torrent_folder",
		B_TRANSLATE("Incomplete torrents folder"),
		new BMessage(MSG_INCOMPLETE_FOLDER_BEHAVIOR_CHANGED));
	fIncompleteDirEnabled->SetValue(fTorrentPreferences->IncompleteFolderEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	fIncompleteDirPath = new FolderSelect("incomplete_torrent_folder_path", 
		fTorrentPreferences->IncompleteFolder(), new BMessage(MSG_INCOMPLETE_FOLDER_PATH_BEHAVIOR_CHANGED));
	fIncompleteDirPath->SetEnabled(fTorrentPreferences->IncompleteFolderEnabled());
	
	//
	//
	//
	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(addingLabel)
		//.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
		//	.Add(fAutoAddTorrentsFrom, 0, 0)
		//	.Add(fAutoAddTorrentsFromFolder, 1, 0)
		//)
		.Add(BGridLayoutBuilder(spacing, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fShowOptionsDialog, 0, 0)
			.Add(fStartWhenAdded, 0, 1)
		)
		.Add(downloadingLabel)
		.Add(BGridLayoutBuilder(spacing, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fIncompleteFileNaming, 0, 0, 2, 1)
			.Add(fTorrentSaveLocation, 0, 1)
			.Add(fTorrentSaveLocationPath, 1, 1)
			.Add(fIncompleteDirEnabled, 0, 2)
			.Add(fIncompleteDirPath, 1, 2)
		)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))
		.SetInsets(spacing, spacing, spacing, spacing)
		.TopView()
	;
	view->SetName("Torrents");
	return view;

}
예제 #22
0
BControl *
DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
{
	BRect rect;
	if (hintRect)
		rect = *hintRect;
	else
		rect.Set(0, 0, 50, 100);

	switch (parameter->Type()) {
		case BParameter::B_NULL_PARAMETER:
			// there is no default view for a null parameter
			return NULL;

		case BParameter::B_DISCRETE_PARAMETER:
		{
			BDiscreteParameter &discrete = static_cast<BDiscreteParameter &>(*parameter);

			if (!strcmp(discrete.Kind(), B_ENABLE)
				|| !strcmp(discrete.Kind(), B_MUTE)
				|| discrete.CountItems() == 0) {
				// create a checkbox item

				BCheckBox *checkBox = new BCheckBox(rect, discrete.Name(),
					discrete.Name(), NULL);
				checkBox->ResizeToPreferred();

				return checkBox;
			} else {
				// create a pop up menu field

				// ToDo: replace BOptionPopUp (or fix it in Antares...)
				// this is a workaround for a bug in BOptionPopUp - you need to
				// know the actual width before creating the object - very nice...

				BFont font;
				float width = 0;
				for (int32 i = 0; i < discrete.CountItems(); i++) {
					float labelWidth = font.StringWidth(discrete.ItemNameAt(i));
					if (labelWidth > width)
						width = labelWidth;
				}
				width += font.StringWidth(discrete.Name()) + 55;
				rect.right = rect.left + width;

				BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(),
					discrete.Name(), NULL);

				for (int32 i = 0; i < discrete.CountItems(); i++) {
					popUp->AddOption(discrete.ItemNameAt(i), discrete.ItemValueAt(i));
				}

				popUp->ResizeToPreferred();

				return popUp;
			}
		}

		case BParameter::B_CONTINUOUS_PARAMETER:
		{
			BContinuousParameter &continuous = static_cast<BContinuousParameter &>(*parameter);

			if (!strcmp(continuous.Kind(), B_MASTER_GAIN)
				|| !strcmp(continuous.Kind(), B_GAIN)) {
				BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(),
					continuous.Name(), NULL, B_VERTICAL, continuous.CountChannels());

				char minLabel[64], maxLabel[64];

				const char *unit = continuous.Unit();
				if (unit[0]) {
					// if we have a unit, print it next to the limit values
					sprintf(minLabel, "%g %s", continuous.MinValue(), continuous.Unit());
					sprintf(maxLabel, "%g %s", continuous.MaxValue(), continuous.Unit());
				} else {
					sprintf(minLabel, "%g", continuous.MinValue());
					sprintf(maxLabel, "%g", continuous.MaxValue());
				}
				slider->SetLimitLabels(minLabel, maxLabel);

				float width, height;
				slider->GetPreferredSize(&width, &height);
				slider->ResizeTo(width, 190);

				// ToDo: take BContinuousParameter::GetResponse() & ValueStep() into account!

				for (int32 i = 0; i < continuous.CountChannels(); i++) {
					slider->SetLimitsFor(i, int32(continuous.MinValue() * 1000),
						int32(continuous.MaxValue() * 1000));
				}

				return slider;
			}

			BSlider *slider = new BSlider(rect, parameter->Name(), parameter->Name(),
				NULL, 0, 100);

			float width, height;
			slider->GetPreferredSize(&width, &height);
			slider->ResizeTo(100, height);

			return slider;
		}

		default:
			ERROR("BMediaTheme: Don't know parameter type: 0x%x\n",
				parameter->Type());
	}
	return NULL;
}
예제 #23
0
파일: PBox.cpp 프로젝트: Haikeek/BePodder
void
PBox::GetData(BMessage* data){
			
			
			
			BView * panel = fPrefView;
			BMessage cur;
			
			for (int i = 0; fTemplate.FindMessage("setting", i, &cur) == B_OK; i++) {
				const char *name = cur.FindString("name");
				int32 type = -1;
				
				cur.FindInt32("type", &type);
				
				if ( dynamic_cast<BTextControl*>(panel->FindView(name))) { 
//					Free text
					BTextControl * ctrl = (BTextControl*)panel->FindView(name);
				
					switch (type) {
						case B_STRING_TYPE: {
							data->AddString(name, ctrl->Text() );
						} break;
						case B_INT32_TYPE: {
							data->AddInt32(name, atoi(ctrl->Text()) );
						} break;
						default: {
							return;
						};
					};
				} else if (dynamic_cast<BMenuField*>(panel->FindView(name))) {
//					Provided option
					BMenuField * ctrl = (BMenuField*)panel->FindView(name);
					BMenuItem * item = ctrl->Menu()->FindMarked();
					
									
					if (!item) return;
					
					switch (type) {
						case B_STRING_TYPE: {
							data->AddString(name, item->Label() );
							BString index(name);
							index << "_index";
							data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index 
						} break;
						case  B_INT32_TYPE: {
							data->AddInt32(name, atoi(item->Label()) );
							BString index(name);
							index << "_index";
							data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index
						} break;
						default: {
							return;
						};
					}
				} else
				if (dynamic_cast<BCheckBox*>(panel->FindView(name))) {
// 					Boolean setting
					BCheckBox * box = (BCheckBox*)panel->FindView(name);
					
					if ( box->Value() == B_CONTROL_ON ) {
						data->AddBool(name,true);
					} else {
						data->AddBool(name,false);
					}
				} else if (dynamic_cast<BTextView *>(panel->FindView(name))) {
					BTextView *view = (BTextView *)panel->FindView(name);
					data->AddString(name, view->Text());
				};
				
				
			};

		
}
/*!	\function		CalendarModulePreferences::CreateWeekendSelectionBox
 *	\brief			Create box for selection of the weekend days
 *	\note			Additionally, select the color for weekends and weekdays
 *	\param[in]	frame	Enclosing rectangle.
 *	\param[in]	label	Reference to label of the enclosing BBox.
 *	\param[in]	calModule	The calendar module for which the preferences are set.
 */
void	CalendarModulePreferences::CreateWeekendSelectionBox( BRect frame,
															  BString &label,
															  CalendarModule* calModule )
{
	/*!	\par	Notes on implementation:
	 *			It's not all that straightforward - to create this selection box.
	 *			The problem is that number of days in week is dependent on the
	 *			Calendar Module, therefore the frame rectangle must be divided
	 *			properly. We should take into account the possibility that there's
	 *			not enough place for all days in the submitted frame.
	 *
	 *	\par	
	 *			The solution will be as follows:
	 *			Let number of days in week be N. I create two columns and 
	 *			several rows (the number depends on N). Days in week will be
	 *			proceeded in the order <em>as Calendar Module supplies them</em>.
	 *			The days occupy both columns, and are located in rows
	 *			[0, (ceiling of (N/2)) ). Days returned from CalendarModule are
	 *			placed as follows: days from 0 to (ceiling of (N/2)-1) in the left
	 *			column, days from (ceiling of (N/2)-1) to (N-1) in right column.
	 *
	 *	\par	
	 *			Two controls for setting the colors of weekdays and weekends
	 *			are located at the bottom row of the grid; weekdays on right,
	 *			weekends on left.
	 *
	 *	\par	
	 *			There will be an empty cell in the right column, if number
	 *			of days in week is odd.
	 */
	BMessage* 	toSend = NULL;
	BCheckBox* 	dayCheckBox = NULL;
	BString		tempString;
	
	/* indexX is 0 for left column or 1 for right column.
	 * indexY is 0 for topmost row, 1 for second from top row, etc.
	 * Max value for indexY = (ceiling of (N/2)).
	 */
	int indexX, indexY;
	 
	// Prepare the item to be returned
	BBox*	enclosingBox = new BBox( frame, "Weekend selector" );
	if ( !enclosingBox )
	{
		/* Panic! */
		exit(1);
	}

	// Prepare the layout to be used
	BGridLayout* layout = new BGridLayout();
	if ( !layout)
	{
		/* Panic! */
		exit(1);
	}	
	enclosingBox->SetLayout( layout );
	
	// Get the data on days of week
	unsigned int daysInWeek = (unsigned int)( calModule->GetDaysInWeek() );
	map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();
	
	indexX = indexY = 0;
	for (unsigned char day = 0; day < daysInWeek; ++day )
	{
		/* Creating the message to be sent */
		toSend = new BMessage( kCalendarModuleWeekendDaySelected );
		if ( !toSend )
		{
			/* Panic! */
			exit(1);
		}
		toSend->AddInt32( "Weekday no", day );

		/* Obtain the name of the day. I use the long name. */
		tempString = (DoubleNames)weekdayNames[ day ].longName;
		
		/* Creating the checkbox */
		dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
									 "Weekday",
									 tempString.String(),
									 toSend );
		if (!dayCheckBox)
		{
			// Panic!
			exit(1);
		}
		
		dayCheckBox->ResizeToPreferred();
		
		/* Adding the item to the BBox */
		layout->AddView( dayCheckBox, indexX, indexY );
		
		/* Advancing to the next cell in grid */
		// If arrived to the last item in the first column, advancing to second
		if ( day == ( int )( ( daysInWeek + 1 ) / 2 ) )
		{
			indexX = 1;	
			indexY = 0;
		}
		else 	// Staying in the same column, but advancing down
		{
			++indexY;	
		}
		
	}	// <-- end of "for (all days in week)"

	BListView* weekdayColorSelector = NULL;	
	
	
	
	
}
예제 #25
0
void SeqPrefWin::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case OK_MSG:
			if (mOwqTable) mOwqTable->ReplacePreferences( mPreferences );
			seq_app->SetPreferences(&mPreferences);
			if (mUndoLevelCtrl) AmGlobals().SetUndoHistory(mUndoLevelCtrl->Value() );
			if (mRefreshWindows != 0) RefreshWindows();
			PostMessage(B_QUIT_REQUESTED);
			break;
		case CANCEL_MSG:
			PostMessage(B_QUIT_REQUESTED);
			break;
		case CHANGE_SKIN_MSG:
			{
				const char*		skin;
				if (msg->FindString("seq:skin", &skin) == B_OK) { 
					SetStringPref(CURRENT_SKIN_PREF, skin);
					new_skin_warning();
				}
			}
			break;
		case CHANGE_SKIN_TO_DEFAULT_MSG:
			{
				if( mPreferences.HasString(CURRENT_SKIN_PREF) ) mPreferences.RemoveData(CURRENT_SKIN_PREF);
				new_skin_warning();
			}
			break;
		case REMEMBER_OPEN_MSG:
			{
				BCheckBox*	cb = dynamic_cast<BCheckBox*>( FindView(REMEMBER_OPEN_STR) );
				if( cb ) SetBoolPref( REMEBER_OPEN_SONGS_PREF, cb->Value() );
			}
			break;
		case OPEN_BLANK_MSG:
			SetStringPref( OPEN_NEW_SONG_PREF, "blank" );
			break;
		case OPEN_FOUR_MSG:
			SetStringPref( OPEN_NEW_SONG_PREF, "channels" );
			SetInt32Pref( OPEN_NEW_SONG_CHANNEL_PREF, 2 );
			break;
		case OPEN_FILE_MSG:
			SetStringPref( OPEN_NEW_SONG_PREF, "file" );
			/* Open a file panel to select a new file.
			 */
			if (!mFilePanel ) mFilePanel = new BFilePanel(B_OPEN_PANEL, 0, 0, 0,
																false);
			if (mFilePanel->IsShowing() ) break;
			if (mFilePanel->Window() ) {
				mFilePanel->Window()->SetTitle("Select File" B_UTF8_ELLIPSIS);
			}
					
			mFilePanel->SetTarget(BMessenger(this));
			mFilePanel->SetMessage( new BMessage('nfen') );
			mFilePanel->Show();

			break;
		case 'nfen':
			{
				entry_ref	ref;
				if( msg->FindRef( "refs", &ref ) == B_OK ) {
					SetOpenNewFromFileRef( &ref );
				}
			}
			break;
		case CHANGE_UNDO_HISTORY_MSG:
			if (mUndoLevelCtrl) SetInt32Pref(UNDO_HISTORY_PREF, mUndoLevelCtrl->Value() );
			break;
		case TRACK_WIN_FOLLOW_MSG:
			if (mTrackWinFollowCtrl) SetBoolPref(TRACK_WIN_FOLLOW_PREF, mTrackWinFollowCtrl->Value() == B_CONTROL_ON);
			break;
		case TRACK_WIN_PLAY_TO_END_MSG:
			if (mTrackWinPlayToEndCtrl) SetBoolPref(TRACK_WIN_PLAY_TO_END_PREF, mTrackWinPlayToEndCtrl->Value() == B_CONTROL_ON);
			break;
		case TRACK_HEIGHT_MSG:
			if (mTrackHeightCtrl) SetInt32Pref(TRACK_HEIGHT_PREF, mTrackHeightCtrl->Value() );
			break;
		case LABEL_HEIGHT_MSG:
			if (mLabelHeightCtrl) {
				SetInt32Pref(PHRASE_LABEL_HEIGHT_PREF, mLabelHeightCtrl->Value() );
				mRefreshWindows |= SEQ_REFRESH_PHRASES;
			}
			break;
		case VIEW_ROW_SELECTED_MSG:
			FactoryRowSelected();
			break;
		default:
			inherited::MessageReceived(msg);
			break;
	}
}
void MessageView::ValueChanged(void)
{
	char		*name; 
	uint32		type; 
	int32		count;
	#ifdef B_ZETA_VERSION_1_0_0
	for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(const char **) &name, &type, &count) == B_OK; i++)
	#else
	for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(char **) &name, &type, &count) == B_OK; i++)
	#endif
	{
		//calculate the Position where to add the next View
		float top = ItemTop();
		BRect rect = BRect(MARGIN_SPACE,top,Bounds().right-MARGIN_SPACE,top);
		switch(type)
		{
			case B_STRING_TYPE:
			{
				char		*string;
				configMessage->FindString(name,count-1,(const char **)&string);
				BTextControl	*stringItem	= new BTextControl(rect,name,name,string,NULL);
				AddChild(stringItem);
				BMessage	*tmpMessage = new BMessage(B_CONTROL_INVOKED);
				tmpMessage->AddString("name",name);
				tmpMessage->AddInt32("count",count-1);
				tmpMessage->AddInt32("type",type);
				stringItem->SetMessage(tmpMessage);
				break;
			}
			case B_RECT_TYPE:
			{
				BRect	valueRect;
				configMessage->FindRect(name,count-1,&valueRect);
				RectItem	*rectItem	= new RectItem(rect,name,valueRect);
				AddChild(rectItem);
				BMessage	*tmpMessage = new BMessage(B_CONTROL_INVOKED);
				tmpMessage->AddString("name",name);
				tmpMessage->AddInt32("count",count-1);
				tmpMessage->AddInt32("type",type);
				rectItem->SetMessage(tmpMessage);
				break;
			}
			case B_FLOAT_TYPE:
			{
				float	value;
				configMessage->FindFloat(name,count-1,&value);
				BString	floatString;
				floatString<<value;
				BTextControl	*stringItem	= new BTextControl(rect,name,name,floatString.String(),NULL);
				AddChild(stringItem);
				BMessage	*tmpMessage = new BMessage(B_CONTROL_INVOKED);
				tmpMessage->AddString("name",name);
				tmpMessage->AddInt32("count",count-1);
				tmpMessage->AddInt32("type",type);
				stringItem->SetMessage(tmpMessage);
				break;
			}
			case B_INT8_TYPE:
			case B_INT16_TYPE:
			case B_INT32_TYPE:
			{
				int32	value;
				configMessage->FindInt32(name,count-1,&value);
				BString	intString;
				intString<<value;
				BTextControl	*stringItem	= new BTextControl(rect,name,name,intString.String(),NULL);
				AddChild(stringItem);
				BMessage	*tmpMessage = new BMessage(B_CONTROL_INVOKED);
				tmpMessage->AddString("name",name);
				tmpMessage->AddInt32("count",count-1);
				tmpMessage->AddInt32("type",type);
				stringItem->SetMessage(tmpMessage);
				break;
			}
			case B_BOOL_TYPE:
			{
				bool	value;
				configMessage->FindBool(name,count-1,&value);
				BCheckBox	*boolItem	= new BCheckBox(rect,name,name,NULL);
				AddChild(boolItem);
				boolItem->SetValue(value);
				BMessage	*tmpMessage = new BMessage(B_CONTROL_INVOKED);
				tmpMessage->AddString("name",name);
				tmpMessage->AddInt32("count",count-1);
				tmpMessage->AddInt32("type",type);
				boolItem->SetMessage(tmpMessage);
				break;
			}
		}

	} 
}
예제 #27
0
	void SetControlEnable(bool enable)
	{
		if( mNameCtrl ) mNameCtrl->SetEnabled( enable );
		if( mFileButton ) mFileButton->SetEnabled( enable );
		if( mSkipBox ) mSkipBox->SetEnabled( enable );
	}
예제 #28
0
void AGMSBayesianSpamFilterConfig::AttachedToWindow ()
{
	char		 numberString [30];
	BRect		 tempRect;
	char		*tempStringPntr;

	SetViewColor (ui_color (B_PANEL_BACKGROUND_COLOR));

	// Make the checkbox for choosing whether the spam is marked by a
	// modification to the subject of the mail message.

	tempRect = Bounds ();
	fAddSpamToSubjectCheckBoxPntr = new BCheckBox (
		tempRect,
		"AddToSubject",
		"Add spam rating to start of subject",
		new BMessage (kAddSpamToSubjectPressed));
	AddChild (fAddSpamToSubjectCheckBoxPntr);
	fAddSpamToSubjectCheckBoxPntr->ResizeToPreferred ();
	fAddSpamToSubjectCheckBoxPntr->SetValue (fAddSpamToSubject);
	fAddSpamToSubjectCheckBoxPntr->SetTarget (this);

	tempRect = Bounds ();
	tempRect.top = fAddSpamToSubjectCheckBoxPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;

	// Add the checkbox on the right for the no words means spam option.

	fNoWordsMeansSpamCheckBoxPntr = new BCheckBox (
		tempRect,
		"NoWordsMeansSpam",
		"or empty e-mail",
		new BMessage (kNoWordsMeansSpam));
	AddChild (fNoWordsMeansSpamCheckBoxPntr);
	fNoWordsMeansSpamCheckBoxPntr->ResizeToPreferred ();
	fNoWordsMeansSpamCheckBoxPntr->MoveBy (
		floorf (tempRect.right - fNoWordsMeansSpamCheckBoxPntr->Frame().right),
		0.0);
	fNoWordsMeansSpamCheckBoxPntr->SetValue (fNoWordsMeansSpam);
	fNoWordsMeansSpamCheckBoxPntr->SetTarget (this);

	// Add the box displaying the spam cutoff ratio to the left, in the space
	// remaining between the left edge and the no words checkbox.

	tempRect.right = fNoWordsMeansSpamCheckBoxPntr->Frame().left -
		be_plain_font->StringWidth ("a");
	tempStringPntr = "Spam above:";
	sprintf (numberString, "%06.4f", (double) fSpamCutoffRatio);
	fSpamCutoffRatioTextBoxPntr	= new BTextControl (
		tempRect,
		"spamcutoffratio",
		tempStringPntr,
		numberString,
		NULL /* BMessage */);
	AddChild (fSpamCutoffRatioTextBoxPntr);
	fSpamCutoffRatioTextBoxPntr->SetDivider (
		be_plain_font->StringWidth (tempStringPntr) +
		1 * be_plain_font->StringWidth ("a"));

	tempRect = Bounds ();
	tempRect.top = fSpamCutoffRatioTextBoxPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;

	// Add the box displaying the genuine cutoff ratio, on a line by itself.

	tempStringPntr = "Genuine below and uncertain above:";
	sprintf (numberString, "%08.6f", (double) fGenuineCutoffRatio);
	fGenuineCutoffRatioTextBoxPntr = new BTextControl (
		tempRect,
		"genuinecutoffratio",
		tempStringPntr,
		numberString,
		NULL /* BMessage */);
	AddChild (fGenuineCutoffRatioTextBoxPntr);
	fGenuineCutoffRatioTextBoxPntr->SetDivider (
		be_plain_font->StringWidth (tempStringPntr) +
		1 * be_plain_font->StringWidth ("a"));

	tempRect = Bounds ();
	tempRect.top = fGenuineCutoffRatioTextBoxPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;

    // Checkbox for automatically training on incoming mail.

	fAutoTrainingCheckBoxPntr = new BCheckBox (
		tempRect,
		"autoTraining",
		"Learn from all incoming e-mail",
		new BMessage (kAutoTrainingPressed));
	AddChild (fAutoTrainingCheckBoxPntr);
	fAutoTrainingCheckBoxPntr->ResizeToPreferred ();
	fAutoTrainingCheckBoxPntr->SetValue (fAutoTraining);
	fAutoTrainingCheckBoxPntr->SetTarget (this);

	tempRect = Bounds ();
	tempRect.top = fAutoTrainingCheckBoxPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;

	// Button for editing the server settings.

/*	fServerSettingsButtonPntr = new BButton (
		tempRect,
		"serverSettings",
		"Advanced Server Settings…",
		new BMessage (kServerSettingsPressed));
	AddChild (fServerSettingsButtonPntr);
	fServerSettingsButtonPntr->ResizeToPreferred ();
	fServerSettingsButtonPntr->SetTarget (this);

	tempRect = Bounds ();
	tempRect.top = fServerSettingsButtonPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;


    // Checkbox for closing the server when done.

	fQuitServerWhenFinishedCheckBoxPntr = new BCheckBox (
		tempRect,
		"quitWhenFinished",
		"Close spam scanner when finished.",
		new BMessage (kQuitWhenFinishedPressed));
	AddChild (fQuitServerWhenFinishedCheckBoxPntr);
	fQuitServerWhenFinishedCheckBoxPntr->ResizeToPreferred ();
	fQuitServerWhenFinishedCheckBoxPntr->SetValue (fQuitServerWhenFinished);
	fQuitServerWhenFinishedCheckBoxPntr->SetTarget (this);

	tempRect = Bounds ();
	tempRect.top = fQuitServerWhenFinishedCheckBoxPntr->Frame().bottom + 1;
	tempRect.bottom = tempRect.top + 20;
*/
}
예제 #29
0
bool BContainer::SaveConfigurationToAttributeList(char* algorithmName,GML::Utils::AttributeList*	attrList)
{
	BItem* element;
	char* objectName;
	GML::Utils::GString gStrTemp;
	CString temp,tempStr;
	CString complexValue;
	CString tempValue;
	CString connectorStr;
	bool	foundComplex;
	void* objectValue;
	unsigned char objectType;
	bool someBoolValue;
	GML::Utils::Attribute*	attr;
	unsigned int someUIntValue;
	int someIntValue;
	double someDoubleValue;
	BEdit* editValue;
	BCombo* comboValue;
	BCheckBox* boolItem;
	BFile* fileItem;
	int i;


	

	for(i=0;i<vElements.GetSize();i++)
	{
		
		element = (BItem*)vElements.GetPointer(i);
		if(element == NULL)
			return false;
		
		objectName = element->label;
		foundComplex = false;

		if(strcmp(objectName,"DataBases") == 0)
		{
			
			if(!GetComplexElement(&i,&temp))
				return false;
			if(!attrList->AddAttribute("DataBase",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
		if(strcmp(objectName,"Notifiers") == 0)
		{
			
			if(!GetComplexElement(&i,&temp))
				return false;
			if(!attrList->AddAttribute("Notifier",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
		if(strcmp(objectName,"Connectors")==0)
		{
			
			if(!GetConnectorsSaveString(&i,&temp))
				return false;
			if(!attrList->AddAttribute("Connector",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
			
		switch(element->elementType)
		{
		case TYPE_HEADER:
			continue;
		case GML::Utils::AttributeList::STRING:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case TYPE_COMBO:
			
			comboValue = (BCombo*)element;
			comboValue->GetSelectedItem(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case TYPE_FILE:
			
			fileItem = (BFile*) element;
			fileItem->GetText(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case GML::Utils::AttributeList::BOOLEAN:
			
			boolItem = (BCheckBox*)element;
			someBoolValue = boolItem->IsChecked();
			objectValue = &someBoolValue;
			objectType = element->elementType;
			break;

		case GML::Utils::AttributeList::UINT32:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToUInt32(&someUIntValue))
				return false;
			objectValue = &someUIntValue;
			objectType = element->elementType;
		case GML::Utils::AttributeList::INT32:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToInt32(&someIntValue))
				return false;
			objectValue = &someIntValue;
			objectType = element->elementType;
			break;
			
	
		case GML::Utils::AttributeList::DOUBLE:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToDouble(&someDoubleValue))
				return false;
			objectValue = &someDoubleValue;
			objectType = element->elementType;
			break;	
		default:
			continue;
			

		}
		
		if(!attrList->AddAttribute(objectName,objectValue,objectType,1,NULL))
		{
			
			return false;
		}
		
				
	}

	attr = attrList->Get("AlgorithmName");
	if(attr== NULL)
	{
		if(!attrList->AddAttribute("AlgorithmName",algorithmName,GML::Utils::AttributeList::STRING,1,NULL))
		{
			return false;
		}
	}
	return true;
}
예제 #30
0
void PrefsWindow::MessageReceived(BMessage* message)
{
	switch(message->what)
	{
		case PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_COLOUR_PREFS);
		}
		break;		
		case PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_COMMAND_PREFS);
		}		
		break;
		case PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_TOOLBAR_PREFS);	
		}
		break;
		case PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_GENERAL_PREFS);
		}
		break;
		case PrefsConstants::K_PREFS_UPDATE:
		{			
			//update the preferences message, from view values
			BString prefsID;			
			if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
			{
				BView *changedView = m_parent->FindView(prefsID.String());
				prefsLock.Lock();
				//different view have different kinds of values
				if (is_instance_of(changedView, BTextControl))
				{
					//a textcontrol value was changed, update preferences with new text
					BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
					preferences.ReplaceString(prefsID.String(), textControl->Text());
				}
				else if (is_instance_of(changedView, BCheckBox))
				{
					//a checkbox value was changed, update preferences with new bool value(on/off)
					BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
					preferences.ReplaceBool(prefsID.String(), checkBox->Value());
				}
				else if (is_instance_of(changedView, BSlider))
				{
					//a slider value was changed, update preferences with new slider value
					BSlider *slider = dynamic_cast<BSlider*>(changedView);
					preferences.ReplaceInt32(prefsID.String(), slider->Value());
				}
				else if (is_instance_of(changedView, ColourButton))
				{
					//a colourcontrol value was changed, update preferences with new colour
					ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
					preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color));
				}
				prefsLock.Unlock();
			}
		}
		break;
		case PrefsConstants::K_LOAD_PREFERENCES:
		{
			//set preferences view values to values of the preferences message
			BString prefsID;
			if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
			{
				//find out which view value has to be updated
				BView *changedView = m_parent->FindView(prefsID.String());
				prefsLock.Lock();
				char *name;
				uint32 type;
				int32 count;
				for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++)
				{
					//find out what kind of field we are using
					switch (type)
					{
						case B_INT32_TYPE:
						{
							int32 value;
							preferences.FindInt32(name, &value);
							if (is_instance_of(changedView, BSlider))
							{
								BSlider *slider = dynamic_cast<BSlider*>(changedView);
								slider->SetValue(value);
							}
						}
						break;
						case B_BOOL_TYPE:
						{
							bool value;
							preferences.FindBool(name, &value);
							if (is_instance_of(changedView, BCheckBox))
							{
								BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
								checkBox->SetValue(value);
							}
						}
						break;
						case B_RGB_COLOR_TYPE:
						{
							rgb_color *colour;
							ssize_t size;
							preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size);
							if (is_instance_of(changedView, ColourButton))
							{
								ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
								colourControl->SetValue(*colour);
							}
						}
						break;
						case B_STRING_TYPE:
						{
							BString string;
							preferences.FindString(name, &string);
							if (is_instance_of(changedView, ColourButton))
							{
								BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
								textControl->SetText(string.String());
							}
						}
						break;
					}
				} 				
				prefsLock.Unlock();
				//make sure the new view values are drawn!
				changedView->Invalidate();
			}
		}
		break;
		default:
			BWindow::MessageReceived(message);
		break;
	}
}