/*********************************************************************** * * FUNCTION: RepeatChangeRepeatOn * * DESCRIPTION: This routine is called when one of the weekly "repeat on" * push button is pushed. This routine checks * if all the buttons has been turned off, if so the day * of the week of the appointment's start date is turn on. * * PARAMETERS: event - pointer to and event * * RETURNED: nothing * ***********************************************************************/ static void RepeatChangeRepeatOn(EventType* event) { UInt16 id = 0; UInt16 dayOfWeek = 0; FormType* frm = FrmGetFormPtr(RepeatForm); Boolean on = false; UInt16 i = 0; const UInt16 idx = FrmGetObjectIndex(frm, RepeatDayOfWeek1PushButton); /* Check if any of the buttons are on. */ for (; i < daysInWeek; i++) { if (FrmGetControlValue(frm, idx + i) != 0) { on = true; break; } } /* If all the buttons are off, turn on the start date's button. */ if (!on) { dayOfWeek = DayOfWeek (d.frm_date.month, d.frm_date.day, d.frm_date.year /*+ firstYear*/); /* frm_date is DateTimeType */ dayOfWeek = (dayOfWeek - d.repeat_start_of_week + daysInWeek) % daysInWeek; id = RepeatDayOfWeek1PushButton + dayOfWeek; CtlSetValue(GetObjectPointer(frm, id), true); } /* Update the display of the repeat description. */ RepeatDrawDescription(frm); }
bool wxControl::GetBoolValue() const { FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; uint16_t index = FrmGetObjectIndex(form, GetId()); if(index==frmInvalidObjectId) return false; return ( FrmGetControlValue(form, index) == 1 ); }
/*! * \brief the create button is pressed in the new city form */ static void cnCreateButtonPressed(void) { char *pGameName; FormPtr form; UInt8 level = 0; UInt8 width; UInt8 height; FieldPtr fp; MemHandle mh; MemPtr mp; InitGameStruct(); form = FrmGetActiveForm(); if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Easy))) level = 0; if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Medium))) level = 1; if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Hard))) level = 2; setDifficultyLevel(level); if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_dis_off))) level = 0; if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_dis_one))) level = 1; if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_dis_two))) level = 2; if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_dis_three))) level = 3; setDisasterLevel(level); fp = (FieldPtr)GetObjectPtr(form, fieldID_width); mh = FldGetTextHandle(fp); mp = MemHandleLock(mh); width = (UInt8)StrAToI(mp); MemHandleUnlock(mh); fp = (FieldPtr)GetObjectPtr(form, fieldID_height); mh = FldGetTextHandle(fp); mp = MemHandleLock(mh); height = (UInt8)StrAToI(mp); MemHandleUnlock(mh); setMapSize(width, height); ConfigureNewGame(); pGameName = FldGetTextPtr((FieldPtr)GetObjectPtr(form, fieldID_newGameName)); if (pGameName != NULL) { MemSet(game.cityname, CITYNAMELEN, '\0'); StrNCopy((char *)game.cityname, pGameName, CITYNAMELEN); while (GameExists((char *)game.cityname)) { UInt16 slen = StrLen((char *)game.cityname); if (slen < CITYNAMELEN-1) { game.cityname[slen-1] = '0' - 1; game.cityname[slen] = '\0'; slen++; } game.cityname[slen - 1]++; } SaveGameByName((char *)game.cityname); CleanSaveGameList(); if (LoadGameByName((char *)game.cityname) != -1) { FrmEraseForm(form); form = FrmGetFormPtr(formID_files); if (form != NULL) { FrmEraseForm(form); FrmDeleteForm(form); } FrmGotoForm(formID_pocketCity); } else { UpdateSaveGameList(); } } else { game.cityname[0] = '\0'; WriteLog("No name specified\n"); } }
/*********************************************************************** * * FUNCTION: RepeatGetUIValues * * DESCRIPTION: This routine gets the current repeat settings of the * ui gadgets in the repeat dialog box * * * PARAMETERS: frm - pointer to the repeat dialog * repeatP - RepeatInfoType structure (fill-in by this routine) * * RETURNED: nothing * ***********************************************************************/ void RepeatGetUIValues (FormType* frm, RepeatInfoType* repeatP) { UInt16 freq; UInt16 i; UInt16 id; UInt16 index; Char* str = NULL; /* Get the repeat type. */ index = FrmGetControlGroupSelection(frm, RepeatTypeGroup); id = FrmGetObjectId(frm, index); if (id == RepeatYearly) { repeatP->repeatType = repeatYearly; } else if (id <= RepeatWeekly) { repeatP->repeatType = (RepeatType) (id - RepeatNone); } else { index = FrmGetControlGroupSelection(frm, RepeatByGroup); id = FrmGetObjectId(frm, index); if (id == RepeatByDayPushButton) repeatP->repeatType = repeatMonthlyByDay; else repeatP->repeatType = repeatMonthlyByDate; } /* Get the repeat end date. */ repeatP->repeatEndDate = d.repeat_end_date; /* Get the repeat frequency. */ str = FldGetTextPtr(GetObjectPointer(frm, RepeatFrequenceField)); if (str) freq = StrAToI(str); else freq = 0; if (freq) repeatP->repeatFrequency = freq; else repeatP->repeatFrequency = 1; /* ** Get the start day of week. If the original repeat type, that is the ** repeat type when the dialog was first displayed, is weekly then ** use the start date in the repeat info (the unedit data), otherwise ** use the current start of week. */ if (repeatP->repeatType == repeatWeekly) { if (d.tmp_repeat.repeatType == repeatWeekly) repeatP->repeatStartOfWeek = d.tmp_repeat.repeatStartOfWeek; else repeatP->repeatStartOfWeek = PrefGetPreference(prefWeekStartDay); } else { /* For all other repeat types, the repeatStartOfWeek field is meaningless. */ repeatP->repeatStartOfWeek = 0; } /* If the repeat type is weekly, get the day of the week the event repeats on. */ if (repeatP->repeatType == repeatWeekly) { repeatP->repeatOn = 0; index = FrmGetObjectIndex(frm, RepeatDayOfWeek1PushButton); for (i = 0; i < daysInWeek ; i++) { if (FrmGetControlValue(frm, index + ((i - d.repeat_start_of_week + daysInWeek) % daysInWeek))) repeatP->repeatOn |= (1 << i); } } else if (repeatP->repeatType == repeatMonthlyByDay) { /* ** If the repeat type is monthly by day, get the day of the month (ex: ** first Friday) of the start date of the event. */ if (d.tmp_repeat.repeatType == repeatMonthlyByDay) repeatP->repeatOn = d.tmp_repeat.repeatOn; else repeatP->repeatOn = DayOfMonth (d.frm_date.month, d.frm_date.day, d.frm_date.year); } else { /* For all other repeat types, the repeatOn field is meaningless. */ repeatP->repeatOn = 0; } }