X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6bdd4f5d1e127efc2b6d9f8e0acfb8e3018692d5..aa154cb1578ba9d44c7e24c5e76d8238bf8809d0:/src/mac/textctrl.cpp diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 4ba38713d4..6ebd852390 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -55,9 +55,9 @@ #include #endif #include -#include "ATSUnicode.h" -#include "TextCommon.h" -#include "TextEncodingConverter.h" +#include +#include +#include #include "wx/mac/uma.h" #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL @@ -69,8 +69,6 @@ extern wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ; // moment is to avoid setting the true focus on the control, the proper solution at the end would be to have // an alternate path for carbon key events that routes automatically into the same wx flow of events -#include "MacTextEditor.h" - /* part codes */ /* kmUPTextPart is the part code we return to indicate the user has clicked @@ -218,8 +216,17 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart InvalWindowRect( GetControlOwner( theControl ) , &oldbounds ) ; SetRect(&varsp->fRFocusOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); SetRect(&varsp->fRTextOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); - SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , - bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2)); + + if (!wxFindControlFromMacControl(theControl)->HasFlag(wxNO_BORDER)) + { + SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , + bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2)); + } + else + { + SetRect(&varsp->fRTextArea, bounds.left , bounds.top , + bounds.right, bounds.bottom); + } RectRgn(varsp->fTextBackgroundRgn, &varsp->fRTextOutline); if ( IsControlVisible( theControl ) ) TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left, @@ -239,9 +246,12 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart TXNDraw(varsp->fTXNRec, NULL); /* restore the drawing environment */ /* draw the text frame and focus frame (if necessary) */ - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); - if ((**tpvars).fIsActive && varsp->fInFocus) - DrawThemeFocusRect(&varsp->fRFocusOutline, true); + if (!wxFindControlFromMacControl(theControl)->HasFlag(wxNO_BORDER)) + { + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + if ((**tpvars).fIsActive && varsp->fInFocus) + DrawThemeFocusRect(&varsp->fRFocusOutline, true); + } /* release our globals */ HSetState((Handle) tpvars, state); } @@ -421,9 +431,12 @@ static pascal void TPPaneActivateProc(ControlHandle theControl, Boolean activati /* redraw the frame */ if ( IsControlVisible( theControl ) ) { - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); - if (varsp->fInFocus) - DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive); + if (!wxFindControlFromMacControl(theControl)->HasFlag(wxNO_BORDER)) + { + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + if (varsp->fInFocus) + DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive); + } } HSetState((Handle) tpvars, state); } @@ -484,11 +497,14 @@ static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlF new focus state */ if ( IsControlVisible( theControl ) ) { + if (!wxFindControlFromMacControl(theControl)->HasFlag(wxNO_BORDER)) + { /* save the drawing state */ SetPort((**tpvars).fDrawingEnvironment); wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ; - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); - DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive && varsp->fInFocus); + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive && varsp->fInFocus); + } } /* done */ HSetState((Handle) tpvars, state); @@ -550,8 +566,17 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle ) GetControlBounds(theControl, &bounds); SetRect(&varsp->fRFocusOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); SetRect(&varsp->fRTextOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); - SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , - bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2)); + if ((wxStyle & wxNO_BORDER) != wxNO_BORDER) + { + SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , + bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2)); + } + else + { + SetRect(&varsp->fRTextArea, bounds.left , bounds.top , + bounds.right, bounds.bottom); + } + /* calculate the background region for the text. In this case, it's kindof and irregular region because we're setting the scroll bar a little ways inside of the text area. */ @@ -662,16 +687,16 @@ END_EVENT_TABLE() static void SetTXNData( TXNObject txn , const wxString& st , TXNOffset start , TXNOffset end ) { #if wxUSE_UNICODE - size_t len = st.Len() ; #if SIZEOF_WCHAR_T == 2 + size_t len = st.Len() ; TXNSetData( txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end); #else - ByteCount byteBufferLen = len * sizeof( UniChar ) ; - UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; wxMBConvUTF16BE converter ; + ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; + UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; - TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, len * 2, + TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, byteBufferLen , start, end); free( unibuf ) ; #endif @@ -733,7 +758,12 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, return FALSE; wxSize mySize = size ; - if ( m_macUsesTXN ) + if (style & wxNO_BORDER) + { + m_macHorizontalBorder = 0 ; + m_macVerticalBorder = 0 ; + } + else if ( m_macUsesTXN ) { m_macHorizontalBorder = 5 ; // additional pixels around the real control m_macVerticalBorder = 3 ; @@ -852,7 +882,7 @@ wxString wxTextCtrl::GetValue() const } else { - actualSize = GetHandleSize( theText ) ; + actualSize = GetHandleSize( theText ) / sizeof( UniChar) ; if ( actualSize > 0 ) { wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ; @@ -861,11 +891,11 @@ wxString wxTextCtrl::GetValue() const #else wxMBConvUTF16BE converter ; HLock( theText ) ; - converter.MB2WC( ptr , (const char*)*theText , actualSize*sizeof(wxChar) ) ; + converter.MB2WC( ptr , (const char*)*theText , actualSize ) ; HUnlock( theText ) ; #endif ptr[actualSize] = 0 ; - result.UngetWriteBuf( actualSize ) ; + result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ; } DisposeHandle( theText ) ; }