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. public:
  31. typedef enum
  32. {
  33. Number, FunctionName, Variable, MatchedPar
  34. } ColorType;
  35. Editor( TQWidget* parent = 0, const char* name = 0 );
  36. ~Editor();
  37. TQSize sizeHint() const;
  38. TQSize xminimumSizeHint() const;
  39. TQStringList history() const;
  40. void setHistory( const TQStringList& history );
  41. bool autoCompleteEnabled() const;
  42. void setAutoCompleteEnabled( bool enable );
  43. bool autoCalcEnabled() const;
  44. void setAutoCalcEnabled( bool enable );
  45. void setFormat( char format );
  46. void setDecimalDigits( int digits );
  47. void setSyntaxHighlight( bool enable );
  48. bool isSyntaxHighlightEnabled() const;
  49. void setHighlightColor( ColorType type, TQColor color );
  50. TQColor highlightColor( ColorType type );
  51. public slots:
  52. void appendHistory( const TQString& text );
  53. void clearHistory();
  54. // Stop the timer from going off.
  55. void squelchNextAutoCalc();
  56. void setText(const TQString &txt);
  57. protected slots:
  58. void checkAutoComplete();
  59. void triggerAutoComplete();
  60. void autoComplete( const TQString& item );
  61. void checkAutoCalc();
  62. void autoCalc();
  63. void checkMatching();
  64. void doMatchingLeft();
  65. void doMatchingRight();
  66. void historyBack();
  67. void historyForward();
  68. protected:
  69. void keyPressEvent( TQKeyEvent* );
  70. void wheelEvent( TQWheelEvent* );
  71. TQString formatNumber( const Abakus::number_t &value ) const;
  72. private:
  73. class Private;
  74. Private* d;
  75. Editor( const Editor& );
  76. Editor& operator=( const Editor& );
  77. };
  78. class EditorCompletion : public TQObject
  79. {
  80. Q_OBJECT
  81. public:
  82. EditorCompletion( Editor* editor );
  83. ~EditorCompletion();
  84. bool eventFilter( TQObject *o, TQEvent *e );
  85. void doneCompletion();
  86. void showCompletion( const TQStringList &choices );
  87. protected slots:
  88. void moveCompletionPopup();
  89. signals:
  90. void selectedCompletion( const TQString& item );
  91. private:
  92. class Private;
  93. Private* d;
  94. EditorCompletion( const EditorCompletion& );
  95. EditorCompletion& operator=( const EditorCompletion& );
  96. };
  97. #endif // ABAKUS_EDITOR_H
  98. // vim: set et ts=8 sw=4: