X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbe4a80c57a77b249ef32117efe9fd923066f958..f7d2128f3c89b2d00fbac0d8c9798409ae23b408:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index eb8d7e1940..2f76bf0fb1 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -189,7 +189,7 @@ wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRe m_formerClip = NewRgn() ; m_newClip = NewRgn() ; GetClip( m_formerClip ) ; - + if ( win ) { // guard against half constructed objects, this just leads to a empty clip @@ -197,13 +197,13 @@ wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRe { int x = 0 , y = 0; win->MacWindowToRootWindow( &x, &y ) ; - + // get area including focus rect HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ); if ( !EmptyRgn( m_newClip ) ) OffsetRgn( m_newClip , x , y ) ; } - + SetClip( m_newClip ) ; } } @@ -486,7 +486,7 @@ void wxTextCtrl::MacSuperChangedPosition() void wxTextCtrl::MacVisibilityChanged() { - GetPeer()->VisibilityChanged( MacIsReallyShown() ) ; + GetPeer()->VisibilityChanged( GetPeer()->IsVisible() ); } void wxTextCtrl::MacCheckSpelling(bool check) @@ -828,6 +828,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) { int key = event.GetKeyCode() ; bool eat_key = false ; + long from, to; if ( key == 'a' && event.MetaDown() ) { @@ -855,10 +856,11 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // Check if we have reached the max # of chars (if it is set), but still // allow navigation and deletion + GetSelection( &from, &to ); if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB && - key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) - ) + key != WXK_BACK && key != WXK_DELETE && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && + from == to ) { // eat it, we don't want to add more than allowed # of characters @@ -1252,6 +1254,24 @@ int wxMacTextControl::GetLineLength(long lineNo) const return 0 ; } +void wxMacTextControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) +{ + wxMacControl::SetFont(font, foreground, windowStyle ); +#ifndef __LP64__ + + // overrule the barrier in wxMacControl for supporting disabled controls, in order to support + // setting the color to eg red and back to black by controllers + + if ( foreground == *wxBLACK ) + { + ControlFontStyleRec fontStyle; + fontStyle.foreColor.red = fontStyle.foreColor.green = fontStyle.foreColor.blue = 0; + fontStyle.flags = kControlUseForeColorMask; + ::SetControlFontStyle( m_controlRef , &fontStyle ); + } +#endif +} + // ---------------------------------------------------------------------------- // standard unicode control implementation // ---------------------------------------------------------------------------- @@ -1763,11 +1783,11 @@ void wxMacMLTEControl::AdjustCreationAttributes(const wxColour &background, | kTXNSupportFontCommandProcessing | kTXNSupportFontCommandUpdating; - // only spell check when not read-only + // only spell check when not read-only // use system options for the default - bool checkSpelling = false ; + bool checkSpelling = false ; if ( !(m_windowStyle & wxTE_READONLY) ) - { + { #if wxUSE_SYSTEM_OPTIONS if ( wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER ) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER ) == 1) ) { @@ -1775,11 +1795,11 @@ void wxMacMLTEControl::AdjustCreationAttributes(const wxColour &background, } #endif } - + if ( checkSpelling ) options |= kTXNSupportSpellCheckCommandProcessing - | kTXNSupportSpellCheckCommandUpdating; + | kTXNSupportSpellCheckCommandUpdating; TXNSetCommandEventSupport( m_txn , options ) ; } @@ -1812,11 +1832,12 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo TXNTab* tabs = NULL; bool relayout = false; + wxFont font ; if ( style.HasFont() ) { wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) ); - const wxFont &font = style.GetFont() ; + font = style.GetFont() ; typeAttr[typeAttrCount].tag = kTXNATSUIStyle ; typeAttr[typeAttrCount].size = kTXNATSUIStyleSize ; typeAttr[typeAttrCount].data.dataPtr = font.MacGetATSUStyle() ; @@ -2562,7 +2583,7 @@ void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 WXUNUSED(thePar if ( textctrl == NULL ) return ; - if ( textctrl->MacIsReallyShown() ) + if ( textctrl->IsShownOnScreen() ) { wxMacWindowClipper clipper( textctrl ) ; TXNDraw( m_txn , NULL ) ; @@ -2575,7 +2596,7 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt1 ControlPartCode result = kControlNoPart; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->MacIsReallyShown() ) + if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) { if (PtInRect( where, &m_txnControlBounds )) { @@ -2602,7 +2623,7 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxIn ControlPartCode result = kControlNoPart; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->MacIsReallyShown() ) + if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) { Point startPt = { y , x } ; @@ -2638,7 +2659,7 @@ void wxMacMLTEClassicControl::MacControlUserPaneIdleProc() if ( textctrl == NULL ) return ; - if (textctrl->MacIsReallyShown()) + if (textctrl->IsShownOnScreen()) { if (IsControlActive(m_controlRef)) { @@ -2744,7 +2765,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer, AdjustCreationAttributes( *wxWHITE , true ) ; - MacSetObjectVisibility( wxPeer->MacIsReallyShown() ) ; + MacSetObjectVisibility( wxPeer->IsShownOnScreen() ) ; { wxString st = str ; @@ -3032,7 +3053,7 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer, m_scrollView = NULL ; TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ; - if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || !(frameOptions &kTXNSingleLineOnlyMask)) + if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || (frameOptions &kTXNSingleLineOnlyMask)) { if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) ) {