]> git.saurik.com Git - wxWidgets.git/commitdiff
corrected line counts and implemented ShowPosition
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 8 Feb 2004 10:56:48 +0000 (10:56 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 8 Feb 2004 10:56:48 +0000 (10:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/textctrl.cpp
src/mac/textctrl.cpp

index ad911c398783ed0ab2b4de559f92f4ef80161887..69a1ddfacc4b8c50d0834c8c6f937bd9a1f74a33 100644 (file)
@@ -24,6 +24,8 @@
   #include <stat.h>
 #endif
 
   #include <stat.h>
 #endif
 
+#include "wx/msgdlg.h"
+
 #if wxUSE_STD_IOSTREAM
     #if wxUSE_IOSTREAMH
         #include <fstream.h>
 #if wxUSE_STD_IOSTREAM
     #if wxUSE_IOSTREAMH
         #include <fstream.h>
@@ -878,7 +880,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
    }
    else
    {
    }
    else
    {
-        TXNGetSelection(  ((TXNObject) m_macTXN) , (TXNOffset*) from , (TXNOffset*) to ) ;
+        TXNGetSelection( (TXNObject) m_macTXN , (TXNOffset*) from , (TXNOffset*) to ) ;
    }
 }
 
    }
 }
 
@@ -1442,16 +1444,23 @@ void wxTextCtrl::DiscardEdits()
 
 int wxTextCtrl::GetNumberOfLines() const
 {
 
 int wxTextCtrl::GetNumberOfLines() const
 {
-    // TODO change this if possible to reflect real lines
-    wxString content = GetValue() ;
-
-    int count = 1;
-    for (size_t i = 0; i < content.Length() ; i++)
+    if ( m_macUsesTXN ) 
     {
     {
-        if (content[i] == '\r') count++;
+       ItemCount lines ;
+               TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
+               return lines ;
     }
     }
+    else
+    {          
+           wxString content = GetValue() ;
 
 
-    return count;
+           int count = 1;
+           for (size_t i = 0; i < content.Length() ; i++)
+           {
+               if (content[i] == '\r') count++;
+           }
+       return count;
+    }
 }
 
 long wxTextCtrl::XYToPosition(long x, long y) const
 }
 
 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)
 {
 
 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
 }
 
 int wxTextCtrl::GetLineLength(long lineNo) const
index ad911c398783ed0ab2b4de559f92f4ef80161887..69a1ddfacc4b8c50d0834c8c6f937bd9a1f74a33 100644 (file)
@@ -24,6 +24,8 @@
   #include <stat.h>
 #endif
 
   #include <stat.h>
 #endif
 
+#include "wx/msgdlg.h"
+
 #if wxUSE_STD_IOSTREAM
     #if wxUSE_IOSTREAMH
         #include <fstream.h>
 #if wxUSE_STD_IOSTREAM
     #if wxUSE_IOSTREAMH
         #include <fstream.h>
@@ -878,7 +880,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
    }
    else
    {
    }
    else
    {
-        TXNGetSelection(  ((TXNObject) m_macTXN) , (TXNOffset*) from , (TXNOffset*) to ) ;
+        TXNGetSelection( (TXNObject) m_macTXN , (TXNOffset*) from , (TXNOffset*) to ) ;
    }
 }
 
    }
 }
 
@@ -1442,16 +1444,23 @@ void wxTextCtrl::DiscardEdits()
 
 int wxTextCtrl::GetNumberOfLines() const
 {
 
 int wxTextCtrl::GetNumberOfLines() const
 {
-    // TODO change this if possible to reflect real lines
-    wxString content = GetValue() ;
-
-    int count = 1;
-    for (size_t i = 0; i < content.Length() ; i++)
+    if ( m_macUsesTXN ) 
     {
     {
-        if (content[i] == '\r') count++;
+       ItemCount lines ;
+               TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
+               return lines ;
     }
     }
+    else
+    {          
+           wxString content = GetValue() ;
 
 
-    return count;
+           int count = 1;
+           for (size_t i = 0; i < content.Length() ; i++)
+           {
+               if (content[i] == '\r') count++;
+           }
+       return count;
+    }
 }
 
 long wxTextCtrl::XYToPosition(long x, long y) const
 }
 
 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)
 {
 
 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
 }
 
 int wxTextCtrl::GetLineLength(long lineNo) const