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