forward declare wxDC (fixes wxMotif compilation)
[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
20 //----------------------------------------------------------------------
21
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26
27 #include "Platform.h"
28
29 #include "Scintilla.h"
30 #include "CharClassify.h"
31 #include "XPM.h"
32 #ifdef SCI_LEXER
33 #include "SciLexer.h"
34 #include "PropSet.h"
35 #include "Accessor.h"
36 #include "KeyWords.h"
37 #endif
38 #include "ContractionState.h"
39 #include "SVector.h"
40 #include "CellBuffer.h"
41 #include "CallTip.h"
42 #include "KeyMap.h"
43 #include "Indicator.h"
44 #include "LineMarker.h"
45 #include "Style.h"
46 #include "ViewStyle.h"
47 #include "AutoComplete.h"
48 #include "Document.h"
49 #include "Editor.h"
50 #include "ScintillaBase.h"
51
52 #ifdef __WXMSW__
53 #include "wx/msw/wrapwin.h" // HBITMAP
54 #endif
55 #if wxUSE_DRAG_AND_DROP
56 #include "wx/timer.h"
57 #endif
58
59 //----------------------------------------------------------------------
60
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
67 #endif
68
69 class WXDLLIMPEXP_CORE wxDC;
70 class WXDLLIMPEXP_STC wxStyledTextCtrl; // forward
71 class ScintillaWX;
72
73
74 //----------------------------------------------------------------------
75 // Helper classes
76
77 #if wxUSE_DRAG_AND_DROP
78 class wxSTCDropTarget : public wxTextDropTarget {
79 public:
80 void SetScintilla(ScintillaWX* swx) {
81 this->swx = swx;
82 }
83
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);
87 void OnLeave();
88
89 private:
90 ScintillaWX* swx;
91 };
92 #endif
93
94 //----------------------------------------------------------------------
95
96 class ScintillaWX : public ScintillaBase {
97 public:
98
99 ScintillaWX(wxStyledTextCtrl* win);
100 ~ScintillaWX();
101
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);
114 virtual void Copy();
115 virtual void Paste();
116 virtual void CopyToClipboard(const SelectionText &selectedText);
117
118 virtual void CreateCallTipWindow(PRectangle rc);
119 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
120 virtual void ClaimSelection();
121
122 virtual sptr_t DefWndProc(unsigned int iMessage,
123 uptr_t wParam,
124 sptr_t lParam);
125 virtual sptr_t WndProc(unsigned int iMessage,
126 uptr_t wParam,
127 sptr_t lParam);
128
129 virtual void NotifyChange();
130 virtual void NotifyParent(SCNotification scn);
131
132 virtual void CancelModes();
133
134 virtual void UpdateSystemCaret();
135
136 // Event delegates
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);
141 void DoLoseFocus();
142 void DoGainFocus();
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);
153 void DoStartDrag();
154
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);
159 void DoDragLeave();
160 #endif
161
162 void DoCommand(int ID);
163 void DoContextMenu(Point pt);
164 void DoOnListBox();
165
166
167 // helpers
168 void FullPaint();
169 bool CanPaste();
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();
176
177 private:
178 bool capturedMouse;
179 bool focusEvent;
180 wxStyledTextCtrl* stc;
181
182 #if wxUSE_DRAG_AND_DROP
183 wxSTCDropTarget* dropTarget;
184 wxDragResult dragResult;
185 wxTimer* startDragTimer;
186 #endif
187
188 int wheelRotation;
189
190 // For use in creating a system caret
191 bool HasCaretSizeChanged();
192 bool CreateSystemCaret();
193 bool DestroySystemCaret();
194 #ifdef __WXMSW__
195 HBITMAP sysCaretBitmap;
196 int sysCaretWidth;
197 int sysCaretHeight;
198 #endif
199
200 friend class wxSTCCallTip;
201 };
202
203 //----------------------------------------------------------------------
204 #endif