]> git.saurik.com Git - wxWidgets.git/blob - src/stc/ScintillaWX.h
cleanup
[wxWidgets.git] / src / stc / ScintillaWX.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: 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 license
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
28 #include "Platform.h"
29
30 #include "Scintilla.h"
31 #include "CharClassify.h"
32 #include "XPM.h"
33 #ifdef SCI_LEXER
34 #include "SciLexer.h"
35 #include "PropSet.h"
36 #include "Accessor.h"
37 #include "KeyWords.h"
38 #endif
39 #include "ContractionState.h"
40 #include "SVector.h"
41 #include "CellBuffer.h"
42 #include "CallTip.h"
43 #include "KeyMap.h"
44 #include "Indicator.h"
45 #include "LineMarker.h"
46 #include "Style.h"
47 #include "ViewStyle.h"
48 #include "AutoComplete.h"
49 #include "Document.h"
50 #include "Editor.h"
51 #include "ScintillaBase.h"
52
53 #ifdef __WXMSW__
54 #include "wx/msw/wrapwin.h" // HBITMAP
55 #endif
56 #if wxUSE_DRAG_AND_DROP
57 #include "wx/timer.h"
58 #endif
59
60 //----------------------------------------------------------------------
61
62
63 class WXDLLIMPEXP_FWD_CORE wxDC;
64 class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward
65 class ScintillaWX;
66
67
68 //----------------------------------------------------------------------
69 // Helper classes
70
71 #if wxUSE_DRAG_AND_DROP
72 class wxSTCDropTarget : public wxTextDropTarget {
73 public:
74 void SetScintilla(ScintillaWX* swx) {
75 m_swx = swx;
76 }
77
78 bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
79 wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
80 wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
81 void OnLeave();
82
83 private:
84 ScintillaWX* m_swx;
85 };
86 #endif
87
88 //----------------------------------------------------------------------
89
90 class ScintillaWX : public ScintillaBase {
91 public:
92
93 ScintillaWX(wxStyledTextCtrl* win);
94 ~ScintillaWX();
95
96 // base class virtuals
97 virtual void Initialise();
98 virtual void Finalise();
99 virtual void StartDrag();
100 virtual bool SetIdle(bool on);
101 virtual void SetTicking(bool on);
102 virtual void SetMouseCapture(bool on);
103 virtual bool HaveMouseCapture();
104 virtual void ScrollText(int linesToMove);
105 virtual void SetVerticalScrollPos();
106 virtual void SetHorizontalScrollPos();
107 virtual bool ModifyScrollBars(int nMax, int nPage);
108 virtual void Copy();
109 virtual void Paste();
110 virtual void CopyToClipboard(const SelectionText &selectedText);
111
112 virtual void CreateCallTipWindow(PRectangle rc);
113 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
114 virtual void ClaimSelection();
115
116 virtual sptr_t DefWndProc(unsigned int iMessage,
117 uptr_t wParam,
118 sptr_t lParam);
119 virtual sptr_t WndProc(unsigned int iMessage,
120 uptr_t wParam,
121 sptr_t lParam);
122
123 virtual void NotifyChange();
124 virtual void NotifyParent(SCNotification scn);
125
126 virtual void CancelModes();
127
128 virtual void UpdateSystemCaret();
129
130 // Event delegates
131 void DoPaint(wxDC* dc, wxRect rect);
132 void DoHScroll(int type, int pos);
133 void DoVScroll(int type, int pos);
134 void DoSize(int width, int height);
135 void DoLoseFocus();
136 void DoGainFocus();
137 void DoSysColourChange();
138 void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
139 void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
140 void DoLeftButtonMove(Point pt);
141 void DoMiddleButtonUp(Point pt);
142 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
143 void DoAddChar(int key);
144 int DoKeyDown(const wxKeyEvent& event, bool* consumed);
145 void DoTick() { Tick(); }
146 void DoOnIdle(wxIdleEvent& evt);
147 void DoStartDrag();
148
149 #if wxUSE_DRAG_AND_DROP
150 bool DoDropText(long x, long y, const wxString& data);
151 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
152 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
153 void DoDragLeave();
154 #endif
155
156 void DoCommand(int ID);
157 void DoContextMenu(Point pt);
158 void DoOnListBox();
159
160
161 // helpers
162 void FullPaint();
163 bool CanPaste();
164 bool GetHideSelection() { return hideSelection; }
165 void DoScrollToLine(int line);
166 void DoScrollToColumn(int column);
167 void ClipChildren(wxDC& dc, PRectangle rect);
168 void SetUseAntiAliasing(bool useAA);
169 bool GetUseAntiAliasing();
170
171 private:
172 bool capturedMouse;
173 bool focusEvent;
174 wxStyledTextCtrl* stc;
175
176 #if wxUSE_DRAG_AND_DROP
177 wxSTCDropTarget* dropTarget;
178 wxDragResult dragResult;
179 wxTimer* startDragTimer;
180 #endif
181
182 int wheelRotation;
183
184 // For use in creating a system caret
185 bool HasCaretSizeChanged();
186 bool CreateSystemCaret();
187 bool DestroySystemCaret();
188 #ifdef __WXMSW__
189 HBITMAP sysCaretBitmap;
190 int sysCaretWidth;
191 int sysCaretHeight;
192 #endif
193
194 friend class wxSTCCallTip;
195 };
196
197 //----------------------------------------------------------------------
198 #endif