]> git.saurik.com Git - wxWidgets.git/blob - src/stc/ScintillaWX.h
use existing helper to remove inconvenient additional reference added by gtk_tree_mod...
[wxWidgets.git] / src / stc / ScintillaWX.h
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(wxMouseWheelAxis axis, int rotation, int delta,
156 int linesPerAction, int columnsPerAction,
157 bool ctrlDown, bool isPageScroll);
158 void DoAddChar(int key);
159 int DoKeyDown(const wxKeyEvent& event, bool* consumed);
160 void DoTick() { Tick(); }
161 void DoOnIdle(wxIdleEvent& evt);
162
163 #if wxUSE_DRAG_AND_DROP
164 bool DoDropText(long x, long y, const wxString& data);
165 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
166 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
167 void DoDragLeave();
168 #endif
169
170 void DoCommand(int ID);
171 void DoContextMenu(Point pt);
172 void DoOnListBox();
173
174
175 // helpers
176 void FullPaint();
177 void FullPaintDC(wxDC* dc);
178 bool CanPaste();
179 bool GetHideSelection() { return hideSelection; }
180 void DoScrollToLine(int line);
181 void DoScrollToColumn(int column);
182 void ClipChildren(wxDC& dc, PRectangle rect);
183 void SetUseAntiAliasing(bool useAA);
184 bool GetUseAntiAliasing();
185
186 private:
187 bool capturedMouse;
188 bool focusEvent;
189 wxStyledTextCtrl* stc;
190
191 #if wxUSE_DRAG_AND_DROP
192 wxSTCDropTarget* dropTarget;
193 wxDragResult dragResult;
194 #endif
195
196 int wheelVRotation;
197 int wheelHRotation;
198
199 // For use in creating a system caret
200 bool HasCaretSizeChanged();
201 bool CreateSystemCaret();
202 bool DestroySystemCaret();
203 #ifdef __WXMSW__
204 HBITMAP sysCaretBitmap;
205 int sysCaretWidth;
206 int sysCaretHeight;
207 #endif
208
209 friend class wxSTCCallTip;
210 };
211
212 //----------------------------------------------------------------------
213 #endif