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