Exemple #1
0
Err show_heap_info() {

  Err err;
  UInt16 numHeaps, numRAMHeaps, version;
  UInt16 heapNo, heapId;
  UInt32 free, max, heapSize;
  Char tmp_text[100], tmp_textd1[100], tmp_textd2[100];
  FormPtr form;

  // Initialize the form.
  form = FrmInitForm(formID_heap_info);

  // Initialize the form.
  if (cardNo > MemNumCards()) {
    FrmAlert(alertID_no_card);
    return err;
  }

  numHeaps = MemNumHeaps(cardNo-1);
  StrPrintF(tmp_text, "Num. heaps: %u", numHeaps);
  show_lab(form, labelID_num_heaps, tmp_text);
  numRAMHeaps = MemNumRAMHeaps(cardNo-1);
  StrPrintF(tmp_text, "Num. RAM heaps: %u", numRAMHeaps);
  show_lab(form, labelID_num_RAM_heaps, tmp_text);

  for (heapNo=0; heapNo < numHeaps && heapNo < 3; heapNo++) {
      heapId = MemHeapID(cardNo-1,heapNo);
      heapSize = MemHeapSize(heapId);
      err = MemHeapFreeBytes(heapId, &free, &max);
      if (err) return err;
      if (heapNo < numRAMHeaps) {
	StrPrintF(tmp_text,
		  "RAM Heap %d is %s", 
		  heapNo, (MemHeapDynamic(heapId))?("dynamic"):("non-dynamic"));
	StrPrintF(tmp_textd1, "Free: %lu Kb.", free);
	StrPrintF(tmp_textd2, "Max. chunk: %lu Kb.", max);
      }
      else {
	StrPrintF(tmp_text, "ROM Heap %d", heapNo);
	StrPrintF(tmp_textd1, "Free: %lu Kb.", free);
	StrPrintF(tmp_textd2, "Max chunk: %lu Kb.", max);
      }
      switch (heapNo) {
      case 0: 
	show_lab(form, labelID_heap1, tmp_text);
	show_lab(form, labelID_heap1d1, tmp_textd1);
	show_lab(form, labelID_heap1d2, tmp_textd2);	
      case 1: 
	show_lab(form, labelID_heap2, tmp_text);
	show_lab(form, labelID_heap2d1, tmp_textd1);
	show_lab(form, labelID_heap2d2, tmp_textd2);
      default: 
	show_lab(form, labelID_heap3, tmp_text);
	show_lab(form, labelID_heap3d1, tmp_textd1);
	show_lab(form, labelID_heap3d2, tmp_textd2);
      }
  }
  display_modal_form(form);
  return err;
}
Exemple #2
0
/*********************************************************************
 * Function: ApplicationHandleEvent
 * Description: this is the event handler that we use to 
 * set up forms on frmLoadEvents. It sets the event handlers
 * for every other non modal form in the program
 * *******************************************************************/ 
