Пример #1
0
static char* GetBits()
{
	BitmapType* Bitmap;
	WinHandle Win = WinGetDisplayWindow();
	if (!Win)
		return NULL;

	Bitmap = WinGetBitmap(Win);
	if (!Bitmap)
		return NULL;

	return BmpGetBits(Bitmap);
}
Пример #2
0
/***********************************************************************
 *
 * FUNCTION:    ThumbnailViewLoadGadgets
 *
 * DESCRIPTION: This routine loads sketches into the thumbnail view form
 *              thumbnail gadgets.
 *
 * PARAMETERS:  recordNum index of the first record to display.
 *
 * RETURNED:    nothing
 *
 ***********************************************************************/
static void ThumbnailViewLoadGadgets(FormType* frm) {
  UInt16 row;
  MemHandle recordH;
  DynamicButtonType* btn;
  MemPtr ptr;
  UInt16 attr;
  UInt16 recordNum = d.top_visible_record;
  const UInt16 max = Min(recordsPerPage, d.records_in_cat - d.top_row_pos_in_cat);

  for (row = 0; row < max; row++) {
    /* Get the next record in the current category. */
    recordH = DmQueryNextInCategory (d.dbR, &recordNum, p.category);

    if(row == 0) {
      /* store the position of the first row so we can use */
      /* d.top_row_pos_in_cat + row when drawing           */
      d.top_row_pos_in_cat = recordH ? DmPositionInCategory(d.dbR, recordNum, p.category) : 0;
    }

    btn = (DynamicButtonType*) FrmGetGadgetData(frm, FrmGetObjectIndex(frm, Thumb1 + row));

    /* Store record number */
    btn->value = recordNum;

    /* Clear old internal values */
    btn->selected = false;

    /* Read record attributes */
    DmRecordInfo(d.dbR, recordNum, &attr, NULL, NULL);

    if (attr & dmRecAttrSecret && d.privateRecordStatus == maskPrivateRecords) {
      DrawMaskedRecord(btn->content.bmpW, maskPattern);
    } else {
/*       WinHandle oldH = NULL; */
/*       Err err = 0; */
/*       BitmapType* bmp = BmpCreate(btn->contentRect.extent.x,  */
/*                btn->contentRect.extent.y, 1, NULL, &err); */
/*       if (err) abort(); */

      /* Uncompress thumbnail */
      ptr = MemHandleLock(recordH);
      //      MemMove(BmpGetBits(bmp), ptr + sketchDataOffset, sketchThumbnailSize);
      MemMove(BmpGetBits(WinGetBitmap(btn->content.bmpW)), ptr + sketchDataOffset, sketchThumbnailSize);
      MemHandleUnlock(recordH);

      /* Write thumbnail to content bitmap */
/*       WinPushDrawState(); */
/*       WinSetCoordinateSystem(kCoordinatesNative); */
/*       oldH = WinSetDrawWindow(btn->content.bmpW); */
/*       WinPaintBitmap(bmp, 0, 0); */
/*       WinSetDrawWindow(oldH); */
/*       WinPopDrawState(); */

      /* Clean up */
/*       BmpDelete(bmp); */
    }

    recordNum++;

    /* Show the right gadgets... */
    ShowObject(frm, Thumb1 + row);
  }

  /* ...store the index of the last visible thumbnail... */
  d.lastVisibleThumbnail = row - 1;

  /* ... and hide the rest */
  for (; row < recordsPerPage; row++)
    HideObject(frm, Thumb1 + row);

  /* Update the scroll arrows. */
  ThumbnailViewUpdateScrollers (frm);
}
Пример #3
0
    /* Clear old internal values */
    btnThumb->selected = false;

    /* Read record attributes */
    DmRecordInfo(d.dbR, recordNum, &attr, NULL, NULL);
    private = attr & dmRecAttrSecret && d.privateRecordStatus == maskPrivateRecords;
    
    /* Get a pointer to the record */
    ptr = MemHandleLock(recordH);

    if (private) {
      DrawMaskedRecord(btnThumb->content.bmpW, maskPattern);
    } else {
      /* Uncompress thumbnail */
      MemMove(BmpGetBits(WinGetBitmap(btnThumb->content.bmpW)), ptr + sketchDataOffset, sketchThumbnailSize);
    }

    /* Read the additional alarm info */
    MemMove(&record, ptr, sizeof(DiddleBugRecordType));
    record_name = ptr + sketchDataOffset + record.sketchLength;
    record_note = record_name + StrLen(record_name) + 1;
    
    /* Initialize detail gadgets' content */
    if (!private) {
      /* Sketch name */
      StrNCopy(btnName->content.text, record_name, TITLE_MAX_LEN);
      font = FntGetFont();
      FntSetFont(btnThumb->font);
      TxtGlueTruncateString(btnName->content.text, btnName->contentRect.extent.x);
      FntSetFont(font);
Пример #4
0
/* Draw the actual buttons onto blank bitmaps, and set them as valid
   templates on the silkscreen */
static void DrawButtons( void )
{
    Err       err;
    BitmapPtr silkBitmap;
    BitmapPtr silkBitmapInv;
    WinHandle silkWindow;
    WinHandle silkWindowInv;
    WinHandle origWindow;
    UInt16    i;
    Coord     currentX;
    Coord     currentY;
    Coord     silkX;
    Coord     silkY;

    origWindow = WinGetDrawWindow();

    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        SilkGetTemplateBitmaps( &silkBitmap, &silkBitmapInv, NULL, NULL );
    }
    else {
        SilkGetTemplateBitmaps( NULL, NULL, &silkBitmap, &silkBitmapInv );
    }
    BmpGlueGetDimensions( silkBitmap, &silkX, &silkY, NULL );
    silkWindow = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err );
    silkWindowInv = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err);
    WinSetDrawWindow( silkWindow );
    WinDrawBitmap( silkBitmap, 0, 0 );
    WinSetDrawWindow( silkWindowInv );
    WinDrawBitmap( silkBitmapInv, 0, 0 );

    /* We need to move down the existing silkscreen to make room for our
       own toolbar's buttons */
    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        RectangleType area;
        UInt16        moveY;

        area.topLeft.x = 40;
        area.topLeft.y = 1;
        area.extent.x = 200;
        area.extent.y = 18;
        moveY         = 14;

        WinCopyRectangle( silkWindow, silkWindow, &area,
            area.topLeft.x, moveY, winPaint );
        WinCopyRectangle( silkWindowInv, silkWindowInv, &area,
            area.topLeft.x, moveY, winPaint );
        area.extent.y = moveY;
        WinSetDrawWindow( silkWindow );
        WinEraseRectangle( &area, 0 );
        WinSetDrawWindow( silkWindowInv );
        WinEraseRectangle( &area, 0 );
    }
    currentX = TOOLBAR_START_X;
    currentY = TOOLBAR_START_Y;

    for ( i = 0; i < TOTAL_ICONS; i++ ) {
        MemHandle bitmapH;
        BitmapPtr bitmap;
        Coord     width;
        Coord     height;

        if ( iconList[ i ].resourceId == 0 ) {
            /* This is just a placeholder for our '0' resourced offset image */
            width = 22;
            height = 13;
        }
        else {
            bitmapH = DmGetResource( bitmapRsc, iconList[ i ].resourceId );
            bitmap = MemHandleLock( bitmapH );
            BmpGlueGetDimensions( bitmap, &width, &height, NULL );

            WinSetDrawWindow( silkWindow );
            WinDrawBitmap( bitmap, currentX, currentY );
            WinSetDrawWindow( silkWindowInv );
            WinDrawBitmap( bitmap, currentX, currentY );

            MemPtrUnlock( bitmap );
            DmReleaseResource( bitmapH );
        }

        iconList[ i ].bounds[ currentSilkStatus ].topLeft.x = currentX;
        iconList[ i ].bounds[ currentSilkStatus ].topLeft.y = currentY;
        iconList[ i ].bounds[ currentSilkStatus ].extent.x = width;
        iconList[ i ].bounds[ currentSilkStatus ].extent.y = height;
        WinInvertRectangle( &( iconList[ i ].bounds[ currentSilkStatus ]), 0 );

        /* Because some icons are meant to appear right beside each other,
           they're defined here up top. Everything else is spaced so
           it fits nicely */
        switch ( iconList[ i ].resourceId ) {
            case bmpFind:
            case bmpAutoscrollDecr:
            case bmpAutoscrollStop:
            case bmpLeft:
            case bmpHome:
                currentX += width;
                break;

            default:
                currentX += width;
                if ( currentSilkStatus == HANDERA_SILK_UP )
                    currentX += 3;
                else if ( currentSilkStatus == HANDERA_SILK_DOWN )
                    currentX += 7;
                break;
        }
    }
    WinSetDrawWindow( origWindow );

    silkBitmap = WinGetBitmap( silkWindow );
    silkBitmapInv = WinGetBitmap( silkWindowInv );

    if ( currentSilkStatus == HANDERA_SILK_UP )
        SilkSetTemplateBitmaps( silkBitmap, silkBitmapInv, NULL, NULL );
    else
        SilkSetTemplateBitmaps( NULL, NULL, silkBitmap, silkBitmapInv );

    WinDeleteWindow( silkWindow, false );
    WinDeleteWindow( silkWindowInv, false );
}
Пример #5
0
/*
** FinishXferMode
*/
void FinishXferMode(void) {
  KleenexType kleenex;
  DtbkRepeatInfoType repeat;
  FormType* frm = FrmGetActiveForm();
  SysDBListItemType* pluglistP = NULL;
  Int16 current_plug = -1;
  UInt32 result;
  Boolean is_goto = false;
  Err err = errNone;
  Char cat_name[dmCategoryLength];
  Char* note = NULL;
  UInt16 attr;

  /* Zero the kleenex */
  MemSet(&kleenex, sizeof(KleenexType), 0);

  /* Bail if no plugins installed */
  if (!d.xfer.pluglistH) {
    FrmAlert(NoPluginInstalled);
    return;
  }

  /* Lock the plugin list */
  pluglistP = MemHandleLock(d.xfer.pluglistH);
  current_plug = GetCurrentXferAppListIndex();
  if (current_plug == -1) {
    FrmAlert(NoPluginSelected);
    MemHandleUnlock(d.xfer.pluglistH);
    return;
  }

  /* Set the version */
  if (pluglistP[current_plug].version & IBVERSION_PICTURE)
    kleenex.version = IBVERSION_PICTURE;
  else if (pluglistP[current_plug].version & IBVERSION_ORIG)
    kleenex.version = IBVERSION_ORIG;
  else
    abort();
  /* Add flag notifier */
  kleenex.version |= IBVERSION_FLAGS;

  /* Set flags */
  if (d.hires) 
    kleenex.flags = IBFLAG_HIRES;
  
  /* Set the current record index */
  kleenex.sketchRecordNum = p.dbI;

  /* Set the pick text */
  kleenex.text = GetLink(FldGetTextPtr(GetObjectPointer(frm, XferField)));
  if (!kleenex.text) {
    FlashWaitMessage(XferNoTextString);
    MemHandleUnlock(d.xfer.pluglistH);
    return;
  }
  
  /* Set the title text */
  kleenex.title = MemHandleLock(d.record_name);

  /* Set the category text */
  DmRecordInfo(d.dbR, p.dbI, &attr, NULL, NULL);
  CategoryGetName(d.dbR, attr & dmRecAttrCategoryMask, cat_name);
  kleenex.category = cat_name;

  /* Set the note */
  note = MemHandleLock(d.record_note);
  if (StrLen(note))
    kleenex.note = note;

  /* Set the seconds for the alarm */
  if (recordIsAlarmSet) 
    kleenex.alarm_secs = d.record.alarmSecs;

  /* Set the repeat information */
  kleenex.repeat = &repeat;
  switch (d.record.repeatInfo.repeatType) {
  case repeatDaily:
  case repeatWeekly:
  case repeatMonthlyByDay:
  case repeatMonthlyByDate:
  case repeatYearly:
    repeat.repeatType = d.record.repeatInfo.repeatType - 1; /* fix offset caused by repeatHourly */
    repeat.repeatFrequency = d.record.repeatInfo.repeatFrequency;
    repeat.repeatEndDate = d.record.repeatInfo.repeatEndDate;
    repeat.repeatOn = d.record.repeatInfo.repeatOn;
    repeat.repeatStartOfWeek = d.record.repeatInfo.repeatStartOfWeek;
    break;
  case repeatNone:
  case repeatHourly:
  default:
    kleenex.repeat = NULL;
  }

  /* Set the priority */
  kleenex.priority = d.record.priority + 1; /* DiddleBug priority is zero-based */

  /* Set the completion flag */
  if ((d.xfer.complete || (xferCompleteIsAlways)) && !(xferCompleteIsNever)) 
    kleenex.is_complete = 1;
  else
    kleenex.is_complete = 0;

  /* Load the sketch data */
  if (kleenex.version & IBVERSION_PICTURE) {
    if (!d.sonyClie || !d.hires) {
      kleenex.data = BmpGetBits(WinGetBitmap(d.winbufM));
      kleenex.data_size = BmpBitsSize(WinGetBitmap(d.winbufM));
    } else {
      kleenex.data = BmpGetBits(WinGetBitmap(d.winbufM));
      kleenex.data_size = HRBmpBitsSize(d.sonyHRRefNum, WinGetBitmap(d.winbufM));
    }
  }

  /* Call the plugin */
  err = SysAppLaunch(pluglistP[current_plug].cardNo,
		     pluglistP[current_plug].dbID, 0,
		     boogerPlugLaunchCmdBlowNose, (MemPtr)&kleenex, &result);

  /* Clean up some stuff */
  MemHandleUnlock(d.xfer.pluglistH);
  MemPtrFree(kleenex.text);
  if (err || result) {
    FrmAlert(PluginError);
    return;
  }

  /* Just to save some typing */
  is_goto = (((p.flags&PFLAGS_XFER_GOTO) || (xferGotoIsAlways)) &&
	     !(xferGotoIsNever));

  if (!is_goto)
    FlashWaitMessage(XferSavingString);
  
  /* Clean up some more */
  MemHandleUnlock(d.record_name);
  MemHandleUnlock(d.record_note);

  /* Delete the sketch if selected */
  if (p.flags&PFLAGS_XFER_DELETE)
    DoCmdRemove();

  /* Goto the new sketch if required */
  if (is_goto) {
    /* Clean up */
    MemHandleFree(d.xfer.pluglistH);
    d.xfer.pluglistH = NULL;
    
    /* Switch to other application */
    err = SysUIAppSwitch(kleenex.booger.cardNo, kleenex.booger.dbID,
			 kleenex.booger.cmd, kleenex.booger.cmdPBP);
    
    /* Clean up on error */
    if (err && kleenex.booger.cmdPBP) 
      MemPtrFree(kleenex.booger.cmdPBP);
  } else {
    if (kleenex.booger.cmdPBP) 
      MemPtrFree(kleenex.booger.cmdPBP);
  }

  CancelXferMode();
}
Пример #6
0
/*
** DrawPlugButton
*/
void DrawPlugButton(DynamicButtonType* btn) {
  Char str[48], str2[48];
  Int16 i = -1;
  WinHandle oldH = WinSetDrawWindow(btn->content.bmpW);

  /* Set up draw state */
  WinPushDrawState();
  WinSetBackColor(0); /* otherwise the pixels will not count as "off" */

  if (d.xfer.pluglistH && ((i = GetCurrentXferAppListIndex()) != -1)) {
    BitmapType* bmp = NULL;
    BitmapTypeV3* bmpV3 = NULL;
    WinHandle tmpH = NULL;
    Coord x, y;
    UInt32 depth;
    Err err = errNone;

    /* Hi-res 1-bpp-bug-workaround, part 1 */
    if (d.hires && !d.sonyClie) {
      /* Create a new temporary bitmap with screen depth */
      BmpGetDimensions(btn->bmp, &x, &y, NULL);
      WinScreenMode(winScreenModeGet, NULL, NULL, &depth, NULL);
      bmp = BmpCreate(x, y, depth, NULL, &err);
      if (err) abort();

      /* ...make it a double density bitmap */
      bmpV3 = BmpCreateBitmapV3(bmp, kDensityDouble, BmpGetBits(bmp), NULL);

      /* ...and create a temporary window */
      tmpH = WinCreateBitmapWindow((BitmapType*) bmpV3, &err);
      if (err) abort();

      /* Draw to temporary window for the time being... */
      WinSetDrawWindow(tmpH);

      /* ...and set the right foreground color */
      WinSetForeColor(WinRGBToIndex(&black));
    }

    /* Get the plugin icon and draw it */
    DrawPlugBitmap(i, boogerID_button, 0, 0);

    /* Hi-res 1-bpp-bug-workaround, part 2 */
    if (d.hires && !d.sonyClie) {
      /* Copy the icon to the actual button */
      WinSetDrawWindow(btn->content.bmpW);
      WinPaintBitmap(WinGetBitmap(tmpH), 0, 0);

      /* Clean up */
      if (tmpH) WinDeleteWindow(tmpH, false);
      if (bmpV3) BmpDelete((BitmapType*) bmpV3);
      if (bmp) BmpDelete(bmp);
    }

    /* Load "goto" behavior */
    GetPlugString(i, boogerID_gotobehavior, str);
    if (StrChr(str, 'n')) 
      xferGotoSetNever();
    else if (StrChr(str, 'a')) 
      xferGotoSetAlways();
    else
      xferGotoClear();

    /* Load "completion" behaviour ("completion" is never on by default (yet)) */
    GetPlugString(i, boogerID_completebehavior, str2);
    if (StrChr(str2, 'a')) 
      xferCompleteSetAlways();
    else if (StrChr(str2, 'o')) 
      xferCompleteClear();
    else
      xferCompleteSetNever();
  } else {
    DrawBitmap(XferNoAppBitmap, 0, 0);
    xferGotoClear();
    xferCompleteClear();
  }

  /* Restore old draw window & state */
  WinPopDrawState();
  WinSetDrawWindow(oldH);
}
Пример #7
0
Boolean v4pDisplayInit(int quality, Color background) {
  bgColor=background;
  buffer = BmpGetBits(WinGetBitmap(WinGetDisplayWindow()));
}
Пример #8
0
static void clear (UInt8 color)
{
	MemSet (BmpGetBits(WinGetBitmap(buffer)), 160 * (160 * BPP / 8), color);
}