From 04d53786f023353f442212d0169405ef5f56d391 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 31 Jan 2003 16:01:38 +0000 Subject: [PATCH] backported fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19037 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dc.cpp | 40 +++++++++++++++++++++++ src/mac/carbon/filedlg.cpp | Bin 15657 -> 16026 bytes src/mac/carbon/textctrl.cpp | 63 +++++++++++++++++++----------------- src/mac/dc.cpp | 40 +++++++++++++++++++++++ src/mac/filedlg.cpp | Bin 15657 -> 16026 bytes src/mac/textctrl.cpp | 63 +++++++++++++++++++----------------- 6 files changed, 148 insertions(+), 58 deletions(-) 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 f4e41ae710a7e1a2511e1c01270d2fc785c8234e..844abe82063e678a0cf5972b5156b84a70231347 100644 GIT binary patch delta 1685 zcmc&!O>7%Q6kh){$quv)r6f+BIOEjVyI%if{qL9{+}Z&e$FbrBF0IPenFN>hkJg){ zX=JrW;6R0*gw)>Pf)J{z)CVLaE*ua734uTy5D0PO0;1vwp}esj2%>5)NR0OBz5U+I zyl>unGw)o!(XI=JMg+ks{Cn6D5>d{eP!xi45ryLxl)4~1@eyiVI~zmj2HFoA*4HhC z-9pgiG?=+z)ahDPXSu4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jk{W9 zggCKtk^(D|1n;E7@H65jB0Y-$M}~c^pawl~(YIqGDN&~7nT^40kiuJEXB#PDB)9sm zOqxz5C-x0a9q&(0^c@<*?GI!(NOBwel3h4A;{}%FKJ*TuXE&~0@KN3bv;GFi`dx6r zFT<)|z^IRY-v&Y{;WTi9*+2`3$|<<4gy5-?TwlR}1jf)rSPnSt`Ej5TcfSp|@cBJ( zVk^c~M;GUglxB9#Ab5Y*XvbfmK9@jBcMUrRb`MZ4ycx@YRoY#pk)>q z)(XE*#VYT3z{`jX@krwio?SNFu`(K5k24vIUyXPb!2RM zWQ048hA1qB+TmJ6Y_yq_X>%U%GSpc^DSQo$A~z?Dgd6PMEQcL+q!L!?OC3B5J8Uwa z!mfWM0~3+vh^^D1jAk(tWm+ZAS<>o@r(6`Vw|p@qcr_xeFN=Y|^N5UEl51_|9Z~Ne z;9xYqnPiXW@Jq!qy4|)um!r;gxD#_+k9OF^A4XgDlH}k3%cp1_^=vP=UeP(sii?Ih zM^Cfj5kA{)4rzuyPg6!gx9qG9u^9Bn#4-mxb_`y{THy 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 f4e41ae710a7e1a2511e1c01270d2fc785c8234e..844abe82063e678a0cf5972b5156b84a70231347 100644 GIT binary patch delta 1685 zcmc&!O>7%Q6kh){$quv)r6f+BIOEjVyI%if{qL9{+}Z&e$FbrBF0IPenFN>hkJg){ zX=JrW;6R0*gw)>Pf)J{z)CVLaE*ua734uTy5D0PO0;1vwp}esj2%>5)NR0OBz5U+I zyl>unGw)o!(XI=JMg+ks{Cn6D5>d{eP!xi45ryLxl)4~1@eyiVI~zmj2HFoA*4HhC z-9pgiG?=+z)ahDPXSu4TH`YT>Gqa?bFG?~DP9-~gt`DsDo75ScdfN`Syc9n7D)75k z&J?xHCDzopmsq7?tcs#o+eb1)%;s~fRY4Hp99z>ibhFT?XlAuhrx^kjpYKXIOfNH| zK{Z{ctD311k%+bPO{7F;>DHxut!ZwTO`}?0#}(+|)Qeh;-P_C8wL;xRlKhYP2T&qn z&=zK*NmmEDSs?JLFF1*G5d!=*P5oc7&>i| z2PA0<=215#39d`i@CoW)B?TsBkA=XTEI~u|Nf?x3=8cv~wPurPMvI?yu3T=i3e^v! znCkKivg#!LMA{5e*2{2;PLm05js~5)&oya_VH9ZO=(Ied) zo{5gy`Gju%UWra(+TV?i!)?`Z&k%VYwq&r)D%-*)2_Qw@-3J?|k8v)vZ+mOoIc#n@ z)18eKY{vX{WJci4SO80_STPHGF<%c;;>of8P2IZmZ0`K&Z1Hry!27>V2waPEj=S*_ z$9mU`wy=TtJ>ysE`?zBmDd`QoFO|kd-Q*xiBp{oRc#K-&9DJHM0hRb8(26?-#5OX* zge4QOnDoMCa?*hJmq`!&mXzV!)DhTA4nZdMC|0mHaLTz<2(G0lbW$q(nDW4I znvRLwdyx3ze2;WzG5wA0O7H!$EaPj%W$r<*)_?5B`2XwZ#kb=l&Y$sT1aYBJ*D8(s zaI)c}9}?rE7Cj_!AfRebxW~ delta 1223 zcmb_cNpI6Y6c(k3PJx!KO=#10n$pB}9Ea>F6+-F8(uLAR2&ssgbW#G29XU?h08u$2 zae~KzMTjFRH`D`*gb)IOSj2$~63dMPaDqR8c;h5U9FZ95dB*R1^X8lPKKpuU<;6MhCY8i=Mq>jRRWs(5easqHt&@T%_SVzN zFqu^_bz0pGTio&0o{mQ~|2OUG7WeI1xaaAF_Z}H)yb}1l?XcfVVczS7ZGwL-sV9&W z98QuQQy0cfwvb_q)8pf057jeTFM_(zvWCE|XcOEN8sLu51#g6I_#ues?Tl>$S!}DU zX2d4Qi89;}yX~}3L;=2{HA+nmJcbNSPUcvOYDP-6GKNlh_JpMDAcrOgO_MS-Jk{W9 zggCKtk^(D|1n;E7@H65jB0Y-$M}~c^pawl~(YIqGDN&~7nT^40kiuJEXB#PDB)9sm zOqxz5C-x0a9q&(0^c@<*?GI!(NOBwel3h4A;{}%FKJ*TuXE&~0@KN3bv;GFi`dx6r zFT<)|z^IRY-v&Y{;WTi9*+2`3$|<<4gy5-?TwlR}1jf)rSPnSt`Ej5TcfSp|@cBJ( zVk^c~M;GUglxB9#Ab5Y*XvbfmK9@jBcMUrRb`MZ4ycx@YRoY#pk)>q z)(XE*#VYT3z{`jX@krwio?SNFu`(K5k24vIUyXPb!2RM zWQ048hA1qB+TmJ6Y_yq_X>%U%GSpc^DSQo$A~z?Dgd6PMEQcL+q!L!?OC3B5J8Uwa z!mfWM0~3+vh^^D1jAk(tWm+ZAS<>o@r(6`Vw|p@qcr_xeFN=Y|^N5UEl51_|9Z~Ne z;9xYqnPiXW@Jq!qy4|)um!r;gxD#_+k9OF^A4XgDlH}k3%cp1_^=vP=UeP(sii?Ih zM^Cfj5kA{)4rzuyPg6!gx9qG9u^9Bn#4-mxb_`y{THy 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);