/* Main entry point; it is unlikely you will need to change this except to handle other launch command codes */ UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 err; if (cmd != sysAppLaunchCmdNormalLaunch) return sysErrParamErr; if (!(buffer = WinCreateOffscreenWindow (160, 160, screenFormat, &err))) return err; if ((err = StartApplication()) != 0) return err; ticks = SysTicksPerSecond() / FRAME_RATE; run_game (); /* EventLoop(); */ StopApplication(); WinDeleteWindow (buffer, false); return 0; }
void FormGadget::drawProxy() { if (!visible()) return; if (form()->application().runningOnTreo600() && hasFocus()) drawFocusRing(); Graphics graphics(WinGetDrawWindow()); // form()->windowHandle() Rect rect; bounds(rect); bool db=doubleBuffer_; if (db) { Rect formBounds; form()->bounds(formBounds); Err error; WinHandle wh = WinCreateOffscreenWindow(formBounds.width(), formBounds.height(), nativeFormat, &error); if (errNone == error) { { Graphics offscreen(wh); ActivateGraphics active(offscreen); handleDraw(graphics); offscreen.copyArea(rect, graphics, rect.topLeft()); } WinDeleteWindow(wh, false); } else db=false; } if (!db) { Graphics::ClipRectangleSetter setClip(graphics, rect); handleDraw(graphics); } fireDrawCompleted(); }
void Window::dispose(EraseOption erase) { WinDeleteWindow(handle(), bool(erase)); handle_ = NULL; }
/* 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 ); }
/* ** 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); }