ScintillaQt.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // The definition of the Qt specific subclass of ScintillaBase.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef SCINTILLAQT_H
  20. #define SCINTILLAQT_H
  21. #include <QClipboard>
  22. #include <QObject>
  23. #include <Qsci/qsciglobal.h>
  24. #include "SciNamespace.h"
  25. // These are needed because Scintilla class header files don't manage their own
  26. // dependencies properly.
  27. #include <algorithm>
  28. #include <assert.h>
  29. #include <ctype.h>
  30. #include <stdexcept>
  31. #include <stdlib.h>
  32. #include <string>
  33. #include <map>
  34. #include <vector>
  35. #include "include/ILexer.h"
  36. #include "include/Platform.h"
  37. #include "include/Scintilla.h"
  38. #include "SplitVector.h"
  39. #include "Partitioning.h"
  40. #include "CellBuffer.h"
  41. #include "CharClassify.h"
  42. #include "RunStyles.h"
  43. #include "CaseFolder.h"
  44. #include "Decoration.h"
  45. #include "Document.h"
  46. #include "Style.h"
  47. #include "XPM.h"
  48. #include "LineMarker.h"
  49. #include "Indicator.h"
  50. #include "ViewStyle.h"
  51. #include "KeyMap.h"
  52. #include "ContractionState.h"
  53. #include "Selection.h"
  54. #include "PositionCache.h"
  55. #include "EditModel.h"
  56. #include "MarginView.h"
  57. #include "EditView.h"
  58. #include "Editor.h"
  59. #include "AutoComplete.h"
  60. #include "CallTip.h"
  61. #include "LexAccessor.h"
  62. #include "Accessor.h"
  63. #include "ScintillaBase.h"
  64. QT_BEGIN_NAMESPACE
  65. class QMimeData;
  66. class QPaintEvent;
  67. QT_END_NAMESPACE
  68. class QsciScintillaBase;
  69. class QsciSciCallTip;
  70. class QsciSciPopup;
  71. // This is an internal class but it is referenced by a public class so it has
  72. // to have a Qsci prefix rather than being put in the Scintilla namespace
  73. // which would mean exposing the SCI_NAMESPACE mechanism).
  74. class QsciScintillaQt : public QObject, public QSCI_SCI_NAMESPACE(ScintillaBase)
  75. {
  76. Q_OBJECT
  77. friend class QsciScintillaBase;
  78. friend class QsciSciCallTip;
  79. friend class QsciSciPopup;
  80. public:
  81. QsciScintillaQt(QsciScintillaBase *qsb_);
  82. virtual ~QsciScintillaQt();
  83. virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam,
  84. sptr_t lParam);
  85. protected:
  86. void timerEvent(QTimerEvent *e);
  87. private slots:
  88. void onIdle();
  89. private:
  90. void Initialise();
  91. void Finalise();
  92. bool SetIdle(bool on);
  93. void StartDrag();
  94. sptr_t DefWndProc(unsigned int, uptr_t, sptr_t);
  95. void SetMouseCapture(bool on);
  96. bool HaveMouseCapture();
  97. void SetVerticalScrollPos();
  98. void SetHorizontalScrollPos();
  99. bool ModifyScrollBars(int nMax, int nPage);
  100. void ReconfigureScrollBars();
  101. void NotifyChange();
  102. void NotifyParent(SCNotification scn);
  103. void CopyToClipboard(
  104. const QSCI_SCI_NAMESPACE(SelectionText) &selectedText);
  105. void Copy();
  106. void Paste();
  107. void CreateCallTipWindow(QSCI_SCI_NAMESPACE(PRectangle) rc);
  108. void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
  109. void ClaimSelection();
  110. void UnclaimSelection();
  111. static sptr_t DirectFunction(QsciScintillaQt *sci, unsigned int iMessage,
  112. uptr_t wParam,sptr_t lParam);
  113. QMimeData *mimeSelection(
  114. const QSCI_SCI_NAMESPACE(SelectionText) &text) const;
  115. void paintEvent(QPaintEvent *e);
  116. void pasteFromClipboard(QClipboard::Mode mode);
  117. // tickPlatform is the last of the TickReason members.
  118. int timers[tickPlatform + 1];
  119. bool FineTickerAvailable();
  120. void FineTickerCancel(TickReason reason);
  121. bool FineTickerRunning(TickReason reason);
  122. void FineTickerStart(TickReason reason, int ms, int tolerance);
  123. int vMax, hMax, vPage, hPage;
  124. bool capturedMouse;
  125. QsciScintillaBase *qsb;
  126. };
  127. #endif