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.

137 lines
3.5KB

  1. #ifndef ABAKUS_MAINWINDOW_H
  2. #define ABAKUS_MAINWINDOW_H
  3. /*
  4. * mainwindow.h - part of abakus
  5. * Copyright (C) 2004, 2005 Michael Pyne <michael.pyne@kdemail.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <kmainwindow.h>
  22. #include "numerictypes.h"
  23. class TQPoint;
  24. class TQVBox;
  25. class TQCheckBox;
  26. class TQRadioButton;
  27. class TQBoxLayout;
  28. class TQListViewItem;
  29. class TQSplitter;
  30. class TQTimer;
  31. //class KComboBox;
  32. class Editor;
  33. class TDEPopupMenu;
  34. class TDEAction;
  35. class TDEListView;
  36. class ResultListView;
  37. class ResultListViewText;
  38. class AbakusIface;
  39. // Main window class, handles events and layout and stuff
  40. class MainWindow : public TDEMainWindow
  41. {
  42. Q_OBJECT
  43. public:
  44. MainWindow();
  45. bool inRPNMode() const;
  46. protected:
  47. virtual void contextMenuEvent(TQContextMenuEvent *e);
  48. virtual bool eventFilter(TQObject *o, TQEvent *e);
  49. virtual bool queryExit();
  50. virtual void polish();
  51. private slots:
  52. void slotReturnPressed();
  53. void slotTextChanged();
  54. void slotEvaluate();
  55. void slotPrecisionAuto();
  56. void slotPrecision3();
  57. void slotPrecision8();
  58. void slotPrecision15();
  59. void slotPrecision50();
  60. void slotPrecisionCustom();
  61. void slotUpdateSize();
  62. void slotDegrees();
  63. void slotRadians();
  64. void slotEntrySelected(const TQString &text);
  65. void slotResultSelected(const TQString &text);
  66. void slotToggleMenuBar();
  67. void slotToggleFunctionList();
  68. void slotToggleVariableList();
  69. void slotToggleHistoryList();
  70. void slotToggleCompactMode();
  71. void slotToggleExpressionMode();
  72. void slotNewValue(const TQString &name, Abakus::number_t value);
  73. void slotChangeValue(const TQString &name, Abakus::number_t value);
  74. void slotRemoveValue(const TQString &name);
  75. void slotNewFunction(const TQString &name);
  76. void slotRemoveFunction(const TQString &name);
  77. private:
  78. int getParenthesesLevel(const TQString &str);
  79. void redrawResults();
  80. void selectCorrectPrecisionAction();
  81. void loadConfig();
  82. void saveConfig();
  83. void setupLayout();
  84. void populateListViews();
  85. TQString interpolateExpression(const TQString &text, ResultListViewText *after);
  86. // Donated via JuK
  87. TDEAction *action(const char *key) const;
  88. template <class T> T *action(const char *key) const
  89. {
  90. return dynamic_cast<T *>(action(key));
  91. }
  92. private:
  93. TQVBox *m_history;
  94. TQRadioButton *m_degrees;
  95. TQRadioButton *m_radians;
  96. Editor *m_edit;
  97. TDEPopupMenu *m_popup;
  98. ResultListView *m_result;
  99. TQString m_lastError;
  100. TQBoxLayout *m_layout;
  101. TDEListView *m_fnList, *m_varList;
  102. TQSplitter *m_mainSplitter, *m_listSplitter;
  103. TQSize m_newSize, m_oldSize;
  104. AbakusIface *m_dcopInterface;
  105. bool m_wasFnShown, m_wasVarShown, m_wasHistoryShown;
  106. bool m_compactMode;
  107. bool m_insert;
  108. };
  109. #endif