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_STC wxStyledTextCtrl
; // forward
73 //----------------------------------------------------------------------
76 #if wxUSE_DRAG_AND_DROP
77 class wxSTCDropTarget
: public wxTextDropTarget
{
79 void SetScintilla(ScintillaWX
* swx
) {
83 bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
);
84 wxDragResult
OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
85 wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
93 //----------------------------------------------------------------------
95 class ScintillaWX
: public ScintillaBase
{
98 ScintillaWX(wxStyledTextCtrl
* win
);
101 // base class virtuals
102 virtual void Initialise();
103 virtual void Finalise();
104 virtual void StartDrag();
105 virtual bool SetIdle(bool on
);
106 virtual void SetTicking(bool on
);
107 virtual void SetMouseCapture(bool on
);
108 virtual bool HaveMouseCapture();
109 virtual void ScrollText(int linesToMove
);
110 virtual void SetVerticalScrollPos();
111 virtual void SetHorizontalScrollPos();
112 virtual bool ModifyScrollBars(int nMax
, int nPage
);
114 virtual void Paste();
115 virtual void CopyToClipboard(const SelectionText
&selectedText
);
117 virtual void CreateCallTipWindow(PRectangle rc
);
118 virtual void AddToPopUp(const char *label
, int cmd
= 0, bool enabled
= true);
119 virtual void ClaimSelection();
121 virtual sptr_t
DefWndProc(unsigned int iMessage
,
124 virtual sptr_t
WndProc(unsigned int iMessage
,
128 virtual void NotifyChange();
129 virtual void NotifyParent(SCNotification scn
);
131 virtual void CancelModes();
133 virtual void UpdateSystemCaret();
136 void DoPaint(wxDC
* dc
, wxRect rect
);
137 void DoHScroll(int type
, int pos
);
138 void DoVScroll(int type
, int pos
);
139 void DoSize(int width
, int height
);
142 void DoSysColourChange();
143 void DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
144 void DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
145 void DoLeftButtonMove(Point pt
);
146 void DoMiddleButtonUp(Point pt
);
147 void DoMouseWheel(int rotation
, int delta
, int linesPerAction
, int ctrlDown
, bool isPageScroll
);
148 void DoAddChar(int key
);
149 int DoKeyDown(const wxKeyEvent
& event
, bool* consumed
);
150 void DoTick() { Tick(); }
151 void DoOnIdle(wxIdleEvent
& evt
);
154 #if wxUSE_DRAG_AND_DROP
155 bool DoDropText(long x
, long y
, const wxString
& data
);
156 wxDragResult
DoDragEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
157 wxDragResult
DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
161 void DoCommand(int ID
);
162 void DoContextMenu(Point pt
);
169 bool GetHideSelection() { return hideSelection
; }
170 void DoScrollToLine(int line
);
171 void DoScrollToColumn(int column
);
172 void ClipChildren(wxDC
& dc
, PRectangle rect
);
173 void SetUseAntiAliasing(bool useAA
);
174 bool GetUseAntiAliasing();
179 wxStyledTextCtrl
* stc
;
181 #if wxUSE_DRAG_AND_DROP
182 wxSTCDropTarget
* dropTarget
;
183 wxDragResult dragResult
;
184 wxTimer
* startDragTimer
;
189 // For use in creating a system caret
190 bool HasCaretSizeChanged();
191 bool CreateSystemCaret();
192 bool DestroySystemCaret();
194 HBITMAP sysCaretBitmap
;
199 friend class wxSTCCallTip
;
202 //----------------------------------------------------------------------