+// guards against inappropriate redraw (hidden objects drawing onto window)
+
+void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis)
+{
+ ControlRef controlFocus = 0 ;
+ GetKeyboardFocus( m_txnWindow , &controlFocus ) ;
+
+ if ( !vis && (controlFocus == m_controlRef ) )
+ SetKeyboardFocus( m_txnWindow , m_controlRef , kControlFocusNoPart ) ;
+
+ TXNControlTag iControlTags[1] = { kTXNVisibilityTag };
+ TXNControlData iControlData[1] = { { (UInt32)false } };
+
+ verify_noerr( TXNGetTXNObjectControls( m_txn , 1, iControlTags, iControlData ) ) ;
+
+ if ( iControlData[0].uValue != vis )
+ {
+ iControlData[0].uValue = vis ;
+ verify_noerr( TXNSetTXNObjectControls( m_txn, false , 1, iControlTags, iControlData ) ) ;
+ }
+
+ // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
+ // if we run into further problems we might set the FrameBounds to an empty rect here
+}
+
+// make sure that the TXNObject is at the right position
+
+void wxMacMLTEClassicControl::MacUpdatePosition()
+{
+ wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
+ if ( textctrl == NULL )
+ return ;
+
+ Rect bounds ;
+ UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
+
+ wxRect visRect = textctrl->MacGetClippedClientRect() ;
+ Rect visBounds = { visRect.y , visRect.x , visRect.y + visRect.height , visRect.x + visRect.width } ;
+ int x , y ;
+ x = y = 0 ;
+ textctrl->MacWindowToRootWindow( &x , &y ) ;
+ OffsetRect( &visBounds , x , y ) ;
+
+ if ( !EqualRect( &bounds, &m_txnControlBounds ) || !EqualRect( &visBounds, &m_txnVisBounds ) )
+ {
+ m_txnControlBounds = bounds ;
+ m_txnVisBounds = visBounds ;
+ wxMacWindowClipper cl( textctrl ) ;
+
+#ifdef __WXMAC_OSX__
+ bool isCompositing = textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ;
+ if ( m_sbHorizontal || m_sbVertical )
+ {
+ int w = bounds.right - bounds.left ;
+ int h = bounds.bottom - bounds.top ;
+
+ if ( m_sbHorizontal )
+ {
+ Rect sbBounds ;
+
+ sbBounds.left = -1 ;
+ sbBounds.top = h - 14 ;
+ sbBounds.right = w + 1 ;
+ sbBounds.bottom = h + 1 ;
+
+ if ( !isCompositing )
+ OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ;
+
+ SetControlBounds( m_sbHorizontal , &sbBounds ) ;
+ SetControlViewSize( m_sbHorizontal , w ) ;
+ }
+
+ if ( m_sbVertical )
+ {
+ Rect sbBounds ;
+
+ sbBounds.left = w - 14 ;
+ sbBounds.top = -1 ;
+ sbBounds.right = w + 1 ;
+ sbBounds.bottom = m_sbHorizontal ? h - 14 : h + 1 ;
+
+ if ( !isCompositing )
+ OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ;
+
+ SetControlBounds( m_sbVertical , &sbBounds ) ;
+ SetControlViewSize( m_sbVertical , h ) ;
+ }
+ }
+
+ Rect oldviewRect ;
+ TXNLongRect olddestRect ;
+ TXNGetRectBounds( m_txn , &oldviewRect , &olddestRect , NULL ) ;
+
+ Rect viewRect = { m_txnControlBounds.top, m_txnControlBounds.left,
+ m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) ,
+ m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ;
+ TXNLongRect destRect = { m_txnControlBounds.top, m_txnControlBounds.left,
+ m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) ,
+ m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ;
+
+ if ( olddestRect.right >= 10000 )
+ destRect.right = destRect.left + 32000 ;
+
+ if ( olddestRect.bottom >= 0x20000000 )
+ destRect.bottom = destRect.top + 0x40000000 ;
+
+ SectRect( &viewRect , &visBounds , &viewRect ) ;
+ TXNSetRectBounds( m_txn , &viewRect , &destRect , true ) ;
+
+#if 0
+ TXNSetFrameBounds(
+ m_txn,
+ m_txnControlBounds.top,
+ m_txnControlBounds.left,
+ m_txnControlBounds.bottom - (m_sbHorizontal ? 14 : 0),
+ m_txnControlBounds.right - (m_sbVertical ? 14 : 0),
+ m_txnFrameID );
+#endif
+#else
+
+ TXNSetFrameBounds(
+ m_txn, m_txnControlBounds.top, m_txnControlBounds.left,
+ wxMax( m_txnControlBounds.bottom, m_txnControlBounds.top ),
+ wxMax( m_txnControlBounds.right, m_txnControlBounds.left ), m_txnFrameID );
+#endif
+
+ // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
+ // movement, therefore we have to force it
+
+ // this problem has been reported in OSX as well, so we use this here once again
+
+ TXNLongRect textRect ;
+ TXNGetRectBounds( m_txn , NULL , NULL , &textRect ) ;
+ if ( textRect.left < m_txnControlBounds.left )
+ TXNShowSelection( m_txn , kTXNShowStart ) ;