]>
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); | |
9b9337da | 155 | void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll); |
10ef30eb | 156 | void DoAddChar(int key); |
5fd656d5 | 157 | int DoKeyDown(const wxKeyEvent& event, bool* consumed); |
9ce192d4 | 158 | void DoTick() { Tick(); } |
8e54aaed | 159 | void DoOnIdle(wxIdleEvent& evt); |
7e126a07 | 160 | |
1bc32508 | 161 | #if wxUSE_DRAG_AND_DROP |
9ce192d4 RD |
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(); | |
1bc32508 | 166 | #endif |
9ce192d4 RD |
167 | |
168 | void DoCommand(int ID); | |
169 | void DoContextMenu(Point pt); | |
f6bcfd97 | 170 | void DoOnListBox(); |
9ce192d4 RD |
171 | |
172 | ||
173 | // helpers | |
ab0f5fa6 | 174 | void FullPaint(); |
c3e0999b | 175 | void FullPaintDC(wxDC* dc); |
9ce192d4 RD |
176 | bool CanPaste(); |
177 | bool GetHideSelection() { return hideSelection; } | |
178 | void DoScrollToLine(int line); | |
179 | void DoScrollToColumn(int column); | |
9e730a78 | 180 | void ClipChildren(wxDC& dc, PRectangle rect); |
d1558f3d RD |
181 | void SetUseAntiAliasing(bool useAA); |
182 | bool GetUseAntiAliasing(); | |
9ce192d4 RD |
183 | |
184 | private: | |
9e730a78 | 185 | bool capturedMouse; |
b0d0494f | 186 | bool focusEvent; |
9ce192d4 RD |
187 | wxStyledTextCtrl* stc; |
188 | ||
1bc32508 | 189 | #if wxUSE_DRAG_AND_DROP |
9eb662e9 | 190 | wxSTCDropTarget* dropTarget; |
9ce192d4 | 191 | wxDragResult dragResult; |
1bc32508 | 192 | #endif |
466c166f | 193 | |
37d62433 | 194 | int wheelRotation; |
9e730a78 | 195 | |
d429e187 RD |
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 | |
466c166f | 205 | |
9e730a78 | 206 | friend class wxSTCCallTip; |
9ce192d4 RD |
207 | }; |
208 | ||
209 | //---------------------------------------------------------------------- | |
210 | #endif |