]> git.saurik.com Git - wxWidgets.git/commitdiff
introduction of m_peer
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 4 Jun 2004 07:28:59 +0000 (07:28 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 4 Jun 2004 07:28:59 +0000 (07:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

24 files changed:
src/mac/carbon/bmpbuttn.cpp
src/mac/carbon/button.cpp
src/mac/carbon/checkbox.cpp
src/mac/carbon/checklst.cpp
src/mac/carbon/choice.cpp
src/mac/carbon/combobxc.cpp
src/mac/carbon/control.cpp
src/mac/carbon/gauge.cpp
src/mac/carbon/listbox.cpp
src/mac/carbon/notebmac.cpp
src/mac/carbon/radiobox.cpp
src/mac/carbon/radiobut.cpp
src/mac/carbon/scrolbar.cpp
src/mac/carbon/slider.cpp
src/mac/carbon/spinbutt.cpp
src/mac/carbon/statbox.cpp
src/mac/carbon/statlmac.cpp
src/mac/carbon/stattext.cpp
src/mac/carbon/tabctrl.cpp
src/mac/carbon/textctrl.cpp
src/mac/carbon/tglbtn.cpp
src/mac/carbon/toplevel.cpp
src/mac/carbon/utils.cpp
src/mac/carbon/window.cpp

index 8fba4742c7095dd402884b1e59be5bbc55068c28..704b1728bafad74e5c550da3e92f43649b50f8bd 100644 (file)
@@ -73,11 +73,13 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
     wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 
         (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel )  , 
-        kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
+        kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , *m_peer ) );
     
-    wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+    
+    wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
     
     MacPostControlCreate(pos,size) ;
 
@@ -92,7 +94,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
     wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
     if ( info.contentType != kControlNoContent )
     {
-        ::SetControlData( (ControlRef) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+        m_peer->SetData( kControlButtonPart , kControlBevelButtonContentTag , info ) ;
     }
 }
 
index 4bb38feb1e538dad12e1dd911953f12621c8581a..94610153a1358a2bd7661522156c6a2bc62e2a3a 100644 (file)
@@ -39,18 +39,20 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
     m_label = label ;
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+    m_peer = new wxMacControl() ;
     if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
     {
-        verify_noerr ( CreatePushButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , (ControlRef*) &m_macControl ) ) ;
+        verify_noerr ( CreatePushButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , *m_peer ) );
     }
     else
     {
         ControlButtonContentInfo info ;
         info.contentType = kControlNoContent ;
         verify_noerr(CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds,CFSTR(""),
-            kControlBevelButtonLargeBevel , kControlBehaviorPushbutton , &info , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
+            kControlBevelButtonLargeBevel , kControlBehaviorPushbutton , &info , 0 , 0 , 0 , *m_peer ) );
     }
-    wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+    
+    wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
     
     MacPostControlCreate(pos,size) ;
     
@@ -68,19 +70,9 @@ void wxButton::SetDefault()
         parent->SetDefaultItem(this);
     }
 
-    Boolean inData;
-    if ( btnOldDefault && btnOldDefault->m_macControl )
-    {
-          inData = 0;
-        ::SetControlData( (ControlRef) btnOldDefault->m_macControl , kControlButtonPart ,
-                           kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
-    }
-    if ( (ControlRef) m_macControl )
-    {
-          inData = 1;
-        ::SetControlData(  (ControlRef) m_macControl , kControlButtonPart ,
-                           kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
-    }
+    if ( btnOldDefault )
+        btnOldDefault->m_peer->SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) 0 ) ;
+    m_peer->SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) 1 ) ;
 }
 
 wxSize wxButton::DoGetBestSize() const
@@ -121,13 +113,7 @@ wxSize wxButton::GetDefaultSize()
 
 void wxButton::Command (wxCommandEvent & event)
 {
-    if ( (ControlRef) m_macControl )
-    {
-        HiliteControl(  (ControlRef) m_macControl , kControlButtonPart ) ;
-        unsigned long finalTicks ;
-        Delay( 8 , &finalTicks ) ;
-        HiliteControl(  (ControlRef) m_macControl , 0 ) ;
-    }
+    m_peer->Flash(kControlButtonPart) ;
     ProcessCommand (event);
 }
 
index 56284d3ce34307fb8a3a094c843873026df7d7a8..11ed5fc74fef125547937c7b24b4dbdd3cb180f5 100644 (file)
@@ -43,10 +43,11 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
         maxValue = 2 /* kControlCheckboxMixedValue */;
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+    m_peer = new wxMacControl() ;
     verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds ,
-        CFSTR("") , 0 , false , (ControlRef*) &m_macControl ) ) ;
-
-    SetControl32BitMaximum( (ControlRef) m_macControl , maxValue ) ;
+        CFSTR("") , 0 , false , *m_peer ) );
+    
+    m_peer->SetMaximum( maxValue ) ;
     
     MacPostControlCreate(pos,size) ;
 
@@ -85,13 +86,12 @@ void wxCheckBox::Command (wxCommandEvent & event)
 
 wxCheckBoxState wxCheckBox::DoGet3StateValue() const
 {
-    return (wxCheckBoxState) ::GetControl32BitValue( (ControlRef) m_macControl );
+    return (wxCheckBoxState) m_peer->GetValue() ;
 }
 
 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
 {
-    ::SetControl32BitValue( (ControlRef) m_macControl , (int) val) ;
-    MacRedrawControl() ;
+    m_peer->SetValue( val ) ;
 }
 
 wxInt32 wxCheckBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) 
index 5fbc1f6c44df0f6d034b73957c112cbc653bda21..bad85ae4555ea59fdcdaaba07127b8a29b8cb370 100644 (file)
@@ -231,10 +231,10 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
     
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-    ControlRef browser ;
 
-    verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , (ControlRef *)&m_macControl ) );
-    browser = (ControlRef) m_macControl ;
+    m_peer = new wxMacControl() ;
+    verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , *m_peer ) );
+    
 
     DataBrowserSelectionFlags  options = kDataBrowserDragSelect ;
     if ( style & wxLB_MULTIPLE )
@@ -249,7 +249,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
     {
         options += kDataBrowserSelectOnlyOne ;
     }
-    verify_noerr(SetDataBrowserSelectionFlags  (browser, options ) ); 
+    verify_noerr(SetDataBrowserSelectionFlags  (*m_peer, options ) ); 
 
     DataBrowserListViewColumnDesc columnDesc ;
     columnDesc.headerBtnDesc.titleOffset = 0;
@@ -273,7 +273,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
        columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
        columnDesc.propertyDesc.propertyFlags = kDataBrowserPropertyIsMutable | kDataBrowserTableViewSelectionColumn |
                                             kDataBrowserDefaultPropertyFlags;
-       verify_noerr(::AddDataBrowserListViewColumn(browser, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
+       verify_noerr(::AddDataBrowserListViewColumn(*m_peer, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
 
     // text column
 
@@ -289,12 +289,12 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
          ;
 
        
-       verify_noerr(::AddDataBrowserListViewColumn(browser, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
+       verify_noerr(::AddDataBrowserListViewColumn(*m_peer, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
 
-    verify_noerr(::AutoSizeDataBrowserListViewColumns( browser ) ) ;
-    verify_noerr(::SetDataBrowserHasScrollBars( browser , false , true ) ) ;
-    verify_noerr(::SetDataBrowserTableViewHiliteStyle( browser, kDataBrowserTableViewFillHilite  ) ) ;
-    verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( browser , 0 ) ) ;
+    verify_noerr(::AutoSizeDataBrowserListViewColumns( *m_peer ) ) ;
+    verify_noerr(::SetDataBrowserHasScrollBars( *m_peer , false , true ) ) ;
+    verify_noerr(::SetDataBrowserTableViewHiliteStyle( *m_peer, kDataBrowserTableViewFillHilite  ) ) ;
+    verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( *m_peer , 0 ) ) ;
 
     DataBrowserCallbacks callbacks ;
     callbacks.version = kDataBrowserLatestCallbacks;
@@ -306,7 +306,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
 #else
            NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc) ;
 #endif
-    SetDataBrowserCallbacks(browser, &callbacks);
+    SetDataBrowserCallbacks(*m_peer, &callbacks);
 
     MacPostControlCreate(pos,size) ;
 
@@ -343,7 +343,7 @@ void wxCheckListBox::Check(size_t item, bool check)
     {
         m_checks[item] = check;
         UInt32 id = m_idArray[item] ;
-        verify_noerr( ::UpdateDataBrowserItems( (ControlRef) m_macControl , kDataBrowserNoItem , 1 , &id , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ;
+        verify_noerr( ::UpdateDataBrowserItems( *m_peer , kDataBrowserNoItem , 1 , &id , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ;
     }
 }
 
index 489243e04a7a7f24e6972954dcb942896881cd8d..c0c21a537795c3397f8b84726cd776dc3c7a6dfe 100644 (file)
@@ -67,15 +67,14 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
 
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 
-        -12345 , false /* no variable width */ , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
+        -12345 , false /* no variable width */ , 0 , 0 , 0 , *m_peer ) );
+    
 
     m_macPopUpMenuHandle =  NewUniqueMenu() ;
-    SetControlData( (ControlRef) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
-    SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , 0) ;
-    if ( n > 0 )
-        SetControl32BitValue( (ControlRef) m_macControl , 1 ) ;
+    m_peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ;
+    m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ) ;
     MacPostControlCreate(pos,size) ;
     // TODO wxCB_SORT
     for ( int i = 0; i < n; i++ )
@@ -96,7 +95,7 @@ int wxChoice::DoAppend(const wxString& item)
     m_datas.Add( NULL ) ;
     int index = m_strings.GetCount()  - 1  ;
     DoSetItemClientData( index , NULL ) ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , GetCount()) ;
+    m_peer->SetMaximum( GetCount() ) ;
     return index ;
 }
 
@@ -112,7 +111,7 @@ int wxChoice::DoInsert(const wxString& item, int pos)
     m_strings.Insert( item, pos ) ;
     m_datas.Insert( NULL, pos ) ;
     DoSetItemClientData( pos , NULL ) ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , pos) ;
+    m_peer->SetMaximum( GetCount() ) ;
     return pos ;
 }
 
@@ -126,7 +125,7 @@ void wxChoice::Delete(int n)
     ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ;
     m_strings.RemoveAt( n ) ;
     m_datas.RemoveAt( n ) ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , GetCount()) ;
+    m_peer->SetMaximum( GetCount() ) ;
 }
 
 void wxChoice::Clear()
@@ -138,7 +137,7 @@ void wxChoice::Clear()
     }
     m_strings.Empty() ;
     m_datas.Empty() ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , 0 ) ;
+    m_peer->SetMaximum( 0 ) ;
 }
 
 void wxChoice::FreeData()
