]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: ScintillaWX.h | |
3 | // Purpose: A wxWindows 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 | #ifdef SCI_LEXER | |
31 | #include "SciLexer.h" | |
32 | #include "PropSet.h" | |
33 | #include "Accessor.h" | |
34 | #include "KeyWords.h" | |
35 | #endif | |
36 | #include "ContractionState.h" | |
37 | #include "SVector.h" | |
38 | #include "CellBuffer.h" | |
39 | #include "CallTip.h" | |
40 | #include "KeyMap.h" | |
41 | #include "Indicator.h" | |
42 | #include "LineMarker.h" | |
43 | #include "Style.h" | |
44 | #include "ViewStyle.h" | |
45 | #include "AutoComplete.h" | |
46 | #include "Document.h" | |
47 | #include "Editor.h" | |
48 | #include "ScintillaBase.h" | |
49 | ||
50 | #include <wx/wx.h> | |
51 | #include <wx/dataobj.h> | |
52 | #include <wx/clipbrd.h> | |
53 | #include <wx/dnd.h> | |
54 | ||
55 | //---------------------------------------------------------------------- | |
56 | ||
57 | class wxStyledTextCtrl; // forward | |
58 | class ScintillaWX; | |
59 | ||
60 | ||
61 | //---------------------------------------------------------------------- | |
62 | // Helper classes | |
63 | ||
64 | #if wxUSE_DRAG_AND_DROP | |
65 | class wxSTCDropTarget : public wxTextDropTarget { | |
66 | public: | |
67 | void SetScintilla(ScintillaWX* swx) { | |
68 | this->swx = swx; | |
69 | } | |
70 | ||
71 | bool OnDropText(wxCoord x, wxCoord y, const wxString& data); | |
72 | wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); | |
73 | wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
74 | void OnLeave(); | |
75 | ||
76 | private: | |
77 | ScintillaWX* swx; | |
78 | }; | |
79 | #endif | |
80 | ||
81 | //---------------------------------------------------------------------- | |
82 | ||
83 | class ScintillaWX : public ScintillaBase { | |
84 | public: | |
85 | ||
86 | ScintillaWX(wxStyledTextCtrl* win); | |
87 | ~ScintillaWX(); | |
88 | ||
89 | // base class virtuals | |
90 | virtual void Initialise(); | |
91 | virtual void Finalise(); | |
92 | virtual void StartDrag(); | |
93 | virtual void SetTicking(bool on); | |
94 | virtual void SetMouseCapture(bool on); | |
95 | virtual bool HaveMouseCapture(); | |
96 | virtual void ScrollText(int linesToMove); | |
97 | virtual void SetVerticalScrollPos(); | |
98 | virtual void SetHorizontalScrollPos(); | |
99 | virtual bool ModifyScrollBars(int nMax, int nPage); | |
100 | virtual void Copy(); | |
101 | virtual void Paste(); | |
102 | virtual void CreateCallTipWindow(PRectangle rc); | |
103 | virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); | |
104 | virtual void ClaimSelection(); | |
105 | ||
106 | virtual long DefWndProc(unsigned int iMessage, | |
107 | unsigned long wParam, | |
108 | long lParam); | |
109 | virtual long WndProc(unsigned int iMessage, | |
110 | unsigned long wParam, | |
111 | long lParam); | |
112 | ||
113 | virtual void NotifyChange(); | |
114 | virtual void NotifyParent(SCNotification scn); | |
115 | ||
116 | ||
117 | // Event delegates | |
118 | void DoPaint(wxDC* dc, wxRect rect); | |
119 | void DoHScroll(int type, int pos); | |
120 | void DoVScroll(int type, int pos); | |
121 | void DoSize(int width, int height); | |
122 | void DoLoseFocus(); | |
123 | void DoGainFocus(); | |
124 | void DoSysColourChange(); | |
125 | void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); | |
126 | void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl); | |
127 | void DoLeftButtonMove(Point pt); | |
128 | void DoMiddleButtonUp(Point pt); | |
129 | void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll); | |
130 | void DoAddChar(int key); | |
131 | int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed); | |
132 | void DoTick() { Tick(); } | |
133 | ||
134 | #if wxUSE_DRAG_AND_DROP | |
135 | bool DoDropText(long x, long y, const wxString& data); | |
136 | wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def); | |
137 | wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); | |
138 | void DoDragLeave(); | |
139 | #endif | |
140 | ||
141 | void DoCommand(int ID); | |
142 | void DoContextMenu(Point pt); | |
143 | void DoOnListBox(); | |
144 | ||
145 | ||
146 | // helpers | |
147 | void FullPaint(); | |
148 | bool CanPaste(); | |
149 | bool GetHideSelection() { return hideSelection; } | |
150 | void DoScrollToLine(int line); | |
151 | void DoScrollToColumn(int column); | |
152 | ||
153 | private: | |
154 | wxStyledTextCtrl* stc; | |
155 | ||
156 | #if wxUSE_DRAG_AND_DROP | |
157 | wxSTCDropTarget* dropTarget; | |
158 | wxDragResult dragResult; | |
159 | #endif | |
160 | int wheelRotation; | |
161 | }; | |
162 | ||
163 | //---------------------------------------------------------------------- | |
164 | #endif |