SciClasses.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // The definition of various Qt version independent classes used by the rest of
  2. // the port.
  3. //
  4. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  5. //
  6. // This file is part of QScintilla.
  7. //
  8. // This file may be used under the terms of the GNU General Public License
  9. // version 3.0 as published by the Free Software Foundation and appearing in
  10. // the file LICENSE included in the packaging of this file. Please review the
  11. // following information to ensure the GNU General Public License version 3.0
  12. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  13. //
  14. // If you do not wish to use this file under the terms of the GPL version 3.0
  15. // then you may purchase a commercial license. For more information contact
  16. // info@riverbankcomputing.com.
  17. //
  18. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  19. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. #ifndef _SCICLASSES_H
  21. #define _SCICLASSES_H
  22. #include <QListWidget>
  23. #include <QMenu>
  24. #include <QSignalMapper>
  25. #include <QWidget>
  26. #include <Qsci/qsciglobal.h>
  27. class QsciScintillaQt;
  28. class QsciListBoxQt;
  29. // A simple QWidget sub-class to implement a call tip. This is not put into
  30. // the Scintilla namespace because of moc's problems with preprocessor macros.
  31. class QsciSciCallTip : public QWidget
  32. {
  33. Q_OBJECT
  34. public:
  35. QsciSciCallTip(QWidget *parent, QsciScintillaQt *sci_);
  36. ~QsciSciCallTip();
  37. protected:
  38. void paintEvent(QPaintEvent *e);
  39. void mousePressEvent(QMouseEvent *e);
  40. private:
  41. QsciScintillaQt *sci;
  42. };
  43. // A popup menu where options correspond to a numeric command. This is not put
  44. // into the Scintilla namespace because of moc's problems with preprocessor
  45. // macros.
  46. class QsciSciPopup : public QMenu
  47. {
  48. Q_OBJECT
  49. public:
  50. QsciSciPopup();
  51. void addItem(const QString &label, int cmd, bool enabled,
  52. QsciScintillaQt *sci_);
  53. private slots:
  54. void on_triggered(int cmd);
  55. private:
  56. QsciScintillaQt *sci;
  57. QSignalMapper mapper;
  58. };
  59. // This sub-class of QListBox is needed to provide slots from which we can call
  60. // QsciListBox's double-click callback (and you thought this was a C++
  61. // program). This is not put into the Scintilla namespace because of moc's
  62. // problems with preprocessor macros.
  63. class QsciSciListBox : public QListWidget
  64. {
  65. Q_OBJECT
  66. public:
  67. QsciSciListBox(QWidget *parent, QsciListBoxQt *lbx_);
  68. virtual ~QsciSciListBox();
  69. void addItemPixmap(const QPixmap &pm, const QString &txt);
  70. int find(const QString &prefix);
  71. QString text(int n);
  72. protected:
  73. void keyPressEvent(QKeyEvent *e);
  74. private slots:
  75. void handleSelection();
  76. private:
  77. QsciListBoxQt *lbx;
  78. };
  79. #endif