]> git.saurik.com Git - wxWidgets.git/commitdiff
minor cleanup
authorDavid Surovell <davids@osafoundation.org>
Sat, 11 Mar 2006 21:13:28 +0000 (21:13 +0000)
committerDavid Surovell <davids@osafoundation.org>
Sat, 11 Mar 2006 21:13:28 +0000 (21:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38007 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/button.cpp
src/mac/carbon/dnd.cpp
src/mac/carbon/window.cpp

index c5b487320b9ef0bf1a6e87ecd355b6d0e27b1acd..e69b3e3e6c18909ca87278c9dc46b86d6457fb70 100644 (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);
 
index f5212eb4e210e5d007c82f947b17abe3975bcc48..1c545b96a1538ddd2a7b38dd6ce7f122e3325f4b 100644 (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() ;
index a82b7e19a719caf5756a668cc6d0411ed1ffa20f..47a280bc4d4d83e3b9343e128ada44dd5a42d4f0 100644 (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 ) ;