Ejemplo n.º 1
0
void
AGMSBayesianSpamFilterConfig::MessageReceived (BMessage *msg)
{
	switch (msg->what)
	{
		case kAddSpamToSubjectPressed:
			fAddSpamToSubject = fAddSpamToSubjectCheckBoxPntr->Value ();
			break;
		case kAutoTrainingPressed:
			fAutoTraining = fAutoTrainingCheckBoxPntr->Value ();
			break;
		case kNoWordsMeansSpam:
			fNoWordsMeansSpam = fNoWordsMeansSpamCheckBoxPntr->Value ();
			break;
		case kQuitWhenFinishedPressed:
			fQuitServerWhenFinished =
				fQuitServerWhenFinishedCheckBoxPntr->Value ();
			break;
		case kServerSettingsPressed:
			ShowSpamServerConfigurationWindow ();
			break;
		default:
			BView::MessageReceived (msg);
	}
}
Ejemplo n.º 2
0
void
FadeView::UpdateStatus()
{
	Window()->DisableUpdates();

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

	Window()->EnableUpdates();

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

	// TODO - Tell the password window to update its stuff
}
void
AutomountSettingsPanel::_SendSettings(bool rescan)
{
	BMessage message(kSetAutomounterParams);

	message.AddBool("autoMountAll", (bool)fAutoMountAllCheck->Value());
	message.AddBool("autoMountAllBFS", (bool)fAutoMountAllBFSCheck->Value());
	if (fAutoMountAllBFSCheck->Value())
		message.AddBool("autoMountAllHFS", false);

	message.AddBool("suspended", (bool)fScanningDisabledCheck->Value());
	message.AddBool("rescanNow", rescan);

	message.AddBool("initialMountAll", (bool)fInitialMountAllCheck->Value());
	message.AddBool("initialMountAllBFS",
		(bool)fInitialMountAllBFSCheck->Value());
	message.AddBool("initialMountRestore",
		(bool)fInitialMountRestoreCheck->Value());
	if (fInitialDontMountCheck->Value())
		message.AddBool("initialMountAllHFS", false);

	message.AddBool("ejectWhenUnmounting",
		(bool)fEjectWhenUnmountingCheckBox->Value());

	fTarget.SendMessage(&message);
}
Ejemplo n.º 4
0
void
FadeView::UpdateTurnOffScreen()
{
	bool enabled = (fSettings.TimeFlags() & ENABLE_DPMS_MASK) != 0;

	BScreen screen(Window());
	uint32 dpmsCapabilities = screen.DPMSCapabilites();

	fTurnOffScreenFlags = 0;
	if (dpmsCapabilities & B_DPMS_OFF)
		fTurnOffScreenFlags |= ENABLE_DPMS_OFF;
	if (dpmsCapabilities & B_DPMS_STAND_BY)
		fTurnOffScreenFlags |= ENABLE_DPMS_STAND_BY;
	if (dpmsCapabilities & B_DPMS_SUSPEND)
		fTurnOffScreenFlags |= ENABLE_DPMS_SUSPEND;

	fTurnOffCheckBox->SetValue(enabled && fTurnOffScreenFlags != 0
		? B_CONTROL_ON : B_CONTROL_OFF);

	enabled = fEnableCheckBox->Value() == B_CONTROL_ON;
	fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0);
	if (fTurnOffScreenFlags != 0) {
		fTurnOffNotSupported->Hide();
		fTurnOffSlider->Show();
	} else {
		fTurnOffSlider->Hide();
		fTurnOffNotSupported->Show();
	}
}
Ejemplo n.º 5
0
void PrefsWindow::hide_show_serial_ctrls(void)
{
	if (udptunnel_checkbox->Value() == B_CONTROL_ON) {
		ether_checkbox->SetEnabled(false);
		udpport_ctrl->SetEnabled(true);
	} else {
		ether_checkbox->SetEnabled(true);
		udpport_ctrl->SetEnabled(false);
	}
}
Ejemplo n.º 6
0
	status_t GetPrefs(BMessage& pref)
	{
		if( !mOnBox || !mNameCtrl ) return B_ERROR;
//		if( !mOnBox || !mNameCtrl || !mSkipBox ) return B_ERROR;
		BMessage		msg('null');
		if( msg.AddBool( "on", (mOnBox->Value() == B_CONTROL_ON) ? true : false ) != B_OK ) return B_ERROR;
		if( msg.AddString( "name", mNameCtrl->Text() ) != B_OK ) return B_ERROR;
		if( mRef ) msg.AddRef( "ref", mRef );
//		if( msg.AddBool( "skip", (mSkipBox->Value() == B_CONTROL_ON) ? true : false ) != B_OK ) return B_ERROR;

		if( pref.AddMessage("new item", &msg) != B_OK ) return B_ERROR;
		return B_OK;
	}
