コード例 #1
0
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, ComponentDescription inCompDesc ) :
	XWindow(owner, nibRef, name),
	mEditUnit(editUnit)
{
	Component editComp = FindNextComponent(NULL, &inCompDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	ControlRef customControl = 0;

	ControlID controlID;
	controlID.signature    	= 'cust';
    controlID.id        	= 1000;
    GetControlByID( mWindow, &controlID, &customControl );

	ControlRef ourControl = customControl ? customControl : rootControl;

	Rect r = {0,0,400,400};
	ControlRef viewPane;
	if(customControl) GetControlBounds(ourControl, &r);

	Float32Point location = { r.left, r.top };
	Float32Point size = { Float32(r.right - r.left ), Float32(r.bottom - r.top ) };
	
	
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, ourControl, &location, &size, &viewPane));

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left; size.y = r.bottom-r.top;
	if(!customControl) SetSize(size);
	Show();	
}
コード例 #2
0
void AUEditWindow::SetUnitToDisplay (AudioUnit editUnit, ComponentDescription& inDesc)
{
	CloseView();
	
	mEditUnit = editUnit;

	Component editComp = FindNextComponent(NULL, &inDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	Rect r;
	ControlRef viewPane;
	GetControlBounds(rootControl, &r);
	Float32Point location = { kOffsetForAUView_X, kOffsetForAUView_Y };
	Float32Point size = { Float32(r.right), Float32(r.bottom) };
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane));
	
	AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this);

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left + kOffsetForAUView_X; size.y = r.bottom-r.top + kOffsetForAUView_Y;
	
	Rect r2;
	GetControlBounds (mResizeableControl->MacControl(), &r2);
	
	if ((r.bottom - r.top) < (r2.bottom - r2.top + 20))
		size.y = r2.bottom + 20;
		
	SetSize(size);	
}
コード例 #3
0
ファイル: AUEditWindow.cpp プロジェクト: arnelh/Examples
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, bool forceGeneric) :
	XWindow(owner, nibRef, name),
	mEditUnit(editUnit)
{
	OSStatus err;
	ComponentDescription editorComponentDesc;
	
	// set up to use generic UI component
	editorComponentDesc.componentType = kAudioUnitCarbonViewComponentType;
	editorComponentDesc.componentSubType = 'gnrc';
	editorComponentDesc.componentManufacturer = 'appl';
	editorComponentDesc.componentFlags = 0;
	editorComponentDesc.componentFlagsMask = 0;
	
	if (!forceGeneric) {
		// ask the AU for its first editor component
		UInt32 propertySize;
		err = AudioUnitGetPropertyInfo(editUnit, kAudioUnitProperty_GetUIComponentList,
			kAudioUnitScope_Global, 0, &propertySize, NULL);
		if (!err) {
			int nEditors = propertySize / sizeof(ComponentDescription);
			ComponentDescription *editors = new ComponentDescription[nEditors];
			err = AudioUnitGetProperty(editUnit, kAudioUnitProperty_GetUIComponentList,
				kAudioUnitScope_Global, 0, editors, &propertySize);
			if (!err)
				// just pick the first one for now
				editorComponentDesc = editors[0];
			delete[] editors;
		}
	}
	Component editComp = FindNextComponent(NULL, &editorComponentDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	Rect r;
	ControlRef viewPane;
	GetControlBounds(rootControl, &r);
	Float32Point location = { 0., 0. };
	Float32Point size = { Float32(r.right), Float32(r.bottom) };
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane));
	
	AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this);

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left; size.y = r.bottom-r.top;
	SetSize(size);
	Show();

