corrected line counts and implemented ShowPosition

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-02-08 10:56:48 +00:00
parent 5c250a1033
commit 3a05d58d94
2 changed files with 76 additions and 18 deletions

View File

@@ -24,6 +24,8 @@
#include <stat.h>
#endif
#include "wx/msgdlg.h"
#if wxUSE_STD_IOSTREAM
#if wxUSE_IOSTREAMH
#include <fstream.h>
@@ -878,7 +880,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
}
else
{
TXNGetSelection( ((TXNObject) m_macTXN) , (TXNOffset*) from , (TXNOffset*) to ) ;
TXNGetSelection( (TXNObject) m_macTXN , (TXNOffset*) from , (TXNOffset*) to ) ;
}
}
@@ -1442,7 +1444,14 @@ void wxTextCtrl::DiscardEdits()
int wxTextCtrl::GetNumberOfLines() const
{
// TODO change this if possible to reflect real lines
if ( m_macUsesTXN )
{
ItemCount lines ;
TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
return lines ;
}
else
{
wxString content = GetValue() ;
int count = 1;
@@ -1450,9 +1459,9 @@ int wxTextCtrl::GetNumberOfLines() const
{
if (content[i] == '\r') count++;
}
return count;
}
}
long wxTextCtrl::XYToPosition(long x, long y) const
{
@@ -1467,7 +1476,27 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
void wxTextCtrl::ShowPosition(long pos)
{
// TODO
#if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER)
if ( m_macUsesTXN )
{
Point current ;
Point desired ;
TXNOffset selstart , selend ;
TXNGetSelection( (TXNObject) m_macTXN , &selstart , &selend) ;
TXNOffsetToPoint( (TXNObject) m_macTXN, selstart , &current);
TXNOffsetToPoint( (TXNObject) m_macTXN, pos , &desired);
//TODO use HIPoints for 10.3 and above
if ( (UInt32) TXNScroll != (UInt32) kUnresolvedCFragSymbolAddress )
{
OSErr theErr = noErr;
SInt32 dv = desired.v - current.v ;
SInt32 dh = desired.h - current.h ;
TXNShowSelection( (TXNObject) m_macTXN , true ) ;
theErr = TXNScroll( (TXNObject) m_macTXN, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh );
wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
}
}
#endif
}
int wxTextCtrl::GetLineLength(long lineNo) const

View File

@@ -24,6 +24,8 @@
#include <stat.h>
#endif
#include "wx/msgdlg.h"
#if wxUSE_STD_IOSTREAM
#if wxUSE_IOSTREAMH
#include <fstream.h>
@@ -878,7 +880,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
}
else
{
TXNGetSelection( ((TXNObject) m_macTXN) , (TXNOffset*) from , (TXNOffset*) to ) ;
TXNGetSelection( (TXNObject) m_macTXN , (TXNOffset*) from , (TXNOffset*) to ) ;
}
}
@@ -1442,7 +1444,14 @@ void wxTextCtrl::DiscardEdits()
int wxTextCtrl::GetNumberOfLines() const
{
// TODO change this if possible to reflect real lines
if ( m_macUsesTXN )
{
ItemCount lines ;
TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
return lines ;
}
else
{
wxString content = GetValue() ;
int count = 1;
@@ -1450,9 +1459,9 @@ int wxTextCtrl::GetNumberOfLines() const
{
if (content[i] == '\r') count++;
}
return count;
}
}
long wxTextCtrl::XYToPosition(long x, long y) const
{
@@ -1467,7 +1476,27 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
void wxTextCtrl::ShowPosition(long pos)
{
// TODO
#if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER)
if ( m_macUsesTXN )
{
Point current ;
Point desired ;
TXNOffset selstart , selend ;
TXNGetSelection( (TXNObject) m_macTXN , &selstart , &selend) ;
TXNOffsetToPoint( (TXNObject) m_macTXN, selstart , &current);
TXNOffsetToPoint( (TXNObject) m_macTXN, pos , &desired);
//TODO use HIPoints for 10.3 and above
if ( (UInt32) TXNScroll != (UInt32) kUnresolvedCFragSymbolAddress )
{
OSErr theErr = noErr;
SInt32 dv = desired.v - current.v ;
SInt32 dh = desired.h - current.h ;
TXNShowSelection( (TXNObject) m_macTXN , true ) ;
theErr = TXNScroll( (TXNObject) m_macTXN, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh );
wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
}
}
#endif
}
int wxTextCtrl::GetLineLength(long lineNo) const