X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8623a8838d8c4a7fd531e1eb3940e3ddf7306584..4b134bb2ce1cba6a0033bdc553817d45de5b2cf7:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index d1b9fa2325..7cc3dd0fae 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -300,6 +300,7 @@ public : const wxSize& size, long style ) ; ~wxMacMLTEClassicControl() ; virtual void VisibilityChanged(bool shown) ; + virtual bool NeedsFocusRect() const; protected : OSStatus DoCreate(); public : @@ -433,6 +434,11 @@ void wxTextCtrl::SetValue(const wxString& str) return ; GetPeer()->SetStringValue(str) ; + + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); + event.SetString( GetValue() ) ; + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); } void wxTextCtrl::SetMaxLength(unsigned long len) @@ -478,7 +484,6 @@ void wxTextCtrl::Cut() GetPeer()->Cut() ; wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - event.SetString( GetValue() ) ; event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); } @@ -492,7 +497,6 @@ void wxTextCtrl::Paste() // eventually we should add setting the default style again wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - event.SetString( GetValue() ) ; event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); } @@ -791,6 +795,16 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) return ; } + // Check if we have reached the max # of chars, but still allow navigation and deletion + if ( !IsMultiLine() && GetValue().Length() >= m_maxLength && + key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB && + key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) ) + ) + { + // eat it, we don't want to add more than allowed # of characters + return; + } + // assume that any key not processed yet is going to modify the control m_dirty = true; @@ -891,7 +905,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) key == WXK_BACK) { wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - event1.SetString( GetValue() ) ; event1.SetEventObject( this ); wxPostEvent(GetEventHandler(),event1); } @@ -1512,7 +1525,7 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo fontStyle |= bold ; if ( font.GetStyle() == wxITALIC ) fontStyle |= italic ; - + typeAttr[attrCounter].tag = kTXNQDFontNameAttribute ; typeAttr[attrCounter].size = kTXNQDFontNameAttributeSize ; typeAttr[attrCounter].data.dataPtr = (void*) fontName ; @@ -1980,21 +1993,36 @@ static void TPCalculateBounds(STPTextPaneVars *varsp, const Rect& bounds) OSStatus MLTESetObjectVisibility( STPTextPaneVars *varsp, Boolean vis , long wxStyle) { OSStatus err = noErr ; -#if TARGET_API_MAC_OSX - TXNControlTag iControlTags[1] = { kTXNVisibilityTag }; - TXNControlData iControlData[1] = {{ vis }}; - err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData ); -#endif wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(varsp->fUserPaneRec); - if ( vis && textctrl ) + if ( textctrl ) { +#if TARGET_API_MAC_OSX + TXNControlTag iControlTags[1] = { kTXNVisibilityTag }; + TXNControlData iControlData[1] = {{ vis }}; + err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData ); +#endif Rect bounds ; UMAGetControlBoundsInWindowCoords( varsp->fUserPaneRec, &bounds); TPCalculateBounds( varsp , bounds ) ; - wxMacWindowClipper cl(textctrl) ; - TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left, - varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame); - TXNShowSelection( varsp->fTXNRec, kTXNShowStart); + if ( vis ) + { + wxMacWindowClipper cl(textctrl) ; + TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left, + varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame); + TXNShowSelection( varsp->fTXNRec, kTXNShowStart); + } + else + { +#if TARGET_API_MAC_OSX + // in 10.2 the scrollbars are still actively redrawn when using only the code above + if ( UMAGetSystemVersion() < 0x1030 ) + { + TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 20000 , varsp->fRTextArea.left + 20000 , + varsp->fRTextArea.bottom + 20000 , varsp->fRTextArea.right + 20000 , varsp->fTXNFrame); + + } +#endif + } } return err ; } @@ -2052,7 +2080,7 @@ static void TPRedrawFocusOutline(STPTextPaneVars *varsp) { if (varsp->fFocusDrawState != (varsp->fIsActive && varsp->fInFocus)) { varsp->fFocusDrawState = (varsp->fIsActive && varsp->fInFocus); - DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState); + // DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState); } } @@ -2396,6 +2424,11 @@ void wxMacMLTEClassicControl::VisibilityChanged(bool shown) InvalWindowRect( GetControlOwner( m_controlRef ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ; } +bool wxMacMLTEClassicControl::NeedsFocusRect() const +{ + return true; +} + OSStatus wxMacMLTEClassicControl::DoCreate() { Rect bounds;