]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textcmn.cpp
Dramatically optimise inserting many items in wxGenericListCtrl.
[wxWidgets.git] / src / common / textcmn.cpp
index 96f70e5d4725b02fed425415d8ecfa2e76888091..d64baccfb743c73d8cf8a6f0a9cc7409638e4320 100644 (file)
@@ -773,7 +773,7 @@ bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags)
 {
     int relevantBitsA = valueA & flags;
     int relevantBitsB = valueB & flags;
-    return (relevantBitsA != relevantBitsB);
+    return relevantBitsA == relevantBitsB;
 }
 
 /// Split into paragraph and character styles
@@ -940,12 +940,47 @@ int wxTextCtrlBase::overflow(int c)
 
 bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
 {
+    bool handled = false;
     // we have a native implementation for Win32 and so don't need this one
 #ifndef __WIN32__
     wxChar ch = 0;
     int keycode = event.GetKeyCode();
+    
+    long from, to;
+    GetSelection(&from,&to);
+    long insert = GetInsertionPoint();
+    long last = GetLastPosition();
+    
+    // catch arrow left and right 
+    
     switch ( keycode )
     {
+        case WXK_LEFT:
+            if ( event.ShiftDown() )
+                SetSelection( (from > 0 ? from - 1 : 0) , to );
+            else
+            {
+                if ( from != to )
+                    insert = from;
+                else if ( insert > 0 )
+                    insert -= 1;
+                SetInsertionPoint( insert );
+            }
+            handled = true;
+            break;
+        case WXK_RIGHT:
+            if ( event.ShiftDown() )
+                SetSelection( from, (to < last ? to + 1 : last) );
+            else
+            {
+                if ( from != to )
+                    insert = to;
+                else if ( insert < last )
+                    insert += 1;
+                SetInsertionPoint( insert );
+            }
+            handled = true;
+            break;
         case WXK_NUMPAD0:
         case WXK_NUMPAD1:
         case WXK_NUMPAD2:
@@ -991,6 +1026,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
                 const long pos = GetInsertionPoint();
                 if ( pos < GetLastPosition() )
                     Remove(pos, pos + 1);
+                handled = true;
             }
             break;
 
@@ -1000,6 +1036,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
                 const long pos = GetInsertionPoint();
                 if ( pos > 0 )
                     Remove(pos - 1, pos);
+                handled = true;
             }
             break;
 
@@ -1031,13 +1068,13 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
     {
         WriteText(ch);
 
-        return true;
+        handled = true;
     }
 #else // __WIN32__
     wxUnusedVar(event);
 #endif // !__WIN32__/__WIN32__
 
-    return false;
+    return handled;
 }
 
 // do the window-specific processing after processing the update event
@@ -1084,6 +1121,19 @@ wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const
     return wxTE_HT_UNKNOWN;
 }
 
+wxPoint wxTextAreaBase::PositionToCoords(long pos) const
+{
+    wxCHECK_MSG( IsValidPosition(pos), wxDefaultPosition,
+                 wxS("Position argument out of range.") );
+
+    return DoPositionToCoords(pos);
+}
+
+wxPoint wxTextAreaBase::DoPositionToCoords(long WXUNUSED(pos)) const
+{
+    return wxDefaultPosition;
+}
+
 #else // !wxUSE_TEXTCTRL
 
 // define this one even if !wxUSE_TEXTCTRL because it is also used by other