예제 #1
0
WinHandle
_WinCreateBitmapWindow(BitmapType *pBitmap, UInt16 *err)
{
	if (hires)
		return (HRWinCreateBitmapWindow(hires, pBitmap, err));
	else
		return (WinCreateBitmapWindow(pBitmap, err));
}
예제 #2
0
파일: xfer.c 프로젝트: jemyzhang/DiddleBug
/*
** 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);
}