Boolean CGameForm::OnInstructions(EventType* pEvent, Boolean& bHandled) { FrmHelp(InstructionsString); bHandled = false; return true; }
static Boolean MainFormHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); DrawIntro(); FrmDrawForm(frm); DrawState(); // Draw those dice! handled = true; break; case frmUpdateEvent: DrawPlayers(); break; case menuEvent: MenuEraseStatus(NULL); switch(e->data.menu.itemID) { case MenuItem_Help: FrmHelp( GenericHelp ); break; case MenuItem_About: FrmAlert(About_Info); break; case MenuItem_New: DialogNewGame(); break; case MenuItem_Reset: ResetCubes(); DrawState(); break; case MenuItem_Defaults: Defaults(); ResetCubes(); DrawState(); break; case MenuItem_Variants: if ( GetCurrPlayer() < 0 ) { DialogVariants(); } else { FrmAlert(NoVariants); } break; case MenuItem_Preferences: DialogPreferences(); break; } handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case btn_Stay: ShowButtons(false); Stay(); break; case btn_Info: //FrmAlert(About_Info); DialogStatus(); break; case btn_Roll: if ( isGameOn() ) { ShowButtons(false); Roll(); } else { DialogNewGame(); } break; case btnTopStatus: FrmHelp( TS_LastLicks ); break; } handled = true; break; case winExitEvent: if( e->data.winExit.exitWindow == (WinHandle)FrmGetFormPtr(MainForm) ) { /* Turn off animations and the AI */ FreezeBit = true; } break; case winEnterEvent: if (e->data.winEnter.enterWindow == (WinHandle)FrmGetFormPtr(MainForm) && e->data.winEnter.enterWindow == (WinHandle)FrmGetFirstForm ()) { /* Turn back on animations and the AI */ FreezeBit = false; } default: break; } return handled; }
Boolean CBiddingForm::OnHelp(EventPtr pEvent, Boolean& bHandled) { FrmHelp(InstructionsString); return true; }
static Boolean MainFormHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; static UInt32 start_sec=0; static UInt32 start_tik; static UInt32 end_sec; static UInt32 end_tik; //static int run = 0; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); // resume interrupted count // note now stopWatchPrefs.tik_timestamp != stopWatchPrefs.timestamp // now this does work okay when switching away from app BUT // not when palm is turned off & on but stays in app // I think possibly GetTicks gets ticks from start of app // when palm off the ticks do not increment if (stopWatchPrefs.timestamp != 0) { stopWatchPrefs.tik_timestamp = TimGetSeconds(); start_tik = TimGetTicks(); RunCount(start_tik); } handled = true; break; case menuEvent: MenuEraseStatus(NULL); switch(e->data.menu.itemID) { // TODO add to TestTemp code //case itemBar: case itemRun: if (start_sec == 0) { stopWatchPrefs.tik_timestamp = stopWatchPrefs.timestamp = start_sec = TimGetSeconds(); start_tik = TimGetTicks(); } RunCount(start_tik); break; case itemHold: // break the run loop run = 0; break; case itemStop: // break the run loop run = 0; end_sec = TimGetSeconds(); end_tik = TimGetTicks(); break; case itemClear: // break the run loop run = 0; start_sec = 0; stopWatchPrefs.timestamp = 0; stopWatchPrefs.tik_timestamp = 0; end_tik = 0; drawCount(0); break; case itemPrefs: FrmPopupForm(PrefForm); break; case itemTest1: WinDrawLine(20,20,50,50); //void WinDrawChar (WChar theChar, Coord x, Coord y) ///void WinDrawChars (const Char *chars, Int16 len, Coord x, Coord y) //void WinPaintChar (WChar theChar, Coord x, Coord y) //void WinPaintChars (const Char *chars, Int16 len, Coord x, Coord y) ///opt/palmdev/sdk-5/include/Core/System/Window.h // Font.h WinDrawChar('X',20,50); FntSetFont(symbol11Font); WinDrawChar('Y',40,50); FntSetFont(largeFont); WinDrawChar('Z',60,50); WinDrawChars("large Font",10,80,50); FntSetFont(largeBoldFont); WinDrawChars("large Bold",10,110,50); { char buf[100]; int l=0; UInt32 t = SysTicksPerSecond(); l+=StrPrintF(buf+l, "SysTicksPerSec is %lu", t); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,20); } if (0){ digiFontType ft; ft.h = 20; ft.w = 16; ft.th = 4; ft.tw = 7; drawHSeg(11,9,ft,WinDrawLineF); drawVSeg(10,10,ft,WinDrawLineF); drawHSeg(11,36,ft,WinDrawLineF); drawVSeg(39,10,ft,WinDrawLineF); } if (0){ digiFontType ft; ft.h = 20; ft.w = 12; ft.th = 4; ft.tw = 7; drawHSeg(11,59,ft,WinDrawLineF); drawVSeg(10,60,ft,WinDrawLineF); drawVSeg(38,60,ft,WinDrawLineF); drawHSeg(11,79,ft,WinDrawLineF); drawVSeg(10,80,ft,WinDrawLineF); drawVSeg(38,80,ft,WinDrawLineF); drawHSeg(11,99,ft,WinDrawLineF); } bigDigit(5,20,'2',WinDrawLineF); bigDigit(40,20,'5',WinDrawLineF); bigDigit(5,70,'7',WinDrawLineF); break; case itemTest2: bigDigit(5,20,'8',WinEraseLineF); bigDigit(40,20,'8',WinEraseLineF); bigDigit(5,70,'8',WinEraseLineF); WinDrawChars("Hello",5,20,80); WinPaintChars("Paint",5,20,110); //Err err; err = TimInit(); { char buf[100]; int l=0; UInt32 s,t; UInt32 hour,min,sec; UInt32 day; // seconds since 1/1/1904 //void TimSetSeconds(UInt32 seconds) // ticks since power on t = TimGetTicks(); s = TimGetSeconds(); l+=StrPrintF(buf+l, "Secs %lu", s); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,20); l=0; l+=StrPrintF(buf+l, "Ticks %lu", t); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,40); day = s / (UInt32)(24 * 60 * 60); s = s - day * (24 * 60 * 60); hour = s / (60 * 60); s = s - hour * (60 * 60); min = s / 60; sec = s - min * 60; l=0; l+=StrPrintF(buf+l, "%07d:%02d:%02d:%02d", day, hour,min,sec); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,60); } break; // call this periodically to hold off auto off // Err EvtResetAutoOffTimer(void) // SystemMgr.h //Err SysTimerCreate(UInt32 *timerIDP, UInt32 *tagP, // SysTimerProcPtr timerProc, UInt32 periodicDelay, UInt32 param) //Err SysTimerDelete(UInt32 timerID) //Err SysTimerWrite(UInt32 timerID, UInt32 value) //Err SysTimerRead(UInt32 timerID, UInt32 *valueP) // SysTaskDelay((100 * SysTicksPerSecond())/1000); case itemOptHelp: FrmHelp(hlpHelp); break; //case itemOptDbgDump: //debugDump(e->eType); //break; case itemOptCopy: FrmHelp(hlpCopy); break; case itemOptAbout: FrmCustomAlert(alertInfo, "stopWatch v" VERSION " not even Alpha. " "Built " __DATE__ ", " __TIME__ ". " "James Coleman http://www.dspsrv.com/~jamesc " "copyleft me.", "", ""); break; } //DEBUGBOX("menuEvent",""); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case btnRun: if (start_sec == 0) { stopWatchPrefs.tik_timestamp = stopWatchPrefs.timestamp = start_sec = TimGetSeconds(); start_tik = TimGetTicks(); } RunCount(start_tik); break; case btnHold: // break the run loop run = 0; break; case btnStop: // break the run loop run = 0; end_sec = TimGetSeconds(); end_tik = TimGetTicks(); break; case btnClear: // break the run loop run = 0; stopWatchPrefs.timestamp = start_sec = 0; stopWatchPrefs.tik_timestamp = 0; end_tik = 0; drawCount(0); break; } break; //case ctlRepeatEvent: //break; case penDownEvent: case penMoveEvent: doPenAction( e->eType, e->screenX, e->screenY, 0, 0); //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2"); break; case penUpEvent: doPenAction( penUpEvent, e->data.penUp.start.x, e->data.penUp.start.y, e->data.penUp.end.x, e->data.penUp.end.y); break; case keyDownEvent: { char buf[1000]; int l=0; l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr); buf[l]=0; DEBUGBOX("keyDownEvent",buf); } switch(e->data.keyDown.chr) { case pageUpChr: case pageDownChr: handled = true; break; case prevFieldChr: case nextFieldChr: case '\n': handled = true; break; default: if (!TxtCharIsCntrl(e->data.keyDown.chr)) { handled = true; /* Swallow event */ } break; } break; default: break; } return handled; }
/* Event handler for the main form */ Boolean FormHandleEvent ( EventType* event ) { Boolean handled; handled = false; switch ( event->eType ) { case ctlSelectEvent: switch ( event->data.ctlEnter.controlID ) { case frmPrefsButton: if ( buttonList[ PREF ].status == VALID && FrmAlert( confirmPrefs ) == 0 ) HandleButton( &buttonList[ PREF ] ); handled = true; break; case frmTempButton: if ( buttonList[ TEMP ].status == VALID && FrmAlert( confirmTemp ) == 0 ) HandleButton( &buttonList[ TEMP ] ); handled = true; break; case frmDocListButton: if ( buttonList[ DOCLIST ].status == VALID && FrmAlert( confirmDocList ) == 0 ) HandleButton( &buttonList[ DOCLIST ] ); handled = true; break; case frmFontCacheButton: if ( buttonList[ FONTCACHE ].status == VALID && FrmAlert( confirmFontCache ) == 0 ) HandleButton( &buttonList[ FONTCACHE ] ); handled = true; break; case frmDone: { EventType stopEvent; stopEvent.eType = appStopEvent; EvtAddEventToQueue( &stopEvent ); handled = true; break; } case frmWhatIsThis: FrmHelp( strWhatIsThis ); handled = true; break; default: break; } break; case menuEvent: switch ( event->data.menu.itemID ) { case menuHelpWhatIsThis: FrmHelp( strWhatIsThis ); handled = true; break; case menuHelpAbout: { FormType* form; form = FrmInitForm( frmAbout ); FrmDoDialog( form ); FrmDeleteForm( form ); handled = true; break; } } break; case frmOpenEvent: FormInit(); handled = true; break; case frmCloseEvent: FreeMemory(); handled = false; break; default: handled = false; break; } return handled; }
static Boolean MainFormHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); handled = true; break; case menuEvent: MenuEraseStatus(NULL); switch(e->data.menu.itemID) { case itemOptHelp: FrmHelp(stringHelp); break; case itemOptAbout: FrmCustomAlert(alertInfo, "MusicScreen v" VERSION " Beta. " "Built " __DATE__ ", " __TIME__ ". " "programming James Coleman http://www.dspsrv.com/~jamesc " "copyleft me, distribute with source code please.", "", ""); break; } //DEBUGBOX("menuEvent",""); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { } break; //case ctlRepeatEvent: //break; case penDownEvent: case penMoveEvent: doPenAction( e->eType, e->screenX, e->screenY, 0, 0); //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2"); break; case penUpEvent: doPenAction( penUpEvent, e->data.penUp.start.x, e->data.penUp.start.y, e->data.penUp.end.x, e->data.penUp.end.y); break; case keyDownEvent: { char buf[1000]; int l=0; l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr); buf[l]=0; DEBUGBOX("keyDownEvent",buf); } switch(e->data.keyDown.chr) { case pageUpChr: case pageDownChr: handled = true; break; case prevFieldChr: case nextFieldChr: case '\n': handled = true; break; default: if (!TxtCharIsCntrl(e->data.keyDown.chr)) { handled = true; /* Swallow event */ } break; } break; default: break; } return handled; }