]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/ScintillaWX.cpp
No changes, just simplify the code using wx2stc() a little.
[wxWidgets.git] / src / stc / ScintillaWX.cpp
index d69d494f1bc38d72ef6864409bd6d6f757c41b80..7e1afb39cd91f4ba2aab7dd6fd30f281dbed4151 100644 (file)
@@ -1,5 +1,5 @@
 ////////////////////////////////////////////////////////////////////////////
-// Name:        ScintillaWX.cxx
+// Name:        src/stc/ScintillaWX.cpp
 // Purpose:     A wxWidgets implementation of Scintilla.  A class derived
 //              from ScintillaBase that uses the "wx platform" defined in
 //              PlatformWX.cxx  This class is one end of a bridge between
 #include "wx/clipbrd.h"
 #include "wx/dnd.h"
 
+#if !wxUSE_STD_CONTAINERS && !wxUSE_STD_IOSTREAM && !wxUSE_STD_STRING
+    #include "wx/beforestd.h"
+    #include <string>
+    #include "wx/afterstd.h"
+#endif
+
 #include "ScintillaWX.h"
 #include "ExternalLexer.h"
 #include "wx/stc/stc.h"
@@ -727,25 +733,47 @@ sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam)
 void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
 
     paintState = painting;
-    Surface* surfaceWindow = Surface::Allocate();
-    surfaceWindow->Init(dc, wMain.GetID());
-    rcPaint = PRectangleFromwxRect(rect);
-    PRectangle rcClient = GetClientRectangle();
-    paintingAllText = rcPaint.Contains(rcClient);
-
-    ClipChildren(*dc, rcPaint);
-    Paint(surfaceWindow, rcPaint);
+    AutoSurface surfaceWindow(dc, this);
+    if (surfaceWindow) {
+        rcPaint = PRectangleFromwxRect(rect);
+        PRectangle rcClient = GetClientRectangle();
+        paintingAllText = rcPaint.Contains(rcClient);
+
+        ClipChildren(*dc, rcPaint);
+        Paint(surfaceWindow, rcPaint);
+        surfaceWindow->Release();
+    }
 
-    delete surfaceWindow;
     if (paintState == paintAbandoned) {
         // Painting area was insufficient to cover new styling or brace
         // highlight positions
-        FullPaint();
+        FullPaintDC(dc);
     }
     paintState = notPainting;
 }
 
 
+// Force the whole window to be repainted
+void ScintillaWX::FullPaint() {
+    wxClientDC dc(stc);
+    FullPaintDC(&dc);
+}
+
+
+void ScintillaWX::FullPaintDC(wxDC* dc) {
+    paintState = painting;
+    rcPaint = GetClientRectangle();
+    paintingAllText = true;
+    AutoSurface surfaceWindow(dc, this);
+    if (surfaceWindow) {
+        Paint(surfaceWindow, rcPaint);
+        surfaceWindow->Release();
+    }
+    paintState = notPainting;
+}
+
+
+
 void ScintillaWX::DoHScroll(int type, int pos) {
     int xPos = xOffset;
     PRectangle rcText = GetTextRectangle();
@@ -799,7 +827,7 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta,
     int lines;
 
     if (ctrlDown) {  // Zoom the fonts if Ctrl key down
-        if (rotation < 0) {
+        if (rotation > 0) {
             KeyCommand(SCI_ZOOMIN);
         }
         else {
@@ -913,6 +941,14 @@ void ScintillaWX::DoAddChar(int key) {
 int  ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed)
 {
     int key = evt.GetKeyCode();
+    if (key == WXK_NONE) {
+        // This is a Unicode character not representable in Latin-1 or some key
+        // without key code at all (e.g. dead key or VK_PROCESSKEY under MSW).
+        if ( consumed )
+            *consumed = false;
+        return 0;
+    }
+
     bool shift = evt.ShiftDown(),
          ctrl  = evt.ControlDown(),
          alt   = evt.AltDown();
@@ -955,7 +991,7 @@ int  ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed)
     case WXK_CONTROL:           key = 0; break;
     case WXK_ALT:               key = 0; break;
     case WXK_SHIFT:             key = 0; break;
-    case WXK_MENU:              key = 0; break;
+    case WXK_MENU:              key = SCK_MENU; break;
     }
 
 #ifdef __WXMAC__
@@ -1066,15 +1102,6 @@ void ScintillaWX::DoDragLeave() {
 #endif // wxUSE_DRAG_AND_DROP
 //----------------------------------------------------------------------
 
-// Force the whole window to be repainted
-void ScintillaWX::FullPaint() {
-#ifndef __WXMAC__
-    stc->Refresh(false);
-#endif
-    stc->Update();
-}
-
-
 void ScintillaWX::DoScrollToLine(int line) {
     ScrollTo(line);
 }