/*	EventLoopTimerRef timer;
	RequireNoErr(
		InstallEventLoopTimer(
			GetMainEventLoop(), 5., 0., TimerProc, this, &timer));*/
}
コード例 #4
0
void wxToolBarTool::SetPosition(const wxPoint& position)
{
    m_x = position.x;
    m_y = position.y;

    int x , y ;
    x = y = 0 ;
    int mac_x = position.x ;
    int mac_y = position.y ;

    if ( ! GetToolBar()->MacGetTopLevelWindow()->MacUsesCompositing() )
    {
        GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
        mac_x += x;
        mac_y += y;
    }

    if ( IsButton() )
    {
        Rect contrlRect ;       
        GetControlBounds( m_controlHandle , &contrlRect ) ; 
        int former_mac_x = contrlRect.left ;
        int former_mac_y = contrlRect.top ;
        GetToolBar()->GetToolSize() ;
        
        if ( mac_x != former_mac_x || mac_y != former_mac_y )
        {
            UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
        }
    }
    else if ( IsControl() )
    {
        GetControl()->Move( position ) ;
    }
    else
    {
        // separator 
#ifdef __WXMAC_OSX__
        Rect contrlRect ;       
        GetControlBounds( m_controlHandle , &contrlRect ) ; 
        int former_mac_x = contrlRect.left ;
        int former_mac_y = contrlRect.top ;
        
        if ( mac_x != former_mac_x || mac_y != former_mac_y )
        {
            UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
        }
#endif
    }
}
コード例 #5
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static ControlPartCode MyUserPaneHitTestProc(ControlRef control, Point where)
{
	Rect bounds;
	GetControlBounds(control, &bounds);
	ControlPartCode partCode = (PtInRect(where, &bounds))?kControlButtonPart:kControlNoPart;
	return partCode;
}
コード例 #6
0
void TActiveScroller::AdjustToControlSize()
{
	// Recalculate the track rect
	#if TARGET_API_MAC_CARBON==1	
		GetControlBounds(scrollBar,&trackRect);
	#else
		trackRect=(**scrollBar).contrlRect;	
	#endif
	
	// How we set up the values for the tracking bar size and pin location
	// is determined by whether we are tracking a horizontal or vertical
	// scroll bar.  In either case, we calcualte the scroll bar rect
	// without the scroll arrows.  We then enlarge that rect for the drag
	// slop area.
	if (IsScrollBarVertical())
	{
		barLength=FRectHeight(trackRect)-(kWidthOfScrollArrow*2);
		barZeroPosition=trackRect.top+kWidthOfScrollArrow;
		
		FInsetRect(trackRect,-kThumbTrackWidthSlop,-kThumbTrackLengthSlop);
	}
	else
	{
		barLength=FRectWidth(trackRect)-(kWidthOfScrollArrow * 2);
		barZeroPosition=trackRect.left+kWidthOfScrollArrow;
		
		FInsetRect(trackRect,-kThumbTrackLengthSlop,-kThumbTrackWidthSlop);
	}
}
コード例 #7
0
void PreviewDrawer(ControlRef Ctrl, void *Data)
{
	// Don't need the data arg here
	CrosshairData &Crosshairs = GetCrosshairData();	// An alias for the global crosshair data
	
	// No need for the window context -- it's assumed
	Rect Bounds = {0,0,0,0};
	
	GetControlBounds(Ctrl, &Bounds);
	
	// Get ready to draw!
	PenNormal();
	
	// Draw the background
	RGBForeColor(&BkgdColor);
	PaintRect(&Bounds);
	
	// Clip to inside of box
	ClipRect(&Bounds);
	
	// Draw the crosshairs
	Crosshairs_Render(Bounds);
	
	// Draw the boundary line
	ForeColor(blackColor);
	FrameRect(&Bounds);
}
コード例 #8
0
 void OSXCarbonWindow::createWindowFromExternal(HIViewRef viewRef)
 {
     // TODO: The Control is going to report the incorrect location with a
     // Metallic / Textured window.  The default windows work just fine.
     
     // First get the HIViewRef / ControlRef
     mView = viewRef;
     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;
 }
コード例 #9
0
ファイル: soundopt.cpp プロジェクト: amuramatsu/np2-mod
static pascal OSStatus s86proc(EventHandlerCallRef myHandler, EventRef event, void* userData) {
    OSStatus	err = eventNotHandledErr;
	HIPoint		pos;
	Point		p;
	Rect		ctrlbounds, winbounds;
	PicHandle   pict;

    if (GetEventClass(event)==kEventClassControl && GetEventKind(event)==kEventControlClick ) {
		err = noErr;
        GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pos);
		GetControlBounds((ControlRef)userData, &ctrlbounds);
		GetWindowBounds(soundWin, kWindowContentRgn, &winbounds);
		p.h = (short)pos.x;
		p.h -= (ctrlbounds.left + winbounds.left);
		p.h /= 8;
		if ((p.h < 2) || (p.h >= 10)) {
			return(err);
		}
		p.h -= 2;
		snd86 ^= (1 << p.h);
		set86s();
		setbmp(dipswbmp_getsnd86(snd86), &pict);
		SetControlData((ControlRef)userData, kControlNoPart, kControlPictureHandleTag, sizeof(PicHandle), &pict);
		Draw1Control((ControlRef)userData);
	}

	(void)myHandler;
	(void)userData;
    return err;
}
コード例 #10
0
OSStatus
MySimpleNotificationCallback(ControlRef browser, DataBrowserItemID item, DataBrowserItemNotification message)
{
    UInt32 numItems;
    Rect browserBounds;
    SInt16 height;
    OSStatus err = noErr;
        
    switch (message)
    {	
        case kDataBrowserItemAdded:
            if (item <= kMaxNeighborhoods)
            {
                gNeighborhoodInfo.isNeighborhoodVisible[item - 1] = true;
            }
            break;
        case kDataBrowserItemRemoved:
            if (item <= kMaxNeighborhoods)
            {
                gNeighborhoodInfo.isNeighborhoodVisible[item - 1] = false;
            }
            break;
        case kDataBrowserContainerOpened:
            gNeighborhoodInfo.isNeighborhoodOpen[item - 1] = true;
            DoNeighborhoodLookup(item);
            DoServicesLookup(item);
            break;
        case kDataBrowserContainerClosing:
            gNeighborhoodInfo.isNeighborhoodOpen[item - 1] = false;
            CancelServicesLookup(item);
            CancelNeighborhoodLookup(item);
            break;
        case kDataBrowserContainerClosed:
            RemoveServicesFromNeighborhood(item, false);
            if (gNeighborhoodInfo.isDefaultNeighborhood[item - 1] == true)
            {
                SetDataBrowserScrollPosition(gDataBrowserControl, 0 , 0);
            }
            else
            {
                err = GetDataBrowserItemCount(gDataBrowserControl, 0, true, kDataBrowserItemAnyState, &numItems);
                if (err == noErr)
                {
                    GetControlBounds(gDataBrowserControl, &browserBounds);
                    height = browserBounds.bottom - browserBounds.top;
                    if (numItems < (height/kDataBrowserRowHeight)) SetDataBrowserScrollPosition(gDataBrowserControl, 0 , 0);
                }
            }
            break;
        case kDataBrowserItemSelected:
            gSelectedItem = item;
            break;
        case kDataBrowserItemDeselected:
            if (gSelectedItem == item) gSelectedItem = kDataBrowserNoItem;
            break;
    }
    
    return noErr;
}
コード例 #11
0
	void OpenGroup(const char* text)
	{
		if (text != NULL) {
			BBox* box = new BBox(GetControlBounds(), text);
			box->SetLabel(text);
			GetView()->AddChild(box);
			Push(box);
			box->ResizeTo(box->Bounds().Width(), kBoxHeight);
		}
	}
