]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/stc/ScintillaWX.cpp
Typos fixed and further clarification of the Python situation on Panther
[wxWidgets.git] / contrib / src / stc / ScintillaWX.cpp
index 9c6d8600edf99172c0d73687fa248fb890286619..26e966cf36e90d6ba10fc83cdec3268daef8f740 100644 (file)
@@ -19,6 +19,7 @@
 #include "ExternalLexer.h"
 #include "wx/stc/stc.h"
 #include "PlatWX.h"
 #include "ExternalLexer.h"
 #include "wx/stc/stc.h"
 #include "PlatWX.h"
+#include <wx/textbuf.h>
 
 //----------------------------------------------------------------------
 // Helper classes
 
 //----------------------------------------------------------------------
 // Helper classes
@@ -136,6 +137,7 @@ END_EVENT_TABLE()
 
 ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
     capturedMouse = false;
 
 ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
     capturedMouse = false;
+    focusEvent = false;
     wMain = win;
     stc   = win;
     wheelRotation = 0;
     wMain = win;
     stc   = win;
     wheelRotation = 0;
@@ -333,6 +335,18 @@ void ScintillaWX::NotifyParent(SCNotification scn) {
 }
 
 
 }
 
 
+// This method is overloaded from ScintillaBase in order to prevent the
+// AutoComplete window from being destroyed when it gets the focus.  There is
+// a side effect that the AutoComp will also not be destroyed when switching
+// to another window, but I think that is okay.
+void ScintillaWX::CancelModes() {
+    if (! focusEvent)
+        AutoCompleteCancel();
+    ct.CallTipCancel();
+    Editor::CancelModes();
+}
+
+
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
 
 void ScintillaWX::Copy() {
     if (currentPos != anchor) {
@@ -371,7 +385,7 @@ void ScintillaWX::Paste() {
 void ScintillaWX::CopyToClipboard(const SelectionText& st) {
     if (wxTheClipboard->Open()) {
         wxTheClipboard->UsePrimarySelection(FALSE);
 void ScintillaWX::CopyToClipboard(const SelectionText& st) {
     if (wxTheClipboard->Open()) {
         wxTheClipboard->UsePrimarySelection(FALSE);
-        wxString text = stc2wx(st.s, st.len);
+        wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len));
         wxTheClipboard->SetData(new wxTextDataObject(text));
         wxTheClipboard->Close();
     }
         wxTheClipboard->SetData(new wxTextDataObject(text));
         wxTheClipboard->Close();
     }
@@ -409,7 +423,7 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
     if (!label[0])
         ((wxMenu*)popup.GetID())->AppendSeparator();
     else
     if (!label[0])
         ((wxMenu*)popup.GetID())->AppendSeparator();
     else
-        ((wxMenu*)popup.GetID())->Append(cmd, stc2wx(label));
+        ((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(stc2wx(label)));
 
     if (!enabled)
         ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
 
     if (!enabled)
         ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
@@ -514,7 +528,7 @@ void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
     delete surfaceWindow;
     if (paintState == paintAbandoned) {
         // Painting area was insufficient to cover new styling or brace highlight positions
     delete surfaceWindow;
     if (paintState == paintAbandoned) {
         // Painting area was insufficient to cover new styling or brace highlight positions
-        FullPaint();
+        FullPaint(dc);
     }
     paintState = notPainting;
 }
     }
     paintState = notPainting;
 }
@@ -606,11 +620,15 @@ void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) {
 }
 
 void ScintillaWX::DoLoseFocus(){
 }
 
 void ScintillaWX::DoLoseFocus(){
+    focusEvent = true;
     SetFocusState(false);
     SetFocusState(false);
+    focusEvent = false;
 }
 
 void ScintillaWX::DoGainFocus(){
 }
 
 void ScintillaWX::DoGainFocus(){
+    focusEvent = true;
     SetFocusState(true);
     SetFocusState(true);
+    focusEvent = false;
 }
 
 void ScintillaWX::DoSysColourChange() {
 }
 
 void ScintillaWX::DoSysColourChange() {
@@ -815,18 +833,18 @@ void ScintillaWX::DoDragLeave() {
 //----------------------------------------------------------------------
 
 // Redraw all of text area. This paint will not be abandoned.
 //----------------------------------------------------------------------
 
 // Redraw all of text area. This paint will not be abandoned.
-void ScintillaWX::FullPaint() {
+void ScintillaWX::FullPaint(wxDC *dc) {
+    wxCHECK_RET(dc != NULL, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
     paintState = painting;
     rcPaint = GetClientRectangle();
     paintingAllText = true;
     paintState = painting;
     rcPaint = GetClientRectangle();
     paintingAllText = true;
-    wxClientDC dc(stc);
     Surface* surfaceWindow = Surface::Allocate();
     Surface* surfaceWindow = Surface::Allocate();
-    surfaceWindow->Init(&dc, wMain.GetID());
+    surfaceWindow->Init(dc, wMain.GetID());
 
 
-    dc.BeginDrawing();
-    ClipChildren(dc, rcPaint);
+    dc->BeginDrawing();
+    ClipChildren(*dc, rcPaint);
     Paint(surfaceWindow, rcPaint);
     Paint(surfaceWindow, rcPaint);
-    dc.EndDrawing();
+    dc->EndDrawing();
 
     delete surfaceWindow;
     paintState = notPainting;
 
     delete surfaceWindow;
     paintState = notPainting;