KOffice – TDE office suite
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.

119 lines
3.0KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
  3. Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. * Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef KFORMULAWIDGET_H
  18. #define KFORMULAWIDGET_H
  19. #include <tqdom.h>
  20. #include <tqpixmap.h>
  21. #include <tqpoint.h>
  22. #include <tqwidget.h>
  23. #include <kformuladefs.h>
  24. #include <kformulaview.h>
  25. KFORMULA_NAMESPACE_BEGIN
  26. class FormulaCursor;
  27. class Container;
  28. KFORMULA_NAMESPACE_END
  29. /**
  30. * The view. A widget that shows the formula. There are methods
  31. * to move the cursor around. To edit the formula use the document.
  32. */
  33. class KFormulaWidget : public TQWidget {
  34. Q_OBJECT
  35. public:
  36. KFormulaWidget(KFormula::Container*, TQWidget* parent=0, const char* name=0, WFlags f=0);
  37. ~KFormulaWidget();
  38. /**
  39. * @returns the point inside the formula widget where the cursor is.
  40. */
  41. TQPoint getCursorPoint() const;
  42. /**
  43. * Puts the widget in read only mode.
  44. */
  45. void setReadOnly(bool ro);
  46. const KFormula::View* view() const { return &formulaView; }
  47. KFormula::View* view() { return &formulaView; }
  48. public slots:
  49. void slotSelectAll();
  50. signals:
  51. /**
  52. * Is emitted every time the cursor might have changed.
  53. */
  54. void cursorChanged(bool visible, bool selecting);
  55. protected slots:
  56. /**
  57. * The formula has changed and needs to be redrawn.
  58. */
  59. void slotFormulaChanged(int width, int height);
  60. void slotCursorChanged(bool visible, bool selecting);
  61. protected:
  62. virtual void mousePressEvent(TQMouseEvent* event);
  63. virtual void mouseReleaseEvent(TQMouseEvent* event);
  64. virtual void mouseDoubleClickEvent(TQMouseEvent* event);
  65. virtual void mouseMoveEvent(TQMouseEvent* event);
  66. virtual void paintEvent(TQPaintEvent* event);
  67. virtual void keyPressEvent(TQKeyEvent* event);
  68. virtual void focusInEvent(TQFocusEvent* event);
  69. virtual void focusOutEvent(TQFocusEvent* event);
  70. /**
  71. * The document we show.
  72. */
  73. KFormula::Container* getDocument();
  74. /**
  75. * Our cursor.
  76. */
  77. KFormula::FormulaCursor* getCursor();
  78. private:
  79. /**
  80. * This widget is a wrapper around the actual view.
  81. */
  82. KFormula::View formulaView;
  83. TQPixmap buffer;
  84. };
  85. #endif // KFORMULAWIDGET_H