_HYPlatformGraphicPane::_HYPlatformGraphicPane(int h, int w, int d) { Rect bRect; bRect.left = bRect.top = 0; bRect.right = w; bRect.bottom = h; short errCode; if (d>1) { errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice|useTempMem); } else { errCode = NewGWorld (&thePane,d,&bRect,0,nil,0); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,nil,useTempMem); } fillColor = NewPixPat(); //backColor = NewPixPat(); if (errCode||(!fillColor)) { _String errMsg ("MacOS Error "); errMsg = errMsg & (long)errCode &" while trying to allocate memory for GraphicPane"; FlagError (errMsg); } savedPort = nil; }
void _HYPlatformGraphicPane::_SetPaneSize (int h,int w, int d) { DisposeGWorld (thePane); Rect bRect; bRect.left = bRect.top = 0; bRect.right = w; bRect.bottom = h; short errCode; if (d>1) { errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice|useTempMem); } else { errCode = NewGWorld (&thePane,d,&bRect,0,nil,0); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,nil,useTempMem); } if (errCode) { _String errMsg ("MacOS Error "); errMsg = errMsg & (long)errCode &" while trying to allocate memory for GraphicPane"; FlagError (errMsg); } }
/* calculate a new stdState rectangle based on the maximum bounds, positioned on the device which the given window overlaps most */ void build_zoom_rectangle( WindowPtr window, Rect *bounds) { GDHandle device; WStateDataHandle window_state; Rect zoomed, unzoomed; Rect device_bounds; short bias; window_state= (WStateDataHandle) (((CWindowRecord *)window)->dataHandle); zoomed= (*window_state)->stdState; unzoomed= (*window_state)->userState; /* official Apple source sends the title bar along with this rectangle, but that isnÕt useful */ device= MostDevice(&unzoomed); if (!device) device= GetMainDevice(); bias= unzoomed.top-(*((WindowPeek)window)->strucRgn)->rgnBBox.top-1; if (device==GetMainDevice()) bias+= GetMBarHeight(); device_bounds= (*device)->gdRect; InsetRect(&device_bounds, 3, 3); device_bounds.top+= bias; zoomed= *bounds; OffsetRect(&zoomed, unzoomed.left-zoomed.left, unzoomed.top-zoomed.top); if (RECTANGLE_HEIGHT(&zoomed)>RECTANGLE_HEIGHT(&device_bounds)) { zoomed.top= device_bounds.top; zoomed.bottom= device_bounds.bottom; } else { if (zoomed.bottom>device_bounds.bottom) OffsetRect(&zoomed, 0, device_bounds.bottom-zoomed.bottom); if (zoomed.top<device_bounds.top) OffsetRect(&zoomed, 0, device_bounds.top-zoomed.top); } if (RECTANGLE_WIDTH(&zoomed)>RECTANGLE_WIDTH(&device_bounds)) { zoomed.left= device_bounds.left; zoomed.right= device_bounds.right; } else { if (zoomed.right>device_bounds.right) OffsetRect(&zoomed, device_bounds.right-zoomed.right, 0); if (zoomed.left<device_bounds.left) OffsetRect(&zoomed, device_bounds.left-zoomed.left, 0); } (*window_state)->stdState= zoomed; return; }
void ROM_VideoQuit(_THIS) { int i; /* Free current video mode */ ROM_UnsetVideoMode(this, this->screen); if ( SDL_Window ) { DisposeWindow(SDL_Window); SDL_Window = nil; } /* Free palette and restore original one */ if ( SDL_CTab != nil ) { DisposeHandle((Handle)SDL_CTab); SDL_CTab = nil; } if ( SDL_CPal != nil ) { DisposePalette(SDL_CPal); SDL_CPal = nil; } RestoreDeviceClut(GetMainDevice()); #if SDL_MACCLASSIC_GAMMA_SUPPORT Mac_QuitGamma(this); #endif /* Free list of video modes */ if ( SDL_modelist != NULL ) { for ( i=0; SDL_modelist[i]; ++i ) { SDL_free(SDL_modelist[i]); } SDL_free(SDL_modelist); SDL_modelist = NULL; } }
void wxClientDisplayRect(int *x, int *y, int *width, int *height) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 HIRect bounds ; HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, &bounds); if ( x ) *x = bounds.origin.x; if ( y ) *y = bounds.origin.y; if ( width ) *width = bounds.size.width; if ( height ) *height = bounds.size.height; #else Rect r; GetAvailableWindowPositioningBounds( GetMainDevice() , &r ); if ( x ) *x = r.left; if ( y ) *y = r.top; if ( width ) *width = r.right - r.left; if ( height ) *height = r.bottom - r.top; #endif }
void MCStack::setgeom() { //set stack(window) size or position from script if (MCnoui || !opened) return; // MW-2009-09-25: Ensure things are the right size when doing // remote dialog/menu windows. if (window == DNULL) { // MW-2011-08-18: [[ Redraw ]] Update to use redraw. MCRedrawLockScreen(); state &= ~CS_NEED_RESIZE; resize(rect . width, rect . height); MCRedrawUnlockScreen(); mode_setgeom(); return; } // MW-2011-09-12: [[ MacScroll ]] Make sure we apply the current scroll setting. applyscroll(); Rect windRect; GetPortBounds(GetWindowPort((WindowPtr)window->handle.window), &windRect); SetGWorld(GetWindowPort((WindowPtr)window->handle.window), GetMainDevice()); Point p; p.h = windRect.left; p.v = windRect.top; LocalToGlobal(&p); int2 curWidth = windRect.right - windRect.left; int2 curHeight = windRect.bottom - windRect.top; if (IsWindowVisible((WindowPtr)window->handle.window)) { if (mode != WM_SHEET && mode != WM_DRAWER && (rect.x != p.h || rect.y != p.v)) { MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False); state |= CS_BEEN_MOVED; } if (rect.width != curWidth || rect.height != curHeight) { SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True); resize(curWidth, curHeight + getscroll()); } state &= ~CS_NEED_RESIZE; } else { if (mode != WM_SHEET && mode != WM_DRAWER) MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False); if (rect.width != curWidth || rect.height != curHeight) { SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True); resize(curWidth, curHeight + getscroll()); } state &= ~(CS_BEEN_MOVED | CS_NEED_RESIZE); } }
void MCScreenDC::expose() { SetGWorld(GetWindowPort(getinvisiblewin()), GetMainDevice()); EventRecord event; while (GetNextEvent(updateMask, &event)) doredraw(event); }
/*===================================== CreatePPWindow Description: Safer way to create a window. ======================================*/ LWindow *SUMiscUtils::CreatePPWindow( ResIDT inWindowID ) { StSaveGWorld aSaver; LWindow *theWindow = nil; // create the window ::SetGDevice( GetMainDevice() ); // bug in Mac toolbox requires this theWindow = LWindow::CreateWindow( inWindowID, LCommander::GetTopCommander() ); return( theWindow ); }
void createImage() { GDHandle mainDevice; mainDevice = GetMainDevice(); /* Store the screen's pixmap image in the offscreen pixmap. */ CopyBits( (BitMap *)*(**mainDevice).gdPMap, (BitMap *)(&gPixMap), &(**(**mainDevice).gdPMap).bounds, &gPixMap.bounds, srcCopy, 0l ); }
static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right) { Rect outAvailableRect; GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); *top = outAvailableRect.top; *left = outAvailableRect.left; *bottom = outAvailableRect.bottom; *right = outAvailableRect.right; }
/* restores former dialog size and (on Mac) position */ bool CDlgItemProperties::RestoreState() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); int iWidth, iHeight; wxASSERT(pConfig); if (!pConfig) return false; pConfig->SetPath(m_strBaseConfigLocation); pConfig->Read(wxT("Width"), &iWidth, wxDefaultCoord); pConfig->Read(wxT("Height"), &iHeight, wxDefaultCoord); #ifndef __WXMAC__ // Set size to saved values or defaults if no saved values SetSize(iWidth, iHeight); #else int iTop, iLeft; pConfig->Read(wxT("YPos"), &iTop, wxDefaultCoord); pConfig->Read(wxT("XPos"), &iLeft, wxDefaultCoord); // If either co-ordinate is less then 0 then set it equal to 0 to ensure // it displays on the screen. if ((iLeft < 0) && (iLeft != wxDefaultCoord)) iLeft = 30; if ((iTop < 0) && (iTop != wxDefaultCoord)) iTop = 30; // Set size and position to saved values or defaults if no saved values SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); // Now make sure window is on screen GetScreenPosition(&iLeft, &iTop); GetSize(&iWidth, &iHeight); Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar region if (!RectInRgn(&titleRect, displayRgn)) { iTop = iLeft = 30; SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); } DisposeRgn(menuRgn); DisposeRgn(displayRgn); #endif return true; }
static void get_device_area_offset( Rect *frame, Point *offset) { GDHandle device= GetMainDevice(); SetPt(offset, (*device)->gdRect.left + RECTANGLE_WIDTH(&(*device)->gdRect)/2, (*device)->gdRect.top + RECTANGLE_HEIGHT(&(*device)->gdRect)/2); SetPt(offset, frame->left + RECTANGLE_WIDTH(frame)/2 - offset->h/DEVICE_AREA_SCALE, frame->top + RECTANGLE_HEIGHT(frame)/2 - offset->v/DEVICE_AREA_SCALE); return; }
void MCScreenDC::querymouse(int2 &x, int2 &y) { CGrafPtr oldport; GDHandle olddevice; GetGWorld(&oldport, &olddevice); MoveWindow(invisibleWin, 0, 0, False); // OS X moves this. SetGWorld(GetWindowPort(invisibleWin), GetMainDevice()); Point mloc; GetMouse(&mloc); //get local mouse position SetGWorld(oldport, olddevice); x = mloc.h; y = mloc.v; }
void CDlgMessages::RestoreWindowDimensions() { wxString strBaseConfigLocation = wxString(wxT("/Simple/Messages")); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); bool bWindowIconized = false; bool bWindowMaximized = false; int iHeight = 0; int iWidth = 0; int iTop = 0; int iLeft = 0; wxASSERT(pConfig); pConfig->SetPath(strBaseConfigLocation); pConfig->Read(wxT("YPos"), &iTop, 30); pConfig->Read(wxT("XPos"), &iLeft, 30); pConfig->Read(wxT("Width"), &iWidth, 640); pConfig->Read(wxT("Height"), &iHeight, 480); pConfig->Read(wxT("WindowIconized"), &bWindowIconized, false); pConfig->Read(wxT("WindowMaximized"), &bWindowMaximized, false); #ifndef __WXMAC__ Iconize(bWindowIconized); Maximize(bWindowMaximized); if (!IsIconized() && !IsMaximized()) { SetSize(-1, -1, iWidth, iHeight); } #else // ! __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion if (!RectInRgn(&titleRect, displayRgn)) iTop = iLeft = 30; DisposeRgn(menuRgn); DisposeRgn(displayRgn); SetSize(iLeft, iTop, iWidth, iHeight); #endif // ! __WXMAC__ }
void COXDragDockContext::Move(CPoint pt) { CPoint ptOffset = pt - m_ptLast; #ifdef _MAC // prevent dragging the floating window completely under the menu bar GDHandle hgd = _AfxFindDevice(pt.x, pt.y); if (hgd == NULL || hgd == GetMainDevice() || TestDeviceAttribute(hgd, hasAuxMenuBar)) { CRect rect; if ((HORZF(m_dwStyle) && !m_bFlip) || (VERTF(m_dwStyle) && m_bFlip)) rect = m_rectFrameDragHorz; else rect = m_rectFrameDragVert; // determine our new position rect.OffsetRect(ptOffset); // keep us on the screen if we were getting too close to the menu bar int yMBarBottom = (*hgd)->gdRect.top + GetMBarHeight() + 4; if (rect.bottom < yMBarBottom) { pt.y += yMBarBottom - rect.bottom; ptOffset.y += yMBarBottom - rect.bottom; } } #endif // offset all drag rects to new position m_rectDragHorz.OffsetRect(ptOffset); m_rectFrameDragHorz.OffsetRect(ptOffset); m_rectDragVert.OffsetRect(ptOffset); m_rectFrameDragVert.OffsetRect(ptOffset); // these rectangles only move in 1 direction m_rectDragHorzAlone.top += ptOffset.y; m_rectDragHorzAlone.bottom += ptOffset.y; m_rectDragVertAlone.left += ptOffset.x; m_rectDragVertAlone.right += ptOffset.x; m_ptLast = pt; // if control key is down don't dock m_dwOverDockStyle = m_bForceFrame ? 0 : CanDock(); // update feedback DrawFocusRect(); }
static GXDISPLAYMODEHANDLE RLXAPI SearchDisplayMode(int lx, int ly, int bpp) { gl_lx = lx; gl_ly = ly; gl_bpp = bpp == -1 ? (*(*GetMainDevice())->gdPMap)->pixelSize : bpp; if ((g_pRLX->Video.Config & RLXVIDEO_Windowed)==0) { boolean_t ret; g_cgDisplayMode = CGDisplayBestModeForParameters(g_cgDisplayID, bpp, lx, ly, &ret); return ModeHandleToDictRef(g_cgDisplayMode); } return 1; }
WindowSystem::WindowSystem(Options& o) { GDHandle mainGD; //HW/SW Depth Reserved GLint testTypes[][3] = { {AGL_ACCELERATED, 16, 0 }, {AGL_ACCELERATED, 16, 0 }, {AGL_ACCELERATED, 16, 0 }, {0, 16, 0 }, {0, 16, 0 }, {0, 0, 0 } }; GLint testAttrib[][10]= { { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, 16, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE}, { AGL_RGBA, AGL_ACCELERATED, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE}, { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE}, { AGL_RENDERER_ID, AGL_RENDERER_GENERIC_ID, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE}, { AGL_RENDERER_ID, AGL_RENDERER_GENERIC_ID, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16 , AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE} }; AGLPixelFormat pf; GLint index = 0; mainGD = GetMainDevice(); if (!mainGD) throw CantOpenDisplay(); // Construct a vector of DrawingSurfaceConfigs corresponding to the // returned pixel formats vector<DrawingSurfaceConfig*> glpf; while (testTypes[index][1] != 0) { pf = aglChoosePixelFormat(&mainGD, 1, testAttrib[index]); if ( (pf == NULL) && ( testTypes[index][0] == 0) ) { testAttrib[index][1] = 0x30300; pf = aglChoosePixelFormat(&mainGD, 1, testAttrib[index]); } if (pf != NULL) glpf.push_back(new DrawingSurfaceConfig (index+1, pf)); index++; } // Filter the basic list of DrawingSurfaceConfigs according to // constraints provided by the user. (This makes it convenient // to run tests on just a subset of all available configs.) DrawingSurfaceFilter f(o.visFilter); // may throw an exception! surfConfigs = f.filter(glpf, o.maxVisuals); }
static void draw_device_area( GDSpecPtr device_spec, GDHandle selected_device, Rect *frame) { Point offset; GDHandle device; get_device_area_offset(frame, &offset); EraseRect(frame); FrameRect(frame); for (device= GetDeviceList(); device; device= GetNextDevice(device)) { if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) { GDSpec spec; Rect bounds; BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); get_device_area_frame(device, &bounds, offset); RGBForeColor(HasDepthGDSpec(&spec) ? &rgb_dark_gray : &rgb_white); PaintRect(&bounds); RGBForeColor(&rgb_black); if (device==selected_device) PenSize(2, 2); FrameRect(&bounds); PenSize(1, 1); if (device==GetMainDevice()) { bounds.bottom= bounds.top + DEVICE_AREA_MENU_BAR_HEIGHT; EraseRect(&bounds); FrameRect(&bounds); } } } return; }
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); }
Display::Display(DisplayRep* d) { rep_ = d; x_point_ = 1; y_point_ = 1; x_pixel_ = 1; y_pixel_ = 1; // ---- determine display size ---- GDHandle theGraphicsDevice = GetMainDevice(); Rect theScreen = (*theGraphicsDevice)->gdRect; rep_->pwidth_ = (theScreen.right) - (theScreen.left); rep_->pheight_ = (theScreen.bottom) - (theScreen.top);; rep_->width_ = to_coord( rep_->pwidth_, Dimension_X); rep_->height_ = to_coord( rep_->pheight_, Dimension_Y); }
int getScreenWidth() { int result = 0; #ifdef VAR_HAS_UI #ifdef ANDROID // GLint m_viewport[2]; // glGetIntegerv(GL_MAX_VIEWPORT_DIMS, m_viewport); // result = m_viewport[0]; #else #ifdef osx Rect outAvailableRect; GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); result = outAvailableRect.right - outAvailableRect.left; #else Display *display = XOpenDisplay(NULL); result = DisplayWidth(display,0); XCloseDisplay(display); #endif #endif #endif return result; }
void initPixmap() { Ptr offBaseAddr; /* Pointer to the off-screen pixel image */ short bytesPerRow; GDHandle mainDevice; CTabHandle cTable; short depth; /* Get a handle to the main device. */ mainDevice = GetMainDevice(); /* Store its current pixel depth. */ depth = (**(**mainDevice).gdPMap).pixelSize; /* Make an identical copy of its pixmap's colortable. */ cTable = (**(**mainDevice).gdPMap).pmTable; (void) HandToHand( (Handle*)(&cTable) ); bytesPerRow = ((gBounds.right - gBounds.left) * depth) / 8; offBaseAddr = NewPtr((unsigned long)bytesPerRow * (gBounds.bottom - gBounds.top)); gPixMap.baseAddr = offBaseAddr; /* Point to image */ gPixMap.rowBytes = bytesPerRow | 0x8000; /* MSB set for PixMap */ gPixMap.bounds = gBounds; /* Use given bounds */ gPixMap.pmVersion = 0; /* No special stuff */ gPixMap.packType = 0; /* Default PICT pack */ gPixMap.packSize = 0; /* Always zero in mem */ gPixMap.hRes = 72; /* 72 DPI default res */ gPixMap.vRes = 72; /* 72 DPI default res */ gPixMap.pixelSize = depth; /* Set # bits/pixel */ //gPixMap.planeBytes = 0; /* Not used */ //gPixMap.pmReserved = 0; /* Not used */ gPixMap.pixelType = 0; /* Indicates indexed */ gPixMap.cmpCount = 1; /* Have 1 component */ gPixMap.cmpSize = depth; /* Component size=depth */ gPixMap.pmTable = cTable; /* Handle to CLUT */ }
OSErr CreateNewSGChannelForRecording(ComponentInstance seqGrab, SGDataUPP dataProc, CGrafPtr drawPort, Rect *theRect, SGChannel *sgChannel, long refCon) { OSErr err = noErr; BailErr((err = SGInitialize(seqGrab))); // tell it we're not making a movie BailErr((err = SGSetDataRef(seqGrab,0,0,seqGrabDontMakeMovie))); // It wants a port, even if its not drawing to it BailErr((err = SGSetGWorld(seqGrab, drawPort, GetMainDevice()))); BailErr((err = SGNewChannel(seqGrab, VideoMediaType, sgChannel))); // let the user configure the video channel BailErr((err = SGSettingsDialog(seqGrab, *sgChannel, 0, nil, 0, nil, 0))); BailErr((err = SGSetChannelBounds(*sgChannel, theRect))); // set usage for new video channel to avoid playthrough BailErr((err = SGSetChannelUsage(*sgChannel, seqGrabRecord ))); //note we don't set seqGrabPlayDuringRecord BailErr((err = SGSetDataProc(seqGrab, dataProc, refCon))); BailErr((err = SGStartRecord(seqGrab))); bail: return err; }
OSErr SetupPickMonitorPane(ControlRef inPane, DisplayIDType inDefaultMonitor) { GDHandle dev = GetDeviceList(); OSErr err = noErr; // make the default monitor the selected device if (inDefaultMonitor) DMGetGDeviceByDisplayID(inDefaultMonitor, &sSelectedDevice, true); else sSelectedDevice = GetMainDevice(); // build the list of monitors sNumMonitors = 0; while (dev && sNumMonitors < kMaxMonitors) { if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive)) { sMonitors[sNumMonitors].device = dev; sMonitors[sNumMonitors].origRect = (**dev).gdRect; sMonitors[sNumMonitors].isMain = (dev == GetMainDevice()); sNumMonitors++; } dev = GetNextDevice(dev); } // calculate scaled rects if (sNumMonitors) { Rect origPaneRect, paneRect; Rect origGrayRect, grayRect, scaledGrayRect; float srcAspect, dstAspect, scale; int i; GetControlBounds(inPane, &origPaneRect); paneRect = origPaneRect; OffsetRect(&paneRect, -paneRect.left, -paneRect.top); GetRegionBounds(GetGrayRgn(), &origGrayRect); grayRect = origGrayRect; OffsetRect(&grayRect, -grayRect.left, -grayRect.top); srcAspect = (float)grayRect.right / (float)grayRect.bottom; dstAspect = (float)paneRect.right / (float)paneRect.bottom; scaledGrayRect = paneRect; if (srcAspect < dstAspect) { scaledGrayRect.right = (float)paneRect.bottom * srcAspect; scale = (float)scaledGrayRect.right / grayRect.right; } else { scaledGrayRect.bottom = (float)paneRect.right / srcAspect; scale = (float)scaledGrayRect.bottom / grayRect.bottom; } for (i = 0; i < sNumMonitors; i++) { Rect r = sMonitors[i].origRect; Rect r2 = r; // normalize rect and scale OffsetRect(&r, -r.left, -r.top); r.bottom = (float)r.bottom * scale; r.right = (float)r.right * scale; // offset rect wrt gray region OffsetRect(&r, (float)(r2.left - origGrayRect.left) * scale, (float)(r2.top - origGrayRect.top) * scale); sMonitors[i].scaledRect = r; } // center scaledGrayRect in the pane OffsetRect(&scaledGrayRect, (paneRect.right - scaledGrayRect.right) / 2, (paneRect.bottom - scaledGrayRect.bottom) / 2); // offset monitors to match for (i = 0; i < sNumMonitors; i++) OffsetRect(&sMonitors[i].scaledRect, scaledGrayRect.left, scaledGrayRect.top); } else return paramErr; // setup the procs for the pick monitor user pane err = SetupUserPaneProcs(inPane, drawProc, hitTestProc, trackingProc); return err; }
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; }
/*
bool GHOST_SystemCarbon::handleMouseDown(EventRef event) { WindowPtr window; short part; BitMap screenBits; bool handled = true; GHOST_WindowCarbon *ghostWindow; Point mousePos = {0, 0}; ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos); part = ::FindWindow(mousePos, &window); ghostWindow = (GHOST_WindowCarbon *) ::GetWRefCon(window); switch (part) { case inMenuBar: handleMenuCommand(::MenuSelect(mousePos)); break; case inDrag: /* * The DragWindow() routine creates a lot of kEventWindowBoundsChanged * events. By setting m_ignoreWindowSizedMessages these are suppressed. * \see GHOST_SystemCarbon::handleWindowEvent(EventRef event) */ /* even worse: scale window also generates a load of events, and nothing * is handled (read: client's event proc called) until you release mouse (ton) */ GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window"); m_ignoreWindowSizedMessages = true; ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds); m_ignoreWindowSizedMessages = false; pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) ); break; case inContent: if (window != ::FrontWindow()) { ::SelectWindow(window); /* * We add a mouse down event on the newly actived window */ //GHOST_PRINT("GHOST_SystemCarbon::handleMouseDown(): adding mouse down event, " << ghostWindow << "\n"); EventMouseButton button; ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button))); } else { handled = false; } break; case inGoAway: GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); if (::TrackGoAway(window, mousePos)) { // todo: add option-close, because it's in the HIG // if (event.modifiers & optionKey) { // Close the clean documents, others will be confirmed one by one. //} // else { pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow)); //} } break; case inGrow: GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); ::ResizeWindow(window, mousePos, NULL, NULL); break; case inZoomIn: case inZoomOut: GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); if (::TrackBox(window, mousePos, part)) { int macState; macState = ghostWindow->getMac_windowState(); if (macState == 0) ::ZoomWindow(window, part, true); else if (macState == 2) { // always ok ::ZoomWindow(window, part, true); ghostWindow->setMac_windowState(1); } else { // need to force size again // GHOST_TUns32 scr_x,scr_y; /*unused*/ Rect outAvailableRect; ghostWindow->setMac_windowState(2); ::GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect); //this->getMainDisplayDimensions(scr_x,scr_y); ::SizeWindow(window, outAvailableRect.right - outAvailableRect.left, outAvailableRect.bottom - outAvailableRect.top - 1, false); ::MoveWindow(window, outAvailableRect.left, outAvailableRect.top, true); } } break; default: handled = false; break; } return handled; }
int _glfwPlatformOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode, _GLFWhints* hints ) { OSStatus error; ProcessSerialNumber psn; unsigned int windowAttributes; // TO DO: Refactor this function! _glfwWin.WindowFunctions = ( _glfwWin.Fullscreen ? &_glfwMacFSWindowFunctions : &_glfwMacDWWindowFunctions ); // Windowed or fullscreen; AGL or CGL? Quite the mess... // AGL appears to be the only choice for attaching OpenGL contexts to // Carbon windows, but it leaves the user no control over fullscreen // mode stretching. Solution: AGL for windowed, CGL for fullscreen. if( !_glfwWin.Fullscreen ) { // create AGL pixel format attribute list GLint AGLpixelFormatAttributes[256]; int numAGLAttrs = 0; AGLpixelFormatAttributes[numAGLAttrs++] = AGL_RGBA; AGLpixelFormatAttributes[numAGLAttrs++] = AGL_DOUBLEBUFFER; if( hints->Stereo ) { AGLpixelFormatAttributes[numAGLAttrs++] = AGL_STEREO; } _setAGLAttribute( AGL_AUX_BUFFERS, hints->AuxBuffers); _setAGLAttribute( AGL_RED_SIZE, redbits ); _setAGLAttribute( AGL_GREEN_SIZE, greenbits ); _setAGLAttribute( AGL_BLUE_SIZE, bluebits ); _setAGLAttribute( AGL_ALPHA_SIZE, alphabits ); _setAGLAttribute( AGL_DEPTH_SIZE, depthbits ); _setAGLAttribute( AGL_STENCIL_SIZE, stencilbits ); _setAGLAttribute( AGL_ACCUM_RED_SIZE, hints->AccumRedBits ); _setAGLAttribute( AGL_ACCUM_GREEN_SIZE, hints->AccumGreenBits ); _setAGLAttribute( AGL_ACCUM_BLUE_SIZE, hints->AccumBlueBits ); _setAGLAttribute( AGL_ACCUM_ALPHA_SIZE, hints->AccumAlphaBits ); if( hints->Samples > 1 ) { _setAGLAttribute( AGL_SAMPLE_BUFFERS_ARB, 1 ); _setAGLAttribute( AGL_SAMPLES_ARB, hints->Samples ); AGLpixelFormatAttributes[numAGLAttrs++] = AGL_NO_RECOVERY; } AGLpixelFormatAttributes[numAGLAttrs++] = AGL_NONE; // create pixel format descriptor AGLDevice mainMonitor = GetMainDevice(); AGLPixelFormat pixelFormat = aglChoosePixelFormat( &mainMonitor, 1, AGLpixelFormatAttributes ); if( pixelFormat == NULL ) { fprintf( stderr, "glfwOpenWindow failing because it can't create a pixel format\n" ); return GL_FALSE; } // store pixel format's values for _glfwPlatformGetWindowParam's use _getAGLAttribute( AGL_ACCELERATED, _glfwWin.Accelerated ); _getAGLAttribute( AGL_RED_SIZE, _glfwWin.RedBits ); _getAGLAttribute( AGL_GREEN_SIZE, _glfwWin.GreenBits ); _getAGLAttribute( AGL_BLUE_SIZE, _glfwWin.BlueBits ); _getAGLAttribute( AGL_ALPHA_SIZE, _glfwWin.AlphaBits ); _getAGLAttribute( AGL_DEPTH_SIZE, _glfwWin.DepthBits ); _getAGLAttribute( AGL_STENCIL_SIZE, _glfwWin.StencilBits ); _getAGLAttribute( AGL_ACCUM_RED_SIZE, _glfwWin.AccumRedBits ); _getAGLAttribute( AGL_ACCUM_GREEN_SIZE, _glfwWin.AccumGreenBits ); _getAGLAttribute( AGL_ACCUM_BLUE_SIZE, _glfwWin.AccumBlueBits ); _getAGLAttribute( AGL_ACCUM_ALPHA_SIZE, _glfwWin.AccumAlphaBits ); _getAGLAttribute( AGL_AUX_BUFFERS, _glfwWin.AuxBuffers ); _getAGLAttribute( AGL_STEREO, _glfwWin.Stereo ); _getAGLAttribute( AGL_SAMPLES_ARB, _glfwWin.Samples ); _glfwWin.RefreshRate = hints->RefreshRate; // create AGL context _glfwWin.AGLContext = aglCreateContext( pixelFormat, NULL ); aglDestroyPixelFormat( pixelFormat ); if( _glfwWin.AGLContext == NULL ) { fprintf( stderr, "glfwOpenWindow failing because it can't create an OpenGL context\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } if (_glfwLibrary.Unbundled) { if( GetCurrentProcess( &psn ) != noErr ) { fprintf( stderr, "glfwOpenWindow failing because it can't get its PSN\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } if( TransformProcessType( &psn, kProcessTransformToForegroundApplication ) != noErr ) { fprintf( stderr, "glfwOpenWindow failing because it can't become a foreground application\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } /* Keith Bauer 2007-07-12 - I don't believe this is desirable if( SetFrontProcess( &psn ) != noErr ) { fprintf( stderr, "glfwOpenWindow failing because it can't become the front process\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } */ } // create window Rect windowContentBounds; windowContentBounds.left = 0; windowContentBounds.top = 0; windowContentBounds.right = width; windowContentBounds.bottom = height; windowAttributes = ( kWindowCloseBoxAttribute \ | kWindowCollapseBoxAttribute \ | kWindowStandardHandlerAttribute ); if( hints->WindowNoResize ) { windowAttributes |= kWindowLiveResizeAttribute; } else { windowAttributes |= ( kWindowFullZoomAttribute | kWindowResizableAttribute ); } error = CreateNewWindow( kDocumentWindowClass, windowAttributes, &windowContentBounds, &( _glfwWin.MacWindow ) ); if( ( error != noErr ) || ( _glfwWin.MacWindow == NULL ) ) { fprintf( stderr, "glfwOpenWindow failing because it can't create a window\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } _glfwWin.WindowUPP = NewEventHandlerUPP( _glfwWindowEventHandler ); error = InstallWindowEventHandler( _glfwWin.MacWindow, _glfwWin.WindowUPP, GetEventTypeCount( GLFW_WINDOW_EVENT_TYPES ), GLFW_WINDOW_EVENT_TYPES, NULL, NULL ); if( error != noErr ) { fprintf( stderr, "glfwOpenWindow failing because it can't install window event handlers\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } // Don't care if we fail here (void)SetWindowTitleWithCFString( _glfwWin.MacWindow, CFSTR( "GLFW Window" ) ); (void)RepositionWindow( _glfwWin.MacWindow, NULL, kWindowCenterOnMainScreen ); if( !aglSetDrawable( _glfwWin.AGLContext, GetWindowPort( _glfwWin.MacWindow ) ) ) { fprintf( stderr, "glfwOpenWindow failing because it can't draw to the window\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } // Make OpenGL context current if( !aglSetCurrentContext( _glfwWin.AGLContext ) ) { fprintf( stderr, "glfwOpenWindow failing because it can't make the OpenGL context current\n" ); _glfwPlatformCloseWindow(); return GL_FALSE; } // show window ShowWindow( _glfwWin.MacWindow ); return GL_TRUE; } else { CGDisplayErr cgErr; CGLError cglErr; CFDictionaryRef optimalMode; CGLPixelFormatObj CGLpfObj; long numCGLvs = 0; CGLPixelFormatAttribute CGLpixelFormatAttributes[64]; int numCGLAttrs = 0; // variables for enumerating color depths GLint rgbColorDepth; GLint rgbaAccumDepth = 0; int rgbChannelDepth = 0; // CGL pixel format attributes _setCGLAttribute( kCGLPFADisplayMask, CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ) ); if( hints->Stereo ) { CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAStereo; } if( hints->Samples > 1 ) { _setCGLAttribute( kCGLPFASamples, (CGLPixelFormatAttribute)hints->Samples ); _setCGLAttribute( kCGLPFASampleBuffers, (CGLPixelFormatAttribute)1 ); CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFANoRecovery; } CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAFullScreen; CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFADoubleBuffer; CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAAccelerated; CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFANoRecovery; CGLpixelFormatAttributes[ numCGLAttrs++ ] = kCGLPFAMinimumPolicy; _setCGLAttribute( kCGLPFAAccumSize, (CGLPixelFormatAttribute)( hints->AccumRedBits \ + hints->AccumGreenBits \ + hints->AccumBlueBits \ + hints->AccumAlphaBits ) ); _setCGLAttribute( kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphabits ); _setCGLAttribute( kCGLPFADepthSize, (CGLPixelFormatAttribute)depthbits ); _setCGLAttribute( kCGLPFAStencilSize, (CGLPixelFormatAttribute)stencilbits ); _setCGLAttribute( kCGLPFAAuxBuffers, (CGLPixelFormatAttribute)hints->AuxBuffers ); CGLpixelFormatAttributes[ numCGLAttrs++ ] = (CGLPixelFormatAttribute)NULL; // create a suitable pixel format with above attributes.. cglErr = CGLChoosePixelFormat( CGLpixelFormatAttributes, &CGLpfObj, &numCGLvs ); if( cglErr != kCGLNoError ) { return GL_FALSE; } // ..and create a rendering context using that pixel format cglErr = CGLCreateContext( CGLpfObj, NULL, &_glfwWin.CGLContext ); if( cglErr != kCGLNoError ) { return GL_FALSE; } // enumerate depth of RGB channels - unlike AGL, CGL works with // a single parameter reflecting the full depth of the frame buffer (void)CGLDescribePixelFormat( CGLpfObj, 0, kCGLPFAColorSize, &rgbColorDepth ); if( rgbColorDepth == 24 || rgbColorDepth == 32 ) { rgbChannelDepth = 8; } if( rgbColorDepth == 16 ) { rgbChannelDepth = 5; } // get pixel depth of accumulator - I haven't got the slightest idea // how this number conforms to any other channel depth than 8 bits, // so this might end up giving completely knackered results... (void)CGLDescribePixelFormat( CGLpfObj, 0, kCGLPFAAccumSize, &rgbaAccumDepth ); if( rgbaAccumDepth == 32 ) { rgbaAccumDepth = 8; } // store values of pixel format for _glfwPlatformGetWindowParam's use _getCGLAttribute( kCGLPFAAccelerated, _glfwWin.Accelerated ); _getCGLAttribute( rgbChannelDepth, _glfwWin.RedBits ); _getCGLAttribute( rgbChannelDepth, _glfwWin.GreenBits ); _getCGLAttribute( rgbChannelDepth, _glfwWin.BlueBits ); _getCGLAttribute( kCGLPFAAlphaSize, _glfwWin.AlphaBits ); _getCGLAttribute( kCGLPFADepthSize, _glfwWin.DepthBits ); _getCGLAttribute( kCGLPFAStencilSize, _glfwWin.StencilBits ); _getCGLAttribute( rgbaAccumDepth, _glfwWin.AccumRedBits ); _getCGLAttribute( rgbaAccumDepth, _glfwWin.AccumGreenBits ); _getCGLAttribute( rgbaAccumDepth, _glfwWin.AccumBlueBits ); _getCGLAttribute( rgbaAccumDepth, _glfwWin.AccumAlphaBits ); _getCGLAttribute( kCGLPFAAuxBuffers, _glfwWin.AuxBuffers ); _getCGLAttribute( kCGLPFAStereo, _glfwWin.Stereo ); _glfwWin.RefreshRate = hints->RefreshRate; // destroy our pixel format (void)CGLDestroyPixelFormat( CGLpfObj ); // capture the display for our application cgErr = CGCaptureAllDisplays(); if( cgErr != kCGErrorSuccess ) { return GL_FALSE; } // find closest matching NON-STRETCHED display mode.. optimalMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty( kCGDirectMainDisplay, rgbColorDepth, width, /* Check further to the right -> */ height, hints->RefreshRate, NULL, NULL ); if( optimalMode == NULL ) { return GL_FALSE; } // ..and switch to that mode cgErr = CGDisplaySwitchToMode( kCGDirectMainDisplay, optimalMode ); if( cgErr != kCGErrorSuccess ) { return GL_FALSE; } // switch to our OpenGL context, and bring it up fullscreen cglErr = CGLSetCurrentContext( _glfwWin.CGLContext ); if( cglErr != kCGLNoError ) { return GL_FALSE; } cglErr = CGLSetFullScreen( _glfwWin.CGLContext ); if( cglErr != kCGLNoError ) { return GL_FALSE; } return GL_TRUE; } }
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 */ }
static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) { long info; /* Check out some things about the system */ Gestalt(gestaltQuickdrawVersion, &info); if ( info == gestaltOriginalQD ) { SDL_SetError("Color Quickdraw not available"); return(-1); } /* Start ROMintosh events */ Mac_InitEvents(this); /* Get a handle to the main monitor */ SDL_Display = GetMainDevice(); /* Determine the current screen size */ this->info.current_w = (**SDL_Display).gdRect.right; this->info.current_h = (**SDL_Display).gdRect.bottom; /* Determine pixel format */ vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; switch (vformat->BitsPerPixel) { case 16: /* 5-5-5 RGB */ vformat->Rmask = 0x00007c00; vformat->Gmask = 0x000003e0; vformat->Bmask = 0x0000001f; break; default: break; } /* Create our palette */ SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8); if ( SDL_CTab == nil ) { SDL_OutOfMemory(); return(-1); } (**SDL_CTab).ctSeed = GetCTSeed(); (**SDL_CTab).ctFlags = 0; (**SDL_CTab).ctSize = 255; CTabChanged(SDL_CTab); SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0); /* Get a list of available fullscreen modes */ SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[0] ) { SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; SDL_modelist[0]->w = (**SDL_Display).gdRect.right; SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom; } SDL_modelist[1] = NULL; } /* Fill in some window manager capabilities */ this->info.wm_available = 1; /* We're done! */ return(0); }