コード例 #12
0
void TActiveScroller::SetScrollBarValue(short value)
{
	#if TARGET_API_MAC_CARBON==1
		Rect		rect;	
		GetControlBounds(scrollBar,&rect);
		UClipSaver		safe(rect);
	#else
		UClipSaver		safe((**scrollBar).contrlRect);	
	#endif
	
	SetControlValue(scrollBar,value);
}
コード例 #13
0
Boolean TActiveScroller::IsScrollBarVertical()
{
	Rect		rect;

	#if TARGET_API_MAC_CARBON==1	
		GetControlBounds(scrollBar,&rect);
	#else
		rect=(**scrollBar).contrlRect;
	#endif
	
	return (FRectHeight(rect)>FRectWidth(rect));
}
コード例 #14
0
ファイル: listbox.cpp プロジェクト: Bluehorn/wxPython
void  wxListBox::DoSetSize(int x, int y,
            int width, int height,
            int sizeFlags )
{
    wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
#if TARGET_CARBON
    Rect bounds ;
    GetControlBounds( (ControlHandle) m_macControl , &bounds ) ;
    ControlRef control = GetListVerticalScrollBar( (ListHandle)m_macList ) ;
    if ( control )
    {
        Rect scrollbounds ;
        GetControlBounds( control , &scrollbounds ) ;
        if( scrollbounds.right != bounds.right + 1 )
        {
            UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
                scrollbounds.top ) ;
        }
    }
#endif
}
コード例 #15
0
	void AddUIGroup(const char* text, Statement* statement)
	{
		if (statement->GetChildren() == NULL) return;
		DetailsBuilder builder(fParent, GetView(), GetControlBounds(), statement, fSettings);
		builder.Visit(statement->GetChildren());
		
		if (IsTop()) {
			fBounds.OffsetTo(fBounds.left, builder.GetBounds().top);
		} else {
			BView* box = GetView();
			box->ResizeTo(box->Bounds().Width(), builder.GetBounds().top + kBoxBottomMargin);
		}
	}
