Esempio n. 1
0
void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
{
    int leftMargin = 2;
    
    wxRect rect;
    GetFieldRect(i, rect);
    
    if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
    {
        dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
    }
    
    wxString text(GetStatusText(i));
    
    long x, y;
    
    dc.GetTextExtent(text, &x, &y);
    
    int xpos = rect.x + leftMargin + 1 ;
    int ypos = 1 ;
    
    dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
    
    dc.DrawText(text, xpos, ypos);
    
    dc.DestroyClippingRegion();
}
Esempio n. 2
0
void wxGLCanvas::SetViewport()
{
    // viewport is initially set to entire port
    // adjust glViewport to just this window
    int x = 0 ;
    int y = 0 ;
    
    wxWindow* iter = this ;
    while( iter->GetParent() )
    {
    	iter = iter->GetParent() ;
    }
    
    if ( iter && iter->IsTopLevel() )
    {
	    MacClientToRootWindow( &x , &y ) ;
	    int width, height;
	    GetClientSize(& width, & height);
	    Rect bounds ;
	    GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ;
	    GLint parms[4] ;
	    parms[0] = x ;
	    parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
	    parms[2] = width ;
	    parms[3] = height ;
	    
	    if ( !m_macCanvasIsShown )
	    	parms[0] += 20000 ;
	    aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ;
   	}
}
Esempio n. 3
0
wxSize wxListBox::DoGetBestSize() const
{
    int lbWidth = 100;  // some defaults
    int lbHeight = 110;
    int wLine;

    {
        wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;

        if ( m_font.Ok() )
        {
            ::TextFont( m_font.GetMacFontNum() ) ;
            ::TextSize( m_font.GetMacFontSize() ) ;
            ::TextFace( m_font.GetMacFontStyle() ) ;
        }
        else
        {
            ::TextFont( kFontIDMonaco ) ;
            ::TextSize( 9  );
            ::TextFace( 0 ) ;
        }

        // Find the widest line
        for(unsigned int i = 0; i < GetCount(); i++) {
            wxString str(GetString(i));
        #if wxUSE_UNICODE
            Point bounds={0,0} ;
            SInt16 baseline ;
            ::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) ,
                kThemeCurrentPortFont,
                kThemeStateActive,
                false,
                &bounds,
                &baseline );
            wLine = bounds.h ;
        #else
            wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
        #endif
            lbWidth = wxMax(lbWidth, wLine);
        }

        // Add room for the scrollbar
        lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);

        // And just a bit more
        int cy = 12 ;
        int cx = ::TextWidth( "X" , 0 , 1 ) ;
        lbWidth += cx ;

        // don't make the listbox too tall (limit height to around 10 items) but don't
        // make it too small neither
        lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
    }
    return wxSize(lbWidth, lbHeight);
}
Esempio n. 4
0
void wxControl::MacRedrawControl()
{
    if ( (ControlHandle) m_macControl && MacGetRootWindow() && m_macControlIsShown )
    {
        wxClientDC dc(this) ;
        wxMacPortSetter helper(&dc) ;
        wxMacWindowClipper clipper(this) ;
        wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
        UMADrawControl( (ControlHandle) m_macControl ) ;
    }
}
Esempio n. 5
0
void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
  	wxPaintDC dc(this);
  	dc.Clear() ;

    int major,minor;
    wxGetOsVersion( &major, &minor );

	if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
	{
		wxPen white( wxWHITE , 1 , wxSOLID ) ;
        if (major >= 10) 
        {
            //Finder statusbar border color: (Project builder similar is 9B9B9B)
            dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));  
        }
        else
        {
            wxPen black( wxBLACK , 1 , wxSOLID ) ;
            dc.SetPen(black);
    	}
		dc.DrawLine(0, 0 ,
		       m_width , 0);
		dc.SetPen(white);
		dc.DrawLine(0, 1 ,
		       m_width , 1);
	}
	else
	{
        if (major >= 10) 
            //Finder statusbar border color: (Project builder similar is 9B9B9B)
            dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); 
        else
            dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));

		dc.DrawLine(0, 0 ,
		       m_width , 0);
	}

	int i;
	if ( GetFont().Ok() )
		dc.SetFont(GetFont());
	dc.SetBackgroundMode(wxTRANSPARENT);

	for ( i = 0; i < m_nFields; i ++ )
		DrawField(dc, i);
}
Esempio n. 6
0
void wxStaticText::OnDraw( wxDC &dc )
{
    if (m_width <= 0 || m_height <= 0)
        return;
    /*
        dc.Clear() ;
        wxRect rect(0,0,m_width,m_height) ;
        dc.SetFont(*wxSMALL_FONT) ;
        
          dc.DrawRectangle(rect) ;
    */
    if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) &&
        ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE )
        || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) )
    {
        dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
    }
    else
    {
        dc.SetTextForeground( GetForegroundColour() ) ;
    }
    
    wxString paragraph;
    size_t i = 0 ;
    wxString text = m_label;
    int y = 0 ;
    while (i < text.Length())
    {
        
        if (text[i] == 13 || text[i] == 10)
        {
            DrawParagraph(dc, paragraph,y);
            paragraph = wxEmptyString ;
        }
        else
        {
            paragraph += text[i];
        }
        ++i;
    }
    if (paragraph.Length() > 0)
        DrawParagraph(dc, paragraph,y);
}
Esempio n. 7
0
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 ) ;
        }
    }
}
Esempio n. 8
0
void wxSlider::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 ;

    int  xborder, yborder;
    int  minValWidth, maxValWidth, textwidth, textheight;
    int  sliderBreadth;

    xborder = yborder = 0;

    if (GetWindowStyle() & wxSL_LABELS)
    {
        wxString text;
        int ht;

        // Get maximum text label width and height
        text.Printf(wxT("%d"), m_rangeMin);
        GetTextExtent(text, &minValWidth, &textheight);
        text.Printf(wxT("%d"), m_rangeMax);
        GetTextExtent(text, &maxValWidth, &ht);
        if(ht > textheight) {
            textheight = ht;
        }
        textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth);

        xborder = textwidth + wxSLIDER_BORDERTEXT;
        yborder = textheight + wxSLIDER_BORDERTEXT;

        // Get slider breadth
        if(GetWindowStyle() & wxSL_AUTOTICKS) {
            sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
        }
        else {
            sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW;
        }

        if(GetWindowStyle() & wxSL_VERTICAL)
        {
            m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT,
                m_height - yborder - textheight);
            m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0);
            m_macValueStatic->Move(0, m_height - textheight);
        }
        else
        {
            m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT);
            m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2,
                sliderBreadth + wxSLIDER_BORDERTEXT);
            m_macValueStatic->Move(m_width - textwidth, 0);
        }
    }

    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 - xborder ;
    int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ;

    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 ) ;
        }
    }
}