Пример #1
0
void OSystem_PalmZodiac::get_coordinates(EventPtr ev, Coord &x, Coord &y) {
	Boolean dummy;
	EvtGetPenNative(WinGetDisplayWindow(), &ev->screenX, &ev->screenY, &dummy);

	x = (ev->screenX - _screenOffset.x);
	y = (ev->screenY - _screenOffset.y);

	if (_stretched) {
		Int32 w, h;

		if (_mode == GFX_NORMAL) {

			h = gVars->screenHeight - MIN_OFFSET * 2;
			w = gVars->screenWidth;
			x = (_screenWidth * x) / w;
			y = (_screenHeight * y) / h;

		} else {

			h = (_ratio.adjustAspect == kRatioHeight ? _ratio.height : gVars->screenFullHeight);
			w = (_ratio.adjustAspect == kRatioWidth ? _ratio.width : gVars->screenFullWidth);
			x = (_screenWidth * x) / w;
			y = (_screenHeight * y) / h;
		}
	}
}
Пример #2
0
static char* GetBits()
{
	BitmapType* Bitmap;
	WinHandle Win = WinGetDisplayWindow();
	if (!Win)
		return NULL;

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

	return BmpGetBits(Bitmap);
}
Пример #3
0
static Boolean MainFormHandleEvent(EventPtr eventP) {
	Boolean handled = false;
	FormType *frmP;
	
	switch (eventP->eType) {
	case menuEvent: 
		if (eventP->data.menu.itemID == AboutMenuItm) {
			MenuEraseStatus(0);
			FrmAlert(AboutAlert);
			handled = true;
			break;
		}
		break;
	case frmOpenEvent:
		frmP = FrmGetActiveForm();
		FrmDrawForm(frmP);
		handled = true;
		break;
	case ctlSelectEvent:
		switch(eventP->data.ctlSelect.controlID) {
		case JavaButton:
			playJavaSound();
			handled=true;
			break;
		default:
			break;
		}
		break;
	case keyDownEvent:
		if(NavSelectPressed(eventP)) {
			playJavaSound();
			handled=true;
			break;
		}
		switch (eventP->data.keyDown.chr) {
		case vchrPageUp:
		case vchrJogUp:
		case vchrPageDown:
		case vchrJogDown:
		case vchrJogPush:
		case vchrJogPushedUp:
		case vchrJogPushedDown:
			playJavaSound();
			handled = true;
			break;
		}
		break;
	case winDisplayChangedEvent:
		{
			RectangleType curBounds,displayBounds;
			frmP=FrmGetActiveForm();
			WinGetBounds(FrmGetWindowHandle(frmP),&curBounds);
			WinGetBounds(WinGetDisplayWindow(), &displayBounds);
			JavaFormResizeForm(frmP,&curBounds,&displayBounds);
			FrmDrawForm(frmP);
			handled=true;
			break;
		}
	default:
		break;
  }
  return handled;
}
Пример #4
0
Boolean v4pDisplayInit(int quality, Color background) {
  bgColor=background;
  buffer = BmpGetBits(WinGetBitmap(WinGetDisplayWindow()));
}
Пример #5
0
static void blit ()
{
	const RectangleType rect = { {0,0}, {160,160} };
	WinCopyRectangle (buffer, WinGetDisplayWindow(), &rect, 0, 0, winPaint);
}
Пример #6
0
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 );
	}