static Boolean prefs_save_checkboxes_1() { FormPtr frm; ControlPtr checkbox; Boolean val, dirty = false; frm = FrmGetActiveForm(); checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_4)); my_prefs.sound = (CtlGetValue(checkbox) != 0); // Inverted background: checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_13)); val = (CtlGetValue(checkbox) != 0); if (my_prefs.black_bg != val) dirty = true; my_prefs.black_bg = val; // Color: checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_14)); val = (CtlGetValue(checkbox) != 0); if (my_prefs.color_on != val) dirty = true; my_prefs.color_on = val; return dirty; }
// Audio CD static Boolean AudioCDTabSave() { ControlType *cck3P; FieldType *fld2P, *fld3P; ListType *list1P, *list2P; UInt16 firstTrack; FormPtr frmP; frmP = FrmGetActiveForm(); cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox); fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField); fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField); list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList); list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList); firstTrack = StrAToI(FldGetTextPtr(fld3P)); if (firstTrack < 1 || firstTrack > 999) { TabSetActive(frmP, myTabP, 2); FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabAudioCDFirstTrackField)); FrmCustomAlert(FrmErrorAlert, "Invalid track value (1...999)", 0, 0); return false; } gameInfoP->musicInfo.sound.CD = CtlGetValue(cck3P); gameInfoP->musicInfo.sound.drvCD = LstGetSelection(list1P); gameInfoP->musicInfo.sound.frtCD = LstGetSelection(list2P); gameInfoP->musicInfo.sound.defaultTrackLength = StrAToI(FldGetTextPtr(fld2P)); gameInfoP->musicInfo.sound.firstTrack = firstTrack; return true; }
static void SetPeople( Short num ) { Int x; Boolean found = false; FormPtr frm; ControlPtr cPtr; Word oIdx; frm = FrmGetActiveForm(); x = MaxPlayers - 1; while( ( x > ( MaxPlayers - (num + 1) ) ) && !found ) { oIdx = FrmGetObjectIndex( frm, pbtnVal[x--] ); cPtr = FrmGetObjectPtr( frm, oIdx ); if( CtlGetValue( cPtr ) ) { CtlSetValue( cPtr, false ); found = true; } } if ( found ) { stor.tmpcomputers = MaxPlayers - (num + 1); oIdx = FrmGetObjectIndex( frm, cbtnVal[stor.tmpcomputers] ); cPtr = FrmGetObjectPtr( frm, oIdx ); CtlSetValue( cPtr, true); } }
void DialogPreferences() { FormPtr prevForm, frm; UInt16 hitButton; // Save previous form prevForm = FrmGetActiveForm(); // Init new form frm = FrmInitForm( frmPreferences); // Set it FrmSetActiveForm(frm); FrmDrawForm(frm); // Set Controls CtlSetValue( GetObjectPtr(check_NextPlayerPopUp ), GetFlag(flag_NextPlayerPopUp) ); CtlSetValue( GetObjectPtr(check_ForceSoundOff ), GetFlag(flag_NoSound) ); // Set the handler // FrmSetEventHandler(frm, DialogNewGameHandleEvent); hitButton = FrmDoDialog(frm); // Get Controls SetFlag( flag_NextPlayerPopUp, CtlGetValue( GetObjectPtr(check_NextPlayerPopUp) ) ); SetFlag( flag_NoSound, CtlGetValue( GetObjectPtr(check_ForceSoundOff) ) ); // Delete the form, we're not using it FrmDeleteForm(frm); // Restore previous form. if (prevForm) { FrmSetActiveForm(prevForm); } // We don't care, as long as the dialog quits. }
static Boolean prefs_save_checkboxes_2() { FormPtr frm; ControlPtr checkbox; Boolean val, dirty = false; frm = FrmGetActiveForm(); checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_2)); val = (CtlGetValue(checkbox) != 0); // decide to erase old circles if (my_prefs.overlay_circles && (val != my_prefs.relative_move)) dirty = true; my_prefs.relative_move = val; checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_3)); val = (CtlGetValue(checkbox) != 0); // decide to draw or erase circles if (my_prefs.overlay_circles != val) dirty = true; my_prefs.overlay_circles = val; return dirty; }
Boolean CBiddingForm::OnSetBid(EventPtr pEvent, Boolean& bHandled) { Int16 player_index = (*gManager->tbl->current_bidder)->playerIndex; if ( gManager->Status() == GetHandBids && player_index == gManager->humanIndex && player_has_bid == false ) { FormPtr frmP = FrmGetActiveForm(); UInt16 bidval = 0; if ( CtlGetValue((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid2PushButton ) )) ) { bidval = 2; } else if ( CtlGetValue((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid3PushButton ) ) ) ){ bidval = 3; } else if ( CtlGetValue((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid4PushButton ) ) ) ) { bidval = 4; } else if ( CtlGetValue((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBidSmudgePushButton ) ) ) ) { bidval = 5; } else { //PlayerBidPassPushButton bidval = 0; } (*gManager->tbl->current_bidder)->Bid(bidval); player_has_bid = true; EventType event; event.eType = nilEvent; EvtAddEventToQueue (&event); } bHandled = false; return true; } // OnSetBid
/* Handle the Gesture preferences */ Boolean PrefsGesturePreferenceEvent ( ActionType action ) { Boolean handled; handled = false; switch ( action ) { case AVAILABLE: /* Always available */ handled = true; break; case SHOWFIRST: handled = showFirst; showFirst = false; break; case LOAD: gestureSelected = GESTURES_UP; MemMove( gestureMode, Prefs()->gestMode, sizeof( gestureMode ) ); InitializeActionList( frmPrefsGestureActionList ); CtlSetValue( GetObjectPtr( frmPrefsGestureGestures ), Prefs()->gestures ); SetListToSelection( frmPrefsGestureActionList, frmPrefsGestureSelectAction, gestureMode[ gestureSelected ] ); handled = true; break; case DISPLAY: AffirmControlImage( gestureSelected, frmPrefsGestureUp, bmpGestureUp ); handled = true; break; case SAVE: Prefs()->gestures = CtlGetValue( GetObjectPtr( frmPrefsGestureGestures ) ); MemMove( Prefs()->gestMode, gestureMode, sizeof( gestureMode ) ); handled = true; break; default: handled = false; break; } return handled; }
// Music static Boolean MusicTabSave() { ControlType *cck1P, *cck2P; ListType *list1P, *list2P, *list3P; FieldType *fld1P; UInt16 tempo; FormPtr frmP; frmP = FrmGetActiveForm(); cck1P = (ControlType *)GetObjectPtr(TabMusicMusicCheckbox); cck2P = (ControlType *)GetObjectPtr(TabMusicMultiMidiCheckbox); list1P = (ListType *)GetObjectPtr(TabMusicDriverList); list2P = (ListType *)GetObjectPtr(TabMusicRateList); list3P = (ListType *)GetObjectPtr(TabMusicQualityList); fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField); tempo = StrAToI(FldGetTextPtr(fld1P)); if (tempo < 50 || tempo > 200) { TabSetActive(frmP, myTabP, 0); FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabMusicTempoField)); FrmCustomAlert(FrmErrorAlert, "Invalid tempo value (50...200)", 0, 0); return false; } gameInfoP->musicInfo.sound.music = CtlGetValue(cck1P); gameInfoP->musicInfo.sound.multiMidi = CtlGetValue(cck2P); gameInfoP->musicInfo.sound.drvMusic = LstGetSelection(list1P); gameInfoP->musicInfo.sound.rate = LstGetSelection(list2P); gameInfoP->fmQuality = LstGetSelection(list3P); gameInfoP->musicInfo.sound.tempo = tempo; return true; }
Err FlickrShowUploadCompleted(FlickrSocketContext& context) { if (NULL != context.progress) { PrgStopDialog(context.progress, false); context.progress = NULL; } Err err = errNone; FormType* form = NULL; bool formStateSaved = false; FormActiveStateType activeState; FrmSaveActiveState(&activeState); formStateSaved = true; MenuEraseStatus(NULL); form = FrmInitForm(uploadCompletedForm); if (NULL == form) { err = exgMemError; goto Finish; } FrmSetActiveForm(form); FrmDrawForm(form); FrmDoDialog(form); ControlType* control = (ControlType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, dontShowUploadCompletedFormCheckbox)); if (NULL != control) { Int16 val = CtlGetValue(control); if (0 != val) err = FlickrDisableUploadCompletedForm(); } Finish: if (NULL != form) FrmDeleteForm(form); if (formStateSaved) FrmRestoreActiveState(&activeState); return err; }
/*********************************************************************** * * FUNCTION: SelectOneTime * * DESCRIPTION: Display a form showing a time and allow the user * to select a different time. This is the single time * dialog as seen in general panel * * PARAMETERS: hour - pointer to hour to change minute - pointer to minute to change * title - string title for the dialog * * RETURNED: true if the OK button was pressed * if true the parameters passed are changed * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * roger 12/2/94 Initial Revision in General Panel * gavin 3/20/98 Extracted into separate system function * ***********************************************************************/ Boolean SelectOneTime(Int16 *hour,Int16 *minute, const Char * titleP) { FormType * originalForm, * frm; EventType event; Boolean confirmed = false; Boolean handled = false; Boolean done = false; TimeFormatType timeFormat; // Format to display time in Int16 curHour; UInt16 currentTimeButton; UInt8 hoursTimeButtonValue; Char hoursTimeButtonString[3]; UInt8 minuteTensButtonValue; Char minuteTensButtonString[2]; UInt8 minuteOnesButtonValue; Char minuteOnesButtonString[2]; Char separatorString[3]; timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat); originalForm = FrmGetActiveForm(); frm = (FormType *) FrmInitForm (SelectOneTimeDialog); if (titleP) FrmSetTitle (frm, (Char *) titleP); FrmSetActiveForm (frm); curHour = *hour; if (Use24HourFormat(timeFormat)) { // Hide the AM & PM ui FrmHideObject (frm, FrmGetObjectIndex (frm, timeAMCheckbox)); FrmHideObject (frm, FrmGetObjectIndex (frm, timePMCheckbox)); } else { if (curHour < 12) CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeAMCheckbox)), true); else { CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timePMCheckbox)), true); curHour -= 12; } if (curHour == 0) curHour = 12; } // Set the time seperator to the system defined one separatorString[0] = TimeSeparator(timeFormat); separatorString[1] = '\0'; FrmCopyLabel(frm, timeSeparatorLabel, separatorString); // Now set the time displayed in the push buttons. hoursTimeButtonValue = curHour; StrIToA(hoursTimeButtonString, hoursTimeButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeHourButton)), hoursTimeButtonString); minuteTensButtonValue = *minute / 10; StrIToA(minuteTensButtonString, minuteTensButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesTensButton)), minuteTensButtonString); minuteOnesButtonValue = *minute % 10; StrIToA(minuteOnesButtonString, minuteOnesButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesOnesButton)), minuteOnesButtonString); // Set the hour time button to be the one set by the arrows currentTimeButton = defaultTimeButton; CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, defaultTimeButton)), true); FrmDrawForm (frm); while (!done) { EvtGetEvent (&event, evtWaitForever); if (! SysHandleEvent ((EventType *)&event)) FrmHandleEvent (frm,&event); if (event.eType == ctlSelectEvent) { switch (event.data.ctlSelect.controlID) { case timeOkButton: frm = FrmGetActiveForm(); // Set the new time (seconds are cleared). if (Use24HourFormat(timeFormat)) *hour = hoursTimeButtonValue; else { *hour = hoursTimeButtonValue % 12 + // 12am is 0 hours! (CtlGetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timePMCheckbox))) ? 12 : 0); } *minute = minuteTensButtonValue * 10 + minuteOnesButtonValue; done = true; confirmed = true; break; case timeCancelButton: done = true; break; case timeDecreaseButton: case timeIncreaseButton: frm = FrmGetActiveForm(); switch (currentTimeButton) { // MemHandle increasing and decreasing the time for each time digit case timeHourButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (Use24HourFormat(timeFormat)) if (hoursTimeButtonValue > 0) hoursTimeButtonValue--; else hoursTimeButtonValue = 23; else if (hoursTimeButtonValue > 1) hoursTimeButtonValue--; else hoursTimeButtonValue = 12; } else { if (Use24HourFormat(timeFormat)) if (hoursTimeButtonValue < 23) hoursTimeButtonValue++; else hoursTimeButtonValue = 0; else if (hoursTimeButtonValue < 12) hoursTimeButtonValue++; else hoursTimeButtonValue = 1; } StrIToA(hoursTimeButtonString, hoursTimeButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeHourButton)), hoursTimeButtonString); break; case timeMinutesTensButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (minuteTensButtonValue > 0) minuteTensButtonValue--; else minuteTensButtonValue = 5; } else { if (minuteTensButtonValue < 5) minuteTensButtonValue++; else minuteTensButtonValue = 0; } StrIToA(minuteTensButtonString, minuteTensButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesTensButton)), minuteTensButtonString); break; case timeMinutesOnesButton: if (event.data.ctlSelect.controlID == timeDecreaseButton) { if (minuteOnesButtonValue > 0) minuteOnesButtonValue--; else minuteOnesButtonValue = 9; } else { if (minuteOnesButtonValue < 9) minuteOnesButtonValue++; else minuteOnesButtonValue = 0; } StrIToA(minuteOnesButtonString, minuteOnesButtonValue); CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesOnesButton)), minuteOnesButtonString); break; } handled = true; break; // timeDecreaseButton & timeIncreaseButton case timeHourButton: currentTimeButton = timeHourButton; break; case timeMinutesTensButton: currentTimeButton = timeMinutesTensButton; break; case timeMinutesOnesButton: currentTimeButton = timeMinutesOnesButton; break; } } else if (event.eType == appStopEvent) { EvtAddEventToQueue (&event); done = true; break; } } // end while true FrmEraseForm (frm); FrmDeleteForm (frm); FrmSetActiveForm(originalForm); return (confirmed); }
/* Event handler for the details form */ Boolean DetailsFormHandleEvent ( EventType* event /* pointer to an EventType structure */ ) { Boolean handled; Boolean update; handled = false; update = false; switch ( event->eType ) { case ctlSelectEvent: if ( event->data.ctlEnter.controlID == frmDetailsOK ) { UInt16 reference; Boolean oldStatus; Boolean newStatus; reference = GetHistoryCurrent(); oldStatus = ShowImages( reference ); newStatus = CtlGetValue( GetObjectPtr( frmDetailsShowImages ) ); update = oldStatus ^ newStatus; if ( newStatus ) ShowImagesOn( reference ); else ShowImagesOff( reference ); if ( CtlGetValue( GetObjectPtr( frmDetailsStatusRead ) ) ) SetVisitedLink( reference ); else UnsetVisitedLink( reference ); } else if ( event->data.ctlEnter.controlID == frmDetailsCopy ) { FieldType* field; field = GetObjectPtr( frmDetailsLink ); WriteTextFieldToMemo( field ); } else if ( event->data.ctlEnter.controlID != frmDetailsCancel ) { break; } FrmReturnToForm( PREVIOUS_FORM ); if ( update ) { ResetHeight(); FrmUpdateForm( GetMainFormId(), frmRedrawUpdateCode ); } handled = true; break; case winEnterEvent: handled = ResizeHandleWinEnterEvent(); break; case winDisplayChangedEvent: handled = ResizeHandleWinDisplayChangedEvent(); break; case winExitEvent: handled = ResizeHandleWinExitEvent(); break; case frmOpenEvent: #ifdef HAVE_SILKSCREEN ResizeHandleFrmOpenEvent(); #endif DetailsFormInit(); handled = true; break; case frmCloseEvent: #ifdef HAVE_SILKSCREEN ResizeHandleFrmCloseEvent(); #endif handled = false; break; default: handled = false; } return handled; }
/* Handle the Color preferences */ Boolean PrefsColorPreferenceEvent ( ActionType action ) { Boolean handled; handled = false; switch ( action ) { case AVAILABLE: if ( IsFormMain( Prefs()->lastForm ) ) { cameFromLibrary = false; handled = true; } else { /* We can only access this form from the library if the "vary with documents" setting is unchecked */ cameFromLibrary = true; if ( Prefs()->individualDocumentColor ) { handled = false; } else { handled = true; } } break; case SHOWFIRST: handled = showFirst; showFirst = false; break; case LOAD: LoadColorPrefs(); handled = true; break; case SAVE: strikethrough = CtlGetValue( GetObjectPtr( frmPrefsColorStrikethrough )); forceDefaultColors = CtlGetValue( GetObjectPtr( frmPrefsColorForceDefaultColors )); if ( cameFromLibrary ) { Prefs()->individualDocumentColor = false; } else { Prefs()->individualDocumentColor = CtlGetValue( GetObjectPtr( frmPrefsColorIndividual )); } if (( strikethrough != Prefs()->strikethrough ) || ( forceDefaultColors != Prefs()->forceDefaultColors )) { if ( Prefs()->individualDocumentColor) { GetHistoryPtr()->strikethrough = strikethrough; GetHistoryPtr()->forceDefaultColors = forceDefaultColors; } else { Prefs()->strikethrough = strikethrough; Prefs()->forceDefaultColors = forceDefaultColors; Prefs()->defaultStrikethrough = strikethrough; Prefs()->defaultForceDefaultColors = forceDefaultColors; } if ( Prefs()->individualDocumentColor && CtlGetValue( GetObjectPtr( frmPrefsColorAsDefault ))) { Prefs()->defaultStrikethrough = GetHistoryPtr()->strikethrough; Prefs()->defaultForceDefaultColors = GetHistoryPtr()->forceDefaultColors; } if ( ! cameFromLibrary ) { ReRenderAllIfNeeded(); } } handled = true; break; case DISPLAY: if ( cameFromLibrary ) { HidePrefsFormObject( frmPrefsColorIndividual, true ); HidePrefsFormObject( frmPrefsColorAsDefault, true ); } else { Boolean individualDocumentColor; individualDocumentColor = Prefs()->individualDocumentColor; CtlSetValue( GetObjectPtr( frmPrefsColorIndividual ), individualDocumentColor ); CtlSetValue( GetObjectPtr( frmPrefsColorAsDefault ), false ); if ( ! individualDocumentColor ) HidePrefsFormObject( frmPrefsColorAsDefault, true ); } handled = true; break; case RELEASE: handled = true; break; default: handled = false; break; } return handled; }
/* Event handler for the Color preferences */ Boolean PrefsColorPalmEvent ( EventType* event /* pointer to an EventType structure */ ) { Boolean handled; handled = false; switch ( event->eType ) { case popSelectEvent: { Int16 selection; selection = event->data.popSelect.selection; if ( selection != noListSelection ) { ControlType* ctl; ListType* list; Char* label; UInt16 controlID; list = event->data.popSelect.listP; controlID = event->data.popSelect.controlID; ctl = GetObjectPtr( controlID ); label = LstGetSelectionText( list, selection ); CtlSetLabel( ctl, label ); LstSetSelection( list, selection ); switch ( controlID ) { default: break; } } break; } case ctlSelectEvent: switch ( event->data.ctlEnter.controlID ) { case frmPrefsColorIndividual: if ( ! CtlGetValue( GetObjectPtr( frmPrefsColorIndividual ))) { HidePrefsFormObject( frmPrefsColorAsDefault, true ); } else { ShowPrefsFormObject( frmPrefsColorAsDefault, true ); } handled = true; break; case frmPrefsColorAsDefault: handled = true; break; default: break; } break; default: handled = false; } return handled; }
/* Handle the Lookup preferences */ Boolean PrefsLookupPreferenceEvent ( ActionType action ) { Boolean handled; handled = false; switch ( action ) { case AVAILABLE: #ifdef SUPPORT_WORD_LOOKUP if ( IsFormMain( Prefs()->lastForm ) ) { cameFromLibrary = false; handled = true; } else { /* We can only access this form from the library if the "vary with documents" setting is unchecked */ cameFromLibrary = true; if ( Prefs()->individualDocumentLookup ) { handled = false; } else { handled = true; } } #else handled = false; #endif break; case SHOWFIRST: handled = showFirst; showFirst = false; break; case LOAD: LoadLookupPrefs(); handled = true; break; case SAVE: if ( cameFromLibrary ) { Prefs()->individualDocumentLookup = false; } else { Prefs()->individualDocumentLookup = CtlGetValue( GetObjectPtr( frmPrefsLookupIndividual )); } if ( Prefs()->individualDocumentLookup ) { GetHistoryPtr()->selectedWordAction = lookupAction; if ( CtlGetValue( GetObjectPtr( frmPrefsLookupAlwaysActive ))) { GetHistoryPtr()->selectWordTap = SELECT_WORD_TAP_ONCE; } else { GetHistoryPtr()->selectWordTap = SELECT_WORD_TAP_NONE; } } else { Prefs()->selectedWordAction = lookupAction; Prefs()->defaultSelectedWordAction = lookupAction; if ( CtlGetValue( GetObjectPtr( frmPrefsLookupAlwaysActive ))) { Prefs()->selectWordTap = SELECT_WORD_TAP_ONCE; Prefs()->defaultSelectWordTap = SELECT_WORD_TAP_ONCE; } else { Prefs()->selectWordTap = SELECT_WORD_TAP_NONE; Prefs()->defaultSelectWordTap = SELECT_WORD_TAP_NONE; } } if ( Prefs()->individualDocumentLookup && CtlGetValue( GetObjectPtr( frmPrefsLookupAsDefault ))) { Prefs()->defaultSelectedWordAction = GetHistoryPtr()->selectedWordAction; Prefs()->defaultSelectWordTap = GetHistoryPtr()->selectWordTap; } ReRenderAllIfNeeded(); handled = true; break; case DISPLAY: if ( cameFromLibrary ) { HidePrefsFormObject( frmPrefsLookupIndividual, true ); HidePrefsFormObject( frmPrefsLookupAsDefault, true ); } else { Boolean individualDocumentLookup; individualDocumentLookup = Prefs()->individualDocumentLookup; CtlSetValue( GetObjectPtr( frmPrefsLookupIndividual ), individualDocumentLookup ); CtlSetValue( GetObjectPtr( frmPrefsLookupAsDefault ), false ); if ( ! individualDocumentLookup ) HidePrefsFormObject( frmPrefsLookupAsDefault, true ); } handled = true; break; case RELEASE: handled = true; break; default: handled = false; break; } return handled; }
Boolean Ln2SlFormHandleEvent(EventPtr e) { Boolean handled = false; DateType dt = {0, 0}; FormPtr frm = FrmGetFormPtr(Ln2SlForm); switch (e->eType) { case frmOpenEvent: if(gbVgaExists) VgaFormModify(frm, vgaFormModify160To240); DateSecondsToDate(TimGetSeconds(), &dt); DateToAsciiLong(dt.month, dt.day, dt.year + 1904, gPrefdfmts, gAppErrStr); SetFieldTextFromStr(Ln2SlFormInput, gAppErrStr); FrmDrawForm(frm); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case Ln2SlFormOk: FrmReturnToForm(0); handled = true; break; case Ln2SlFormConvert: { HappyDaysFlag dummy; Int16 year, month, day; Char* input; int ret; input = FldGetTextPtr(GetObjectPointer(frm, Ln2SlFormInput)); if ((ret = AnalysisHappyDays(input, &dummy, &year, &month, &day))) { int syear, smonth, sday; int leapyes = CtlGetValue(GetObjectPointer(frm, Ln2SlFormInputLeap)); ret = lunarL2S(lunarRefNum, year, month, day, leapyes, &syear, &smonth, &sday); if (ret == errNone) { Char temp[15]; SysCopyStringResource(temp, DayOfWeek(smonth, sday, syear) + SunString); DateToAsciiLong(smonth, sday, syear, gPrefdfmts, gAppErrStr); StrNCat(gAppErrStr, " [", AppErrStrLen); StrNCat(gAppErrStr, temp, AppErrStrLen); StrNCat(gAppErrStr, "]", AppErrStrLen); FldDrawField(SetFieldTextFromStr(Ln2SlFormResult, gAppErrStr)); } else DisplayInvalidDateErrorString(Ln2SlFormResult); } else { DisplayInvalidDateErrorString(Ln2SlFormResult); } handled = true; break; } default: break; } break; case menuEvent: handled = TextMenuHandleEvent(e->data.menu.itemID, Ln2SlFormInput); break; default: break; } return handled; }
static Boolean URLFormDoCommand(UInt16 command) { GlobalsPtr gP = GetGlobals(); Boolean handled = false; if (!gP) return false; switch (command) { // Menus // Control Objects case kURLOpenButton: { Char *navigationText = FldGetTextPtr(GetObjectPtr(kURLField)); Boolean openInNewTab = false; if (navigationText && StrLen(navigationText)) { if (gP->navigationOpen) { MemPtrFree(gP->navigationOpen); } gP->navigationOpen = StrDup(navigationText); if (CtlGetValue(GetObjectPtr(kURLOpenInNewTabCheckbox))) { openInNewTab = true; } FrmReturnToForm(0); if (openInNewTab) { FrmUpdateForm(kMainForm, frmUpdateNewTab); } FrmUpdateForm(kMainForm, URLFormDetermineRequestType(navigationText)); } } break; case kURLCancelButton: FrmReturnToForm(0); break; // Handle inserting text using the insert buttons, or list. case kWWWPushButton: case kCOMPushButton: case kORGPushButton: case kNETPushButton: case kSlashPushButton: case kDotPushButton: case kHTMLPushButton: { FieldPtr urlFldP = GetObjectPtr(kURLField); const Char *buttonLabelP = CtlGetLabel(GetObjectPtr(command)); FldInsert(urlFldP, buttonLabelP, StrLen(buttonLabelP)); CtlSetValue(GetObjectPtr(command), 0); handled = true; } break; case kMoreTrigger: { ListPtr moreListP = GetObjectPtr(kMoreList); FieldPtr urlFldP = GetObjectPtr(kURLField); Int16 selection = LstPopupList(moreListP); if (selection >= 0) { const Char *selectionP = LstGetSelectionText(moreListP, selection); FldInsert(urlFldP, selectionP, StrLen(selectionP)); } handled = true; } break; // Default default: break; } return handled; }