@@ -158,12 +157,12 @@ void wxChoice::FreeData()
 // ----------------------------------------------------------------------------
 int wxChoice::GetSelection() const
 {
-    return GetControl32BitValue( (ControlRef) m_macControl ) -1 ;
+    return m_peer->GetValue() -1 ;
 }
 
 void wxChoice::SetSelection(int n)
 {
-    SetControl32BitValue( (ControlRef) m_macControl , n + 1 ) ;
+    m_peer->SetValue( n + 1 ) ;
 }
 
 // ----------------------------------------------------------------------------
index 8f1e122bd0384facebe895b18c9dbc412312c318..8cee1e946e1b2b8a773ea50aeb25724e71241249 100644 (file)
@@ -43,6 +43,48 @@ MenuHandle NewUniqueMenu()
   return handle ;
 }
 
+#if USE_HICOMBOBOX
+static const EventTypeSpec eventList[] =
+{
+    { kEventClassTextField , kEventTextAccepted } ,
+} ;
+
+static pascal OSStatus wxMacComboBoxEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+{
+    OSStatus result = eventNotHandledErr ;
+    wxComboBox* cb = (wxComboBox*) data ;
+    
+    wxMacCarbonEvent cEvent( event ) ;
+
+    switch( cEvent.GetClass() )
+    {
+        case kEventClassTextField :
+            switch( cEvent.GetKind() )
+            {
+                case kEventTextAccepted :
+                    {
+                        wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, cb->GetId() );
+                        event.SetInt( cb->GetSelection() );
+                        event.SetString( cb->GetStringSelection() );
+                        event.SetEventObject( cb );
+                        cb->GetEventHandler()->ProcessEvent( event );
+                    }
+                    break ;
+                default :
+                    break ;
+            }
+            break ;
+        default :
+            break ;
+    }
+    
+
+    return result ;
+}
+
+DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacComboBoxEventHandler )
+
+#endif
 
 // ----------------------------------------------------------------------------
 // constants
@@ -339,12 +381,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
     //hiRect.size.height = bounds.bottom - bounds.top;
     //printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom);
        //printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height);
-    verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, (HIViewRef*) &m_macControl) );
+       m_peer = new wxMacControl() ;
+    verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, *m_peer ) );
+    
 
-    SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
-    SetControl32BitMaximum( (ControlRef) m_macControl , 100) ;
+    SetControl32BitMinimum( *m_peer , 0 ) ;
+    SetControl32BitMaximum( *m_peer , 100) ;
     if ( n > 0 )
-        SetControl32BitValue( (ControlRef) m_macControl , 1 ) ;
+        SetControl32BitValue( *m_peer , 1 ) ;
     
     MacPostControlCreate(pos,size) ;
     
@@ -353,8 +397,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
         DoAppend( choices[ i ] );
     }
     
-    HIViewSetVisible( (HIViewRef) m_macControl, true );
+    HIViewSetVisible( *m_peer, true );
     SetSelection(0);
+    EventHandlerRef comboEventHandler ;
+    InstallControlEventHandler( *m_peer, GetwxMacComboBoxEventHandlerUPP(),
+        GetEventTypeCount(eventList), eventList, this, 
+        (EventHandlerRef *)&comboEventHandler);
 #else
     m_choice = new wxComboBoxChoice(this, style );
 
@@ -390,7 +438,7 @@ wxString wxComboBox::GetValue() const
 {
 #if USE_HICOMBOBOX
     CFStringRef myString;
-    HIComboBoxCopyTextItemAtIndex( (HIViewRef) m_macControl, (CFIndex)GetSelection(), &myString );
+    HIComboBoxCopyTextItemAtIndex( *m_peer, (CFIndex)GetSelection(), &myString );
     return wxMacCFStringHolder( myString, m_font.GetEncoding() ).AsString();
 #else
     wxString        result;
@@ -509,8 +557,8 @@ int wxComboBox::DoAppend(const wxString& item)
 {
 #if USE_HICOMBOBOX
     CFIndex outIndex;
-    HIComboBoxAppendTextItem( (HIViewRef) m_macControl, wxMacCFStringHolder( item, m_font.GetEncoding() ), &outIndex );
-    //SetControl32BitMaximum( (HIViewRef) m_macControl, GetCount() );
+    HIComboBoxAppendTextItem( *m_peer, wxMacCFStringHolder( item, m_font.GetEncoding() ), &outIndex );
+    //SetControl32BitMaximum( *m_peer, GetCount() );
     return (int) outIndex;
 #else
     return m_choice->DoAppend( item ) ;
@@ -520,9 +568,9 @@ int wxComboBox::DoAppend(const wxString& item)
 int wxComboBox::DoInsert(const wxString& item, int pos) 
 {
 #if USE_HICOMBOBOX
-    HIComboBoxInsertTextItemAtIndex( (HIViewRef) m_macControl, (CFIndex)pos, wxMacCFStringHolder(item, m_font.GetEncoding()) );
+    HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex)pos, wxMacCFStringHolder(item, m_font.GetEncoding()) );
     
-    //SetControl32BitMaximum( (HIViewRef) m_macControl, GetCount() );
+    //SetControl32BitMaximum( *m_peer, GetCount() );
     
     return pos;
 #else
@@ -580,7 +628,7 @@ void wxComboBox::FreeData()
 
 int wxComboBox::GetCount() const {
 #if USE_HICOMBOBOX
-       return (int) HIComboBoxGetItemCount( (HIViewRef) m_macControl );
+       return (int) HIComboBoxGetItemCount( *m_peer );
 #else
        return m_choice->GetCount() ; 
 #endif
@@ -589,7 +637,7 @@ int wxComboBox::GetCount() const {
 void wxComboBox::Delete(int n)
 {
 #if USE_HICOMBOBOX
-    HIComboBoxRemoveItemAtIndex( (HIViewRef) m_macControl, (CFIndex)n );
+    HIComboBoxRemoveItemAtIndex( *m_peer, (CFIndex)n );
 #else
     // force client object deletion
     if( HasClientObjectData() )
@@ -603,11 +651,8 @@ void wxComboBox::Clear()
     FreeData();
 #if USE_HICOMBOBOX
     for ( CFIndex i = GetCount() - 1 ; i >= 0 ; ++ i )
-        verify_noerr( HIComboBoxRemoveItemAtIndex( (HIViewRef) m_macControl, i ) );
-    wxMacCFStringHolder cf(wxEmptyString,m_font.GetEncoding()) ;
-    CFStringRef cfr = cf ;
-    SetControlData((ControlRef) m_macControl,kHIComboBoxEditTextPart,kControlEditTextCFStringTag, 
-           sizeof(CFStringRef),(Ptr) &cfr);
+        verify_noerr( HIComboBoxRemoveItemAtIndex( *m_peer, i ) );
+    m_peer->SetData<CFStringRef>(kHIComboBoxEditTextPart,kControlEditTextCFStringTag,CFSTR(""));
 #else
     m_choice->Clear();
 #endif
@@ -625,7 +670,7 @@ int wxComboBox::GetSelection() const
 void wxComboBox::SetSelection(int n)
 {
 #if USE_HICOMBOBOX
-    SetControl32BitValue( (ControlRef) m_macControl , n + 1 ) ;
+    SetControl32BitValue( *m_peer , n + 1 ) ;
 #else
     m_choice->SetSelection( n );
     
@@ -654,7 +699,7 @@ wxString wxComboBox::GetString(int n) const
 {
 #if USE_HICOMBOBOX
     CFStringRef itemText;
-    HIComboBoxCopyTextItemAtIndex( (HIViewRef) m_macControl, (CFIndex)n, &itemText );
+    HIComboBoxCopyTextItemAtIndex( *m_peer, (CFIndex)n, &itemText );
     return wxMacCFStringHolder(itemText).AsString();
 #else
     return m_choice->GetString( n );
@@ -664,12 +709,7 @@ wxString wxComboBox::GetString(int n) const
 wxString wxComboBox::GetStringSelection() const
 {
 #if USE_HICOMBOBOX
-    CFStringRef cfr ;
-    verify_noerr(GetControlData((ControlRef) m_macControl,kHIComboBoxEditTextPart,kControlEditTextCFStringTag, 
-           sizeof(CFStringRef),(Ptr) &cfr,NULL));
-    // takes of release responsibility
-    wxMacCFStringHolder cf( cfr ) ;
-    return cf.AsString() ;
+    return wxMacCFStringHolder(m_peer->GetData<CFStringRef>(kHIComboBoxEditTextPart,kControlEditTextCFStringTag)).AsString() ;
 #else
     int sel = GetSelection ();
     if (sel > -1)
@@ -694,9 +734,9 @@ bool wxComboBox::SetStringSelection(const wxString& sel)
 void wxComboBox::SetString(int n, const wxString& s) 
 {
 #if USE_HICOMBOBOX
-    verify_noerr ( HIComboBoxInsertTextItemAtIndex( (HIViewRef) m_macControl, (CFIndex) n, 
+    verify_noerr ( HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex) n, 
         wxMacCFStringHolder(s, m_font.GetEncoding()) ) );
-    verify_noerr ( HIComboBoxRemoveItemAtIndex( (HIViewRef) m_macControl, (CFIndex) n + 1 ) );
+    verify_noerr ( HIComboBoxRemoveItemAtIndex( *m_peer, (CFIndex) n + 1 ) );
 #else
     m_choice->SetString( n , s ) ;
 #endif
index ba7d6a7a3cee2c0c8619c3e280bff04949b27fc8..39f3a344d2072de468465bac34b38db0f7b58ad1 100644 (file)
@@ -85,7 +85,7 @@ bool wxControl::ProcessCommand (wxCommandEvent & event)
 
 void  wxControl::OnKeyDown( wxKeyEvent &event ) 
 {
-    if ( (ControlRef) m_macControl == NULL )
+    if ( m_peer == NULL || !m_peer->Ok() )
         return ;
     
 #if TARGET_CARBON
@@ -98,7 +98,7 @@ void  wxControl::OnKeyDown( wxKeyEvent &event )
     GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL,  sizeof(UInt32), NULL, &keyCode );
        GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
 
-    ::HandleControlKey( (ControlRef) m_macControl , keyCode , charCode , modifiers ) ;
+    ::HandleControlKey( *m_peer , keyCode , charCode , modifiers ) ;
     
 #else
     EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
@@ -107,7 +107,7 @@ void  wxControl::OnKeyDown( wxKeyEvent &event )
     keychar = short(ev->message & charCodeMask);
     keycode = short(ev->message & keyCodeMask) >> 8 ;
 
-    ::HandleControlKey( (ControlRef) m_macControl , keycode , keychar , ev->modifiers ) ;
+    ::HandleControlKey( *m_peer , keycode , keychar , ev->modifiers ) ;
 #endif
 }
 
index 36abf248dce06f070f3e0bd00b6a83d9a43fc1fc..bfdbe410dce810c2949f8b9908ae499f54ebb75d 100644 (file)
@@ -30,66 +30,52 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
            const wxString& name)
 {
     m_macIsUserPane = FALSE ;
-    
+
     if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) )
         return false;
 
     wxSize size = s ;
 
-    m_rangeMax = range ;
-    m_gaugePos = 0 ;
-    
     if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
     {
         size = wxSize( 200 , 16 ) ;
     }
     
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 
-     m_gaugePos , 0 , m_rangeMax , false /* not indeterminate */ , (ControlRef*) &m_macControl ) ) ;
+     GetValue() , 0 , GetRange() , false /* not indeterminate */ , *m_peer ) );
+    
        
     MacPostControlCreate(pos,size) ;
     
     return TRUE;
 }
 
