]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/stc/ScintillaWX.h | |
3 | // Purpose: A wxWidgets 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 licence | |
15 | ///////////////////////////////////////////////////////////////////////////// | |
16 | ||
17 | #ifndef __ScintillaWX_h__ | |
18 | #define __ScintillaWX_h__ | |
19 | #include "wx/defs.h" | |
20 | ||
21 | //---------------------------------------------------------------------- | |
22 | ||
23 | #include <ctype.h> | |
24 | #include <stdlib.h> | |
25 | #include <stdio.h> | |
26 | #include <string.h> | |
27 | #include <vector> | |
28 | #include <map> | |
29 | ||
30 | // These are all Scintilla headers | |
31 | #include "Platform.h" | |
32 | #include "SplitVector.h" | |
33 | #include "Partitioning.h" | |
34 | #include "RunStyles.h" | |
35 | #include "Scintilla.h" | |
36 | #include "ScintillaWidget.h" | |
37 | #ifdef SCI_LEXER | |
38 | #include "SciLexer.h" | |
39 | #include "PropSetSimple.h" | |
40 | #include "ILexer.h" | |
41 | #include "LexerModule.h" | |
42 | #include "LexAccessor.h" | |
43 | #include "Accessor.h" | |
44 | #include "WordList.h" | |
45 | #endif | |
46 | #include "ContractionState.h" | |
47 | #include "SVector.h" | |
48 | #include "CellBuffer.h" | |
49 | #include "CallTip.h" | |
50 | #include "KeyMap.h" | |
51 | #include "Indicator.h" | |
52 | #include "XPM.h" | |
53 | #include "LineMarker.h" | |
54 | #include "Style.h" | |
55 | #include "AutoComplete.h" | |
56 | #include "ViewStyle.h" | |
57 | #include "CharClassify.h" | |
58 | #include "Decoration.h" | |
59 | #include "Document.h" | |
60 | #include "Selection.h" | |
61 | #include "PositionCache.h" | |
62 | #include "Editor.h" | |
63 | #include "PropSetSimple.h" | |
64 | #include "ScintillaBase.h" | |
65 | ||
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 | ||
73 | //---------------------------------------------------------------------- | |
74 | ||
75 | ||
76 | class WXDLLIMPEXP_FWD_CORE wxDC; | |
77 | class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward | |
78 | class ScintillaWX; | |
79 | ||
80 | ||
81 | //---------------------------------------------------------------------- | |
82 | // Helper classes | |
83 | ||
84 | #if wxUSE_DRAG_AND_DROP | |
85 | class wxSTCDropTarget : public wxTextDropTarget { | |
86 | public: | |
87 | void SetScintilla(ScintillaWX* swx) { | |
88 | m_swx = swx; | |
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: | |
97 | ScintillaWX* m_swx; | |
98 | }; | |
99 | #endif | |
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(); | |
113 | virtual bool SetIdle(bool on); | |
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(); | |
123 | virtual void CopyToClipboard(const SelectionText &selectedText); | |
124 | ||
125 | virtual void CreateCallTipWindow(PRectangle rc); | |
126 | virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); | |
127 | virtual void ClaimSelection(); | |
128 | ||
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); | |
135 | ||
136 | virtual void NotifyChange(); | |
137 | virtual void NotifyParent(SCNotification scn); | |
138 | ||
139 | virtual void CancelModes(); | |
140 | ||
141 | virtual void UpdateSystemCaret(); | |
142 | ||
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(); | |
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); | |
155 | void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll); | |
156 | void DoAddChar(int key); | |
157 | int DoKeyDown(const wxKeyEvent& event, bool* consumed); | |
158 | void DoTick() { Tick(); } | |
159 | void DoOnIdle(wxIdleEvent& evt); | |
160 | ||
161 | #if wxUSE_DRAG_AND_DROP | |
162 | bool DoDropText(long x, long y, const wxString& data); | |
163 | wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); | |
164 | wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
165 | void DoDragLeave(); | |
166 | #endif | |
167 | ||
168 | void DoCommand(int ID); | |
169 | void DoContextMenu(Point pt); | |
170 | void DoOnListBox(); | |
171 | ||
172 | ||
173 | // helpers | |
174 | void FullPaint(); | |
175 | void FullPaintDC(wxDC* dc); | |
176 | bool CanPaste(); | |
177 | bool GetHideSelection() { return hideSelection; } | |
178 | void DoScrollToLine(int line); | |
179 | void DoScrollToColumn(int column); | |
180 | void ClipChildren(wxDC& dc, PRectangle rect); | |
181 | void SetUseAntiAliasing(bool useAA); | |
182 | bool GetUseAntiAliasing(); | |
183 | ||
184 | private: | |
185 | bool capturedMouse; | |
186 | bool focusEvent; | |
187 | wxStyledTextCtrl* stc; | |
188 | ||
189 | #if wxUSE_DRAG_AND_DROP | |
190 | wxSTCDropTarget* dropTarget; | |
191 | wxDragResult dragResult; | |
192 | #endif | |
193 | ||
194 | int wheelRotation; | |
195 | ||
196 | // For use in creating a system caret | |
197 | bool HasCaretSizeChanged(); | |
198 | bool CreateSystemCaret(); | |
199 | bool DestroySystemCaret(); | |
200 | #ifdef __WXMSW__ | |
201 | HBITMAP sysCaretBitmap; | |
202 | int sysCaretWidth; | |
203 | int sysCaretHeight; | |
204 | #endif | |
205 | ||
206 | friend class wxSTCCallTip; | |
207 | }; | |
208 | ||
209 | //---------------------------------------------------------------------- | |
210 | #endif |