Esempio n. 1
0
File: draw.c Progetto: docwhat/cwimp
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);
    }
}
Esempio n. 2
0
static Boolean ResidentBrowseFormFieldChanged(AppContext* appContext, FormType* form, EventType* event)
{
    char *      word;
    UInt32      newSelectedWord=0;
    FieldType * field;
    ListType *  list;
    UInt16      index=FrmGetObjectIndex(form, fieldWord);

    Assert(index!=frmInvalidObjectId);
    field=(FieldType*)FrmGetObjectPtr(form, index);
    Assert(field);
    index=FrmGetObjectIndex(form, listMatching);
    Assert(index!=frmInvalidObjectId);
    list=(ListType*)FrmGetObjectPtr(form, index);
    Assert(list);
    word=FldGetTextPtr(field);
    // TODO: get length of the word via FldGetTextLength()
    if (word && *word)
        newSelectedWord = dictGetFirstMatching(GetCurrentFile(appContext), word);
    if (appContext->selectedWord != newSelectedWord)
    {
        appContext->selectedWord = newSelectedWord;
        Assert(appContext->selectedWord < appContext->wordsCount);
        LstSetSelectionMakeVisibleEx(appContext, list, appContext->selectedWord);
    }
    return true;
}
Esempio n. 3
0
File: draw.c Progetto: docwhat/cwimp
static void SetComputers( Short num ) {
    FormPtr frm;
    ControlPtr cPtr;
    Word oIdx;

    if( num > (MaxPlayers - 1) || num < 0 ) {
        ErrNonFatalDisplayIf( true, "SetComputers: Out of Bounds");
        return;
    }

    if( stor.tmpcomputers == num ) {
        return;
    }

    frm = FrmGetActiveForm();


    /* Unset the old one */
    oIdx = FrmGetObjectIndex( frm, cbtnVal[stor.tmpcomputers] );
    cPtr = FrmGetObjectPtr( frm, oIdx );
    CtlSetValue( cPtr, false );

    /* Set new one */
    oIdx = FrmGetObjectIndex( frm, cbtnVal[num] );
    cPtr = FrmGetObjectPtr( frm, oIdx );
    CtlSetValue( cPtr, true );

    stor.tmpcomputers = num;

    if( stor.tmpcomputers + stor.tmpplayers > MaxPlayers ) {
        SetPlayers( MaxPlayers - stor.tmpcomputers );
    }

    return;
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
static void UserCredentialsFormValidate(FormType* form, FlickrPrefs& prefs)
{
    const char* email = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, emailField)));
    const char* password = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, passwordField)));
    StrCopy(prefs.email, email);
    StrCopy(prefs.password, password);
}
Esempio n. 6
0
static Boolean UserCredentialsFormHandleEvent(EventType* event)
{
    switch (event->eType)
    {
        case ctlSelectEvent:
            DMSG("UserCredentialsFormHandleEvent(): ctlSelectEvent"); DENDL;
            if (okButton == event->data.ctlSelect.controlID)
            {
                FormType* form = FrmGetFormPtr(userCredentialsForm);
                UInt16 emailIndex = FrmGetObjectIndex(form, emailField);
                UInt16 passwordIndex = FrmGetObjectIndex(form, passwordField);
                const char* email = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, emailIndex));
                const char* password = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, passwordIndex));

                if (NULL == email || 0 == StrLen(email))
                {
                    FrmSetFocus(form, emailIndex);
                    return true;
                }
                if (NULL == password || 0 == StrLen(password))
                {
                    FrmSetFocus(form, passwordIndex);
                    return true;
                }
            }
            return false;

        default:
            return false;
    }
}
Esempio n. 7
0
/***********************************************************************
 *
 * FUNCTION:    SetTimeTriggers
 *
 * DESCRIPTION: This routine sets the text label of the start time and
 *              end time triggers.
 *
 * PARAMETERS:  startTime	    - pointer to TimeType
 *              endTime        - pointer to TimeType
 *              startTimeText  - buffer that holds start time string
 *              emdTimeText    - buffer that holds end time string
 *              timeFormat     - time format
 *              untimed  	    - true if there isn't a time.
 *
 * RETURNED:	 nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			art	4/4/96	Initial Revision
 *
 ***********************************************************************/
