-
- /* calculate the rectangles used by the control */
- UMAGetControlBoundsInWindowCoords(m_controlRef, &bounds);
- m_macTXNvars->fRTextOutlineRegion = NewRgn() ;
- TPCalculateBounds( m_macTXNvars , bounds ) ;
-
- /* set up the drawing environment */
- SetPort(m_macTXNvars->fDrawingEnvironment);
-
- /* create the new edit field */
-
- TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( m_windowStyle ) ;
-
- verify_noerr(TXNNewObject(NULL, m_macTXNvars->fOwner, &m_macTXNvars->fRTextArea,
- frameOptions ,
- kTXNTextEditStyleFrameType,
- kTXNTextensionFile,
- kTXNSystemDefaultEncoding,
- &m_macTXNvars->fTXNRec, &m_macTXNvars->fTXNFrame, (TXNObjectRefcon) m_macTXNvars));
- m_txn = m_macTXNvars->fTXNRec ;
-
- /* perform final activations and setup for our text field. Here,
- we assume that the window is going to be the 'active' window. */
- TPActivatePaneText(m_macTXNvars, m_macTXNvars->fIsActive && m_macTXNvars->fInFocus);
- /* all done */
+
+ // calculate the rectangles used by the control
+ GetRectInWindowCoords( &bounds );
+
+ m_txnControlBounds = bounds ;
+ m_txnVisBounds = bounds ;
+
+ CGrafPtr origPort ;
+ GDHandle origDev ;
+
+ GetGWorld( &origPort, &origDev ) ;
+ SetPort( m_txnPort );
+
+ // create the new edit field
+ TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( m_windowStyle );
+
+ // the scrollbars are not correctly embedded but are inserted at the root:
+ // this gives us problems as we have erratic redraws even over the structure area
+
+ m_sbHorizontal = 0 ;
+ m_sbVertical = 0 ;
+ m_lastHorizontalValue = 0 ;
+ m_lastVerticalValue = 0 ;
+
+ Rect sb = { 0 , 0 , 0 , 0 } ;
+ if ( frameOptions & kTXNWantVScrollBarMask )
+ {
+ CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbVertical );
+ SetControlReference( m_sbVertical, (SInt32)this );
+ SetControlAction( m_sbVertical, gTXNScrollActionProc );
+ ShowControl( m_sbVertical );
+ EmbedControl( m_sbVertical , m_controlRef );
+ frameOptions &= ~kTXNWantVScrollBarMask;
+ }
+
+ if ( frameOptions & kTXNWantHScrollBarMask )
+ {
+ CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbHorizontal );
+ SetControlReference( m_sbHorizontal, (SInt32)this );
+ SetControlAction( m_sbHorizontal, gTXNScrollActionProc );
+ ShowControl( m_sbHorizontal );
+ EmbedControl( m_sbHorizontal, m_controlRef );
+ frameOptions &= ~(kTXNWantHScrollBarMask | kTXNDrawGrowIconMask);
+ }
+
+ err = TXNNewObject(
+ NULL, m_txnWindow, &bounds, frameOptions,
+ kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding,
+ &m_txn, &m_txnFrameID, NULL );
+ verify_noerr( err );
+
+#if 0
+ TXNControlTag iControlTags[] = { kTXNUseCarbonEvents };
+ TXNControlData iControlData[] = { { (UInt32)&cInfo } };
+ int toptag = WXSIZEOF( iControlTags ) ;
+ TXNCarbonEventInfo cInfo ;
+ cInfo.useCarbonEvents = false ;
+ cInfo.filler = 0 ;
+ cInfo.flags = 0 ;
+ cInfo.fDictionary = NULL ;
+
+ verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) );
+#endif
+
+ TXNRegisterScrollInfoProc( m_txn, gTXNScrollInfoProc, (SInt32)this );
+
+ SetGWorld( origPort , origDev ) ;
+