Beispiel #1
0
static Boolean
CourseListHandleSelection(void)
{
  MemHandle m, mWebsite, mEmail, old;
  CourseDBRecord c;
  FieldType *fldWebsite, *fldEmail;
  Char *buffer;
  
  m = DmQueryRecord(DatabaseGetRefN(DB_MAIN), gCourseInd[LstGetSelection(GetObjectPtr(LIST_courses))]);
  if (! m)  return true;
  UnpackCourse(&c, MemHandleLock(m));
  fldWebsite = GetObjectPtr(FIELD_cl_website);
  fldEmail = GetObjectPtr(FIELD_cl_email);

  if (StrLen(c.website) == 0) {
    mWebsite = MemHandleNew(4);
    buffer=MemHandleLock(mWebsite);
    MemSet(buffer, 4, 0);
    StrCopy(buffer, "-?-");
  } else {
    mWebsite = MemHandleNew(StrLen(c.website)+1);
    buffer = MemHandleLock(mWebsite);
    MemSet(buffer, StrLen(c.website)+1, 0);
    StrCopy(buffer, c.website);
  }
  MemHandleUnlock(mWebsite);
  old = FldGetTextHandle(fldWebsite);
  FldSetTextHandle(fldWebsite, mWebsite);
  if (old != NULL)  MemHandleFree(old); 
  FldDrawField(fldWebsite);

  if (StrLen(c.teacherEmail) == 0) {
    mEmail = MemHandleNew(4);
    buffer = MemHandleLock(mEmail);
    MemSet(buffer, 4, 0);
    StrCopy(buffer, "-?-");
  } else {
    mEmail = MemHandleNew(StrLen(c.teacherEmail)+1);
    buffer = MemHandleLock(mEmail);
    MemSet(buffer, StrLen(c.teacherEmail)+1, 0);
    StrCopy(buffer, c.teacherEmail);
  }
  MemHandleUnlock(mEmail);
  old = FldGetTextHandle(fldEmail);
  FldSetTextHandle(fldEmail, mEmail);
  if (old != NULL)  MemHandleFree(old); 
  FldDrawField(fldEmail);

  MemHandleUnlock(m);

  return false;
}
void wxControl::SetFieldLabel(const wxString& label)
{
    FieldType* field = (FieldType*)GetObjectPtr();
    if(field==NULL)
        return;

    uint16_t newSize = label.Length() + 1;
    MemHandle strHandle = FldGetTextHandle(field);
    FldSetTextHandle(field, NULL );
    if (strHandle)
    {
        if(MemHandleResize(strHandle, newSize)!=errNone)
            strHandle = 0;
    }
    else
    {
        strHandle = MemHandleNew( newSize );
    }
    if(!strHandle)
        return;

    char* str = (char*) MemHandleLock( strHandle );
    if(str==NULL)
        return;

    strcpy(str, label.c_str());
    MemHandleUnlock(strHandle);
    FldSetTextHandle(field, strHandle);
    FldRecalculateField(field, true);
}
Beispiel #3
0
Boolean DoRenameFigure(void)
{
    FormPtr prevFrm = FrmGetActiveForm();
    int numFigures = TFigurerecordGetCount();
    if ((currentFigure != noListSelection) && (currentFigure < numFigures)) {
	TFigure_type *t1 = TFigurerecordGet(currentFigure);
	if (t1) {
	    FormPtr frm = FrmInitForm(formRenameFigure);
	    FieldPtr field = (FieldPtr) FrmGetObjectPtr(frm,
							FrmGetObjectIndex
							(frm,
							 fieldFigureName));
	    MemHandle oldhText=FldGetTextHandle(field);
	    MemHandle hText = MemHandleNew(DESCSIZE);
	    char *titleptr = (char *) MemHandleLock(hText);
	    StrNCopy(titleptr, t1->name, DESCSIZE);
	    titleptr[DESCSIZE - 1] = 0;

	    MemPtrUnlock(titleptr);
	    FldSetTextHandle(field, (MemHandle) hText);
	    if (oldhText!=NULL) {
	      MemHandleFree(oldhText);
	    }

	    if (FrmDoDialog(frm) == buttonRFOK) {
		hText = FldGetTextHandle(field);
		titleptr = (char *) MemHandleLock(hText);
		if ((titleptr) && StrLen(titleptr) > 0) {

		    StrNCopy(t1->name, titleptr, DESCSIZE);
		    t1->name[DESCSIZE - 1] = 0;
		    TFigurerecordChange(currentFigure, t1);
		}
		MemPtrUnlock(titleptr);
	    }

	    TFigureFree(t1);
	    if (prevFrm)
		FrmSetActiveForm(prevFrm);
	    FrmDeleteForm(frm);
	}
	return true;
    }

    return false;
}
Beispiel #4
0
void CleanField( FieldPtr fld )
{
	VoidHand h;

	h = (VoidHand)FldGetTextHandle(fld);
	FldSetTextHandle(fld, NULL);
	if( h!=NULL ) MemHandleFree(h);
}
Beispiel #5
0
static Err UserCredentialsFormInit(FormType* form, const FlickrPrefs& prefs)
{
    FieldType* field;
    MemHandle handle;
    MemHandle newText;
    UInt16 len;

    FrmSetEventHandler(form, UserCredentialsFormHandleEvent);

    field = (FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, emailField));
    assert(field != NULL);
