Exemple #1
0
/***********************************************************************
 *
 * FUNCTION:    RepeatHandleEvent
 *
 * DESCRIPTION: This routine is the event handler for the "Repeat
 *              Dialog Box".
 *
 * PARAMETERS:  event  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event was handled and should not be passed
 *              to a higher level handler.
 *
 ***********************************************************************/
Boolean RepeatHandleEvent (EventType* event) {
  Boolean handled = false;

  if (event->eType == ctlSelectEvent) {
    switch (event->data.ctlSelect.controlID) {
      
    case RepeatOkButton:
      RepeatApply();
      /* Fall through... */
    case RepeatCancelButton:
      /* ...to system */
      break;

    case RepeatNone:
    case RepeatHourly:
    case RepeatDaily:
    case RepeatWeekly:
    case RepeatMonthly:
    case RepeatYearly:
      RepeatChangeType(event);
      handled = true;
      break;
      
    case RepeatDayOfWeek1PushButton:
    case RepeatDayOfWeek2PushButton:
    case RepeatDayOfWeek3PushButton:
    case RepeatDayOfWeek4PushButton:
    case RepeatDayOfWeek5PushButton:
    case RepeatDayOfWeek6PushButton:
    case RepeatDayOfWeek7PushButton:
      RepeatChangeRepeatOn(event);
      handled = true;
      break;

    case RepeatByDayPushButton:
    case RepeatByDatePushButton:
      RepeatDrawDescription(FrmGetFormPtr(RepeatForm));
      handled = true;
      break;
    }
  } else if (event->eType == keyDownEvent &&
	     !TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr) && 
	     !EvtKeydownIsVirtual(event)) {
    const WChar chr = event->data.keyDown.chr;
    if (TxtCharIsDigit(chr) || TxtCharIsCntrl(chr)) {
      Boolean noSelection = true;
      UInt16 startPos = 0;
      UInt16 endPos = 0;
      FormType* frm = FrmGetFormPtr(RepeatForm);
      FieldType* fld = GetObjectPointer(frm, RepeatFrequenceField);

      FldGetSelection(fld, &startPos, &endPos);
      noSelection = startPos == endPos;
      FldHandleEvent(fld, event);

      /*
      ** There are 3 ways that the repeat every value can be
      ** updated
      **	1) by the soft keyboard (on silkscreen)
      **	2) via graffiti entry in the form with a selection range
      ** 	3) via graffiti entry in the form with no selection range
      **	   (i.e. just an insertion cursor)
      ** Methods 1 & 2 result in a fldChangedEvent being posted so the
      ** update will be handled in response to that event.  ONLY when
      ** there is no selection range replacement, do we do the update here
      ** to avoid a double redraw of the description field.
      */
      if (noSelection)
	RepeatDrawDescription(frm);
    }

    handled = true;

  } else if (event->eType == fldChangedEvent) {
    /*
    ** When the user changes the "repeat every" value via the
    ** soft keyboard or in the form via a selection replacement
    ** a fldChangedEvent is posted. Update the description in
    ** response.
    */
    RepeatDrawDescription(FrmGetFormPtr(RepeatForm));

    handled = true;

  } else if (event->eType == popSelectEvent) {
    if (event->data.popSelect.listID == RepeatEndOnList) {
      RepeatSelectEndDate (event);
      handled = true;
    }
  }

  return handled;
}
Exemple #2
0
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;
}
Exemple #3
0
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;
}