1 ////////////////////////////////////////////////////////////////////////////
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.
11 // Created: 13-Jan-2000
13 // Copyright: (c) 2000 by Total Control Software
14 // Licence: wxWindows license
15 /////////////////////////////////////////////////////////////////////////////
17 #ifndef __ScintillaWX_h__
18 #define __ScintillaWX_h__
21 //----------------------------------------------------------------------
33 #include "Scintilla.h"
34 #include "CharClassify.h"
39 #include "SplitVector.h"
40 #include "Partitioning.h"
41 #include "RunStyles.h"
42 #include "ContractionState.h"
43 #include "CellBuffer.h"
46 #include "Indicator.h"
47 #include "LineMarker.h"
49 #include "ViewStyle.h"
50 #include "AutoComplete.h"
51 #include "Decoration.h"
53 #include "PositionCache.h"
55 #include "ScintillaBase.h"
58 #include "wx/msw/wrapwin.h" // HBITMAP
60 #if wxUSE_DRAG_AND_DROP
64 //----------------------------------------------------------------------
67 class WXDLLIMPEXP_FWD_CORE wxDC
;
68 class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl
; // forward
72 //----------------------------------------------------------------------
75 #if wxUSE_DRAG_AND_DROP
76 class wxSTCDropTarget
: public wxTextDropTarget
{
78 void SetScintilla(ScintillaWX
* swx
) {
82 bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
);
83 wxDragResult
OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
84 wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
92 //----------------------------------------------------------------------
94 class ScintillaWX
: public ScintillaBase
{
97 ScintillaWX(wxStyledTextCtrl
* win
);
100 // base class virtuals
101 virtual void Initialise();
102 virtual void Finalise();
103 virtual void StartDrag();
104 virtual bool SetIdle(bool on
);
105 virtual void SetTicking(bool on
);
106 virtual void SetMouseCapture(bool on
);
107 virtual bool HaveMouseCapture();
108 virtual void ScrollText(int linesToMove
);
109 virtual void SetVerticalScrollPos();
110 virtual void SetHorizontalScrollPos();
111 virtual bool ModifyScrollBars(int nMax
, int nPage
);
113 virtual void Paste();
114 virtual void CopyToClipboard(const SelectionText
&selectedText
);
116 virtual void CreateCallTipWindow(PRectangle rc
);
117 virtual void AddToPopUp(const char *label
, int cmd
= 0, bool enabled
= true);
118 virtual void ClaimSelection();
120 virtual sptr_t
DefWndProc(unsigned int iMessage
,
123 virtual sptr_t
WndProc(unsigned int iMessage
,
127 virtual void NotifyChange();
128 virtual void NotifyParent(SCNotification scn
);
130 virtual void CancelModes();
132 virtual void UpdateSystemCaret();
135 void DoPaint(wxDC
* dc
, wxRect rect
);
136 void DoHScroll(int type
, int pos
);
137 void DoVScroll(int type
, int pos
);
138 void DoSize(int width
, int height
);
141 void DoSysColourChange();
142 void DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
143 void DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
144 void DoLeftButtonMove(Point pt
);
145 void DoMiddleButtonUp(Point pt
);
146 void DoMouseWheel(int rotation
, int delta
, int linesPerAction
, int ctrlDown
, bool isPageScroll
);
147 void DoAddChar(int key
);
148 int DoKeyDown(const wxKeyEvent
& event
, bool* consumed
);
149 void DoTick() { Tick(); }
150 void DoOnIdle(wxIdleEvent
& evt
);
152 #if wxUSE_DRAG_AND_DROP
153 bool DoDropText(long x
, long y
, const wxString
& data
);
154 wxDragResult
DoDragEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
155 wxDragResult
DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
159 void DoCommand(int ID
);
160 void DoContextMenu(Point pt
);
167 bool GetHideSelection() { return hideSelection
; }
168 void DoScrollToLine(int line
);
169 void DoScrollToColumn(int column
);
170 void ClipChildren(wxDC
& dc
, PRectangle rect
);
171 void SetUseAntiAliasing(bool useAA
);
172 bool GetUseAntiAliasing();
177 wxStyledTextCtrl
* stc
;
179 #if wxUSE_DRAG_AND_DROP
180 wxSTCDropTarget
* dropTarget
;
181 wxDragResult dragResult
;
186 // For use in creating a system caret
187 bool HasCaretSizeChanged();
188 bool CreateSystemCaret();
189 bool DestroySystemCaret();
191 HBITMAP sysCaretBitmap
;
196 friend class wxSTCCallTip
;
199 //----------------------------------------------------------------------