]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/stc/ScintillaWX.h
don't crash if one of GetAllCommands() parameters is NULL (coverity checker CID 11)
[wxWidgets.git] / src / stc / ScintillaWX.h
... / ...
CommitLineData
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 "XPM.h"
31#ifdef SCI_LEXER
32#include "SciLexer.h"
33#include "PropSet.h"
34#include "Accessor.h"
35#include "KeyWords.h"
36#endif
37#include "ContractionState.h"
38#include "SVector.h"
39#include "CellBuffer.h"
40#include "CallTip.h"
41#include "KeyMap.h"
42#include "Indicator.h"
43#include "LineMarker.h"
44#include "Style.h"
45#include "ViewStyle.h"
46#include "AutoComplete.h"
47#include "Document.h"
48#include "Editor.h"
49#include "ScintillaBase.h"
50
51
52//----------------------------------------------------------------------
53
54#ifdef WXMAKINGDLL_STC
55 #define WXDLLIMPEXP_STC WXEXPORT
56#elif defined(WXUSINGDLL)
57 #define WXDLLIMPEXP_STC WXIMPORT
58#else // not making nor using DLL
59 #define WXDLLIMPEXP_STC
60#endif
61
62class WXDLLIMPEXP_STC wxStyledTextCtrl; // forward
63class ScintillaWX;
64
65
66//----------------------------------------------------------------------
67// Helper classes
68
69#if wxUSE_DRAG_AND_DROP
70class wxSTCDropTarget : public wxTextDropTarget {
71public:
72 void SetScintilla(ScintillaWX* swx) {
73 this->swx = swx;
74 }
75
76 bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
77 wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
78 wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
79 void OnLeave();
80
81private:
82 ScintillaWX* swx;
83};
84#endif
85
86//----------------------------------------------------------------------
87
88class ScintillaWX : public ScintillaBase {
89public:
90
91 ScintillaWX(wxStyledTextCtrl* win);
92 ~ScintillaWX();
93
94 // base class virtuals
95 virtual void Initialise();
96 virtual void Finalise();
97 virtual void StartDrag();
98 virtual bool SetIdle(bool on);
99 virtual void SetTicking(bool on);
100 virtual void SetMouseCapture(bool on);
101 virtual bool HaveMouseCapture();
102 virtual void ScrollText(int linesToMove);
103 virtual void SetVerticalScrollPos();
104 virtual void SetHorizontalScrollPos();
105 virtual bool ModifyScrollBars(int nMax, int nPage);
106 virtual void Copy();
107 virtual void Paste();
108 virtual void CopyToClipboard(const SelectionText &selectedText);
109
110 virtual void CreateCallTipWindow(PRectangle rc);
111 virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
112 virtual void ClaimSelection();
113
114 virtual long DefWndProc(unsigned int iMessage,
115 unsigned long wParam,
116 long lParam);
117 virtual long WndProc(unsigned int iMessage,
118 unsigned long wParam,
119 long lParam);
120
121 virtual void NotifyChange();
122 virtual void NotifyParent(SCNotification scn);
123
124 virtual void CancelModes();
125
126 virtual void UpdateSystemCaret();
127
128 // Event delegates
129 void DoPaint(wxDC* dc, wxRect rect);
130 void DoHScroll(int type, int pos);
131 void DoVScroll(int type, int pos);
132 void DoSize(int width, int height);
133 void DoLoseFocus();
134 void DoGainFocus();
135 void DoSysColourChange();
136 void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
137 void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
138 void DoLeftButtonMove(Point pt);
139 void DoMiddleButtonUp(Point pt);
140 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
141 void DoAddChar(int key);
142 int DoKeyDown(const wxKeyEvent& event, bool* consumed);
143 void DoTick() { Tick(); }
144 void DoOnIdle(wxIdleEvent& evt);
145
146#if wxUSE_DRAG_AND_DROP
147 bool DoDropText(long x, long y, const wxString& data);
148 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
149 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
150 void DoDragLeave();
151#endif
152
153 void DoCommand(int ID);
154 void DoContextMenu(Point pt);
155 void DoOnListBox();
156
157
158 // helpers
159 void FullPaint();
160 bool CanPaste();
161 bool GetHideSelection() { return hideSelection; }
162 void DoScrollToLine(int line);
163 void DoScrollToColumn(int column);
164 void ClipChildren(wxDC& dc, PRectangle rect);
165 void SetUseAntiAliasing(bool useAA);
166 bool GetUseAntiAliasing();
167
168private:
169 bool capturedMouse;
170 bool focusEvent;
171 wxStyledTextCtrl* stc;
172
173#if wxUSE_DRAG_AND_DROP
174 wxSTCDropTarget* dropTarget;
175 wxDragResult dragResult;
176#endif
177 int wheelRotation;
178
179 // For use in creating a system caret
180 bool HasCaretSizeChanged();
181 bool CreateSystemCaret();
182 bool DestroySystemCaret();
183#ifdef __WXMSW__
184 HBITMAP sysCaretBitmap;
185 int sysCaretWidth;
186 int sysCaretHeight;
187#endif
188
189 friend class wxSTCCallTip;
190};
191
192//----------------------------------------------------------------------
193#endif