AbaKus – a complex calculator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.3KB

  1. /* This file was part of the SpeedCrunch project
  2. Copyright (C) 2004,2005 Ariya Hidayat <ariya@kde.org>
  3. And is now part of abakus.
  4. Copyright (c) 2005 Michael Pyne <michael.pyne@kdemail.net>
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef ABAKUS_EDITOR_H
  18. #define ABAKUS_EDITOR_H
  19. #include <tqobject.h>
  20. #include <tqstringlist.h>
  21. #include <tqtextedit.h>
  22. #include "hmath.h"
  23. class TQEvent;
  24. class TQKeyEvent;
  25. class TQWidget;
  26. class Evaluator;
  27. class Editor : public TQTextEdit
  28. {
  29. Q_OBJECT
  30. TQ_OBJECT
  31. public:
  32. typedef enum
  33. {
  34. Number, FunctionName, Variable, MatchedPar
  35. } ColorType;
  36. Editor( TQWidget* parent = 0, const char* name = 0 );
  37. ~Editor();
  38. TQSize tqsizeHint() const;
  39. TQSize xtqminimumSizeHint() const;
  40. TQStringList history() const;
  41. void setHistory( const TQStringList& history );
  42. bool autoCompleteEnabled() const;
  43. void setAutoCompleteEnabled( bool enable );
  44. bool autoCalcEnabled() const;
  45. void setAutoCalcEnabled( bool enable );
  46. void setFormat( char format );
  47. void setDecimalDigits( int digits );
  48. void setSyntaxHighlight( bool enable );
  49. bool isSyntaxHighlightEnabled() const;
  50. void setHighlightColor( ColorType type, TQColor color );
  51. TQColor highlightColor( ColorType type );
  52. public slots:
  53. void appendHistory( const TQString& text );
  54. void clearHistory();
  55. // Stop the timer from going off.
  56. void squelchNextAutoCalc();
  57. void setText(const TQString &txt);
  58. protected slots:
  59. void checkAutoComplete();
  60. void triggerAutoComplete();
  61. void autoComplete( const TQString& item );
  62. void checkAutoCalc();
  63. void autoCalc();
  64. void checkMatching();
  65. void doMatchingLeft();
  66. void doMatchingRight();
  67. void historyBack();
  68. void historyForward();
  69. protected:
  70. void keyPressEvent( TQKeyEvent* );
  71. void wheelEvent( TQWheelEvent* );
  72. TQString formatNumber( const Abakus::number_t &value ) const;
  73. private:
  74. class Private;
  75. Private* d;
  76. Editor( const Editor& );
  77. Editor& operator=( const Editor& );
  78. };
  79. class EditorCompletion : public TQObject
  80. {
  81. Q_OBJECT
  82. TQ_OBJECT
  83. public:
  84. EditorCompletion( Editor* editor );
  85. ~EditorCompletion();
  86. bool eventFilter( TQObject *o, TQEvent *e );
  87. void doneCompletion();
  88. void showCompletion( const TQStringList &choices );
  89. protected slots:
  90. void moveCompletionPopup();
  91. signals:
  92. void selectedCompletion( const TQString& item );
  93. private:
  94. class Private;
  95. Private* d;
  96. EditorCompletion( const EditorCompletion& );
  97. EditorCompletion& operator=( const EditorCompletion& );
  98. };
  99. #endif // ABAKUS_EDITOR_H
  100. // vim: set et ts=8 sw=4: