

#ifdef MACVERSION 
#include <standard.h>
#endif

#ifdef WIN95VERSION 
#include "standard.h"
#endif

#include "quickdraw.h"
#include "scrap.h"
#include "scrollbar.h"
#include "frontierwindows.h"
#include "shell.h"
#include "shellbuttons.h"
#include "shellprivate.h"


boolean shellactivatewindow (WindowPtr w, boolean flactivate) {
	
	/*
	activate or deactivate the indicated window.
	
	8/31/90 DW: we no longer set the globals at the end of the routine. 
	
	10/11/90 dmb: set superglobals up now
	
	3/30/93 dmb: make sure it's a shell window
	
	2.1a7 dmb: fixed shaging of display so newly-opened windows look good
	
	4.1b4 dmb: overload the config.fleraseonresize flag to avoid updating 
	iowa windows while activating

	5.0a10 dmb: dirty the window menu
	*/
	
	register hdlwindowinfo hinfo;
	register hdlscrollbar vertbar, horizbar;
	//Code change by Timothy Paustian Saturday, April 29, 2000 11:03:12 PM
	//Changed to Opaque call for Carbon
	//moved r to outside, since need for carbon call below
	Rect r;
	
#ifdef WIN95VERSION
	RECT winrect;
#endif
	
	if (!isshellwindow (w)) /*chase the refcon field of the mac window*/
		return (false);
	
	shellwindowmenudirty ();

	shellsetsuperglobals (); /*do everyone a favor - make superglobals current right away*/
	
	if (!shellpushglobals (w)) /*install globals of newly active or de-active window*/
		return (false);
	
	hinfo = shellwindowinfo; /*copy into register*/
	
	(**hinfo).flwindowactive = bitboolean (flactivate);

#ifdef MACVERSION
	#if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
	{
	CGrafPtr	thePort;
	thePort = GetWindowPort(w);
	GetPortBounds(thePort, &r);	
	}
	#else
	r = w->portRect;
	#endif
	pushclip (r); /*make sure we can draw into whole window*/
#endif
	
#ifdef WIN95VERSION
	GetClientRect (w, &winrect);
	winrecttorect (&winrect, &r);
	pushclip (r);
#endif

	shelldrawbuttons (); /*if window has an attached button list, draw it*/
	
	vertbar = (**hinfo).vertscrollbar;
	
	horizbar = (**hinfo).horizscrollbar;
	
	if (flactivate) {
	
		shellsetscrollbars (w);
		
		displayscrollbar (vertbar);
		
		displayscrollbar (horizbar);
		
		(**hinfo).selectioninfo.fldirty = true; /*dmb: force menu update*/
		}
	
	else {

		disablescrollbar (vertbar);
		
		disablescrollbar (horizbar);
	
	#if TARGET_API_MAC_CARBON != 1
	
		if (isdeskaccessorywindow (getfrontwindow ())) /*DA is being activated*/

	#endif	
	
	shellwritescrap (anyscraptype);
		
		}
	
	shelldrawgrowicon (hinfo);
	
	drawwindowmessage (w);
	
	popclip ();
	
	if ((*shellglobals.dataholder != NULL)) { // 4/8.97 dmb: window has conent
		
		pushclip ((**hinfo).contentrect); /*driver limited to drawing in content rect*/
		
		(*shellglobals.activateroutine) (bitboolean (flactivate));
		
		popclip ();

		#ifdef WIN95VERSION
			if (config.fleraseonresize)
				shellupdatenow (w);
		#endif
		}
	
	shellpopglobals ();
	
	return (true);
	} /*shellactivatewindow*/




