translating background style BG_PAINT into opaqueness for speed-up of OS redraws, supporting positioning for native carbon controls also on non-composited windows (custom pane in navservices dialogs)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2010-04-16 06:18:16 +00:00
parent 7f2468e96a
commit bc5c09a3aa
7 changed files with 74 additions and 2 deletions

View File

@ -433,6 +433,7 @@ public :
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
virtual void SetBackgroundColour( const wxColour& col ); virtual void SetBackgroundColour( const wxColour& col );
virtual bool SetBackgroundStyle(wxBackgroundStyle style);
virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ); virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
void SetActionProc( ControlActionUPP actionProc ); void SetActionProc( ControlActionUPP actionProc );
SInt32 GetViewSize() const; SInt32 GetViewSize() const;

View File

@ -101,6 +101,7 @@ public :
virtual WXWidget GetWXWidget() const { return m_osxView; } virtual WXWidget GetWXWidget() const { return m_osxView; }
virtual void SetBackgroundColour(const wxColour&); virtual void SetBackgroundColour(const wxColour&);
virtual bool SetBackgroundStyle(wxBackgroundStyle style);
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const; virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
virtual void Move(int x, int y, int width, int height); virtual void Move(int x, int y, int width, int height);

View File

@ -215,6 +215,7 @@ public :
virtual WXWidget GetWXWidget() const = 0; virtual WXWidget GetWXWidget() const = 0;
virtual void SetBackgroundColour( const wxColour& col ) = 0; virtual void SetBackgroundColour( const wxColour& col ) = 0;
virtual bool SetBackgroundStyle(wxBackgroundStyle style) = 0;
// all coordinates in native parent widget relative coordinates // all coordinates in native parent widget relative coordinates
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0; virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0;

View File

@ -91,6 +91,8 @@ public:
virtual bool SetBackgroundColour( const wxColour &colour ); virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour ); virtual bool SetForegroundColour( const wxColour &colour );
virtual bool SetBackgroundStyle(wxBackgroundStyle style);
virtual int GetCharHeight() const; virtual int GetCharHeight() const;
virtual int GetCharWidth() const; virtual int GetCharWidth() const;

View File

@ -970,7 +970,17 @@ void wxMacControl::GetContentArea(int &left , int &top , int &width , int &heigh
void wxMacControl::Move(int x, int y, int width, int height) void wxMacControl::Move(int x, int y, int width, int height)
{ {
UInt32 attr = 0 ;
GetWindowAttributes( GetControlOwner(m_controlRef) , &attr ) ;
HIRect hir = CGRectMake(x,y,width,height); HIRect hir = CGRectMake(x,y,width,height);
if ( !(attr & kWindowCompositingAttribute) )
{
HIRect parent;
HIViewGetFrame( HIViewGetSuperview(m_controlRef), &parent );
hir.origin.x += parent.origin.x;
hir.origin.y += parent.origin.y;
}
HIViewSetFrame ( m_controlRef , &hir ); HIViewSetFrame ( m_controlRef , &hir );
} }
@ -980,6 +990,18 @@ void wxMacControl::GetPosition( int &x, int &y ) const
GetControlBounds( m_controlRef , &r ); GetControlBounds( m_controlRef , &r );
x = r.left; x = r.left;
y = r.top; y = r.top;
UInt32 attr = 0 ;
GetWindowAttributes( GetControlOwner(m_controlRef) , &attr ) ;
if ( !(attr & kWindowCompositingAttribute) )
{
HIRect parent;
HIViewGetFrame( HIViewGetSuperview(m_controlRef), &parent );
x -= parent.origin.x;
y -= parent.origin.y;
}
} }
void wxMacControl::GetSize( int &width, int &height ) const void wxMacControl::GetSize( int &width, int &height ) const
@ -1324,6 +1346,22 @@ void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
// HITextViewSetBackgroundColor( m_textView , color ); // HITextViewSetBackgroundColor( m_textView , color );
} }
bool wxMacControl::SetBackgroundStyle(wxBackgroundStyle style)
{
if ( style != wxBG_STYLE_PAINT )
{
OSStatus err = HIViewChangeFeatures(m_controlRef , 0 , kHIViewIsOpaque);
verify_noerr( err );
}
else
{
OSStatus err = HIViewChangeFeatures(m_controlRef , kHIViewIsOpaque , 0);
verify_noerr( err );
}
return true ;
}
void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum ) void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
{ {
::SetControl32BitMinimum( m_controlRef , minimum ); ::SetControl32BitMinimum( m_controlRef , minimum );
@ -1393,7 +1431,7 @@ void wxMacControl::GetRectInWindowCoords( Rect *r )
OffsetRect( r , (short) hiPoint.x , (short) hiPoint.y ) ; OffsetRect( r , (short) hiPoint.x , (short) hiPoint.y ) ;
} }
} }
void wxMacControl::GetBestRect( wxRect *rect ) const void wxMacControl::GetBestRect( wxRect *rect ) const
{ {
short baselineoffset; short baselineoffset;

View File

@ -131,6 +131,7 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
- (void)setAction:(SEL)aSelector; - (void)setAction:(SEL)aSelector;
- (void)setDoubleAction:(SEL)aSelector; - (void)setDoubleAction:(SEL)aSelector;
- (void)setBackgroundColor:(NSColor*)aColor; - (void)setBackgroundColor:(NSColor*)aColor;
- (void)setOpaque:(BOOL)opaque;
- (void)setTextColor:(NSColor *)color; - (void)setTextColor:(NSColor *)color;
- (void)setImagePosition:(NSCellImagePosition)aPosition; - (void)setImagePosition:(NSCellImagePosition)aPosition;
@end @end
@ -1690,6 +1691,18 @@ void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col )
} }
} }
bool wxWidgetCocoaImpl::SetBackgroundStyle( wxBackgroundStyle style )
{
BOOL opaque = ( style == wxBG_STYLE_PAINT );
if ( [m_osxView respondsToSelector:@selector(setOpaque:) ] )
{
[m_osxView setOpaque: opaque];
}
return true ;
}
void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding ) void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding )
{ {
if ( [m_osxView respondsToSelector:@selector(setTitle:) ] ) if ( [m_osxView respondsToSelector:@selector(setTitle:) ] )
@ -2088,7 +2101,13 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
wxWidgetCocoaImpl* c = NULL; wxWidgetCocoaImpl* c = NULL;
if ( now->IsNativeWindowWrapper() ) if ( now->IsNativeWindowWrapper() )
{ {
c = new wxWidgetCocoaImpl( now, [tlw contentView], true ); NSView* cv = [tlw contentView];
c = new wxWidgetCocoaImpl( now, cv, true );
// increase ref count, because the impl destructor will decrement it again
CFRetain(cv);
if ( !now->IsShown() )
[cv setHidden:NO];
} }
else else
{ {

View File

@ -472,6 +472,16 @@ bool wxWindowMac::SetForegroundColour(const wxColour& col )
return retval; return retval;
} }
bool wxWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
{
if ( !wxWindowBase::SetBackgroundStyle(style) )
return false;
if ( m_peer )
m_peer->SetBackgroundStyle(style);
return true;
}
bool wxWindowMac::SetBackgroundColour(const wxColour& col ) bool wxWindowMac::SetBackgroundColour(const wxColour& col )
{ {
if (m_growBox) if (m_growBox)