]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/ScintillaWX.h
More AutoComplete crash fixes
[wxWidgets.git] / contrib / src / stc / ScintillaWX.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: ScintillaWX.h
3 // Purpose: A wxWindows implementation of Scintilla. A class derived
4 // from ScintillaBase that uses the "wx platform" defined in
5 // PlatWX.cpp. This class is one end of a bridge between
6 // the wx world and the Scintilla world. It needs a peer
7 // object of type wxStyledTextCtrl to function.
8 //
9 // Author: Robin Dunn
10 //
11 // Created: 13-Jan-2000
12 // RCS-ID: $Id$
13 // Copyright: (c) 2000 by Total Control Software
14 // Licence: wxWindows license
15 /////////////////////////////////////////////////////////////////////////////
16
17 #ifndef __ScintillaWX_h__
18 #define __ScintillaWX_h__
19
20 //----------------------------------------------------------------------
21
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26
27 #include "Platform.h"
28
29 #include "Scintilla.h"
30 #include "XPM.h"
31 #ifdef SCI_LEXER
32 #include "SciLexer.h"
33 #include "PropSet.h"
34 #include "Accessor.h"
35 #include "KeyWords.h"
36 #endif
37 #include "ContractionState.h"
38 #include "SVector.h"
39 #include "CellBuffer.h"
40 #include "CallTip.h"
41 #include "KeyMap.h"
42 #include "Indicator.h"
43 #include "LineMarker.h"
44 #include "Style.h"
45 #include "ViewStyle.h"
46 #include "AutoComplete.h"
47 #include "Document.h"
48 #include "Editor.h"
49 #include "ScintillaBase.h"
50
51 #include <wx/wx.h>
52 #include <wx/dataobj.h>
53 #include <wx/clipbrd.h>
54 #include <wx/dnd.h>
55
56 //----------------------------------------------------------------------
57
58 #ifdef WXMAKINGDLL_STC
59 #define WXDLLIMPEXP_STC WXEXPORT
60 #elif defined(WXUSINGDLL)
61 #define WXDLLIMPEXP_STC WXIMPORT
62 #else // not making nor using DLL
63 #define WXDLLIMPEXP_STC
64 #endif
65
66 class WXDLLIMPEXP_STC wxStyledTextCtrl; // forward
67 class ScintillaWX;
68
69
70 //----------------------------------------------------------------------
71 // Helper classes
72
73 #if wxUSE_DRAG_AND_DROP
74 class wxSTCDropTarget : public wxTextDropTarget {
75 public:
76 void SetScintilla(ScintillaWX* swx) {
77 this->swx = swx;
78 }
79
80 bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
81 wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
82 wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
83 void OnLeave();
84
85 private:
86 ScintillaWX* swx;
87 };
88 #endif
89
90 //----------------------------------------------------------------------
91
92 class ScintillaWX : public ScintillaBase {
93 public:
94
95 ScintillaWX(wxStyledTextCtrl* win);
96 ~ScintillaWX();
97
98 // base class virtuals
99 virtual void Initialise();
100 virtual void Finalise();
101 virtual void StartDrag();
102 virtual void SetTicking(bool on);
103 virtual void SetMouseCapture(bool on);
104 virtual bool HaveMouseCapture();
105 virtual void ScrollText(int linesToMove);
106 virtual void SetVerticalScrollPos();
107 virtual void SetHorizontalScrollPos();
108 virtual bool ModifyScrollBars(int nMax, int nPage);
109 virtual void Copy();
110 virtual void Paste();
111 virtual void CopyToClipboard(const SelectionText &selectedText);
112
113 virtual void CreateCallTipWindow(PRectangle rc);
114 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
115 virtual void ClaimSelection();
116
117 virtual long DefWndProc(unsigned int iMessage,
118 unsigned long wParam,
119 long lParam);
120 virtual long WndProc(unsigned int iMessage,
121 unsigned long wParam,
122 long lParam);
123
124 virtual void NotifyChange();
125 virtual void NotifyParent(SCNotification scn);
126
127 virtual void CancelModes();
128
129 // Event delegates
130 void DoPaint(wxDC* dc, wxRect rect);
131 void DoHScroll(int type, int pos);
132 void DoVScroll(int type, int pos);
133 void DoSize(int width, int height);
134 void DoLoseFocus();
135 void DoGainFocus();
136 void DoSysColourChange();
137 void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
138 void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
139 void DoLeftButtonMove(Point pt);
140 void DoMiddleButtonUp(Point pt);
141 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
142 void DoAddChar(int key);
143 int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed);
144 void DoTick() { Tick(); }
145
146 #if wxUSE_DRAG_AND_DROP
147 bool DoDropText(long x, long y, const wxString& data);
148 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
149 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
150 void DoDragLeave();
151 #endif
152
153 void DoCommand(int ID);
154 void DoContextMenu(Point pt);
155 void DoOnListBox();
156
157
158 // helpers
159 void FullPaint();
160 bool CanPaste();
161 bool GetHideSelection() { return hideSelection; }
162 void DoScrollToLine(int line);
163 void DoScrollToColumn(int column);
164 void ClipChildren(wxDC& dc, PRectangle rect);
165
166 private:
167 bool capturedMouse;
168 bool focusEvent;
169 wxStyledTextCtrl* stc;
170
171 #if wxUSE_DRAG_AND_DROP
172 wxSTCDropTarget* dropTarget;
173 wxDragResult dragResult;
174 #endif
175 int wheelRotation;
176
177
178 friend class wxSTCCallTip;
179 };
180
181 //----------------------------------------------------------------------
182 #endif