minor cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38007 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-03-11 21:13:28 +00:00
parent f30f25b559
commit 2e91d506b2
3 changed files with 52 additions and 41 deletions

View File

@@ -40,6 +40,7 @@ bool wxButton::Create(wxWindow *parent,
m_label = label ; m_label = label ;
OSStatus err;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_peer = new wxMacControl(this) ; m_peer = new wxMacControl(this) ;
if ( id == wxID_HELP ) if ( id == wxID_HELP )
@@ -47,8 +48,10 @@ bool wxButton::Create(wxWindow *parent,
ControlButtonContentInfo info ; ControlButtonContentInfo info ;
info.contentType = kControlContentIconRef ; info.contentType = kControlContentIconRef ;
GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef); GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef);
verify_noerr ( CreateRoundButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , kControlRoundButtonNormalSize , err = CreateRoundButtonControl(
&info , m_peer->GetControlRefAddr() ) ); MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, kControlRoundButtonNormalSize,
&info, m_peer->GetControlRefAddr() );
} }
else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND) else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
{ {
@@ -71,19 +74,24 @@ bool wxButton::Create(wxWindow *parent,
} }
#endif #endif
verify_noerr ( CreatePushButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , m_peer->GetControlRefAddr() ) ); err = CreatePushButtonControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, CFSTR(""), m_peer->GetControlRefAddr() );
} }
else else
{ {
ControlButtonContentInfo info ; ControlButtonContentInfo info ;
info.contentType = kControlNoContent ; info.contentType = kControlNoContent ;
verify_noerr(CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""), err = CreateBevelButtonControl(
kControlBevelButtonLargeBevel , kControlBehaviorPushbutton , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""),
kControlBevelButtonLargeBevel, kControlBehaviorPushbutton,
&info, 0, 0, 0, m_peer->GetControlRefAddr() );
} }
verify_noerr( err );
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid Mac control") ) ; wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid Mac control") ) ;
MacPostControlCreate(pos, size) ; MacPostControlCreate( pos, size );
return true; return true;
} }
@@ -169,7 +177,7 @@ void wxButton::Command (wxCommandEvent & event)
wxInt32 wxButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) wxInt32 wxButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{ {
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId ); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
ProcessCommand(event); ProcessCommand(event);

View File

@@ -141,41 +141,41 @@ bool wxDropTarget::GetData()
return false; return false;
if ( !CurrentDragHasSupportedFormat() ) if ( !CurrentDragHasSupportedFormat() )
return false ; return false;
bool transferred = false ; bool transferred = false;
if ( gTrackingGlobals.m_currentSource != NULL ) if ( gTrackingGlobals.m_currentSource != NULL )
{ {
wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject();
if ( data ) if (data != NULL)
{ {
size_t formatcount = data->GetFormatCount() ; size_t formatcount = data->GetFormatCount();
wxDataFormat *array = new wxDataFormat[formatcount]; wxDataFormat *array = new wxDataFormat[formatcount];
data->GetAllFormats( array ); data->GetAllFormats( array );
for (size_t i = 0; !transferred && i < formatcount ; i++) for (size_t i = 0; !transferred && i < formatcount; i++)
{ {
wxDataFormat format = array[i] ; wxDataFormat format = array[i];
if ( m_dataObject->IsSupported( format ) ) if ( m_dataObject->IsSupported( format ) )
{ {
int size = data->GetDataSize( format ); int size = data->GetDataSize( format );
transferred = true ; transferred = true;
if (size == 0) if (size == 0)
{ {
m_dataObject->SetData( format , 0 , 0 ); m_dataObject->SetData( format, 0, 0 );
} }
else else
{ {
char *d = new char[size]; char *d = new char[size];
data->GetDataHere( format , (void*) d ); data->GetDataHere( format, (void*)d );
m_dataObject->SetData( format , size , d ) ; m_dataObject->SetData( format, size, d );
delete [] d ; delete [] d;
} }
} }
} }
delete [] array ; delete [] array;
} }
} }
@@ -237,7 +237,10 @@ bool wxDropTarget::GetData()
dataSize++ ; dataSize++ ;
} }
theData = new char[dataSize]; if (dataSize > 0)
theData = new char[dataSize];
else
theData = NULL;
GetFlavorData( (DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L ); GetFlavorData( (DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L );
if ( theType == kScrapFlavorTypeText ) if ( theType == kScrapFlavorTypeText )
@@ -334,7 +337,7 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
if (m_data->GetFormatCount() == 0) if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone; return (wxDragResult) wxDragNone;
OSErr result; OSStatus result;
DragReference theDrag; DragReference theDrag;
RgnHandle dragRegion; RgnHandle dragRegion;
if ((result = NewDrag(&theDrag)) != noErr) if ((result = NewDrag(&theDrag)) != noErr)
@@ -490,13 +493,13 @@ void wxMacEnsureTrackingHandlersInstalled()
{ {
if ( !gTrackingGlobalsInstalled ) if ( !gTrackingGlobalsInstalled )
{ {
OSErr result; OSStatus err;
result = InstallTrackingHandler( NewDragTrackingHandlerUPP(wxMacWindowDragTrackingHandler), 0L, &gTrackingGlobals ); err = InstallTrackingHandler( NewDragTrackingHandlerUPP(wxMacWindowDragTrackingHandler), 0L, &gTrackingGlobals );
wxASSERT( result == noErr ); verify_noerr( err );
result = InstallReceiveHandler( NewDragReceiveHandlerUPP(wxMacWindowDragReceiveHandler), 0L, &gTrackingGlobals ); err = InstallReceiveHandler( NewDragReceiveHandlerUPP(wxMacWindowDragReceiveHandler), 0L, &gTrackingGlobals );
wxASSERT( result == noErr ); verify_noerr( err );
gTrackingGlobalsInstalled = true; gTrackingGlobalsInstalled = true;
} }
@@ -616,21 +619,21 @@ pascal OSErr wxMacWindowDragTrackingHandler(
{ {
switch ( result ) switch ( result )
{ {
case wxDragCopy : case wxDragCopy:
{ {
wxCursor cursor(wxCURSOR_COPY_ARROW) ; wxCursor cursor(wxCURSOR_COPY_ARROW) ;
cursor.MacInstall() ; cursor.MacInstall() ;
} }
break ; break ;
case wxDragMove : case wxDragMove:
{ {
wxCursor cursor(wxCURSOR_ARROW) ; wxCursor cursor(wxCURSOR_ARROW) ;
cursor.MacInstall() ; cursor.MacInstall() ;
} }
break ; break ;
case wxDragNone : case wxDragNone:
{ {
wxCursor cursor(wxCURSOR_NO_ENTRY) ; wxCursor cursor(wxCURSOR_NO_ENTRY) ;
cursor.MacInstall() ; cursor.MacInstall() ;

View File

@@ -587,7 +587,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
delete [] uniChars ; delete [] uniChars ;
if ( charBuf != buf ) if ( charBuf != buf )
delete [] charBuf ; delete [] charBuf ;
return result ; return result ;
} }
@@ -1259,14 +1259,16 @@ void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
bool wxWindowMac::MacCanFocus() const bool wxWindowMac::MacCanFocus() const
{ {
// TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
// CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning, but the value range // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning,
// is nowhere documented // but the value range is nowhere documented
Boolean keyExistsAndHasValidFormat ; Boolean keyExistsAndHasValidFormat ;
CFIndex fullKeyboardAccess = CFPreferencesGetAppIntegerValue ( CFSTR("AppleKeyboardUIMode" ) , CFIndex fullKeyboardAccess = CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) ,
kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat );
if ( keyExistsAndHasValidFormat && fullKeyboardAccess > 0 ) if ( keyExistsAndHasValidFormat && fullKeyboardAccess > 0 )
{
return true ; return true ;
}
else else
{ {
UInt32 features = 0 ; UInt32 features = 0 ;
@@ -1336,7 +1338,7 @@ void wxWindowMac::DoCaptureMouse()
wxApp::s_captureWindow = this ; wxApp::s_captureWindow = this ;
} }
wxWindow* wxWindowBase::GetCapture() wxWindow * wxWindowBase::GetCapture()
{ {
return wxApp::s_captureWindow ; return wxApp::s_captureWindow ;
} }
@@ -1362,7 +1364,7 @@ void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
#endif #endif
// Old style file-manager drag&drop // Old-style File Manager Drag & Drop
void wxWindowMac::DragAcceptFiles(bool accept) void wxWindowMac::DragAcceptFiles(bool accept)
{ {
// TODO: // TODO:
@@ -1385,10 +1387,7 @@ bool wxWindowMac::MacGetBoundsForControl(
int& x, int& y, int& x, int& y,
int& w, int& h , bool adjustOrigin ) const int& w, int& h , bool adjustOrigin ) const
{ {
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
// the desired size, minus the border pixels gives the correct size of the control // the desired size, minus the border pixels gives the correct size of the control
x = (int)pos.x; x = (int)pos.x;
y = (int)pos.y; y = (int)pos.y;
@@ -1396,6 +1395,7 @@ bool wxWindowMac::MacGetBoundsForControl(
w = wxMax(size.x, 0) ; // WidthDefault( size.x ); w = wxMax(size.x, 0) ; // WidthDefault( size.x );
h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ; h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
if ( !isCompositing ) if ( !isCompositing )
GetParent()->MacWindowToRootWindow( &x , &y ) ; GetParent()->MacWindowToRootWindow( &x , &y ) ;