static Boolean 
ApplicationHandleEvent (EventType *event) 
{
	FormType *frm;
	Int16 formId;
	Boolean handled = false;
	if (event->eType == frmLoadEvent)
		
	{
		
			// load and activate the requested form
			formId = event->data.frmLoad.formID;
		frm = FrmInitForm (formId);
		FrmSetActiveForm (frm);
		
			// set an event handler
			switch (formId)
			
		{
			case PasswordForm:
				FrmSetEventHandler (frm, PasswordHandleEvent);
				break;
		}
		handled = true;
	}
	return handled;
}
Exemple #3
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;
}
Exemple #4
0
Boolean Application_EventHandler(EventPtr event)
{
    FormPtr frm;
    int     formId;
    Boolean handled = false;

    switch (event->eType) {
       case frmLoadEvent : 
       {
           formId = event->data.frmLoad.formID;
           frm = FrmInitForm(formId);
           FrmSetActiveForm(frm);
                         
           switch(formId) {
                        
               case _GmF:
                   FrmSetEventHandler(frm, GmF_EventHandler);
                   break;
                
           }
           handled = true;
       }
       case menuEvent : 
       {
            switch (event->data.menu.itemID) {
            }
            handled = true;
       }
       default:
           break;
    }
    return handled;
}
static Boolean AppHandleEvent(EventPtr eventP) {
	Boolean handled = false;
	FormType *frmP;
	
	if (eventP->eType == frmLoadEvent) { /* Initialize and activate the form resource. */
		frmP = FrmInitForm(eventP->data.frmLoad.formID);

		FrmSetActiveForm(frmP);
		
		if (eventP->data.frmLoad.formID == MainForm) {
			dynInputOnMainFormLoad(frmP);
			FrmSetEventHandler(frmP, MainFormHandleEvent);
		}
		handled = true;
	} else if (eventP->eType == frmOpenEvent) { /* Load the form resource. */
		frmP = FrmGetActiveForm();
		FrmDrawForm(frmP);
		handled = true;
	} else if (eventP->eType == appStopEvent) { /* Unload the form resource. */
		frmP = FrmGetActiveForm();
		FrmEraseForm(frmP);
		FrmDeleteForm(frmP);
		handled = true;
	}
	
	return(handled);
}
/***********************************************************************
 *
 * FUNCTION:    AppHandleEvent
 *
 * DESCRIPTION: This routine loads form resources and set the event
 *              handler for the form loaded.
 *
 * PARAMETERS:  event  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event has handle and should not be passed
 *              to a higher level handler.
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static Boolean AppHandleEvent(EventPtr eventP)
{
	UInt16 formId;
	FormPtr frmP;

	if (eventP->eType == frmLoadEvent)
		{
		// Load the form resource.
		formId = eventP->data.frmLoad.formID;
		frmP = FrmInitForm(formId);
		FrmSetActiveForm(frmP);

		// Set the event handler for the form.  The handler of the currently
		// active form is called by FrmHandleEvent each time is receives an
		// event.
		switch (formId)
			{
			case MainForm:
				FrmSetEventHandler(frmP, MainFormHandleEvent);
				break;

			default:
//				ErrFatalDisplay("Invalid Form Load Event");
				break;

			}
		return true;
		}
	
	return false;
}
Exemple #7
0
static Boolean AppHandleEvent(EventPtr event)
{
    FormPtr frm;
    Int32 formId;
    Boolean handled;

    handled = false;

    if (event->eType == frmLoadEvent)
    {
	formId = event->data.frmLoad.formID;
	frm = FrmInitForm(formId);
	FrmSetActiveForm(frm);
	switch (formId)
	{
	case FlopForm:
	    FrmSetEventHandler(frm, FlopFormHandleEvent);
	    handled = true;
	    break;
				
	default:
	    break;
	}
    }

    return handled;
}
static Boolean
ApplicationHandleEvent (EventPtr event)
{
    Word formId;
    FormPtr frm;

    if (event->eType == frmLoadEvent)
    {
        // Load the form resource.
        formId = event->data.frmLoad.formID;
        frm = FrmInitForm (formId);
        if (frm)
        {
            switch (formId) {
            case mainForm:
                mainFrm = frm;
                FrmSetEventHandler (frm, MainFormHandleEvent);
                break;
            }
            FrmSetActiveForm (frm);
        }
        // Set the event handler for the form.  The handler of the currently
        // active form is called by FrmHandleEvent each time is receives an
        // event.
        return (true);
    }
    return (false);
}
Exemple #9
0
Int DialogChooseTwo( CharPtr fText, CharPtr bOne, CharPtr bTwo ) {
    FormPtr prevForm, frm;
    Word hitButton;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmChooseTwo );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Fill it...
    CtlSetLabel( GetObjectPtr(btnChooseTwo1), bOne );
    CtlSetLabel( GetObjectPtr(btnChooseTwo2), bTwo );
    SetFieldTextFromStr( fldChooseTwo, fText );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    if( hitButton == btnChooseTwo1 ) return 1;
    if( hitButton == btnChooseTwo2 ) return 2;
    return ( -1 );
}
Exemple #10
0
static Boolean AppHandleEvent(EventPtr event){
  FormPtr pfrm;
  Boolean handled = false;
  switch (event->eType){
    case frmLoadEvent:
      prevFormId = formId;
      formId = event->data.frmLoad.formID;
      pfrm = FrmInitForm(formId);
      FrmSetActiveForm(pfrm);
      switch (formId){
       case GraffitiForm:
          FrmSetEventHandler(pfrm, GraffitiFormHandleEvent);
          handled = true;
          break;
        case HelpForm:
          offset = 0;
          FrmSetEventHandler(pfrm, HelpFormHandleEvent);
          handled = true;
          break;
        case WinForm:
          FrmSetEventHandler(pfrm, WinFormHandleEvent);
          handled = true;
          break;
        case GraffitiHelpForm:
          FrmSetEventHandler(pfrm, GraffitiHelpFormHandleEvent);
          handled = true;
          break;
        default:
          break;
      }
      break;
    case menuEvent:
      MenuEraseStatus(NULL);
      switch (event->data.menu.itemID) {
        case MainMenuGraffitiHelpCmd:
          FrmGotoForm(GraffitiHelpForm);
          handled = true;
          break;
         case MainMenuRestartCmd:
          FrmGotoForm(HelpForm);
          handled = true;
          break;
        default:
          break;
      }
      break;
    case keyDownEvent:
      if (event->data.keyDown.chr == vchrHardPower){
        FrmGotoForm(HelpForm);
      }
      break;
    default:
      break;
  }
  return handled;
}
Exemple #11
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);
}
static Err ModImport(UInt16 volRefNum, UInt8 engine, Boolean *armP) {
#ifndef _DEBUG_ENGINE
	char filename[256];
	UInt16 cardNo;
	LocalID dbID;
	UInt32 result;
	FileRef file;
#endif
	char msg[256];
	FormPtr ofmP, frmP;
	Err e = errNone;

	ofmP = FrmGetActiveForm();
	frmP = FrmInitForm(ImportForm);
	FrmSetActiveForm(frmP);
	FrmDrawForm(frmP);

	// In debug mode, the engine files are directly uploaded to the simulator
#ifndef _DEBUG_ENGINE
	// engine file ?
	BUILD_FILE(engines[engine].fileP, ".engine");
	CHECK_FILE("ScummVM engine file was not found !");
	IMPRT_FILE("Cannot import engine file !");

	// need more files ?
	dbID = DmFindDatabase(0, "ScummVM-Engine");	// be sure to have the correct dbID
	e = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCustomEngineGetInfo, 0, &result);
	*armP = ((result & GET_MODEARM) == GET_MODEARM);

	// common file ?
	if (!e && (result & GET_DATACOMMON)) {
		BUILD_FILE("common", ".data");
		CHECK_FILE("Common data file was not found !");
		IMPRT_FILE("Cannot import common data file !");
	}
	// data file ?
	if (!e && (result & GET_DATAENGINE)) {
		BUILD_FILE(engines[engine].fileP, ".data");
		CHECK_FILE("Engine data file was not found !");
		IMPRT_FILE("Cannot import engine data file !");
	}
#endif
	// if error, cleanup
	if (e) ModDelete();

onError:
	FrmEraseForm(frmP);
	FrmDeleteForm(frmP);
	if (e) {
		if (ofmP) FrmSetActiveForm(ofmP);
		FrmCustomAlert(FrmErrorAlert, msg, 0, 0);
	}

	return e;
}
static void
Help (Int   id)
{
    FormPtr	frm;

    frm = FrmInitForm (id);
    if (frm)
    {
        FrmDoDialog (frm);
        FrmDeleteForm (frm);
    }
}
Exemple #14
0
static Err FlickrGetUserCredentials(FlickrPrefs& prefs)
{
    Err err = errNone;
    FormType* form = NULL;
    bool formStateSaved = false;

    FormActiveStateType activeState;
    FrmSaveActiveState(&activeState);
    formStateSaved = true;

    MenuEraseStatus(NULL);
    form = FrmInitForm(userCredentialsForm);
    if (NULL == form)
    {
        DMSG("FlickrGetUserCredentials(): unable to initialize form");DENDL;
        err = exgMemError;
        goto Finish;
    }

    err = UserCredentialsFormInit(form, prefs);
    if (errNone != err)
        goto Finish;

    FrmSetActiveForm(form);
    FrmDrawForm(form);

    UInt16 button = FrmDoDialog(form);
    switch (button)
    {
        case cancelButton:
            err = exgErrUserCancel;
            goto Finish;

        case okButton:
            UserCredentialsFormValidate(form, prefs);
            break;

        default:
            assert(false);
    }

    FlickrSavePrefs(prefs);

Finish:
    if (NULL != form)
        FrmDeleteForm(form);

    if (formStateSaved)
        FrmRestoreActiveState(&activeState);

    return err;
}
Exemple #15
0
Err PopupResidentBrowseForm(AppContext* appContext)
{
    Err error=errNone;
    FormType* form=FrmInitForm(formResidentBrowse);
    UInt16 buttonId=0;
    Assert(form);
    error=DefaultFormInit(appContext, form);
    if (error) 
        goto OnError;
    FrmSetEventHandler(form, ResidentBrowseFormHandleEvent);
    buttonId=FrmDoDialog(form);
    Assert(!buttonId || buttonCancel==buttonId);
OnError:
    FrmDeleteForm(form);
    return error;
}
Exemple #16
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;
}
Exemple #17
0
// Show card info in a modal form. Use global variable cardNo.
Err show_card_info() {
  Char cardName[32];
  Char manufName[32];
  UInt32 crDate, romSize, ramSize, freeBytes;
  Err err;
  UInt16 version;
  UInt32 free, max;
  Char tmp_text[100];

  // Initialize the form.
  FormPtr form = FrmInitForm(formID_card_info);

  // Initialize the form.
  if (cardNo > MemNumCards()) {
    FrmAlert(alertID_no_card);
    return err;
  }
  err = MemCardInfo (cardNo-1, cardName, manufName, &version, 
		     &crDate, &romSize, &ramSize, &freeBytes);
  if (err) {
    FrmAlert(alertID_no_card);
    return err;
  }

  StrPrintF(tmp_text, "Card no.: %u", cardNo);
  show_lab(form, labelID_card_info_no, tmp_text);
  StrPrintF(tmp_text, "Card name: %s", cardName);
  show_lab(form, labelID_card_name, tmp_text);
  StrPrintF(tmp_text, "Manu name: %s", manufName);
  show_lab(form, labelID_manu_name, tmp_text);
  StrPrintF(tmp_text, "Version: %u", version);
  show_lab(form, labelID_version, tmp_text);
  StrPrintF(tmp_text, "Cration date: %lu", crDate);
  show_lab(form, labelID_cr_date, tmp_text);
  StrPrintF(tmp_text, "ROM size: %lu Kb.", romSize / 1024);
  show_lab(form, labelID_ROM_size, tmp_text);
  StrPrintF(tmp_text, "RAM size: %lu Kb.", ramSize / 1024);
  show_lab(form, labelID_RAM_size, tmp_text);
  StrPrintF(tmp_text, "Free bytes: %lu Kb.", freeBytes / 1024);
  show_lab(form, labelID_free_mem, tmp_text);

  display_modal_form(form);

  return err;
}
Exemple #18
0
Err FlickrShowUploadCompleted(FlickrSocketContext& context)
{
    if (NULL != context.progress)
    {
        PrgStopDialog(context.progress, false);
        context.progress = NULL;
    }
    Err err = errNone;
    FormType* form = NULL;
    bool formStateSaved = false;
    FormActiveStateType activeState;
    FrmSaveActiveState(&activeState);
    formStateSaved = true;

    MenuEraseStatus(NULL);
    form = FrmInitForm(uploadCompletedForm);
    if (NULL == form)
    {
        err = exgMemError;
        goto Finish;
    }

    FrmSetActiveForm(form);
    FrmDrawForm(form);

    FrmDoDialog(form);

    ControlType* control = (ControlType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, dontShowUploadCompletedFormCheckbox));
    if (NULL != control)
    {
        Int16 val = CtlGetValue(control);
        if (0 != val)
            err = FlickrDisableUploadCompletedForm();
    }


Finish:
    if (NULL != form)
        FrmDeleteForm(form);

    if (formStateSaved)
        FrmRestoreActiveState(&activeState);

    return err;
}
Exemple #19
0
UInt16 DisplayDialog( UInt16 formID, FormEventHandlerPtr handler ) 
{ 
	FormPtr active = FrmGetActiveForm();
    
	UInt16 activeID = ( active != NULL ) ? FrmGetFormId( active ) : 0;
	FormPtr dialog = FrmInitForm( formID );
	UInt16 buttonPressed = 0;
    
	FrmSetActiveForm( dialog ); 
	if( handler ){ 
		FrmSetEventHandler( dialog, handler ); 
	} 
	FrmPopupForm( formID ); 
	buttonPressed = FrmDoDialog( dialog ); 
	FrmReturnToForm( activeID );
    
	return buttonPressed;
} 
/***********************************************************************
 *
 * FUNCTION:    MainFormDoCommand
 *
 * DESCRIPTION: This routine performs the menu command specified.
 *
 * PARAMETERS:  command  - menu item id
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static Boolean MainFormDoCommand(UInt16 command)
{
	Boolean handled = false;
	FormPtr frmP;

	switch (command)
		{
		case MainOptionsAboutStockQuote:
			MenuEraseStatus(0);					// Clear the menu status from the display.
			frmP = FrmInitForm (AboutForm);
			FrmDoDialog (frmP);					// Display the About Box.
			FrmDeleteForm (frmP);
			handled = true;
			break;

		}
	
	return handled;
}
Exemple #21
0
DieType DialogChooseThree( Char* fText, DieType c1, DieType c2, DieType c3 )
{

    FormPtr prevForm, frm;
    UInt16 hitButton;

    if( IsAI( GetCurrPlayer() ) ) {
        return AIChooseThree( c1, c2, c3 );
    }

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmChooseThree );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Fill it...
    CtlSetLabel( GetObjectPtr(btnChooseThree1), val2name[c1] );
    CtlSetLabel( GetObjectPtr(btnChooseThree2), val2name[c2] );
    CtlSetLabel( GetObjectPtr(btnChooseThree3), val2name[c3] );
    SetFieldTextFromStr( fldChooseThree, fText );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    if( hitButton == btnChooseThree1 ) return c1;
    if( hitButton == btnChooseThree2 ) return c2;
    if( hitButton == btnChooseThree3 ) return c3;
    return c1;
}
Exemple #22
0
Err BookmarksFormLoad(AppContext* appContext)
{
    Err error=errNone;
    FormType* form=FrmInitForm(formBookmarks);
    if (!form)
    {
        error=memErrNotEnoughSpace;
        goto OnError;
    }
    error=DefaultFormInit(appContext, form);
    if (!error)
    {
        FrmSetActiveForm(form);
        FrmSetEventHandler(form, BookmarksFormHandleEvent);
    }
    else 
        FrmDeleteForm(form);
OnError:
    return error;    
}
Exemple #23
0
void DialogPreferences() {
    FormPtr prevForm, frm;
    UInt16 hitButton;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmPreferences);

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Set Controls
    CtlSetValue( GetObjectPtr(check_NextPlayerPopUp ),
                 GetFlag(flag_NextPlayerPopUp) );

    CtlSetValue( GetObjectPtr(check_ForceSoundOff ),
                 GetFlag(flag_NoSound) );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Get Controls
    SetFlag( flag_NextPlayerPopUp,
             CtlGetValue( GetObjectPtr(check_NextPlayerPopUp) ) );
    SetFlag( flag_NoSound,
             CtlGetValue( GetObjectPtr(check_ForceSoundOff) ) );

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    // We don't care, as long as the dialog quits.
}
Exemple #24
0
static Boolean ApplicationHandleEvent(EventPtr e)
{
        FormPtr frm;
        UInt16	formId;
        Boolean handled = false;

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

                switch(formId) {
                case MainForm:
                        FrmSetEventHandler(frm, MainFormHandleEvent);
                        break;
                }
                handled = true;
        }

        return handled;
}
Exemple #25
0
/* This routine handles the loading of forms */
static void HandleFormLoad
    (
    EventType* event
    )
{
    FormType*  form;
    UInt16     formID;

    formID  = event->data.frmLoad.formID;
    form    = FrmInitForm( formID );
    FrmSetActiveForm( form );

    switch( formID ) {
        case frmMain:
            FrmSetEventHandler( form, FormHandleEvent );
            break;

        default:
            ErrFatalDisplay( "Unknown form ID" );
            break;
    }
}
Exemple #26
0
static void
EventLoop (void)
{
    short err;
    int fid;
    FormPtr form;
    EventType event;

    do
    {
	EvtGetEvent(&event, 200);

	// let the system handle it's own events
	if (SysHandleEvent(&event)) continue;

	// same for menu events
	if (MenuHandleEvent((void *)0, &event, &err)) continue;

	// set up our handler when our main form is loaded
	if (event.eType == frmLoadEvent) {
	    fid = event.data.frmLoad.formID;
	    form = FrmInitForm(fid);
	    FrmSetActiveForm(form);

	    switch (fid) {
	    case fid_kartrando:
		FrmSetEventHandler(form, mainEventHandler);
		break;
	    case fid_prefs:
		FrmSetEventHandler(form, prefsEventHandler);
		break;
	    }
	}

	FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);
}
Exemple #27
0
static Boolean AppHandleEvent(EventType *eventP)
{
    UInt16 formId;
    FormType *frmP;

    if (eventP->eType == frmLoadEvent) {
        /* Load the form resource. */
        formId = eventP->data.frmLoad.formID;
        frmP = FrmInitForm(formId);
        FrmSetActiveForm(frmP);

        /* 
         * Set the event handler for the form.  The handler of the
         * currently active form is called by FrmHandleEvent each
         * time is receives an event. 
         */
        switch (formId) {
            case kMainForm:
                FrmSetEventHandler(frmP, MainFormHandleEvent);
                FrmSetGadgetHandler(frmP, FrmGetObjectIndex(frmP, kTabGadget), TabGadgetHandler);
                break;
            case kURLForm:
                FrmSetEventHandler(frmP, URLFormHandleEvent);
                break;
            case kPrivacyForm:
                FrmSetEventHandler(frmP, PrivacyFormHandleEvent);
                break;
            case kPrefsForm:
                FrmSetEventHandler(frmP, PrefsFormHandleEvent);
                FrmSetGadgetHandler(frmP, FrmGetObjectIndex(frmP, kPrefsTabGadget), TabGadgetHandler);
                break;
        }
        return true;
    }

    return false;
}
Exemple #28
0
int event_loop(void) {
  UInt16 error;
  EventType event;
  FormPtr form;
  int form_id;
  Regiondesc rd;

  do {
    EvtGetEvent(&event, 0); // No timeout - return immediately
    if (!SysHandleEvent(&event))
      if (!MenuHandleEvent(NULL, &event, &error))
	if (event.eType == frmLoadEvent) {
	  // Load and activate form.
	  form_id = event.data.frmLoad.formID;
	  form = FrmInitForm(form_id);
	  FrmSetActiveForm(form);
	  switch (form_id) {
	  case formID_main_ri_sim: FrmSetEventHandler(form, (FormEventHandlerPtr) ri_sim_event); break;
	  case formID_sys_info: FrmSetEventHandler(form, (FormEventHandlerPtr) sys_info_event); break;
	  }
	} else
	    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Exemple #29
0
Word ChooseReader( Word itemNum )
{
	FormPtr prevFrm = FrmGetActiveForm();
	FormPtr frm = FrmInitForm( readerFormID );
	ListPtr lst = FrmGetObjectPtr( frm, FrmGetObjectIndex( frm,
		readerListID ) );
	Word hitButton;
	Word newSel;

	FrmSetActiveForm( frm );

	LstSetSelection( lst, itemNum );

	hitButton = FrmDoDialog( frm );

	newSel = LstGetSelection( lst );
	if( newSel==noListSelection ) newSel=-1;

	if( prevFrm ) FrmSetActiveForm( prevFrm );
	FrmDeleteForm( frm );

	if( hitButton==readerOkButtonID ) return( newSel );
	else return( itemNum );
}
static Boolean
RulesFormHandleEvent(EventPtr event)
{
    Boolean handled = false;

    switch (event->eType) {
    case ctlRepeatEvent:
        switch (event->data.ctlRepeat.controlID) {
        case rulesScrollUp:
            RulesScroll (winUp, false);
            break;
        case rulesScrollDown:
            RulesScroll (winDown, false);
            break;
        }
        break;
    case ctlSelectEvent:
        switch (event->data.ctlSelect.controlID) {
        case rulesScrollUp:
            RulesScroll (winUp, false);
            break;
        case rulesScrollDown:
            RulesScroll (winDown, false);
            break;
        }
        break;
    case keyDownEvent:
        switch (event->data.keyDown.chr) {
        case pageDownChr:
            RulesScroll (winDown, true);
            handled = true;
            break;
        case pageUpChr:
            RulesScroll (winUp, true);
            handled = true;
            break;
        }
        break;
    default:
    }
    return handled;
}

void
Rules (void)
{
    FieldPtr	field;
    VoidHand	rulesH;

    rulesH = DmGetResource ('tSTR', ricochetRulesText);
    if (rulesH)
    {
        rulesFrm = FrmInitForm (rulesForm);
        field = FrmGetObjectPtr (rulesFrm,
                                 FrmGetObjectIndex (rulesFrm, rulesText));
        FldSetInsPtPosition (field, 0);
        FldSetTextHandle (field, (Handle) rulesH);
        RulesSetScrolling ();
        FrmSetEventHandler (rulesFrm, RulesFormHandleEvent);
        FrmDoDialog (rulesFrm);
        FldSetTextHandle (field, 0);
        DmReleaseResource (rulesH);
        FrmDeleteForm (rulesFrm);
    }
}