-void wxGauge::SetShadowWidth(int w)
-{
-}
-
-void wxGauge::SetBezelFace(int w)
-{
-}
-
 void wxGauge::SetRange(int r)
 {
-    m_rangeMax = r;
-    ::SetControl32BitMaximum( (ControlRef) m_macControl , m_rangeMax ) ;
+    // we are going via the base class in case there is 
+    // some change behind the values by it
+    wxGaugeBase::SetRange(r) ;
+    if ( m_peer && m_peer->Ok() )
+        m_peer->SetMaximum( GetRange() ) ;
 }
 
 void wxGauge::SetValue(int pos)
 {
-    m_gaugePos = pos;
-       ::SetControl32BitValue( (ControlRef) m_macControl , m_gaugePos ) ;
-}
-
-int wxGauge::GetShadowWidth() const
-{
-    return 0;
-}
-
-int wxGauge::GetBezelFace() const
-{
-    return 0;
-}
-
-int wxGauge::GetRange() const
-{
-    return m_rangeMax;
+    // we are going via the base class in case there is 
+    // some change behind the values by it
+    wxGaugeBase::SetValue(pos) ;
+    if ( m_peer && m_peer->Ok() )
+        m_peer->SetValue( GetValue() ) ;
 }
 
 int wxGauge::GetValue() const
 {
-    return m_gaugePos;
+/*
+    if ( m_peer && m_peer->Ok() )
+        return m_peer->GetValue() ;
+*/
+    return m_gaugePos ;
 }
 
index 50e9f4445f58a2db943b4b52e8be048b14a65138..361bc4def7de3a2a6ff0e01fefb9be50f5f31807 100644 (file)
@@ -175,10 +175,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
     
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-    ControlRef browser ;
 
-    verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , (ControlRef *)&m_macControl ) );
-    browser = (ControlRef) m_macControl ;
+    m_peer = new wxMacControl() ;
+    verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , *m_peer ) );
 
     DataBrowserSelectionFlags  options = kDataBrowserDragSelect ;
     if ( style & wxLB_MULTIPLE )
@@ -193,7 +192,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
     {
         options += kDataBrowserSelectOnlyOne ;
     }
-    verify_noerr(SetDataBrowserSelectionFlags  (browser, options ) ); 
+    verify_noerr(SetDataBrowserSelectionFlags  (*m_peer, options ) ); 
 
     DataBrowserListViewColumnDesc columnDesc ;
     columnDesc.headerBtnDesc.titleOffset = 0;
@@ -221,11 +220,11 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
         kDataBrowserTableViewSelectionColumn ;
 
        
-       verify_noerr(::AddDataBrowserListViewColumn(browser, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
-    verify_noerr(::AutoSizeDataBrowserListViewColumns( browser ) ) ;
-    verify_noerr(::SetDataBrowserHasScrollBars( browser , false , true ) ) ;
-    verify_noerr(::SetDataBrowserTableViewHiliteStyle( browser, kDataBrowserTableViewFillHilite  ) ) ;
-    verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( browser , 0 ) ) ;
+       verify_noerr(::AddDataBrowserListViewColumn(*m_peer, &columnDesc, kDataBrowserListViewAppendColumn) ) ;
+    verify_noerr(::AutoSizeDataBrowserListViewColumns( *m_peer ) ) ;
+    verify_noerr(::SetDataBrowserHasScrollBars( *m_peer , false , true ) ) ;
+    verify_noerr(::SetDataBrowserTableViewHiliteStyle( *m_peer, kDataBrowserTableViewFillHilite  ) ) ;
+    verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( *m_peer , 0 ) ) ;
     DataBrowserCallbacks callbacks ;
     
     callbacks.version = kDataBrowserLatestCallbacks;
@@ -241,7 +240,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
 #else
            NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc) ;
 #endif
-    SetDataBrowserCallbacks(browser, &callbacks);
+    SetDataBrowserCallbacks(*m_peer, &callbacks);
 
     MacPostControlCreate(pos,size) ;
 
@@ -257,7 +256,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
 
 wxListBox::~wxListBox()
 {
-    SetControlReference( (ControlRef) m_macControl , NULL ) ;
+    SetControlReference( *m_peer , NULL ) ;
     FreeData() ;
     // avoid access during destruction
     if ( m_macList )
@@ -626,27 +625,27 @@ wxOwnerDrawn *wxListBox::CreateItem(size_t n)
 void wxListBox::MacDelete( int N )
 {
     UInt32 id = m_idArray[N] ;
-    verify_noerr(::RemoveDataBrowserItems((ControlRef) m_macControl , kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) ) ;
+    verify_noerr(::RemoveDataBrowserItems(*m_peer , kDataBrowserNoItem , 1 , (UInt32*) &id , kDataBrowserItemNoProperty ) ) ;
     m_idArray.RemoveAt( N ) ;
 }
 
 void wxListBox::MacInsert( int n , const wxString& text)
 {
-    verify_noerr(::AddDataBrowserItems( (ControlRef) m_macControl , kDataBrowserNoItem , 1 , (UInt32*) &m_nextId , kDataBrowserItemNoProperty ) ) ;
+    verify_noerr(::AddDataBrowserItems( *m_peer , kDataBrowserNoItem , 1 , (UInt32*) &m_nextId , kDataBrowserItemNoProperty ) ) ;
     m_idArray.Insert( m_nextId , n ) ;
     ++m_nextId ;
 }
 
 void wxListBox::MacAppend( const wxString& text)
 {
-    verify_noerr(::AddDataBrowserItems( (ControlRef) m_macControl , kDataBrowserNoItem , 1 , (UInt32*) &m_nextId , kDataBrowserItemNoProperty ) ) ;
+    verify_noerr(::AddDataBrowserItems( *m_peer , kDataBrowserNoItem , 1 , (UInt32*) &m_nextId , kDataBrowserItemNoProperty ) ) ;
     m_idArray.Add( m_nextId ) ;
     ++m_nextId ;
 }
 
 void wxListBox::MacClear()
 {
-    verify_noerr(::RemoveDataBrowserItems((ControlRef) m_macControl , kDataBrowserNoItem , 0 , NULL , kDataBrowserItemNoProperty ) ) ;
+    verify_noerr(::RemoveDataBrowserItems(*m_peer , kDataBrowserNoItem , 0 , NULL , kDataBrowserItemNoProperty ) ) ;
     m_idArray.Empty() ;
 }
 
@@ -659,26 +658,26 @@ void wxListBox::MacSetSelection( int n , bool select )
         if ( n >= 0 )
         {
             UInt32 idOld = m_idArray[n] ;
-            SetDataBrowserSelectedItems((ControlRef) m_macControl , 1 , & idOld , kDataBrowserItemsRemove ) ;
+            SetDataBrowserSelectedItems(*m_peer , 1 , & idOld , kDataBrowserItemsRemove ) ;
         }
     }
