From 7f1de2b26e841b21110dadf3b9f2d543703eaf45 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 14 May 2004 09:25:21 +0000 Subject: [PATCH] supporting readonly and singleline attributes for non-mlte textrcontrol git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/textctrl.cpp | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 61f918d554..96c3cc2477 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 } } -- 2.45.2