コード例 #16
0
ファイル: tkMacOSXButton.c プロジェクト: AsvAgent/ASV
void
UserPaneDraw(
    ControlRef control,
    ControlPartCode cpc)
{
    MacButton *mbPtr = (MacButton *)(intptr_t)GetControlReference(control);
    Rect contrlRect;
    CGrafPtr port;
    
    GetPort(&port);
    GetControlBounds(control,&contrlRect);
    TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port);
    EraseRect(&contrlRect);
}
コード例 #17
0
ファイル: PlayerWin.cpp プロジェクト: ullerrm/frogg
static OSStatus playerEvtHandler(EventHandlerCallRef nextHdlr, EventRef thisEvt, void *pvUserData)
{
    ControlRef cRef;
    ControlID cID;
    OSStatus iErr;

    UInt32 iSize, iPos;
    HIPoint pMouse;
    Rect rDims;
    int iPct;
    
    if ( (kEventClassWindow == GetEventClass(thisEvt)) &&
         (kEventWindowClose == GetEventKind(thisEvt)) )
    {
        HideWindow(g_refPlayerWin);
        g_bVisible = false;
        return noErr;
    }
    else if ( (kEventClassControl == GetEventClass(thisEvt)) &&
              (kEventControlClick == GetEventKind(thisEvt)) )
    {
        if (noErr != (iErr = GetEventParameter(thisEvt, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(Point), NULL, &pMouse)))
        {
            fprintf(stderr, "playerEvtHandler() - GetEventParameter(HitTest) failed, returning %lu!\n", (unsigned long) iErr);
        }

        cID.signature = FOUR_CHAR_CODE('fpos');
        cID.id = 7;
        if (noErr == (iErr = GetControlByID(g_refPlayerWin, &cID, &cRef)))
        {
            GetControlBounds(cRef, &rDims);
            iSize = rDims.right - rDims.left;
            iPos = (UInt32) pMouse.x - rDims.left;
            iPct = (int) (100.0 * ((double) iPos) / ((double) iSize));
        }
        else
        {
            fprintf(stderr, "playerEvtHandler() - GetControlByID() failed, returning %lu!\n", (unsigned long) iErr);
        }
        
        attemptSeekTo(iPct);
        
        return CallNextEventHandler(nextHdlr, thisEvt);        
    }
    else
    {
        return CallNextEventHandler(nextHdlr, thisEvt);
    }
}
コード例 #18
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static void MyUserPaneDrawProc(ControlRef control, SInt16 part)
{
	// we now use a User Pane Control instead of a dialog user item
	// the draw, hit test, and track are more separated
	Rect bounds;
	GetControlBounds(control, &bounds);
	
	PenSize(3, 3);
	if (!IsControlActive(control))
	{
		RGBColor gray = {32767, 32767, 32767};
		RGBForeColor(&gray);
	}
	FrameRect(&bounds);
	Rect userRect = {gUserV-4, gUserH-4, gUserV+4, gUserH+4};
	PaintRect(&userRect);
}
コード例 #19
0
void GraphInteraction::updateProjectedMouse(float x, float y)
{
  ViewLayer& view = _stateLayer->getViewLayer();
  WindowRef window = view.getWindow();

  Rect portRect;
  GetWindowBounds(window, kWindowContentRgn, &portRect);

  Rect bounds;
  GetControlBounds(view.getRenderPane(), &bounds);

  renderer::Space& space = view.getSpace();

  // Note the inversion of the y-ordinate according to OpenGL's basis
  space.setMousePosition(x - portRect.left - bounds.left,
			 portRect.top + bounds.bottom - y);

  space.display();
}
コード例 #20
0
ファイル: listbox.cpp プロジェクト: 0ryuO/dolphin-avsync
void wxMacDataBrowserListControl::ListScrollTo( unsigned int n )
{
    UInt32 top , left ;
    GetScrollPosition( &top , &left ) ;
    wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );

    // there is a bug in RevealItem that leads to situations
    // in large lists, where the item does not get scrolled
    // into sight, so we do a pre-scroll if necessary
    UInt16 height ;
    GetRowHeight( (DataBrowserItemID) item , &height ) ;
    UInt32 linetop = n * ((UInt32) height );
    UInt32 linebottom = linetop + height;
    Rect rect ;
    GetControlBounds( m_controlRef, &rect );

    if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) )
        SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ;

    RevealItem( item , kDataBrowserRevealWithoutSelecting );
}
コード例 #21
0
static void HandleAdjustRect(NavCBRecPtr callBackParms, CustomData * data)
{
   Rect rect;
   
   if (!data->userpane)
   {
      return;
   }
   
   GetControlBounds(data->userpane, &rect);
   
   SInt16 w = rect.right - rect.left;
   SInt16 h = rect.bottom - rect.top;
   SInt16 cw = callBackParms->customRect.right - callBackParms->customRect.left;
   SInt16 ch = callBackParms->customRect.bottom - callBackParms->customRect.top;
   
   MoveControl(data->userpane,
               callBackParms->customRect.left + ((cw-w) / 2),
               callBackParms->customRect.top + ((ch-h) / 2));
   
   return;
}
コード例 #22
0
ファイル: control.cpp プロジェクト: Duion/Torsion
void wxControl::MacUpdateDimensions() 
{
    // actually in the current systems this should never be possible, but later reparenting
    // may become a reality
    
    if ( (ControlHandle) m_macControl == NULL )
        return ;
        
    if ( GetParent() == NULL )
        return ;
        
    WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
    if ( rootwindow == NULL )
        return ;
        
    Rect oldBounds ;       
    GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; 
    
    int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
    int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
    int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
    int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
    
    GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
    bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
    bool doResize =  ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
    if ( doMove || doResize )
    {
        InvalWindowRect( rootwindow, &oldBounds ) ;
        if ( doMove )
        {
            UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
        }
        if ( doResize )
        {
            UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
        }
    }
}
コード例 #23
0
ファイル: AUCarbonViewControl.cpp プロジェクト: kdridi/acau
Boolean	AUCarbonViewControl::SizeControlToFit(ControlRef inControl, SInt16 *outWidth, SInt16 *outHeight)
{
#if !__LP64__
	if (inControl == 0) return false;
	
	Boolean bValue = false;
	// this only works on text controls -- returns an error for other controls, but doesn't do anything,
	// so the error is irrelevant
	SetControlData(inControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
	
	SInt16 baseLineOffset;
	Rect bestRect;
	OSErr err = GetBestControlRect(inControl, &bestRect, &baseLineOffset);  
	if (err != noErr) return false;
	
	int width = (bestRect.right - bestRect.left) + 1;
	int height = (bestRect.bottom - bestRect.top) + 1;
	
	Rect boundsRect;
	GetControlBounds (inControl, &boundsRect);
	
	Rect newRect;
	newRect.top = boundsRect.top;
	newRect.bottom = newRect.top + height;
	newRect.left = boundsRect.left;
	newRect.right = newRect.left + width;
	
	SetControlBounds (inControl, &newRect);
	
	if (outWidth)
		*outWidth = width;
	
	if (outHeight)
		*outHeight = height;
#endif	
	return true;
}
コード例 #24
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static void MoveSpotActionProc(ControlRef theControl, ControlPartCode partCode)
{
	Rect bounds;
	GetControlBounds(theControl, &bounds);
	Point thePoint;
	if (partCode == kControlButtonPart)
	{
		GetMouse(&thePoint);
		gUserH = thePoint.h;
		gUserV = thePoint.v;
		if (gUserH < bounds.left+4) gUserH = bounds.left+4;
		if (gUserH > bounds.right-4) gUserH = bounds.right-4;
		if (gUserV < bounds.top+4) gUserV = bounds.top+4;
		if (gUserV > bounds.bottom-4) gUserV = bounds.bottom-4;
		
		// the erasing/drawing management is very complex to do properly
		// unless we just Hide and Show. This technique is OK if the control
		// is not too big on the screen and the machine is fast enough to
		// prevent flicker. If not then a better tracking would require
		// clipping management and calling the User Pane Draw Proc.
		HideControl(theControl);
		ShowControl(theControl);
	}
}
コード例 #25
0
ファイル: control.cpp プロジェクト: Duion/Torsion
void  wxControl::DoSetSize(int x, int y,
            int width, int height,
            int sizeFlags )
{
    wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
#if 0
    {
        Rect meta , control ;
        GetControlBounds( (ControlHandle) m_macControl , &control ) ;
        RgnHandle rgn = NewRgn() ;
        GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ;
        GetRegionBounds( rgn , &meta ) ;
        if ( !EmptyRect( &meta ) )
        {
            wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ;
            wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ;
            wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ;
            wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ;
        }
        DisposeRgn( rgn ) ;
    }
#endif
    return ;
}
コード例 #26
0
OSErr SetupPickMonitorPane(ControlRef inPane, DisplayIDType inDefaultMonitor)
{
	GDHandle dev = GetDeviceList();
	OSErr err = noErr;
	
	// make the default monitor the selected device
	if (inDefaultMonitor)
		DMGetGDeviceByDisplayID(inDefaultMonitor, &sSelectedDevice, true);
	else
		sSelectedDevice = GetMainDevice();

	// build the list of monitors
	sNumMonitors = 0;
	while (dev && sNumMonitors < kMaxMonitors)
	{
		if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive))
		{
			sMonitors[sNumMonitors].device = dev;
			sMonitors[sNumMonitors].origRect = (**dev).gdRect;
			sMonitors[sNumMonitors].isMain = (dev == GetMainDevice());
			sNumMonitors++;
		}
		dev = GetNextDevice(dev);
	}

	// calculate scaled rects
	if (sNumMonitors)
	{
		Rect origPaneRect, paneRect;
		Rect origGrayRect, grayRect, scaledGrayRect;
		float srcAspect, dstAspect, scale;
		int i;
		
		GetControlBounds(inPane, &origPaneRect);
		paneRect = origPaneRect;
		OffsetRect(&paneRect, -paneRect.left, -paneRect.top);
		
		GetRegionBounds(GetGrayRgn(), &origGrayRect);
		grayRect = origGrayRect;
		OffsetRect(&grayRect, -grayRect.left, -grayRect.top);
		
		srcAspect = (float)grayRect.right / (float)grayRect.bottom;
		dstAspect = (float)paneRect.right / (float)paneRect.bottom;
		
		scaledGrayRect = paneRect;
		
		if (srcAspect < dstAspect)
		{
			scaledGrayRect.right = (float)paneRect.bottom * srcAspect;
			scale = (float)scaledGrayRect.right / grayRect.right;
		}
		else
		{
			scaledGrayRect.bottom = (float)paneRect.right / srcAspect;
			scale = (float)scaledGrayRect.bottom / grayRect.bottom;
		}
		
		for (i = 0; i < sNumMonitors; i++)
		{
			Rect r = sMonitors[i].origRect;
			Rect r2 = r;
			
			// normalize rect and scale
			OffsetRect(&r, -r.left, -r.top);
			r.bottom = (float)r.bottom * scale;
			r.right = (float)r.right * scale;
			
			// offset rect wrt gray region
			OffsetRect(&r, (float)(r2.left - origGrayRect.left) * scale, 
							(float)(r2.top - origGrayRect.top) * scale);

			sMonitors[i].scaledRect = r;
		}
		
		// center scaledGrayRect in the pane
		OffsetRect(&scaledGrayRect, (paneRect.right - scaledGrayRect.right) / 2,
					(paneRect.bottom - scaledGrayRect.bottom) / 2);

		// offset monitors to match
		for (i = 0; i < sNumMonitors; i++)
			OffsetRect(&sMonitors[i].scaledRect, scaledGrayRect.left, scaledGrayRect.top);
	}
	else
		return paramErr;
		
	// setup the procs for the pick monitor user pane
	err = SetupUserPaneProcs(inPane, drawProc, hitTestProc, trackingProc);
	return err;
}
コード例 #27
0
//-------------------------------------------------------------------------------------------------//
void OSXCarbonWindow::create( const String& name, unsigned int width, unsigned int height,
	            bool fullScreen, const NameValuePairList *miscParams )
{
	bool hasDepthBuffer;
	String title = name;
	size_t fsaa_samples = 0;
	int left = 0;
	int top = 0;
	int depth = 32;
	
	if( miscParams )
	{
		
		NameValuePairList::const_iterator opt = NULL;
		
		// Full screen anti aliasing
		opt = miscParams->find( "FSAA" );
		if( opt != miscParams->end() )
			fsaa_samples = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "left" );
		if( opt != miscParams->end() )
			left = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "top" );
		if( opt != miscParams->end() )
			top = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "title" );
		if( opt != miscParams->end() )
			title = opt->second;

		opt = miscParams->find( "depthBuffer" );
		if( opt != miscParams->end() )
			hasDepthBuffer = StringConverter::parseBool( opt->second );
		
		opt = miscParams->find( "colourDepth" );
		if( opt != miscParams->end() )
			depth = StringConverter::parseUnsignedInt( opt->second );
	}
	
	if(fullScreen)
	{
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		OSXContext *mainContext = (OSXContext*)rs->_getMainContext();
		
		CGLContextObj share = NULL;
		if(mainContext == 0)
		{
			share = NULL;
		}
		else if(mainContext->getContextType() == "AGL")
		{
			OSXCarbonContext* aglShare = static_cast<OSXCarbonContext*>(mainContext);
			aglGetCGLContext(aglShare->getContext(), &((void*)share));
		}
		else if(mainContext->getContextType() == "CGL")
		{
			OSXCGLContext* cglShare = static_cast<OSXCGLContext*>(mainContext);
			share = cglShare->getContext();
		}
		
		// create the context
		createCGLFullscreen(width, height, depth, fsaa_samples, share);		
	}
	else
	{
		int i = 0;
		AGLPixelFormat pixelFormat;
		GLint attribs[ 20 ];
		
		attribs[ i++ ] = AGL_NO_RECOVERY;
		attribs[ i++ ] = GL_TRUE;
		attribs[ i++ ] = AGL_ACCELERATED;
		attribs[ i++ ] = GL_TRUE;
		attribs[ i++ ] = AGL_RGBA;
		attribs[ i++ ] = AGL_DOUBLEBUFFER;
		attribs[ i++ ] = AGL_ALPHA_SIZE;
		attribs[ i++ ] = 8;
		attribs[ i++ ] = AGL_STENCIL_SIZE;
		attribs[ i++ ] = 8;
		attribs[ i++ ] = AGL_DEPTH_SIZE;
		attribs[ i++ ] = depth;
	
		if(fsaa_samples > 1)
		{
			attribs[ i++ ] = AGL_MULTISAMPLE;
			attribs[ i++ ] = 1;
			attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB;
			attribs[ i++ ] = fsaa_samples;
		}
	
		attribs[ i++ ] = AGL_NONE;
	
		pixelFormat = aglChoosePixelFormat( NULL, 0, attribs );
	
		// Create the AGLContext from our pixel format
		// Share it with main
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		OSXContext* mainContext = static_cast<OSXContext*>( rs->_getMainContext() );
		if(mainContext == 0)
		{
			mAGLContext = aglCreateContext(pixelFormat, NULL);
		}
		else if(mainContext->getContextType() == "AGL")
		{
			OSXCarbonContext* context = static_cast<OSXCarbonContext*>( rs->_getMainContext() );
			AGLContext shared = context->getContext();
			mAGLContext = aglCreateContext(pixelFormat, context->getContext());
		}
		else
		{
			// If we do not have an AGL, we can not clone it using this window
			LogManager::getSingleton().logMessage( "Warning: You asked to create a second window, "
				"when the previous window was not of this type.  OgreOSXCarbonWindow can only share "
				"with an AGL context.");
		}
		
		NameValuePairList::const_iterator opt = 0;
		if(miscParams)
			opt = miscParams->find("externalWindowHandle");
		if(!miscParams || opt == miscParams->end())
		{
			// create the window rect in global coords
			::Rect windowRect;
			windowRect.left = 0;
			windowRect.top = 0;
			windowRect.right = width;
			windowRect.bottom = height;
			
			// set the default attributes for the window
			WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize"
			
			if (miscParams)
			{
				opt = miscParams->find("border");
				if( opt != miscParams->end() )
				{
					String borderType = opt->second;
					if( borderType == "none" )
						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;
}
コード例 #28
0
OSStatus			AUCarbonViewBase::CreateCarbonView(AudioUnit inAudioUnit, WindowRef inWindow, ControlRef inParentControl, const Float32Point &inLocation, const Float32Point &inSize, ControlRef &outParentControl)
{
#if !__LP64__
	mEditAudioUnit = inAudioUnit;
	mCarbonWindow = inWindow;

	WindowAttributes attributes;
	verify_noerr(GetWindowAttributes(mCarbonWindow, &attributes));
	mCompositWindow = (attributes & kWindowCompositingAttribute) != 0;

	Rect area;
	area.left = short(inLocation.x); area.top = short(inLocation.y);
	area.right = short(area.left + inSize.x); area.bottom = short(area.top + inSize.y);
	OSStatus err = ::CreateUserPaneControl(inWindow, &area, 
						kControlSupportsEmbedding,
						&mCarbonPane);	// subclass can resize mCarbonPane to taste
	verify_noerr(err);
	if (err) return err;
	outParentControl = mCarbonPane;
	
	// register for mouse-down in our pane -- we want to clear focus
	EventTypeSpec paneEvents[] = {
		{ kEventClassControl, kEventControlClick }
	};
	WantEventTypes(GetControlEventTarget(mCarbonPane), GetEventTypeCount(paneEvents), paneEvents);
	
	if (IsCompositWindow()) {
		verify_noerr(::HIViewAddSubview(inParentControl, mCarbonPane));
		mXOffset = 0;
		mYOffset = 0;
	}
	else {
		verify_noerr(::EmbedControl(mCarbonPane, inParentControl));
		mXOffset = inLocation.x;
		mYOffset = inLocation.y;
	}
	mBottomRight.h = mBottomRight.v = 0;
	
	SizeControl(mCarbonPane, 0, 0);
	if (err = CreateUI(mXOffset, mYOffset))
		return err;

	// we should only resize the control if a subclass has embedded
	// controls in this AND this is done with the EmbedControl call below
	// if mBottomRight is STILL equal to zero, then that wasn't done
	// so don't size the control
	Rect paneBounds;
	GetControlBounds(mCarbonPane, &paneBounds);
	// only resize mCarbonPane if it has not already been resized during CreateUI
	if ((paneBounds.top == paneBounds.bottom) && (paneBounds.left == paneBounds.right)) {
		if (mBottomRight.h != 0 && mBottomRight.v != 0)
			SizeControl(mCarbonPane, (short) (mBottomRight.h - mXOffset), (short) (mBottomRight.v - mYOffset));
	}

	if (IsCompositWindow()) {
		// prepare for handling scroll-events
		EventTypeSpec scrollEvents[] = {
			{ kEventClassScrollable, kEventScrollableGetInfo },
			{ kEventClassScrollable, kEventScrollableScrollTo }
		};
		
		WantEventTypes(GetControlEventTarget(mCarbonPane), GetEventTypeCount(scrollEvents), scrollEvents);
	
		mCurrentScrollPoint.x = mCurrentScrollPoint.y = 0.0f;
	}
	
	return err;
#else
	return noErr;
#endif
}
コード例 #29
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static DialogRef DrawDialogTheMacOS8or9Way(void)
{
	short		i;
	ControlRef theControl;
	
	DialogRef theDialog = GetNewDialog(257, NULL, (WindowRef)-1L);
	if (theDialog == NULL) return(NULL);
	
	// Let's get a pulsing blue default button!
	GetDialogItemAsControl(theDialog, 1, &theControl);
	SetWindowDefaultButton(GetDialogWindow(theDialog), theControl);
	
	// Setting the check box
	GetDialogItemAsControl(theDialog, 2, &theControl);
	SetControl32BitValue(theControl, 1);
	
	// We need to autoembed our radio buttons in the radio group
	// so that they work automatically
	for (i = 4; i <= 8; i++)
	{
		GetDialogItemAsControl(theDialog, i, &theControl);
		AutoEmbedControl(theControl, GetDialogWindow(theDialog));
	}
	
	// we assign a key filter on our edit text box so that only digits can be entered
	ControlRef theTextControl;
	ControlKeyFilterUPP keyFilter = MyEditKeyFilter;
	GetDialogItemAsControl(theDialog, 9, &theTextControl);
	SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart);
	SetControlData(theTextControl, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter);
	
	// Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work
	// We also associate the previous edit text box with the scroll bar so it gets updated
	GetDialogItemAsControl(theDialog, 14, &theControl);
	SetControlAction(theControl, ScrollBar32BitActionProc);
	SetControl32BitMaximum(theControl, 0x7fffffff);
	SetControlReference(theControl, (SInt32)theTextControl);
	
	// The static text control is created as a resource but we could only set its title and
	// not its content. We set the content now!
	GetDialogItemAsControl(theDialog, 15, &theControl);
	Str255 theTitle;
	GetControlTitle(theControl, theTitle);
	SetControlData(theControl, kControlEntireControl, kControlStaticTextTextTag, theTitle[0], &theTitle[1]);
	
	// We set up our User Pane Control with the draw, hit test, and track (actually action) procs
	GetDialogItemAsControl(theDialog, 13, &theControl);
	Rect bounds;
	GetControlBounds(theControl, &bounds);
	gUserH = (bounds.left + bounds.right) / 2;
	gUserV = (bounds.top + bounds.bottom) / 2;	
	ControlUserPaneDrawUPP userPaneDraw = MyUserPaneDrawProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(userPaneDraw), &userPaneDraw);
	ControlUserPaneHitTestUPP userPaneHitTest = MyUserPaneHitTestProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(userPaneHitTest), &userPaneHitTest);
	SetControlAction(theControl, MoveSpotActionProc);
	
	ShowWindow(GetDialogWindow(theDialog));
	
	return(theDialog);
}
コード例 #30
0
OSStatus
InitDataBrowserControl()
{
    DataBrowserCallbacks 	myCallbacks;
    ControlID 			controlID = { kNSLSample, kUserPaneControl };
    ControlRef			control;
    Rect			outRect;
    OSStatus			err;
    int				i;

    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        GetControlBounds(control, &outRect);
        DisposeControl(control);
    }
    else
    {
        return err;
    }
    
    if (gDataBrowserControl == NULL)
    {
        err = CreateDataBrowserControl(gMainWindow, &outRect, kDataBrowserListView, &gDataBrowserControl);
        if (err == noErr)
        {
            AdvanceKeyboardFocus(gMainWindow);
            SetDataBrowserHasScrollBars(gDataBrowserControl, false, true);
            SetDataBrowserTableViewRowHeight(gDataBrowserControl, kDataBrowserRowHeight);
            SetDataBrowserSortOrder(gDataBrowserControl, kDataBrowserOrderIncreasing);
            SetDataBrowserSelectionFlags(gDataBrowserControl, kDataBrowserSelectOnlyOne);
            SetDataBrowserListViewUsePlainBackground(gDataBrowserControl, false);
    
            myCallbacks.version = kDataBrowserLatestCallbacks;
            InitDataBrowserCallbacks(&myCallbacks);
    
        #if USE_OLD_DATA_BROWSER_STRUCTS    
            myCallbacks.u.v1.clientDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.compareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #else
            myCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #endif
            
            myCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP((DataBrowserItemNotificationProcPtr)MySimpleNotificationCallback);

            err = SetDataBrowserCallbacks(gDataBrowserControl, &myCallbacks);
            if (err != noErr) return err;
        }
        else
        {
            return err;
        }
    }
    
    err = AddNameColumnToList();
    if (err == noErr)
    {        
        SetDataBrowserListViewDisclosureColumn(gDataBrowserControl, kNameColumn, false);
        SetDataBrowserSortProperty(gDataBrowserControl, kNameColumn);        
        
        for (i = 0; i < kMaxNeighborhoods; i++)
        {
            gNeighborhoodInfo.neighborhoodSize[i] = 0;
            gNeighborhoodInfo.isNeighborhoodOpen[i] = false;
            gNeighborhoodInfo.isDefaultNeighborhood[i] = false;
            gNeighborhoodInfo.isNeighborhoodVisible[i] = false;
            gLookupInfo[i + 1].sLookupActive = false;
            gLookupInfo[i + 1].nLookupActive = false;
        }
        
        gNeighborhoodInfo.neighborhoodCount = 0;
        gSelectedItem = 0;
        
        DoNeighborhoodLookup(kDefaultNeighborhoods);
    }
    
    return err;
}