#include "TextEncodingConverter.h"
#include "wx/mac/uma.h"
-#define wxMAC_USE_CARBON_EVENTS 0
-
extern wxApp *wxTheApp ;
// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
ControlUserPaneActivateUPP gTPActivateProc = NULL;
ControlUserPaneFocusUPP gTPFocusProc = NULL;
- /* events handled by our focus advance override routine */
-#if TARGET_CARBON
-#if wxMAC_USE_CARBON_EVENTS
-static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
-#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
-#endif
-#endif
-
-
/* TPActivatePaneText activates or deactivates the text edit record
according to the value of setActive. The primary purpose of this
routine is to ensure each call is only made once. */
TXNActivate(varsp->fTXNRec, varsp->fTXNFrame, varsp->fTEActive);
-#if !TARGET_CARBON
if (varsp->fInFocus)
TXNFocus( varsp->fTXNRec, varsp->fTEActive);
-#endif
}
}
varsp = *tpvars;
if (varsp->fInFocus != setFocus) {
varsp->fInFocus = setFocus;
-#if !TARGET_CARBON
TXNFocus( varsp->fTXNRec, varsp->fInFocus);
-#endif
}
}
char state;
Rect bounds;
/* set up our globals */
+
tpvars = (STPTextPaneVars **) GetControlReference(theControl);
if (tpvars != NULL) {
state = HGetState((Handle) tpvars);
Rect oldbounds = varsp->fRFocusOutline ;
InsetRect( &oldbounds , -1 , -1 ) ;
-// InvalWindowRect( GetControlOwner( theControl ) , &oldbounds ) ;
+ 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) ,
if ((**tpvars).fInFocus) {
/* turn autoscrolling on and send the key event to text edit */
SetPort((**tpvars).fDrawingEnvironment);
- TXNKeyDown( (**tpvars).fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
+ EventRecord ev ;
+ memset( &ev , 0 , sizeof( ev ) ) ;
+ ev.what = keyDown ;
+ ev.modifiers = modifiers ;
+ ev.message = (( keyCode & keyCodeMask ) << 8 ) + ( charCode & charCodeMask ) ;
+ TXNKeyDown( (**tpvars).fTXNRec, &ev);
}
}
return kControlEntireControl;
return focusResult;
}
-//This our carbon event handler for unicode key downs
-#if TARGET_CARBON
-#if wxMAC_USE_CARBON_EVENTS
-static pascal OSStatus FocusAdvanceOverride(EventHandlerCallRef myHandler, EventRef event, void* userData) {
- WindowRef window;
- STPTextPaneVars **tpvars;
- OSStatus err;
- unsigned short mUnicodeText;
- ByteCount charCounts=0;
- /* get our window pointer */
- tpvars = (STPTextPaneVars **) userData;
- window = (**tpvars).fOwner;
- //find out how many bytes are needed
- err = GetEventParameter(event, kEventParamTextInputSendText,
- typeUnicodeText, NULL, 0, &charCounts, NULL);
- if (err != noErr) goto bail;
- /* we're only looking at single characters */
- if (charCounts != 2) { err = eventNotHandledErr; goto bail; }
- /* get the character */
- err = GetEventParameter(event, kEventParamTextInputSendText,
- typeUnicodeText, NULL, sizeof(mUnicodeText),
- &charCounts, (char*) &mUnicodeText);
- if (err != noErr) goto bail;
- /* if it's not the tab key, forget it... */
- if ((mUnicodeText != '\t')) { err = eventNotHandledErr; goto bail; }
- /* advance the keyboard focus */
- AdvanceKeyboardFocus(window);
- /* noErr lets the CEM know we handled the event */
- return noErr;
-bail:
- return eventNotHandledErr;
-}
-#endif
-#endif
-
/* mUPOpenControl initializes a user pane control so it will be drawn
and will behave as a scrolling text edit field inside of a window.
/* create the new edit field */
TXNNewObject(NULL, varsp->fOwner, &varsp->fRTextArea,
( multiline ? kTXNWantVScrollBarMask : 0 ) |
-#if !TARGET_CARBON
kTXNDontDrawCaretWhenInactiveMask |
kTXNDontDrawSelectionWhenInactiveMask |
-#endif
- kTXNAlwaysWrapAtViewEdgeMask,
+ kTXNAlwaysWrapAtViewEdgeMask,
kTXNTextEditStyleFrameType,
kTXNTextensionFile,
kTXNSystemDefaultEncoding,
tback.bgType = kTXNBackgroundTypeRGB;
tback.bg.color = rgbWhite;
TXNSetBackground( varsp->fTXNRec, &tback);
-
- /* install our focus advance override routine */
-#if TARGET_CARBON
-#if wxMAC_USE_CARBON_EVENTS
- varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride);
- err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
- kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
-#endif
-#endif
/* unlock our storage */
HUnlock((Handle) tpvars);
{
SetControlReference((ControlHandle)m_macControl, 0) ;
TXNDeleteObject((TXNObject)m_macTXN);
- #if TARGET_CARBON
-#if wxMAC_USE_CARBON_EVENTS
- /* remove our focus advance override */
- ::RemoveEventHandler((**(STPTextPaneVars **) m_macTXNvars).handlerRef);
- ::DisposeEventHandlerUPP((**(STPTextPaneVars **) m_macTXNvars).handlerUPP);
- #endif
-#endif
/* delete our private storage */
DisposeHandle((Handle) m_macTXNvars);
/* zero the control reference */
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 );
+ if ( parent )
+ {
+ parent->MacGetTopLevelWindow()->MacInstallEventHandler() ;
+ }
}
MacPostControlCreate() ;
}
}
+void wxTextCtrl::MacSuperShown( bool show )
+{
+ bool former = m_macControlIsShown ;
+ wxControl::MacSuperShown( show ) ;
+ if ( (former != m_macControlIsShown) && m_macUsesTXN )
+ {
+ if ( m_macControlIsShown )
+ TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
+ (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom,(**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
+ else
+ TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
+ (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
+ }
+}
+
+bool wxTextCtrl::Show(bool show)
+{
+ bool former = m_macControlIsShown ;
+
+ bool retval = wxControl::Show( show ) ;
+
+ if ( former != m_macControlIsShown )
+ {
+ if ( m_macControlIsShown )
+ TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
+ (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom,(**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
+ else
+ TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
+ (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
+ }
+
+ return retval ;
+}
+
// ----------------------------------------------------------------------------
// standard handlers for standard edit menu events
// ----------------------------------------------------------------------------