Ejemplo n.º 7
0
void
FadeView::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_COLORS_UPDATED:
			_UpdateColors();
			break;
		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);
	}
}
Ejemplo n.º 8
0
void MenuWindow::ToggleTestIcons(BMessage* message)
{
	if (! Valid()) {
		return;
	}
	
	void* pSrc;
	icon_size size = B_MINI_ICON;
	
	if (message->FindPointer("source", &pSrc) == B_OK) {
		BCheckBox* pCheckBox = reinterpret_cast<BCheckBox*>(pSrc);
		size = (pCheckBox->Value() == B_CONTROL_ON) ? B_LARGE_ICON : B_MINI_ICON;
	}
	
	ReplaceTestMenu(m_pFullMenuBar, size);
	ReplaceTestMenu(m_pHiddenMenuBar, size);	
}
Ejemplo n.º 9
0
//------------------------------------------------------------------------------
void WindowEditor::MessageReceived(BMessage *msg)
{
	BMessage fwd;
	switch (msg->what)
	{
		case MSG_WINDOW_SET_TITLE:
			fwd.what = msg->what;
			fwd.AddString("title", fTitleText->Text());
			fEditWindow.SendMessage(&fwd);
			break;

		case MSG_WINDOW_SET_LOOK:
			fEditWindow.SendMessage(msg);
			break;

		case MSG_WINDOW_SET_FLAG:
			fwd.what = msg->what;
			fwd.AddInt32("flags", MakeBitmask());
			fEditWindow.SendMessage(&fwd);
			break;

		case MSG_WINDOW_ADD_MENU:
		{
			BCheckBox* cbox;
			msg->FindPointer("source",(void **)(&cbox));
			fwd.what = msg->what;
			fwd.AddBool("addmenu", cbox->Value() == B_CONTROL_ON);
			fEditWindow.SendMessage(&fwd);
			break;
		}

		case MSG_WINDOW_SET_FEEL:
			fEditWindow.SendMessage(msg);
			break;

		default:
			BView::MessageReceived(msg);
			break;
	}
}
Ejemplo n.º 10
0
void MenuWindow::ToggleUserMenus(BMessage* message)
{
	if (! Valid()) {
		return;
	}
	
	void* pSrc;
	bool useFullMenus = false;
	
	if (message->FindPointer("source", &pSrc) == B_OK) {
		BCheckBox* pCheckBox = reinterpret_cast<BCheckBox*>(pSrc);
		useFullMenus = (pCheckBox->Value() == B_CONTROL_OFF);
	}
	
	if ((! useFullMenus) && m_bUsingFullMenuBar) {
		RemoveChild(m_pFullMenuBar);
		AddChild(m_pHiddenMenuBar);
		m_bUsingFullMenuBar = false;
	} else if (useFullMenus && (! m_bUsingFullMenuBar)) {
		RemoveChild(m_pHiddenMenuBar);
		AddChild(m_pFullMenuBar);
		m_bUsingFullMenuBar = true;
	}
}
Ejemplo n.º 11
0
void
PartitionsPage::PageCompleted()
{
	BGridLayout* layout = (BGridLayout*)fPartitions->GetLayout();
	int32 index = 0;

	for (int32 row = 0; row < layout->CountRows(); row += 3, index++) {
		BCheckBox* showBox
			= dynamic_cast<BCheckBox*>(layout->ItemAt(0, row)->View());
		BTextControl* nameControl
			= dynamic_cast<BTextControl*>(layout->ItemAt(1, row)->View());
		if (nameControl == NULL || showBox == NULL)
			debugger("partitions page is broken");

		BMessage partition;
		if (fSettings->FindMessage("partition", index, &partition) != B_OK)
			continue;

		partition.ReplaceBool("show", showBox->Value() != 0);
		partition.ReplaceString("name", nameControl->Text());

		fSettings->ReplaceMessage("partition", index, &partition);
	}
}
Ejemplo n.º 12
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;
	}
}
Ejemplo n.º 13
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);
}
/*!	\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
Ejemplo n.º 15
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;
	}
}
Ejemplo n.º 16
0
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());
				};
				
				
			};

		
}
Ejemplo n.º 17
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;
	}
}
Ejemplo n.º 18
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;
	}
}
Ejemplo n.º 19
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);
		}
	}
}
Ejemplo n.º 20
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;
}