static void SetTimeTriggers (TimeType startTime, TimeType endTime,
		Char * startTimeText, Char * endTimeText, 
		TimeFormatType timeFormat, Boolean untimed)
	{

	FormType *		frm;
	ControlPtr 	startTimeCtl, endTimeCtl;

	frm = FrmGetActiveForm ();
	startTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorStartTimeButton));
	endTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorEndTimeButton));

	if (! untimed)
		{
		TimeToAscii (startTime.hours, startTime.minutes, timeFormat, startTimeText);
		TimeToAscii (endTime.hours, endTime.minutes, timeFormat, endTimeText);
		}
	else
		{
		// copy two spaces into these fields instead of just a null
		// because controls with empty strings (or one space) cause old-style
		// graphic control behavior, which uses the wrong colors!
		StrCopy(startTimeText, "  ");
		StrCopy(endTimeText, "  ");
		}
		
	CtlSetLabel (startTimeCtl, startTimeText);
	CtlSetLabel(endTimeCtl, endTimeText);
	}
Esempio n. 8
0
static void init_lists(Short rw, Short ws)
{
  FormPtr frm;
  ListPtr lst;
  frm = FrmGetActiveForm();
  /* set initial settings for lists */
  lst = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, list_prf_1));
  LstSetSelection(lst, ws-1);
  lst = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, list_prf_2));
  LstSetSelection(lst, rw-1);
}
Esempio n. 9
0
static void init_checkboxes_1()
{
  FormPtr frm;
  ControlPtr checkbox;
  frm = FrmGetActiveForm();

  checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_4));
  CtlSetValue(checkbox, (my_prefs.sound ? 1 : 0));
  checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_13));
  CtlSetValue(checkbox, (my_prefs.black_bg ? 1 : 0));
  checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_14));
  CtlSetValue(checkbox, (my_prefs.color_on ? 1 : 0));
}
Esempio n. 10
0
static Boolean ApplicationHandleEvent( EventPtr event )
{
	FormPtr frm;
	FieldPtr fld;
	FieldAttrType fldattr;
	Int formId;
	Boolean handled = false;

	if( event->eType == frmLoadEvent ) {
		formId = event->data.frmLoad.formID;
		frm = FrmInitForm( formId );
		FrmSetActiveForm( frm );

		switch( formId ) {
			case mainFormID:
				FrmSetEventHandler( frm, MyMainFormHandleEvent );

				fld = FrmGetObjectPtr( frm, FrmGetObjectIndex( frm,
					dataFieldID ) );
				FldGetAttributes( fld, &fldattr );
				fldattr.hasScrollBar=true;
				FldSetAttributes( fld, &fldattr );

				break;
			default:
				break;
		}

		handled = true;
	}

	return handled;
}
Esempio n. 11
0
void* wxControl::GetObjectPtr() const
{
    uint16_t index;
    FormType* form = (FormType*)GetObjectFormIndex(index);
    if(form==NULL || index==frmInvalidObjectId)return NULL;
    return FrmGetObjectPtr(form,index);
}
Esempio n. 12
0
static void NewGameGetPlayerName( UInt16 field, Int16 player)
{
    FormPtr frm = FrmGetActiveForm();
    Char *buff;

    if( tmppref[player].type == PlayerNone )
    {
        return;
    }

    buff = FldGetTextPtr(
               FrmGetObjectPtr(
                   frm,
                   FrmGetObjectIndex(
                       frm,
                       fldNGname0+player )
               )
           );
    if( tmppref[player].type == PlayerHuman )
    {
        StrCopy( tmppref[player].hname, buff );
    }
    if( tmppref[player].type == PlayerAI )
    {
        StrCopy( tmppref[player].aname, buff );
    }
}
Esempio n. 13
0
/***********************************************************************
 *
 * FUNCTION:    PrvSetTimeField
 *
 * DESCRIPTION: Set the given field's text to show a time and day of week.
 *
 * PARAMETERS:  frm - a pointer to the form containing the field to set
 *					 timeFieldID - the ID of the field to set
 *					 timeHandle - the handle used for storing the text for this field
 *					 time - a pointer to the date and time to show in the field
 *					 drawField - whether to draw field after setting its text
 *
 * RETURNED:	 nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			peter	3/7/00	Initial Revision
 *
 ***********************************************************************/
