| 1 | /* |
| 2 | * File: MainPanel.h |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This object presents the main panel |
| 11 | * |
| 12 | * This program is free software: you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation, either version 3 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef MAINPANEL_H_ |
| 28 | #define MAINPANEL_H_ |
| 29 | |
| 30 | #include "StatusUpdateCollector.h" |
| 31 | #include "Mips.h" |
| 32 | |
| 33 | #include <QtWidgets/QWidget> |
| 34 | #include <QLabel> |
| 35 | #include <QPushButton> |
| 36 | #include <QToolButton> |
| 37 | #include <QLCDNumber> |
| 38 | #include "ui_Devices.h" |
| 39 | |
| 40 | class MainPanel; |
| 41 | // base class for "clickable" objects |
| 42 | class ClickLabel : public QLabel |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | public: |
| 46 | ClickLabel(MainPanel *parent, QObject * lcd); |
| 47 | virtual void mousePressEvent(QMouseEvent * event ); |
| 48 | signals: |
| 49 | void clicked(const QPoint &); |
| 50 | private: |
| 51 | MainPanel * mPanel; |
| 52 | QObject * mLcd; |
| 53 | |
| 54 | }; |
| 55 | |
| 56 | class MainPanel : public QWidget, public StatusUpdateCollector |
| 57 | { |
| 58 | Q_OBJECT |
| 59 | |
| 60 | public: |
| 61 | MainPanel(QWidget *parent = 0); |
| 62 | virtual ~MainPanel(); |
| 63 | virtual void doConnect(); |
| 64 | |
| 65 | virtual void standby()=0; |
| 66 | virtual void setDormant()=0; |
| 67 | virtual bool notify(const QByteArray& statusLine)=0; |
| 68 | virtual void switchMips()=0; |
| 69 | virtual int getLoadAddress(); |
| 70 | virtual void setLoadAddress(const char * devNo); |
| 71 | virtual bool isStopped()const = 0; |
| 72 | virtual void updateLcd(QLCDNumber * lcd, int inc)=0; |
| 73 | virtual void animate() = 0; |
| 74 | |
| 75 | signals: |
| 76 | void powerOnClicked(); |
| 77 | void powerOffClicked(); |
| 78 | void loadClicked(); |
| 79 | void interruptClicked(); |
| 80 | void restartClicked(); |
| 81 | void storeClicked(); |
| 82 | void startClicked(); |
| 83 | void stopClicked(); |
| 84 | |
| 85 | protected: |
| 86 | virtual void resizeEvent(QResizeEvent * event)=0; |
| 87 | virtual QSize sizeHint() const=0; |
| 88 | virtual QAbstractButton* powerOnButton() {return mPowerOnButton;}; |
| 89 | virtual QAbstractButton* powerOffButton() {return mPowerOffButton;}; |
| 90 | virtual QAbstractButton* interruptButton() {return mInterruptButton;}; |
| 91 | virtual QAbstractButton* stopButton() {return mStopButton;}; |
| 92 | virtual QAbstractButton* loadButton() {return mLoadButton;}; |
| 93 | |
| 94 | bool mStopped; |
| 95 | double mMipsHWM; |
| 96 | QPushButton *mPowerOnButton; |
| 97 | QPushButton *mPowerOffButton; |
| 98 | QPushButton *mInterruptButton; |
| 99 | QPushButton *mLoadButton; |
| 100 | QPushButton *mRestartButton; |
| 101 | QPushButton *mStoreButton; |
| 102 | QPushButton *mStopButton; |
| 103 | QPushButton *mStartButton; |
| 104 | |
| 105 | QPixmap *mYellowLow; |
| 106 | QPixmap *mYellowHigh; |
| 107 | QLCDNumber *mLcd0, *mLcd1, *mLcd2, *mLcd3; |
| 108 | |
| 109 | public slots: |
| 110 | void powerOnClickedSlot(); |
| 111 | void powerOffClickedSlot(); |
| 112 | void loadClickedSlot(); |
| 113 | void interruptClickedSlot(); |
| 114 | void restartClickedSlot(); |
| 115 | void storeClickedSlot(); |
| 116 | void startClickedSlot(); |
| 117 | void stopClickedSlot(); |
| 118 | }; |
| 119 | |
| 120 | #endif /* MAINPANEL_H_ */ |