diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 638a4f0d58..b0e3183298 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -64,6 +64,9 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) if ( win ) { +#if 0 + // this clipping area was set to the parent window's drawing area, lead to problems + // with MacOSX controls drawing outside their wx' rectangle RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; wxWindow *parent = win->GetParent() ; @@ -77,6 +80,13 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; DisposeRgn( insidergn ) ; +#endif + RgnHandle insidergn = NewRgn() ; + int x = 0 , y = 0; + win->MacWindowToRootWindow( &x,&y ) ; + CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; + OffsetRgn( m_newClip , x , y ) ; + SetClip( m_newClip ) ; } } wxMacWindowClipper::~wxMacWindowClipper() @@ -1369,6 +1379,21 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1395,6 +1420,21 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index f4e41ae710..844abe8206 100644 Binary files a/src/mac/carbon/filedlg.cpp and b/src/mac/carbon/filedlg.cpp differ diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index f08f4e0ff7..2fa477f7da 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -768,46 +768,53 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, wxString wxTextCtrl::GetValue() const { - Size actualsize; - + Size actualSize = 0; + wxString result ; + OSStatus err ; if ( !m_macUsesTXN ) { - ::GetControlData( (ControlHandle) m_macControl, 0, - ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - 32767 , wxBuffer , &actualsize ) ; + err = ::GetControlDataSize((ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; + + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + + ::GetControlData( (ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, + actualSize , ptr , &actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf(actualSize) ; + } + } else { Handle theText ; - OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); // all done if ( err ) { - actualsize = 0 ; + actualSize = 0 ; } else { - actualsize = GetHandleSize( theText ) ; - if (actualsize != 0) - strncpy( wxBuffer , *theText , actualsize ) ; - DisposeHandle( theText ) ; + actualSize = GetHandleSize( theText ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + strncpy( ptr , *theText , actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf( actualSize ) ; + } + DisposeHandle( theText ) ; } } - wxBuffer[actualsize] = 0 ; - - wxString value; - - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakePCStringFromMac( wxBuffer ) ; - value.Replace( "\r", "\n" ); - } - else - value = wxBuffer; - - - return value; + return wxMacMakeStringFromMacString( result ) ; } void wxTextCtrl::GetSelection(long* from, long* to) const @@ -830,7 +837,7 @@ void wxTextCtrl::SetValue(const wxString& st) if( wxApp::s_macDefaultEncodingIsPC ) { value = wxMacMakeMacStringFromPC( st ) ; - value.Replace( "\n", "\r" ); + // value.Replace( "\n", "\r" ); TODO this should be handled by the conversion } else value = st; @@ -1206,7 +1213,7 @@ void wxTextCtrl::WriteText(const wxString& text) if( wxApp::s_macDefaultEncodingIsPC ) { value = wxMacMakeMacStringFromPC( text ) ; - value.Replace( "\n", "\r" ); + // value.Replace( "\n", "\r" ); // TODO this should be handled by the conversion } else value = text ; @@ -1543,9 +1550,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) key == WXK_DELETE || key == WXK_BACK) { - long t1 = 0xDEADBEEF ; wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - long t2 = 0xDEADBEEF ; event1.SetString( GetValue() ) ; event1.SetEventObject( this ); wxPostEvent(GetEventHandler(),event1); diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 638a4f0d58..b0e3183298 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -64,6 +64,9 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) if ( win ) { +#if 0 + // this clipping area was set to the parent window's drawing area, lead to problems + // with MacOSX controls drawing outside their wx' rectangle RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; wxWindow *parent = win->GetParent() ; @@ -77,6 +80,13 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; DisposeRgn( insidergn ) ; +#endif + RgnHandle insidergn = NewRgn() ; + int x = 0 , y = 0; + win->MacWindowToRootWindow( &x,&y ) ; + CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; + OffsetRgn( m_newClip , x , y ) ; + SetClip( m_newClip ) ; } } wxMacWindowClipper::~wxMacWindowClipper() @@ -1369,6 +1379,21 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1395,6 +1420,21 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, diff --git a/src/mac/filedlg.cpp b/src/mac/filedlg.cpp index f4e41ae710..844abe8206 100644 Binary files a/src/mac/filedlg.cpp and b/src/mac/filedlg.cpp differ diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index f08f4e0ff7..2fa477f7da 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -768,46 +768,53 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, wxString wxTextCtrl::GetValue() const { - Size actualsize; - + Size actualSize = 0; + wxString result ; + OSStatus err ; if ( !m_macUsesTXN ) { - ::GetControlData( (ControlHandle) m_macControl, 0, - ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - 32767 , wxBuffer , &actualsize ) ; + err = ::GetControlDataSize((ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; + + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + + ::GetControlData( (ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, + actualSize , ptr , &actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf(actualSize) ; + } + } else { Handle theText ; - OSStatus err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); // all done if ( err ) { - actualsize = 0 ; + actualSize = 0 ; } else { - actualsize = GetHandleSize( theText ) ; - if (actualsize != 0) - strncpy( wxBuffer , *theText , actualsize ) ; - DisposeHandle( theText ) ; + actualSize = GetHandleSize( theText ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + strncpy( ptr , *theText , actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf( actualSize ) ; + } + DisposeHandle( theText ) ; } } - wxBuffer[actualsize] = 0 ; - - wxString value; - - if( wxApp::s_macDefaultEncodingIsPC ) - { - value = wxMacMakePCStringFromMac( wxBuffer ) ; - value.Replace( "\r", "\n" ); - } - else - value = wxBuffer; - - - return value; + return wxMacMakeStringFromMacString( result ) ; } void wxTextCtrl::GetSelection(long* from, long* to) const @@ -830,7 +837,7 @@ void wxTextCtrl::SetValue(const wxString& st) if( wxApp::s_macDefaultEncodingIsPC ) { value = wxMacMakeMacStringFromPC( st ) ; - value.Replace( "\n", "\r" ); + // value.Replace( "\n", "\r" ); TODO this should be handled by the conversion } else value = st; @@ -1206,7 +1213,7 @@ void wxTextCtrl::WriteText(const wxString& text) if( wxApp::s_macDefaultEncodingIsPC ) { value = wxMacMakeMacStringFromPC( text ) ; - value.Replace( "\n", "\r" ); + // value.Replace( "\n", "\r" ); // TODO this should be handled by the conversion } else value = text ; @@ -1543,9 +1550,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) key == WXK_DELETE || key == WXK_BACK) { - long t1 = 0xDEADBEEF ; wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - long t2 = 0xDEADBEEF ; event1.SetString( GetValue() ) ; event1.SetEventObject( this ); wxPostEvent(GetEventHandler(),event1);