Advertisement
Guest User

Untitled

a guest
Jan 30th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  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 wxScintilla to function.
  8. //
  9. // Author: Robin Dunn
  10. //
  11. // Created: 13-Jan-2000
  12. // RCS-ID: $Id: ScintillaWX.h,v 1.9 2006/06/06 19:16:25 wyo Exp $
  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 "SplitVector.h"
  38. #include "Partitioning.h"
  39. #include "RunStyles.h"
  40. #include "ContractionState.h"
  41. #include "SVector.h"
  42. #include "CellBuffer.h"
  43. #include "CallTip.h"
  44. #include "KeyMap.h"
  45. #include "Indicator.h"
  46. #include "LineMarker.h"
  47. #include "Style.h"
  48. #include "ViewStyle.h"
  49. #include "AutoComplete.h"
  50. #include "CharClassify.h"
  51. #include "RESearch.h"
  52. #include "Decoration.h"
  53. #include "Document.h"
  54. #include "PositionCache.h"
  55. #include "Editor.h"
  56. #include "ScintillaBase.h"
  57.  
  58. #include <wx/wx.h>
  59. #include <wx/dataobj.h>
  60. #include <wx/clipbrd.h>
  61. #include <wx/dnd.h>
  62.  
  63. //----------------------------------------------------------------------
  64.  
  65. #ifdef WXMAKINGDLL_SCI
  66. #define WXDLLIMPEXP_SCI WXEXPORT
  67. #elif defined(WXUSINGDLL)
  68. #define WXDLLIMPEXP_SCI WXIMPORT
  69. #else // not making nor using DLL
  70. #define WXDLLIMPEXP_SCI
  71. #endif
  72.  
  73. class WXDLLIMPEXP_SCI wxScintilla; // forward
  74. class ScintillaWX;
  75.  
  76.  
  77. //----------------------------------------------------------------------
  78. // Helper classes
  79.  
  80. #if wxUSE_DRAG_AND_DROP
  81. class wxSCIDropTarget : public wxTextDropTarget {
  82. public:
  83. void SetScintilla(ScintillaWX* swx) {
  84. this->swx = swx;
  85. }
  86.  
  87. bool OnDropText(wxCoord x, wxCoord y, const wxString& data);
  88. wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
  89. wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
  90. void OnLeave();
  91.  
  92. private:
  93. ScintillaWX* swx;
  94. };
  95. #endif
  96.  
  97. //----------------------------------------------------------------------
  98.  
  99. class ScintillaWX : public ScintillaBase {
  100. public:
  101.  
  102. ScintillaWX(wxScintilla* win);
  103. ~ScintillaWX();
  104.  
  105. // base class virtuals
  106. virtual void Initialise();
  107. virtual void Finalise();
  108. virtual void StartDrag();
  109. virtual bool SetIdle(bool on);
  110. virtual void SetTicking(bool on);
  111. virtual void SetMouseCapture(bool on);
  112. virtual bool HaveMouseCapture();
  113. virtual void ScrollText(int linesToMove);
  114. virtual void SetVerticalScrollPos();
  115. virtual void SetHorizontalScrollPos();
  116. virtual bool ModifyScrollBars(int nMax, int nPage);
  117. virtual void Copy();
  118. virtual void Paste();
  119. virtual void CopyToClipboard(const SelectionText &selectedText);
  120.  
  121. virtual void CreateCallTipWindow(PRectangle rc);
  122. virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
  123. virtual void ClaimSelection();
  124.  
  125. virtual long DefWndProc(unsigned int iMessage,
  126. unsigned long wParam,
  127. long lParam);
  128. virtual long WndProc(unsigned int iMessage,
  129. unsigned long wParam,
  130. long lParam);
  131.  
  132. virtual void NotifyChange();
  133. virtual void NotifyParent(SCNotification scn);
  134.  
  135. virtual void CancelModes();
  136.  
  137. virtual void UpdateSystemCaret();
  138.  
  139. // Event delegates
  140. void DoPaint(wxDC* dc, wxRect rect);
  141. void DoHScroll(int type, int pos);
  142. void DoVScroll(int type, int pos);
  143. void DoSize(int width, int height);
  144. void DoLoseFocus();
  145. void DoGainFocus();
  146. void DoSysColourChange();
  147. void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
  148. void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
  149. void DoLeftButtonMove(Point pt);
  150. void DoMiddleButtonUp(Point pt);
  151. void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
  152. void DoAddChar(int key);
  153. int DoKeyDown(const wxKeyEvent& event, bool* consumed);
  154. void DoTick() { Tick(); }
  155. void DoOnIdle(wxIdleEvent& evt);
  156. void DoStartDrag();
  157.  
  158. #if wxUSE_DRAG_AND_DROP
  159. bool DoDropText(long x, long y, const wxString& data);
  160. wxDragResult DoDragEnter(wxCoord x, wxCoord y, wxDragResult def);
  161. wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def);
  162. void DoDragLeave();
  163. #endif
  164.  
  165. void DoCommand(int ID);
  166. void DoContextMenu(Point pt);
  167. void DoOnListBox();
  168.  
  169.  
  170. // helpers
  171. void FullPaint();
  172. bool CanPaste();
  173. bool GetHideSelection() { return hideSelection; }
  174. void DoScrollToLine(int line);
  175. void DoScrollToColumn(int column);
  176. void ClipChildren(wxDC& dc, PRectangle rect);
  177. void SetUseAntiAliasing(bool useAA);
  178. bool GetUseAntiAliasing();
  179.  
  180. private:
  181. bool capturedMouse;
  182. bool focusEvent;
  183. wxScintilla* sci;
  184.  
  185. #if wxUSE_DRAG_AND_DROP
  186. wxSCIDropTarget* dropTarget;
  187. wxDragResult dragResult;
  188. bool dragRectangle;
  189. wxTimer* startDragTimer;
  190. #endif
  191.  
  192. int wheelRotation;
  193.  
  194. // For use in creating a system caret
  195. bool HasCaretSizeChanged();
  196. bool CreateSystemCaret();
  197. bool DestroySystemCaret();
  198. #ifdef __WXMSW__
  199. #if wxCHECK_VERSION(2, 5, 0)
  200. HBITMAP sysCaretBitmap;
  201. int sysCaretWidth;
  202. int sysCaretHeight;
  203. #endif
  204. #endif
  205.  
  206. friend class wxSCICallTip;
  207. };
  208.  
  209. //----------------------------------------------------------------------
  210. #endif
  211.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement