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__
20 //----------------------------------------------------------------------
29 #include "Scintilla.h"
30 #include "CharClassify.h"
38 #include "ContractionState.h"
40 #include "CellBuffer.h"
43 #include "Indicator.h"
44 #include "LineMarker.h"
46 #include "ViewStyle.h"
47 #include "AutoComplete.h"
50 #include "ScintillaBase.h"
53 #include "wx/msw/wrapwin.h" // HBITMAP
55 #if wxUSE_DRAG_AND_DROP
59 //----------------------------------------------------------------------
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
69 class WXDLLIMPEXP_CORE wxDC
;
70 class WXDLLIMPEXP_STC wxStyledTextCtrl
; // forward
74 //----------------------------------------------------------------------
77 #if wxUSE_DRAG_AND_DROP
78 class wxSTCDropTarget
: public wxTextDropTarget
{
80 void SetScintilla(ScintillaWX
* swx
) {
84 bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
);
85 wxDragResult
OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
86 wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
94 //----------------------------------------------------------------------
96 class ScintillaWX
: public ScintillaBase
{
99 ScintillaWX(wxStyledTextCtrl
* win
);
102 // base class virtuals
103 virtual void Initialise();
104 virtual void Finalise();
105 virtual void StartDrag();
106 virtual bool SetIdle(bool on
);
107 virtual void SetTicking(bool on
);
108 virtual void SetMouseCapture(bool on
);
109 virtual bool HaveMouseCapture();
110 virtual void ScrollText(int linesToMove
);
111 virtual void SetVerticalScrollPos();
112 virtual void SetHorizontalScrollPos();
113 virtual bool ModifyScrollBars(int nMax
, int nPage
);
115 virtual void Paste();
116 virtual void CopyToClipboard(const SelectionText
&selectedText
);
118 virtual void CreateCallTipWindow(PRectangle rc
);
119 virtual void AddToPopUp(const char *label
, int cmd
= 0, bool enabled
= true);
120 virtual void ClaimSelection();
122 virtual sptr_t
DefWndProc(unsigned int iMessage
,
125 virtual sptr_t
WndProc(unsigned int iMessage
,
129 virtual void NotifyChange();
130 virtual void NotifyParent(SCNotification scn
);
132 virtual void CancelModes();
134 virtual void UpdateSystemCaret();
137 void DoPaint(wxDC
* dc
, wxRect rect
);
138 void DoHScroll(int type
, int pos
);
139 void DoVScroll(int type
, int pos
);
140 void DoSize(int width
, int height
);
143 void DoSysColourChange();
144 void DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
145 void DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
146 void DoLeftButtonMove(Point pt
);
147 void DoMiddleButtonUp(Point pt
);
148 void DoMouseWheel(int rotation
, int delta
, int linesPerAction
, int ctrlDown
, bool isPageScroll
);
149 void DoAddChar(int key
);
150 int DoKeyDown(const wxKeyEvent
& event
, bool* consumed
);
151 void DoTick() { Tick(); }
152 void DoOnIdle(wxIdleEvent
& evt
);
155 #if wxUSE_DRAG_AND_DROP
156 bool DoDropText(long x
, long y
, const wxString
& data
);
157 wxDragResult
DoDragEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
158 wxDragResult
DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
162 void DoCommand(int ID
);
163 void DoContextMenu(Point pt
);
170 bool GetHideSelection() { return hideSelection
; }
171 void DoScrollToLine(int line
);
172 void DoScrollToColumn(int column
);
173 void ClipChildren(wxDC
& dc
, PRectangle rect
);
174 void SetUseAntiAliasing(bool useAA
);
175 bool GetUseAntiAliasing();
180 wxStyledTextCtrl
* stc
;
182 #if wxUSE_DRAG_AND_DROP
183 wxSTCDropTarget
* dropTarget
;
184 wxDragResult dragResult
;
185 wxTimer
* startDragTimer
;
190 // For use in creating a system caret
191 bool HasCaretSizeChanged();
192 bool CreateSystemCaret();
193 bool DestroySystemCaret();
195 HBITMAP sysCaretBitmap
;
200 friend class wxSTCCallTip
;
203 //----------------------------------------------------------------------