////////////////////////////////////////////////////////////////////////////
-// 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"
void OnPaint(wxPaintEvent& WXUNUSED(evt))
{
wxAutoBufferedPaintDC dc(this);
- Surface* surfaceWindow = Surface::Allocate();
+ Surface* surfaceWindow = Surface::Allocate(0);
surfaceWindow->Init(&dc, m_ct->wDraw.GetID());
m_ct->PaintCT(surfaceWindow);
surfaceWindow->Release();
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
evt.SetEventObject(stc);
evt.SetDragText(dragText);
- evt.SetDragAllowMove(wxDrag_DefaultMove);
+ evt.SetDragFlags(wxDrag_DefaultMove);
evt.SetPosition(wxMin(stc->GetSelectionStart(),
stc->GetSelectionEnd()));
stc->GetEventHandler()->ProcessEvent(evt);
dragText = evt.GetDragText();
- if (dragText.length()) {
+ if ( !dragText.empty() ) {
wxDropSource source(stc);
wxTextDataObject data(dragText);
wxDragResult result;
source.SetData(data);
dropWentOutside = true;
inDragDrop = ddDragging;
- result = source.DoDragDrop(evt.GetDragAllowMove());
+ result = source.DoDragDrop(evt.GetDragFlags());
if (result == wxDragMove && dropWentOutside)
ClearSelection();
inDragDrop = ddNone;
void ScintillaWX::ScrollText(int linesToMove) {
int dy = vs.lineHeight * (linesToMove);
stc->ScrollWindow(0, dy);
- stc->Update();
}
void ScintillaWX::SetVerticalScrollPos() {
sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
+#if 0 // TODO: check this
+
case SCI_CALLTIPSHOW: {
// NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
// because of the little tweak that needs done below for wxGTK.
ct.wCallTip.Show();
break;
}
+#endif
#ifdef SCI_LEXER
case SCI_LOADLEXERLIBRARY:
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();
+ // highlight positions. So trigger a new paint event that will
+ // repaint the whole window.
+ stc->Refresh(false);
+
+#if defined(__WXOSX__)
+ // On Mac we also need to finish the current paint to make sure that
+ // everything is on the screen that needs to be there between now and
+ // when the next paint event arrives.
+ FullPaintDC(dc);
+#endif
}
paintState = notPainting;
}
+// Force the whole window to be repainted
+void ScintillaWX::FullPaint() {
+ stc->Refresh(false);
+ stc->Update();
+}
+
+
+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();
int lines;
if (ctrlDown) { // Zoom the fonts if Ctrl key down
- if (rotation < 0) {
+ if (rotation > 0) {
KeyCommand(SCI_ZOOMIN);
}
else {
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();
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__
#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);
}