Compile fix for gcc on MSW
[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_STC wxStyledTextCtrl; // forward
70 class ScintillaWX;
71
72
73 //----------------------------------------------------------------------
74 // Helper classes
75
76 #if wxUSE_DRAG_AND_DROP
77 class wxSTCDropTarget : public wxTextDropTarget {
78 public:
79 void SetScintilla(ScintillaWX* swx) {
80 this->swx = swx;
81 }
82
83 bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
84 wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
85 wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
86 void OnLeave();
87
88 private:
89 ScintillaWX* swx;
90 };
91 #endif
92
93 //----------------------------------------------------------------------
94
95 class ScintillaWX : public ScintillaBase {
96 public:
97
98 ScintillaWX(wxStyledTextCtrl* win);
99 ~ScintillaWX();
100
101 // base class virtuals
102 virtual void Initialise();
103 virtual void Finalise();
104 virtual void StartDrag();
105 virtual bool SetIdle(bool on);
106 virtual void SetTicking(bool on);
107 virtual void SetMouseCapture(bool on);
108 virtual bool HaveMouseCapture();
109 virtual void ScrollText(int linesToMove);
110 virtual void SetVerticalScrollPos();
111 virtual void SetHorizontalScrollPos();
112 virtual bool ModifyScrollBars(int nMax, int nPage);
113 virtual void Copy();
114 virtual void Paste();
115 virtual void CopyToClipboard(const SelectionText &selectedText);
116
117 virtual void CreateCallTipWindow(PRectangle rc);
118 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
119 virtual void ClaimSelection();
120
121 virtual sptr_t DefWndProc(unsigned int iMessage,
122 uptr_t wParam,
123 sptr_t lParam);
124 virtual sptr_t WndProc(unsigned int iMessage,
125 uptr_t wParam,
126 sptr_t lParam);
127
128 virtual void NotifyChange();
129 virtual void NotifyParent(SCNotification scn);
130
131 virtual void CancelModes();
132
133 virtual void UpdateSystemCaret();
134
135 // Event delegates
136 void DoPaint(wxDC* dc, wxRect rect);
137 void DoHScroll(int type, int pos);
138 void DoVScroll(int type, int pos);
139 void DoSize(int width, int height);
140 void DoLoseFocus();
141 void DoGainFocus();
142 void DoSysColourChange();
143 void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
144 void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
145 void DoLeftButtonMove(Point pt);
146 void DoMiddleButtonUp(Point pt);
147 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
148 void DoAddChar(int key);
149 int DoKeyDown(const wxKeyEvent& event, bool* consumed);
150 void DoTick() { Tick(); }
151 void DoOnIdle(wxIdleEvent& evt);
152 void DoStartDrag();
153
154 #if wxUSE_DRAG_AND_DROP
155 bool DoDropText(long x, long y, const wxString& data);
156 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
157 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
158 void DoDragLeave();
159 #endif
160
161 void DoCommand(int ID);
162 void DoContextMenu(Point pt);
163 void DoOnListBox();
164
165
166 // helpers
167 void FullPaint();
168 bool CanPaste();
169 bool GetHideSelection() { return hideSelection; }
170 void DoScrollToLine(int line);
171 void DoScrollToColumn(int column);
172 void ClipChildren(wxDC& dc, PRectangle rect);
173 void SetUseAntiAliasing(bool useAA);
174 bool GetUseAntiAliasing();
175
176 private:
177 bool capturedMouse;
178 bool focusEvent;
179 wxStyledTextCtrl* stc;
180
181 #if wxUSE_DRAG_AND_DROP
182 wxSTCDropTarget* dropTarget;
183 wxDragResult dragResult;
184 wxTimer* startDragTimer;
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