-    if ( ::IsDataBrowserItemSelected( (ControlRef) m_macControl , id ) != select )
+    if ( ::IsDataBrowserItemSelected( *m_peer , id ) != select )
     {
-        verify_noerr(::SetDataBrowserSelectedItems((ControlRef) m_macControl , 1 , & id , kDataBrowserItemsToggle ) ) ;
+        verify_noerr(::SetDataBrowserSelectedItems(*m_peer , 1 , & id , kDataBrowserItemsToggle ) ) ;
     }
     MacScrollTo( n ) ;
 }
 
 bool wxListBox::MacIsSelected( int n ) const
 {
-    return ::IsDataBrowserItemSelected( (ControlRef) m_macControl , m_idArray[n] ) ;
+    return ::IsDataBrowserItemSelected( *m_peer , m_idArray[n] ) ;
 }
 
 int wxListBox::MacGetSelection() const
 {
     for ( size_t i = 0 ; i < m_idArray.GetCount() ; ++i )
     {
-        if ( ::IsDataBrowserItemSelected((ControlRef) m_macControl , m_idArray[i] ) )
+        if ( ::IsDataBrowserItemSelected(*m_peer , m_idArray[i] ) )
         {
             return i ;
         }
@@ -693,7 +692,7 @@ int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
     aSelections.Empty();
     for ( size_t i = 0 ; i < m_idArray.GetCount() ; ++i )
     {
-        if ( ::IsDataBrowserItemSelected((ControlRef) m_macControl , m_idArray[i] ) )
+        if ( ::IsDataBrowserItemSelected(*m_peer , m_idArray[i] ) )
         {
             aSelections.Add( i ) ;
             no_sel++ ;
@@ -706,13 +705,13 @@ void wxListBox::MacSet( int n , const wxString& text )
 {
     // as we don't store the strings we only have to issue a redraw
     UInt32 id = m_idArray[n] ;
-    verify_noerr( ::UpdateDataBrowserItems( (ControlRef) m_macControl , kDataBrowserNoItem , 1 , &id , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ;
+    verify_noerr( ::UpdateDataBrowserItems( *m_peer , kDataBrowserNoItem , 1 , &id , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ;
 }
 
 void wxListBox::MacScrollTo( int n )
 {
     UInt32 id = m_idArray[n] ;
-    verify_noerr( ::RevealDataBrowserItem((ControlRef) m_macControl , id , kTextColumnId , kDataBrowserRevealWithoutSelecting ) ) ;
+    verify_noerr( ::RevealDataBrowserItem(*m_peer , id , kTextColumnId , kDataBrowserRevealWithoutSelecting ) ) ;
 }
 
 #if !TARGET_API_MAC_OSX
index cee99d8c80d1e67f9a76bb75fd0ae71cded98c68..4867e34272abb377281da5907abe4d40c8f968c3 100644 (file)
@@ -125,8 +125,10 @@ bool wxNotebook::Create(wxWindow *parent,
             tabsize = kControlSizeSmall; 
     }
 
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
-     tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl) ); 
+     tabsize , tabstyle, 0, NULL,  *m_peer ) );
+    
     
     MacPostControlCreate(pos,size) ;
     return TRUE ;
@@ -329,7 +331,7 @@ bool wxNotebook::InsertPage(size_t nPage,
     {
         m_nSelection++;
         // while this still is the same page showing, we need to update the tabs
-        SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
+        SetControl32BitValue( *m_peer , m_nSelection + 1 ) ;
     }
     
     // some page should be selected: either this one or the first one if there
@@ -348,12 +350,12 @@ bool wxNotebook::InsertPage(size_t nPage,
 
 /* Added by Mark Newsam
 * When a page is added or deleted to the notebook this function updates
-* information held in the m_macControl so that it matches the order
+* information held in the control so that it matches the order
 * the user would expect.
 */
 void wxNotebook::MacSetupTabs()
 {
-    SetControl32BitMaximum( (ControlRef) m_macControl , GetPageCount() ) ;
+    SetControl32BitMaximum( *m_peer , GetPageCount() ) ;
 
     wxNotebookPage *page;
     ControlTabInfoRec info;
@@ -366,9 +368,9 @@ void wxNotebook::MacSetupTabs()
         info.iconSuiteID = 0;
         wxMacStringToPascal( page->GetLabel() , info.name ) ;
 
-        SetControlData( (ControlRef) m_macControl, ii+1, kControlTabInfoTag,
+        SetControlData( *m_peer, ii+1, kControlTabInfoTag,
             sizeof( ControlTabInfoRec) , (char*) &info ) ;
-        SetTabEnabled( (ControlRef) m_macControl , ii+1 , true ) ;
+        SetTabEnabled( *m_peer , ii+1 , true ) ;
 #if TARGET_CARBON
         if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
         {
@@ -397,7 +399,7 @@ void wxNotebook::MacSetupTabs()
                 wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
                 info.contentType = kControlContentIconRef ;
                 info.u.iconRef = iconRef ;
-                SetControlData( (ControlRef) m_macControl, ii+1,kControlTabImageContentTag,
+                SetControlData( *m_peer, ii+1,kControlTabImageContentTag,
                     sizeof( info ), (Ptr)&info );
                 wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
                 if ( UMAGetSystemVersion() < 0x1030 )
@@ -412,7 +414,7 @@ void wxNotebook::MacSetupTabs()
 #endif
     }
     Rect bounds;
-    UMAGetControlBoundsInWindowCoords((ControlRef)m_macControl, &bounds);
+    UMAGetControlBoundsInWindowCoords(*m_peer, &bounds);
     InvalWindowRect((WindowRef)MacGetTopLevelWindowRef(), &bounds);
 }
 
@@ -564,14 +566,14 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
     }
     
     m_nSelection = nSel;
-    SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
+    SetControl32BitValue( *m_peer , m_nSelection + 1 ) ;
 }
 
 wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) 
 {
     OSStatus status = eventNotHandledErr ;
     
-    SInt32 newSel = GetControl32BitValue( (ControlRef) m_macControl ) - 1 ;
+    SInt32 newSel = GetControl32BitValue( *m_peer ) - 1 ;
     if ( newSel != m_nSelection )
     {
         wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
@@ -589,7 +591,7 @@ wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTR
         }
         else
         {
-            SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
+            SetControl32BitValue( *m_peer , m_nSelection + 1 ) ;
         }
         status = noErr ;
     }
index cf279d567ba81d2069537a4805926b516a02f212..0fbd9fa5f1a2613e8ff188777c46ff56fe739f31 100644 (file)
@@ -137,8 +137,10 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
     if ( bounds.bottom <= bounds.top )
         bounds.bottom = bounds.top + 100 ;
    
+    m_peer = new wxMacControl() ;
+    
     verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , 
-        true /*primary*/ , (ControlRef*)&m_macControl ) ) ;  
+        true /*primary*/ , *m_peer ) ) ;  
     
     for (i = 0; i < n; i++)
     {
index 32ad08047ec36a54ca5b90eed613b63db1de193f..eb8423fa8e7eb16744abec65707562cf5c26e7ed 100644 (file)
@@ -39,8 +39,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
     
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 
-        0 , false /* no autotoggle */ , (ControlRef*) &m_macControl ) ) ;
+        0 , false /* no autotoggle */ , *m_peer ) );
+    
 
     MacPostControlCreate(pos,size) ;
 
@@ -73,10 +75,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
 void wxRadioButton::SetValue(bool val)
 {
     wxRadioButton *cycle;
-      if ( GetControl32BitValue( (ControlRef) m_macControl ) == val )
+      if ( GetControl32BitValue( *m_peer ) == val )
         return ;
         
-   ::SetControl32BitValue( (ControlRef) m_macControl , val ) ;
+   ::SetControl32BitValue( *m_peer , val ) ;
    if (val) 
    {
            cycle=this->NextInCycle();
@@ -92,7 +94,7 @@ void wxRadioButton::SetValue(bool val)
 
 bool wxRadioButton::GetValue() const
 {
-    return ::GetControl32BitValue( (ControlRef) m_macControl ) ;
+    return ::GetControl32BitValue( *m_peer ) ;
 }
 
 void wxRadioButton::Command (wxCommandEvent & event)
index 08818c04704638f12cb8124264fac6f8bd814775..c5a74bc2f4ca3bf55109e693028b121cca9a0fb2 100644 (file)
@@ -47,8 +47,10 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
 
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateScrollBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 
-    0 , 0 , 100 , 1 , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , (ControlRef*) &m_macControl ) ) ;
+    0 , 0 , 100 , 1 , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , *m_peer ) );
+    
 
     MacPostControlCreate(pos,size) ;
 
@@ -61,12 +63,12 @@ wxScrollBar::~wxScrollBar()
 
 void wxScrollBar::SetThumbPosition(int viewStart)
 {
-    ::SetControl32BitValue( (ControlRef) m_macControl , viewStart ) ;
+    ::SetControl32BitValue( *m_peer , viewStart ) ;
 }
 
 int wxScrollBar::GetThumbPosition() const
 {
-    return ::GetControl32BitValue( (ControlRef) m_macControl ) ;
+    return ::GetControl32BitValue( *m_peer ) ;
 }
 
 void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
@@ -78,10 +80,10 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
 
    int range1 = wxMax((m_objectSize - m_viewSize), 0) ;
 
-    SetControl32BitMaximum( (ControlRef) m_macControl , range1 ) ;
-    SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
-    SetControl32BitValue( (ControlRef) m_macControl , position ) ;
-    SetControlViewSize( (ControlRef) m_macControl , m_viewSize ) ;
+    SetControl32BitMaximum( *m_peer , range1 ) ;
+    SetControl32BitMinimum( *m_peer , 0 ) ;
+    SetControl32BitValue( *m_peer , position ) ;
+    SetControlViewSize( *m_peer , m_viewSize ) ;
 
     if ( refresh )
       MacRedrawControl() ;
@@ -96,9 +98,9 @@ void wxScrollBar::Command(wxCommandEvent& event)
 
 void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) 
 {
-    int position = GetControl32BitValue( (ControlRef) m_macControl) ;
-    int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
-    int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
+    int position = GetControl32BitValue( *m_peer) ;
+    int minPos = GetControl32BitMinimum( *m_peer) ;
+    int maxPos = GetControl32BitMaximum( *m_peer) ;
     
     wxEventType scrollEvent = wxEVT_NULL;
     int nScrollInc = 0;
@@ -169,9 +171,9 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart
 
 wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) 
 {
-    int position = GetControl32BitValue( (ControlRef) m_macControl) ;
-    int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
-    int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
+    int position = GetControl32BitValue( *m_peer) ;
+    int minPos = GetControl32BitMinimum( *m_peer) ;
+    int maxPos = GetControl32BitMaximum( *m_peer) ;
     
     wxEventType scrollEvent = wxEVT_NULL;
     int nScrollInc = 0;
index d1dd3ee950fd570c6a5f04c7ee7677f84cec35bb..2be371444641cf9dd0b1a0f0fd702c09d120971d 100644 (file)
@@ -81,9 +81,11 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
     if ( style & wxSL_AUTOTICKS )
         tickMarks = maxValue - minValue ;
         
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 
     value , minValue , maxValue , kControlSliderPointsDownOrRight , tickMarks , true /* liveTracking */ ,
-        wxMacLiveScrollbarActionUPP , (ControlRef*) &m_macControl ) ) ;
+        wxMacLiveScrollbarActionUPP , *m_peer ) );
+    
         
     if(style & wxSL_VERTICAL) {
         SetSizeHints(10, -1, 10, -1);  // Forces SetSize to use the proper width
@@ -118,7 +120,7 @@ wxSlider::~wxSlider()
 
 int wxSlider::GetValue() const
 {
-    return GetControl32BitValue( (ControlRef) m_macControl) ;
+    return GetControl32BitValue( *m_peer) ;
 }
 
 void wxSlider::SetValue(int value)
@@ -127,7 +129,7 @@ void wxSlider::SetValue(int value)
     valuestring.Printf( wxT("%d") , value ) ;    
     if ( m_macValueStatic )
         m_macValueStatic->SetLabel( valuestring ) ;
-    SetControl32BitValue( (ControlRef) m_macControl , value ) ;
+    SetControl32BitValue( *m_peer , value ) ;
 }
 
 void wxSlider::SetRange(int minValue, int maxValue)
@@ -137,8 +139,8 @@ void wxSlider::SetRange(int minValue, int maxValue)
     m_rangeMin = minValue;
     m_rangeMax = maxValue;
     
-    SetControl32BitMinimum( (ControlRef) m_macControl, m_rangeMin);
-    SetControl32BitMaximum( (ControlRef) m_macControl, m_rangeMax);
+    SetControl32BitMinimum( *m_peer, m_rangeMin);
+    SetControl32BitMaximum( *m_peer, m_rangeMax);
     
     if(m_macMinimumStatic) {
         value.Printf(wxT("%d"), m_rangeMin);
@@ -232,7 +234,7 @@ void wxSlider::Command (wxCommandEvent & event)
 
 void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) 
 {
-    SInt16 value = ::GetControl32BitValue( (ControlRef) m_macControl ) ;
+    SInt16 value = ::GetControl32BitValue( *m_peer ) ;
     
     SetValue( value ) ;        
     
@@ -254,7 +256,7 @@ void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bo
 
 wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) 
 {
-    SInt16 value = ::GetControl32BitValue( (ControlRef) m_macControl ) ;
+    SInt16 value = ::GetControl32BitValue( *m_peer ) ;
     
     SetValue( value ) ;        
     
index 7e8de83b09c60c7d45c2692c9f66947f6f5aaf5b..526eaacd7bb71a43bcbd9adb68819c882b74a18c 100644 (file)
@@ -54,9 +54,11 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
     
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
         
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 ,
-     (ControlRef*) &m_macControl ) ) ;
-    SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
+     *m_peer ) );
+    
+    SetControlAction( *m_peer , wxMacLiveScrollbarActionUPP ) ;
     MacPostControlCreate(pos,size) ;
     
     return TRUE;
@@ -93,8 +95,8 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
 {
     m_min = minVal;
     m_max = maxVal;
-    SetControl32BitMaximum( (ControlRef) m_macControl , maxVal ) ;
-    SetControl32BitMinimum((ControlRef) m_macControl , minVal ) ;
+    SetControl32BitMaximum( *m_peer , maxVal ) ;
+    SetControl32BitMinimum(*m_peer , minVal ) ;
 }
 
 void wxSpinButton::MacHandleValueChanged( int inc )
