TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
}
+
+ // in case MLTE is catching events before we get the chance to do so, we'd have to reintroduce the tlw-handler in front :
+ // parent->MacGetTopLevelWindow()->MacInstallTopLevelWindowEventHandler() ;
SetBackgroundColour( *wxWHITE ) ;
long wxTextCtrl::XYToPosition(long x, long y) const
{
- // TODO
+ Point curpt ;
+
+ long lastpos = GetLastPosition() ;
+
+ // TODO find a better implementation : while we can get the
+ // line metrics of a certain line, we don't get its starting
+ // position, so it would probably be rather a binary search
+ // for the start position
+ long xpos = 0 ;
+ long ypos = 0 ;
+ int lastHeight = 0 ;
+
+ ItemCount n ;
+ for ( n = 0 ; n <= lastpos ; ++n )
+ {
+ if ( y == ypos && x == xpos )
+ return n ;
+
+ TXNOffsetToPoint( (TXNObject) m_macTXN, n , &curpt);
+
+ if ( curpt.v > lastHeight )
+ {
+ xpos = 0 ;
+ if ( n > 0 )
+ ++ypos ;
+ lastHeight = curpt.v ;
+ }
+ else
+ ++xpos ;
+ }
+
return 0;
}
bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
{
+ Point curpt ;
+
+ long lastpos = GetLastPosition() ;
+
+ if ( y ) *y = 0 ;
+ if ( x ) *x = 0 ;
+
+ if ( pos <= lastpos )
+ {
+ // TODO find a better implementation : while we can get the
+ // line metrics of a certain line, we don't get its starting
+ // position, so it would probably be rather a binary search
+ // for the start position
+ long xpos = 0 ;
+ long ypos = 0 ;
+ int lastHeight = 0 ;
+
+ ItemCount n ;
+ for ( n = 0 ; n <= pos ; ++n )
+ {
+ TXNOffsetToPoint( (TXNObject) m_macTXN, n , &curpt);
+
+ if ( curpt.v > lastHeight )
+ {
+ xpos = 0 ;
+ if ( n > 0 )
+ ++ypos ;
+ lastHeight = curpt.v ;
+ }
+ else
+ ++xpos ;
+ }
+ if ( y ) *y = ypos ;
+ if ( x ) *x = xpos ;
+ }
+
return FALSE ;
}
int wxTextCtrl::GetLineLength(long lineNo) const
{
- // TODO change this if possible to reflect real lines
- wxString content = GetValue() ;
-
- // Find line first
- int count = 0;
- for (size_t i = 0; i < content.Length() ; i++)
+ Point curpt ;
+ if ( lineNo < GetNumberOfLines() )
{
- if (count == lineNo)
+ // TODO find a better implementation : while we can get the
+ // line metrics of a certain line, we don't get its starting
+ // position, so it would probably be rather a binary search
+ // for the start position
+ long xpos = 0 ;
+ long ypos = 0 ;
+ int lastHeight = 0 ;
+ long lastpos = GetLastPosition() ;
+
+ ItemCount n ;
+ for ( n = 0 ; n <= lastpos ; ++n )
{
- // Count chars in line then
- count = 0;
- for (size_t j = i; j < content.Length(); j++)
+ TXNOffsetToPoint( (TXNObject) m_macTXN, n , &curpt);
+
+ if ( curpt.v > lastHeight )
{
- count++;
- if (content[j] == '\n') return count;
+ if ( ypos == lineNo )
+ return xpos ;
+
+ xpos = 0 ;
+ if ( n > 0 )
+ ++ypos ;
+ lastHeight = curpt.v ;
}
-
- return count;
+ else
+ ++xpos ;
}
- if (content[i] == '\n') count++;
}
+
return 0;
}
wxString wxTextCtrl::GetLineText(long lineNo) const
{
- // TODO change this if possible to reflect real lines
+ Point curpt ;
+ wxString line ;
wxString content = GetValue() ;
- // Find line first
- int count = 0;
- for (size_t i = 0; i < content.Length() ; i++)
+ if ( lineNo < GetNumberOfLines() )
{
- if (count == lineNo)
+ // TODO find a better implementation : while we can get the
+ // line metrics of a certain line, we don't get its starting
+ // position, so it would probably be rather a binary search
+ // for the start position
+ long xpos = 0 ;
+ long ypos = 0 ;
+ int lastHeight = 0 ;
+ long lastpos = GetLastPosition() ;
+
+ ItemCount n ;
+ for ( n = 0 ; n <= lastpos ; ++n )
{
- // Add chars in line then
- wxString tmp;
+ TXNOffsetToPoint( (TXNObject) m_macTXN, n , &curpt);
- for (size_t j = i; j < content.Length(); j++)
+ if ( curpt.v > lastHeight )
{
- if (content[j] == '\n')
- return tmp;
-
- tmp += content[j];
+ if ( ypos == lineNo )
+ return line ;
+
+ xpos = 0 ;
+ if ( n > 0 )
+ ++ypos ;
+ lastHeight = curpt.v ;
+ }
+ else
+ {
+ if ( ypos == lineNo )
+ line += content[n] ;
+ ++xpos ;
}
-
- return tmp;
}
- if (content[i] == '\n') count++;
}
- return wxEmptyString ;
+
+ return line ;
}
/*