X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7548762cb5d8320cf8a36518594dfb5269cd8c60..3c5487b14442ddbc6e43ee2f4475b5a6ba251fb1:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index f260ca06fc..a522f2e9e9 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -859,15 +859,23 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, tback.bg.color = MAC_WXCOLORREF( GetBackgroundColour().GetPixel() ); TXNSetBackground( (TXNObject) m_macTXN , &tback); - if ( m_windowStyle & wxTE_READONLY) - { - SetEditable( false ) ; - } #else wxMacCFStringHolder cf(st , m_font.GetEncoding()) ; - CreateEditUnicodeTextControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , cf , style & wxTE_PASSWORD , NULL , (ControlRef*) &m_macControl ) ; + CFStringRef cfr = cf ; + Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ; + CreateEditUnicodeTextControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , cfr , isPassword , NULL , (ControlRef*) &m_macControl ) ; + if ( !(m_windowStyle & wxTE_MULTILINE) ) + { + Boolean singleline = true ; + ::SetControlData( (ControlHandle) m_macControl, kControlEditTextPart , kControlEditTextSingleLineTag , sizeof( singleline ) , &singleline ) ; + } MacPostControlCreate(pos,size) ; + #endif + if ( m_windowStyle & wxTE_READONLY) + { + SetEditable( false ) ; + } return TRUE; @@ -875,11 +883,32 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, void wxTextCtrl::MacVisibilityChanged() { -#if wxMAC_USE_MLTE && !wxMAC_USE_MLTE_HIVIEW +#if wxMAC_USE_MLTE +#if !wxMAC_USE_MLTE_HIVIEW MLTESetObjectVisibility((STPTextPaneVars*) m_macTXNvars , MacIsReallyShown() , GetWindowStyle() ) ; if ( !MacIsReallyShown() ) InvalWindowRect( GetControlOwner( (ControlHandle) m_macControl ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ; #endif +#else + if ( !(m_windowStyle & wxTE_MULTILINE) && MacIsReallyShown() ) + { + // work around a refresh issue insofar as not always the entire content is shown even if this would be possible + ControlEditTextSelectionRec sel ; + CFStringRef value = NULL ; + Size actualSize = 0 ; + ResType datatag = GetWindowStyle() & wxTE_PASSWORD ? + kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag ; + + verify_noerr( GetControlData( (ControlRef) m_macControl , 0, kControlEditTextSelectionTag, + sizeof(ControlEditTextSelectionRec), &sel, &actualSize ) ); + verify_noerr( GetControlData( (ControlRef) m_macControl , 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 ) ); + + CFRelease( value ) ; + } +#endif } void wxTextCtrl::MacEnabledStateChanged() @@ -1215,6 +1244,9 @@ void wxTextCtrl::SetEditable(bool editable) TXNControlTag tag[] = { kTXNIOPrivilegesTag } ; TXNControlData data[] = { { editable ? kTXNReadWrite : kTXNReadOnly } } ; TXNSetTXNObjectControls( (TXNObject) m_macTXN , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ; +#else + Boolean value = !editable ; + ::SetControlData( (ControlHandle) m_macControl, 0, kControlEditTextLockedTag , sizeof( value ) , &value ) ; #endif } } @@ -1413,7 +1445,9 @@ void wxTextCtrl::WriteText(const wxString& str) { if ( !wxIsMainThread() ) { - wxMacMPRemoteGUICall( this , &wxTextCtrl::WriteText , str ) ; + // unfortunately CW 8 is not able to correctly deduce the template types, so we have + // to instantiate explicitely + wxMacMPRemoteGUICall( this , &wxTextCtrl::WriteText , str ) ; return ; } else @@ -1449,6 +1483,7 @@ void wxTextCtrl::WriteText(const wxString& str) val.Remove( start , end - start ) ; val.insert( start , str ) ; SetValue( val ) ; + SetInsertionPoint( start + str.Length() ) ; #endif #endif } @@ -1516,6 +1551,13 @@ wxSize wxTextCtrl::DoGetBestSize() const break ; } +#if !wxMAC_USE_MLTE + // unicode text control is using client size, ie 3 pixels on every side + // TODO make this fit into normal window size concept, probably having + // to reintroduce the margin vars + hText -= 6 ; +#endif + if ( m_windowStyle & wxTE_MULTILINE ) { hText *= 5 ; @@ -1870,7 +1912,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } } - // this will make wxWindows eat the ENTER key so that + // this will make wxWidgets eat the ENTER key so that // we actually prevent line wrapping in a single line // text control eat_key = TRUE;