//    FldSetMaxVisibleLines(field, 2);

    if (0 != (len = StrLen(prefs.email)))
    {
        newText = StrCopyToHandle(prefs.email, len);
        if (NULL == newText)
            return exgMemError;

        handle = FldGetTextHandle(field);
        if (NULL != handle)
            MemHandleFree(handle);

        FldSetTextHandle(field, newText);
        FldSetSelection(field, 0, len);
        FldRecalculateField(field, false);
    }
    if (0 != (len = StrLen(prefs.password)))
    {
        field = (FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, passwordField));
        assert(field != NULL);
        newText = StrCopyToHandle(prefs.password, len);
        if (NULL == newText)
            return exgMemError;

        handle = FldGetTextHandle(field);
        if (NULL != handle)
            MemHandleFree(handle);

        FldSetTextHandle(field, newText);
        FldSetSelection(field, 0, len);
        FldRecalculateField(field, false);
    }
    return errNone;
}
Beispiel #6
0
/*****************************************************************************
* Function: DrawCourses
*
* Description: local function to fill the course list
*****************************************************************************/
static void
DrawCourses(ListType *lst)
{
  MemHandle mWebsite, mEmail, old;
  Char *buffer;
  FieldType *fldWebsite, *fldEmail;
  
  gNumCourses=CountCourses();
  gCourseList = (Char **) MemPtrNew(gNumCourses * sizeof(Char *));
  gCourseInd = (UInt16 *) MemPtrNew(gNumCourses * sizeof(UInt16));

  CourseListGen(gCourseList, NULL, gCourseInd, gNumCourses, 0, CLIST_SEARCH_INDEX);
  LstSetListChoices(lst, gCourseList, gNumCourses);
  LstSetSelection(lst, -1);

  
  fldWebsite = GetObjectPtr(FIELD_cl_website);
  fldEmail = GetObjectPtr(FIELD_cl_email);
  
  mWebsite = MemHandleNew(4);
  buffer = MemHandleLock(mWebsite);
  MemSet(buffer, 4, 0);
  StrCopy(buffer, "-?-");
  MemHandleUnlock(mWebsite);

  old = FldGetTextHandle(fldWebsite);
  FldSetTextHandle(fldWebsite, mWebsite);
  if (old != NULL)  MemHandleFree(old); 

  mEmail = MemHandleNew(4);
  buffer = MemHandleLock(mEmail);
  MemSet(buffer, 4, 0);
  StrCopy(buffer, "-?-");
  MemHandleUnlock(mEmail);

  old = FldGetTextHandle(fldEmail);
  FldSetTextHandle(fldEmail, mEmail);
  if (old != NULL)  MemHandleFree(old); 

  
}
Beispiel #7
0
/* SetFieldTextFromHandle -- Fills a field with contents of a handle
 * Args:    
 *     Word     fieldID  -- ID of field to fill, see cwimp.rpc file
 *     VoidHand txtH     -- Handle of String to fill ID with
 * Returns:
 *     FieldPtr          -- Ptr to the field set.
 */
