Esempio n. 1
0
File: IntExp.c Progetto: ysei/palmos
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;
}
Esempio n. 2
0
Boolean FormGroupManagementHandleEvent(EventType* eventP)
{
	Boolean handled = false;
	
	switch (eventP->eType) 
	{
		case frmOpenEvent:
			FormPtr frmP = FrmGetActiveForm();
			FrmDrawForm(frmP);
			ListAllGroups();
			handled = true;
			break;
		case frmCloseEvent:
			ClearPhoneGroups(g_PhoneGroups);
			break;
		case ctlSelectEvent:
			switch(eventP->data.ctlSelect.controlID) {
				case ButtonOk:
					FrmGotoForm(FormMain);
					break;
				case ButtonNew:
					NewGroup();
					break;
				case ButtonRemove:
					RemoveCurrentSelection();
					break;
				case ButtonModify:
					EditCurrentSelection();
					break;
			}
			break;
	}
	return handled;
}
Esempio n. 3
0
UInt32 PilotMain(UInt16 launchCode, 
		 MemPtr launchParameters, 
		 UInt16 launchFlags)
{
    Err error;
    UInt32 romVersion;

    FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
    if (romVersion < ROM_VERSION_REQUIRED_FOR_FLOP)
    {
	FrmAlert(RomIncompatibleAlert);
	return (sysErrRomIncompatible);
    }

    switch(launchCode)
    {
    case sysAppLaunchCmdNormalLaunch:

	error = AppStart();
	if (error) return error;

	FrmGotoForm(FlopForm);
	AppEventLoop();
	AppStop();
	break;
	
    default:
	break;
    }

    return errNone;
}
Esempio n. 4
0
static Err StartApplication( void )
{
	/* Open Form */
	FrmGotoForm( mainFormID );

	return 0;
}
/***********************************************************************
 *
 * FUNCTION:    StarterPalmMain
 *
 * DESCRIPTION: This is the main entry point for the application.
 *
 * PARAMETERS:  cmd - word value specifying the launch code. 
 *              cmdPB - pointer to a structure that is associated with the launch code. 
 *              launchFlags -  word value providing extra information about the launch.
 *
 * RETURNED:    Result of launch
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
	Err error;

	error = RomVersionCompatible (ourMinVersion, launchFlags);
	if (error) return (error);

	switch (cmd)
		{
		case sysAppLaunchCmdNormalLaunch:
			error = AppStart();
			if (error) 
				return error;
				
			FrmGotoForm(MainForm);
			AppEventLoop();
			AppStop();
			break;

		default:
			break;

		}
	
	return errNone;
}
Esempio n. 6
0
/*
** Go to the record specified gadgetID and open the specified
** "field" (the note dialog, the details dialog, ...)
*/
static void GotoRecordField(UInt16 gadgetID, UInt16 field) {
  FormType* frm = FrmGetActiveForm();
  DynamicButtonType* btn = (DynamicButtonType*) FrmGetGadgetData(frm, FrmGetObjectIndex(frm, gadgetID));

  p.dbI = btn->value;
  LoadRecordData();

  switch (field) {
  case ffNote:
    DoNoteDialog(0, 0);
    break;

  case ffDetails:
    d.detailsWithSketch = false;
    FrmPopupForm(RecordDetailsForm);
    break;

  case ffAlarm:
    recordUnsetCountdown();
    FrmGotoForm(TimeForm);
    break;

  default:
    /* ignore */
  }
}
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
	EventType event;
	Err err = 0;

	switch (cmd) {
	case sysAppLaunchCmdNormalLaunch:
		if(isTheDeviceSupported() == false) {
			FrmAlert(OldAlert);
			break;
		}
		
		FrmGotoForm(MainForm);
		do {
			UInt16 MenuError;
			EvtGetEvent(&event, evtWaitForever);
			if (! SysHandleEvent(&event))
				if (! MenuHandleEvent(0, &event, &MenuError))
					if (! AppHandleEvent(&event))
						FrmDispatchEvent(&event);
		} while (event.eType != appStopEvent);
		break;
	case sysAppLaunchCmdNotify:
		if(((SysNotifyParamType*) cmdPBP)->notifyType==sysNotifyDisplayResizedEvent) {
			EventType resizedEvent;
			MemSet(&resizedEvent,sizeof(EventType),0);
			resizedEvent.eType=winDisplayChangedEvent;
			EvtAddUniqueEventToQueue(&resizedEvent,0,true);
		}
		break;
	default:
		break;
	}    
	return(err);
}
Esempio n. 8
0
File: IntExp.c Progetto: ysei/palmos
static Boolean GraffitiFormHandleEvent(EventPtr event){
  Boolean handled = false;
  switch (event->eType) {
    case frmOpenEvent:
      FrmDrawForm(FrmGetActiveForm());
      handled = true;
      break;
    case keyDownEvent:
      if(event->data.keyDown.chr == sentence[offset]){
        offset++;
        if(offset == StrLen(sentence)){ FrmGotoForm(WinForm); }
      }
      handled = true;
      break;
    case nilEvent: {
      if(offset < StrLen(sentence)){
        updateSprite(&nextLetter);
        drawSprite(&nextLetter);
      }
      handled = true;
      break;
    }
    default:
      break;
  }
  return handled;
}
Esempio n. 9
0
/* Simply goto the main form */
static Err StartApplication
    (
    MemPtr cmdPBP
    )
{
    FrmGotoForm( frmMain );

    return errNone;
}
Esempio n. 10
0
static Err AppStart(UInt16 cmd, void *cmdPBP)
{
    DisplayInitDepth(true);
    
    InitGlobals();
    
    FrmGotoForm(kMainForm);
    return errNone;
}
Esempio n. 11
0
static void
SaveButtonClick (void)
{
  DmOpenRef openRef;
  UInt16 recIndex;
  MemHandle recH;
  Err err;

  if (EditorMidi.dbID == 0) {

    debugPrintf("dbID==0, create a new record in Palmano DB\n");
    /* create new record in palmano DB */
 
    err = getPalmanoDatabase(&openRef, dmModeReadWrite | dmModeExclusive);
    if (err != 0) {
      ErrAlert(err);
      return;
    }

    /* allocate new record in DB */
    recIndex = dmMaxRecordIndex;
    recH = DmNewRecord(openRef, &recIndex, 5); /* initial size is 5 bytes */
    ErrFatalDisplayIf(!recH, "SaveButtonClick(): can't get new record by index!");
  }
  else {
    /* replace old song in-place */

    openRef = DmOpenDatabase (EditorMidi.cardNo, EditorMidi.dbID,
			      dmModeReadWrite | dmModeExclusive);

    ErrFatalDisplayIf(!openRef, "SaveButtonClick(): "
		      "Can't open old song database for record");

    err = DmFindRecordByID(openRef, EditorMidi.uniqueRecID, &recIndex);

    ErrFatalDisplayIf(err, "Can't find record by ID");

    recH = DmGetRecord(openRef, recIndex);

    ErrFatalDisplayIf(!recH, "SaveButtonClick(): "
		      "Can't get old song record for writing");
  }

  // save midi to recH
  GetFieldTextToStr(EditorMidi.name, ID_EditorNameField, sndMidiNameLength);

  debugPrintf("SaveButtonClick(): smfutils_save(recH=%lx, name=%s\n",
	      recH, EditorMidi.name);
  smfutils_save(recH, EditorMidi.name, &notelist);
  debugPrintf("SaveButtonClick(): return from smfutils_save()\n");

  DmReleaseRecord (openRef, recIndex, 1);
  DmCloseDatabase (openRef);
  
  FrmGotoForm(ID_MainForm);
}
Esempio n. 12
0
static void
DropButtonClick (void)
{
  // TODO: alert 
  // Do you want exit without save this song?
  // [ ] Don't ask in future
  // [Yes] [No] [Cancel]

  FrmGotoForm (ID_MainForm);
}
Esempio n. 13
0
Boolean PostListFormEventHandler(EventPtr event)
{
    static FormPtr gpForm;
    UInt16 postCount;

    switch (event->eType) {
    case frmOpenEvent: {
        postCount = 10; // If you exceed 10 you pop a warning and it gets trimmed.
        setup_database();
        FrmDrawForm(gpForm = FrmGetActiveForm());
        UpdatePostsTable(gpForm, postCount);

        return true;
    }
    case frmCloseEvent: {
        FrmEraseForm(gpForm);
        FrmDeleteForm(gpForm);
        return true;
    }
    case ctlSelectEvent: {
        switch (event->data.ctlSelect.controlID) {
        case HelpButton: {
            FrmCustomAlert(TheError,
                "Oops, looks like our connection goofed here, try again?",
                NULL, NULL);
            return true;
        }
        case PalmrMainMenuAbout: {
            FrmAlert(AboutAlert);
            return true;
        }
        }
    }
    case tblSelectEvent: {
        int row = event->data.tblSelect.row;
        int column = event->data.tblSelect.column;
        // char strRow[15];
        // char strColumn[15];
        //
        // sprintf(strRow, "%i", row);
        // sprintf(strColumn, "%i", column);

        // AlertPrintf3(
        //     "You selected:",
        //     strRow, strColumn);

        FrmGotoForm(PostViewForm);

        return true;
    }
    default: {
        return false;
    }
    }
}
Esempio n. 14
0
DWord
PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
    if (cmd == sysAppLaunchCmdNormalLaunch)
    {
        StartApplication ();
        FrmGotoForm (mainForm);
        EventLoop ();
        StopApplication ();
    }
    return (0);
}
Esempio n. 15
0
static int
StartApplication (void)
{
    int i;

    // initialize the race strings data
    for (i = 0; i < 11; i++) {
	racestrs[i] = racedata+(128*i);
    }

    FrmGotoForm(fid_kartrando);
    return 0;
}
Esempio n. 16
0
File: IntExp.c Progetto: ysei/palmos
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
  short err;
  EventType e;
  UInt16 obj;
  FieldType *pfld;

  // Make sure only react to NormalLaunch, not Reset, Beam, Find, GoTo...
  if (cmd == sysAppLaunchCmdNormalLaunch) {
    FrmGotoForm(HelpForm);
    AppEventLoop();
    FrmCloseAllForms();
  }
  return 0;
}
Esempio n. 17
0
/*
** Handle 5-way navigation (right).
*/
static Boolean ThumbnailViewHandleFiveWayNavLeft(void) {
  if (!d.fiveWayNavigation) {
    FrmGotoForm(DiddleListForm);
  } else {
    /* Deselect previous item */     
    ToggleButton(d.thumbnailX, d.thumbnailY, false);
    
    /* Select new item, scroll if necessary */
    if (ThumbnailViewMoveCursorLeft())
      ThumbnailViewScroll(-1);        
    UpdateButtonAndIndex();
  }

  return true;
}
Esempio n. 18
0
File: IntExp.c Progetto: ysei/palmos
static Boolean HelpFormHandleEvent(EventPtr event){
  Boolean handled = false;
  switch (event->eType) {
    case frmOpenEvent:
      FrmDrawForm(FrmGetActiveForm());
      handled = true;
      break;
    case keyDownEvent:
      FrmGotoForm(GraffitiForm);
      handled = true;
      break;
    default:
      break;
  }
  return handled;
}
Esempio n. 19
0
File: IntExp.c Progetto: ysei/palmos
static Boolean WinFormHandleEvent(EventPtr event){
  Boolean handled = false;
  switch (event->eType) {
    case frmOpenEvent:
      FrmDrawForm(FrmGetActiveForm());
      handled = true;
      break;
    case ctlSelectEvent:
      if (event->data.ctlSelect.controlID == DoneButton){
        FrmGotoForm(HelpForm);
        handled = true;
      }
    default:
      break;
  }
  return handled;
}
Esempio n. 20
0
/* Get preferences, open (or create) app database */
static UInt16 StartApplication(void)
{
        UInt32 romversion;
        UInt16 err;

        err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romversion);

        /* We *must* be version 2 or greater */
        if( err || (romversion < 0x02003000) ) {
                FrmAlert(alertVersion);
                return(1);
        }

        FrmGotoForm(MainForm);
        LoadPrefs();
        return 0;
}
Esempio n. 21
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. 22
0
/* 
** Handle 5-way navigation select.
*/
static Boolean ThumbnailViewHandleFiveWayNavSelect(void) {
  if (d.records_in_cat) {
    if (!d.fiveWayNavigation) {
      d.fiveWayNavigation = true;
      
      if (p.dbI == noRecordSelected)
    p.dbI = d.top_visible_record;
      
      MapIndexToCoordinates(&p.dbI, &d.thumbnailX, &d.thumbnailY);
      ToggleButton(d.thumbnailX, d.thumbnailY, true);       
    } else {
      d.fiveWayNavigation = false;
      p.dbI = MapCoordinatesToIndex(d.thumbnailX, d.thumbnailY);
      FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
    }
  }
  
  return true;
}
Esempio n. 23
0
int start_application(void) {

  int error = 0;

  // Initialize the runtime system
  init_runtime_system();

  // Get system-wide preferences. ri_sim does not need that.

  // Find the application's data file. If it doesn't exist, create it.

  // Get application-specific preferences.

  // Initialize other global variables.

  FrmGotoForm(formID_main_ri_sim);

  return error;
}
Esempio n. 24
0
/* Get preferences, open (or create) app database */
static UInt16 StartApplication(void)
{
    UInt16 prefsize,i;
    /* Fetch application preferences */
    prefsize = sizeof(stopWatchPreferenceType);
    i = PrefGetAppPreferences('StWt', 0, &stopWatchPrefs, &prefsize, true);

    /* If no prefs were found, reset all values. */
    if (noPreferenceFound == i) {
        //DEBUGBOX("no prefs","");
        stopWatchPrefs.timestamp = 0;
        stopWatchPrefs.vol=10;
        stopWatchPrefs.sound=btnSound2;
        stopWatchPrefs.visual=btnVisualNum;
        stopWatchPrefs.disableAutoOff = 1;
    }

    FrmGotoForm(MainForm);
    return 0;
}
Esempio n. 25
0
// All form-related events are handled here.
static Boolean ri_sim_event(EventPtr event){
  FormPtr form;
  int handled = 0;

  switch (event->eType)   {
  case frmOpenEvent:
    form = FrmGetActiveForm();
    FrmDrawForm(form);
    draw_histogram(0,region_stack_idx-1);
    handled = 1;
    break;

  case ctlSelectEvent:  // A control button was pressed and released.
    switch (event->data.ctlSelect.controlID) {
    default: break;
    }

  case menuEvent:
    switch (event->data.menu.itemID)    {
    case menuitemID_about:
      FrmAlert(alertID_about);
      handled = 1;
      break;
    case menuitemID_card_info:
      // form = FrmGetActiveForm();
      // FrmDeleteForm(form);
      FrmGotoForm(formID_sys_info);
      break;
    }
    break;

  case nilEvent:
    // continue region simulation
    sim_regs();
    update_form_main_ri_sim();
    handled = 1;
    break;
  }
  return handled;
}
Esempio n. 26
0
File: IntExp.c Progetto: ysei/palmos
static void AppEventLoop(void){
  EventType event;
  short error;
  UInt16 nilEvents;
  do {
    EvtGetEvent(&event, 25);
    if (MenuHandleEvent(NULL, &event, &error)) { nilEvents=0; continue; }
    if (AppHandleEvent(&event)){ if(event.eType!=nilEvent){nilEvents=0;} continue; }
    if (SysHandleEvent(&event)) { nilEvents=0; continue; }
    if (event.eType == nilEvent){
      nilEvents++;
      if(nilEvents++ > 40 * 60){
        nilEvents = 0;
        if(FrmGetActiveFormID()!=HelpForm){
          FrmGotoForm(HelpForm);
        }
        continue;
      }
    }
    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Esempio n. 27
0
// *************************************************************************
// Event handler for the Current Ship screen
// ********************************************************************
Boolean CurrentShipFormHandleEvent( EventPtr eventP )
{
    Boolean handled = false;

	switch (eventP->eType) 
	{

		case frmOpenEvent:
		case frmUpdateEvent:
			DrawCurrentShipForm();
			handled = true;
			break;

		case ctlSelectEvent:
			if (eventP->data.ctlSelect.controlID == CurrentShipStatusButton)
			{
				CurForm = CommanderStatusForm;
			}
			else if (eventP->data.ctlSelect.controlID == CurrentShipQuestsButton)
			{
				CurForm = QuestsForm;
			}
			else if (eventP->data.ctlSelect.controlID == CurrentShipSpecialButton)
			{
				CurForm = SpecialCargoForm;
			}
			
			FrmGotoForm( CurForm );
			handled = true;
			break;
			
		default:
			break;
	}
	
	return handled;
}
Esempio n. 28
0
// All form-related events are handled here.
static Boolean sys_info_event(EventPtr event){
  FormPtr form;
  int handled = 0;

  switch (event->eType)   {
  case frmOpenEvent:
    form = FrmGetActiveForm();
    FrmDrawForm(form);
    mem_card_info(form);
    handled = 1;
    break;

  case ctlSelectEvent:  // A control button was pressed and released.
    switch (event->data.ctlSelect.controlID) {
    case pushbottomID_card1: cardNo = 1; handled = 1; break;
    case pushbottomID_card2: cardNo = 2; handled = 1; break;
    case pushbottomID_card3: cardNo = 3; handled = 1; break;
    case pushbottomID_card4: cardNo = 4; handled = 1; break;
    case pushbottomID_card5: cardNo = 5; handled = 1; break;
    case pushbottomID_card6: cardNo = 6; handled = 1; break;
    case buttonID_show_card_info: show_card_info(); handled = 1; break;
    case buttonID_show_heap_info: show_heap_info(); handled = 1; break;
    case buttonID_sys_info_done: 
      // form = FrmGetActiveForm();
      // FrmDeleteForm(form); Done automatically by FrmGotoForm via event frmCloseEvent
      FrmGotoForm(formID_main_ri_sim);
      break;
    default: break;
    }

  case nilEvent:
    // continue region simulation
    handled = 1;
    break;
  }
  return handled;
}
Esempio n. 29
0
/**********************************************************************************
 * Function: PilotMain
 * Description: this is the function that is acctually called by the PalmOS when
 * application start and other events occur. we handle those system launch events
 * here
 * *******************************************************************************/ 
UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) 
{
	Err err = 0;
	
		// request to start application normally
		if (cmd == sysAppLaunchCmdNormalLaunch)
		
	{
#if ((defined DEBUG) && (defined HAVE_GDBHOOK))	
	_gdb_hook();
#endif 
			// call StartApplication to initialize things, 
			// go to the opening form and enter the event loop,
			// until end.
			if ((err = StartApplication ()) == 0)
			
		{
			FrmGotoForm (PasswordForm);
			EventLoop ();
			StopApplication ();
		}
	}
	return cmd;
}
Esempio n. 30
0
void stub_enter_siteswap(void) {
  //FrmCustomAlert(Info, "enter siteswap stub", 0,0);
  set_pause();
  FrmGotoForm(EnterSiteswapForm);
}