Exemple #1
0
void createWindow()
{
	int		width, height;
	int		left, top;
	Rect	rect;
	Rect	tempRect1;
	BitMap	bitMap;
	
	GetPortBounds(gGWorld, &tempRect1);
	
	width = 58 + (tempRect1.right - tempRect1.left) * 2;
	height = 230 + tempRect1.bottom - tempRect1.top;
	
	
	tempRect1 = GetQDGlobalsScreenBits(&bitMap)->bounds;
	
	left = (((tempRect1.right - tempRect1.left) - width) / 2);
	top = (((tempRect1.bottom - tempRect1.top) - height) / 2) + 20;

	SetRect( &rect, left, top, left + width, top + height );
	gWindow = NewCWindow( 0L, &rect, "\pQuickDraw Special Effects", true, noGrowDocProc,
							(WindowPtr)-1L, true, 0 );
							
	SetPortWindowPort( gWindow );
}
Exemple #2
0
void createWindow()
{
	Rect 	wBounds;
	BitMap	bitMap;
	Rect 	tempRect1;
	int		top, left, width, height;
	
	GetQDGlobalsScreenBits(&bitMap);
	
	width = ((bitMap.bounds.right - bitMap.bounds.left) / 2);
	height = ((bitMap.bounds.bottom - bitMap.bounds.top) / 2);

	left = (((bitMap.bounds.right - bitMap.bounds.left) - width) / 2);
	top = (((bitMap.bounds.bottom - bitMap.bounds.top) - height) / 2);
	
	/* Create a window to display the final offscreen image. */
	
	//SetRect( &wBounds, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &wBounds, left, top, left + width, top + height );
	
	gWindow = NewCWindow( 0L, &wBounds, "\pSnapshot Test", false, documentProc,
							(WindowPtr)-1L, true, 0L );
							
	//SetRect( &gBounds, 0, 0, gWindow->portRect.right - gWindow->portRect.left,
	//				gWindow->portRect.bottom - gWindow->portRect.top );
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	SetRect( &gBounds, 0, 0, tempRect1.right - tempRect1.left, 
	 tempRect1.bottom - tempRect1.top);
							
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
}
OSErr QTDR_PlayMovieFromRAM (Movie theMovie)
{
	WindowPtr				myWindow = NULL;
	Rect					myBounds = {50, 50, 100, 100};
	Rect					myRect;
	StringPtr				myTitle = QTUtils_ConvertCToPascalString(kWindowTitle);
	OSErr					myErr = memFullErr;

	myWindow = NewCWindow(NULL, &myBounds, myTitle, false, 0, (WindowPtr)-1, false, 0);
	if (myWindow == NULL)
		goto bail;
		
	myErr = noErr;
	
	MacSetPort((GrafPtr)GetWindowPort(myWindow));

	GetMovieBox(theMovie, &myRect);
	MacOffsetRect(&myRect, -myRect.left, -myRect.top);
	SetMovieBox(theMovie, &myRect);

	if (!EmptyRect(&myRect))
		SizeWindow(myWindow, myRect.right, myRect.bottom, false);
	else
		SizeWindow(myWindow, 200, 0, false);
		
	MacShowWindow(myWindow);

	SetMovieGWorld(theMovie, GetWindowPort(myWindow), NULL);
	GoToBeginningOfMovie(theMovie);
	MoviesTask(theMovie, 0);
	StartMovie(theMovie);
	
	myErr = GetMoviesError();
	if (myErr != noErr)
		goto bail;
	
	while (!IsMovieDone(theMovie))
		MoviesTask(theMovie, 0);

bail:
	free(myTitle);
	
	if (theMovie != NULL)
		DisposeMovie(theMovie);

	if (myWindow != NULL)
		DisposeWindow(myWindow);
		
	return(myErr);
}
Exemple #4
0
static void window_create(IMAGE *img)
{
    WindowRef windowRef;
    Str255    windowTitle = "\pGhostscript Image";
    Rect      windowRect = {20,4,580,420};//, portRect;
    Rect      scrollbarRect = {0,0,0,0};

#if TARGET_API_MAC_CARBON
    GetAvailableWindowPositioningBounds(GetMainDevice(),&windowRect);
#endif

    /* Create a new suitablty positioned window */
    windowRect.top = windowRect.top * 2 + 2;
    windowRect.bottom -= 10;
    windowRect.left += 4;
    windowRect.right = ((windowRect.bottom - windowRect.top) * 3) / 4 + windowRect.left;

    if(!(windowRef = NewCWindow(NULL, &windowRect, windowTitle, true,
                                zoomDocProc, (WindowRef) -1, false, 0)))
        ExitToShell();

    img->windowRef = windowRef;

    SetWRefCon(img->windowRef, (SInt32)img);

    /* Create the window's scrollbars */
#if TARGET_API_MAC_CARBON
    if(gRunningOnX)
        ChangeWindowAttributes(windowRef,kWindowLiveResizeAttribute,0);

    CreateScrollBarControl(windowRef, &scrollbarRect, 0, 0, 0, 0,
                           true, gActionFunctionScrollUPP, &(img->scrollbarVertRef));

    CreateScrollBarControl(windowRef, &scrollbarRect, 0, 0, 0, 0,
                           true, gActionFunctionScrollUPP, &(img->scrollbarHorizRef));
#else
    img->scrollbarVertRef = NewControl(windowRef,&scrollbarRect,"\p",false,0,0,0,scrollBarProc,0);
    img->scrollbarHorizRef = NewControl(windowRef,&scrollbarRect,"\p",false,0,0,0,scrollBarProc,0);
#endif

    window_adjust_scrollbars(windowRef);
}
void createWindow()
{
	Rect		rect;
	BitMap		bitMap;
	Rect		tempRect1;
	int			top, left;
	
	GetQDGlobalsScreenBits(&bitMap);
	tempRect1 = bitMap.bounds;
	
	left = (((tempRect1.right - tempRect1.left) - WWIDTH) / 2);
	top = (((tempRect1.bottom - tempRect1.top) - WHEIGHT) / 2);

	//SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &rect, left, top, left + WWIDTH, top + WHEIGHT );
	gWindow = NewCWindow( 0L, &rect, "\pDirect Pixel Access", true, documentProc,
							(WindowPtr)-1L, true, 0L );						
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
	
	TextFont( kFontIDGeneva );
	TextSize( 9 );
	TextMode( srcXor );
}
void createWindow()
{
	Rect rect;
	
	BitMap	bitMap;
	int	top, left;
	
	GetQDGlobalsScreenBits(&bitMap);
	
	top = (((bitMap.bounds.bottom - bitMap.bounds.top) - WHEIGHT) / 2);
	left = (((bitMap.bounds.right - bitMap.bounds.left) - WWIDTH) / 2);
	
	//SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &rect, left, top, left + WWIDTH, top + WHEIGHT );
	
	gWindow = NewCWindow( 0L, &rect, "\pMyDeviceLoop", true, documentProc,
							(WindowPtr)-1L, true, 0L );						
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
	
	TextFont( kFontIDTimes );
	TextSize( 48 );
	TextMode( srcCopy );
}
Exemple #7
0
Boolean MCScreenDC::open()
{
	owndnd = False;
	mouseMoveRgn = NewRgn();
	SetRectRgn(mouseMoveRgn, 0, 0, 1, 1);

	//create a invisible window, and set port to this window
	//so that later on at the very first time MC select and set font
	//will only affect in this invisible window, not other apps on the desk top,
	// when MC is first started.  The size of the window is random.
	//  Rect invisibleWinRect;
	Rect invisibleWinRect;
	SetRect(&invisibleWinRect, 0, 0, 20, 20);


	invisibleWin = NewCWindow(nil, &invisibleWinRect, "\p", False,
	                          kUtilityWindowClass, (WindowRef)(-1L), False, 0);



	long response;
	if (Gestalt(gestaltSystemVersion, &response) == noErr)
	{
		if (response >= 0x1030 && response < 0x1040)
			MCantialiasedtextworkaround = True;
		else
			MCantialiasedtextworkaround = False;
	}

	SetGWorld(GetWindowPort(invisibleWin), GetMainDevice());

	vis = new MCVisualInfo;
	
	devdepth = 32;

	black_pixel.red = black_pixel.green = black_pixel.blue = 0; //black pixel
	white_pixel.red = white_pixel.green = white_pixel.blue = 0xFFFF; //white pixel
		black_pixel.pixel = 0;
		white_pixel.pixel = 0xFFFFFF;

			redbits = greenbits = bluebits = 8;
			redshift = 16;
			greenshift = 8;
			blueshift = 0;
			vis->red_mask = 0x00FF0000;
			vis->green_mask = 0x0000FF00;
			vis->blue_mask = 0x000000FF;

	MCzerocolor = MCbrushcolor = white_pixel;
	alloccolor(MCbrushcolor);
	MCselectioncolor = MCpencolor = black_pixel;
	alloccolor(MCselectioncolor);
	alloccolor(MCpencolor);
	gray_pixel.red = gray_pixel.green = gray_pixel.blue = 0x8888;
	alloccolor(gray_pixel);
	background_pixel.red = background_pixel.green = background_pixel.blue = 0xffff;
	alloccolor(background_pixel);

	//query the system for the hilited text color, and set ours
	RGBColor hiliteRGB;
	LMGetHiliteRGB(&hiliteRGB);
	MChilitecolor.red = hiliteRGB.red;
	MChilitecolor.green = hiliteRGB.green;
	MChilitecolor.blue = hiliteRGB.blue;
	alloccolor(MChilitecolor);

	MCColor *syscolors = getaccentcolors();
	if (syscolors != NULL)
		MCaccentcolor = syscolors[4];
	else
	{
		MCaccentcolor.red = MCaccentcolor.green = 0x0000;
		MCaccentcolor.blue = 0x8080;
	}
	alloccolor(MCaccentcolor);

	grabbed = False;
	tripleclick = doubleclick = False;
	MCdoubletime = GetDblTime() * 1000 / 60;
	opened = True;
	mousewindow = new _Drawable;
	activewindow = new _Drawable;
	lastactivewindow = new _Drawable;
	mousewindow->type = activewindow->type = lastactivewindow->type = DC_WINDOW;
	mousewindow->handle.window = activewindow->handle.window
	                             = lastactivewindow->handle.window = 0;

	//get handle of application menu bar
	menuBar = GetMenuBar();
	SetMenuBar(menuBar);  //set menu bar as current menulist
	
	//create Apple menu
	appleMenu = NewMenu(mApple, "\p\024"); //menu title is an apple icon
	InsertMenuItem(appleMenu, "\pAbout...", 0);
	InsertMenu(appleMenu, 0);
	
	DrawMenuBar(); //draw the menu bar with the Apple menu
	usetemp = False;
	Handle tmem = Get1IndResource('TMEM', 1);
	if (tmem != NULL)
	{
		char *ptr = *tmem;
		if (*(ptr + 1))
			usetemp = True;
	}
	MCtemplatescrollbar->alloccolors();
	if (IsMacEmulatedLF()) // no AM
		MCtemplatebutton->allocicons();

	// preallocate these because GetItemMark can't distinguish them
	submenuIDs[0] = 1;
	submenuIDs[checkMark] = 1;
	submenuIDs[diamondMark] = 1;
	
	MCcursors[PI_NONE] = nil;
	MCblinkrate = GetCaretTime() * 1000 / 60;

	MCDisplay const *t_displays;
	getdisplays(t_displays, false);
	MCwbr = t_displays[0] . workarea;

	//TSM - INIT TSM APPLICATION AND INSTALL REQUIRED APPLEVENT HANDLERS
	TSMPositionToOffsetUPP = NewAEEventHandlerUPP(TSMPositionToOffset);
	TSMOffsetToPositionUPP = NewAEEventHandlerUPP(TSMOffsetToPosition);
	TSMUpdateHandlerUPP = NewAEEventHandlerUPP(TSMUpdateHandler);
	TSMUnicodeNotFromInputUPP
	= NewAEEventHandlerUPP(TSMUnicodeNotFromInputHandler);
	AEInstallEventHandler(kTextServiceClass, kPos2Offset,
	                      TSMPositionToOffsetUPP, 0L , False);
	AEInstallEventHandler(kTextServiceClass, kOffset2Pos,
	                      TSMOffsetToPositionUPP, 0L , False);
	AEInstallEventHandler(kTextServiceClass, kUpdateActiveInputArea,
	                      TSMUpdateHandlerUPP, 0L , False);
	AEInstallEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod,
	                      TSMUnicodeNotFromInputUPP, 0L , False);
	openIME();

	dragdropUPP = NewDragReceiveHandlerUPP(DragReceiveHandler);
	InstallReceiveHandler(dragdropUPP, NULL, NULL);
	dragmoveUPP = NewDragTrackingHandlerUPP(DragTrackingHandler);
	InstallTrackingHandler(dragmoveUPP, NULL, NULL);
	
	s_animation_current_time = s_animation_start_time = CFAbsoluteTimeGetCurrent();
	
	//// Dock Menu Initialization
	
	EventTypeSpec t_menu_event_specs[1];
	t_menu_event_specs[0] . eventClass = kEventClassMenu;
	t_menu_event_specs[0] . eventKind = kEventMenuPopulate;
	
	CreateNewMenu(0, 0, &f_icon_menu);
	s_icon_menu_event_handler_upp = NewEventHandlerUPP((EventHandlerProcPtr)handleiconmenuevent);
	InstallEventHandler(GetMenuEventTarget(f_icon_menu), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL);
	
	t_menu_event_specs[0] . eventClass = kEventClassCommand;
	t_menu_event_specs[0] . eventKind = kEventCommandProcess;
	InstallEventHandler(GetApplicationEventTarget(), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL);
	
	SetApplicationDockTileMenu(f_icon_menu);
	
	//// Color Profile Initialization
	
	CMGetDefaultProfileBySpace(cmRGBData, &m_dst_profile);

	CMProfileLocation t_location;
	t_location . locType = cmPathBasedProfile;
	strcpy(t_location . u . pathLoc . path, "/System/Library/ColorSync/Profiles/sRGB Profile.icc");
	CMOpenProfile(&m_srgb_profile, &t_location);
	
	////
	
	return True;
}
Exemple #8
0
Window::Window(WindowSystem& ws, DrawingSurfaceConfig& c, int w, int h,
    int x, int y):
    DrawingSurface(ws, c) {

#if defined(__X11__)

#if defined(GLX_VERSION_1_3)
	if (ws.GLXVersMajor == 1 && ws.GLXVersMinor < 3)
		goto legacyMethod;
// XXX Need GLX 1.3 window-creation code.  For now, just fall through.
#endif

legacyMethod:
	// XXX There's basically no error-handling code here.
	// See XErrorHandler().

	// Create the window:
	XSetWindowAttributes xswa;
	xswa.background_pixmap = None;
	xswa.border_pixel = 0;
	xswa.colormap = ChooseColormap(winSys->dpy, config->vi);
	xswa.event_mask = StructureNotifyMask;
	xWindow = XCreateWindow(winSys->dpy,
		RootWindow(winSys->dpy, config->vi->screen),
		x, y, w, h,
		0,
		config->vi->depth,
		InputOutput,
		config->vi->visual,
		CWBackPixmap|CWBorderPixel|CWColormap|CWEventMask,
		&xswa);

	// Set attributes for the benefit of the window manager:
	XSizeHints sizeHints;
	sizeHints.width = w;
	sizeHints.height = h;
	sizeHints.x = x;
	sizeHints.y = y;
	sizeHints.flags = USSize | USPosition;
	XSetStandardProperties(winSys->dpy, xWindow, "glean", "glean",
		None, 0, 0, &sizeHints);

	// Map the window and wait for it to appear:
	XMapWindow(winSys->dpy, xWindow);
	XEvent event;
	for (;;) {
		XNextEvent(winSys->dpy, &event);
		if (event.type == MapNotify && event.xmap.window == xWindow)
			break;
	}


#elif defined(__WIN__)
	// XXX There's basically no error-handling code here.
	// create the window
	RECT r;
	int style = WS_POPUP | WS_CAPTION | WS_BORDER;

	r.left = x;
	r.top = y;
	r.right = r.left + w;
	r.bottom = r.top + h;
	AdjustWindowRect(&r,style,FALSE);
		
	hWindow = CreateWindow("glean","glean",
		style | WS_VISIBLE,
		r.left,r.top,r.right - r.left,r.bottom - r.top,
		NULL, NULL,
		GetModuleHandle(NULL),
		NULL);

    if (!hWindow)
        return;

	hDC = GetDC(hWindow);

	PIXELFORMATDESCRIPTOR pfd;
	SetPixelFormat(hDC,config->pfdID,&pfd);
	
#elif defined(__BEWIN__)

	tWindow = new GLTestWindow (BRect(x,y, x+w, y+h), "GL Test Window");
	tWindow->Show();

#elif defined(__AGL__)
	Rect	 r ;
	
	//we need some extra room for the menu bar
	r.left = x+16;
	r.top = y+20;
	if (h < 20)
		r.bottom = r.top + 32;
	else
		r.bottom = r.top+w;
		
	if (w < 20)
		r.right = r.left + 32;
	else
		r.right = r.left + w;

	macWindow = NewCWindow(nil, &r, (unsigned char*)"glean", true, documentProc, 
						(WindowPtr) -1, false, 0);

	SetPortWindowPort(macWindow);

#endif
} // Window::Window
Exemple #9
0
static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	Rect wrect, orect;
#if TARGET_API_MAC_CARBON
	Rect tmprect;
