From 21fd55291b631eae9ccfd78866616aca6e573ebe Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 4 Jun 2004 07:28:59 +0000 Subject: [PATCH] introduction of m_peer git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/bmpbuttn.cpp | 8 +- src/mac/carbon/button.cpp | 32 ++----- src/mac/carbon/checkbox.cpp | 12 +-- src/mac/carbon/checklst.cpp | 24 ++--- src/mac/carbon/choice.cpp | 23 +++-- src/mac/carbon/combobxc.cpp | 94 ++++++++++++------ src/mac/carbon/control.cpp | 6 +- src/mac/carbon/gauge.cpp | 52 ++++------ src/mac/carbon/listbox.cpp | 45 +++++---- src/mac/carbon/notebmac.cpp | 24 ++--- src/mac/carbon/radiobox.cpp | 4 +- src/mac/carbon/radiobut.cpp | 10 +- src/mac/carbon/scrolbar.cpp | 28 +++--- src/mac/carbon/slider.cpp | 16 ++-- src/mac/carbon/spinbutt.cpp | 12 ++- src/mac/carbon/statbox.cpp | 3 +- src/mac/carbon/statlmac.cpp | 3 +- src/mac/carbon/stattext.cpp | 7 +- src/mac/carbon/tabctrl.cpp | 4 +- src/mac/carbon/textctrl.cpp | 109 ++++++++++++++++----- src/mac/carbon/tglbtn.cpp | 8 +- src/mac/carbon/toplevel.cpp | 5 +- src/mac/carbon/utils.cpp | 32 ++++++- src/mac/carbon/window.cpp | 185 ++++++++++++++++++------------------ 24 files changed, 439 insertions(+), 307 deletions(-) diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index 8fba4742c7..704b1728ba 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -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 ) ; } } diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index 4bb38feb1e..94610153a1 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -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); } diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index 56284d3ce3..11ed5fc74f 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -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) ) diff --git a/src/mac/carbon/checklst.cpp b/src/mac/carbon/checklst.cpp index 5fbc1f6c44..bad85ae455 100644 --- a/src/mac/carbon/checklst.cpp +++ b/src/mac/carbon/checklst.cpp @@ -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 ) ) ; } } diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 489243e04a..c0c21a5377 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -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( 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 ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/combobxc.cpp b/src/mac/carbon/combobxc.cpp index 8f1e122bd0..8cee1e946e 100644 --- a/src/mac/carbon/combobxc.cpp +++ b/src/mac/carbon/combobxc.cpp @@ -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(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(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 diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index ba7d6a7a3c..39f3a344d2 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -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 } diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index 36abf248dc..bfdbe410dc 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -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 ; } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 50e9f4445f..361bc4def7 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -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 diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index cee99d8c80..4867e34272 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -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 ; } diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index cf279d567b..0fbd9fa5f1 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -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++) { diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 32ad08047e..eb8423fa8e 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -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) diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index 08818c0470..c5a74bc2f4 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -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; diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index d1dd3ee950..2be3714446 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -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 ) ; diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 7e8de83b09..526eaacd7b 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -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) diff --git a/src/mac/carbon/statbox.cpp b/src/mac/carbon/statbox.cpp index 870154ebba..d25be44dab 100644 --- a/src/mac/carbon/statbox.cpp +++ b/src/mac/carbon/statbox.cpp @@ -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) ; diff --git a/src/mac/carbon/statlmac.cpp b/src/mac/carbon/statlmac.cpp index d13f45e35e..cf9f999fa0 100644 --- a/src/mac/carbon/statlmac.cpp +++ b/src/mac/carbon/statlmac.cpp @@ -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) ; diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index e2bd22ed23..f4757d19d7 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -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) ) diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index e96fb25f80..677dd1ae91 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -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 ; diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index a522f2e9e9..100978c50f 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -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 ) ; } } } diff --git a/src/mac/carbon/tglbtn.cpp b/src/mac/carbon/tglbtn.cpp index c41c9610f3..909eeb4d79 100644 --- a/src/mac/carbon/tglbtn.cpp +++ b/src/mac/carbon/tglbtn.cpp @@ -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) diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index e97fc6b17a..e657e1025f 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -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() ; diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 5c4da3a625..c2f1be7ea1 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -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(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 // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index c2a4d8fe40..305886f890 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -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 -- 2.45.2