@@ -137,7 +139,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
     {
         m_value = oldValue ;
     }
-    SetControl32BitValue( (ControlRef) m_macControl , m_value ) ;
+    SetControl32BitValue( *m_peer , m_value ) ;
     
     /* always send a thumbtrack event */
     if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
index 870154ebba917a0cd88953fe0d0b1b6e4c28d7d1..d25be44dabef238a432710dac46b50f67bd37fec 100644 (file)
@@ -43,8 +43,9 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
     
+    m_peer = new wxMacControl() ;
     verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , 
-        true /*primary*/ , (ControlRef*)&m_macControl ) ) ;  
+        true /*primary*/ , *m_peer ) ) ;  
 
     MacPostControlCreate(pos,size) ;
     
index d13f45e35e26984f5343a7c5def9a0a8ad5bedf5..cf9f999fa0e3dd1bf1236a4ab59182e00ed5b0c9 100644 (file)
@@ -56,7 +56,8 @@ bool wxStaticLine::Create( wxWindow *parent,
         return false;
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-    verify_noerr(CreateSeparatorControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, (ControlRef*)&m_macControl ) ) ;  
+    m_peer = new wxMacControl() ;
+    verify_noerr(CreateSeparatorControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, *m_peer ) ) ;  
 
     MacPostControlCreate(pos,size) ;
 
index e2bd22ed23209477b5493424df7809f5e04bff95..f4757d19d7c223c2b853c4ac0779efdf3f3f55f1 100644 (file)
@@ -49,8 +49,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
     wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
+    m_peer = new wxMacControl() ;
     verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str , 
-        NULL , (ControlRef*)&m_macControl ) ) ;  
+        NULL , *m_peer ) ) ;  
 
     MacPostControlCreate(pos,size) ;
 
@@ -61,7 +62,7 @@ wxSize wxStaticText::DoGetBestSize() const
 {
     ControlFontStyleRec controlFont ;
     Size outSize ;
-    verify_noerr( GetControlData( (ControlRef) m_macControl , kControlEntireControl , kControlFontStyleTag , sizeof(controlFont) , &controlFont , &outSize ) ) ;
+    verify_noerr( GetControlData( *m_peer , kControlEntireControl , kControlFontStyleTag , sizeof(controlFont) , &controlFont , &outSize ) ) ;
     
     Point bounds ;
     SInt16 baseline ;
@@ -88,7 +89,7 @@ void wxStaticText::SetLabel(const wxString& st )
     
     wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
     CFStringRef ref = str ;
-    SetControlData( (ControlRef) m_macControl, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ),
+    SetControlData( *m_peer, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ),
                &ref );
 
     if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
index e96fb25f807e21866b7c4a03a36326d4de389539..677dd1ae910d024d0a1e07b1c49dd0742bb688c1 100644 (file)
@@ -56,8 +56,10 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
             tabsize = kControlSizeSmall; 
     }
     
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
-     tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl) ); 
+     tabsize , tabstyle, 0, NULL,  *m_peer ) );
+    
 
     MacPostControlCreate(pos,size) ;
     return TRUE ;
index a522f2e9e9edba7926bf7663970a27cbe77dd467..100978c50f2c3012c993102e35e9b9526eb1ac26 100644 (file)
@@ -738,7 +738,7 @@ void wxTextCtrl::Init()
 wxTextCtrl::~wxTextCtrl()
 {
 #if wxMAC_USE_MLTE
-    SetControlReference((ControlRef)m_macControl, 0) ;
+    SetControlReference(*m_peer, 0) ;
 #if !wxMAC_USE_MLTE_HIVIEW
     TXNDeleteObject((TXNObject)m_macTXN);
 #endif
@@ -803,11 +803,11 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
         if ( scrollView )
         {
             HIViewAddSubview( scrollView , textView ) ;
-            m_macControl = (WXWidget) scrollView ;
+            m_peer = scrollView ;
         }
         else
         {
-            m_macControl = (WXWidget) textView ;
+            m_peer = textView ;
         }
 #else
         short featurSet;
@@ -816,11 +816,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
                 | kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground
                 | kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
             /* create the control */
-        verify_noerr( CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, featurSet , (ControlRef*) &m_macControl) ) ;
+        m_peer = new wxMacControl() ;
+        verify_noerr( CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, featurSet , , *m_peer ) );
+    ) ) ;
         
         wxMacWindowClipper c(this) ;
         STPTextPaneVars *varsp ;
-        mUPOpenControl( varsp, (ControlRef) m_macControl, m_windowStyle );
+        mUPOpenControl( varsp, *m_peer, m_windowStyle );
         m_macTXNvars = varsp ;
         m_macTXN =  varsp->fTXNRec ;
 #endif
@@ -841,7 +843,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     {
        wxMacWindowClipper clipper( this ) ;
 #if !wxMAC_USE_MLTE_HIVIEW
-        TPUpdateVisibility( (ControlRef) m_macControl ) ;
+        TPUpdateVisibility( *m_peer ) ;
 #endif
         SetTXNData( (STPTextPaneVars *)m_macTXNvars , (TXNObject) m_macTXN , st , kTXNStartOffset, kTXNEndOffset ) ;
 
@@ -863,11 +865,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     wxMacCFStringHolder cf(st , m_font.GetEncoding()) ;
     CFStringRef cfr = cf ;
     Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
-    CreateEditUnicodeTextControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , cfr , isPassword , NULL , (ControlRef*) &m_macControl ) ;
+    m_peer = new wxMacControl() ;
+    CreateEditUnicodeTextControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , cfr , isPassword , NULL , *m_peer ) ;
+    
     if ( !(m_windowStyle & wxTE_MULTILINE) )
     {
         Boolean singleline = true ;
-        ::SetControlData( (ControlHandle) m_macControl, kControlEditTextPart , kControlEditTextSingleLineTag , sizeof( singleline ) , &singleline ) ;
+        ::SetControlData( *m_peer, kControlEditTextPart , kControlEditTextSingleLineTag , sizeof( singleline ) , &singleline ) ;
     }
     MacPostControlCreate(pos,size) ;
     
@@ -887,7 +891,7 @@ void wxTextCtrl::MacVisibilityChanged()
 #if !wxMAC_USE_MLTE_HIVIEW
     MLTESetObjectVisibility((STPTextPaneVars*) m_macTXNvars , MacIsReallyShown() , GetWindowStyle() ) ;
     if ( !MacIsReallyShown() )
