Don't use -kAddToPopUp() gettext hack with Scintilla.
[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 #include "SplitVector.h"
30 #include "Partitioning.h"
31 #include "RunStyles.h"
32 #include "Scintilla.h"
33 #include "ScintillaWidget.h"
34 #ifdef SCI_LEXER
35 #include "SciLexer.h"
36 #include "PropSet.h"
37 #include "Accessor.h"
38 #include "KeyWords.h"
39 #endif
40 #include "ContractionState.h"
41 #include "SVector.h"
42 #include "CellBuffer.h"
43 #include "CallTip.h"
44 #include "KeyMap.h"
45 #include "Indicator.h"
46 #include "XPM.h"
47 #include "LineMarker.h"
48 #include "Style.h"
49 #include "AutoComplete.h"
50 #include "ViewStyle.h"
51 #include "CharClassify.h"
52 #include "Decoration.h"
53 #include "Document.h"
54 #include "Selection.h"
55 #include "PositionCache.h"
56 #include "Editor.h"
57 #include "PropSetSimple.h"
58 #include "ScintillaBase.h"
59
60 #ifdef __WXMSW__
61 #include "wx/msw/wrapwin.h" // HBITMAP
62 #endif
63 #if wxUSE_DRAG_AND_DROP
64 #include "wx/timer.h"
65 #endif
66
67 //----------------------------------------------------------------------
68
69
70 class WXDLLIMPEXP_FWD_CORE wxDC;
71 class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward
72 class ScintillaWX;
73
74
75 //----------------------------------------------------------------------
76 // Helper classes
77
78 #if wxUSE_DRAG_AND_DROP
79 class wxSTCDropTarget : public wxTextDropTarget {
80 public:
81 void SetScintilla(ScintillaWX* swx) {
82 m_swx = swx;
83 }
84
85 bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
86 wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
87 wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
88 void OnLeave();
89
90 private:
91 ScintillaWX* m_swx;
92 };
93 #endif
94
95 //----------------------------------------------------------------------
96
97 class ScintillaWX : public ScintillaBase {
98 public:
99
100 ScintillaWX(wxStyledTextCtrl* win);
101 ~ScintillaWX();
102
103 // base class virtuals
104 virtual void Initialise();
105 virtual void Finalise();
106 virtual void StartDrag();
107 virtual bool SetIdle(bool on);
108 virtual void SetTicking(bool on);
109 virtual void SetMouseCapture(bool on);
110 virtual bool HaveMouseCapture();
111 virtual void ScrollText(int linesToMove);
112 virtual void SetVerticalScrollPos();
113 virtual void SetHorizontalScrollPos();
114 virtual bool ModifyScrollBars(int nMax, int nPage);
115 virtual void Copy();
116 virtual void Paste();
117 virtual void CopyToClipboard(const SelectionText &selectedText);
118
119 virtual void CreateCallTipWindow(PRectangle rc);
120 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
121 virtual void ClaimSelection();
122
123 virtual sptr_t DefWndProc(unsigned int iMessage,
124 uptr_t wParam,
125 sptr_t lParam);
126 virtual sptr_t WndProc(unsigned int iMessage,
127 uptr_t wParam,
128 sptr_t lParam);
129
130 virtual void NotifyChange();
131 virtual void NotifyParent(SCNotification scn);
132
133 virtual void CancelModes();
134
135 virtual void UpdateSystemCaret();
136
137 // Event delegates
138 void DoPaint(wxDC* dc, wxRect rect);
139 void DoHScroll(int type, int pos);
140 void DoVScroll(int type, int pos);
141 void DoSize(int width, int height);
142 void DoLoseFocus();
143 void DoGainFocus();
144 void DoSysColourChange();
145 void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
146 void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
147 void DoLeftButtonMove(Point pt);
148 void DoMiddleButtonUp(Point pt);
149 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
150 void DoAddChar(int key);
151 int DoKeyDown(const wxKeyEvent& event, bool* consumed);
152 void DoTick() { Tick(); }
153 void DoOnIdle(wxIdleEvent& evt);
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 #endif
186
187 int wheelRotation;
188
189 // For use in creating a system caret
190 bool HasCaretSizeChanged();
191 bool CreateSystemCaret();
192 bool DestroySystemCaret();
193 #ifdef __WXMSW__
194 HBITMAP sysCaretBitmap;
195 int sysCaretWidth;
196 int sysCaretHeight;
197 #endif
198
199 friend class wxSTCCallTip;
200 };
201
202 //----------------------------------------------------------------------
203 #endif