]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Editor.h
Added some WXDLLEXPORTs
[wxWidgets.git] / src / stc / scintilla / src / Editor.h
1 // Scintilla source code edit control
2 // Editor.h - defines the main editor class
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
5
6 #ifndef EDITOR_H
7 #define EDITOR_H
8
9 class Caret {
10 public:
11 bool active;
12 bool on;
13 int period;
14
15 Caret();
16 };
17
18 class Timer {
19
20 public:
21 bool ticking;
22 int ticksToWait;
23 enum {tickSize = 100};
24 int tickerID;
25
26 Timer();
27 };
28
29 class LineLayout {
30 public:
31 // Drawing is only performed for maxLineLength characters on each line.
32 enum {maxLineLength = 4000};
33 int numCharsInLine;
34 int xHighlightGuide;
35 bool highlightColumn;
36 int selStart;
37 int selEnd;
38 int edgeColumn;
39 char chars[maxLineLength+1];
40 char styles[maxLineLength+1];
41 char indicators[maxLineLength+1];
42 int positions[maxLineLength+1];
43 };
44
45 class Editor : public DocWatcher {
46 // Private so Editor objects can not be copied
47 Editor(const Editor &) : DocWatcher() {}
48 Editor &operator=(const Editor &) { return *this; }
49 protected: // ScintillaBase subclass needs access to much of Editor
50
51 // On GTK+, Scintilla is a container widget holding two scroll bars and a drawing area
52 // whereas on Windows there is just one window with both scroll bars turned on.
53 // Therefore, on GTK+ the following are separate windows but only one window on Windows.
54 Window wMain; // The Scintilla parent window
55 Window wDraw; // The text drawing area
56
57 // Style resources may be expensive to allocate so are cached between uses.
58 // When a style attribute is changed, this cache is flushed.
59 bool stylesValid;
60 ViewStyle vs;
61 Palette palette;
62 int printMagnification;
63 int printColourMode;
64
65 bool hideSelection;
66 bool inOverstrike;
67
68 // In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
69 // the screen. This avoids flashing but is about 30% slower.
70 bool bufferedDraw;
71
72 int xOffset; // Horizontal scrolled amount in pixels
73 int xCaretMargin; // Ensure this many pixels visible on both sides of caret
74 bool horizontalScrollBarVisible;
75
76 Surface pixmapLine;
77 Surface pixmapSelMargin;
78 Surface pixmapSelPattern;
79 Surface pixmapIndentGuide;
80 Surface pixmapIndentGuideHighlight;
81 // Intellimouse support - currently only implemented for Windows
82 unsigned int ucWheelScrollLines;
83 int cWheelDelta; //wheel delta from roll
84
85 KeyMap kmap;
86
87 Caret caret;
88 Timer timer;
89
90 Point lastClick;
91 unsigned int lastClickTime;
92 enum { selChar, selWord, selLine } selectionType;
93 Point ptMouseLast;
94 bool firstExpose;
95 bool inDragDrop;
96 bool dropWentOutside;
97 int posDrag;
98 int posDrop;
99 int lastXChosen;
100 int lineAnchor;
101 int originalAnchorPos;
102 int currentPos;
103 int anchor;
104 int topLine;
105 int posTopLine;
106
107 bool needUpdateUI;
108 Position braces[2];
109 int bracesMatchStyle;
110 int highlightGuideColumn;
111
112 int theEdge;
113
114 enum { notPainting, painting, paintAbandoned } paintState;
115 PRectangle rcPaint;
116 bool paintingAllText;
117
118 int modEventMask;
119
120 char *dragChars;
121 int lenDrag;
122 bool dragIsRectangle;
123 enum { selStream, selRectangle, selRectangleFixed } selType;
124 int xStartSelect;
125 int xEndSelect;
126 bool primarySelection;
127
128 int caretPolicy;
129 int caretSlop;
130
131 int searchAnchor;
132
133 int displayPopupMenu;
134
135 #ifdef MACRO_SUPPORT
136 int recordingMacro;
137 #endif
138
139 int foldFlags;
140 ContractionState cs;
141
142 Document *pdoc;
143
144 Editor();
145 virtual ~Editor();
146 virtual void Initialise() = 0;
147 virtual void Finalise();
148
149 void InvalidateStyleData();
150 void InvalidateStyleRedraw();
151 virtual void RefreshColourPalette(Palette &pal, bool want);
152 void RefreshStyleData();
153 void DropGraphics();
154
155 PRectangle GetClientRectangle();
156 PRectangle GetTextRectangle();
157
158 int LinesOnScreen();
159 int LinesToScroll();
160 int MaxScrollPos();
161 Point LocationFromPosition(unsigned int pos);
162 int XFromPosition(unsigned int pos);
163 int PositionFromLocation(Point pt);
164 int PositionFromLineX(int line, int x);
165 int LineFromLocation(Point pt);
166 void SetTopLine(int topLineNew);
167
168 void RedrawRect(PRectangle rc);
169 void Redraw();
170 void RedrawSelMargin();
171 PRectangle RectangleFromRange(int start, int end);
172 void InvalidateRange(int start, int end);
173
174 int CurrentPosition();
175 bool SelectionEmpty();
176 int SelectionStart(int line=-1);
177 int SelectionEnd(int line=-1);
178 void SetSelection(int currentPos_, int anchor_);
179 void SetSelection(int currentPos_);
180 void SetEmptySelection(int currentPos_);
181 int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
182 int MovePositionTo(int newPos, bool extend = false);
183 int MovePositionSoVisible(int pos, int moveDir);
184 void SetLastXChosen();
185
186 void ScrollTo(int line);
187 virtual void ScrollText(int linesToMove);
188 void HorizontalScrollTo(int xPos);
189 void MoveCaretInsideView();
190 void EnsureCaretVisible(bool useMargin=true);
191 void ShowCaretAtCurrentPosition();
192 void DropCaret();
193 void InvalidateCaret();
194
195 void PaintSelMargin(Surface *surface, PRectangle &rc);
196 void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
197 void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
198 PRectangle rcLine, LineLayout &ll);
199 void Paint(Surface *surfaceWindow, PRectangle rcArea);
200 long FormatRange(bool draw, RangeToFormat *pfr);
201
202 virtual void SetVerticalScrollPos() = 0;
203 virtual void SetHorizontalScrollPos() = 0;
204 virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
205 virtual void ReconfigureScrollBars();
206 void SetScrollBarsTo(PRectangle rsClient);
207 void SetScrollBars();
208
209 void AddChar(char ch);
210 virtual void AddCharUTF(char *s, unsigned int len);
211 void ClearSelection();
212 void ClearAll();
213 void ClearDocumentStyle();
214 void Cut();
215 void PasteRectangular(int pos, const char *ptr, int len);
216 virtual void Copy() = 0;
217 virtual void Paste() = 0;
218 void Clear();
219 void SelectAll();
220 void Undo();
221 void Redo();
222 void DelChar();
223 void DelCharBack();
224 virtual void ClaimSelection() = 0;
225
226 virtual void NotifyChange() = 0;
227 virtual void NotifyFocus(bool focus);
228 virtual void NotifyParent(SCNotification scn) = 0;
229 virtual void NotifyStyleToNeeded(int endStyleNeeded);
230 void NotifyChar(char ch);
231 void NotifyMove(int position);
232 void NotifySavePoint(bool isSavePoint);
233 void NotifyModifyAttempt();
234 virtual void NotifyDoubleClick(Point pt, bool shift);
235 void NotifyUpdateUI();
236 bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
237 void NotifyNeedShown(int pos, int len);
238
239 void NotifyModifyAttempt(Document *document, void *userData);
240 void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
241 void NotifyModified(Document *document, DocModification mh, void *userData);
242 void NotifyDeleted(Document *document, void *userData);
243 void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
244
245
246 #ifdef MACRO_SUPPORT
247 void NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam);
248 #endif
249
250 void PageMove(int direction, bool extend=false);
251 void ChangeCaseOfSelection(bool makeUpperCase);
252 void LineTranspose();
253 virtual void CancelModes();
254 virtual int KeyCommand(unsigned int iMessage);
255 virtual int KeyDefault(int /* key */, int /*modifiers*/);
256 int KeyDown(int key, bool shift, bool ctrl, bool alt);
257
258 int GetWhitespaceVisible();
259 void SetWhitespaceVisible(int view);
260
261 void Indent(bool forwards);
262
263 long FindText(unsigned int iMessage, unsigned long wParam, long lParam);
264 void SearchAnchor();
265 long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
266 void GoToLine(int lineNo);
267
268 char *CopyRange(int start, int end);
269 int SelectionRangeLength();
270 char *CopySelectionRange();
271 void CopySelectionIntoDrag();
272 void SetDragPosition(int newPos);
273 virtual void StartDrag();
274 void DropAt(int position, const char *value, bool moving, bool rectangular);
275 // PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
276 // Before means either before any line of selection or before selection on its line, with a similar meaning to after
277 int PositionInSelection(int pos);
278 bool PointInSelection(Point pt);
279 bool PointInSelMargin(Point pt);
280 virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
281 void ButtonMove(Point pt);
282 void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
283
284 void Tick();
285 virtual void SetTicking(bool on) = 0;
286 virtual void SetMouseCapture(bool on) = 0;
287 virtual bool HaveMouseCapture() = 0;
288
289 void CheckForChangeOutsidePaint(Range r);
290 int BraceMatch(int position, int maxReStyle);
291 void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
292
293 void SetDocPointer(Document *document);
294
295 void Expand(int &line, bool doExpand);
296 void ToggleContraction(int line);
297 void EnsureLineVisible(int line);
298
299 virtual long DefWndProc(unsigned int iMessage, unsigned long wParam, long lParam) = 0;
300
301 public:
302 // Public so scintilla_send_message can use it
303 virtual long WndProc(unsigned int iMessage, unsigned long wParam, long lParam);
304 // Public so scintilla_set_id can use it
305 int ctrlID;
306 };
307
308 #endif