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