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