FieldPtr SetFieldTextFromHandle(Word fieldID, VoidHand txtH)
{
  Handle   oldTxtH;
  FormPtr  frm = FrmGetActiveForm();
  FieldPtr fldP;

  fldP = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID));
  ErrNonFatalDisplayIf(!fldP, "missing field");
  oldTxtH = FldGetTextHandle(fldP);

  FldSetTextHandle(fldP, (Handle) txtH);
  // FldEraseField( fldP );
  FldDrawField(fldP);

  if (oldTxtH)
    MemHandleFree((VoidHand) oldTxtH);

  return fldP;
}
Beispiel #8
0
void SetFieldFromHandle ( UInt16 fieldID, MemHandle txtH )
{
	MemHandle oldTxtH;	/* Old text */
	FormType * frmP;	/* Form pointer */
	FieldType * fldP;	/* Field pointer */

	frmP = FrmGetActiveForm();	/* Find form pointer */
	fldP = FrmGetObjectPtr (frmP, FrmGetObjectIndex ( frmP, fieldID)); /* Find field pointer */

	ErrNonFatalDisplayIf ( !fldP, "missing field");	/* Check if the current object exists */
	
	oldTxtH = FldGetTextHandle(fldP);	/* Find text pointer of old text */
	
	FldSetTextHandle(fldP, txtH);	/* Set the new text */
	FldDrawField(fldP);	/* Redraw field */
	
	if (oldTxtH != NULL)	/* Free up old text */
		MemHandleFree(oldTxtH);

}
Beispiel #9
0
int AppendField( FieldPtr fld, CharPtr str, UInt len )
{
	Err err=0;
	CharPtr  s;
	VoidHand h;
	UInt prevlen;

	h=(VoidHand)FldGetTextHandle(fld);

	if(h==NULL) {
		h=MemHandleNew(len+1);
		if(h==NULL) return(-1);
		s=MemHandleLock(h);
		StrNCopy(s, str, len);
		s[len]=0;
		MemHandleUnlock(h);
	} else {
		prevlen=FldGetTextLength(fld);

		FldSetTextHandle(fld, NULL);

		if( MemHandleSize(h)<=(prevlen+len)) {
			err=MemHandleResize( h, prevlen+len+1 );
		}
		if( err!=0 ) return(-1);

		s=MemHandleLock(h);
		StrNCopy(s+prevlen, str, len);
		s[len+prevlen]=0;
		MemHandleUnlock(h);
	}

	FldSetTextHandle(fld, (Handle)h);
	/* FldDrawField(fld); */

	return( 0 );
}
Beispiel #10
0
static void SetField(UInt16 formID, UInt16 fieldID, const char *str)
{
    FormPtr frm;
    FieldPtr fld;
    UInt16 obj;
    CharPtr p;
    VoidHand h;
	
    frm = FrmGetFormPtr(formID);
    obj = FrmGetObjectIndex(frm, fieldID);
    fld = (FieldPtr)FrmGetObjectPtr(frm, obj);
    h = (VoidHand)FldGetTextHandle(fld);
    if (h == NULL)
    {
	h = MemHandleNew (FldGetMaxChars(fld)+1);
	ErrFatalDisplayIf(!h, "No Memory");
    }
	
    p = (CharPtr)MemHandleLock(h);
    StrCopy(p, str);
    MemHandleUnlock(h);
	
    FldSetTextHandle(fld, (Handle)h);
}
Beispiel #11
0
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);

}
Beispiel #12
0
/*!
 * \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");
	}
}
Beispiel #13
0
static void FlopSpeakCmd(UInt16 formID, UInt16 ifieldID, UInt16 ofieldID)
{
    FormPtr frm;
    FieldPtr fld;
    UInt16 obj;
    CharPtr p;
    VoidHand h;
    UInt32 processor_type;
    const char *ch=NULL;
    
    frm = FrmGetFormPtr(formID);
    obj = FrmGetObjectIndex(frm, ifieldID);
    fld = (FieldPtr)FrmGetObjectPtr(frm, obj);
    h = (VoidHand)FldGetTextHandle(fld);
    p = (CharPtr)MemHandleLock(h);

    /* Check we are on an ARM */
    FtrGet(sysFileCSystem, sysFtrNumProcessorID, &processor_type);
    if (processor_type == sysFtrNumProcessorx86)
	ch = "Flite doesn't run on the emulator";
    else if (!sysFtrNumProcessorIsARM(processor_type))
	ch = "Flite requires an ARM processor";
    else
    {   /* We're on an ARM -- so setup flite */
	if (!flite) 
	{
	    flite = flite_init();
	    if (flite == 0)
		ch = "Flite failed to initialize";
	    else
	    {
		flite->PlayPosition = 0;
		flite->output = output;
		flite->max_output = FlopMaxOutputChars;
		ch = flite->output;
	    }
	}

	if (FlopPlay == false)
	{
	    FlopPlay = true;
	    StrPrintF(input,"%s",p);
	    if (flite->utt_length == 0)
		flite->start = 0;
	    /* toggle play/stop button to play */
	}
	else
	{
	    FlopPlay = false;
	    flite->start = flite->PlayPosition;
	    /* toggle play/stop button to stop */
	}
    }

    if (ch)
    {
	/* Update the output field with any new information */
	SetField(FlopForm, FlopOutput, ch);
	FrmDrawForm(FrmGetFormPtr(FlopForm));
    }

    MemHandleUnlock(h);
}
Beispiel #14
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);
}