cleanup - reformat; minor code tweaks

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36711 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-05 19:02:39 +00:00
parent a319ce7d74
commit 586031781c

View File

@@ -847,7 +847,8 @@ void wxWindowMac::MacInstallEventHandler( WXWidget control )
}
// Constructor
bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
bool wxWindowMac::Create(wxWindowMac *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
@@ -873,19 +874,19 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
| kControlHandlesTracking
| kControlSupportsFocus
| kControlWantsActivate
| kControlWantsIdle
;
| kControlWantsIdle ;
m_peer = new wxMacControl(this) ;
::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() );
OSStatus err =::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() );
verify_noerr( err );
MacPostControlCreate(pos, size) ;
}
#ifndef __WXUNIVERSAL__
// Don't give scrollbars to wxControls unless they ask for them
if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) ||
(IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL)))
if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar)))
|| (IsKindOf(CLASSINFO(wxControl)) && ((style & wxHSCROLL) || (style & wxVSCROLL))))
{
MacCreateScrollBars( style ) ;
}
@@ -1023,6 +1024,7 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
wxBrush brush ;
wxColour newCol(GetBackgroundColour());
if ( newCol == wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) )
brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ;
else if ( newCol == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) )
@@ -1031,7 +1033,6 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
brush.SetColour( newCol ) ;
MacSetBackgroundBrush( brush ) ;
MacUpdateControlFont() ;
return true ;
@@ -1077,8 +1078,11 @@ void wxWindowMac::SetFocus()
if ( former )
{
EventRef evRef = NULL ;
verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent ,
&evRef ) );
err = MacCreateEvent(
NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) ,
kEventAttributeUserEvent , &evRef );
verify_noerr( err );
wxMacCarbonEvent cEvent( evRef ) ;
cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) former->GetHandle() ) ;
@@ -1091,8 +1095,11 @@ void wxWindowMac::SetFocus()
// send new focus event
{
EventRef evRef = NULL ;
verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent ,
&evRef ) );
err = MacCreateEvent(
NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) ,
kEventAttributeUserEvent , &evRef );
verify_noerr( err );
wxMacCarbonEvent cEvent( evRef ) ;
cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) GetHandle() ) ;
@@ -1129,7 +1136,7 @@ void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
m_dropTarget = pDropTarget;
if ( m_dropTarget != NULL )
{
// TODO
// TODO:
}
}
@@ -1138,7 +1145,7 @@ void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
// Old style file-manager drag&drop
void wxWindowMac::DragAcceptFiles(bool accept)
{
// TODO
// TODO:
}
// Returns the size of the native control. In the case of the toplevel window
@@ -1164,7 +1171,8 @@ bool wxWindowMac::MacGetBoundsForControl(
x = (int)pos.x;
y = (int)pos.y;
// todo the default calls may be used as soon as PostCreateControl Is moved here
// TODO: the default calls may be used as soon as PostCreateControl Is moved here
w = wxMax(size.x, 0) ; // WidthDefault( size.x );
h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
@@ -1240,10 +1248,8 @@ void wxWindowMac::DoGetPosition(int *x, int *y) const
void wxWindowMac::DoScreenToClient(int *x, int *y) const
{
WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
wxCHECK_RET( window , wxT("TopLevel Window missing") ) ;
wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ;
{
Point localwhere = { 0, 0 } ;
if (x)
@@ -1257,7 +1263,6 @@ void wxWindowMac::DoScreenToClient(int *x, int *y) const
*x = localwhere.h ;
if (y)
*y = localwhere.v ;
}
MacRootWindowToWindow( x , y ) ;
@@ -1281,7 +1286,6 @@ void wxWindowMac::DoClientToScreen(int *x, int *y) const
MacWindowToRootWindow( x , y ) ;
{
Point localwhere = { 0, 0 };
if (x)
localwhere.h = *x ;
@@ -1295,7 +1299,6 @@ void wxWindowMac::DoClientToScreen(int *x, int *y) const
if (y)
*y = localwhere.v ;
}
}
void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const
{
@@ -1322,6 +1325,7 @@ void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const
void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
{
wxPoint pt ;
if (x)
pt.x = *x ;
if (y)
@@ -1508,13 +1512,14 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor)
CGrafPtr savePort ;
Boolean swapped = QDSwapPort( GetWindowPort( window ) , &savePort ) ;
// TODO If we ever get a GetCurrentEvent.. replacement for the mouse
// position, use it...
// TODO: If we ever get a GetCurrentEvent... replacement
// for the mouse position, use it...
Point pt ;
GetMouse( &pt ) ;
ControlPartCode part ;
ControlRef control ;
GetMouse( &pt ) ;
control = wxMacFindControlUnderMouse( tlw , pt , window , &part ) ;
if ( control )
mouseWin = wxFindControlFromMacControl( control ) ;
@@ -1603,11 +1608,13 @@ void wxWindowMac::MacInvalidateBorders()
// now we know that we have something to do at all
// as the borders are drawn on the parent we have to properly invalidate all these areas
RgnHandle updateInner = NewRgn() ,
updateOuter = NewRgn() ;
RgnHandle updateInner , updateOuter;
Rect rect ;
// this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
Rect rect ;
updateInner = NewRgn() ;
updateOuter = NewRgn() ;
m_peer->GetRect( &rect ) ;
RectRgn( updateInner, &rect ) ;
InsetRect( &rect , -outerBorder , -outerBorder ) ;
@@ -1624,105 +1631,6 @@ void wxWindowMac::MacInvalidateBorders()
DisposeRgn( updateOuter ) ;
DisposeRgn( updateInner ) ;
#if 0
RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ;
RectRgn( updateInner , &rect ) ;
InsetRect( &rect , -4 , -4 ) ;
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner , updateOuter ) ;
wxPoint parent(0, 0);
GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
parent -= GetParent()->GetClientAreaOrigin() ;
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
DisposeRgn(updateOuter) ;
DisposeRgn(updateInner) ;
#endif
#if 0
if ( m_peer )
{
// deleting a window while it is shown invalidates
// the region occupied by border or focus
if ( IsShown() && ( outerBorder > 0 ) )
{
// as the borders are drawn on the parent we have to properly invalidate all these areas
RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
Rect rect ;
m_peer->GetRect( &rect ) ;
RectRgn( updateInner , &rect ) ;
InsetRect( &rect , -outerBorder , -outerBorder ) ;
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner ,updateOuter ) ;
wxPoint parent(0, 0);
GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
parent -= GetParent()->GetClientAreaOrigin() ;
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
CopyRgn( updateOuter , updateTotal ) ;
GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
DisposeRgn(updateOuter) ;
DisposeRgn(updateInner) ;
DisposeRgn(updateTotal) ;
}
}
#endif
#if 0
Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
int outerBorder = MacGetLeftBorderSize() ;
if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
outerBorder += 4 ;
if ( vis && ( outerBorder > 0 ) )
{
// as the borders are drawn on the parent we have to properly invalidate all these areas
RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
Rect rect ;
m_peer->GetRect( &rect ) ;
RectRgn( updateInner , &rect ) ;
InsetRect( &rect , -outerBorder , -outerBorder ) ;
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner ,updateOuter ) ;
/*
wxPoint parent(0, 0);
#if TARGET_API_MAC_OSX
// no offsetting needed when compositing
#else
GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
parent -= GetParent()->GetClientAreaOrigin() ;
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
#endif
*/
CopyRgn( updateOuter , updateTotal ) ;
rect = r ;
RectRgn( updateInner , &rect ) ;
InsetRect( &rect , -outerBorder , -outerBorder ) ;
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner , updateOuter ) ;
/*
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
*/
UnionRgn( updateOuter , updateTotal , updateTotal ) ;
GetParent()->m_peer->SetNeedsDisplay( updateTotal ) ;
DisposeRgn( updateOuter ) ;
DisposeRgn( updateInner ) ;
DisposeRgn( updateTotal ) ;
}
#endif
}
void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
@@ -1874,10 +1782,13 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
return;
}
if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
{
if ( x == wxDefaultCoord )
x = currentX;
if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
if ( y == wxDefaultCoord )
y = currentY;
}
AdjustForParentClientOrigin( x, y, sizeFlags );
@@ -1971,20 +1882,13 @@ bool wxWindowMac::Show(bool show)
if ( !wxWindowBase::Show(show) )
return false;
// TODO use visibilityChanged Carbon Event for OSX
// TODO: use visibilityChanged Carbon Event for OSX
if ( m_peer )
m_peer->SetVisibility( show , true ) ;
if ( former != MacIsReallyShown() )
MacPropagateVisibilityChanged() ;
#if 1
// patch from Sailesh Agrawal
wxShowEvent eventShow(GetId(), show);
eventShow.SetEventObject(this);
GetEventHandler()->ProcessEvent(eventShow);
#endif
return true;
}
@@ -2322,8 +2226,8 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
bool hasFocus = m_peer->NeedsFocusRect() && m_peer->HasFocus() ;
bool hasBothScrollbars = (m_hScrollBar && m_hScrollBar->IsShown()) && (m_vScrollBar && m_vScrollBar->IsShown()) ;
m_peer->GetRect( &rect ) ;
// back to the surrounding frame rectangle
m_peer->GetRect( &rect ) ;
InsetRect( &rect, -1 , -1 ) ;
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
@@ -2415,20 +2319,15 @@ void wxWindowMac::RemoveChild( wxWindowBase *child )
void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh)
{
bool showScroller;
if ( orient == wxHORIZONTAL )
{
if ( m_hScrollBar )
{
if ( range == 0 || thumbVisible >= range )
{
if ( m_hScrollBar->IsShown() )
m_hScrollBar->Show(false) ;
}
else
{
if ( !m_hScrollBar->IsShown() )
m_hScrollBar->Show(true) ;
}
showScroller = ((range != 0) && (range > thumbVisible));
if ( m_hScrollBar->IsShown() != showScroller )
m_hScrollBar->Show( showScroller ) ;
m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
@@ -2437,16 +2336,9 @@ void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible,
{
if ( m_vScrollBar )
{
if ( range == 0 || thumbVisible >= range )
{
if ( m_vScrollBar->IsShown() )
m_vScrollBar->Show(false) ;
}
else
{
if ( !m_vScrollBar->IsShown() )
m_vScrollBar->Show(true) ;
}
showScroller = ((range != 0) && (range > thumbVisible));
if ( m_vScrollBar->IsShown() != showScroller )
m_vScrollBar->Show( showScroller ) ;
m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
@@ -2469,14 +2361,14 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
{
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
// area is scrolled, this does not occur if width and height are 2 pixels less,
// TODO write optimal workaround
// TODO: write optimal workaround
wxRect scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width , height ) ;
if ( rect )
scrollrect.Intersect( *rect ) ;
if ( m_peer->GetNeedsDisplay() )
{
// becuase HIViewScrollRect does not scroll the already invalidated area we have two options
// because HIViewScrollRect does not scroll the already invalidated area we have two options:
// either immediate redraw or full invalidate
#if 1
// is the better overall solution, as it does not slow down scrolling
@@ -3308,7 +3200,6 @@ wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENT
bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
{
wxWindowMac *newParent = (wxWindowMac *)newParentBase;
if ( !wxWindowBase::Reparent(newParent) )
return false;