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