]>
Commit | Line | Data |
---|---|---|
9ce192d4 | 1 | //////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/stc/ScintillaWX.h |
be5a51fb | 3 | // Purpose: A wxWidgets implementation of Scintilla. A class derived |
9ce192d4 RD |
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 | |
526954c5 | 14 | // Licence: wxWindows licence |
9ce192d4 RD |
15 | ///////////////////////////////////////////////////////////////////////////// |
16 | ||
17 | #ifndef __ScintillaWX_h__ | |
18 | #define __ScintillaWX_h__ | |
c079af66 | 19 | #include "wx/defs.h" |
9ce192d4 RD |
20 | |
21 | //---------------------------------------------------------------------- | |
22 | ||
1a2fb4cd RD |
23 | #include <ctype.h> |
24 | #include <stdlib.h> | |
25 | #include <stdio.h> | |
26 | #include <string.h> | |
9b01abb8 RD |
27 | #include <vector> |
28 | #include <map> | |
1a2fb4cd | 29 | |
9b01abb8 | 30 | // These are all Scintilla headers |
9ce192d4 | 31 | #include "Platform.h" |
9e96e16f RD |
32 | #include "SplitVector.h" |
33 | #include "Partitioning.h" | |
34 | #include "RunStyles.h" | |
9ce192d4 | 35 | #include "Scintilla.h" |
9e96e16f | 36 | #include "ScintillaWidget.h" |
9ce192d4 RD |
37 | #ifdef SCI_LEXER |
38 | #include "SciLexer.h" | |
9b01abb8 RD |
39 | #include "PropSetSimple.h" |
40 | #include "ILexer.h" | |
41 | #include "LexerModule.h" | |
42 | #include "LexAccessor.h" | |
9e96e16f | 43 | #include "Accessor.h" |
9b01abb8 | 44 | #include "WordList.h" |
9ce192d4 RD |
45 | #endif |
46 | #include "ContractionState.h" | |
9e96e16f | 47 | #include "SVector.h" |
9ce192d4 RD |
48 | #include "CellBuffer.h" |
49 | #include "CallTip.h" | |
50 | #include "KeyMap.h" | |
51 | #include "Indicator.h" | |
9e96e16f | 52 | #include "XPM.h" |
9ce192d4 RD |
53 | #include "LineMarker.h" |
54 | #include "Style.h" | |
9ce192d4 | 55 | #include "AutoComplete.h" |
9e96e16f RD |
56 | #include "ViewStyle.h" |
57 | #include "CharClassify.h" | |
7e0c58e9 | 58 | #include "Decoration.h" |
9ce192d4 | 59 | #include "Document.h" |
9e96e16f | 60 | #include "Selection.h" |
7e0c58e9 | 61 | #include "PositionCache.h" |
9ce192d4 | 62 | #include "Editor.h" |
9e96e16f | 63 | #include "PropSetSimple.h" |
9ce192d4 RD |
64 | #include "ScintillaBase.h" |
65 | ||
633566f6 RD |
66 | #ifdef __WXMSW__ |
67 | #include "wx/msw/wrapwin.h" // HBITMAP | |
68 | #endif | |
69 | #if wxUSE_DRAG_AND_DROP | |
70 | #include "wx/timer.h" | |
71 | #endif | |
72 | ||
9ce192d4 RD |
73 | //---------------------------------------------------------------------- |
74 | ||
ba8a4f66 | 75 | |
b5dbe15d VS |
76 | class WXDLLIMPEXP_FWD_CORE wxDC; |
77 | class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward | |
9ce192d4 RD |
78 | class ScintillaWX; |
79 | ||
80 | ||
81 | //---------------------------------------------------------------------- | |
82 | // Helper classes | |
83 | ||
1bc32508 | 84 | #if wxUSE_DRAG_AND_DROP |
9ce192d4 RD |
85 | class wxSTCDropTarget : public wxTextDropTarget { |
86 | public: | |
87 | void SetScintilla(ScintillaWX* swx) { | |
291b0f5b | 88 | m_swx = swx; |
9ce192d4 RD |
89 | } |
90 | ||
91 | bool OnDropText(wxCoord x, wxCoord y, const wxString& data); | |
92 | wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
93 | wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
94 | void OnLeave(); | |
95 | ||
96 | private: | |
291b0f5b | 97 | ScintillaWX* m_swx; |
9ce192d4 | 98 | }; |
1bc32508 | 99 | #endif |
9ce192d4 RD |
100 | |
101 | //---------------------------------------------------------------------- | |
102 | ||
103 | class ScintillaWX : public ScintillaBase { | |
104 | public: | |
105 | ||
106 | ScintillaWX(wxStyledTextCtrl* win); | |
107 | ~ScintillaWX(); | |
108 | ||
109 | // base class virtuals | |
110 | virtual void Initialise(); | |
111 | virtual void Finalise(); | |
112 | virtual void StartDrag(); | |
8e54aaed | 113 | virtual bool SetIdle(bool on); |
9ce192d4 RD |
114 | virtual void SetTicking(bool on); |
115 | virtual void SetMouseCapture(bool on); | |
116 | virtual bool HaveMouseCapture(); | |
117 | virtual void ScrollText(int linesToMove); | |
118 | virtual void SetVerticalScrollPos(); | |
119 | virtual void SetHorizontalScrollPos(); | |
120 | virtual bool ModifyScrollBars(int nMax, int nPage); | |
121 | virtual void Copy(); | |
122 | virtual void Paste(); | |
e14d10b0 RD |
123 | virtual void CopyToClipboard(const SelectionText &selectedText); |
124 | ||
9ce192d4 RD |
125 | virtual void CreateCallTipWindow(PRectangle rc); |
126 | virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); | |
127 | virtual void ClaimSelection(); | |
128 | ||
80dc1dd3 VZ |
129 | virtual sptr_t DefWndProc(unsigned int iMessage, |
130 | uptr_t wParam, | |
131 | sptr_t lParam); | |
132 | virtual sptr_t WndProc(unsigned int iMessage, | |
133 | uptr_t wParam, | |
134 | sptr_t lParam); | |
9ce192d4 RD |
135 | |
136 | virtual void NotifyChange(); | |
137 | virtual void NotifyParent(SCNotification scn); | |
138 | ||
b0d0494f | 139 | virtual void CancelModes(); |
9ce192d4 | 140 | |
d429e187 RD |
141 | virtual void UpdateSystemCaret(); |
142 | ||
9ce192d4 RD |
143 | // Event delegates |
144 | void DoPaint(wxDC* dc, wxRect rect); | |
145 | void DoHScroll(int type, int pos); | |
146 | void DoVScroll(int type, int pos); | |
147 | void DoSize(int width, int height); | |
148 | void DoLoseFocus(); | |
149 | void DoGainFocus(); | |
150 | void DoSysColourChange(); | |
2b5f62a0 VZ |
151 | void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); |
152 | void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl); | |
153 | void DoLeftButtonMove(Point pt); | |
154 | void DoMiddleButtonUp(Point pt); | |
1d84348c VZ |
155 | void DoMouseWheel(wxMouseWheelAxis axis, int rotation, int delta, |
156 | int linesPerAction, int columnsPerAction, | |
157 | bool ctrlDown, bool isPageScroll); | |
10ef30eb | 158 | void DoAddChar(int key); |
5fd656d5 | 159 | int DoKeyDown(const wxKeyEvent& event, bool* consumed); |
9ce192d4 | 160 | void DoTick() { Tick(); } |
8e54aaed | 161 | void DoOnIdle(wxIdleEvent& evt); |
7e126a07 | 162 | |
1bc32508 | 163 | #if wxUSE_DRAG_AND_DROP |
9ce192d4 RD |
164 | bool DoDropText(long x, long y, const wxString& data); |
165 | wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); | |
166 | wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
167 | void DoDragLeave(); | |
1bc32508 | 168 | #endif |
9ce192d4 RD |
169 | |
170 | void DoCommand(int ID); | |
171 | void DoContextMenu(Point pt); | |
f6bcfd97 | 172 | void DoOnListBox(); |
9ce192d4 RD |
173 | |
174 | ||
175 | // helpers | |
ab0f5fa6 | 176 | void FullPaint(); |
c3e0999b | 177 | void FullPaintDC(wxDC* dc); |
9ce192d4 RD |
178 | bool CanPaste(); |
179 | bool GetHideSelection() { return hideSelection; } | |
180 | void DoScrollToLine(int line); | |
181 | void DoScrollToColumn(int column); | |
9e730a78 | 182 | void ClipChildren(wxDC& dc, PRectangle rect); |
d1558f3d RD |
183 | void SetUseAntiAliasing(bool useAA); |
184 | bool GetUseAntiAliasing(); | |
9ce192d4 RD |
185 | |
186 | private: | |
9e730a78 | 187 | bool capturedMouse; |
b0d0494f | 188 | bool focusEvent; |
9ce192d4 RD |
189 | wxStyledTextCtrl* stc; |
190 | ||
1bc32508 | 191 | #if wxUSE_DRAG_AND_DROP |
9eb662e9 | 192 | wxSTCDropTarget* dropTarget; |
9ce192d4 | 193 | wxDragResult dragResult; |
1bc32508 | 194 | #endif |
466c166f | 195 | |
1d84348c VZ |
196 | int wheelVRotation; |
197 | int wheelHRotation; | |
9e730a78 | 198 | |
d429e187 RD |
199 | // For use in creating a system caret |
200 | bool HasCaretSizeChanged(); | |
201 | bool CreateSystemCaret(); | |
202 | bool DestroySystemCaret(); | |
203 | #ifdef __WXMSW__ | |
204 | HBITMAP sysCaretBitmap; | |
205 | int sysCaretWidth; | |
206 | int sysCaretHeight; | |
207 | #endif | |
466c166f | 208 | |
9e730a78 | 209 | friend class wxSTCCallTip; |
9ce192d4 RD |
210 | }; |
211 | ||
212 | //---------------------------------------------------------------------- | |
213 | #endif |