-        InvalWindowRect( GetControlOwner( (ControlHandle) m_macControl ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ;
+        InvalWindowRect( GetControlOwner( *m_peer ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ;
 #endif
 #else
     if ( !(m_windowStyle & wxTE_MULTILINE) && MacIsReallyShown() )
@@ -899,12 +903,12 @@ void wxTextCtrl::MacVisibilityChanged()
         ResType datatag = GetWindowStyle() & wxTE_PASSWORD ? 
             kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag ;
 
-        verify_noerr( GetControlData( (ControlRef) m_macControl , 0, kControlEditTextSelectionTag, 
+        verify_noerr( GetControlData( *m_peer , 0, kControlEditTextSelectionTag, 
                     sizeof(ControlEditTextSelectionRec), &sel, &actualSize ) );
-        verify_noerr( GetControlData( (ControlRef) m_macControl , 0, datatag , sizeof(CFStringRef), &value, &actualSize ) );
+        verify_noerr( GetControlData( *m_peer , 0, datatag , sizeof(CFStringRef), &value, &actualSize ) );
         
-        verify_noerr( SetControlData(  (ControlRef) m_macControl , 0, datatag, sizeof(CFStringRef), &value ) );
-        verify_noerr( SetControlData(  (ControlRef) m_macControl , 0, kControlEditTextSelectionTag, sizeof(ControlEditTextSelectionRec), &sel ) );
+        verify_noerr( SetControlData(  *m_peer , 0, datatag, sizeof(CFStringRef), &value ) );
+        verify_noerr( SetControlData(  *m_peer , 0, kControlEditTextSelectionTag, sizeof(ControlEditTextSelectionRec), &sel ) );
                         
         CFRelease( value ) ;
     }
@@ -984,7 +988,7 @@ wxString wxTextCtrl::GetValue() const
     CFStringRef value = NULL ;
     Size    actualSize = 0 ;
 
-    verify_noerr( GetControlData( (ControlRef) m_macControl , 0, GetWindowStyle() & wxTE_PASSWORD ? 
+    verify_noerr( GetControlData( *m_peer , 0, GetWindowStyle() & wxTE_PASSWORD ? 
         kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag, 
                     sizeof(CFStringRef), &value, &actualSize ) );
     if ( value )
@@ -1004,7 +1008,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
 #else
     ControlEditTextSelectionRec sel ;
     Size actualSize ;
-    verify_noerr( GetControlData( (ControlRef) m_macControl , 0, kControlEditTextSelectionTag, 
+    verify_noerr( GetControlData( *m_peer , 0, kControlEditTextSelectionTag, 
                     sizeof(ControlEditTextSelectionRec), &sel, &actualSize ) );
     if ( from ) *from = sel.selStart ;
     if ( to ) *to = sel.selEnd ;
@@ -1039,7 +1043,7 @@ void wxTextCtrl::SetValue(const wxString& str)
 #else
     wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
     CFStringRef value = cf ;
-    verify_noerr( SetControlData(  (ControlRef) m_macControl , 0, GetWindowStyle() & wxTE_PASSWORD ? 
+    verify_noerr( SetControlData(  *m_peer , 0, GetWindowStyle() & wxTE_PASSWORD ? 
         kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag, 
         sizeof(CFStringRef), &value ) );
 #endif
@@ -1167,6 +1171,8 @@ void wxTextCtrl::Copy()
         ClearCurrentScrap();
         TXNCopy((TXNObject)m_macTXN);
         TXNConvertToPublicScrap();
+#else
+        m_peer->SendHICommand( kHICommandCopy ) ;
 #endif
     }
 }
@@ -1179,6 +1185,8 @@ void wxTextCtrl::Cut()
         ClearCurrentScrap();
         TXNCut((TXNObject)m_macTXN);
         TXNConvertToPublicScrap();
+#else
+        m_peer->SendHICommand( kHICommandCut ) ;
 #endif
         wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
         event.SetString( GetValue() ) ;
@@ -1195,6 +1203,8 @@ void wxTextCtrl::Paste()
         TXNConvertFromPublicScrap();
         TXNPaste((TXNObject)m_macTXN);
         SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
+#else
+        m_peer->SendHICommand( kHICommandPaste ) ;
 #endif
         wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
         event.SetString( GetValue() ) ;
@@ -1246,7 +1256,7 @@ void wxTextCtrl::SetEditable(bool editable)
         TXNSetTXNObjectControls( (TXNObject) m_macTXN , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ;
 #else
         Boolean value = !editable ;
-        ::SetControlData( (ControlHandle) m_macControl, 0, kControlEditTextLockedTag , sizeof( value ) , &value ) ;
+        ::SetControlData( *m_peer, 0, kControlEditTextLockedTag , sizeof( value ) , &value ) ;
 #endif
     }
 }
@@ -1336,7 +1346,7 @@ void wxTextCtrl::SetSelection(long from, long to)
     ControlEditTextSelectionRec sel ;
     sel.selStart = from ;
     sel.selEnd = to ;
-    verify_noerr( SetControlData( (ControlRef) m_macControl , 0, kControlEditTextSelectionTag, 
+    verify_noerr( SetControlData( *m_peer , 0, kControlEditTextSelectionTag, 
                     sizeof(ControlEditTextSelectionRec), &sel ) );
 
 #endif
@@ -1474,7 +1484,7 @@ void wxTextCtrl::WriteText(const wxString& str)
     #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
         wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
         CFStringRef value = cf ;
-        SetControlData(  (ControlRef) m_macControl , 0, kControlEditTextInsertCFStringRefTag, 
+        SetControlData(  *m_peer , 0, kControlEditTextInsertCFStringRefTag, 
             sizeof(CFStringRef), &value );
     #else
         wxString val = GetValue() ;
@@ -1632,6 +1642,13 @@ int wxTextCtrl::GetNumberOfLines() const
     ItemCount lines = 0 ;
 #if wxMAC_USE_MLTE
     TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
+#else
+    wxString content = GetValue() ;
+    lines = 1;
+    for (size_t i = 0; i < content.Length() ; i++)
+    {
+        if (content[i] == '\r') lines++;
+    }
 #endif
     return lines ;
 }
@@ -1778,14 +1795,36 @@ int wxTextCtrl::GetLineLength(long lineNo) const
                 ++xpos ;
         }
     }
+#else
+    // TODO change this if possible to reflect real lines
+    wxString content = GetValue() ;
+
+    // Find line first
+    int count = 0;
+    for (size_t i = 0; i < content.Length() ; i++)
+    {
+        if (count == lineNo)
+        {
+            // Count chars in line then
+            count = 0;
+            for (size_t j = i; j < content.Length(); j++)
+            {
+                count++;
+                if (content[j] == '\n') return count;
+            }
+
+            return count;
+        }
+        if (content[i] == '\n') count++;
+    }
 #endif
     return 0;
 }
 
 wxString wxTextCtrl::GetLineText(long lineNo) const
 {
-    wxString line ;
 #if wxMAC_USE_MLTE
+    wxString line ;
     Point curpt ;
     wxString content = GetValue() ;
 
@@ -1823,8 +1862,34 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
             }
         }
     }
-#endif
     return line ;
+#else
+    // TODO change this if possible to reflect real lines
+    wxString content = GetValue() ;
+
+    // Find line first
+    int count = 0;
+    for (size_t i = 0; i < content.Length() ; i++)
+    {
+        if (count == lineNo)
+        {
+            // Add chars in line then
+            wxString tmp;
+
+            for (size_t j = i; j < content.Length(); j++)
+            {
+                if (content[j] == '\n')
+                    return tmp;
+
+                tmp += content[j];
+            }
+
+            return tmp;
+        }
+        if (content[i] == '\n') count++;
+    }
+    return wxEmptyString ;
+#endif
 }
 
 /*
@@ -1956,7 +2021,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
                 keychar = short(ev->message & charCodeMask);
                 keycode = short(ev->message & keyCodeMask) >> 8 ;
 
-                ::HandleControlKey( (ControlRef) m_macControl , keycode , keychar , ev->modifiers ) ;
+                ::HandleControlKey( *m_peer , keycode , keychar , ev->modifiers ) ;
             }
         }
     }
index c41c9610f3b09fb8bd9a1c396c89bf12401b3b46..909eeb4d79326e8e98d3db485504dd62ad6c1ef5 100644 (file)
@@ -65,8 +65,10 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
 
     Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
     
+    m_peer = new wxMacControl() ;
     verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 
-        kControlBevelButtonNormalBevel , kControlBehaviorToggles , NULL , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
+        kControlBevelButtonNormalBevel , kControlBehaviorToggles , NULL , 0 , 0 , 0 , *m_peer ) );
+    
     
     MacPostControlCreate(pos,size) ;
     
@@ -87,12 +89,12 @@ wxSize wxToggleButton::DoGetBestSize() const
 
 void wxToggleButton::SetValue(bool val)
 {
-    ::SetControl32BitValue( (ControlRef) m_macControl , val ) ;
+    ::SetControl32BitValue( *m_peer , val ) ;
 }
 
 bool wxToggleButton::GetValue() const
 {
-    return GetControl32BitValue( (ControlRef) m_macControl ) ;
+    return GetControl32BitValue( *m_peer ) ;
 }
 
 void wxToggleButton::Command(wxCommandEvent & event)
index e97fc6b17a40483a6c9922db00ffe3f4b784b8a1..e657e1025f32e10bfa1467d63718a96087ee5dff 100644 (file)
@@ -972,13 +972,14 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
 
     wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
     UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
+    m_peer = new wxMacControl() ;
 #if TARGET_API_MAC_OSX
     // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of 
     // the content view, so we have to retrieve it explicitely
     HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID , 
-        (ControlRef*)&m_macControl ) ;
+        *m_peer ) ;
 #else
-    ::CreateRootControl( (WindowRef)m_macWindow , (ControlRef*)&m_macControl ) ;
+    ::CreateRootControl( (WindowRef)m_macWindow , *m_peer ) ;
 #endif
     // the root control level handleer
     MacInstallEventHandler() ;
index 5c4da3a6252973b283a73290548dc52c4448c8a1..c2f1be7ea19fb143ec6a9cc57041dd0fa9bd6937 100644 (file)
@@ -1281,7 +1281,7 @@ OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType in
     return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ;   
 }
 
-OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, void * inData)
+OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData)
 {
     return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ;   
 }
@@ -1305,6 +1305,36 @@ OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size
     return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData ) ;   
 }
 
+OSStatus wxMacControl::SendEvent(  EventRef event , OptionBits inOptions ) 
+{
+    return SendEventToEventTargetWithOptions( event, 
+        HIObjectGetEventTarget( (HIObjectRef) m_controlRef ),
+               inOptions );        
+}
+
+OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions ) 
+{
+    wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess ) ;
+    event.SetParameter<HICommand>(kEventParamDirectObject,command) ;
+    return SendEvent( event , inOptions ) ;     
+}
+
+OSStatus wxMacControl::SendHICommand( UInt32 commandID , OptionBits inOptions  ) 
+{
+    HICommand command ;
+    memset( &command, 0 , sizeof(command) ) ;
+    command.commandID = commandID ;
+    return SendHICommand( command , inOptions ) ;
+}
+
+void wxMacControl::Flash( ControlPartCode part , UInt32 ticks ) 
+{
+    HiliteControl( m_controlRef , part ) ;
+    unsigned long finalTicks ;
+    Delay( ticks , &finalTicks ) ;
+    HiliteControl( m_controlRef , kControlNoPart ) ;
+}
+
 // ----------------------------------------------------------------------------
 // debugging support
 // ----------------------------------------------------------------------------
index c2a4d8fe40b7700bb73cf19ec49e12d4eb2ada0c..305886f8907b940a6920ed72478fde045dfd5d78 100644 (file)
@@ -577,6 +577,7 @@ wxWindowMac::wxWindowMac(wxWindowMac *parent,
 
 void wxWindowMac::Init()
 {
+    m_peer = NULL ;
     m_frozenness = 0 ;
 #if WXWIN_COMPATIBILITY_2_4
     m_backgroundTransparent = FALSE;
@@ -589,8 +590,6 @@ void wxWindowMac::Init()
     m_vScrollBar = NULL ;
     m_macBackgroundBrush = wxNullBrush ;
 
-       m_macControl = NULL ;
-
     m_macIsUserPane = TRUE;
     
     // make sure all proc ptrs are available
@@ -652,13 +651,12 @@ wxWindowMac::~wxWindowMac()
         if (parent->GetDefaultItem() == (wxButton*) this)
             parent->SetDefaultItem(NULL);
     }
-    if ( (ControlRef) m_macControl )
+    if ( m_peer && m_peer->Ok() )
     {
         // in case the callback might be called during destruction
         wxRemoveMacControlAssociation( this) ;
-        ::SetControlColorProc( (ControlRef) m_macControl , NULL ) ;
-        ::DisposeControl( (ControlRef) m_macControl ) ;
-        m_macControl = NULL ;
+        ::SetControlColorProc( *m_peer , NULL ) ;
+        ::DisposeControl( *m_peer ) ;
     }
 
     if ( g_MacLastWindow == this )
@@ -683,14 +681,19 @@ wxWindowMac::~wxWindowMac()
         m_dropTarget = NULL;
     }
 #endif // wxUSE_DRAG_AND_DROP
+    delete m_peer ;
+}
+
+WXWidget wxWindowMac::GetHandle() const 
+{ 
+    return (WXWidget) (ControlRef) *m_peer ; 
 }
 
-//
 
 void wxWindowMac::MacInstallEventHandler()
 {
-    wxAssociateControlWithMacControl( (ControlRef) m_macControl , this ) ;
-    InstallControlEventHandler( (ControlRef) m_macControl, GetwxMacWindowEventHandlerUPP(),
+    wxAssociateControlWithMacControl( *m_peer , this ) ;
+    InstallControlEventHandler( *m_peer, GetwxMacWindowEventHandlerUPP(),
         GetEventTypeCount(eventList), eventList, this, 
         (EventHandlerRef *)&m_macControlEventHandler);
 
@@ -727,25 +730,27 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
 //                     | kControlWantsIdle
                        ; 
 
-        ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , (ControlRef*) &m_macControl); 
+        m_peer = new wxMacControl() ;
+        ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , *m_peer);
+         
 
         MacPostControlCreate(pos,size) ;
 #if !TARGET_API_MAC_OSX
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneDrawProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneDrawProcTag, 
                sizeof(gControlUserPaneDrawUPP),(Ptr) &gControlUserPaneDrawUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneHitTestProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneHitTestProcTag, 
                sizeof(gControlUserPaneHitTestUPP),(Ptr) &gControlUserPaneHitTestUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneTrackingProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneTrackingProcTag, 
                sizeof(gControlUserPaneTrackingUPP),(Ptr) &gControlUserPaneTrackingUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneIdleProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneIdleProcTag, 
                sizeof(gControlUserPaneIdleUPP),(Ptr) &gControlUserPaneIdleUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneKeyDownProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneKeyDownProcTag, 
                sizeof(gControlUserPaneKeyDownUPP),(Ptr) &gControlUserPaneKeyDownUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneActivateProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneActivateProcTag, 
                sizeof(gControlUserPaneActivateUPP),(Ptr) &gControlUserPaneActivateUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneFocusProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneFocusProcTag, 
                sizeof(gControlUserPaneFocusUPP),(Ptr) &gControlUserPaneFocusUPP);
-        SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneBackgroundProcTag, 
+        SetControlData(*m_peer,kControlEntireControl,kControlUserPaneBackgroundProcTag, 
                sizeof(gControlUserPaneBackgroundUPP),(Ptr) &gControlUserPaneBackgroundUPP);
 #endif        
     }
@@ -766,15 +771,15 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
 
 void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
 {
-    wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+    wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
 
-    ::SetControlReference( (ControlRef) m_macControl , (long) this ) ;
+    ::SetControlReference( *m_peer , (long) this ) ;
 
     MacInstallEventHandler();
 
     ControlRef container = (ControlRef) GetParent()->GetHandle() ;
     wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
-    ::EmbedControl( (ControlRef) m_macControl , container ) ;
+    ::EmbedControl( *m_peer , container ) ;
 
     // adjust font, controlsize etc
     DoSetWindowVariant( m_windowVariant ) ;
@@ -782,10 +787,10 @@ void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
 #if !TARGET_API_MAC_OSX
     // eventually we can fix some clipping issues be reactivating this hook 
     //if ( m_macIsUserPane )
-    // SetControlColorProc( (ControlRef) m_macControl , wxMacSetupControlBackgroundUPP ) ;
+    // SetControlColorProc( *m_peer , wxMacSetupControlBackgroundUPP ) ;
 #endif
     
-    UMASetControlTitle( (ControlRef) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
+    UMASetControlTitle( *m_peer , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
 
     if (!m_macIsUserPane)
     {
@@ -799,11 +804,11 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
 {
     // Don't assert, in case we set the window variant before
     // the window is created
-    // wxASSERT( m_macControl != NULL ) ;
+    // wxASSERT( m_peer->Ok() ) ;
 
     m_windowVariant = variant ;
 
-    if (!m_macControl)
+    if (m_peer == NULL || !m_peer->Ok())
         return;
 
        ControlSize size ;
@@ -844,7 +849,7 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
             wxFAIL_MSG(_T("unexpected window variant"));
             break ;
     }
-       ::SetControlData( (ControlRef) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
+       ::SetControlData( *m_peer , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
 
     wxFont font ;
     font.MacCreateThemeFont( themeFont ) ;
@@ -884,7 +889,7 @@ void wxWindowMac::MacUpdateControlFont()
     fontStyle.foreColor = MAC_WXCOLORREF(GetForegroundColour().GetPixel() ) ;
     fontStyle.flags |= kControlUseForeColorMask ;
        
-       ::SetControlFontStyle( (ControlRef) m_macControl , &fontStyle );
+       ::SetControlFontStyle( *m_peer , &fontStyle );
        Refresh() ;
 }
 
@@ -940,7 +945,7 @@ bool wxWindowMac::MacCanFocus() const
     // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
     // in event handlers...
     UInt32 features = 0 ;
-    GetControlFeatures( (ControlRef) m_macControl , &features ) ;
+    GetControlFeatures( *m_peer , &features ) ;
     return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ; 
 }
 
@@ -1033,7 +1038,7 @@ void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
                                            int& w, int& h) const 
 {
     Rect bounds ;
-    GetControlBounds( (ControlRef) m_macControl , &bounds ) ;   
+    GetControlBounds( *m_peer , &bounds ) ;   
 
 
     x = bounds.left ;
@@ -1080,7 +1085,7 @@ void wxWindowMac::DoGetSize(int *x, int *y) const
     
 #else
     Rect bounds ;
-    GetControlBounds( (ControlRef) m_macControl , &bounds ) ;   
+    GetControlBounds( *m_peer , &bounds ) ;   
     if(x)   *x = bounds.right - bounds.left ;
     if(y)   *y = bounds.bottom - bounds.top ;
 #endif
@@ -1105,7 +1110,7 @@ void wxWindowMac::DoGetPosition(int *x, int *y) const
     if(y)   *y = y1 ;
  #else
     Rect bounds ;
-    GetControlBounds( (ControlRef) m_macControl , &bounds ) ;   
+    GetControlBounds( *m_peer , &bounds ) ;   
     wxCHECK_RET( GetParent() , wxT("Missing Parent") ) ;
     
     int xx = bounds.left ;
@@ -1199,7 +1204,7 @@ void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
     if ( y ) pt.y = *y ;
 
     if ( !IsTopLevel() )
-        HIViewConvertPoint( &pt , (ControlRef) m_macControl , (ControlRef) MacGetTopLevelWindow()->GetHandle()  ) ;
+        HIViewConvertPoint( &pt , *m_peer , (ControlRef) MacGetTopLevelWindow()->GetHandle()  ) ;
     
     if ( x ) *x = (int) pt.x ;
     if ( y ) *y = (int) pt.y ;
@@ -1207,7 +1212,7 @@ void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
     if ( !IsTopLevel() )
     {
         Rect bounds ;
-        GetControlBounds( (ControlRef) m_macControl , &bounds ) ;   
+        GetControlBounds( *m_peer , &bounds ) ;   
         if(x)   *x += bounds.left ;
         if(y)   *y += bounds.top ;
     }
@@ -1232,7 +1237,7 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
     if ( y ) pt.y = *y ;
 
     if ( !IsTopLevel() )
-        HIViewConvertPoint( &pt , (ControlRef) MacGetTopLevelWindow()->GetHandle()  , (ControlRef) m_macControl ) ;
+        HIViewConvertPoint( &pt , (ControlRef) MacGetTopLevelWindow()->GetHandle()  , *m_peer ) ;
     
     if ( x ) *x = (int) pt.x ;
     if ( y ) *y = (int) pt.y ;
@@ -1240,7 +1245,7 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
     if ( !IsTopLevel() )
     {
         Rect bounds ;
-        GetControlBounds( (ControlRef) m_macControl , &bounds ) ;   
+        GetControlBounds( *m_peer , &bounds ) ;   
         if(x)   *x -= bounds.left ;
         if(y)   *y -= bounds.top ;
     }
@@ -1261,17 +1266,17 @@ void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , in
 {
     RgnHandle rgn = NewRgn() ;
     Rect content ;
-    if ( GetControlRegion( (ControlRef) m_macControl , kControlContentMetaPart , rgn ) == noErr )
+    if ( GetControlRegion( *m_peer , kControlContentMetaPart , rgn ) == noErr )
     {
         GetRegionBounds( rgn , &content ) ;
         DisposeRgn( rgn ) ;
     }
     else
     {
-        GetControlBounds( (ControlRef) m_macControl , &content ) ;
+        GetControlBounds( *m_peer , &content ) ;
     }
     Rect structure ;
-    GetControlBounds( (ControlRef) m_macControl , &structure ) ;
+    GetControlBounds( *m_peer , &structure ) ;
 #if !TARGET_API_MAC_OSX    
     OffsetRect( &content , -structure.left , -structure.top ) ;
 #endif
@@ -1289,17 +1294,17 @@ wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size )  const
 
     Rect content ;
     
-    if ( GetControlRegion( (ControlRef) m_macControl , kControlContentMetaPart , rgn ) == noErr )
+    if ( GetControlRegion( *m_peer , kControlContentMetaPart , rgn ) == noErr )
     {
         GetRegionBounds( rgn , &content ) ;
         DisposeRgn( rgn ) ;
     }
     else
     {
-        GetControlBounds( (ControlRef) m_macControl , &content ) ;
+        GetControlBounds( *m_peer , &content ) ;
     }
     Rect structure ;
-    GetControlBounds( (ControlRef) m_macControl , &structure ) ;
+    GetControlBounds( *m_peer , &structure ) ;
 #if !TARGET_API_MAC_OSX    
     OffsetRect( &content , -structure.left , -structure.top ) ;
 #endif
@@ -1321,18 +1326,18 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const
 
     RgnHandle rgn = NewRgn() ;
     Rect content ;
-    if ( GetControlRegion( (ControlRef) m_macControl , kControlContentMetaPart , rgn ) == noErr )
+    if ( GetControlRegion( *m_peer , kControlContentMetaPart , rgn ) == noErr )
     {
         GetRegionBounds( rgn , &content ) ;
         DisposeRgn( rgn ) ;
     }
     else
     {
-        GetControlBounds( (ControlRef) m_macControl , &content ) ;
+        GetControlBounds( *m_peer , &content ) ;
     }
 #if !TARGET_API_MAC_OSX
     Rect structure ;
-    GetControlBounds( (ControlRef) m_macControl , &structure ) ;
+    GetControlBounds( *m_peer , &structure ) ;
     OffsetRect( &content , -structure.left , -structure.top ) ;
 #endif 
     ww = content.right - content.left ;
@@ -1529,21 +1534,21 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
     {
         // we don't adjust twice for the origin
         Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
-        bool vis = IsControlVisible( (ControlRef) m_macControl ) ;
+        bool vis = IsControlVisible( *m_peer ) ;
 #if TARGET_API_MAC_OSX
         // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
         if ( vis )
-            SetControlVisibility(  (ControlRef)m_macControl , false , true ) ;
+            SetControlVisibility(  *m_peer , false , true ) ;
         HIRect hir = { r.left , r.top , r.right - r.left , r.bottom - r.top } ;
-        HIViewSetFrame ( (ControlRef) m_macControl , &hir ) ;
+        HIViewSetFrame ( *m_peer , &hir ) ;
         if ( vis )
-            SetControlVisibility(  (ControlRef)m_macControl , true , true ) ;
+            SetControlVisibility(  *m_peer , true , true ) ;
 #else
         if ( vis )
-            SetControlVisibility(  (ControlRef)m_macControl , false , true ) ;
-        SetControlBounds( (ControlRef) m_macControl , &r ) ;
+            SetControlVisibility(  *m_peer , false , true ) ;
+        SetControlBounds( *m_peer , &r ) ;
         if ( vis )
-            SetControlVisibility(  (ControlRef)m_macControl , true , true ) ;
+            SetControlVisibility(  *m_peer , true , true ) ;
 #endif
         MacRepositionScrollBars() ;
         if ( doMove )
@@ -1573,7 +1578,7 @@ wxSize wxWindowMac::DoGetBestSize() const
     Rect    bestsize = { 0 , 0 , 0 , 0 } ;
     short   baselineoffset ;
     int bestWidth, bestHeight ;
-    ::GetBestControlRect( (ControlRef) m_macControl , &bestsize , &baselineoffset ) ;
+    ::GetBestControlRect( *m_peer , &bestsize , &baselineoffset ) ;
 
     if ( EmptyRect( &bestsize ) )
     {
@@ -1680,7 +1685,7 @@ wxPoint wxWindowMac::GetClientAreaOrigin() const
 {
     RgnHandle rgn = NewRgn() ;
     Rect content ;
-    GetControlRegion( (ControlRef) m_macControl , kControlContentMetaPart , rgn ) ;
+    GetControlRegion( *m_peer , kControlContentMetaPart , rgn ) ;
     GetRegionBounds( rgn , &content ) ;
     DisposeRgn( rgn ) ;
 #if !TARGET_API_MAC_OSX
@@ -1689,7 +1694,7 @@ wxPoint wxWindowMac::GetClientAreaOrigin() const
     if (!::EmptyRect( &content ) )
     {
         Rect structure ;
-        GetControlBounds( (ControlRef) m_macControl , &structure ) ;
+        GetControlBounds( *m_peer , &structure ) ;
         OffsetRect( &content , -structure.left , -structure.top ) ;
     }
 #endif 
@@ -1716,9 +1721,9 @@ void wxWindowMac::SetTitle(const wxString& title)
 {
     m_label = wxStripMenuCodes(title) ;
 
-    if ( m_macControl )
+    if ( m_peer && m_peer->Ok() )
     {
-               UMASetControlTitle( (ControlRef) m_macControl , m_label , m_font.GetEncoding() ) ;
+               UMASetControlTitle( *m_peer , m_label , m_font.GetEncoding() ) ;
     }
     Refresh() ;
 }
@@ -1736,7 +1741,7 @@ bool wxWindowMac::Show(bool show)
     // TODO use visibilityChanged Carbon Event for OSX
     bool former = MacIsReallyShown() ;
     
-    SetControlVisibility( (ControlRef) m_macControl , show , true ) ;
+    SetControlVisibility( *m_peer , show , true ) ;
     if ( former != MacIsReallyShown() )
         MacPropagateVisibilityChanged() ;
     return TRUE;
@@ -1744,21 +1749,21 @@ bool wxWindowMac::Show(bool show)
 
 bool wxWindowMac::Enable(bool enable)
 {
-    wxASSERT( m_macControl != NULL ) ;
+    wxASSERT( m_peer->Ok() ) ;
     if ( !wxWindowBase::Enable(enable) )
         return FALSE;
 
     bool former = MacIsReallyEnabled() ;
 #if TARGET_API_MAC_OSX
     if ( enable )
-        EnableControl( (ControlRef) m_macControl ) ;
+        EnableControl( *m_peer ) ;
     else
-        DisableControl( (ControlRef) m_macControl ) ;
+        DisableControl( *m_peer ) ;
 #else
     if ( enable )
-        ActivateControl( (ControlRef) m_macControl ) ;
+        ActivateControl( *m_peer ) ;
     else
-        DeactivateControl( (ControlRef) m_macControl ) ;
+        DeactivateControl( *m_peer ) ;
 #endif
 
     if ( former != MacIsReallyEnabled() )
@@ -1842,7 +1847,7 @@ bool wxWindowMac::MacIsReallyShown()
 {
     // only under OSX the visibility of the TLW is taken into account
 #if TARGET_API_MAC_OSX
-    return IsControlVisible( (ControlRef) m_macControl ) ;
+    return IsControlVisible( *m_peer ) ;
 #else
     wxWindow* win = this ;
     while( win->IsShown()  )
@@ -1862,15 +1867,15 @@ bool wxWindowMac::MacIsReallyShown()
 bool wxWindowMac::MacIsReallyEnabled() 
 {
 #if TARGET_API_MAC_OSX
-    return IsControlEnabled( (ControlRef) m_macControl ) ;
+    return IsControlEnabled( *m_peer ) ;
 #else
-    return IsControlActive( (ControlRef) m_macControl ) ;
+    return IsControlActive( *m_peer ) ;
 #endif
 }
 
 bool wxWindowMac::MacIsReallyHilited() 
 {
-    return IsControlActive( (ControlRef) m_macControl ) ;
+    return IsControlActive( *m_peer ) ;
 }
 
 void wxWindowMac::MacFlashInvalidAreas() 
@@ -1925,7 +1930,7 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
 {
 #if TARGET_API_MAC_OSX
     if ( rect == NULL )
-        HIViewSetNeedsDisplay( (ControlRef) m_macControl , true ) ; 
+        HIViewSetNeedsDisplay( *m_peer , true ) ; 
     else
     {
         RgnHandle update = NewRgn() ;
@@ -1933,7 +1938,7 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
         SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
         wxPoint origin = GetClientAreaOrigin() ;
         OffsetRgn( update, origin.x , origin.y ) ;        
-        HIViewSetNeedsDisplayInRegion( (ControlRef) m_macControl , update , true ) ;
+        HIViewSetNeedsDisplayInRegion( *m_peer , update , true ) ;
     }
 #else
 /*
@@ -1950,16 +1955,16 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
         InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
         DisposeRgn(updateRgn) ;
 */
-    if ( IsControlVisible( (ControlRef) m_macControl ) )
+    if ( IsControlVisible( *m_peer ) )
     {
-        SetControlVisibility( (ControlRef) m_macControl , false , false ) ;
-        SetControlVisibility( (ControlRef) m_macControl , true , true ) ;
+        SetControlVisibility( *m_peer , false , false ) ;
+        SetControlVisibility( *m_peer , true , true ) ;
     }
     /*
     if ( MacGetTopLevelWindow() == NULL )
         return ;
 
-    if ( !IsControlVisible( (ControlRef) m_macControl ) )
+    if ( !IsControlVisible( *m_peer ) )
        return ;
  
      wxPoint client = GetClientAreaOrigin();
@@ -2003,7 +2008,7 @@ void wxWindowMac::Freeze()
 #if TARGET_API_MAC_OSX
     if ( !m_frozenness++ )
     {
-        HIViewSetDrawingEnabled( (HIViewRef) m_macControl , false ) ;
+        HIViewSetDrawingEnabled( *m_peer , false ) ;
     }
 #endif
 }
@@ -2036,9 +2041,9 @@ void wxWindowMac::Thaw()
 
     if ( !--m_frozenness )
     {
-        HIViewSetDrawingEnabled( (HIViewRef) m_macControl , true ) ;
-        InvalidateControlAndChildren( (HIViewRef) m_macControl )  ;
-        // HIViewSetNeedsDisplay( (HIViewRef) m_macControl , true ) ;
+        HIViewSetDrawingEnabled( *m_peer , true ) ;
+        InvalidateControlAndChildren( *m_peer )  ;
+        // HIViewSetNeedsDisplay( *m_peer , true ) ;
     }
 #endif
 }
@@ -2046,7 +2051,7 @@ void wxWindowMac::Thaw()
 void wxWindowMac::MacRedrawControl()
 {
 /*
-    if ( (ControlRef) m_macControl && MacGetTopLevelWindowRef() && IsControlVisible( (ControlRef) m_macControl ) )
+    if ( *m_peer && MacGetTopLevelWindowRef() && IsControlVisible( *m_peer ) )
     {
 #if TARGET_API_MAC_CARBON
         Update() ;
@@ -2055,7 +2060,7 @@ void wxWindowMac::MacRedrawControl()
         wxMacPortSetter helper(&dc) ;
         wxMacWindowClipper clipper(this) ;
         wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
-        UMADrawControl( (ControlRef) m_macControl ) ;
+        UMADrawControl( *m_peer ) ;
 #endif
     }
 */
@@ -2311,22 +2316,22 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
             HIRect scrollarea = CGRectMake( rect->x , rect->y , rect->width , rect->height) ;
             scrollrect = CGRectIntersection( scrollrect , scrollarea ) ;
         }
-        if ( HIViewGetNeedsDisplay( (ControlRef) m_macControl ) )
+        if ( HIViewGetNeedsDisplay( *m_peer ) )
         {
             // becuase 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
-            HIViewSetNeedsDisplay( (ControlRef) m_macControl , true ) ;
+            HIViewSetNeedsDisplay( *m_peer , true ) ;
 #else
             // this would be the preferred version for fast drawing controls       
             if( UMAGetSystemVersion() < 0x1030 )
                 Update() ;
             else
-                HIViewRender((ControlRef) m_macControl) ;
+                HIViewRender(*m_peer) ;
 #endif
         }
-        HIViewScrollRect ( (ControlRef) m_macControl , &scrollrect , dx ,dy ) ;
+        HIViewScrollRect ( *m_peer , &scrollrect , dx ,dy ) ;
 #else
 
         wxPoint pos;
@@ -2339,7 +2344,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
             wxClientDC dc(this) ;
             wxMacPortSetter helper(&dc) ;
         
-            GetControlBounds( (ControlRef) m_macControl, &scrollrect);
+            GetControlBounds( *m_peer, &scrollrect);
             scrollrect.top += MacGetTopBorderSize() ;
             scrollrect.left += MacGetLeftBorderSize() ;
             scrollrect.bottom = scrollrect.top + height ;
@@ -2447,7 +2452,7 @@ void wxWindowMac::OnInternalIdle()
 void wxWindowMac::Raise()
 {
 #if TARGET_API_MAC_OSX
-    HIViewSetZOrder((ControlRef)m_macControl,kHIViewZOrderAbove, NULL) ;
+    HIViewSetZOrder(*m_peer,kHIViewZOrderAbove, NULL) ;
 #endif
 }
 
@@ -2455,7 +2460,7 @@ void wxWindowMac::Raise()
 void wxWindowMac::Lower()
 {
 #if TARGET_API_MAC_OSX
-    HIViewSetZOrder((ControlRef)m_macControl,kHIViewZOrderBelow, NULL) ;
+    HIViewSetZOrder(*m_peer,kHIViewZOrderBelow, NULL) ;
 #endif
 }
 
@@ -2545,10 +2550,10 @@ void wxWindowMac::Update()
             status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
         }
         else
-            HIViewSetNeedsDisplay( (ControlRef) m_macControl , true ) ;
+            HIViewSetNeedsDisplay( *m_peer , true ) ;
     }
 #else
-    ::Draw1Control( (ControlRef) m_macControl ) ;
+    ::Draw1Control( *m_peer ) ;
 #endif
 }
 
@@ -2568,9 +2573,9 @@ wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures )
     Rect r ;
     RgnHandle visRgn = NewRgn() ;
     RgnHandle tempRgn = NewRgn() ;
-    if ( IsControlVisible( (ControlRef) m_macControl ) )
+    if ( IsControlVisible( *m_peer ) )
     {
-        GetControlBounds( (ControlRef) m_macControl , &r ) ;
+        GetControlBounds( *m_peer , &r ) ;
         if (! MacGetTopLevelWindow()->MacUsesCompositing() )
         {
             MacRootWindowToWindow( &r.left , & r.top ) ;
@@ -2694,7 +2699,7 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
     if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
     { 
         Rect bounds;
-        UMAGetControlBoundsInWindowCoords( (ControlRef)m_macControl, &bounds );
+        UMAGetControlBoundsInWindowCoords( *m_peer, &bounds );
         RgnHandle controlRgn = NewRgn();
         RectRgn( controlRgn, &bounds );
         //KO: This sets the ownUpdateRgn to the area of this control that is inside