#endif

	/* Free any previous video mode */
	ROM_UnsetVideoMode(this, current);

	/* Create the ROM window and SDL video surface */
	current->flags = 0;		/* Clear flags */
	current->w = width;
	current->h = height;
	SetRect(&wrect, 0, 0, width, height);
	if ( SDL_Window ) {
		/* If we recreate the window, don't move it around */
#if TARGET_API_MAC_CARBON
		orect = *GetWindowPortBounds(SDL_Window, &tmprect);
#else
		orect = SDL_Window->portRect;
#endif
		OffsetRect(&wrect, orect.left, orect.top);
	} else {
		/* Center the window the first time we show it */
		OffsetRect(&wrect,
		(SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2);
	}

#if defined(__MACOSX__) && !USE_QUICKTIME
	/* Hum.. fullscreen mode is broken */
	flags &= ~SDL_FULLSCREEN;
#endif
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		/* Create the fullscreen window and use screen bits */
		current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN;
		if ( SDL_Window ) {
			DisposeWindow(SDL_Window);
		}
#if USE_QUICKTIME
		BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0);
#else
		SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
						(WindowPtr)-1, false, 0);
		ROM_HideMenuBar(this);
#endif
		current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
		current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
		this->UpdateRects = ROM_DirectUpdate;
	} else {
		GWorldPtr memworld;
		PixMapHandle pixmap;
		int style;

		style = noGrowDocProc;
		if ( flags & SDL_NOFRAME ) {
			style = plainDBox;
			current->flags |= SDL_NOFRAME;
		} else
		if ( flags & SDL_RESIZABLE ) {
			style = zoomDocProc;
			current->flags |= SDL_RESIZABLE;
		}
		if ( SDL_Window && (style == current_style) ) {
			/* Resize existing window, if necessary */
			if ( ((orect.right-orect.left) != width) ||
			     ((orect.bottom-orect.top) != height) ) {
				SizeWindow(SDL_Window, width, height, false);
			}
		} else {
			/* Recreate the window in the new style */
			if ( SDL_Window ) {
				DisposeWindow(SDL_Window);
			}
			SDL_Window = NewCWindow(nil, &wrect, "\p", true,
			                        style, (WindowPtr)-1, true, 0);

			/* Set the window title, if any */
			{ char *title;
				SDL_WM_GetCaption(&title, NULL);
				if ( title ) {
					Mac_SetCaption(this, title, NULL);
				}
			}
		}
		current_style = style;
		SetPalette(SDL_Window, SDL_CPal, false);
		ActivatePalette(SDL_Window);
		if ( NewGWorld(&memworld, 0,
#if TARGET_API_MAC_CARBON
			       GetWindowPortBounds(SDL_Window, &tmprect),
#else
			       &SDL_Window->portRect,
#endif
			       SDL_CTab, nil, 0) != noErr ) {
			SDL_SetError("NewGWorld() failed");
			return(NULL);
		}
		SetWRefCon(SDL_Window, (long)memworld);
		pixmap = GetGWorldPixMap(memworld);
		LockPixels(pixmap);
		current->pitch = (**pixmap).rowBytes & 0x3FFF;
		current->pixels = GetPixBaseAddr(pixmap);
		this->UpdateRects = ROM_WindowUpdate;
	}
	SetPortWindowPort(SDL_Window);
	SelectWindow(SDL_Window);

	/* Handle OpenGL support */
	if ( flags & SDL_OPENGL ) {
		if ( Mac_GL_Init(this) == 0 ) {
			current->flags |= SDL_OPENGL;
		} else {
			current = NULL;
		}
	}
	
	if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) )
	   current->flags |= SDL_HWPALETTE;
	   
	/* We're live! */
	return(current);
}
void init()
{
	RgnHandle			tempRgn;
	Rect				BaseRect;
	OSErr				err;
	long				QDfeature/*, OSfeature*/;
	GDHandle			SaveGD;
	CGrafPtr			SavePort;

	/*	Initialize Managaer.	*/
	//InitGraf(&qd.thePort);
	//InitWindows();
	//InitDialogs(nil);
	InitCursor();
	FlushEvents(everyEvent, 0);
	
	/*	Set up menus.	*/
	mymenu0 = GetMenu(appleID);
	//AppendResMenu(mymenu0, 'DRVR');
	InsertMenu(mymenu0,0);
	mymenu1 = GetMenu(fileID);
	InsertMenu(mymenu1,0);
	DrawMenuBar();
	DoneFlag = false;
	ThePict = GetPicture(PictID);
	if (ThePict == nil)
		DoneFlag = true;

	/*	Use Gestalt to find is QuickDraw is avaiable.	*/
	/*if ((GetOSTrapAddress(Gestalttest) != GetOSTrapAddress(NoTrap))) {
		err = Gestalt(gestaltQuickdrawVersion, &QDfeature);
		if (err)
			DoneFlag = true;
		err = Gestalt(gestaltSystemVersion, &OSfeature);
		if (err)
			DoneFlag = true;
		if (!DoneFlag && (QDfeature & 0x0f00) != 0x0200 && OSfeature < 0x0605)
			DoneFlag = true;
		}
	else
		DoneFlag = true;*/
	
	err = Gestalt(gestaltQuickdrawVersion, &QDfeature);
	if (err != noErr || QDfeature < gestalt32BitQD)
		DoneFlag = true;

	/*	Set Rects.	*/
	SetRect(&BaseRect, 40, 60, 472, 282);
	SetRect(&WinMinusScroll, BaseRect.left-40, BaseRect.top-60, BaseRect.right-60, 
				BaseRect.bottom - 80);
	SetRect(&InitWindowSize, WinMinusScroll.left, WinMinusScroll.top, 
							WinMinusScroll.right, WinMinusScroll.bottom);
	tempRgn = GetGrayRgn();
	HLock ((Handle) tempRgn);
	//TotalRect = (**tempRgn).rgnBBox;
	GetRegionBounds(tempRgn, &TotalRect);
	/*SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40, 
				(**tempRgn).rgnBBox.bottom - 40);*/
	SetRect(&minRect, 80, 80, TotalRect.right - 40, TotalRect.bottom - 40);
	HUnlock ((Handle) tempRgn);

	/*	Open window and set up picture.	*/
	GetGWorld (&SavePort, &SaveGD);
	mycolors = GetCTable (clutID);
	(*mycolors)->ctFlags |= 0x4000;

	myWindow = NewCWindow(nil, &BaseRect, (ConstStr255Param)"", true, zoomDocProc, 
							(WindowPtr) -1, true, 150);
	SetGWorld(GetWindowPort(myWindow), SaveGD);
	DrawGrowIcon (myWindow);

	srcPalette = NewPalette (((**mycolors).ctSize)+1, mycolors,
			pmTolerant + pmExplicit + pmAnimated, 0);
	SetPalette ((WindowPtr) myWindow, srcPalette, true);
	
	GetGWorld (&SavePort, &SaveGD);
	err = NewGWorld (&offscreenGWorld, 8, &InitWindowSize, mycolors, nil, 0);
	if (err)
		Debugger();
	SetGWorld (offscreenGWorld, nil);
	EraseRect (&InitWindowSize);
	DrawPicture (ThePict, &InitWindowSize);
	SetGWorld (SavePort, SaveGD);
}
Exemple #11
0
CWindowPtr
createdirwindow (CInfoPBRec *dir, Rect *r, char **path, short volume)
{
  CWindowPeek wp;
  short i;
  OSErr e;
  Str255 s;
  opendirinfo **infoh;
  ControlHandle c;

  if (executor_p ())
    {
      CInfoPBRec cpb;
      OSErr e2;

      cpb = *dir;
      e2 = unixmount (&cpb);
      if (e2 == noErr)
	volume = cpb.hFileInfo.ioVRefNum;
    }
  tail (*path, s);
  wp = (CWindowPeek) NewPtr (sizeof (CWindowRecord));
  wp = (CWindowPeek) NewCWindow (wp, r, s, false, documentProc, (WindowPtr) 0, true, 0);
  wp->refCon = (long) NewHandle (sizeof (opendirinfo));

  infoh = (opendirinfo **) wp->refCon;
#if 1
/* This handle should be unlocked later, but it isn't for Executor 1.99m */
  HLock ((Handle) infoh);
#endif /* 0 */
  (*infoh)->sortorder = ALPHABETIC;
  (*infoh)->items = (ControlHandle (**)[])
    NewHandle (BANDARRAYSIZE * sizeof (ControlHandle));
  (*infoh)->path = path;
  (*infoh)->iodirid = dir->dirInfo.ioDrDirID;
  (*infoh)->vrefnum = volume;
  (*infoh)->numitems = 0;
  (*infoh)->view = ICONVIEW;

/* NOTE: r is the wrong rectangle, but it gets fixed before it's used. */
  (*infoh)->sbar = NewControl ((WindowPtr) wp, r, (StringPtr) "\p", false, 0, 0, 0,
			       scrollBarProc, 0);
  MoveControl ((*infoh)->sbar, wp->port.portRect.right - SCROLLBARWIDTH, 0);

  dir->hFileInfo.ioNamePtr = s;
  dir->hFileInfo.ioVRefNum = volume;
  e = noErr;
  for (i = 1; e == noErr; i++)
    {
      checkgrowitemarray (i, (*infoh)->items);
      dir->hFileInfo.ioDirID = (*infoh)->iodirid;
      dir->hFileInfo.ioFDirIndex = i;
      e = PBGetCatInfo (dir, false);
      if (e == noErr && !(dir->hFileInfo.ioFlFndrInfo.fdFlags & fInvisible))
	{
	  c = addtolist ((WindowPeek) wp, s, dir->hFileInfo.ioFlParID, volume);
	  if (dir->hFileInfo.ioFlFndrInfo.fdType == 'APPL' ||
	      dir->hFileInfo.ioFlFndrInfo.fdType == 'dfil')
	    hashicons (c);
	}
    }
  setwindowicons (wp);
  straightenwindow ((WindowPtr) wp);
  return (CWindowPtr) wp;
}