static UInt16 SafeWinSetCoordinateSystem( UInt16 coordSys ) { if ( ! palmHiRes || NULL == WinGetDrawWindow() ) return kCoordinatesStandard; else return WinSetCoordinateSystem( coordSys ); }
/*------------------------------------------------CIRexxApp::NewScriptIndexDB-+ | Load the scripts DB | +----------------------------------------------------------------------------*/ void CIRexxApp::NewScriptIndexDB() { //<<<JAL since searching for many scripts can be slow, // we draw a little indicator at the start. // palm os does provide a set of progress functions, // but their progress dialog is too much for something simple. Err err; RectangleType saveFrame; WinHandle saveWindow = 0; if (WinGetDrawWindow()) { // If we can't draw yet, forget it! const char * s = getRexxAppMessage(msgRexxIsStarting); // the text in the rectangle const int wFrame = 2; // the width of dialogFrame const int padding = 2; // padding for the text in the rectangle Int16 w = FntCharsWidth(s, StrLen(s)) + (padding * 2); Int16 h = FntCharHeight() + (padding * 2); RectangleType r; RctSetRectangle(&r, (160-w)/2, (160-h)/2, w, h); RctSetRectangle(&saveFrame, r.topLeft.x-wFrame, r.topLeft.y-wFrame, r.extent.x+(wFrame*2), r.extent.y+(wFrame*2)); saveWindow = WinSaveBits(&saveFrame, &err); WinDrawRectangleFrame(dialogFrame, &r); WinDrawChars(s, StrLen(s), r.topLeft.x+padding, r.topLeft.y+padding); } initializeIndexDatabase(); if (saveWindow) { WinRestoreBits(saveWindow, saveFrame.topLeft.x, saveFrame.topLeft.y); } return; }
/*********************************************************************** * * FUNCTION: ZDicToolsWinGetBounds * * DESCRIPTION: This routine returns the bounds of the winH argument * in display relative coordinates. * * PARAMETERS: winH -> window for which to get bounds * rP <- set to the bounds of the window * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * ZhongYuanHuan 14/Aug/04 Initial Revision * ***********************************************************************/ void ZDicToolsWinGetBounds(WinHandle winH, RectangleType* rP) { WinHandle oldDrawWinH; oldDrawWinH = WinGetDrawWindow (); // Set the draw and acitve windows to fixe bugs of chinese os. WinSetDrawWindow ( winH ); WinGetDrawWindowBounds ( rP ); if ( oldDrawWinH != 0 ) WinSetDrawWindow ( oldDrawWinH ); return; }
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(); }
/* 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 ); }
void slowPoll( void ) { static BOOLEAN addedFixedItems = FALSE; RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; struct batteryInfoType { uint16_t warnThreshold; /* Percent left for warn */ uint16_t criticalThreshold; /* Percent left for critical warn */ uint16_t shutdownThreshold; /* Percent left for shutdown */ uint32_t timeout; /* Battery timeout */ SysBatteryKind type; /* Battery type */ Boolean pluggedIn; /* Whether battery plugged in */ uint8_t powerLevel; /* Percent power remaining */ } batteryInfo; const FontType *fontPtr; MenuBarType *menuPtr; void *stackStart, *stackEnd; MemHeapInfoType memInfo; RectangleType rectangleInfo; EvtQueueHandle evtQueueHandle; DatabaseID databaseID; FontID fontID; WinHandle winHandle; WinFlagsType winFlags; PatternType pattern; uint32_t version; uint16_t formID; uint8_t value; initRandomData( randomState, buffer, RANDOM_BUFSIZE ); /* Get the handle of the current thread's event queue, current resource database ID, start and end of the current thread's stack, ID and pointer to the current font, ID and pointer to the currently active form, and pointer to the currently active menu */ evtQueueHandle = EvtGetThreadEventQueue(); addRandomValue( randomState, evtQueueHandle ); SysCurAppDatabase( &databaseID ); addRandomValue( randomState, databaseID ); SysGetStackInfo( &stackStart, &stackEnd ); addRandomData( randomState, &stackStart, sizeof( void * ) ); addRandomData( randomState, &stackEnd, sizeof( void * ) ); fontID = FntGetFont(); addRandomValue( randomState, fontID ); fontPtr = FntGetFontPtr(); addRandomData( randomState, &fontPtr, sizeof( FontType * ) ); formID = FrmGetActiveFormID(); addRandomValue( randomState, formID ); if( formID > 0 ) { FormType *formPtr; formPtr = FrmGetFormPtr( formID ); addRandomData( randomState, &formPtr, sizeof( FormType * ) ); } menuPtr = MenuGetActiveMenu(); addRandomData( randomState, &menuPtr, sizeof( MenuBarType * ) ); /* Get system memory info: heap base address, total memory, memory in use, number of chunks allocated/free and chunk memory used/free, available memory block info */ MemDynHeapGetInfo( &memInfo ); addRandomData( randomState, &memInfo, sizeof( MemHeapInfoType ) ); /* Get the handle, creation flags, and size of the active window, the screen window created at startup, and the current draw window, the size and clipping rectangle of the draw window, the current pattern type, and the current scaling mode */ winHandle = WinGetActiveWindow(); addRandomValue( randomState, winHandle ); winFlags = WinGetWindowFlags( winHandle ); addRandomValue( randomState, winFlags ); WinGetWindowFrameRect( winHandle, &rectangleInfo ); addRandomData( randomState, &rectangleInfo, sizeof( RectangleType ) ); winHandle = WinGetDisplayWindow(); addRandomValue( randomState, winHandle ); winHandle = WinGetDrawWindow(); addRandomValue( randomState, winHandle ); winFlags = WinGetWindowFlags( winHandle ); addRandomValue( randomState, winFlags ); WinGetDrawWindowBounds( &rectangleInfo ); addRandomData( randomState, &rectangleInfo, sizeof( RectangleType ) ); WinGetClip( &rectangleInfo ); addRandomData( randomState, &rectangleInfo, sizeof( RectangleType ) ); pattern = WinGetPatternType(); addRandomValue( randomState, pattern ); if( FtrGet( sysFtrCreator, sysFtrNumWinVersion, &version ) == errNone && \ version >= 5 ) { uint32_t scaleType; /* Not implemented before PalmOS 5.3, requires the 1.5x Display Feature Set to avoid generating a fatal alert */ scaleType = WinGetScalingMode(); addRandomValue( randomState, scaleType ); } /* Get expansiode card info (capability flags, manufacturer, product, and device info including unique serial number if available), and media info (disk space, partition info, pseudo-HDD metrics) for all expansion slots */ if( FtrGet( sysFileCExpansionMgr,expFtrIDVersion, &version ) == errNone ) { uint32_t slotIterator = expIteratorStart; uint16_t slotRefNum; while( slotIterator != expIteratorStop && \ ExpSlotEnumerate( &slotRefNum, &slotIterator ) == errNone ) { ExpCardInfoType cardInfo; CardMetricsType cardMetrics; addRandomValue( randomState, slotRefNum ); ExpCardInfo( slotRefNum, &cardInfo ); addRandomData( randomState, &cardInfo, sizeof( ExpCardInfoType ) ); ExpCardMetrics( slotRefNum, &cardMetrics ); addRandomData( randomState, &cardMetrics, sizeof( CardMetricsType ) ); } } /* Get attributes, filesystem type, mount info, media type, space used, and total space for all mounted volumes */ if( FtrGet( sysFileCVFSMgr, vfsFtrIDVersion, &version ) == errNone ) { uint32_t volIterator = vfsIteratorStart; uint16_t volRefNum; while( volIterator != vfsIteratorStop && \ VFSVolumeEnumerate( &volRefNum, &volIterator ) == errNone ) { VolumeInfoType volInfo; uint32_t volUsed, volTotal; addRandomValue( randomState, volRefNum ); VFSVolumeInfo( volRefNum, &volInfo ); addRandomData( randomState, &volInfo, sizeof( VolumeInfoType ) ); VFSVolumeSize( volRefNum, &volUsed, &volTotal ); addRandomValue( randomState, volUsed ); addRandomValue( randomState, volTotal ); } } /* Get battery state info */ if( SysBatteryInfo( FALSE, &batteryInfo.warnThreshold, &batteryInfo.criticalThreshold, &batteryInfo.shutdownThreshold, &batteryInfo.timeout, &batteryInfo.type, &batteryInfo.pluggedIn, &batteryInfo.powerLevel ) == errNone ) addRandomData( randomState, &batteryInfo, sizeof( struct batteryInfoType ) ); /* Get the LCD brightness and contrast level */ value = SysLCDBrightness( FALSE, 0 ); addRandomValue( randomState, value ); value = SysLCDContrast( FALSE, 0 ); addRandomValue( randomState, value ); /* The following are fixed for the lifetime of the process so we only add them once */ if( !addedFixedItems ) { struct ftrInfoType { uint32_t creator; /* Feature creator */ uint16_t number; /* Feature number */ uint32_t value; /* Feature value */ } ftrInfo; uint16_t ftrIterator, romTokenSize; uint8_t *romToken; /* Get system features. This includes a large amount of information ranging from fairly static (extensive hardware capability info, OS version/configuration data) through to variable (default font, locale, etc) */ for( ftrIterator = 0; \ FtrGetByIndex( ftrIterator, FALSE, &ftrInfo.creator, \ &ftrInfo.number, &ftrInfo.value ) == errNone; \ ftrIterator++ ) addRandomData( randomState, &ftrInfo, sizeof( struct ftrInfoType ) ); /* Get the ROM serial number. This is somewhat complex, for it to be valid the function call has to succeed and the returned pointer has to be non-null and the first byte of the returned data can't be 0xFF */ if( SysGetROMToken( sysROMTokenSnum, &romToken, \ &romTokenSize ) == errNone && \ romToken != NULL && *romToken != 0xFF ) addRandomData( randomState, &romToken, romTokenSize ); addedFixedItems = TRUE; } /* Flush any remaining data through */ endRandomData( randomState, 100 ); }