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 ;
OSStatus err;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_peer = new wxMacControl(this) ;
if ( id == wxID_HELP )
@@ -47,8 +48,10 @@ bool wxButton::Create(wxWindow *parent,
ControlButtonContentInfo info ;
info.contentType = kControlContentIconRef ;
GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef);
verify_noerr ( CreateRoundButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , kControlRoundButtonNormalSize ,
&info , m_peer->GetControlRefAddr() ) );
err = CreateRoundButtonControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, kControlRoundButtonNormalSize,
&info, m_peer->GetControlRefAddr() );
}
else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
{
@@ -71,19 +74,24 @@ bool wxButton::Create(wxWindow *parent,
}
#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
{
ControlButtonContentInfo info ;
info.contentType = kControlNoContent ;
verify_noerr(CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""),
kControlBevelButtonLargeBevel , kControlBehaviorPushbutton , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
err = CreateBevelButtonControl(
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") ) ;
MacPostControlCreate(pos, size) ;
MacPostControlCreate( pos, size );
return true;
}
@@ -169,7 +177,7 @@ void wxButton::Command (wxCommandEvent & 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);
ProcessCommand(event);

View File

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

View File

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