X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b2b1638a203ea88439e07d967aaa2c95373729a..4855a4773e9a49c6bb70f1adc3da7109e0b6ccf7:/src/mac/textctrl.cpp?ds=sidebyside diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 3b7918178b..f7b6eee18a 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -159,7 +159,6 @@ typedef struct { /* OS records referenced */ TXNObject fTXNRec; /* the txn record */ TXNFrameID fTXNFrame; /* the txn frame ID */ - bool fMultiline ; ControlHandle fUserPaneRec; /* handle to the user pane control */ WindowPtr fOwner; /* window containing control */ GrafPtr fDrawingEnvironment; /* grafport where control is drawn */ @@ -176,6 +175,7 @@ typedef struct { /* our focus advance override routine */ EventHandlerUPP handlerUPP; EventHandlerRef handlerRef; + bool fMultiline ; } STPTextPaneVars; @@ -194,8 +194,8 @@ ControlUserPaneFocusUPP gTPFocusProc = NULL; /* events handled by our focus advance override routine */ #if TARGET_CARBON -//static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } }; -//#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec )) +static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } }; +#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec )) #endif @@ -524,7 +524,7 @@ static pascal OSStatus FocusAdvanceOverride(EventHandlerCallRef myHandler, Event /* noErr lets the CEM know we handled the event */ return noErr; bail: - return eventNotHandledErr; + return eventNotHandledErr; } #endif @@ -601,21 +601,18 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) kTXNSystemDefaultEncoding, &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars); - /* set the field's font and style */ - TXNTypeAttributes typeAttr[2]; - typeAttr[0].tag = kTXNQDFontSizeAttribute; - typeAttr[0].size = kTXNFontSizeAttributeSize; - typeAttr[0].data.dataValue = 10 << 16; - - typeAttr[1].tag = kTXNQDFontStyleAttribute; - typeAttr[1].size = kTXNQDFontStyleAttributeSize; - typeAttr[1].data.dataValue = normal ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; - /* this does not seem to get the font id through - typeAttr[2].tag = kTXNQDFontFamilyIDAttribute ; // NameAttribute; - typeAttr[2].size = kTXNQDFontFamilyIDAttributeSize ; // kTXNQDFontNameAttributeSize; - typeAttr[2].data.dataValue = kFontIDTimes ; // (void*) "\pGeneva" ; - */ + TXNTypeAttributes typeAttr[] = + { + { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } , + { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } , + { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } , + } ; OSStatus status = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr, kTXNStartOffset, @@ -627,9 +624,9 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) /* install our focus advance override routine */ #if TARGET_CARBON -// varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride); -// err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP, -// kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef ); + varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride); + err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP, + kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef ); #endif /* unlock our storage */ @@ -667,8 +664,9 @@ END_EVENT_TABLE() // Text item wxTextCtrl::wxTextCtrl() { - ((TEHandle) m_macTE) = NULL ; - ((TXNObject) m_macTXN) = NULL ; + m_macTE = NULL ; + m_macTXN = NULL ; + m_macTXNvars = NULL ; m_macUsesTXN = false ; m_editable = true ; } @@ -677,16 +675,16 @@ wxTextCtrl::~wxTextCtrl() { if ( m_macUsesTXN ) { + SetControlReference((ControlHandle)m_macControl, 0) ; TXNDeleteObject((TXNObject)m_macTXN); #if TARGET_CARBON /* remove our focus advance override */ - // RemoveEventHandler((**tpvars).handlerRef); - // DisposeEventHandlerUPP((**tpvars).handlerUPP); + ::RemoveEventHandler((**(STPTextPaneVars **) m_macTXNvars).handlerRef); + ::DisposeEventHandlerUPP((**(STPTextPaneVars **) m_macTXNvars).handlerUPP); #endif /* delete our private storage */ DisposeHandle((Handle) m_macTXNvars); /* zero the control reference */ - SetControlReference((ControlHandle)m_macControl, 0) ; } } @@ -700,8 +698,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - ((TEHandle) m_macTE) = NULL ; - ((TXNObject) m_macTXN) = NULL ; + m_macTE = NULL ; + m_macTXN = NULL ; + m_macTXNvars = NULL ; m_macUsesTXN = false ; m_editable = true ; @@ -728,17 +727,16 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - + /* if ( mySize.y == -1 ) { - if ( !m_macUsesTXN ) - mySize.y = 13 ; - else - mySize.y = 16 ; + mySize.y = 13 ; + if ( m_windowStyle & wxTE_MULTILINE ) + mySize.y *= 5 ; mySize.y += 2 * m_macVerticalBorder ; } - + */ MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; if ( m_windowStyle & wxTE_MULTILINE ) @@ -752,7 +750,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( !m_macUsesTXN ) { - m_macControl = ::NewControl( (GrafPtr) parent->MacGetRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , true , 0 , 0 , 1, (style & wxTE_PASSWORD) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ; long size ; ::GetControlData((ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &((TEHandle) m_macTE) , &size ) ; @@ -762,11 +760,11 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, { short featurSet; - featurSet = kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle + featurSet = kControlSupportsEmbedding | kControlSupportsFocus // | kControlWantsIdle | kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground | kControlGetsFocusOnClick | kControlSupportsLiveFeedback; /* create the control */ - m_macControl = NewControl((GrafPtr) parent->MacGetRootWindow(), &bounds, "\p", true, featurSet, 0, featurSet, kControlUserPaneProc, 0); + m_macControl = NewControl(MAC_WXHWND(parent->MacGetRootWindow()), &bounds, "\p", true, featurSet, 0, featurSet, kControlUserPaneProc, 0); /* set up the mUP specific features and data */ mUPOpenControl((ControlHandle) m_macControl, m_windowStyle & wxTE_MULTILINE ); } @@ -1129,7 +1127,7 @@ void wxTextCtrl::WriteText(const wxString& text) } else { - TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (const char*)value, value.Length(), + TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(), kTXNUseCurrentSelection, kTXNUseCurrentSelection); } MacRedrawControl() ; @@ -1179,12 +1177,15 @@ wxSize wxTextCtrl::DoGetBestSize() const { int wText = 100 ; - int hText ; - if ( UMAHasAppearance() ) - hText = 13 ; - else - hText = 24 ; - hText += 2 * m_macHorizontalBorder ; + int hText; + if ( m_macUsesTXN ) + { + hText = 17 ; + } + else + { + hText = 13 ; + } /* int cx, cy; wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); @@ -1197,8 +1198,10 @@ wxSize wxTextCtrl::DoGetBestSize() const */ if ( m_windowStyle & wxTE_MULTILINE ) { - hText *= wxMin(GetNumberOfLines(), 5); + hText *= 5 ; } + hText += 2 * m_macVerticalBorder ; + wText += 2 * m_macHorizontalBorder ; //else: for single line control everything is ok return wxSize(wText, hText); } @@ -1319,6 +1322,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const } if (content[i] == '\r') count++; } + return "" ; } /*