static void PrvSetTimeField(FormType * frm, UInt16 timeFieldID, MemHandle timeHandle,
	DateTimeType *time, Boolean drawField)
{
	FieldType * timeFieldP;
	Char * timeString, * timeZoneDOWFormatString, * currentDOWString;
	MemHandle resHandle;
	TimeFormatType timeFormat;			// Format to display time in

	timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat);
	
	timeString = MemHandleLock(timeHandle);
	TimeToAscii(time->hour, time->minute, timeFormat, timeString);
	currentDOWString = timeString + StrLen(timeString);
	currentDOWString[0] = ' ';
	currentDOWString++;

	resHandle = DmGetResource(strRsc, DOWformatString);
	ErrNonFatalDisplayIf(resHandle == NULL, "Missing string resource");
	timeZoneDOWFormatString = MemHandleLock(resHandle);
	DateTemplateToAscii(timeZoneDOWFormatString, time->month, time->day, time->year,
		currentDOWString, dowLongDateStrLength);
	MemHandleUnlock(resHandle);
	
	MemHandleUnlock(timeHandle);
	timeFieldP = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeFieldID));
	FldSetTextHandle(timeFieldP, timeHandle);
	
	if (drawField)
		FldDrawField(timeFieldP);
}
Esempio n. 14
0
File: draw.c Progetto: docwhat/cwimp
static VoidPtr GetObjectPtr (Word objID) {
    FormPtr frm;

    frm = FrmGetActiveForm();

    return (FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, objID)));
}
Esempio n. 15
0
void * GetObjectPtr(UInt16 objectID)
{
	FormType * frmP;

	frmP = FrmGetActiveForm();
	return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID));
}
Esempio n. 16
0
static void MainFormFindButtonPressed(AppContext* appContext, FormType* form)
{
    const char* newWord=NULL;
    UInt16      index=FrmGetObjectIndex(form, fieldWordInput);

    Assert(frmInvalidObjectId!=index);

    FieldType* field=static_cast<FieldType*>(FrmGetObjectPtr(form, index));
    const char* prevWord=ebufGetDataPointer(&appContext->currentWordBuf);
    Assert(field);
    newWord=FldGetTextPtr(field);
    if (newWord && (StrLen(newWord)>0) && (!prevWord || 0!=StrCompare(newWord, prevWord)))
        StartWordLookup(appContext, newWord);
    else if (mainFormShowsDefinition!=appContext->mainFormContent)
    {
        const char* currentDefinition=ebufGetDataPointer(&appContext->currentDefinition);
        if ( NULL != currentDefinition )
        {
            // it can be NULL if we didn't have a definition and pressed "GO"
            // with no word in text field
            cbNoSelection(appContext);
            appContext->mainFormContent=mainFormShowsDefinition;

            diSetRawTxt(appContext->currDispInfo, const_cast<char*>(currentDefinition));
            FrmUpdateForm(formDictMain, redrawAll);
        }
    } 
}
Esempio n. 17
0
/***********************************************************************
 *
 * FUNCTION:    PrvUpdateTimeFields
 *
 * DESCRIPTION: Update the current time and new time displayed if they have
 *					 changed in the time zone dialog. Also used to update these
 *					 times in the daylight saving time dialog.
 *
 * PARAMETERS:  frm	 - the time zone or daylight saving time dialog
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			peter	4/13/00	Initial Revision
 *
 ***********************************************************************/
