static void AudioCDTabInit() { ControlType *cck3P; FieldType *fld2P, *fld3P; ListType *list1P, *list2P; MemHandle lengthH, firstTrackH; Char *lengthP, *firstTrackP; cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox); fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField); fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField); list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList); list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList); LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvCD); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); LstSetSelection(list2P, gameInfoP->musicInfo.sound.frtCD); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P))); CtlSetValue(cck3P, gameInfoP->musicInfo.sound.CD); lengthH = MemHandleNew(FldGetMaxChars(fld2P)+1); lengthP = (Char *)MemHandleLock(lengthH); StrIToA(lengthP, gameInfoP->musicInfo.sound.defaultTrackLength); MemHandleUnlock(lengthH); FldSetTextHandle(fld2P, lengthH); firstTrackH = MemHandleNew(FldGetMaxChars(fld3P)+1); firstTrackP = (Char *)MemHandleLock(firstTrackH); StrIToA(firstTrackP, gameInfoP->musicInfo.sound.firstTrack); MemHandleUnlock(firstTrackH); FldSetTextHandle(fld3P, firstTrackH); }
//////////////////////////////////////////////////////////////////////// // FUNCTION: CategorySelect // // DESCRIPTION: This routine process the selection and editing of // categories. Usually you call this when the user taps // the category pop-up trigger. // // PARAMETERS: (DmOpenRef) db - Opened database containing category info. // (FormType *) frm - Form that contains the category popup list. // (UInt16) ctlID - ID of the popup trigger // (UInt16) lstID - ID of the popup list // (Boolean) title - true if the popup trigger is on the title // line, which mans that an "All" choice should be // added to the list. Pass false if the popup // tigger appears in a form where a specific record // is being modified or any where else the "All" // choice should not appear. // (UInt16 *) categoryP - Current category (pointer into db // structure). // (char *) categoryName - Name of the current category // (UInt8) numUneditableCategories - This is the number // categories, starting with the first one at // zero, that may not have their names edited // by the user. // (UInt32) editingStrID - The resource ID of a string to // use with the "Edit Categories" list item. // // RETURNED: Returns true if any of the following conditions are true: // .The current category is renamed. // .The current category is deleted. // .The current category is merged with another category. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 3/16/01 Initial Revision // Jerry 3/19/01 Initial Revision // Jerry 5/05/01 Modify to use Global LIST catList //////////////////////////////////////////////////////////////////////// Boolean CategorySelect (DmOpenRef db, const FormType *frm, UInt16 ctlID, UInt16 lstID, Boolean title, UInt16 *categoryP, char *categoryName, UInt8 numUneditableCategories, UInt32 editingStrID) { ControlPtr ctlP; ListType *listP; UInt16 maxlength = 0; Int16 theIndex, lastIndex = *categoryP; ctlP = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, ctlID)); listP = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, lstID)); if ( !ctlP || !listP ) return FALSE; Vmemcpy (&(listP->bounds), &(ctlP->bounds), sizeof(RectangleType)); CategoryCreateList (db, listP, *categoryP, title,TRUE, TRUE, 0, TRUE); if ( title ) { if (*categoryP == dmAllCategories) listP->currentItem = 0; else listP->currentItem = *categoryP+1; } else listP->currentItem = *categoryP; theIndex = LstPopupList(listP); if (theIndex >= 0) { Vstrcpy (categoryName, LstGetSelectionText(listP,theIndex)); CtlSetLabel (ctlP, categoryName); if ( title ) { if ( !theIndex ) *categoryP = dmAllCategories; else *categoryP = theIndex-1; } else *categoryP = theIndex; return FALSE; } else { if ( *categoryP == dmAllCategories ) Vstrcpy (categoryName, LstGetSelectionText(listP,0)); // *categoryP = dmAllCategories; return FALSE; } }
static void MusicTabInit() { ControlType *cck1P, *cck2P; ListType *list1P, *list2P, *list3P; FieldType *fld1P; MemHandle tempoH; Char *tempoP; cck1P = (ControlType *)GetObjectPtr(TabMusicMusicCheckbox); cck2P = (ControlType *)GetObjectPtr(TabMusicMultiMidiCheckbox); list1P = (ListType *)GetObjectPtr(TabMusicDriverList); list2P = (ListType *)GetObjectPtr(TabMusicRateList); list3P = (ListType *)GetObjectPtr(TabMusicQualityList); fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField); CtlSetValue(cck1P, gameInfoP->musicInfo.sound.music); CtlSetValue(cck2P, gameInfoP->musicInfo.sound.multiMidi); if (gameInfoP->musicInfo.sound.drvMusic > 5) gameInfoP->musicInfo.sound.drvMusic = 0; LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvMusic); LstSetTopItem(list1P, gameInfoP->musicInfo.sound.drvMusic); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); LstSetSelection(list2P, gameInfoP->musicInfo.sound.rate); LstSetTopItem(list2P, gameInfoP->musicInfo.sound.rate); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicRatePopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P))); LstSetSelection(list3P, gameInfoP->fmQuality); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicQualityPopTrigger), LstGetSelectionText(list3P, LstGetSelection(list3P))); tempoH = MemHandleNew(FldGetMaxChars(fld1P)+1); tempoP = (Char *)MemHandleLock(tempoH); StrIToA(tempoP, gameInfoP->musicInfo.sound.tempo); MemHandleUnlock(tempoH); FldSetTextHandle(fld1P, tempoH); }
/*! * \brief get the current city that is selected on the list * \return the string containing the city or NULL if no city is selected */ static char * GetCurrentCityOnList(void) { FormPtr form = FrmGetFormPtr(formID_files); ListPtr listp; Int16 index; listp = (ListPtr)GetObjectPtr(form, listID_FilesList); index = LstGetSelection(listp); if (index != noListSelection) return (LstGetSelectionText(listp, index)); else return (NULL); }
void SavePrefsButtons(void) { ListType* lst; Int16 selection; char* buf; UInt32 i; UInt32 lists[] = { LstCal, LstPho, LstDo, LstNt, LstUp, LstDn }; // Map each string in the boxes to a keymap and set // the keymap settings (hd.button[1]...hd.button[6]) accordingly+ for (i=0;i<=5;i++) { lst = (ListType*)GetObjectPtr(lists[i]); selection = LstGetSelection(lst); buf = LstGetSelectionText(lst, selection); //FrmCustomAlert(Info, buf, 0, 0); temphd.buttons[i+1] = map_string_to_keymap(buf); } }
void LoadPrefsButtons(void) { ListType* lst; Int16 selection; UInt32 i; UInt32 lists[] = { LstCal, LstPho, LstDo, LstNt, LstUp, LstDn }; UInt32 triggers[] = { TrCal, TrPho, TrDo, TrNt, TrUp, TrDn }; // Map each keymap setting (hd.button[1]...hd.button[6]) to // a string and set the boxes accordingly for (i=0;i<=5;i++) { lst = (ListType*)GetObjectPtr(lists[i]); selection = temphd.buttons[i+1]; LstSetSelection(lst, selection); CtlSetLabel((ControlType*)GetObjectPtr(triggers[i]), LstGetSelectionText(lst, selection)); } }
/*********************************************************************** * * FUNCTION: RepeatSetDateTrigger * * DESCRIPTION: This routine sets the label of the trigger that displays * the end date of a repeating appointment. * * PARAMETERS: endDate - date or -1 if no end date * * RETURNED: nothing * * NOTES: * This routine assumes that the memory allocated for the label of * the due date trigger is large enough to hold the lagest posible * label. This label's memory is reserved by initializing the label * in the resource file. * ***********************************************************************/ static void RepeatSetDateTrigger (DateType endDate) { FormType* frm = FrmGetFormPtr(RepeatForm); ListType* lst = GetObjectPointer(frm, RepeatEndOnList); ControlType* ctl = GetObjectPointer(frm, RepeatEndOnTrigger); Char* label = (Char*)CtlGetLabel(ctl); /* OK to cast; we call CtlSetLabel */ ASSERT(lst); ASSERT(ctl); ASSERT(label); if (DateToInt(endDate) == apptNoEndDate) { StrCopy(label, LstGetSelectionText(lst, repeatNoEndDateItem)); LstSetSelection(lst, noEndDateItem); } else { /* Format the end date into a string. */ DateToDOWDMFormat(endDate.month, endDate.day, endDate.year + firstYear, PrefGetPreference(prefDateFormat), label); LstSetSelection(lst, repeatChooseDateItem); } CtlSetLabel(ctl, label); }
Boolean BookmarksFormHandleEvent(EventType * event) { Boolean handled = false; FormType * frm; ListType * bkmList, * sortTypeList; char * listTxt; UInt16 bookmarksCount; AppContext* appContext = GetAppContext(); frm = FrmGetActiveForm(); switch (event->eType) { case frmOpenEvent: OpenBookmarksDB(appContext, appContext->prefs.bookmarksSortType); bkmList = (ListType *) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, listBookmarks)); bookmarksCount = BookmarksWordCount(appContext); Assert( 0 != bookmarksCount ); LstSetDrawFunction(bkmList, BookmarksListDrawFunc); LstSetListChoices(bkmList, NULL, bookmarksCount); sortTypeList = (ListType *) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, listSortBy)); // list position matches enums for simplicity LstSetSelection(sortTypeList, (Int16)appContext->prefs.bookmarksSortType); listTxt = LstGetSelectionText(sortTypeList, appContext->prefs.bookmarksSortType); CtlSetLabel((ControlType *)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,popupSortBy)), listTxt); FrmDrawForm(frm); handled = true; break; case winDisplayChangedEvent: handled= BookmarksFormDisplayChanged(appContext, frm); break; case ctlSelectEvent: switch (event->data.ctlSelect.controlID) { case buttonCancel: CloseBookmarksDB(appContext); FrmReturnToForm(0); handled = true; break; case popupSortBy: // do nothing break; default: Assert(false); break; } break; case popSelectEvent: switch (event->data.popSelect.listID) { case listSortBy: Assert( appContext->currBookmarkDbType == appContext->prefs.bookmarksSortType ); if ((BookmarkSortType) event->data.popSelect.selection != appContext->prefs.bookmarksSortType) { // we changed sorting type sortTypeList = (ListType *) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, listSortBy)); listTxt = LstGetSelectionText(sortTypeList, event->data.popSelect.selection); CtlSetLabel((ControlType *)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,popupSortBy)), listTxt); // list position matches enums for simplicity OpenBookmarksDB(appContext, (BookmarkSortType) event->data.popSelect.selection); appContext->prefs.bookmarksSortType = (BookmarkSortType) event->data.popSelect.selection; #ifdef DEBUG // word count shouldn't change bookmarksCount = BookmarksWordCount(appContext); bkmList = (ListType *) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, listBookmarks)); Assert( LstGetNumberOfItems(bkmList) == bookmarksCount ); #endif FrmDrawForm(frm); } handled = true; break; default: Assert(false); break; } break; case lstSelectEvent: { MemHandle recHandle; char * word; recHandle = DmQueryRecord(appContext->bookmarksDb, event->data.lstSelect.selection); Assert( recHandle ); // no reason it shouldn't work if (recHandle) { word = (char*)MemHandleLock(recHandle); Assert(word); #ifndef I_NOAH appContext->currentWord = dictGetFirstMatching(GetCurrentFile(appContext), word); MemHandleUnlock(recHandle); SendEvtWithType(evtNewWordSelected); #else FrmReturnToForm(0); StartWordLookup(appContext, word); MemHandleUnlock(recHandle); #endif } CloseBookmarksDB(appContext); #ifndef I_NOAH FrmReturnToForm(0); #endif handled = true; } default: break; } return handled; }
static void ExamDetailsFormInit(FormType *frm) { UInt16 selectedCourse=0; ListType *course; ControlType *course_tr, *date_tr, *time_tr; course = GetObjectPtr(LIST_exd_course); course_tr = GetObjectPtr(LIST_exd_course_trigger); date_tr = GetObjectPtr(SELECTOR_exd_date); time_tr = GetObjectPtr(SELECTOR_exd_time); gExamDetailsNumCourses = CountCourses(); gExamDetailsItemList = (Char **) MemPtrNew(gExamDetailsNumCourses * sizeof(Char *)); gExamDetailsItemIDs = (UInt16 *) MemPtrNew(gExamDetailsNumCourses * sizeof(UInt16)); gExamDetailsItemInd = (UInt16 *) MemPtrNew(gExamDetailsNumCourses * sizeof(UInt16)); if (gExamsLastSelRowUID == 0) { // ADD DateTimeType dt; selectedCourse = CourseListGen(gExamDetailsItemList, gExamDetailsItemIDs, gExamDetailsItemInd, gExamDetailsNumCourses, 0, CLIST_SEARCH_INDEX); TimSecondsToDateTime(TimGetSeconds(), &dt); gExamDetailsDate.year=dt.year-MAC_SHIT_YEAR_CONSTANT; gExamDetailsDate.month=dt.month; gExamDetailsDate.day=dt.day; gExamDetailsBegin.hours=14; gExamDetailsBegin.minutes=0; gExamDetailsEnd.hours=15; gExamDetailsEnd.minutes=30; } else { MemHandle mex, mRoom, old; ExamDBRecord *ex; UInt16 index=0; Char *buffer; FieldType *fldRoom; fldRoom=GetObjectPtr(FIELD_exd_room); DmFindRecordByID(DatabaseGetRefN(DB_MAIN), gExamsLastSelRowUID, &index); mex = DmQueryRecord(DatabaseGetRefN(DB_MAIN), index); ex = (ExamDBRecord *)MemHandleLock(mex); selectedCourse = CourseListGen(gExamDetailsItemList, gExamDetailsItemIDs, gExamDetailsItemInd, gExamDetailsNumCourses, ex->course, CLIST_SEARCH_ID); gExamDetailsDate.year=ex->date.year; gExamDetailsDate.month=ex->date.month; gExamDetailsDate.day=ex->date.day; gExamDetailsBegin.hours=ex->begin.hours; gExamDetailsBegin.minutes=ex->begin.minutes; gExamDetailsEnd.hours=ex->end.hours; gExamDetailsEnd.minutes=ex->end.minutes; // Copy contents to the memory handle mRoom=MemHandleNew(StrLen(ex->room)+1); buffer=(Char *)MemHandleLock(mRoom); MemSet(buffer, MemPtrSize(buffer), 0); StrNCopy(buffer, ex->room, StrLen(ex->room)); MemHandleUnlock(mRoom); // Load fields old = FldGetTextHandle(fldRoom); FldSetTextHandle(fldRoom, mRoom); if (old != NULL) MemHandleFree(old); MemHandleUnlock(mex); } LstSetListChoices(course, gExamDetailsItemList, gExamDetailsNumCourses); if (gExamDetailsNumCourses < 5) LstSetHeight(course, gExamDetailsNumCourses); else LstSetHeight(course, 5); LstSetSelection(course, selectedCourse); CtlSetLabel(course_tr, LstGetSelectionText(course, selectedCourse)); ExamDetailsSetTriggers(date_tr, time_tr); EditTimeSetSelectorText(time_tr, &gExamDetailsBegin, &gExamDetailsEnd, gExamDetailsTimeTrigger); }
/* Event handler for the Control preference */ Boolean PrefsControlPalmEvent ( EventType* event /* pointer to an EventType structure */ ) { Boolean handled; handled = false; switch ( event->eType ) { case ctlSelectEvent: switch ( event->data.ctlEnter.controlID ) { case frmPrefsControlMode1: case frmPrefsControlMode2: case frmPrefsControlMode3: controlMode = event->data.ctlEnter.controlID - frmPrefsControlMode1; /* We need to hide then redraw our current section because HandleControlPrefs() has the code to display the proper objects to match our recently updated controlMode */ PrefsHideSection( objectList, prevControlMode ); PrefsOpenSection( GetCurrentSection() ); handled = true; break; default: break; } break; 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 ) { case frmPrefsControlPopup1: case frmPrefsControlPopup2: case frmPrefsControlPopup3: case frmPrefsControlPopup4: { UInt8 area; area = event->data.popSelect.listID - frmPrefsControlList1; controlSelect[ controlMode ][ area ] = LstGetSelection( list ); handled = true; break; } default: handled = false; break; } } break; } default: handled = false; } 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; }
Boolean MusicFormHandleEvent(EventPtr eventP) { FormPtr frmP = FrmGetActiveForm(); Boolean handled = false; switch (eventP->eType) { case frmOpenEvent: MusicFormInit(GamGetSelected()); handled = true; break; case frmCloseEvent: MusicFormSave(dmMaxRecordIndex); handled = true; break; case ctlSelectEvent: switch (eventP->data.ctlSelect.controlID) { case (MusicForm + 1) : case (MusicForm + 2) : case (MusicForm + 3) : lastTab = (eventP->data.ctlSelect.controlID - MusicForm - 1); TabSetActive(frmP, myTabP, lastTab); break; case TabMusicDriverPopTrigger: FrmList(eventP, TabMusicDriverList); FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicDriverList)); if (!OPTIONS_TST(kOptDeviceZodiac) && !OPTIONS_TST(kOptSonyPa1LibAPI)) { ListType *list1P = (ListType *)GetObjectPtr(TabMusicDriverList); if (LstGetSelection(list1P) == 4) { FrmCustomAlert(FrmInfoAlert, "There is no built-in MIDI support on your device.", 0, 0); LstSetSelection(list1P, 0); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); } } break; case TabMusicQualityPopTrigger: FrmList(eventP, TabMusicQualityList); FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicQualityList)); break; case TabMusicRatePopTrigger: FrmList(eventP, TabMusicRateList); FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicRateList)); if (!OPTIONS_TST(kOptPalmSoundAPI)) { ListType *list1P = (ListType *)GetObjectPtr(TabMusicRateList); if (LstGetSelection(list1P) != 0) { FrmCustomAlert(FrmInfoAlert, "You cannot use this rate on your device.", 0, 0); LstSetSelection(list1P, 0); CtlSetLabel((ControlType *)GetObjectPtr(TabMusicRatePopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); } } break; case TabAudioCDFormatPopTrigger: FrmList(eventP, TabAudioCDFormatList); FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDFormatList)); if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) { ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList); LstSetSelection(list1P, 0); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); } break; case TabAudioCDDriverPopTrigger: FrmList(eventP, TabAudioCDDriverList); FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDDriverList)); if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) { ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList); LstSetSelection(list1P, 0); CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); } break; case MusicOKButton: MusicFormSave(GamGetSelected()); break; case MusicCancelButton: MusicFormSave(dmMaxRecordIndex); break; } handled = true; break; default: break; } return handled; }
/* Event handler for the bookmark form */ Boolean BookmarksFormHandleEvent ( EventType* event /* pointer to an EventType structure */ ) { Boolean handled = false; switch ( event->eType ) { case winEnterEvent: handled = ResizeHandleWinEnterEvent(); break; case winDisplayChangedEvent: handled = ResizeHandleWinDisplayChangedEvent(); break; case winExitEvent: handled = ResizeHandleWinExitEvent(); break; case frmOpenEvent: #ifdef HAVE_SILKSCREEN ResizeHandleFrmOpenEvent(); #endif BookmarksFormInit(); handled = true; break; case frmCloseEvent: ReleaseBookmarkList(); #ifdef HAVE_SILKSCREEN ResizeHandleFrmCloseEvent(); #endif handled = false; break; case ctlSelectEvent: if ( event->data.ctlEnter.controlID == frmBookmarksDelete ) { ListType* list; Int16 selection; list = GetObjectPtr( frmBookmarksList ); selection = LstGetSelection( list ); if ( selection != noListSelection ) { BookmarkListEntry* e; e = GetBookmarkListEntry( selection ); if ( e->kind == BOOKMARK_ANNOTATION || e->kind == BOOKMARK_BOOKMARK ) { UInt16 choice; choice = FrmCustomAlert( confirmDelete, LstGetSelectionText( list, selection ), NULL, NULL ); if ( choice == DELETE_BOOKMARK ) { ErrTry { DeleteAnnotationByRecordNum( e->recordNum ); ReleaseBookmarkList(); CreateBookmarkList( list ); LstDrawList( list ); deleted = true; } ErrCatch( UNUSED_PARAM( err ) ) { FrmCustomAlert( errCannotDeleteBookmark, LstGetSelectionText( list, selection ), NULL, NULL ); } ErrEndCatch } }
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; }