Ejemplo n.º 1
0
static void ROM_HideMenuBar(_THIS)
{
#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
	RgnHandle		drawRgn = nil;
	RgnHandle		tempRgn = nil;
	RgnHandle		grayRgn = nil;
	WindowPtr		window = nil;
	GDHandle		gd = nil;
	GrafPtr			savePort;
	long			response;
	short			height;
	EventRecord		theEvent;

	height = GetMBarHeight();
	
	if ( height > 0 ) {
		tempRgn = NewRgn();
		drawRgn = NewRgn();
		gSaveGrayRgn = NewRgn();
		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
			goto CLEANUP;
		}
		grayRgn = GetGrayRgn(); /* No need to check for this */
	
		GetPort(&savePort);

		/* Hide the control strip if it's present, and record its 
		   previous position into the dirty region for redrawing. 
		   This isn't necessary, but may help catch stray bits. */
		CopyRgn(grayRgn, tempRgn);
		if (!Gestalt(gestaltControlStripAttr, &response) && 
			(response & (1L << gestaltControlStripExists))) {
			gSaveCSVis = SBIsControlStripVisible();
			if (gSaveCSVis)
				SBShowHideControlStrip(false);
		}
		DiffRgn(grayRgn, tempRgn, drawRgn);

		/* Save the gray region once the control strip is hidden*/
		CopyRgn(grayRgn, gSaveGrayRgn);

		/* Change the menu height in lowmem */
		gSaveMenuBar = height;
		LMSetMBarHeight(0);
		
		/* Walk the monitor rectangles, and combine any pieces that
		   aren't in GrayRgn: menubar, round corners, fake floaters. */
		for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) 
			{
			if (!TestDeviceAttribute(gd, screenDevice)) continue;
			if (!TestDeviceAttribute(gd, screenActive)) continue;

			RectRgn(tempRgn, &(*gd)->gdRect);	/* Get the whole screen */
			DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */
			UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */
			}
			
		/* Add the bits into the GrayRgn */
		UnionRgn(drawRgn, grayRgn, grayRgn);

		/* Modify the vis regions of exposed windows */
		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
		PaintBehind(window, drawRgn);
		CalcVisBehind(window, drawRgn);

		SetPort(savePort);
		
		/* Yield time so that floaters can catch up */
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		}

CLEANUP:

	if (tempRgn) DisposeRgn(tempRgn);
	if (drawRgn) DisposeRgn(drawRgn);
#endif /* !TARGET_API_MAC_CARBON */
}
Ejemplo n.º 2
0
static void ROM_ShowMenuBar(_THIS)
{
#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
	RgnHandle		drawRgn = nil;
	RgnHandle		menuRgn = nil;
	RgnHandle		tempRgn = nil;
	RgnHandle		grayRgn = nil;
	WindowPtr		window = nil;
	GrafPtr			wMgrPort;
	GrafPtr			savePort;
	Rect			menuRect;
	long			response;
	short			height;
	EventRecord		theEvent;
	RGBColor		saveRGB;
	RGBColor		blackRGB = { 0, 0, 0 };

	height = GetMBarHeight();
	
	if ((height <= 0) && (gSaveMenuBar > 0)) {
		drawRgn = NewRgn();
		menuRgn = NewRgn();
		tempRgn = NewRgn();
		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
			goto CLEANUP;
		}
		grayRgn = GetGrayRgn(); /* No need to check for this */
	
		GetPort(&savePort);
		GetWMgrPort(&wMgrPort);

		/* Set the height properly */
		LMSetMBarHeight(gSaveMenuBar);

		/* Restore the old GrayRgn: rounded corners, etc, but not
		   the menubar -- subtract that out first! */
		if (gSaveGrayRgn)
			{
			menuRect = (*GetMainDevice())->gdRect;
			menuRect.bottom = menuRect.top + gSaveMenuBar;
			RectRgn(menuRgn, &menuRect);

			DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); 	/* What do we inval? */
			DiffRgn(drawRgn, menuRgn, drawRgn);			/* Clip out the menu */
			
			/* Now redraw the corners and other bits black */
			SetPort(wMgrPort);
			GetClip(tempRgn);
			SetClip(drawRgn);
			GetForeColor(&saveRGB);
			RGBForeColor(&blackRGB);
			PaintRgn(drawRgn);
			RGBForeColor(&saveRGB);
			SetClip(tempRgn);
			SetPort(savePort);
			
			UnionRgn(drawRgn, menuRgn, drawRgn);		/* Put back the menu */

			/* Now actually restore the GrayRgn */
			CopyRgn(gSaveGrayRgn, grayRgn);
			DisposeRgn(gSaveGrayRgn);
			gSaveGrayRgn = nil;
			}

		/* Modify the vis regions of exposed windows and draw menubar */
		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
		PaintBehind(window, drawRgn);
		CalcVisBehind(window, drawRgn);
		DrawMenuBar();

		SetPort(savePort);
		gSaveMenuBar = 0;

		/* Now show the control strip if it's present */
		if (!Gestalt(gestaltControlStripAttr, &response) && 
				(response & (1L << gestaltControlStripExists)))
			{
			if (gSaveCSVis && !SBIsControlStripVisible())
				SBShowHideControlStrip(true);
			gSaveCSVis = true;
			}

		/* Yield time so that floaters can catch up */
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		}

CLEANUP:

	if (drawRgn) DisposeRgn(drawRgn);
	if (menuRgn) DisposeRgn(menuRgn);
	if (tempRgn) DisposeRgn(tempRgn);
