void PIInspectorTable::ListenToMessage( MessageT inMessage, void* ioParam) { switch (inMessage) { // Grow zone: Property inspector is expendable, close it if low on memory. case msg_GrowZone: LWindow* window; window = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(window); window->DoClose(); break; // Detach PI button: Detach this inspector from the selection. case 'DTCH': DetachFromSelection(); break; // Other messages: Pass along to table. default: OVTable::ListenToMessage(inMessage, ioParam); } }
Boolean UPropertyInspector::SelectInspectorWindow( DMElement* inElement) { // Validate pointers. ValidateObject_(inElement); // See if there's an inspector for this element. PIInspectorTable* table = (PIInspectorTable*) inElement->FindUserInterfaceObject(PIInspectorTable::object_ID); if (table == nil) return false; // There's a table. Select its window. LWindow* window = LWindow::FetchWindowObject(GetWindowFromPort(table->GetMacPort())); ValidateObject_(window); window->Select(); return true; }
void structGraphicsScreen :: v_getMouseLocation (double *xWC, double *yWC) { #if cairo GdkEvent *gevent = gdk_display_get_event (d_display); if (gevent != NULL) { if (gevent -> type == GDK_BUTTON_RELEASE) { theMouseDown = false; } gdk_event_free (gevent); } gint xDC, yDC; gdk_window_get_pointer (d_window, & xDC, & yDC, NULL); Graphics_DCtoWC (this, xDC, yDC, xWC, yWC); #elif cocoa #elif win POINT pos; if (! GetCursorPos (& pos)) { Melder_warning (L"Cannot get cursor position."); return; } ScreenToClient (d_winWindow, & pos); Graphics_DCtoWC (this, pos. x, pos. y, xWC, yWC); #elif mac if (HIGetMousePosition != NULL && false) { // AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER //Melder_casual ("HIGetMousePosition exists"); HIPoint mouseLoc; HIGetMousePosition (kHICoordSpaceWindow, GetWindowFromPort (d_macPort), & mouseLoc); Graphics_DCtoWC (this, mouseLoc. x, mouseLoc. y, xWC, yWC); } else { Point mouseLoc; GetMouse (& mouseLoc); // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 Graphics_DCtoWC (this, mouseLoc. h, mouseLoc. v, xWC, yWC); } #endif }
void PIInspectorTable::DetachFromSelection() { // Validate pointers. ValidateThis_(); // Make sure we're currently inspecting an object. // If not, the detach command is ignored. if (mElement == nil) return; ValidateObject_(mElement.GetObject()); // Disable the detach button. if (mDetachPIButton != nil) { ValidateObject_(mDetachPIButton); mDetachPIButton->Disable(); } // Disconnect from selection. mFollowSelection = nil; mIsDetached = true; // Retitle the window to match our object's title. LWindow* window = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(window); LStr255 displayableName; mElement->GetDisplayableName(displayableName); if (displayableName.Length() > 0) window->SetDescriptor(displayableName); // Tell the property inspector manager that we're no longer following selection. LWindow* myWindow = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(myWindow); UPropertyInspector::ClosingInspectorWindow(myWindow); }
void XMapWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; CGrafPtr destPort; /* * Under certain situations it's possible for this function to be * called before the toplevel window it's associated with has actually * been mapped. In that case we need to create the real Macintosh * window now as this function as well as other X functions assume that * the portPtr is valid. */ if (!TkMacOSXHostToplevelExists(macWin->toplevel->winPtr)) { TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr); } destPort = TkMacOSXGetDrawablePort (window); display->request++; macWin->winPtr->flags |= TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { ShowWindow(GetWindowFromPort(destPort)); } /* * We only need to send the MapNotify event * for toplevel windows. */ event.xany.serial = display->request; event.xany.send_event = False; event.xany.display = display; event.xmap.window = window; event.xmap.type = MapNotify; event.xmap.event = window; event.xmap.override_redirect = macWin->winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { TkMacOSXInvalClipRgns(macWin->winPtr->parentPtr); } /* * Generate damage for that area of the window */ SetGWorld (destPort, NULL); TkMacOSXUpdateClipRgn(macWin->winPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); }
PIInspectorTable::~PIInspectorTable() { // Validate pointers. ValidateThis_(); // Tell the property inspector manager that this window is going away. LWindow* myWindow = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(myWindow); UPropertyInspector::ClosingInspectorWindow(myWindow); }
WindowRef TkMacOSXDrawableWindow( Drawable drawable) { MacDrawable *macWin = (MacDrawable *) drawable; WindowRef result = NULL; if (!macWin || macWin->flags & TK_IS_PIXMAP) { result = NULL; } else { result = GetWindowFromPort(TkMacOSXGetDrawablePort(drawable)); } return result; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Destructor // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Deletes the world if it owns it CBLCanvas::~CBLCanvas() { if (mWorld && mOwnsWorld) { if (mIsWindow) { WindowPtr window=GetWindowFromPort(mWorld); BlastAssert_(IsValidWindowPtr(window)); ::DisposeWindow(window); } else ::DisposeGWorld(mWorld); } ::DestroyABCRec(&mABCRec); }
void XConfigureWindow( Display* display, /* Display. */ Window w, /* Window. */ unsigned int value_mask, XWindowChanges* values) { MacDrawable *macWin = (MacDrawable *) w; TkWindow *winPtr = macWin->winPtr; display->request++; /* * Change the shape and/or position of the window. */ if (value_mask & (CWX|CWY|CWWidth|CWHeight)) { XMoveResizeWindow(display, w, winPtr->changes.x, winPtr->changes.y, winPtr->changes.width, winPtr->changes.height); } /* * Change the stacking order of the window. Tk actuall keeps all * the information we need for stacking order. All we need to do * is make sure the clipping regions get updated and generate damage * that will ensure things get drawn correctly. */ if (value_mask & CWStackMode) { Rect bounds; CGrafPtr destPort; destPort = TkMacOSXGetDrawablePort(w); if (destPort != NULL) { SetPort( destPort); TkMacOSXInvalClipRgns(winPtr->parentPtr); TkMacOSXWinBounds(winPtr, &bounds); InvalWindowRect(GetWindowFromPort(destPort),&bounds); } } /* TkGenWMMoveRequestEvent(macWin->winPtr, macWin->winPtr->changes.x, macWin->winPtr->changes.y); */ }
void PIInspectorTable::FinishCreateSelf() { // Validate pointers. ValidateThis_(); // Do inherited initialization. OVTable::FinishCreateSelf(); // Set up default column widths. InsertCols(2, 0, nil, 0, false); SetColWidth(130, 1, 1); SetColWidth(150, 2, 2); // Find inspected object caption. LWindow* window = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(window); mInspectedObjectCaption = dynamic_cast<LStaticText*>(window->FindPaneByID(Pane_InspectedObject)); if (mInspectedObjectCaption != nil) ValidateObject_(mInspectedObjectCaption); // Find detach selection button. mDetachPIButton = (dynamic_cast<LBevelButton*>(window->FindPaneByID('DTCH'))); if (mDetachPIButton != nil) { ValidateObject_(mDetachPIButton); mDetachPIButton->AddListener(this); } // Listen to the grow zone. LGrowZone* growZone = LGrowZone::GetGrowZone(); ThrowIfNil_(growZone); growZone->AddListener(this); }
void TkMacOSXInvalidateWindow( MacDrawable *macWin, /* Make window that's causing damage. */ int flag) /* Should be TK_WINDOW_ONLY or * TK_PARENT_WINDOW */ { WindowRef windowRef; CGrafPtr grafPtr; grafPtr=TkMacOSXGetDrawablePort((Drawable)macWin); windowRef=GetWindowFromPort(grafPtr); if (flag == TK_WINDOW_ONLY) { InvalWindowRgn(windowRef,macWin->clipRgn); } else { if (!EmptyRgn(macWin->aboveClipRgn)) { InvalWindowRgn(windowRef,macWin->aboveClipRgn); } } }
void XUnmapWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; CGrafPtr destPort; destPort = TkMacOSXGetDrawablePort(window); display->request++; macWin->winPtr->flags &= ~TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { HideWindow(GetWindowFromPort(destPort)); } /* * We only need to send the UnmapNotify event * for toplevel windows. */ event.xany.serial = display->request; event.xany.send_event = False; event.xany.display = display; event.xunmap.type = UnmapNotify; event.xunmap.window = window; event.xunmap.event = window; event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { /* * Generate damage for that area of the window. */ SetGWorld(destPort, NULL); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); /* TODO: may not be valid */ TkMacOSXInvalClipRgns(macWin->winPtr->parentPtr); } }
void IPlugProcess::SetViewPort (GrafPtr aPort) { mMainPort = aPort; CEffectProcess::SetViewPort( mMainPort ); // call inherited first if(mMainPort) { if(mCustomUI) { void *windowPtr = NULL; #if WINDOWS_VERSION windowPtr = (void*)ASI_GethWnd((WindowPtr)mMainPort); #elif MAC_VERSION windowPtr = (void*)GetWindowFromPort(mMainPort); // WindowRef for Carbon, not GrafPtr (quickdraw) Rect portBounds; GetPortBounds(aPort, &portBounds); if ((portBounds.left <= 0 && portBounds.top <= 0) && (mLeftOffset == 0 && mTopOffset == 0)) { mLeftOffset = -portBounds.left; mTopOffset = -portBounds.top; } #endif mCustomUI->Open(windowPtr, mLeftOffset, mTopOffset); #if WINDOWS_VERSION mCustomUI->Draw(mPluginWinRect.left, mPluginWinRect.top, mPluginWinRect.right, mPluginWinRect.bottom); #endif } } else { if(mCustomUI) mCustomUI->Close(); if( mView ) mView->SetEnable(false); } return; }
void PIInspectorTable::GoingAway( DMElement* /* inElement */) { // Validate pointers. ValidateThis_(); // If detached, close the window and go away. if (mIsDetached) { LWindow* window = LWindow::FetchWindowObject(GetWindowFromPort(GetMacPort())); ValidateObject_(window); delete window; return; } // Clear table and wait for a new selection. SetElement(nil); }
void XMoveWindow( Display* display, /* Display. */ Window window, /* Window. */ int x, int y) { MacDrawable *macWin = (MacDrawable *) window; CGrafPtr destPort; destPort = TkMacOSXGetDrawablePort(window); if (destPort == NULL) { return; } SetPort( destPort); if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { /* * NOTE: we are not adding the new space to the update * region. It is currently assumed that Tk will need * to completely redraw anway. */ MoveWindowStructure( GetWindowFromPort(destPort), x, y); /* TODO: is the following right? */ TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY); TkMacOSXInvalClipRgns(macWin->winPtr); } else { int deltaX, deltaY, parentBorderwidth; Rect bounds; MacDrawable *macParent; /* * Find the Parent window - * For an embedded window this will be its container. */ if (Tk_IsEmbedded(macWin->winPtr)) { TkWindow *contWinPtr; contWinPtr = TkpGetOtherWindow(macWin->winPtr); if (contWinPtr == NULL) { panic("XMoveWindow could not find container"); } macParent = contWinPtr->privatePtr; /* * NOTE: Here we should handle out of process embedding. */ } else { macParent = macWin->winPtr->parentPtr->privatePtr; if (macParent == NULL) { return; /* TODO: Probably should be a panic */ } } TkMacOSXInvalClipRgns(macParent->winPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = - macWin->xOff; deltaY = - macWin->yOff; /* * If macWin->winPtr is an embedded window, don't offset by its * parent's borderwidth... */ if (!Tk_IsEmbedded(macWin->winPtr)) { parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width; } else { parentBorderwidth = 0; } deltaX += macParent->xOff + parentBorderwidth + macWin->winPtr->changes.x; deltaY += macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y; UpdateOffsets(macWin->winPtr, deltaX, deltaY); TkMacOSXWinBounds(macWin->winPtr, &bounds); InvalWindowRect(GetWindowFromPort(destPort),&bounds); } }
void XDestroyWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; CGrafPtr destPort; /* * Remove any dangling pointers that may exist if * the window we are deleting is being tracked by * the grab code. */ TkPointerDeadWindow(macWin->winPtr); macWin->toplevel->referenceCount--; if (Tk_IsTopLevel(macWin->winPtr)) { DisposeRgn(macWin->clipRgn); DisposeRgn(macWin->aboveClipRgn); /* * Delete the Mac window and remove it from the windowTable. * The window could be NULL if the window was never mapped. * However, we don't do this for embedded windows, they don't * go in the window list, and they do not own their portPtr's. */ if (!(Tk_IsEmbedded(macWin->winPtr))) { destPort = TkMacOSXGetDrawablePort(window); if (destPort != NULL) { TkMacOSXWindowList *listPtr, *prevPtr; WindowRef winRef; winRef = GetWindowFromPort(destPort); TkMacOSXUnregisterMacWindow(winRef); DisposeWindow(winRef); for (listPtr = tkMacOSXWindowListPtr, prevPtr = NULL; tkMacOSXWindowListPtr != NULL; prevPtr = listPtr, listPtr = listPtr->nextPtr) { if (listPtr->winPtr == macWin->winPtr) { if (prevPtr == NULL) { tkMacOSXWindowListPtr = listPtr->nextPtr; } else { prevPtr->nextPtr = listPtr->nextPtr; } ckfree((char *) listPtr); break; } } } } macWin->grafPtr = NULL; /* * Delay deletion of a toplevel data structure untill all * children have been deleted. */ if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } } else { CGrafPtr destPort; destPort = TkMacOSXGetDrawablePort(window); if (destPort != NULL) { SetGWorld(destPort, NULL); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); } if (macWin->winPtr->parentPtr != NULL) { TkMacOSXInvalClipRgns(macWin->winPtr->parentPtr); } DisposeRgn(macWin->clipRgn); DisposeRgn(macWin->aboveClipRgn); if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } ckfree((char *) macWin); } }
void XResizeWindow( Display* display, /* Display. */ Window window, /* Window. */ unsigned int width, unsigned int height) { MacDrawable *macWin = (MacDrawable *) window; CGrafPtr destPort; destPort = TkMacOSXGetDrawablePort(window); if (destPort == NULL) { return; } display->request++; SetPort( destPort); if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { /* * NOTE: we are not adding the new space to the update * region. It is currently assumed that Tk will need * to completely redraw anway. */ SizeWindow(GetWindowFromPort(destPort), (short) width, (short) height, false); TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY); TkMacOSXInvalClipRgns(macWin->winPtr); } else { int deltaX, deltaY; /* * Find the Parent window - * For an embedded window this will be its container. */ TkWindow *contWinPtr; contWinPtr = TkpGetOtherWindow(macWin->winPtr); if (contWinPtr != NULL) { MacDrawable *macParent = contWinPtr->privatePtr; TkMacOSXInvalClipRgns(macParent->winPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = macParent->xOff + macWin->winPtr->changes.x - macWin->xOff; deltaY = macParent->yOff + macWin->winPtr->changes.y - macWin->yOff; UpdateOffsets(macWin->winPtr, deltaX, deltaY); } else { /* * This is the case where we are embedded in * another app. At this point, we are assuming that * the changes.x,y is not maintained, if you need * the info get it from Tk_GetRootCoords, * and that the toplevel sits at 0,0 when it is drawn. */ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); UpdateOffsets(macWin->winPtr, 0, 0); } } } else { /* TODO: update all xOff & yOffs */ int deltaX, deltaY, parentBorderwidth; MacDrawable *macParent = macWin->winPtr->parentPtr->privatePtr; if (macParent == NULL) { return; /* TODO: Probably should be a panic */ } TkMacOSXInvalClipRgns(macParent->winPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = - macWin->xOff; deltaY = - macWin->yOff; parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width; deltaX += macParent->xOff + parentBorderwidth + macWin->winPtr->changes.x; deltaY += macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y; UpdateOffsets(macWin->winPtr, deltaX, deltaY); } }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macDraw; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; WindowRef windowRef; if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } /* * Draw the focus or any 3D relief we may have. */ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, Tk_WindowId(tkwin)); TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } else { TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); if (macScrollPtr->sbHandle == NULL) { Rect r; SInt16 initialValue; SInt16 minValue; SInt16 maxValue; SInt16 procID; WindowRef frontNonFloating; r.left = r.top = 0; r.right = r.bottom = 1; minValue = MIN_SCROLLBAR_VALUE; maxValue = MAX_SCROLLBAR_VALUE; initialValue = (minValue + maxValue)/2; procID = kControlScrollBarLiveProc; windowRef = GetWindowFromPort(destPort); CreateScrollBarControl(windowRef, &r, initialValue, minValue, maxValue, maxValue - minValue, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); /* * If we are foremost then make us active. */ frontNonFloating = FrontNonFloatingWindow(); if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Adjust the control size based on its width... */ if (macScrollPtr->info.width < 13) { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeSmall); } else { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeLarge); } /* * Update the control values before we draw. */ windowRef = GetControlOwner (macScrollPtr->sbHandle); UpdateControlValues(macScrollPtr); if (macScrollPtr->macFlags & ACTIVE) { Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); } } else { HiliteControl (macScrollPtr->sbHandle, 255 ); Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } } SetGWorld(saveWorld, saveDevice); done: scrollPtr->flags &= ~REDRAW_PENDING; }