Esempio n. 1
0
void wxControl::MacAdjustControlRect() 
{
    wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
    if ( m_width == -1 || m_height == -1 )
    {
        Rect    bestsize = { 0 , 0 , 0 , 0 } ;
        short   baselineoffset ;
        
        ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;

        if ( EmptyRect( &bestsize ) )
        {
            baselineoffset = 0;
            bestsize.left = bestsize.top = 0 ;
            bestsize.right = 16 ;
            bestsize.bottom = 16 ;
            if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
            {
                bestsize.bottom = 16 ;
            }
            else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
            {
                bestsize.bottom = 24 ; 
            }
        }

        if ( m_width == -1 )
        {
            if ( IsKindOf( CLASSINFO( wxButton ) ) )
            {
                m_width = m_label.Length() * 8 + 12 ;
                if ( m_width < 70 )
                  m_width = 70 ;
            }
            else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
            {
                m_width = m_label.Length() * 8 ;
            }
            else
                m_width = bestsize.right - bestsize.left ;
            
            m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
        }
        if ( m_height == -1 )
        {
            m_height = bestsize.bottom - bestsize.top ;
            if ( m_height < 10 )
                m_height = 13 ;

            m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
        }
         MacUpdateDimensions() ;      
    }
}
Esempio n. 2
0
wxSize wxStaticText::DoGetBestSize() const
{
    Point bounds;
#if wxOSX_USE_CARBON
    Rect bestsize = { 0 , 0 , 0 , 0 } ;

    // try the built-in best size if available
    Boolean former = m_peer->GetData<Boolean>( kControlStaticTextIsMultilineTag);
    m_peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
    m_peer->GetBestRect( &bestsize ) ;
    m_peer->SetData( kControlStaticTextIsMultilineTag, former );
    if ( !EmptyRect( &bestsize ) )
    {
        bounds.h = bestsize.right - bestsize.left ;
        bounds.v = bestsize.bottom - bestsize.top ;
    }
    else
#endif
    {
#if wxOSX_USE_CARBON
        ControlFontStyleRec controlFont;
        OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
        verify_noerr( err );

        wxCFStringRef str( m_label,  GetFont().GetEncoding() );

#if wxOSX_USE_ATSU_TEXT
        SInt16 baseline;
        if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
        {
            err = GetThemeTextDimensions(
                (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
                m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
            verify_noerr( err );
        }
        else
#endif
#endif
        {
            wxClientDC dc(const_cast<wxStaticText*>(this));
            wxCoord width, height ;
            dc.GetTextExtent( m_label , &width, &height);
            bounds.h = width;
            bounds.v = height;
        }

        if ( m_label.empty() )
            bounds.h = 0;
    }
    bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
    bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();

    return wxSize( bounds.h, bounds.v );
}
Esempio n. 3
0
OSErr QTDR_PlayMovieFromRAM (Movie theMovie)
{
	WindowPtr				myWindow = NULL;
	Rect					myBounds = {50, 50, 100, 100};
	Rect					myRect;
	StringPtr				myTitle = QTUtils_ConvertCToPascalString(kWindowTitle);
	OSErr					myErr = memFullErr;

	myWindow = NewCWindow(NULL, &myBounds, myTitle, false, 0, (WindowPtr)-1, false, 0);
	if (myWindow == NULL)
		goto bail;
		
	myErr = noErr;
	
	MacSetPort((GrafPtr)GetWindowPort(myWindow));

	GetMovieBox(theMovie, &myRect);
	MacOffsetRect(&myRect, -myRect.left, -myRect.top);
	SetMovieBox(theMovie, &myRect);

	if (!EmptyRect(&myRect))
		SizeWindow(myWindow, myRect.right, myRect.bottom, false);
	else
		SizeWindow(myWindow, 200, 0, false);
		
	MacShowWindow(myWindow);

	SetMovieGWorld(theMovie, GetWindowPort(myWindow), NULL);
	GoToBeginningOfMovie(theMovie);
	MoviesTask(theMovie, 0);
	StartMovie(theMovie);
	
	myErr = GetMoviesError();
	if (myErr != noErr)
		goto bail;
	
	while (!IsMovieDone(theMovie))
		MoviesTask(theMovie, 0);

bail:
	free(myTitle);
	
	if (theMovie != NULL)
		DisposeMovie(theMovie);

	if (myWindow != NULL)
		DisposeWindow(myWindow);
		
	return(myErr);
}
Esempio n. 4
0
void GetObjectScrRect (CMap *Map, ObjectRecHdl theObjectHdl, Rect *theScrRect)
{
	GrafPtr		SavePort;
	LongRect	ObjectLRect;
	OSType		thisObjectType;
	
	GetPort (&SavePort);
	
	GetObjectType (theObjectHdl, &thisObjectType);
	if (thisObjectType == kSymbolType)
	{
		LongPoint	SymbolLPoint;
		Point		SymbolScrPoint;
		Rect		LabelScrRect;

		GetObjectLPoint (theObjectHdl, &SymbolLPoint);
		Map -> GetScrPoint (&SymbolLPoint, &SymbolScrPoint);
		theScrRect -> top    = SymbolScrPoint.v - 8;
		theScrRect -> bottom = SymbolScrPoint.v + 8;
		theScrRect -> left   = SymbolScrPoint.h - 8;
		theScrRect -> right  = SymbolScrPoint.h + 8;
		
		// now add object's label rect if label is visible
		if (IsOLabelVisible (theObjectHdl))
		{
			GetObjectLabelRect (theObjectHdl, &LabelScrRect);
			if (!EmptyRect (&LabelScrRect))
				MyUnionRect (theScrRect, &LabelScrRect, theScrRect);
		}
	}
	else
	{
		GetObjectLRect (theObjectHdl, &ObjectLRect);
		Map -> GetScrRect (&ObjectLRect, theScrRect);
	}
	
	SetPort (SavePort);
	
	return;
}
Esempio n. 5
0
wxSize wxControl::DoGetBestSize() const
{
    if ( (ControlHandle) m_macControl == NULL )
        return wxWindow::DoGetBestSize() ;
        
    Rect    bestsize = { 0 , 0 , 0 , 0 } ;
    short   baselineoffset ;
    int bestWidth, bestHeight ;
    ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;

    if ( EmptyRect( &bestsize ) )
    {
        baselineoffset = 0;
        bestsize.left = bestsize.top = 0 ;
        bestsize.right = 16 ;
        bestsize.bottom = 16 ;
        if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
        {
            bestsize.bottom = 16 ;
        }
        else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
        {
            bestsize.bottom = 24 ; 
        }
    }

    bestWidth = bestsize.right - bestsize.left ;
        
    bestWidth += 2 * m_macHorizontalBorder ;

    bestHeight = bestsize.bottom - bestsize.top ;
    if ( bestHeight < 10 )
        bestHeight = 13 ;

    bestHeight += 2 * m_macVerticalBorder;

        
    return wxSize(bestWidth, bestHeight);
}
Esempio n. 6
0
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 ;
}
Esempio n. 7
0
wxSize wxButton::DoGetBestSize() const
{
    if ( GetId() == wxID_HELP )
        return wxSize( 20 , 20 ) ;

    wxSize sz = GetDefaultSize() ;

    switch (GetWindowVariant())
    {
        case wxWINDOW_VARIANT_NORMAL:
        case wxWINDOW_VARIANT_LARGE:
            sz.y = 20 ;
            break;

        case wxWINDOW_VARIANT_SMALL:
            sz.y = 17 ;
            break;

        case wxWINDOW_VARIANT_MINI:
            sz.y = 15 ;
            break;

        default:
            break;
    }

#if wxOSX_USE_CARBON
    Rect    bestsize = { 0 , 0 , 0 , 0 } ;
    m_peer->GetBestRect( &bestsize ) ;

    int wBtn;
    if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) )
    {
        Point bounds;

        ControlFontStyleRec controlFont;
        OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
        verify_noerr( err );

        // GetThemeTextDimensions will cache strings and the documentation
        // says not to use the NoCopy string creation calls.
        // This also means that we can't use CFSTR without
        // -fno-constant-cfstrings if the library might be unloaded,
        // as GetThemeTextDimensions may cache a pointer to our
        // unloaded segment.
        wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "),
                          GetFont().GetEncoding() );

