示例#1
0
bool handleProcessSoftKeyStroke(PointType * start, PointType * end)
{
   Err err;
   UInt32 romVersion;
   RexxletHackPrefs * prefs = 0;
   
   // For romVersion-specific behavior.
   FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
   if (romVersion < sysMakeROMVersion(3, 0, 0, sysROMStageRelease, 0)) {
      goto passthru;
   }

   // Avoid re-entering, only because there's typically not enough
   // stack space to handle this.  If we did our own stack, then maybe...
   UInt32 isRexxletRunning = 0;
   err = FtrGet(CREATORID, FEATURE_ISREXXLETRUNNING, &isRexxletRunning);
   if (err == errNone && isRexxletRunning == 1) { goto passthru; }
   
   // Set prefs and check to see if this is our custom penstroke.
   // If not, pass it thru.
   prefs = RexxletHackPrefs__ctor();
   Int16 strokeIndex = myStroke(start, end, prefs);
   if (strokeIndex == -1) { goto passthru; }
   StrokeDescriptor * stroke = RexxletHackPrefs__strokeDescriptor(prefs, strokeIndex);

   // Set up the Rexxlet launch code's param type.
   struct RexxAppLaunchRexxletParamType r;
   MemSet((void *)&r, sizeof(struct RexxAppLaunchRexxletParamType), 0);
   r.iflags.pauseWhenDone = stroke->flags.pauseWhenDone;
   r.iflags.copyAndPaste = stroke->flags.copyAndPaste;  
   r.iflags.defaultInput = stroke->flags.defaultInput;
   r.iflags.defaultOutput = stroke->flags.defaultOutput;
   r.iflags.defaultError = stroke->flags.defaultError;  
   r.script = RexxletHackPrefs__url(prefs, strokeIndex + 1);
   // allow a null script...it will pop up the url dialog to prompt for one
   //   if (r.script == 0 || StrLen(r.script) == 0) {
   //      goto passthru;
   //   }
   r.iflags.args = stroke->flags.args;
   if (stroke->flags.args == RexxAppLaunchRexxletParamType::ARGS_SELECTION) {
      FieldType * activeField = MyFrmGetActiveField();
	   if (activeField) {
	      UInt16 startPosition, endPosition;
	      FldGetSelection(activeField, &startPosition, &endPosition);
	      Int32 len = endPosition - startPosition;
	      if (len > 0) {
	         char * p = FldGetTextPtr(activeField);
	         if (p) {
	            r.args = (char *)MemPtrNew(len + 1);
	            if (r.args) {
	               MemMove(r.args, &p[startPosition], len);
	               r.args[len] = '\0';
	            }
	         }
	      }
	   }
   }

   // no more literal scripts...could be done if we really wanted, e.g.,
   // not in the configuration (we don't want to store scripts in prefs),
   // but instead to allow the user to use the current selection as the script,
   // much in the same way we allow the clipboard, e.g., selection:   
   // r.script = "say \"This is the identity Rexxlet! Enter something to return, and press Enter when done:\"; parse pull x; return x";
   // r.script = "say \"Please enter numbers to add and press Enter when done:\"; parse pull n; r=0; do i=1 to words(n); if datatype(word(n,i))=\"NUM\" then r=r+word(n,i); end; return r";
   // r.script = "parse arg s; say s; return s";  // PGR idea:  use currently selected text!
   
   if (romVersion < sysMakeROMVersion(5, 0, 0, sysROMStageRelease, 0)) {
      EvtFlushNextPenStroke();
   }
   
   // Remember that a rexxlet is active because we're not
   // going to allow then to be "stacked" for now...not enough stack space!
	FtrSet(CREATORID, FEATURE_ISREXXLETRUNNING, 1);
   Rexxlet(r);
	FtrSet(CREATORID, FEATURE_ISREXXLETRUNNING, 0);
		
	if (r.args && stroke->flags.args == RexxAppLaunchRexxletParamType::ARGS_SELECTION) {
	   MemPtrFree(r.args);
	}
	if (prefs) { RexxletHackPrefs__dtor(prefs); }
	return true;
	
passthru:   
	if (prefs) { RexxletHackPrefs__dtor(prefs); }
	return false;
}
示例#2
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;
}