/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ bool CalcWindow::QuitRequested() { // if (wind != NULL) { Prefs prefs; prefs.h = (int)(Frame().left); prefs.v = (int)(Frame().top); (void) WritePrefs("calculator.prefs", &prefs, sizeof(prefs)); } be_app->PostMessage(B_QUIT_REQUESTED); return true; }
/** * Save all of the printer settings; if we can find a printer name, save * printer-specific preferences. Otherwise, save generic ones. */ nsresult nsPrintOptions::SavePrintSettingsToPrefs(nsIPrintSettings *aPS, PRBool aUsePrinterNamePrefix, PRUint32 aFlags) { NS_ENSURE_ARG_POINTER(aPS); nsAutoString prtName; // Get the printer name from the PrinterSettings for an optional prefix. nsresult rv = GetAdjustedPrinterName(aPS, aUsePrinterNamePrefix, prtName); NS_ENSURE_SUCCESS(rv, rv); // Write the prefs, with or without a printer name prefix. return WritePrefs(aPS, prtName, aFlags); }
void TestPrefsDataWrite( void ) { Preferences testPref; Int16 version; UInt16 prefSize; /* Write known preference structure */ MemSet( Prefs(), sizeof( Preferences ), 0 ); Prefs()->controlMode = MODE2; WritePrefs(); /* Check that the correct preference structure was stored */ prefSize = 0; version = PrefGetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerPrefID, NULL, &prefSize, true); if ( version != noPreferenceFound && prefSize == sizeof( Preferences ) ) { PrefGetAppPreferences( (UInt32) ViewerAppID, (UInt16) ViewerPrefID, &testPref, &prefSize, true); } ASSERT( testPref.controlMode == MODE2 ); }
void AvcCompressorDialog::OnOK(wxCommandEvent &event) { if ( Validate() && TransferDataFromWindow() ) { // do our dialog specific validation // Check Adjustment Settings mstrAdjWin.ToLong(&mnAdjWin); if ( LongRangeCheck( mctlAdjWin, mnAdjWin, ADJWIN_MIN, ADJWIN_MAX ) == false ) { // value out of range return; } mstrDelay.ToLong(&mnDelay); if ( LongRangeCheck( mctlDelay, mnDelay, DELAY_MIN, DELAY_MAX ) == false ) { // value out of range return; } mstrChangeWin.ToLong(&mnChangeWin); if ( LongRangeCheck( mctlChangeWin, mnChangeWin, CHANGE_MIN, CHANGE_MAX ) == false ) { // value out of range return; } if ( mnChangeWin > mnAdjWin ) { wxMessageBox(wxT("Change window size must be less than or equal to Adjustment window size."), wxT("Validation error"), wxOK | wxICON_EXCLAMATION, GetParent() ); if ( mctlChangeWin ) mctlChangeWin->SetFocus(); return; } mstrMinPct.ToLong(&mnMinPct); if ( LongRangeCheck( mctlMinPct, mnMinPct, MINPCT_MIN, MINPCT_MAX ) == false ) { // value out of range return; } // Check Amplification Settings long iPrevPoint= 0; // index to mnXAxis and mnYAxis for ( int i = 0 ; i < NUM_CURVE_POINTS ; ++i ) { mstrXAxis[i].ToLong(&mnXAxis[i]); mstrYAxis[i].ToLong(&mnYAxis[i]); // see if this is a checked point if ( mctlCheckBoxes[i]->GetValue() == false) continue; // last box guaranteed to be checked if ( i > 0 ) { if ( mnXAxis[i] <= mnXAxis[iPrevPoint] ) { wxMessageBox(wxT("Values in columns must be in ascending order."), wxT("Validation error"), wxOK | wxICON_EXCLAMATION, GetParent() ); mctlXAxis[(i==NUM_CURVE_POINTS-1) ? iPrevPoint : i]->SetFocus(); return; } if ( mnYAxis[i] <= mnYAxis[iPrevPoint] ) { wxMessageBox(wxT("Values in columns must be in ascending order."), wxT("Validation error"), wxOK | wxICON_EXCLAMATION, GetParent() ); mctlYAxis[(i==NUM_CURVE_POINTS-1) ? iPrevPoint : i]->SetFocus(); return; } } iPrevPoint = i; } // AOK, time to return WritePrefs(); // save values user entered for next execution if ( IsModal() ) EndModal(wxID_OK); else { SetReturnCode(wxID_OK); this->Show(FALSE); } } }