#if wxOSX_USE_ATSU_TEXT
        SInt16 baseline;
        if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
        {
            err = GetThemeTextDimensions(
                (CFStringRef)str,
                m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
            verify_noerr( err );
        }
        else
#endif
        {
            wxClientDC dc(const_cast<wxButton*>(this));
            wxCoord width, height ;
            dc.GetTextExtent( m_label , &width, &height);
            bounds.h = width;
            bounds.v = height;
        }

        wBtn = bounds.h + sz.y;
    }
    else
    {
        wBtn = bestsize.right - bestsize.left ;
        // non 'normal' window variants don't return the correct height
        // sz.y = bestsize.bottom - bestsize.top ;
    }
    if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
        sz.x = wBtn;
#endif

    return sz ;
}
Esempio n. 8
0
wxSize wxStaticText::DoGetBestSize() const
{
    Point bounds;
#if wxOSX_USE_CARBON
    Rect bestsize = { 0 , 0 , 0 , 0 } ;

    // try the built-in best size if available
    Boolean former = GetPeer()->GetData<Boolean>( kControlStaticTextIsMultilineTag);
    GetPeer()->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
    GetPeer()->GetBestRect( &bestsize ) ;
    GetPeer()->SetData( kControlStaticTextIsMultilineTag, former );
    
    if ( !EmptyRect( &bestsize ) )
    {
        bounds.h = bestsize.right - bestsize.left ;
        bounds.v = bestsize.bottom - bestsize.top ;
    }
    else
#endif
    {
#if wxOSX_USE_CARBON
        ControlFontStyleRec controlFont;
        OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
        verify_noerr( err );

#if wxOSX_USE_ATSU_TEXT
        SInt16 baseline;
        if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
        {
            // GetThemeTextDimensions will cache strings and the documentation
            // says not to use the NoCopy string creation calls.
            // This also means that we can't use CFSTR without
            // -fno-constant-cfstrings if the library might be unloaded,
            // as GetThemeTextDimensions may cache a pointer to our
            // unloaded segment.
            wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "),
                              GetFont().GetEncoding() );

            err = GetThemeTextDimensions(
                (CFStringRef)str,
                m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
            verify_noerr( err );
        }
        else
#endif
#endif
        {
            wxClientDC dc(const_cast<wxStaticText*>(this));
            wxCoord width, height ;
            dc.GetTextExtent( m_label , &width, &height);
            bounds.h = width;
            bounds.v = height;
        }

        if ( m_label.empty() )
            bounds.h = 0;
    }
    bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
    bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();

    return wxSize( bounds.h, bounds.v );
}
Esempio n. 9
0
wxSize wxStaticText::DoGetBestSize() const
{
    Rect bestsize = { 0 , 0 , 0 , 0 } ;
    Point bounds;
    
    // try the built-in best size if available
    Boolean former = m_peer->GetData<Boolean>( kControlStaticTextIsMultilineTag);
    m_peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
    m_peer->GetBestRect( &bestsize ) ;
    m_peer->SetData( kControlStaticTextIsMultilineTag, former );
    if ( !EmptyRect( &bestsize ) )
    {
        bounds.h = bestsize.right - bestsize.left ;
        bounds.v = bestsize.bottom - bestsize.top ;
    }
    else
    {
        ControlFontStyleRec controlFont;
        OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
        verify_noerr( err );

        SInt16 baseline;
        wxMacCFStringHolder str( m_label,  m_font.GetEncoding() );

#ifndef __LP64__
        if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
        {
            err = GetThemeTextDimensions(
                (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
                m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
            verify_noerr( err );
        }
        else
#endif
        {
    #if wxMAC_USE_CORE_GRAPHICS
            wxClientDC dc(const_cast<wxStaticText*>(this));
            wxCoord width, height ;
            dc.GetTextExtent( m_label , &width, &height);
            bounds.h = width;
            bounds.v = height;
    #else
            wxMacWindowStateSaver sv( this );
            ::TextFont( m_font.MacGetFontNum() );
            ::TextSize( (short)(m_font.MacGetFontSize()) );
            ::TextFace( m_font.MacGetFontStyle() );

            err = GetThemeTextDimensions(
                (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
                kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline );
            verify_noerr( err );
    #endif
        }

        if ( m_label.empty() )
            bounds.h = 0;
    }
    bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
    bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();

    return wxSize( bounds.h, bounds.v );
}
Esempio n. 10
0
static int ioSetFullScreenActual(int fullScreen) {
    Rect                screen;
    int                 width, height, maxWidth, maxHeight;
    int                 oldWidth, oldHeight;
    static Rect			rememberOldLocation = {0,0,0,0};		
    GDHandle            dominantGDevice;
	windowDescriptorBlock *	targetWindowBlock  = windowBlockFromIndex(1);
	extern Boolean gSqueakBrowserWasHeadlessButMadeFullScreen;
	extern Boolean gSqueakBrowserSubProcess;

	
	if (browserActiveAndDrawingContextOk()) {
		if (!gSqueakBrowserWasHeadlessButMadeFullScreen) {
			gSqueakBrowserWasHeadlessButMadeFullScreen = true;
			SetUpMenus();
			AdjustMenus();
		}
		sqShowWindowActual(1);
		if (targetWindowBlock->context)  //Set context to NULL, if screen is same size as fullscreen we wouldn't get new context
				QDEndCGContext(GetWindowPort(targetWindowBlock->handle),&targetWindowBlock->context);
		targetWindowBlock->context = NULL;
	}

	if ((targetWindowBlock == NULL) || (fullScreen && getFullScreenFlag() && !targetWindowBlock->isInvisible))
		return 0;

	dominantGDevice = getThatDominateGDevice(targetWindowBlock->handle);
    if (dominantGDevice == null) {
        success(false);
        return 0;
    }
    screen = (**dominantGDevice).gdRect;
	        
    if (fullScreen) {
		GetPortBounds(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation);
		oldWidth =  rememberOldLocation.right -  rememberOldLocation.left;
		oldHeight =  rememberOldLocation.bottom -  rememberOldLocation.top;

		if (targetWindowBlock->isInvisible) {
			rememberOldLocation.top = 44;
			rememberOldLocation.left = 8;
		}
		QDLocalToGlobalRect(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation);
		if (gSqueakBrowserSubProcess) {
			ProcessSerialNumber psn = { 0, kCurrentProcess };
			ProcessInfoRec info;
			info.processName = NULL;
			info.processAppSpec = NULL;
			info.processInfoLength = sizeof(ProcessInfoRec);
			GetProcessInformation(&psn,&info);
			SetFrontProcess(&psn);
		}
		MenuBarHide();
		width  = screen.right - screen.left; 
		height = (screen.bottom - screen.top);
		MoveWindow(targetWindowBlock->handle, screen.left, screen.top, true);
		SizeWindow(targetWindowBlock->handle, width, height, true);
		setFullScreenFlag(true);
	} else {
		MenuBarRestore();
	
		if (gSqueakBrowserWasHeadlessButMadeFullScreen) {
			HideWindow(targetWindowBlock->handle);
			{
				ProcessSerialNumber psn;
				pid_t parent;
				OSStatus err;
				parent = getppid();
				if (parent != 1) {
					err = GetProcessForPID(parent,&psn); 
					if(err == 0) 
						SetFrontProcess(&psn);
				}
			}
		}

		if (EmptyRect(&rememberOldLocation)) {
			/* get old window size */
			width  = (unsigned) getSavedWindowSize() >> 16;
			height = getSavedWindowSize() & 0xFFFF;

			/* minimum size is 1 x 1 */
			width  = (width  > 0) ?  width : 64;
			height = (height > 0) ? height : 64;

			/* maximum size is screen size inset slightly */
			maxWidth  = (screen.right  - screen.left) - 16;
			maxHeight = (screen.bottom - screen.top)  - 52;
			width  = (width  <= maxWidth)  ?  width : maxWidth;
			height = (height <= maxHeight) ? height : maxHeight;
			MoveWindow(targetWindowBlock->handle, 8, 44, true);
			SizeWindow(targetWindowBlock->handle, width, height, true);
		} else {
Esempio n. 11
0
void
TkpDisplayScrollbar(
    ClientData clientData)	/* Information about window. */
{
    TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
    MacScrollbar *macScrollPtr = (MacScrollbar *) clientData;
    Tk_Window tkwin = scrollPtr->tkwin;
    CGrafPtr destPort, savePort;
    Boolean portChanged;
    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);

    if (macScrollPtr->sbHandle == NULL) {
	Rect r = {0, 0, 1, 1};

	windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
	CreateScrollBarControl(windowRef, &r, 0, 0, 0, 0, true, NULL,
		&(macScrollPtr->sbHandle));
	SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr);

	if (IsWindowActive(windowRef)) {
	    macScrollPtr->macFlags |= ACTIVE;
	}
    }

    /*
     * Update the control values before we draw.
     */

    UpdateControlValues(macScrollPtr);

    /*
     * Set up port for drawing Macintosh control.
     */
    destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
    portChanged = QDSwapPort(destPort, &savePort);
    TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));

    /*
     * Scrollbars do not erase the complete control bounds if they are wider
     * than the standard width, so manually erase the extra space.
     */

    if (!EmptyRect(&macScrollPtr->eraseRect)) {
	EraseRect(&macScrollPtr->eraseRect);
    }

    Draw1Control(macScrollPtr->sbHandle);

    if (portChanged) {
	QDSwapPort(savePort, NULL);
    }

    done:
    scrollPtr->flags &= ~REDRAW_PENDING;
}