static void PrvUpdateTimeFields (FormPtr frm,
	DateTimeType *currentTimeP, DateTimeType *newTimeP,
	MemHandle currentTimeHandle, MemHandle newTimeHandle,
	UInt16 currentTimeFieldID, UInt16 newTimeFieldID)
{
	DateTimeType now, then;
	UInt32 delta;

	TimSecondsToDateTime(TimGetSeconds(), &now);

	if (now.minute != currentTimeP->minute ||
		now.hour != currentTimeP->hour ||
		now.day != currentTimeP->day ||
		now.month != currentTimeP->month ||
		now.year != currentTimeP->year)
	{
		then = *currentTimeP;
		*currentTimeP = now;
		PrvSetTimeField(frm, currentTimeFieldID, currentTimeHandle, currentTimeP, true);
		if (FldGetTextLength(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, newTimeFieldID))) != 0)
		{
			delta = TimDateTimeToSeconds(newTimeP) - TimDateTimeToSeconds(&then);
			TimSecondsToDateTime(TimDateTimeToSeconds(currentTimeP) + delta, newTimeP);
			PrvSetTimeField(frm, newTimeFieldID, newTimeHandle, newTimeP, true);
		}
	}
} // PrvUpdateTimeFields
Esempio n. 18
0
static void init_checkboxes_2()
{
  FormPtr frm;
  ControlPtr checkbox;
  frm = FrmGetActiveForm();
  checkbox = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, check_prf_2));
  CtlSetValue(checkbox, (my_prefs.relative_move ? 1 : 0));
}
Esempio n. 19
0
/**********************************************************************
  Tell the Palm to act like the user tapped the given button...
  Return true if we did (a very few callers would like to know)
**********************************************************************/
Boolean hit_button_if_usable(FormPtr frm, Word btn_index)
{
  ControlPtr btn;
  btn = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, btn_index));
  if (btn->attr.usable)
    CtlHitControl(btn);
  return (btn->attr.usable);
}
Esempio n. 20
0
File: helper.c Progetto: teras/FEdit
Char * GetTextFromField ( UInt16 fieldID ) {
	FieldType *fldP;
	FormType * frmP;

	frmP = FrmGetActiveForm();
	fldP = FrmGetObjectPtr (frmP, FrmGetObjectIndex ( frmP, fieldID )); /* Find field pointer */
	return FldGetTextPtr (fldP);
}
Esempio n. 21
0
static void MainFormSelectWholeInputText(const FormType* form)
{
    UInt16 index=FrmGetObjectIndex(form, fieldWordInput);
    Assert(frmInvalidObjectId!=index);
    FieldType* field=static_cast<FieldType*>(FrmGetObjectPtr(form, index));
    Assert(field);
    FldSelectAllText(field);
}
Esempio n. 22
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;
}
Esempio n. 23
0
static Boolean
prefsEventHandler (EventPtr event)
{
    int handled = 0;
    FormPtr form;
    ControlPtr ptr;

    switch (event->eType) {
    case frmOpenEvent:
	form = FrmGetActiveForm();
	ptr = FrmGetObjectPtr(form, FrmGetObjectIndex(form, cbid_repeats));
	CtlSetValue(ptr, repeats);
	ptr = FrmGetObjectPtr(form, FrmGetObjectIndex(form, cbid_rainbow));
	CtlSetValue(ptr, rainbow);
	ptr = FrmGetObjectPtr(form, FrmGetObjectIndex(form, cbid_extra));
	CtlSetValue(ptr, extra);
	FrmDrawForm(form);
	handled = 1;
	break;

    case ctlSelectEvent:  // a button was pressed and released
	switch (event->data.ctlSelect.controlID) {
	case cbid_repeats:
	    repeats = event->data.ctlSelect.on; handled = 1; break;
	case cbid_rainbow:
	    rainbow = event->data.ctlSelect.on; handled = 1; break;
	case cbid_extra:
	    extra = event->data.ctlSelect.on; handled = 1; break;

	case bid_ok:
	    FrmGotoForm(fid_kartrando); handled = 1; break;

	case bid_repeats_help: FrmAlert(aid_repeats_help); break;
	case bid_rainbow_help: FrmAlert(aid_rainbow_help); break;
	case bid_extra_help: FrmAlert(aid_extra_help); break;
	}
	break;

    default:
	break;
    }

    return handled;
}
Esempio n. 24
0
// Show a registration dialog where a user enters registration code.
// if fDeleteAfterCancel is set to true, we'll remove the registration code
// from preferences. We want this behavior if "re-enter registration code" was
// pressed after registration process failed (this was an invalid registration code
// so we don't want the client to send it to the server -> so we erase it).
// If this dialog was brought by "Register" menu item, then we don't want to
// touch the registration code (we assume it's correct)
// TODO: maybe if we're called from "Register" menu and registartion code
// is already present (i.e. valid) we should make it harder to edit it by accident
// (e.g. make it read only until user makes some action like pressing a "edit" button)
static void MainFormHandleRegister(AppContext* appContext, bool fDeleteAfterCancel)
{
    FormType* form=FrmInitForm(formRegistration);
    if (!form)
    {
        FrmAlert(alertMemError);
        return;
    }

    DefaultFormInit(appContext, form);
    FrmSetEventHandler(form, RegistrationFormHandleEvent);
    UInt16 button=FrmDoDialog(form);
    if (buttonRegister!=button)
    {
        if (fDeleteAfterCancel)
        {
            appContext->prefs.regCode[0] = '\0';
            SavePreferencesInoah(appContext);
        }
        goto Exit;
    }

    UInt16 index=FrmGetObjectIndex(form, fieldRegCode);
    Assert(frmInvalidObjectId!=index);
    const FieldType* field=static_cast<FieldType*>(FrmGetObjectPtr(form, index));
    Assert(field);
    const char* regCode=FldGetTextPtr(field);
    int regCodeLen = (int)FldGetTextLength(field);

    if ( (NULL != regCode) && (regCodeLen>0) )
    {
        // save the registration code in preferences so that we can
        // send it in all requests
        if (regCodeLen>MAX_REG_CODE_LENGTH)
        {
            // this is laziness: reg code longer than MAX_REG_CODE_LENGTH
            // is invalid for sure so we should just display such message
            // but we'll just use truncated version and go on with normal
            // processing
            regCodeLen=MAX_REG_CODE_LENGTH;
        }
        SafeStrNCopy((char*)appContext->prefs.regCode, sizeof(appContext->prefs.regCode), regCode, regCodeLen);
        RemoveNonDigits( (char*)appContext->prefs.regCode );
        // save preferences just for sure - so that we don't loose regCode
        // in case of a crash
        SavePreferencesInoah(appContext);
        // send a registration query to the server so that the user
        // knows if he registered correctly
        // it doesn't really matter, in the long run, because every time
        // we send a request, we also send the registration code and
        // if it's not correct, we'll reject the query
        StartRegistration(appContext, (const char*)appContext->prefs.regCode);
    }
Exit:
    FrmDeleteForm(form);
}
Esempio n. 25
0
static Boolean WordsListFormFieldChanged(AppContext* appContext, FormType* form, EventType* event)
{
    UInt16 index=FrmGetObjectIndex(form, fieldWordInput);
    Assert(index!=frmInvalidObjectId);
    FieldType* field=static_cast<FieldType*>(FrmGetObjectPtr(form, index));
    Assert(field);
    index=FrmGetObjectIndex(form, listProposals);
    Assert(index!=frmInvalidObjectId);
    ListType* list=static_cast<ListType*>(FrmGetObjectPtr(form, index));
    Assert(list);
    const char* word=FldGetTextPtr(field);
    // TODO: get length of the word via FldGetTextLength()
    if (word && *word)
    {
        UInt16 proposal=WordsListFormFindClosestProposal(appContext, list, word);
        LstSetSelection(list, proposal);
    }
    return true;
}
Esempio n. 26
0
void MainFormPressFindButton(const FormType* form) 
{
    Assert(form);
    Assert(formDictMain==FrmGetFormId(form));
    UInt16 index=FrmGetObjectIndex(form, buttonFind);
    Assert(frmInvalidObjectId!=index);
    const ControlType* findButton=static_cast<const ControlType*>(FrmGetObjectPtr(form, index));
    Assert(findButton);
    CtlHitControl(findButton);
}
Esempio n. 27
0
////////////////////////////////////////////////////////////////////////
// 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;
	}
}
Esempio n. 28
0
static Boolean RegistrationFormHandleEvent(EventType* event)
{
    Boolean     handled=false;
    FormType*   form=FrmGetFormPtr(formRegistration);
    UInt16      index;
    char *      regCode;
    AppContext* appContext=GetAppContext();

    switch (event->eType)
    {
        case winEnterEvent:
            if ((reinterpret_cast<_WinEnterEventType&>(event->data)).enterWindow==(void*)form)
            {
                index=FrmGetObjectIndex(form, fieldRegCode);
                Assert(frmInvalidObjectId!=index);
                FrmSetFocus(form, index);
                FieldType* field=static_cast<FieldType*>(FrmGetObjectPtr(form, index));
                Assert(field);

                regCode = (char*)appContext->prefs.regCode;
                if (StrLen(regCode)>0)
                {
                    FldClearInsert(form, fieldRegCode, regCode);
                    FldSelectAllText(field);
                }
            }
            handled = true;
            break;

        case keyDownEvent:
            if (returnChr==event->data.keyDown.chr || linefeedChr==event->data.keyDown.chr)
            {
                index=FrmGetObjectIndex(form, buttonRegister);
                Assert(frmInvalidObjectId!=index);
                const ControlType* regButton=static_cast<const ControlType*>(FrmGetObjectPtr(form, index));
                Assert(regButton);
                CtlHitControl(regButton);
                handled=true;
            }
    }
    return handled;
}
Esempio n. 29
0
File: screen.cpp Progetto: Jaxo/yaxx
/*--------------------------------------------------------------------display-+
|                                                                             |
+----------------------------------------------------------------------------*/
void display(char const * text, int len)
{
   FormPtr frm = FrmGetActiveForm();
   FieldPtr field = (FieldPtr)FrmGetObjectPtr(
      frm,
      FrmGetObjectIndex(frm, MainConsoleField)
   );
   FldInsert(field, text, len);
   updateScroll();
   FldDrawField(field);
}
Esempio n. 30
0
static void ResidentBrowseFormChooseWord(AppContext* appContext, FormType* form, UInt32 wordNo)
{
    ControlType* cancelButton=NULL;
    UInt16 index=FrmGetObjectIndex(form, buttonCancel);
    Assert(index!=frmInvalidObjectId);
    appContext->currentWord = wordNo;
    Assert(appContext->currentWord < appContext->wordsCount);
    cancelButton=(ControlType*)FrmGetObjectPtr(form, index);
    Assert(cancelButton);
    CtlHitControl(cancelButton);
}