这篇教程C++ GetWindowPort函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetWindowPort函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowPort函数的具体用法?C++ GetWindowPort怎么用?C++ GetWindowPort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetWindowPort函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetGWorldPixMap //------------------------------------------------------------------------ void pixel_map::draw(WindowRef window, const Rect *device_rect, const Rect *pmap_rect) const { if(m_pmap == nil || m_buf == NULL) return; PixMapHandle pm = GetGWorldPixMap (m_pmap); CGrafPtr port = GetWindowPort (window); Rect dest_rect; // Again, I used the Quicktime version. // Good old 'CopyBits' does better interpolation when scaling // but does not support all pixel depths. MacSetRect (&dest_rect, 0, 0, this->width(), this->height()); ImageDescriptionHandle image_description; MakeImageDescriptionForPixMap (pm, &image_description); if (image_description != nil) { DecompressImage (GetPixBaseAddr (pm), image_description, GetPortPixMap (port), nil, &dest_rect, ditherCopy, nil); DisposeHandle ((Handle) image_description); } }
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:21,
示例2: closeWindowint closeWindow(int windowIndex) { wHandleType windowHandle; windowHandle = windowHandleFromIndex(windowIndex); if(windowHandle == NULL) return 0; if (windowBlockFromIndex(windowIndex)->context) QDEndCGContext(GetWindowPort(windowBlockFromIndex(windowIndex)->handle),&windowBlockFromIndex(windowIndex)->context); //CGContextRelease(windowBlockFromIndex(windowIndex)->context); if (windowBlockFromIndex(windowIndex)->windowTrackingRef) { ReleaseMouseTrackingRegion(windowBlockFromIndex(windowIndex)->windowTrackingRef ); windowBlockFromIndex(windowIndex)->windowTrackingRef = NULL; } windowBlockFromIndex(windowIndex)->context = NULL; RemoveWindowBlock(windowBlockFromIndex(windowIndex)); DisposeWindow(windowHandle); return 1;}
开发者ID:Geal,项目名称:Squeak-VM,代码行数:20,
示例3: Q_UNUSEDvoid QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset){ Q_UNUSED(offset); // Get a context for the widget.#ifndef QT_MAC_USE_COCOA CGContextRef context; CGrafPtr port = GetWindowPort(qt_mac_window_for(widget)); QDBeginCGContext(port, &context);#else extern CGContextRef qt_mac_graphicsContextFor(QWidget *); CGContextRef context = qt_mac_graphicsContextFor(widget);#endif CGContextSaveGState(context); // Flip context. CGContextTranslateCTM(context, 0, widget->height()); CGContextScaleCTM(context, 1, -1); // Clip to region. const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) { const QRect &rect = rects.at(i); CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height())); } CGContextClip(context); // Draw the image onto the window. const CGRect dest = CGRectMake(0, 0, widget->width(), widget->height()); const CGImageRef image = d_ptr->device.toMacCGImageRef(); qt_mac_drawCGImage(context, &dest, image); CFRelease(image); // Restore context. CGContextRestoreGState(context);#ifndef QT_MAC_USE_COCOA QDEndCGContext(port, &context);#else CGContextFlush(context);#endif}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:41,
示例4: WXUNUSEDbool wxGLCanvas::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const int *attribList, const wxPalette& WXUNUSED(palette)){ m_needsUpdate = false; m_macCanvasIsShown = false; m_glFormat = WXGLChoosePixelFormat(attribList); if ( !m_glFormat ) return false; if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; m_dummyContext = WXGLCreateContext(m_glFormat, NULL); static GLint gCurrentBufferName = 1; m_bufferName = gCurrentBufferName++; aglSetInteger (m_dummyContext, AGL_BUFFER_NAME, &m_bufferName);#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if ( UMAGetSystemVersion() >= 0x1050 ) { aglSetWindowRef(m_dummyContext, MacGetTopLevelWindowRef()); } else#endif { AGLDrawable drawable = (AGLDrawable)GetWindowPort(MAC_WXHWND(MacGetTopLevelWindowRef())); aglSetDrawable(m_dummyContext, drawable); } m_macCanvasIsShown = true; return true;}
开发者ID:Annovae,项目名称:Dolphin-Core,代码行数:41,
示例5: QDEndCGContextvoid wxOverlayImpl::Reset(){ if ( m_overlayContext ) {#ifndef __LP64__ OSStatus err = QDEndCGContext(GetWindowPort(m_overlayWindow), &m_overlayContext); if ( err != noErr ) { wxFAIL_MSG("Couldn't end the context on the overlay window"); }#endif m_overlayContext = NULL ; } // todo : don't dispose, only hide and reposition on next run if (m_overlayWindow) { DisposeWindow(m_overlayWindow); m_overlayWindow = NULL ; }}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:21,
示例6: DrawImagevoid DrawImage( void ){ OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; Rect bounds; GraphicsImportComponent importer = 0; BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); DisposeHandle( hOpenTypeList ); if ( err ) return; // locate and open a graphics importer component which can be used to draw the // selected file. If a suitable importer is not found the ComponentInstance // is set to NULL. err = GetGraphicsImporterForFile( &theFSSpec, // specifies the file to be drawn &importer ); // pointer to the returned GraphicsImporterComponent // get the native size of the image associated with the importer err = GraphicsImportGetNaturalBounds( importer, // importer instance &bounds ); // returned bounds OffsetRect( &bounds, 10, 45 ); window = NewCWindow( NULL, &bounds, "/pDraw Image", true, documentProc, (WindowPtr)-1, true, 0); // set the graphics port for drawing err = GraphicsImportSetGWorld( importer, // importer instance GetWindowPort( window ), // destination graphics port or GWorld NULL ); // destination GDevice, set to NULL uses GWorlds device // draw the image err = GraphicsImportDraw( importer ); // close the importer instance CloseComponent( importer );}
开发者ID:fruitsamples,项目名称:ImproveYourImage,代码行数:40,
示例7: MacOS_splashstatic PyObject *MacOS_splash(PyObject *self, PyObject *args){ int resid = -1; static DialogPtr curdialog = NULL; DialogPtr olddialog; WindowRef theWindow; CGrafPtr thePort;#if 0 short xpos, ypos, width, height, swidth, sheight;#endif if (!PyArg_ParseTuple(args, "|i", &resid)) return NULL; olddialog = curdialog; curdialog = NULL; if ( resid != -1 ) { curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1); if ( curdialog ) { theWindow = GetDialogWindow(curdialog); thePort = GetWindowPort(theWindow);#if 0 width = thePort->portRect.right - thePort->portRect.left; height = thePort->portRect.bottom - thePort->portRect.top; swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left; sheight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - LMGetMBarHeight(); xpos = (swidth-width)/2; ypos = (sheight-height)/5 + LMGetMBarHeight(); MoveWindow(theWindow, xpos, ypos, 0); ShowWindow(theWindow);#endif DrawDialog(curdialog); } } if (olddialog) DisposeDialog(olddialog); Py_INCREF(Py_None); return Py_None;}
开发者ID:CSC-IT-Center-for-Science,项目名称:scalable-python,代码行数:40,
示例8: ROM_WindowUpdatestatic void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect *rects){ GWorldPtr memworld; GrafPtr saveport; CGrafPtr thePort; const BitMap *memBits; const BitMap *winBits; int i; Rect update; /* Copy from the offscreen GWorld to the window port */ GetPort(&saveport); SetPortWindowPort(SDL_Window); thePort = GetWindowPort(SDL_Window); memworld = (GWorldPtr)GetWRefCon(SDL_Window);#if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld);#else memBits = &((GrafPtr)memworld)->portBits;#endif#if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS winBits = GetPortBitMapForCopyBits(thePort);#else winBits = &SDL_Window->portBits;#endif for ( i=0; i<numrects; ++i ) { update.left = rects[i].x; update.right = rects[i].x+rects[i].w; update.top = rects[i].y; update.bottom = rects[i].y+rects[i].h; CopyBits(memBits, winBits, &update, &update, srcCopy, nil); }#if TARGET_API_MAC_CARBON if ( QDIsPortBuffered(thePort) ) { QDFlushPortBuffer(thePort, NULL); }#endif SetPort(saveport);}
开发者ID:3bu1,项目名称:crossbridge,代码行数:40,
示例9: DisplayDialogCmd/* DisplayDialogCmd(theDialog, dlogItemNo, cmd) Displays the command in an IGOR-style dialog. See GBLoadWaveDialog.c for an example. dlogItemNo is the item number of the dialog item in which the command is to be displayed. On the Macintosh, this must be a user item. On Windows, it must be an EDITTEXT item. Thread Safety: DisplayDialogCmd is not thread-safe.*/voidDisplayDialogCmd(DialogPtr theDialog, int dlogItemNo, const char* cmd){ WindowRef theWindow; CGrafPtr thePort; Rect box; int font, size; int lineHeight; FontInfo info; RgnHandle saveClipRgnH; theWindow = GetDialogWindow(theDialog); thePort = GetWindowPort(theWindow); font = GetPortTextFont(thePort); // Save text characteristics. size = GetPortTextSize(thePort); TextFont(kFontIDMonaco); TextSize(9); GetFontInfo(&info); lineHeight = info.ascent + info.descent + info.leading; GetDBox(theDialog, dlogItemNo, &box); saveClipRgnH = NewRgn(); if (saveClipRgnH != NULL) { GetClip(saveClipRgnH); ClipRect(&box); InsetRect(&box, 2, 2); EraseRect(&box); if (*cmd != 0) { MoveTo(box.left+2, box.top + info.ascent + 2); DrawDialogCmd(cmd, lineHeight); } SetClip(saveClipRgnH); DisposeRgn(saveClipRgnH); } TextFont(font); // Restore font, size, style. TextSize(size);}
开发者ID:jgreenb2,项目名称:DFMLoadWave,代码行数:51,
示例10: GetWindowPortvoid QuartzWindow::close() { if (!is_open()) return; CGrafPtr gp = GetWindowPort(my_window()); if (gp != NULL) // already closed by std handler QDEndCGContext( gp, &myContext ); CGColorRelease((CGColorRef) _red); CGColorRelease((CGColorRef) _yellow); CGColorRelease((CGColorRef) _black); CGColorRelease((CGColorRef) _gray); CGColorRelease((CGColorRef) _white); CGColorSpaceRelease(_color_space); WindowSet::rm_window(my_window()); if (gp != NULL) DisposeWindow(my_window()); _is_open = false; DisposeEventHandlerUPP(_my_event_handler_upp); DisposeEventHandlerUPP(_my_spy_event_handler_upp); _my_event_handler = NULL; _my_spy_event_handler = NULL; _quartz_win = NULL;}
开发者ID:ardeujho,项目名称:self,代码行数:22,
示例11: ActivateMacWinstatic INT ActivateMacWin (GRAPH_WINDOW *gw, INT tool){ WindowPtr MacWindow; MacWindow = MAC_WIN(gw); DrawGrowIcon(MacWindow); SetPort(GetWindowPort(MacWindow)); switch (tool) { case arrowTool : SetMyCursor(arrowCurs); break; case crossTool : SetMyCursor(crossCurs); break; case choiceTool : SetMyCursor(choiceCurs); break; case circleTool : SetMyCursor(circleCurs); break; case handTool : SetMyCursor(handCurs); break; case heartTool : SetMyCursor(heartCurs); break; case gnoedelTool : SetMyCursor(gnoedelCurs); break; } return (0);}
开发者ID:rolk,项目名称:ug,代码行数:22,
示例12: SetCurrentbool wxGLContext::SetCurrent(const wxGLCanvas& win) const{ if ( !m_glContext ) return false; AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); GLint bufnummer = win.GetAglBufferName(); aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer); //win.SetLastContext(m_glContext); const_cast<wxGLCanvas&>(win).SetViewport(); if ( !aglSetDrawable(m_glContext, drawable) ) { wxLogAGLError("aglSetDrawable"); return false; } return WXGLSetCurrentContext(m_glContext);}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:22,
示例13: DrawToolBoxstatic void DrawToolBox (GRAPH_WINDOW *gw, INT tool){ Rect r,dstRect; CGrafPtr myPort; PicHandle toolBox; WindowPtr theWindow; theWindow = MAC_WIN(gw); myPort = GetWindowPort(theWindow); SetPort(myPort); GetPortBounds(myPort,&r); toolBox = GetPicture(TOOLBOX_RSRC_ID); if (toolBox!=NULL) { SetRect(&dstRect,r.right-120,r.bottom-15,r.right-15,r.bottom); DrawPicture(toolBox,&dstRect); } SetRect(&dstRect,r.right-119+tool*15,r.bottom-14,r.right-104+tool*15,r.bottom); InvertRect(&dstRect);}
开发者ID:rolk,项目名称:ug,代码行数:23,
示例14: langerrorupdatestatic void langerrorupdate (void) { langerrorsetrects (); /* eraserect ((**hw).contentrect); */ #if TARGET_API_MAC_CARBON == 1 drawthemeborder ((**langerrordata).textrect, (**langerrorwindowinfo).contentrect); #endif langerrordrawicon (false); #ifdef gray3Dlook pushbackcolor (&whitecolor); eraserect ((**langerrordata).textrect); #endif // framerect ((**langerrordata).textrect); langerrorframetext (); langerrordrawtext (false); //Timothy Paustian 10/5/00 //For some reason the buffer is not being flushed for this window. //This should fix it. #if TARGET_API_MAC_CARBON == 1 QDFlushPortBuffer (GetWindowPort (langerrorwindow), nil); #endif #ifdef gray3Dlook popbackcolor (); #endif } /*langerrorupdate*/
开发者ID:dvincent,项目名称:frontier,代码行数:36,
示例15: if//.........这里部分代码省略......... windowAttrs = kWindowNoTitleBarAttribute; else if( borderType == "fixed" ) windowAttrs = kWindowStandardFloatingAttributes; } } windowAttrs |= kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowHideOnFullScreenAttribute; // Create the window CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow); // Color the window background black SetThemeWindowBackground (mWindow, kThemeBrushBlack, true); // Set the title of our window CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII ); SetWindowTitleWithCFString( mWindow, titleRef ); // Center our window on the screen RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen ); // Get our view HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView ); // Set up our UPP for Window Events EventTypeSpec eventSpecs[] = { {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowClosed}, {kEventClassWindow, kEventWindowClose} }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler); // Install the standard event handler for the window EventTargetRef target = GetWindowEventTarget(mWindow); InstallStandardEventHandler(target); // We also need to install the WindowEvent Handler, we pass along the window with our requests InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef); // Display and select our window ShowWindow(mWindow); SelectWindow(mWindow); // Add our window to the window event listener class WindowEventUtilities::_addRenderWindow(this); } else { // TODO: The Contol is going to report the incorrect location with a // Metalic / Textured window. The default windows work just fine. // First get the HIViewRef / ControlRef mView = (HIViewRef)StringConverter::parseUnsignedLong(opt->second); mWindow = GetControlOwner(mView); // Lets try hiding the HIView //HIViewSetVisible(mView, false); // Get the rect bounds ::Rect ctrlBounds; GetControlBounds(mView, &ctrlBounds); GLint bufferRect[4]; bufferRect[0] = ctrlBounds.left; // left edge bufferRect[1] = ctrlBounds.bottom; // bottom edge bufferRect[2] = ctrlBounds.right - ctrlBounds.left; // width of buffer rect bufferRect[3] = ctrlBounds.bottom - ctrlBounds.top; // height of buffer rect aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); aglEnable (mAGLContext, AGL_BUFFER_RECT); mIsExternal = true; } // Set the drawable, and current context // If you do this last, there is a moment before the rendering window pops-up // This could go once inside each case above, before the window is displayed, // if desired. aglSetDrawable(mAGLContext, GetWindowPort(mWindow)); aglSetCurrentContext(mAGLContext); // Give a copy of our context to the render system mContext = new OSXCarbonContext(mAGLContext, pixelFormat); } mName = name; mWidth = width; mHeight = height; mActive = true; mClosed = false; mCreated = true; mIsFullScreen = fullScreen;}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,
示例16: DrawMultipleStylesContents// This example is almost identical to the helloworld example, except that// in this case, there are two styles instead of just one. ATSUSetRunStyle// is used to apply a style to different parts of the text.//void DrawMultipleStylesContents(WindowRef window){ CFStringRef string; UniChar *text; UniCharCount length; UniCharArrayOffset currentStart, currentEnd; ATSUStyle style1, style2; ATSUTextLayout layout; ATSUFontID font; Fixed pointSize; ATSUAttributeTag tags[2]; ByteCount sizes[2]; ATSUAttributeValuePtr values[2]; Fixed lineWidth, ascent, descent; CGContextRef cgContext; float x, y, cgY, windowHeight; ItemCount numSoftBreaks; UniCharArrayOffset *theSoftBreaks; int i; GrafPtr port, savedPort; Rect portBounds; // Set up the graphics port port = GetWindowPort(window); GetPort(&savedPort); SetPort(port); GetPortBounds(port, &portBounds); EraseRect(&portBounds); // Create a style object. This is one of two objects necessary to draw using ATSUI. // (The layout is the other.) verify_noerr( ATSUCreateStyle(&style1) ); // Look up the font we are going to use, and set it in the style object, using // the aforementioned "triple" (tag, size, value) semantics. This is how almost // all settings in ATSUI are applied. verify_noerr( ATSUFindFontFromName(kMultipleStylesFontName, strlen(kMultipleStylesFontName), kFontFullName, kFontNoPlatform, kFontNoScript, kFontNoLanguage, &font) ); tags[0] = kATSUFontTag; sizes[0] = sizeof(ATSUFontID); values[0] = &font; verify_noerr( ATSUSetAttributes(style1, 1, tags, sizes, values) ); // Set the point size, also using a triple. You can actually set multiple triples at once, // since the tag, size, and value parameters are arrays. Other examples do this, such as // the vertical text example. // pointSize = Long2Fix(kMultipleStylesFontSize); tags[0] = kATSUSizeTag; sizes[0] = sizeof(Fixed); values[0] = &pointSize; verify_noerr( ATSUSetAttributes(style1, 1, tags, sizes, values) ); // Now we create the second of two objects necessary to draw text using ATSUI, the layout. // You can specify a pointer to the text buffer at layout creation time, or later using // the routine ATSUSetTextPointerLocation(). Below, we do it after layout creation time. verify_noerr( ATSUCreateTextLayout(&layout) ); // Before assigning text to the layout, we must first convert the string we plan to draw // from a CFStringRef into an array of UniChar. string = CFStringCreateWithCString(NULL, "In this example, various parts of the text have different styles applied. The same style is used more than once.", kCFStringEncodingASCII); // Extract the raw Unicode from the CFString, then dispose of the CFString length = CFStringGetLength(string); text = (UniChar *)malloc(length * sizeof(UniChar)); CFStringGetCharacters(string, CFRangeMake(0, length), text); CFRelease(string); // Attach the resulting UTF-16 Unicode text to the layout verify_noerr( ATSUSetTextPointerLocation(layout, text, kATSUFromTextBeginning, kATSUToTextEnd, length) ); // Now we tie the two necessary objects, the layout and the style, together verify_noerr( ATSUSetRunStyle(layout, style1, kATSUFromTextBeginning, kATSUToTextEnd) ); // Now, for this example we create a second style, and assign it to various runs within // the text. For our example, the run offsets are hard-coded for simplicity's sake. In // a real application, style runs are often assigned from external sources, such as user // selection. verify_noerr( ATSUCreateAndCopyStyle(style1, &style2) ); // Change the font for the second style verify_noerr( ATSUFindFontFromName(kMultipleStylesFontName2, strlen(kMultipleStylesFontName2), kFontFullName, kFontNoPlatform, kFontNoScript, kFontNoLanguage, &font) ); tags[0] = kATSUFontTag; sizes[0] = sizeof(ATSUFontID); values[0] = &font; verify_noerr( ATSUSetAttributes(style2, 1, tags, sizes, values) ); // Apply the new style to the text in various places verify_noerr( ATSUSetRunStyle(layout, style2, 8, 7) ); // The word "example" verify_noerr( ATSUSetRunStyle(layout, style2, 65, 7) ); // The word "applied" verify_noerr( ATSUSetRunStyle(layout, style2, 83, 5) ); // The word "style" verify_noerr( ATSUSetRunStyle(layout, style2, 107, 4) ); // The word "once" // In this example, we are breaking text into lines. // Therefore, we need to know the width of the line. lineWidth = X2Fix(portBounds.right - portBounds.left - 2.0*kMultipleStylesMargin); tags[0] = kATSULineWidthTag;//.........这里部分代码省略.........
开发者ID:arnelh,项目名称:Examples,代码行数:101,
示例17: GetWindowPortvoid TabbedWindow::ForceUpdate( void ){ CGrafPtr port = GetWindowPort( fWindowRef ); QDFlushPortBuffer( port, NULL );}
开发者ID:fruitsamples,项目名称:InkSample,代码行数:5,
示例18: _glfwPlatformOpenWindow//.........这里部分代码省略......... 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;
开发者ID:x-y-z,项目名称:SteerSuite-CUDA,代码行数:66,
示例19: aboutupdatestatic void aboutupdate (void) { /* 1/22/91 dmb: openbitmap moves memory; its result cannot be assigned into a double-dereferenced handle. (ahem!) 2.1b5 dmb: special case for nil cancoondata (during revert). also, removed unneeded flbitmapactive logic */ register hdlwindowinfo hw = aboutwindowinfo; Rect r; displayedaboutdata = aboutdata; #if TARGET_API_MAC_CARBON aboutport = GetWindowPort(aboutwindow); #else aboutport = (CGrafPtr)aboutwindow; #endif flhavemiscrect = false; if (aboutdata == nil) /*in the middle of a revert*/ return; r = (**hw).contentrect; eraserect (r); shelldrawgrowicon (hw); if ((**aboutdata).flbigwindow) { ccdrawabout (); // ccgetmsgrect (&r); getmessagecontentrect (&r); insetrect (&r, -1, -1); #if TARGET_API_MAC_CARBON == 1 insetrect (&r, 0, -3); r.bottom = r.top + 2; DrawThemeSeparator (&r, kThemeStateActive); #else // grayframerect (r); movepento (r.left, r.top); pushpen (); setgraypen (); pendrawline (r.right, r.top); poppen (); #endif flhavemiscrect = ccgettextitemrect (miscinfoitem, &miscinforect); } if (!(**aboutdata).flbootsplash) { ccdrawagentpopup (); ccdrawmsg (); } } /*aboutupdate*/
开发者ID:pombredanne,项目名称:Frontier,代码行数:74,
示例20: DoEventvoid DoEvent(EventRecord *event){ short part; Boolean hit; char key; Rect tempRect; WindowRef whichWindow; switch (event->what) { case mouseDown: part = FindWindow(event->where, &whichWindow); switch (part) { case inMenuBar: /* process a moused menu command */ DoMenuCommand(MenuSelect(event->where)); break; case inSysWindow: break; case inContent: if (whichWindow != FrontWindow()) SelectWindow(whichWindow); break; case inDrag: /* pass screenBits.bounds */ GetRegionBounds(GetGrayRgn(), &tempRect); DragWindow(whichWindow, event->where, &tempRect); break; case inGrow: break; case inGoAway: DisposeWindow(whichWindow); ExitToShell(); break; case inZoomIn: case inZoomOut: hit = TrackBox(whichWindow, event->where, part); if (hit) { SetPort(GetWindowPort(whichWindow)); // window must be current port EraseRect(GetWindowPortBounds(whichWindow, &tempRect)); // inval/erase because of ZoomWindow bug ZoomWindow(whichWindow, part, true); InvalWindowRect(whichWindow, GetWindowPortBounds(whichWindow, &tempRect)); } break; } break; case keyDown: case autoKey: key = event->message & charCodeMask; if (event->modifiers & cmdKey) if (event->what == keyDown) DoMenuCommand(MenuKey(key)); case activateEvt: /* if you needed to do something special */ break; case updateEvt: DrawWindow((WindowRef) event->message); break; case kHighLevelEvent: AEProcessAppleEvent( event ); break; case diskEvt: break; }}
开发者ID:fruitsamples,项目名称:CGGamma,代码行数:74,
示例21: Q_D//.........这里部分代码省略......... XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded); } QPoint widgetOffset = offset + wOffset; QRect clipRect = widget->rect().translated(widgetOffset).intersected(d_ptr->image->image.rect()); QRect br = rgn.boundingRect().translated(offset).intersected(clipRect); QPoint wpos = br.topLeft() - widgetOffset;#ifndef QT_NO_MITSHM if (d_ptr->image->xshmpm) { XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc, br.x(), br.y(), br.width(), br.height(), wpos.x(), wpos.y()); d_ptr->needsSync = true; } else if (d_ptr->image->xshmimg) { XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg, br.x(), br.y(), wpos.x(), wpos.y(), br.width(), br.height(), False); d_ptr->needsSync = true; } else#endif { int depth = widget->x11Info().depth(); const QImage &src = d->image->image; if (src.format() != QImage::Format_RGB32 || depth < 24 || X11->bppForDepth.value(depth) != 32) { Q_ASSERT(src.depth() >= 16); const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8), br.width(), br.height(), src.bytesPerLine(), src.format()); QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType); data->xinfo = widget->x11Info(); data->fromImage(sub_src, Qt::NoOpaqueDetection); QPixmap pm = QPixmap(data); XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wpos.x(), wpos.y()); } else { // qpaintengine_x11.cpp extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth); qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), depth); } } if (wrgn.rectCount() != 1) XSetClipMask(X11->display, d_ptr->gc, XNone);#endif // FALCON#ifdef Q_WS_MAC Q_UNUSED(offset); // This is mainly done for native components like native "open file" dialog. if (widget->testAttribute(Qt::WA_DontShowOnScreen)) { return; }#ifdef QT_MAC_USE_COCOA this->needsFlush = true; this->regionToFlush += rgn; // The actual flushing will be processed in [view drawRect:rect] qt_mac_setNeedsDisplay(widget);#else // Get a context for the widget. CGContextRef context; CGrafPtr port = GetWindowPort(qt_mac_window_for(widget)); QDBeginCGContext(port, &context); CGContextRetain(context); CGContextSaveGState(context); // Flip context. CGContextTranslateCTM(context, 0, widget->height()); CGContextScaleCTM(context, 1, -1); // Clip to region. const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) { const QRect &rect = rects.at(i); CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height())); } CGContextClip(context); QRect r = rgn.boundingRect().intersected(d->image->image.rect()); const CGRect area = CGRectMake(r.x(), r.y(), r.width(), r.height()); CGImageRef image = CGBitmapContextCreateImage(d->image->cg); CGImageRef subImage = CGImageCreateWithImageInRect(image, area); qt_mac_drawCGImage(context, &area, subImage); CGImageRelease(subImage); CGImageRelease(image); QDEndCGContext(port, &context); // Restore context. CGContextRestoreGState(context); CGContextRelease(context);#endif // QT_MAC_USE_COCOA#endif // Q_WS_MAC}
开发者ID:wpbest,项目名称:copperspice,代码行数:101,
示例22: helpvoid wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height){ wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; wxMacWindowClipper clip (this); int former_x = m_x ; int former_y = m_y ; int former_w = m_width ; int former_h = m_height ; int actualWidth = width; int actualHeight = height; int actualX = x; int actualY = y; if ((m_minWidth != -1) && (actualWidth < m_minWidth)) actualWidth = m_minWidth; if ((m_minHeight != -1) && (actualHeight < m_minHeight)) actualHeight = m_minHeight; if ((m_maxWidth != -1) && (actualWidth > m_maxWidth)) actualWidth = m_maxWidth; if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) actualHeight = m_maxHeight; bool doMove = false ; bool doResize = false ; if ( actualX != former_x || actualY != former_y ) { doMove = true ; } if ( actualWidth != former_w || actualHeight != former_h ) { doResize = true ; } if ( doMove || doResize ) { m_x = actualX ; m_y = actualY ; if ( doMove ) ::MoveWindow((WindowRef)m_macWindow, m_x, m_y , false); // don't make frontmost m_width = actualWidth ; m_height = actualHeight ; if ( doResize ) ::SizeWindow((WindowRef)m_macWindow, m_width, m_height , true); // the OS takes care of invalidating and erasing the new area so we only have to // take care of refreshing for full repaints if ( doResize && HasFlag(wxFULL_REPAINT_ON_RESIZE) ) Refresh() ; if ( IsKindOf( CLASSINFO( wxFrame ) ) ) { wxFrame* frame = (wxFrame*) this ;#if wxUSE_STATUSBAR frame->PositionStatusBar();#endif #if wxUSE_TOOLBAR frame->PositionToolBar();#endif } if ( doMove ) wxWindowMac::MacTopLevelWindowChangedPosition() ; // like this only children will be notified MacRepositionScrollBars() ; if ( doMove ) { wxPoint point(m_x, m_y); wxMoveEvent event(point, m_windowId); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event) ; } if ( doResize ) { MacRepositionScrollBars() ; wxSize size(m_width, m_height); wxSizeEvent event(size, m_windowId); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); } }}
开发者ID:Duion,项目名称:Torsion,代码行数:89,
示例23: createAGLContext void OSXCarbonWindow::setFullscreen(bool fullScreen, unsigned int width, unsigned int height) { if (mIsFullScreen != fullScreen || width != mWidth || height != mHeight) { // Set the full screen flag mIsFullScreen = fullScreen; createAGLContext(mFSAA, mColourDepth); if (mIsFullScreen) { GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); CGLContextObj share = NULL; aglGetCGLContext(mAGLContext, (void**)&share); // Create the CGL context object if it doesn't already exist, sharing the AGL context. if(!mCGLContext) { void *cglPixFormat; aglGetCGLPixelFormat(mAGLPixelFormat, (void **)&cglPixFormat); mCGLContext = OGRE_NEW OSXCGLContext(mCGLContextObj, (CGLPixelFormatObj) cglPixFormat); } // Create the context, keeping the current colour depth and FSAA settings createCGLFullscreen(width, height, getColourDepth(), getFSAA(), share); rs->_switchContext(mContext); // Hide the Carbon window HideWindow(mWindow); // And tell the rendersystem to stop rendering to it too WindowEventUtilities::_removeRenderWindow(this); } else { // Create a new AGL context and pixel format if necessary createAGLContext(mFSAA, mColourDepth); // Create a window if we haven't already, existence check is done within the functions if(!mWindow) { if(mIsExternal) createWindowFromExternal(mView); else createNewWindow(width, height, mWindowTitle); } // Destroy the current CGL context, we will create a new one when/if we go back to full screen destroyCGLFullscreen(); // Set the drawable, and current context // If you do this last, there is a moment before the rendering window pops-up #if defined(MAC_OS_X_VERSION_10_4) && MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 aglSetDrawable(mAGLContext, GetWindowPort(mWindow)); #else aglSetWindowRef(mAGLContext, mWindow); #endif aglSetCurrentContext(mAGLContext); if(!mCarbonContext) { mCarbonContext = OGRE_NEW OSXCarbonContext(mAGLContext, mAGLPixelFormat); } GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); mContext = mCarbonContext; rs->_switchContext(mContext); WindowEventUtilities::_addRenderWindow(this); ShowWindow(mWindow); SelectWindow(mWindow); RepositionWindow(mWindow, NULL, kWindowCenterOnMainScreen); } mWidth = width; mHeight = height; } }
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:79,
示例24: NewRgnBoolean 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)//.........这里部分代码省略.........
开发者ID:alilloyd,项目名称:livecode,代码行数:101,
示例25: HITestViewTrack// -----------------------------------------------------------------------------// HITestViewTrack// -----------------------------------------------------------------------------// This is overkill, and probably #ifdef'd out, but is here as an example of// a custom tracking handler.//OSStatus HITestViewTrack( EventRef inEvent, HITestViewData* inData ){ OSStatus err; HIRect bounds; HIPoint where; ControlPartCode part; Boolean inside; Boolean wasInside; Point qdPt; MouseTrackingResult mouseResult; PixMapHandle portPixMap; // Extract the mouse location err = GetEventParameter( inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof( HIPoint ), NULL, &where ); require_noerr( err, ParameterMissing ); // Is the mouse location in the view? err = HIViewGetBounds( inData->view, &bounds ); if ( CGRectContainsPoint( bounds, where ) ) part = 1; else part = kControlNoPart; HiliteControl( inData->view, part ); wasInside = true; // Need the port's pixMap's bounds to convert the mouse location portPixMap = GetPortPixMap( GetWindowPort( GetControlOwner( inData->view ) ) ); // The tracking loop while ( true ) { // Check again to see if the mouse is in the view if ( CGRectContainsPoint( bounds, where ) ) part = 1; else part = kControlNoPart; inside = ( part != kControlNoPart ); // If that changed, update if ( inside != wasInside ) HiliteControl( inData->view, part ); wasInside = inside; // Watch the mouse for change err = TrackMouseLocation( (GrafPtr)-1L, &qdPt, &mouseResult ); // Need to convert from global QDGlobalToLocalPoint( GetWindowPort( GetControlOwner( inData->view ) ), &qdPt ); where.x = qdPt.h - (**portPixMap).bounds.left; where.y = qdPt.v - (**portPixMap).bounds.top; HIViewConvertPoint( &where, NULL, inData->view ); // Bail out when the mouse is released if ( mouseResult == kMouseTrackingMouseReleased ) break; } // Restore the original highlight HiliteControl( inData->view, kControlNoPart ); // Send back the part upon which the mouse was released err = SetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, sizeof( ControlPartCode ), &part ); ParameterMissing: return err;}
开发者ID:arnelh,项目名称:Examples,代码行数:77,
示例26: CGMainDisplayID//.........这里部分代码省略......... else { gl_attribs[i++] = AGL_RGBA; gl_attribs[i++] = AGL_NO_RECOVERY; gl_attribs[i++] = AGL_DOUBLEBUFFER; gl_attribs[i++] = AGL_DEPTH_SIZE; gl_attribs[i++] = 16; } /* else { gl_attribs[i++] = AGL_RGBA; gl_attribs[i++] = AGL_DOUBLEBUFFER; gl_attribs[i++] = AGL_RED_SIZE; gl_attribs[i++] = 4; gl_attribs[i++] = AGL_GREEN_SIZE; gl_attribs[i++] = 4; gl_attribs[i++] = AGL_BLUE_SIZE; gl_attribs[i++] = 4; gl_attribs[i++] = AGL_DEPTH_SIZE; gl_attribs[i++] = 16;// gl_attribs[i++] = AGL_FULLSCREEN; }*/ gl_attribs[i] = AGL_NONE; CGDirectDisplayID display = CGMainDisplayID(); GDHandle gdhDisplay, *pgdhDisplay; int numDisplay; pgdhDisplay = &gdhDisplay; if (noErr == DMGetGDeviceByDisplayID ((DisplayIDType)display, pgdhDisplay, false)) numDisplay = 1; else { pgdhDisplay = 0; numDisplay = 0; } AGLPixelFormat pixelformat; pixelformat = aglChoosePixelFormat(pgdhDisplay, numDisplay, gl_attribs); win_context = aglCreateContext(pixelformat, share_context); if (!share_context) share_context = win_context; aglDestroyPixelFormat(pixelformat); gl_attribs[i++] = AGL_FULLSCREEN; gl_attribs[i] = AGL_NONE; pixelformat = aglChoosePixelFormat(pgdhDisplay, numDisplay, gl_attribs); fs_context = aglCreateContext(pixelformat, win_context); aglDestroyPixelFormat(pixelformat); if (!(win_context && fs_context)) { printf("Requested visual not supported by your OpenGL implementation. Falling back on singlebuffered Visual!/n"); pixelformat = aglChoosePixelFormat(0, 0, gl_attribs_single); win_context = aglCreateContext(pixelformat, share_context); aglDestroyPixelFormat(pixelformat); fs_context = 0; } WindowAttributes style = kWindowCloseBoxAttribute | kWindowStandardHandlerAttribute; if (desc.get_allow_resize()) style |= kWindowResizableAttribute | kWindowFullZoomAttribute; Rect window_rect; SetRect(&window_rect, 50, 50, 50+desc.get_size().width, 50+desc.get_size().height); result = CreateNewWindow(kDocumentWindowClass, style, &window_rect, &window_ref); if (result != noErr) printf("Could not create window, due to error %d/n", (int)result); // set title of window: set_title(desc.get_title()); // Set standard arrow cursor: InitCursor(); // do we need to do this? -- iMBN, 13. may 2004 // Create input devices for window: keyboard = CL_InputDevice(new CL_InputDevice_MacKeyboard(this)); mouse = CL_InputDevice(new CL_InputDevice_MacMouse(this)); get_ic()->clear(); get_ic()->add_keyboard(keyboard); get_ic()->add_mouse(mouse);// buffer_front = CL_PixelBuffer(new CL_PixelBuffer_OpenGL_Frame(CL_FRONT, gc));// buffer_back = CL_PixelBuffer(new CL_PixelBuffer_OpenGL_Frame(CL_BACK, gc)); if (!aglSetDrawable(win_context, GetWindowPort(window_ref))) { printf("Unable to set drawable"); } if (desc.is_fullscreen()) set_fullscreen(desc.get_size().width, desc.get_size().height, desc.get_bpp(), desc.get_refresh_rate()); else { fullscreen = true; // not really, but need to fool set_windowed set_windowed(); } ShowWindow(window_ref);}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:101,
注:本文中的GetWindowPort函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetWindowRect函数代码示例 C++ GetWindowPlacement函数代码示例 |