Beispiel #1
0
/*!
 * \brief Update the list of save games.
 *
 * Can be called from 2 contexts ... from the delete items dialog
 * or from the main save game dialog. That's the reason for the
 * check agains the active form and the formID_files pointer
 */
static void
UpdateSaveGameList(void)
{
	int count;
	FormPtr files_form;
	ListPtr list;

	if (citylist != NULL)
		FreeCityNames(citylist);

	citylist = CityNames(&count);

	files_form = FrmGetFormPtr((UInt16)formID_files);

	if (files_form == NULL) {
		WriteLog("could not get the files form pointer\n");
		return;
	}
	list = (ListPtr)GetObjectPtr(files_form, listID_FilesList);

	if (list == NULL) {
		WriteLog("Could not get the pointer for list\n");
		return;
	}

	if (NULL == citylist) {
		LstSetListChoices(list, NULL, 0);
		if (files_form == FrmGetActiveForm() && FrmVisible(files_form))
			LstDrawList(list);
		return; /* no cities */
	}

	/* update list */
	LstSetListChoices(list, citylist, count);
	if (files_form == FrmGetActiveForm() && FrmVisible(files_form))
		LstDrawList(list);
}
Beispiel #2
0
/***********************************************************************
 *
 * FUNCTION:    RepeatSetUIValues
 *
 * DESCRIPTION: This routine sets the current repeat settings of the
 *              ui gadgets in the repeat dialog box
 *
 * PARAMETERS:  frm     - pointer to the Repeat Dialog
 *              repeatP - pointer to a RepeatInfoType structure.
 *
 * RETURNED:    nothing
 *
 ***********************************************************************/
void RepeatSetUIValues(FormType* frm, RepeatInfoType* repeatP) {
  UInt16 i;
  UInt16 id;
  UInt16 oldFreq;
  MemHandle freqH;
  Char* freqP = NULL;
  Boolean on = false;
  FieldType* fld = NULL;
  const Int8 startOfWeek = PrefGetPreference(prefWeekStartDay);

  /* Set the selection of the "repeat type" push button group. */
  id = repeatP->repeatType + RepeatNone;
  if (repeatP->repeatType > repeatMonthlyByDay)
    id--;
  FrmSetControlGroupSelection (frm, RepeatTypeGroup, id);


  /* Set the frequency field */
  if (repeatP->repeatType != repeatNone) {
    fld = GetObjectPointer(frm, RepeatFrequenceField);
    freqH = FldGetTextHandle(fld);
    if (freqH) {
      freqP = MemHandleLock(freqH);
      oldFreq = StrAToI(freqP);
    } else {
      freqH = MemHandleNew(maxFrequenceFieldLen);
      ASSERT(freqH);
      freqP = MemHandleLock(freqH);
      oldFreq = 0;
    }

    if (oldFreq != repeatP->repeatFrequency) {
      StrIToA(freqP, repeatP->repeatFrequency);
      FldSetTextHandle(fld, freqH);
      if (FrmVisible(frm)) {
	FldEraseField(fld);
	FldDrawField(fld);
      }
    }
    MemHandleUnlock (freqH);
  }

  /* Set the selection of the "repeat on" push button groups. */
  if (repeatP->repeatType == repeatWeekly) {
    /*
    ** If the appointment has a different start-day-of-week than
    ** the dialog-box's current start-day-of-week, rearrange the
    ** labels on the days-of-week push buttons.
    ** Note that this will only handle button-label shifts of one day.
    */
    if (startOfWeek != d.repeat_start_of_week) {
      const Char* sundayLabel = CtlGetLabel(GetObjectPointer(frm, RepeatDayOfWeek1PushButton));
      for (id = RepeatDayOfWeek1PushButton; id < RepeatDayOfWeek7PushButton; id++)
	CtlSetLabel(GetObjectPointer(frm, id), CtlGetLabel(GetObjectPointer(frm, id + 1)));

      CtlSetLabel(GetObjectPointer(frm, RepeatDayOfWeek7PushButton), sundayLabel);
      d.repeat_start_of_week = startOfWeek;
    }

    /* Turn on the push buttons for the days the appointment repeats on. */
    for (i = 0; i < daysInWeek; i++) {
      on = ((repeatP->repeatOn & (1 << i) ) != 0);
      id = RepeatDayOfWeek1PushButton +
	((i - startOfWeek + daysInWeek) % daysInWeek);
      CtlSetValue(GetObjectPointer(frm, id), on);
    }
  }

  /* Set the selection of the "repeat by" push button groups. */
  if (repeatP->repeatType == repeatMonthlyByDate)
    FrmSetControlGroupSelection(frm, RepeatByGroup, RepeatByDatePushButton);
  else
    FrmSetControlGroupSelection(frm, RepeatByGroup, RepeatByDayPushButton);
  
  /* Set the "end on" trigger label and popup list selection. */
  if (repeatP->repeatType != repeatNone)
    RepeatSetDateTrigger(repeatP->repeatEndDate);
}