]> git.saurik.com Git - wxWidgets.git/blame_incremental - contrib/src/stc/ScintillaWX.h
Actually check if the menu should be shown before popping it up
[wxWidgets.git] / contrib / src / stc / ScintillaWX.h
... / ...
CommitLineData
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
57class wxStyledTextCtrl; // forward
58class ScintillaWX;
59
60
61//----------------------------------------------------------------------
62// Helper classes
63
64#if wxUSE_DRAG_AND_DROP
65class wxSTCDropTarget : public wxTextDropTarget {
66public:
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
76private:
77 ScintillaWX* swx;
78};
79#endif
80
81//----------------------------------------------------------------------
82
83class ScintillaWX : public ScintillaBase {
84public:
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 DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
126 void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
127 void DoButtonMove(Point pt);
128 void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
129 void DoAddChar(int key);
130 int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
131 void DoTick() { Tick(); }
132
133#if wxUSE_DRAG_AND_DROP
134 bool DoDropText(long x, long y, const wxString& data);
135 wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
136 wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
137 void DoDragLeave();
138#endif
139
140 void DoCommand(int ID);
141 void DoContextMenu(Point pt);
142 void DoOnListBox();
143
144
145 // helpers
146 void FullPaint();
147 bool CanPaste();
148 bool GetHideSelection() { return hideSelection; }
149 void DoScrollToLine(int line);
150 void DoScrollToColumn(int column);
151
152private:
153 bool capturedMouse;
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