RgnHandle getWindowContentRegion(WindowRef window,RgnHandle contentRegion) { Rect portBounds; GetWindowBounds(window, kWindowGlobalPortRgn, &portBounds); RectRgn(contentRegion, &portBounds); return contentRegion; }
// ----------------------------------------------------------------------------- // HITestViewGetRegion // ----------------------------------------------------------------------------- // OSStatus HITestViewGetRegion( EventRef inEvent, HITestViewData* inData ) { OSStatus err; ControlPartCode part; RgnHandle outRegion; HIRect bounds; Rect qdBounds; err = GetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, NULL, sizeof( ControlPartCode ), NULL, &part ); require_noerr( err, ParameterMissing ); err = GetEventParameter( inEvent, kEventParamControlRegion, typeQDRgnHandle, NULL, sizeof( RgnHandle ), NULL, &outRegion ); if ( part == kControlContentMetaPart || part == kControlStructureMetaPart /* || part == kControlOpaqueRegionMetaPart */ ) { HIViewGetBounds( inData->view, &bounds ); qdBounds.top = (SInt16) CGRectGetMinY( bounds ); qdBounds.left = (SInt16) CGRectGetMinX( bounds ); qdBounds.bottom = (SInt16) CGRectGetMaxY( bounds ); qdBounds.right = (SInt16) CGRectGetMaxX( bounds ); RectRgn( outRegion, &qdBounds ); } ParameterMissing: return err; }
/* YASTControlCalculateBounds is called to recalculate all of the internal rectangles in the YASTControl's internal structures. bounds is the control's rectangle, the coordinates calculated in this routine are used to place the TXNObject, draw the focus rectangle, and draw the text box outline. */ static void YASTControlCalculateBounds(YASTControlVars *varsp, Rect* bounds) { SetRect(&varsp->fRBounds, bounds->left, bounds->top, bounds->right, bounds->bottom); SetRect(&varsp->fRFocusOutline, bounds->left, bounds->top, bounds->right, bounds->bottom); SetRect(&varsp->fRTextOutline, bounds->left+1, bounds->top+1, bounds->right-1, bounds->bottom-1); SetRect(&varsp->fRTextArea, bounds->left+2, bounds->top+3, bounds->right-3, bounds->bottom-2); RectRgn(varsp->fRTextOutlineRegion, &varsp->fRTextOutline); }
void LCD_resize(Lcd *x) { Rect r; short hor,ver; #ifdef debug post("LCD_Resize"); #endif r = x->lcd_box.b_rect; hor = x->cols = FixRound(FixRatio(((r.right-r.left-(2*BORDER_WIDTH))),x->f_width)); ver = x->rows = FixRound(FixRatio(((r.bottom-r.top-(2*BORDER_HEIGHT))),x->f_height)); #ifdef FORCEDResize x->lcd_box.b_rect.right = r.left + (2*BORDER_WIDTH) + hor*x->f_width; x->lcd_box.b_rect.bottom = r.top + (2*BORDER_HEIGHT) + ver*x->f_height; #endif if (x->lcd_region) DisposeRgn(x->lcd_region); x->lcd_oldRect = r = x->lcd_box.b_rect; InsetRect(&r,1,1); x->lcd_region = NewRgn(); RectRgn(x->lcd_region,&r); /* DDZ simpler way to make a rectangular region */ }
static int HandleMacEvents(void) { EventRecord theEvent; int eventFound = 0, needsUpdate = 0; Point currentMouse; WindowRef windowRef; Rect mouseRect; /* * Check for mouse moved events. These events aren't placed on the * system event queue unless we call WaitNextEvent. */ GetGlobalMouse(¤tMouse); if ((notifier.eventProcPtr != NULL) && !EqualPt(currentMouse, notifier.lastMousePosition)) { notifier.lastMousePosition = currentMouse; theEvent.what = nullEvent; if ((*notifier.eventProcPtr)(&theEvent) == true) { eventFound = 1; } } /* * Check for update events. Since update events aren't generated * until we call GetNextEvent, we may need to force a call to * GetNextEvent, even if the queue is empty. */ for (windowRef = FrontWindow(); windowRef != NULL; windowRef = GetNextWindow(windowRef)) { GetWindowUpdateRgn(windowRef, notifier.utilityRgn); if (!EmptyRgn(notifier.utilityRgn)) { needsUpdate = 1; break; } } /* * Process events from the OS event queue. */ while (needsUpdate || (GetEvQHdr()->qHead != NULL)) { GetGlobalMouse(¤tMouse); SetRect(&mouseRect, currentMouse.h, currentMouse.v, currentMouse.h + 1, currentMouse.v + 1); RectRgn(notifier.utilityRgn, &mouseRect); WaitNextEvent(everyEvent, &theEvent, 5, notifier.utilityRgn); needsUpdate = 0; if ((notifier.eventProcPtr != NULL) && ((*notifier.eventProcPtr)(&theEvent) == true)) { eventFound = 1; } } return eventFound; }
bool MCRegionExcludeRect(MCRegionRef self, const MCRectangle& rect) { Rect t_rect; SetRect(&t_rect, rect . x, rect . y, rect . x + rect . width, rect . y + rect . height); RgnHandle t_rect_rgn; t_rect_rgn = NewRgn(); RectRgn(t_rect_rgn, &t_rect); DiffRgn((RgnHandle)self, t_rect_rgn, (RgnHandle)self); DisposeRgn(t_rect_rgn); return true; }
/* 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; }
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 wxTopLevelWindowMac::MacUpdate( long timestamp) { wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; RgnHandle visRgn = NewRgn() ; GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), visRgn ); BeginUpdate( (WindowRef)m_macWindow ) ; RgnHandle updateRgn = NewRgn(); RgnHandle diffRgn = NewRgn() ; if ( updateRgn && diffRgn ) { #if 1 // macos internal control redraws clean up areas we'd like to redraw ourselves // therefore we pick the boundary rect and make sure we can redraw it // this has to be intersected by the visRgn in order to avoid drawing over its own // boundaries RgnHandle trueUpdateRgn = NewRgn() ; Rect trueUpdateRgnBoundary ; GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), trueUpdateRgn ); GetRegionBounds( trueUpdateRgn , &trueUpdateRgnBoundary ) ; RectRgn( updateRgn , &trueUpdateRgnBoundary ) ; SectRgn( updateRgn , visRgn , updateRgn ) ; if ( trueUpdateRgn ) DisposeRgn( trueUpdateRgn ) ; SetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ) ; #else GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ); #endif DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; if ( !EmptyRgn( updateRgn ) ) { MacRedraw( updateRgn , timestamp , m_macNeedsErasing || !EmptyRgn( diffRgn ) ) ; } } if ( updateRgn ) DisposeRgn( updateRgn ); if ( diffRgn ) DisposeRgn( diffRgn ); if ( visRgn ) DisposeRgn( visRgn ) ; EndUpdate( (WindowRef)m_macWindow ) ; SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ; m_macNeedsErasing = false ; }
static void HIOpenGLViewSetContextWindowAndBounds (HIOpenGLViewData* inData) { if (inData == nil) return; if (inData->mControl == nil) return; if (inData->mContext == nil) return; // Determine the AGL_BUFFER_RECT for the control. The coordinate // system for this rectangle is relative to the owning window, with // the origin at the bottom left corner and the y-axis inverted. HIRect ctrlBounds, winBounds; HIViewGetBounds(inData->mControl, &ctrlBounds); WindowRef window = GetControlOwner(inData->mControl); ControlRef root = nil; GetRootControl(window, &root); HIViewGetBounds(root, &winBounds); HIViewConvertRect(&ctrlBounds, inData->mControl, root); GLint bufferRect[4] = { (int)ctrlBounds.origin.x, (int)((winBounds.size.height) - (ctrlBounds.origin.y + ctrlBounds.size.height)), (int)ctrlBounds.size.width, (int)ctrlBounds.size.height }; // Associate the OpenGL context with the control's window, and establish the buffer rect. aglSetDrawable(inData->mContext, GetWindowPort(window)); aglSetInteger(inData->mContext, AGL_BUFFER_RECT, bufferRect); aglEnable(inData->mContext, AGL_BUFFER_RECT); // Establish the clipping region for the OpenGL context. To properly handle clipping // within the view hierarchy, I'm walking the hierarchy to determine the intersection // of this view's bounds with its parents. Is there an easier way to do this? CGRect clipBounds = ctrlBounds; HIViewRef parent = HIViewGetSuperview(inData->mControl); while (parent != root) { CGRect parentBounds; HIViewGetBounds(parent, &parentBounds); HIViewConvertRect(&parentBounds, parent, root); clipBounds = CGRectIntersection(clipBounds, parentBounds); parent = HIViewGetSuperview(parent); } Rect rgnBounds = { (int)clipBounds.origin.y, (int)clipBounds.origin.x, (int)(clipBounds.origin.y + clipBounds.size.height), (int)(clipBounds.origin.x + clipBounds.size.width) }; RgnHandle rgn = NewRgn(); RectRgn(rgn, &rgnBounds); aglSetInteger(inData->mContext, AGL_CLIP_REGION, (const GLint*)rgn); aglEnable(inData->mContext, AGL_CLIP_REGION); }
wxMetaFileDC::wxMetaFileDC(const wxString& filename , int width , int height , const wxString& WXUNUSED(description) ) { wxASSERT_MSG( width == 0 || height == 0 , _T("no arbitration of metafilesize supported") ) ; wxASSERT_MSG( filename.empty() , _T("no file based metafile support yet")) ; m_metaFile = new wxMetaFile(filename) ; #if wxMAC_USE_CORE_GRAPHICS #else Rect r={0,0,height,width} ; RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ; ::GetPort( (GrafPtr*) &m_macPort ) ; m_ok = true ; #endif SetMapMode(wxMM_TEXT); }
/* Update procedure for textedit window */ short NATEupdatep(na_win *winp, Boolean newsize) { TEHandle hTE = teinfo->hTE; WindowPtr window = winp->pwin; Rect prect, vrect, hrect, drect; prect = window->portRect; prect.top += teinfo->topoff; EraseRect(&prect); hrect = vrect = prect; vrect.top--; hrect.left--; vrect.left = ++vrect.right - 16; hrect.top = ++hrect.bottom - 16; vrect.bottom -= 14; hrect.right -= 14; InsetRect(&prect, 4, 4); prect.right -= 15; if (!(winp->flags & NATE_NOHSCROLL)) prect.bottom -= 15; prect.bottom -= (prect.bottom - prect.top) % teinfo->lheight; if (newsize) { drect = (*hTE)->viewRect = prect; drect.right = drect.left + (short) teinfo->docwidth; (*hTE)->destRect = drect; RectRgn(winp->cursorRgn, &prect); OffsetRgn(winp->cursorRgn, -window->portBits.bounds.left, -window->portBits.bounds.top); TECalText(hTE); TESelView(hTE); if (teinfo->hctrl != (ControlHandle) NULL) HideControl(teinfo->hctrl); if (teinfo->vctrl != (ControlHandle) NULL) HideControl(teinfo->vctrl); } TEUpdate(&prect, hTE); if (newsize) NATEsetscroll(winp, true, &hrect, &vrect); return (NA_NOTPROCESSED); }
void myHideMenuBar( GDHandle ignoredDev) { RgnHandle gray,rect; GDHandle dev; (void)ignoredDev; if (savedgray) return; gray=GetGrayRgn(); savedgray=NewRgn(); rect=NewRgn(); CopyRgn(gray,savedgray); for (dev=GetDeviceList(); dev; dev=GetNextDevice(dev)) { if (!TestDeviceAttribute(dev,screenDevice) || !TestDeviceAttribute(dev,screenActive)) continue; RectRgn(rect,&(*dev)->gdRect); UnionRgn(gray,rect,gray); } DisposeRgn(rect); savedmbh=LMGetMBarHeight(); LMSetMBarHeight(0); }
static pascal void MyTimerHandler( EventLoopTimerRef inTimer, void *inUserData ) { CGrafPtr currentPort; Rect currentPortRect; RgnHandle flushRegion; SetPortWindowPort( (WindowRef) inUserData ); // Call the plug-in function "drawBall" which is defined in the plug-in interface. (*gDrawBallInterface)->drawBall( gDrawBallInterface ); // We are not drawing in response to an update or draw event, so if the window is buffered // (i.e. on Mac OS X) we need to flush the content to be drawn in the window. GetPort( ¤tPort ); if( QDIsPortBuffered( currentPort ) ) { GetPortBounds( currentPort, ¤tPortRect ); flushRegion = NewRgn(); RectRgn( flushRegion, ¤tPortRect ); QDFlushPortBuffer( currentPort, flushRegion ); DisposeRgn( flushRegion ); } }
int TkScrollWindow( Tk_Window tkwin, /* The window to be scrolled. */ GC gc, /* GC for window to be scrolled. */ int x, /* Position rectangle to be scrolled. */ int y, int width, int height, int dx, /* Distance rectangle should be moved. */ int dy, TkRegion damageRgn) /* Region to accumulate damage in. */ { MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin); RgnHandle rgn = (RgnHandle) damageRgn; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; Rect srcRect, scrollRect; destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Due to the implementation below the behavior may be differnt * than X in certain cases that should never occur in Tk. The * scrollRect is the source rect extended by the offset (the union * of the source rect and the offset rect). Everything * in the extended scrollRect is scrolled. On X, it's possible * to "skip" over an area if the offset makes the source and * destination rects disjoint and non-aligned. */ SetRect(&srcRect, (short) (destDraw->xOff + x), (short) (destDraw->yOff + y), (short) (destDraw->xOff + x + width), (short) (destDraw->yOff + y + height)); scrollRect = srcRect; if (dx < 0) { scrollRect.left += dx; } else { scrollRect.right += dx; } if (dy < 0) { scrollRect.top += dy; } else { scrollRect.bottom += dy; } /* * Adjust clip region so that we don't copy any windows * that may overlap us. */ RectRgn(rgn, &srcRect); DiffRgn(rgn, destPort->visRgn, rgn); OffsetRgn(rgn, dx, dy); DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn); SetEmptyRgn(rgn); /* * When a menu is up, the Mac does not expect drawing to occur and * does not clip out the menu. We have to do it ourselves. This * is pretty gross. */ if (tkUseMenuCascadeRgn == 1) { Point scratch = {0, 0}; MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin); LocalToGlobal(&scratch); CopyRgn(tkMenuCascadeRgn, rgn); OffsetRgn(rgn, -scratch.h, -scratch.v); DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn); SetEmptyRgn(rgn); macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU; } ScrollRect(&scrollRect, dx, dy, rgn); SetGWorld(saveWorld, saveDevice); /* * Fortunantly, the region returned by ScrollRect is symanticlly * the same as what we need to return in this function. If the * region is empty we return zero to denote that no damage was * created. */ if (EmptyRgn(rgn)) { return 0; } else { return 1; } }
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CDlgEventLog member initialisation m_iPreviousRowCount = 0; m_iTotalDocCount = 0; m_iPreviousTotalDocCount = 0; if (!s_bIsFiltered) { s_strFilteredProjectName.clear(); } m_iFilteredIndexes.Clear(); m_bProcessingRefreshEvent = false; m_bEventLogIsOpen = true; ////@end CDlgEventLog member initialisation CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxPoint oTempPoint; wxSize oTempSize; wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); if ((pos == wxDefaultPosition) && (size == wxDefaultSize)) { // Get size and position from the previous configuration GetWindowDimensions( oTempPoint, oTempSize ); #ifdef __WXMSW__ // Windows does some crazy things if the initial position is a negative // value. oTempPoint.x = wxDefaultCoord; oTempPoint.y = wxDefaultCoord; #endif #ifdef __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. Rect titleRect = {oTempPoint.y, oTempPoint.x, oTempPoint.y+22, oTempPoint.x+oTempSize.x }; 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)) oTempPoint.y = oTempPoint.x = 30; DisposeRgn(menuRgn); DisposeRgn(displayRgn); #endif // ! __WXMAC__ } else { oTempPoint = pos; oTempSize = size; } wxDialog::Create( parent, id, caption, oTempPoint, oTempSize, style ); SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); // Initialize Application Title wxString strCaption = caption; if (strCaption.IsEmpty()) { strCaption.Printf(_("%s - Event Log"), pSkinAdvanced->GetApplicationName().c_str()); } SetTitle(strCaption); // Initialize Application Icon wxIconBundle icons; icons.AddIcon(*pSkinAdvanced->GetApplicationIcon()); icons.AddIcon(*pSkinAdvanced->GetApplicationIcon32()); SetIcons(icons); CreateControls(); // Create List Pane Items m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109); m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130); m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378); m_pMessageInfoAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); m_pMessageErrorAttr = new wxListItemAttr( *wxRED, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); #if EVENT_LOG_STRIPES m_pMessageInfoGrayAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxColour(240, 240, 240), wxNullFont ); m_pMessageErrorGrayAttr = new wxListItemAttr(*wxRED, wxColour(240, 240, 240), wxNullFont); #else m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr); m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr); #endif SetTextColor(); RestoreState(); return true; }
pascal OSErr wxMacWindowDragTrackingHandler( DragTrackingMessage theMessage, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag ) { MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon; Point mouse, localMouse; DragAttributes attributes; GetDragAttributes( theDrag, &attributes ); PasteboardRef pasteboard = 0; GetDragPasteboard( theDrag, &pasteboard ); wxNonOwnedWindow* toplevel = wxNonOwnedWindow::GetFromWXWindow( (WXWindow) theWindow ); bool optionDown = GetCurrentKeyModifiers() & optionKey; wxDragResult result = optionDown ? wxDragCopy : wxDragMove; switch (theMessage) { case kDragTrackingEnterHandler: case kDragTrackingLeaveHandler: break; case kDragTrackingEnterWindow: if (trackingGlobals != NULL) { trackingGlobals->m_currentTargetWindow = NULL; trackingGlobals->m_currentTarget = NULL; } break; case kDragTrackingInWindow: if (trackingGlobals == NULL) break; if (toplevel == NULL) break; GetDragMouse( theDrag, &mouse, 0L ); { int x = mouse.h ; int y = mouse.v ; toplevel->GetNonOwnedPeer()->ScreenToWindow( &x, &y ); localMouse.h = x; localMouse.v = y; { wxWindow *win = NULL; ControlPartCode controlPart; ControlRef control = FindControlUnderMouse( localMouse, theWindow, &controlPart ); if ( control ) win = wxFindWindowFromWXWidget( (WXWidget) control ); else win = toplevel; int localx, localy; localx = localMouse.h; localy = localMouse.v; if ( win ) win->MacRootWindowToWindow( &localx, &localy ); if ( win != trackingGlobals->m_currentTargetWindow ) { if ( trackingGlobals->m_currentTargetWindow ) { // this window is left if ( trackingGlobals->m_currentTarget ) { HideDragHilite( theDrag ); trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard ); trackingGlobals->m_currentTarget->OnLeave(); trackingGlobals->m_currentTarget = NULL; trackingGlobals->m_currentTargetWindow = NULL; } } if ( win ) { // this window is entered trackingGlobals->m_currentTargetWindow = win; trackingGlobals->m_currentTarget = win->GetDropTarget(); { if ( trackingGlobals->m_currentTarget ) { trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard ); result = trackingGlobals->m_currentTarget->OnEnter( localx, localy, result ); } if ( result != wxDragNone ) { int x, y; x = y = 0; win->MacWindowToRootWindow( &x, &y ); RgnHandle hiliteRgn = NewRgn(); Rect r = { y, x, y + win->GetSize().y, x + win->GetSize().x }; RectRgn( hiliteRgn, &r ); ShowDragHilite( theDrag, hiliteRgn, true ); DisposeRgn( hiliteRgn ); } } } } else { if ( trackingGlobals->m_currentTarget ) { trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard ); result = trackingGlobals->m_currentTarget->OnDragOver( localx, localy, result ); } } // set cursor for OnEnter and OnDragOver if ( trackingGlobals->m_currentSource && !trackingGlobals->m_currentSource->GiveFeedback( result ) ) { if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) ) { wxStockCursor cursorID = wxCURSOR_NONE; switch (result) { case wxDragCopy: cursorID = wxCURSOR_COPY_ARROW; break; case wxDragMove: cursorID = wxCURSOR_ARROW; break; case wxDragNone: cursorID = wxCURSOR_NO_ENTRY; break; case wxDragError: case wxDragLink: case wxDragCancel: default: // put these here to make gcc happy ; } if (cursorID != wxCURSOR_NONE) { wxCursor cursor( cursorID ); cursor.MacInstall(); } } } } } break; case kDragTrackingLeaveWindow: if (trackingGlobals == NULL) break; if (trackingGlobals->m_currentTarget) { trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard ); trackingGlobals->m_currentTarget->OnLeave(); HideDragHilite( theDrag ); trackingGlobals->m_currentTarget = NULL; } trackingGlobals->m_currentTargetWindow = NULL; break; default: break; } return noErr; }
int Tcl_WaitForEvent( Tcl_Time *timePtr) /* Maximum block time. */ { int found; EventRecord macEvent; long sleepTime = 5; long ms; Point currentMouse; void * timerToken; Rect mouseRect; /* * Compute the next timeout value. */ if (!timePtr) { ms = INT_MAX; } else { ms = (timePtr->sec * 1000) + (timePtr->usec / 1000); } timerToken = TclMacStartTimer((long) ms); /* * Poll the Mac event sources. This loop repeats until something * happens: a timeout, a socket event, mouse motion, or some other * window event. Note that we don't call WaitNextEvent if another * event is found to avoid context switches. This effectively gives * events coming in via WaitNextEvent a slightly lower priority. */ found = 0; if (notifier.utilityRgn == NULL) { notifier.utilityRgn = NewRgn(); } while (!found) { /* * Check for generated and queued events. */ if (HandleMacEvents()) { found = 1; } /* * Check for time out. */ if (!found && TclMacTimerExpired(timerToken)) { found = 1; } /* * Check for window events. We may receive a NULL event for * various reasons. 1) the timer has expired, 2) a mouse moved * event is occuring or 3) the os is giving us time for idle * events. Note that we aren't sharing the processor very * well here. We really ought to do a better job of calling * WaitNextEvent for time slicing purposes. */ if (!found) { /* * Set up mouse region so we will wake if the mouse is moved. * We do this by defining the smallest possible region around * the current mouse position. */ GetGlobalMouse(¤tMouse); SetRect(&mouseRect, currentMouse.h, currentMouse.v, currentMouse.h + 1, currentMouse.v + 1); RectRgn(notifier.utilityRgn, &mouseRect); WaitNextEvent(everyEvent, &macEvent, sleepTime, notifier.utilityRgn); if (notifier.eventProcPtr != NULL) { if ((*notifier.eventProcPtr)(&macEvent) == true) { found = 1; } } } } TclMacRemoveTimer(timerToken); return 0; }
static void ROM_ShowMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; RgnHandle menuRgn = nil; RgnHandle tempRgn = nil; RgnHandle grayRgn = nil; WindowPtr window = nil; GrafPtr wMgrPort; GrafPtr savePort; Rect menuRect; long response; short height; EventRecord theEvent; RGBColor saveRGB; RGBColor blackRGB = { 0, 0, 0 }; height = GetMBarHeight(); if ((height <= 0) && (gSaveMenuBar > 0)) { drawRgn = NewRgn(); menuRgn = NewRgn(); tempRgn = NewRgn(); if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { goto CLEANUP; } grayRgn = GetGrayRgn(); /* No need to check for this */ GetPort(&savePort); GetWMgrPort(&wMgrPort); /* Set the height properly */ LMSetMBarHeight(gSaveMenuBar); /* Restore the old GrayRgn: rounded corners, etc, but not the menubar -- subtract that out first! */ if (gSaveGrayRgn) { menuRect = (*GetMainDevice())->gdRect; menuRect.bottom = menuRect.top + gSaveMenuBar; RectRgn(menuRgn, &menuRect); DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */ /* Now redraw the corners and other bits black */ SetPort(wMgrPort); GetClip(tempRgn); SetClip(drawRgn); GetForeColor(&saveRGB); RGBForeColor(&blackRGB); PaintRgn(drawRgn); RGBForeColor(&saveRGB); SetClip(tempRgn); SetPort(savePort); UnionRgn(drawRgn, menuRgn, drawRgn); /* Put back the menu */ /* Now actually restore the GrayRgn */ CopyRgn(gSaveGrayRgn, grayRgn); DisposeRgn(gSaveGrayRgn); gSaveGrayRgn = nil; } /* Modify the vis regions of exposed windows and draw menubar */ window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; PaintBehind(window, drawRgn); CalcVisBehind(window, drawRgn); DrawMenuBar(); SetPort(savePort); gSaveMenuBar = 0; /* Now show the control strip if it's present */ if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { if (gSaveCSVis && !SBIsControlStripVisible()) SBShowHideControlStrip(true); gSaveCSVis = true; } /* Yield time so that floaters can catch up */ EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); } CLEANUP: if (drawRgn) DisposeRgn(drawRgn); if (menuRgn) DisposeRgn(menuRgn); if (tempRgn) DisposeRgn(tempRgn); #endif /* !TARGET_API_MAC_CARBON */ }
static void ROM_HideMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; RgnHandle tempRgn = nil; RgnHandle grayRgn = nil; WindowPtr window = nil; GDHandle gd = nil; GrafPtr savePort; long response; short height; EventRecord theEvent; height = GetMBarHeight(); if ( height > 0 ) { tempRgn = NewRgn(); drawRgn = NewRgn(); gSaveGrayRgn = NewRgn(); if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { goto CLEANUP; } grayRgn = GetGrayRgn(); /* No need to check for this */ GetPort(&savePort); /* Hide the control strip if it's present, and record its previous position into the dirty region for redrawing. This isn't necessary, but may help catch stray bits. */ CopyRgn(grayRgn, tempRgn); if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { gSaveCSVis = SBIsControlStripVisible(); if (gSaveCSVis) SBShowHideControlStrip(false); } DiffRgn(grayRgn, tempRgn, drawRgn); /* Save the gray region once the control strip is hidden*/ CopyRgn(grayRgn, gSaveGrayRgn); /* Change the menu height in lowmem */ gSaveMenuBar = height; LMSetMBarHeight(0); /* Walk the monitor rectangles, and combine any pieces that aren't in GrayRgn: menubar, round corners, fake floaters. */ for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) { if (!TestDeviceAttribute(gd, screenDevice)) continue; if (!TestDeviceAttribute(gd, screenActive)) continue; RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */ } /* Add the bits into the GrayRgn */ UnionRgn(drawRgn, grayRgn, grayRgn); /* Modify the vis regions of exposed windows */ window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; PaintBehind(window, drawRgn); CalcVisBehind(window, drawRgn); SetPort(savePort); /* Yield time so that floaters can catch up */ EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); } CLEANUP: if (tempRgn) DisposeRgn(tempRgn); if (drawRgn) DisposeRgn(drawRgn); #endif /* !TARGET_API_MAC_CARBON */ }
pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag) { MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon; Point mouse, localMouse; DragAttributes attributes; GetDragAttributes(theDrag, &attributes); wxTopLevelWindowMac* toplevel = wxFindWinFromMacWindow( theWindow ) ; bool optionDown = GetCurrentKeyModifiers() & optionKey ; wxDragResult result = optionDown ? wxDragCopy : wxDragMove; switch(theMessage) { case kDragTrackingEnterHandler: break; case kDragTrackingLeaveHandler: break; case kDragTrackingEnterWindow: trackingGlobals->m_currentTargetWindow = NULL ; trackingGlobals->m_currentTarget = NULL ; break; case kDragTrackingInWindow: if (toplevel == NULL) break; GetDragMouse(theDrag, &mouse, 0L); localMouse = mouse; GlobalToLocal(&localMouse); { wxWindow *win = NULL ; ControlPartCode controlPart ; ControlRef control = wxMacFindControlUnderMouse( toplevel , localMouse , theWindow , &controlPart ) ; if ( control ) win = wxFindControlFromMacControl( control ) ; else win = toplevel ; int localx , localy ; localx = localMouse.h ; localy = localMouse.v ; if ( win ) win->MacRootWindowToWindow( &localx , &localy ) ; if ( win != trackingGlobals->m_currentTargetWindow ) { if ( trackingGlobals->m_currentTargetWindow ) { // this window is left if ( trackingGlobals->m_currentTarget ) { HideDragHilite(theDrag); trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->OnLeave() ; trackingGlobals->m_currentTarget = NULL; trackingGlobals->m_currentTargetWindow = NULL ; } } if ( win ) { // this window is entered trackingGlobals->m_currentTargetWindow = win ; trackingGlobals->m_currentTarget = win->GetDropTarget() ; { if ( trackingGlobals->m_currentTarget ) { trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; result = trackingGlobals->m_currentTarget->OnEnter( localx , localy , result ) ; } if ( result != wxDragNone ) { int x , y ; x = y = 0 ; win->MacWindowToRootWindow( &x , &y ) ; RgnHandle hiliteRgn = NewRgn() ; Rect r = { y , x , y+win->GetSize().y , x+win->GetSize().x } ; RectRgn( hiliteRgn , &r ) ; ShowDragHilite(theDrag, hiliteRgn, true); DisposeRgn( hiliteRgn ) ; } } } } else { if( trackingGlobals->m_currentTarget ) { trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->OnDragOver( localx , localy , result ) ; } } // set cursor for OnEnter and OnDragOver if ( trackingGlobals->m_currentSource && trackingGlobals->m_currentSource->GiveFeedback( result ) == FALSE ) { if ( trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) == FALSE ) { switch( result ) { case wxDragCopy : { wxCursor cursor(wxCURSOR_COPY_ARROW) ; cursor.MacInstall() ; } break ; case wxDragMove : { wxCursor cursor(wxCURSOR_ARROW) ; cursor.MacInstall() ; } break ; case wxDragNone : { wxCursor cursor(wxCURSOR_NO_ENTRY) ; cursor.MacInstall() ; } break ; case wxDragError: case wxDragLink: case wxDragCancel: // put these here to make gcc happy ; } } } } break; case kDragTrackingLeaveWindow: if (trackingGlobals->m_currentTarget) { trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->OnLeave() ; HideDragHilite(theDrag); trackingGlobals->m_currentTarget = NULL ; } trackingGlobals->m_currentTargetWindow = NULL ; break; } return(noErr); }
void DrawNoSectPolyRecursive (CMap *theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings,Rect subRect) { long PointCount, PlotCount = 0, PointIndex; LongPoint MatrixPt; Point LastScrPt, ThisScrPt, FirstScrPt; LongPoint **RgnPtsHdl; PolyHandle PolyHdl = nil; //////////// Boolean alwaysIn123 = true; Boolean alwaysIn174 = true; Boolean alwaysIn456 = true; Boolean alwaysIn386 = true; Boolean canSkipDrawingPolygon = false; // 1 7 4 // 2 0 5 // 3 8 6 //////////////// PointCount = GetPolyPointCount (MapPolyHdl); RgnPtsHdl = GetPolyPointsHdl (MapPolyHdl); Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE); #define MAXNUMSEGMENTS 8000 // JLM, It seems the limit is 32K not 64K at the documentation says short thisSectionOfPlane,prevSectionOfPlane; Boolean canSkipThisPt,skippedAPt,offQuickDrawPlane=false; Point lastSkippedPt; Rect fuzzyRect = subRect; long lineWidth = 1, esiCode; long outsetPixels = 2*lineWidth+2; // needs to be wider that the line width //long penWidth = 3; long penWidth = 2; long halfPenWidth = 0; InsetRect(&fuzzyRect,-outsetPixels,-outsetPixels); if (RgnPtsHdl != nil) { // must clip to this rect in addtion to the original clip Rect clippingRect = subRect; RgnHandle saveClip = NewRgn(), addition = NewRgn() , newClip = NewRgn(); GetClip(saveClip); GetClip(newClip); RectRgn(addition, &clippingRect); SectRgn(newClip, addition, newClip); SetClip(newClip); if(newClip) DisposeRgn(newClip); if(addition) DisposeRgn(addition); if (drawSettings -> fillCode != kNoFillCode) PolyHdl = OpenPoly (); else { PolyHdl = OpenPoly (); //Our_PmForeColor (gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd); Our_PmForeColor (drawSettings -> foreColorInd); } GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); if (esiCode>0) // -500 is the default { //halfPenWidth = penWidth/2; #ifdef MAC PenSize(penWidth,penWidth); #else PenStyle(BLACK,penWidth); #endif } for (PointIndex = 0,skippedAPt = false,prevSectionOfPlane = -1; PointIndex < PointCount; ++PointIndex) { MatrixPt = (*RgnPtsHdl) [PointIndex]; // theMap -> GetScrPoint (&MatrixPt, &ThisScrPt); //ThisScrPt.h = SameDifferenceX(MatrixPt.h); //ThisScrPt.v = (gRect.bottom + gRect.top) - SameDifferenceY(MatrixPt.v); ThisScrPt = GetQuickDrawPt(MatrixPt.h, MatrixPt.v, &gRect, &offQuickDrawPlane); // code goes here, what to do when point is off quickdraw plane? //if (offQuickDrawPlane) break; ThisScrPt.h += drawSettings -> offsetDx; ThisScrPt.v += drawSettings -> offsetDy; if(PolyHdl) { //// JLM 2/18/99 // for points outside the drawing area, it is not necessary to move to the correct point, // as long as we preserve the winding. This allows us to ignore many of the points outside // the drawing rectangle gRect thisSectionOfPlane = SectionOfPlane(&fuzzyRect,ThisScrPt); if( thisSectionOfPlane > 0 // outside of the rectangle && thisSectionOfPlane == prevSectionOfPlane // we have not changed sections of the plane && PointIndex < PointCount -1) // not the last point canSkipThisPt = true; else canSkipThisPt = false; prevSectionOfPlane = thisSectionOfPlane; if(canSkipThisPt) { skippedAPt = true; lastSkippedPt =ThisScrPt; continue; } /// JLM 3/6/01 switch(thisSectionOfPlane) { case 1: alwaysIn456 = false; alwaysIn386 = false; break; case 2: alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break; case 3: alwaysIn174 = false; alwaysIn456 = false; break; case 4: alwaysIn123 = false; alwaysIn386 = false; break; case 5: alwaysIn123 = false; alwaysIn174 = false; alwaysIn386 = false; break; case 6: alwaysIn123 = false; alwaysIn174 = false; break; case 7: alwaysIn123 = false; alwaysIn456 = false; alwaysIn386 = false; break; case 8: alwaysIn123 = false; alwaysIn174 = false; alwaysIn456 = false; break; default: alwaysIn123 = false; alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break; } ////// if(skippedAPt) { // then we have to draw to the previous point // before we draw to the current point PointIndex--; //so we do the previous point below ThisScrPt = lastSkippedPt; // restore the coordinates of the previous point prevSectionOfPlane = -1; // force the next point to not be skipped } skippedAPt = false; if(PlotCount > MAXNUMSEGMENTS) { // there is a bug on the max when the number of points gets too large // try recusion ClosePoly(); KillPoly(PolyHdl); SetClip(saveClip);// JLM 8/4/99 goto recursion; } ////////////// } if (PointIndex == 0) { MyMoveTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth); FirstScrPt = ThisScrPt; LastScrPt = ThisScrPt; PlotCount = 0; } else { if (LastScrPt.h != ThisScrPt.h || LastScrPt.v != ThisScrPt.v) { MyLineTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth); LastScrPt = ThisScrPt; ++PlotCount; } } } if (drawSettings -> bClosed) /* draw a line from last point to first point if requested */ { MyLineTo (FirstScrPt.h-halfPenWidth, FirstScrPt.v-halfPenWidth); ++PlotCount; } if (PolyHdl != nil) { ClosePoly (); ////////////// JLM 3/6/01 if(alwaysIn123 || alwaysIn174 || alwaysIn456 || alwaysIn386) canSkipDrawingPolygon = true; if(canSkipDrawingPolygon) PlotCount = 0; // so that we skip the code below //////////// if (PlotCount > 0) { if (PlotCount > 2) /* polygon must contain more than 2 line-to points */ { if (drawSettings -> bErase || (drawSettings -> fillCode == kNoFillCode && drawSettings -> backColorInd == kWaterColorInd)) ErasePoly (PolyHdl); if (drawSettings -> fillCode == kPaintFillCode) { // this is the usual drawing code Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM if(bDrawBlackAndWhite) SetPenPat(UPSTRIPES); PaintPoly(PolyHdl);//JLM if(bDrawBlackAndWhite) SetPenPat(BLACK); } else if (drawSettings -> fillCode == kPatFillCode) FillPoly (PolyHdl, &(drawSettings -> backPattern)); } if (drawSettings -> frameCode == kPaintFrameCode) { Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd); FramePoly (PolyHdl); } else if (drawSettings -> frameCode == kPatFrameCode) { PenPat (&(drawSettings -> forePattern)); FramePoly (PolyHdl); } } KillPoly (PolyHdl); } SetClip(saveClip); if(saveClip) DisposeRgn(saveClip); } #ifdef MAC PenSize(1,1); #else PenStyle(BLACK,1); #endif return; //////////////////////////////// recursion: //////////////////////////////// { #define MAXRECURSION 20 static short sRecursionValue = 0; if(sRecursionValue >= MAXRECURSION) { printError("max recusion exceeded"); } else { // use recursion Rect subBoundingRect; long middleH = (subRect.left+subRect.right)/2; long middleV = (subRect.top+subRect.bottom)/2; long index; sRecursionValue++; // divide the points up and Draw again for(index = 0; index < 4; index++) { subBoundingRect = subRect; switch(index) { case 0: subBoundingRect.top = middleV; subBoundingRect.left = middleH; break; case 1: subBoundingRect.top = middleV; subBoundingRect.right = middleH; break; case 2: subBoundingRect.bottom = middleV; subBoundingRect.left = middleH; break; default: subBoundingRect.bottom = middleV; subBoundingRect.right = middleH; break; } // the recursive call DrawNoSectPolyRecursive (theMap,MapPolyHdl,drawSettings,subBoundingRect); } // all done sRecursionValue--; return; } } }
bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) { CBOINCBaseFrame* pNewFrame = NULL; CBOINCBaseFrame* pOldFrame = m_pFrame; wxInt32 iTop = 0; wxInt32 iLeft = 0; wxInt32 iHeight = 0; wxInt32 iWidth = 0; // Create the new window if ((iGUISelection != m_iGUISelected) || !m_pFrame) { // Reterieve the desired window state before creating the // desired frames if (BOINC_ADVANCEDGUI == iGUISelection) { m_pConfig->SetPath(wxT("/")); m_pConfig->Read(wxT("YPos"), &iTop, 30); m_pConfig->Read(wxT("XPos"), &iLeft, 30); m_pConfig->Read(wxT("Width"), &iWidth, 800); m_pConfig->Read(wxT("Height"), &iHeight, 600); } else { m_pConfig->SetPath(wxT("/Simple")); m_pConfig->Read(wxT("YPos"), &iTop, 30); m_pConfig->Read(wxT("XPos"), &iLeft, 30); #ifdef __WXMAC__ m_pConfig->Read(wxT("Width"), &iWidth, 409); m_pConfig->Read(wxT("Height"), &iHeight, 561); #else m_pConfig->Read(wxT("Width"), &iWidth, 416); m_pConfig->Read(wxT("Height"), &iHeight, 570); #endif } // Make sure that the new window is going to be visible // on a screen #ifdef __WXMAC__ 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); #else // 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 = 30; if ( iTop < 0 ) iTop = 30; // Read the size of the screen wxInt32 iMaxWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X ); wxInt32 iMaxHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); // Max sure that it doesn't go off to the right or bottom if ( iLeft + iWidth > iMaxWidth ) iLeft = iMaxWidth - iWidth; if ( iTop + iHeight > iMaxHeight ) iTop = iMaxHeight - iHeight; #endif // Create the main window // if (BOINC_ADVANCEDGUI == iGUISelection) { // Initialize the advanced gui window pNewFrame = new CAdvancedFrame( m_pSkinManager->GetAdvanced()->GetApplicationName(), m_pSkinManager->GetAdvanced()->GetApplicationIcon(), m_pSkinManager->GetAdvanced()->GetApplicationIcon32(), wxPoint(iLeft, iTop), wxSize(iWidth, iHeight) ); } else { // Initialize the simple gui window pNewFrame = new CSimpleFrame( m_pSkinManager->GetAdvanced()->GetApplicationName(), m_pSkinManager->GetAdvanced()->GetApplicationIcon(), m_pSkinManager->GetAdvanced()->GetApplicationIcon32(), wxPoint(iLeft, iTop), wxSize(iWidth, iHeight) ); } wxASSERT(pNewFrame); if (pNewFrame) { SetTopWindow(pNewFrame); // Store the new frame for future use m_pFrame = pNewFrame; // Hide the old one if it exists. We must do this // after updating m_pFrame to prevent Mac OSX from // hiding the application if (pOldFrame) pOldFrame->Hide(); // Delete the old one if it exists // Note: this has the side effect of hiding the Event Log if (pOldFrame) pOldFrame->Destroy(); // Show the new frame if needed (and show the Event Log if open) if (pNewFrame && bShowWindow) pNewFrame->Show(); } } // Show the new frame if needed if (m_pFrame && bShowWindow) { if (m_pEventLog) { m_pEventLog->Show(); m_pEventLog->Raise(); #ifdef __WXMSW__ ::SetForegroundWindow((HWND)m_pEventLog->GetHWND()); #endif } if (!m_pFrame->IsShown()) { m_pFrame->Show(); } m_pFrame->Raise(); #ifdef __WXMSW__ ::SetForegroundWindow((HWND)m_pFrame->GetHWND()); #endif } m_iGUISelected = iGUISelection; m_pConfig->SetPath(wxT("/")); m_pConfig->Write(wxT("GUISelection"), iGUISelection); return true; }
OSStatus HIRevolutionStackViewHandler(EventHandlerCallRef p_call_ref, EventRef p_event, void *p_data) { OSStatus t_status; t_status = eventNotHandledErr; UInt32 t_event_class; t_event_class = GetEventClass(p_event); UInt32 t_event_kind; t_event_kind = GetEventKind(p_event); HIRevolutionStackViewData *t_context; t_context = (HIRevolutionStackViewData *)p_data; switch(t_event_class) { case 'revo': switch(t_event_kind) { case 'rlnk': GetEventParameter(p_event, 'Stak', typeVoidPtr, NULL, sizeof(void *), NULL, &t_context -> stack); break; } break; case kEventClassHIObject: switch(t_event_kind) { case kEventHIObjectConstruct: { HIRevolutionStackViewData *t_data; t_data = new HIRevolutionStackViewData; t_data -> stack = NULL; GetEventParameter(p_event, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(HIObjectRef), NULL, (HIObjectRef *)&t_data -> view); SetEventParameter(p_event, kEventParamHIObjectInstance, typeVoidPtr, sizeof(HIRevolutionStackViewData *), &t_data); t_status = noErr; } break; case kEventHIObjectInitialize: { GetEventParameter(p_event, 'Stak', typeVoidPtr, NULL, sizeof(void *), NULL, &t_context -> stack); Rect t_bounds; t_bounds . left = 0; // MW-2011-09-12: [[ MacScroll ]] Make sure the top of the HIView takes into // account the scroll. t_bounds . top = -t_context -> stack -> getscroll(); t_bounds . right = t_context -> stack -> getrect() . width; t_bounds . bottom = t_context -> stack -> getrect() . height; SetControlBounds((ControlRef)t_context -> view, &t_bounds); t_status = noErr; } break; case kEventHIObjectDestruct: { delete t_context; t_status = noErr; } break; } break; case kEventClassControl: switch(t_event_kind) { case kEventControlInitialize: { t_status = noErr; } break; case kEventControlDraw: { CGContextRef t_graphics; GetEventParameter(p_event, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &t_graphics); RgnHandle t_dirty_rgn; GetEventParameter(p_event, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof(RgnHandle), NULL, &t_dirty_rgn); if (t_context -> stack != NULL) { // Compute the clip region for players. RgnHandle t_clip_rgn, t_rect_rgn; t_clip_rgn = NULL; t_rect_rgn = NULL; for(MCPlayer *t_player = MCplayers; t_player != NULL; t_player = t_player -> getnextplayer()) if (t_player -> isvisible() && t_player -> getcard() == t_context -> stack -> getcurcard() && !t_player -> isbuffering()) { MCRectangle t_rect; Rect t_mac_rect; t_rect = t_player -> getactiverect(); if (t_clip_rgn == NULL) { t_clip_rgn = NewRgn(); CopyRgn((RgnHandle)t_dirty_rgn, t_clip_rgn); t_rect_rgn = NewRgn(); } SetRect(&t_mac_rect, t_rect . x, t_rect . y, t_rect . x + t_rect . width, t_rect . y + t_rect . height); RectRgn(t_rect_rgn, &t_mac_rect); DiffRgn(t_clip_rgn, t_rect_rgn, t_clip_rgn); } // We don't need the rect rgn anymore. if (t_rect_rgn != NULL) DisposeRgn(t_rect_rgn); // If the clip region is non-nil, then apply it. if (t_clip_rgn != NULL) { // As we can't clip to empty path, if the region is empty, we set the context // to nil. if (!EmptyRgn(t_clip_rgn)) { HIShapeRef t_shape; t_shape = HIShapeCreateWithQDRgn(t_clip_rgn); HIShapeReplacePathInCGContext(t_shape, t_graphics); CGContextClip(t_graphics); CFRelease(t_shape); } else t_graphics = nil; DisposeRgn(t_clip_rgn); } // If the graphics context is non-nil (i.e. we aren't completely occluded) then // draw something. if (t_graphics != nil) { // HIView gives us a context in top-left origin mode which isn't so good // for our CG rendering so, revert back to bottom-left. CGContextScaleCTM(t_graphics, 1.0, -1.0); CGContextTranslateCTM(t_graphics, 0.0, -t_context -> stack -> getcurcard() -> getrect() . height); // Save the context state CGContextSaveGState(t_graphics); // If we don't have an update pixmap, then use redrawwindow. if (s_update_pixmap == nil) { MCMacStackSurface t_surface(t_context -> stack, (MCRegionRef)t_dirty_rgn, t_graphics); t_context -> stack -> redrawwindow(&t_surface, (MCRegionRef)t_dirty_rgn); } else { int32_t t_height; t_height = t_context -> stack -> getcurcard() -> getrect() . height; MCRectangle t_rect; t_rect = MCRegionGetBoundingBox((MCRegionRef)t_dirty_rgn); CGRect t_area; t_area = CGRectMake(t_rect . x, t_height - (t_rect . y + t_rect . height), t_rect . width, t_rect . height); CGContextClearRect(t_graphics, t_area); void *t_bits; uint32_t t_stride; MCscreen -> lockpixmap(s_update_pixmap, t_bits, t_stride); MCMacRenderBitsToCG(t_graphics, t_area, t_bits, t_stride, t_context -> stack -> getwindowshape() != nil ? true : false); MCscreen -> unlockpixmap(s_update_pixmap, t_bits, t_stride); } // Restore the context state CGContextRestoreGState(t_graphics); } // MW-2011-11-23: [[ Bug ]] Force a redraw of the players on the stack // after we've drawn the rest of the content. This ensures players // which are just appearing don't disappear behind said content. for(MCPlayer *t_player = MCplayers; t_player != NULL; t_player = t_player -> getnextplayer()) if (t_player -> isvisible() && t_player -> getcard() == t_context -> stack -> getcurcard() && !t_player -> isbuffering()) MCDoAction((MovieController)t_player -> getMovieController(), mcActionDraw, t_context -> stack -> getqtwindow()); } t_status = noErr; } break; case kEventControlHitTest: break; case kEventControlGetPartRegion: { ControlPartCode t_part; GetEventParameter(p_event, kEventParamControlPart, typeControlPartCode, NULL, sizeof(ControlPartCode), NULL, &t_part); RgnHandle t_region; GetEventParameter(p_event, kEventParamControlRegion, typeQDRgnHandle, NULL, sizeof(RgnHandle), NULL, &t_region); } break; case kEventControlHiliteChanged: break; case kEventControlActivate: break; case kEventControlDeactivate: break; } break; } return t_status; }
void shellupdatecontent (Rect contentrect) { /* update the portion of contectrect in shellwindow that needs updating, and validate the area updated 2/11/91 dmb: it turns out that we usually want to update the scroll bars at this time too, before redrawing contectrect 12/9/91 dmb: quick bail-out if update rgn is empty 9/22/92 dmb: don't draw scrollbars when update rgn is empty */ register hdlwindowinfo hw = shellwindowinfo; register hdlregion contentrgn, updatergn; hdlregion actualupdatergn; actualupdatergn = getupdateregion (shellwindow); if (EmptyRgn (actualupdatergn)) { #ifdef WIN95VERSION DeleteObject (actualupdatergn); #endif return; } shellupdatescrollbars (hw); updatergn = NewRgn (); CopyRgn (actualupdatergn, updatergn); /*window's update rgn is global*/ globaltolocalrgn (updatergn); #ifdef MACVERSION RectRgn (contentrgn = NewRgn (), &contentrect); #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1 //in carbon a copy of the update region is returned. DisposeRgn(actualupdatergn); actualupdatergn = nil; #endif #endif #ifdef WIN95VERSION DeleteObject (actualupdatergn); insetrect (&contentrect, -1, -1); contentrgn = CreateRectRgn (contentrect.left, contentrect.top, contentrect.right, contentrect.bottom); #endif SectRgn (contentrgn, updatergn, contentrgn); /*re-use contentrgn*/ #if defined(WIN95VERSION) && fldebug /****** DEBUG CODE *********/ if (false) { RECT rrr; GetClientRect (shellwindow, &rrr); DeleteObject(contentrgn); contentrgn = CreateRectRgn (rrr.left, rrr.top, rrr.right, rrr.bottom); FillRect (getport(), &rrr, GetStockObject (WHITE_BRUSH)); } #endif if (!EmptyRgn (contentrgn)) { (**hw).drawrgn = contentrgn; /*for display routines to refer to*/ //Code change by Timothy Paustian Monday, June 19, 2000 3:09:46 PM //Changed to Opaque call for Carbon #ifdef MACVERSION #if TARGET_API_MAC_CARBON == 1 ValidWindowRgn((WindowRef) hw, contentrgn); #else ValidRgn (contentrgn); /*no need to draw it again. do now to simulate beginupdate*/ #endif #endif #ifdef WIN95VERSION ValidateRgn (shellwindow, contentrgn); #endif pushcliprgn (contentrgn, false); (*shellglobals.updateroutine) (); popclip (); (**hw).drawrgn = nil; /*keep it neat, this guy is a temp*/ } DisposeRgn (updatergn); DisposeRgn (contentrgn); } /*shellupdatecontent*/