#endif /* !TARGET_API_MAC_CARBON */
}
Ejemplo n.º 3
0
void fastPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE + 8 ];
/*	BatteryTimeRec batteryTimeInfo; */
	SMStatus soundStatus;
	ThreadID threadID;
	ThreadState threadState;
	EventRecord eventRecord;
	Point point;
	WindowPtr windowPtr;
	PScrapStuff scrapInfo;
	UnsignedWide usSinceStartup;
	BYTE dataBuffer[ 2 + 8 ];
/*	short driverRefNum; */
	UInt32 dateTime;
/*	int count, dummy; */
	NumVersion version;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Get the status of the last alert, how much battery time is remaining
	   and the voltage from all batteries, the internal battery status, the
	   current date and time and time since system startup in ticks, the
	   application heap limit and current and heap zone, free memory in the
	   current and system heap, microseconds since system startup, whether
	   QuickDraw has finished drawing, modem status, SCSI status
	   information, maximum block allocatable without compacting, available
	   stack space, the last QuickDraw error code */
/*	addRandomValue( randomState, GetAlertStage() );
	count = BatteryCount();
	while( count-- > 0 )
		{
		addRandomValue( randomState,
				   GetBatteryVoltage( count ) );
		GetBatteryTimes( count, &batteryTimeInfo );
		addRandomData( randomState, &batteryTimeInfo,
					   sizeof( BatteryTimeRec ) );
		}
	if( !BatteryStatus( buffer, dataBuffer + 1 ) )
		addRandomValue( randomState, dataBuffer );
*/	GetDateTime( &dateTime );
	addRandomValue( randomState, dateTime );
	addRandomValue( randomState, TickCount() );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	addRandomValue( randomState, GetApplLimit() );
	addRandomValue( randomState, GetZone() );
	addRandomValue( randomState, SystemZone() );
	addRandomValue( randomState, FreeMem() );
	addRandomValue( randomState, FreeMemSys() );
#endif
/*	MicroSeconds( &usSinceStartup );
	addRandomData( randomState, &usSinceStartup, sizeof( UnsignedWide ) ); */
	addRandomValue( randomState, QDDone( NULL ) );
/*	ModemStatus( dataBuffer );
	addRandomValue( randomState, dataBuffer[ 0 ] ); */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	addRandomValue( randomState, SCSIStat() );
#endif
	addRandomValue( randomState, MaxBlock() );
	addRandomValue( randomState, StackSpace() );
	addRandomValue( randomState, QDError() );

	/* Get the event code and message, time, and mouse location for the next
	   event in the event queue and the OS event queue */
	if( EventAvail( everyEvent, &eventRecord ) )
		addRandomData( randomState, &eventRecord, sizeof( EventRecord ) );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	if( OSEventAvail( everyEvent, &eventRecord ) )
		addRandomData( randomState, &eventRecord, sizeof( EventRecord ) );
#endif

	/* Get all sorts of information such as device-specific info, grafport
	   information, visible and clipping region, pattern, pen, text, and
	   colour information, and other details, on the topmost window.  Also
	   get the window variant.  If there's a colour table record, add the
	   colour table as well */
	if( ( windowPtr = FrontWindow() ) != NULL )
		{
/*		CTabHandle colourHandle; */

#if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS
		addRandomData( randomState, windowPtr, sizeof( GrafPort ) );
#endif
		addRandomValue( randomState, GetWVariant( windowPtr ) );
/*		if( GetAuxWin( windowPtr, colourHandle ) )
			{
			CTabPtr colourPtr;

			HLock( colourHandle );
			colourPtr = *colourHandle;
			addRandomData( randomState, colourPtr, sizeof( ColorTable ) );
			HUnlock( colourHandle );
			} */
		}

	/* Get mouse-related such as the mouse button status and mouse position,
	   information on the window underneath the mouse */
	addRandomValue( randomState, Button() );
	GetMouse( &point );
	addRandomData( randomState, &point, sizeof( Point ) );
	FindWindow( point, &windowPtr );
#if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS
	if( windowPtr != NULL )
		addRandomData( randomState, windowPtr, sizeof( GrafPort ) );
#endif

	/* Get the size, handle, and location of the desk scrap/clipboard */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	scrapInfo = InfoScrap();
	addRandomData( randomState, scrapInfo, sizeof( ScrapStuff ) );
#endif

	/* Get information on the current thread */
	threadID = kCurrentThreadID; /*GetThreadID( &threadID ); */
	GetThreadState( threadID, &threadState );
	addRandomData( randomState, &threadState, sizeof( ThreadState ) );

	/* Get the sound mananger status.  This gets the number of allocated
	   sound channels and the current CPU load from these channels */
	SndManagerStatus( sizeof( SMStatus ), &soundStatus );
	addRandomData( randomState, &soundStatus, sizeof( SMStatus ) );

	/* Get the speech manager version and status */
/*	version = SpeechManagerVersion();
	addRandomData( randomState, &version, sizeof( NumVersion ) );
	addRandomValue( randomState, SpeechBusy() );
*/
	/* Get the status of the serial port.  This gets information on recent
	   errors, read and write pending status, and flow control values */
/*	if( !OpenDriver( "\p.AIn", &driverRefNum ) )
		{
		SerStaRec serialStatus;

		SetStatus( driverRefNum, &serialStatus );
		addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) );
		}
	if( !OpenDriver( "\p.AOut", &driverRefNum ) )
		{
		SerStaRec serialStatus;

		SetStatus( driverRefNum, &serialStatus );
		addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) );
		} */

	/* Flush any remaining data through */
	endRandomData( randomState, 10 );
	}