]> git.saurik.com Git - wxWidgets.git/blob - src/stc/ScintillaWX.h
Add wxColour::{Set,Get}RGB[A]().
[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 "SplitVector.h"
40 #include "Partitioning.h"
41 #include "RunStyles.h"
42 #include "ContractionState.h"
43 #include "CellBuffer.h"
44 #include "CallTip.h"
45 #include "KeyMap.h"
46 #include "Indicator.h"
47 #include "LineMarker.h"
48 #include "Style.h"
49 #include "ViewStyle.h"
50 #include "AutoComplete.h"
51 #include "Decoration.h"
52 #include "Document.h"
53 #include "PositionCache.h"
54 #include "Editor.h"
55 #include "ScintillaBase.h"
56
57 #ifdef __WXMSW__
58 #include "wx/msw/wrapwin.h" // HBITMAP
59 #endif
60 #if wxUSE_DRAG_AND_DROP
61 #include "wx/timer.h"
62 #endif
63
64 //----------------------------------------------------------------------
65
66
67 class WXDLLIMPEXP_FWD_CORE wxDC;
68 class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward
69 class ScintillaWX;
70
71
72 //----------------------------------------------------------------------
73 // Helper classes
74
75 #if wxUSE_DRAG_AND_DROP
76 class wxSTCDropTarget : public wxTextDropTarget {
77 public:
78 void SetScintilla(ScintillaWX* swx) {
79 m_swx = swx;
80 }
81
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);
85 void OnLeave();
86
87 private:
88 ScintillaWX* m_swx;
89 };
90 #endif
91
92 //----------------------------------------------------------------------
93
94 class ScintillaWX : public ScintillaBase {
95 public:
96
97 ScintillaWX(wxStyledTextCtrl* win);
98 ~ScintillaWX();
99
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);
112 virtual void Copy();
113 virtual void Paste();
114 virtual void CopyToClipboard(const SelectionText &selectedText);
115
116 virtual void CreateCallTipWindow(PRectangle rc);
117 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
118 virtual void ClaimSelection();
119
120 virtual sptr_t DefWndProc(unsigned int iMessage,
121 uptr_t wParam,
122 sptr_t lParam);
123 virtual sptr_t WndProc(unsigned int iMessage,
124 uptr_t wParam,
125 sptr_t lParam);
126
127 virtual void NotifyChange();
128 virtual void NotifyParent(SCNotification scn);
129
130 virtual void CancelModes();
131
132 virtual void UpdateSystemCaret();
133
134 // Event delegates
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);
139 void DoLoseFocus();
140 void DoGainFocus();
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);
151
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);
156 void DoDragLeave();
157 #endif
158
159 void DoCommand(int ID);
160 void DoContextMenu(Point pt);
161 void DoOnListBox();
162
163
164 // helpers
165 void FullPaint();
166 bool CanPaste();
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();
173
174 private:
175 bool capturedMouse;
176 bool focusEvent;
177 wxStyledTextCtrl* stc;
178
179 #if wxUSE_DRAG_AND_DROP
180 wxSTCDropTarget* dropTarget;
181 wxDragResult dragResult;
182 #endif
183
184 int wheelRotation;
185
186 // For use in creating a system caret
187 bool HasCaretSizeChanged();
188 bool CreateSystemCaret();
189 bool DestroySystemCaret();
190 #ifdef __WXMSW__
191 HBITMAP sysCaretBitmap;
192 int sysCaretWidth;
193 int sysCaretHeight;
194 #endif
195
196 friend class wxSTCCallTip;
197 };
198
199 //----------------------------------------------------------------------
200 #endif