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"
52 //----------------------------------------------------------------------
54 #ifdef WXMAKINGDLL_STC
55 #define WXDLLIMPEXP_STC WXEXPORT
56 #elif defined(WXUSINGDLL)
57 #define WXDLLIMPEXP_STC WXIMPORT
58 #else // not making nor using DLL
59 #define WXDLLIMPEXP_STC
62 class WXDLLIMPEXP_STC wxStyledTextCtrl
; // forward
66 //----------------------------------------------------------------------
69 #if wxUSE_DRAG_AND_DROP
70 class wxSTCDropTarget
: public wxTextDropTarget
{
72 void SetScintilla(ScintillaWX
* swx
) {
76 bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
);
77 wxDragResult
OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
78 wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
86 //----------------------------------------------------------------------
88 class ScintillaWX
: public ScintillaBase
{
91 ScintillaWX(wxStyledTextCtrl
* win
);
94 // base class virtuals
95 virtual void Initialise();
96 virtual void Finalise();
97 virtual void StartDrag();
98 virtual bool SetIdle(bool on
);
99 virtual void SetTicking(bool on
);
100 virtual void SetMouseCapture(bool on
);
101 virtual bool HaveMouseCapture();
102 virtual void ScrollText(int linesToMove
);
103 virtual void SetVerticalScrollPos();
104 virtual void SetHorizontalScrollPos();
105 virtual bool ModifyScrollBars(int nMax
, int nPage
);
107 virtual void Paste();
108 virtual void CopyToClipboard(const SelectionText
&selectedText
);
110 virtual void CreateCallTipWindow(PRectangle rc
);
111 virtual void AddToPopUp(const char *label
, int cmd
= 0, bool enabled
= true);
112 virtual void ClaimSelection();
114 virtual long DefWndProc(unsigned int iMessage
,
115 unsigned long wParam
,
117 virtual long WndProc(unsigned int iMessage
,
118 unsigned long wParam
,
121 virtual void NotifyChange();
122 virtual void NotifyParent(SCNotification scn
);
124 virtual void CancelModes();
126 virtual void UpdateSystemCaret();
129 void DoPaint(wxDC
* dc
, wxRect rect
);
130 void DoHScroll(int type
, int pos
);
131 void DoVScroll(int type
, int pos
);
132 void DoSize(int width
, int height
);
135 void DoSysColourChange();
136 void DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
137 void DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
138 void DoLeftButtonMove(Point pt
);
139 void DoMiddleButtonUp(Point pt
);
140 void DoMouseWheel(int rotation
, int delta
, int linesPerAction
, int ctrlDown
, bool isPageScroll
);
141 void DoAddChar(int key
);
142 int DoKeyDown(const wxKeyEvent
& event
, bool* consumed
);
143 void DoTick() { Tick(); }
144 void DoOnIdle(wxIdleEvent
& evt
);
147 #if wxUSE_DRAG_AND_DROP
148 bool DoDropText(long x
, long y
, const wxString
& data
);
149 wxDragResult
DoDragEnter(wxCoord x
, wxCoord y
, wxDragResult def
);
150 wxDragResult
DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
154 void DoCommand(int ID
);
155 void DoContextMenu(Point pt
);
162 bool GetHideSelection() { return hideSelection
; }
163 void DoScrollToLine(int line
);
164 void DoScrollToColumn(int column
);
165 void ClipChildren(wxDC
& dc
, PRectangle rect
);
166 void SetUseAntiAliasing(bool useAA
);
167 bool GetUseAntiAliasing();
172 wxStyledTextCtrl
* stc
;
174 #if wxUSE_DRAG_AND_DROP
175 wxSTCDropTarget
* dropTarget
;
176 wxDragResult dragResult
;
177 wxTimer
* startDragTimer
;
182 // For use in creating a system caret
183 bool HasCaretSizeChanged();
184 bool CreateSystemCaret();
185 bool DestroySystemCaret();
187 HBITMAP sysCaretBitmap
;
192 friend class wxSTCCallTip
;
195 //----------------------------------------------------------------------