backported fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19037 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2003-01-31 16:01:38 +00:00
parent 89fb932dc8
commit 04d53786f0
6 changed files with 148 additions and 58 deletions

View File

@@ -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,

Binary file not shown.

View File

@@ -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);

View File

@@ -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,

Binary file not shown.

View File

@@ -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);