Example #1
0
/* Rename document name in document list */
void UpdateDocumentName
    (
    UInt16      index,  /* record index */
    const Char* name,   /* new document name */
    const Char* filename  /* new filename */
    )
    /* THROWS */
{
    MemHandle       handle;
    DocumentData*   handlePtr;

    THROW_IF( name == NULL || *name == '\0', errNoDocumentName );

    handle = OpenRecord( plkrDocList, index );
    THROW_IF( handle == NULL, DmGetLastErr() );

    handlePtr = MemHandleLock( handle );
    DmWrite( handlePtr, OFFSETOF( DocumentData, name ),
        name, StrLen( name ) + 1 );
    if ( handlePtr->location != RAM ) {
        DocumentData*   dataPtr;
        UInt16          infoSize;
        UInt16          dataSize;
        Char            volumeLabel[ LABEL_LEN ];
        UInt16          fileLength;
        UInt16          volumeLabelLength;

        fileLength          = StrLen( handlePtr->data ) + 1;
        volumeLabelLength   = StrLen( handlePtr->data + fileLength ) + 1;
        StrNCopy( volumeLabel, handlePtr->data + fileLength,
            volumeLabelLength );

        MemHandleUnlock( handle );

        infoSize = sizeof *dataPtr;
        dataSize = StrLen( filename ) + StrLen( volumeLabel ) + 2;

        handle  = ResizeRecord( plkrDocList, index, infoSize + dataSize );
        dataPtr = MemHandleLock( handle );
        DmWrite( dataPtr, infoSize, filename, StrLen( filename ) + 1 );
        DmWrite( dataPtr, infoSize + StrLen( filename ) + 1, volumeLabel,
            StrLen( volumeLabel ) + 1 );
    }
    MemHandleUnlock( handle );
    CloseRecord( handle, true );
    DmInsertionSort( plkrDocList, CompareDocumentNames, 0 );
}
Example #2
0
/* Populate document list with records */
static void UpdateDocList( void )
    /* THROWS */
{
    /* no automatic update if user has selected to handle it manually
       or if we have a low power situation */
    if ( Prefs()->syncPolicy == SYNC_MANUAL || ! HasEnoughPower() )
        return;

    SpeedFaster();

    /* create list for documents that have been deleted since the last
       session */
    CreateRemoveList();

    ErrTry {
        /* find all Plucker documents in RAM */

        EnumerateRAM();

        /* ... and on mounted external cards */
        if ( Prefs()->syncPolicy != SYNC_IGNORE_CARD ) {
#ifdef SUPPORT_VFS_FONTS
            if ( ! ScannedVFSFonts() ) {
                EnumerateCards( ENUMERATECARD_DOCS | ENUMERATECARD_FONTS );
                PostprocessVFSFonts();
            }
            else
#endif
            {
                EnumerateCards( ENUMERATECARD_DOCS );
            }
        }

        /* clean up */
        DeactivateDocuments();

        DmInsertionSort( plkrDocList, CompareDocumentNames, 0 );
    }
    ErrCatch( err ) {
        ReleaseDeactivateList();
        ErrThrow( err );
    } ErrEndCatch

    SpeedRestore();
}
Example #3
0
/***********************************************************************
 *
 * FUNCTION:    ThumbnailViewHandleEvent
 *
 * DESCRIPTION: This routine is the event handler for the "Thumbnail View"
 *              of the Record application.
 *
 * 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 ThumbnailViewHandleEvent (EventPtr event) {
  FormPtr frm = NULL;
  Boolean handled = false;

  switch (event->eType) {
  case keyDownEvent:
    /* Hardware button pressed? */
    if (TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr)) {
      if (!(event->data.keyDown.modifiers & poweredOnKeyMask))
    ThumbnailViewNextCategory();
      handled = true;
    } else if (EvtKeydownIsVirtual(event)) {
      switch (event->data.keyDown.chr) {
      case vchrPageUp:
      case vchrRockerUp:
    if (d.fiveWayNavigation) {
      /* Deselect previous item */
      ToggleButton(d.thumbnailX, d.thumbnailY, false);
      
      /* Select new item, scroll if necessary */
      if (ThumbnailViewMoveCursorUp())
        ThumbnailViewScroll(-1);
      UpdateButtonAndIndex();
    } else {
      ThumbnailViewPageScroll(winUp);
    }
    handled = true;
    break;

      case vchrPageDown:
      case vchrRockerDown:
    if (d.fiveWayNavigation) {
      /* Deselect previous item */
      ToggleButton(d.thumbnailX, d.thumbnailY, false);
      
      /* Select new item, scroll if necessary */
      if (ThumbnailViewMoveCursorDown())
        ThumbnailViewScroll(1);
      UpdateButtonAndIndex();
    } else {
      ThumbnailViewPageScroll(winDown);
    }
    handled = true;
    break;
    
    /* Treo 600 5-way navigation */
      case vchrRockerCenter:
    handled = ThumbnailViewHandleFiveWayNavSelect();
    break;
      case vchrRockerLeft:
    handled = ThumbnailViewHandleFiveWayNavLeft();
    break;
      case vchrRockerRight:
    handled = ThumbnailViewHandleFiveWayNavRight();
    break;

    /* Tungsten 5-way navigation */
      case vchrNavChange:
    if (NavDirectionPressed(event, Left))
      handled = ThumbnailViewHandleFiveWayNavLeft();
    else if (NavDirectionPressed(event, Right))
      handled = ThumbnailViewHandleFiveWayNavRight();
    else if (NavSelectPressed(event))
      handled = ThumbnailViewHandleFiveWayNavSelect();
    break;

/*       case vchrSendData: */
/*  ThumbnailViewDoCommand(ThumbnailRecordBeamCategoryCmd); */
/*  handled = true; */
/*  break; */

      default:
    /* ignore */
      }
    }
    break;

  case ctlSelectEvent:
    switch (event->data.ctlSelect.controlID) {
    case NewButton:
      /* Create new sketch after all existing ones */
      p.dbI = DmNumRecords(d.dbR);

      AllocImage();
      FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
      handled = true;
      break;

    case CategoryPop:
      ThumbnailViewSelectCategory();
      handled = true;
      break;

    case TextListButton:
      FrmGotoForm(DiddleListForm);
      handled = true;
      break;

    case ThumbnailDetailListButton:
      FrmGotoForm(DiddleThumbnailDetailForm);
      handled = true;
      break;
    }
    break;

  case frmGotoEvent:
    p.dbI = event->data.frmGoto.recordNum;
    SwitchCategoryForGoto();
    FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
    event->eType = dbOpenRecordFieldEvent;
    EvtAddEventToQueue(event);

    handled = true;
    break;

  case menuEvent:
    {
      Char chr = 0;

      switch(event->data.menu.itemID) {
      case menuitemID_CmdAbout:
    DoAboutDialog();
    handled = true;
    break;

      case menuitemID_CmdSecurity:
    ThumbnailDoCmdSecurity();
    handled = true;
    break;

      case menuitemID_CmdSortByAlarm:      
      case menuitemID_CmdSortByName:
    if (event->data.menu.itemID == menuitemID_CmdSortByAlarm)
      DmInsertionSort(d.dbR, &SortByAlarmTime, 0);
    else
      DmInsertionSort(d.dbR, &SortByName, 0);

        SetTopVisibleRecord(0);
    ThumbnailViewLoadRecords(FrmGetActiveForm());
    handled = true;
    break;

      case menuitemID_CmdPref: chr=cmdPref; break;
      case menuitemID_CmdExtPref: chr=cmdExtPref; break;
      case menuitemID_CmdHWPref: chr=cmdHWPref; break;
      case menuitemID_CmdAlarmPref: chr=cmdAlarmPref; break;
      case menuitemID_CmdHelp: chr=cmdHelp; break;
      }

      if (!handled)
    handled = KeyDown(chr);
    }
    break;

  case frmOpenEvent:
    frm = FrmGetActiveForm();
    ThumbnailViewInit(frm);
    FrmDrawForm(frm);

    /* Disable 5-way navigation initially */
    d.fiveWayNavigation = false;

    /* Clean up */
    if (d.record_name) MemHandleFree(d.record_name);
    d.record_name = NULL;
    if (d.record_note) MemHandleFree(d.record_note);
    d.record_note = NULL;

    handled = true;
    break;

  case frmUpdateEvent:
    handled = ThumbnailViewUpdateDisplay(event->data.frmUpdate.updateCode);
    break;

  case menuCmdBarOpenEvent:
    MenuCmdBarAddButton(menuCmdBarOnLeft, BarSecureBitmap,
            menuCmdBarResultMenuItem, menuitemID_CmdSecurity, 0);

    /* Tell the field package to not add buttons automatically; */
    /* we've done it all ourselves.                             */
    event->data.menuCmdBarOpen.preventFieldButtons = true;

    /* don't set handled to true; this event must fall through to the system. */
    break;

  case sclRepeatEvent:
    ThumbnailViewScroll (event->data.sclRepeat.newValue - event->data.sclRepeat.value);
    break;

  case dbNonKeyCommandEvent:
    handled = HandleNonKeyCommandCode(event->data.menu.itemID);
    break;

/*   case frmObjectFocusTakeEvent: */
/*     { */
/*       RectangleType r; */
/*       FormType* frm = FrmGetFormPtr(event->data.frmObjectFocusTake.formID); */
/*       const UInt16 id = event->data.frmObjectFocusTake.objectID; */
/*       const UInt16 idx = FrmGetObjectIndex(frm, id); */

/*       if (id >= Thumb1 && id <= Thumb30) { */
/*  FrmGetObjectBounds(frm, idx, &r); */
/*  FrmSetFocus(frm, idx); */
/*  HsNavDrawFocusRing(frm, id, hsNavFocusRingNoExtraInfo, &r, */
/*             hsNavFocusRingStyleObjectTypeDefault, false); */
/*  handled = true; */
/*       } */
/*     } */
/*     break; */

  default:
    /* do nothing */
  }

  return handled;
}