Compilation fix
[opentx.git] / companion / src / simulation / simulateduiwidget.h
blob225fb65feb365e69a64efe5d5663a4604ca220c6
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef SIMULATEDUIWIDGET_H
22 #define SIMULATEDUIWIDGET_H
24 #include "boards.h"
25 #include "constants.h"
26 #include "radiowidget.h"
27 #include "simulator.h"
28 #include "simulator_strings.h"
30 #include <QWidget>
31 #include <QMouseEvent>
33 class SimulatorInterface;
34 class LcdWidget;
35 class RadioKeyWidget;
36 class RadioUiAction;
39 * This is a base class for the main hardware-specific radio user interface, including LCD screen and navigation buttons/widgets.
40 * It is responsible for hanlding all interactions with this part of the simulation (vs. common radio widgets like sticks/switches/knobs).
41 * Sub-classes are responsible for building the actual UI form they need for presentation.
42 * This base class should not be instantiated directly.
44 class SimulatedUIWidget : public QWidget
46 Q_OBJECT
48 protected:
50 explicit SimulatedUIWidget(SimulatorInterface * simulator, QWidget * parent = NULL);
52 public:
54 ~SimulatedUIWidget();
56 RadioWidget * addRadioWidget(RadioWidget * keyWidget);
57 RadioUiAction * addRadioAction(RadioUiAction * act);
59 QVector<Simulator::keymapHelp_t> getKeymapHelp() const;
61 static QPolygon polyArc(int ctrX, int ctrY, int radius, int startAngle = 0, int endAngle = 360, int step = 10);
63 public slots:
65 void captureScreenshot();
67 void wheelEvent(QWheelEvent *event);
68 void mousePressEvent(QMouseEvent *event);
69 void mouseReleaseEvent(QMouseEvent *event);
71 signals:
73 void controlValueChange(RadioWidget::RadioWidgetType type, int index, int value);
74 void customStyleRequest(const QString & style);
75 void simulatorWheelEvent(qint8 steps);
77 protected slots:
79 void setLcd(LcdWidget * lcd);
80 void connectScrollActions();
81 void onLcdChange(bool backlightEnable);
82 virtual void setLightOn(bool enable) { }
84 protected:
86 SimulatorInterface * m_simulator;
87 QWidget * m_parent;
88 LcdWidget * m_lcd;
89 QVector<QColor> m_backlightColors;
90 QList<RadioUiAction *> m_actions;
91 QList<RadioWidget *> m_widgets;
92 RadioUiAction * m_scrollUpAction;
93 RadioUiAction * m_scrollDnAction;
94 RadioUiAction * m_mouseMidClickAction;
95 RadioUiAction * m_screenshotAction;
96 Board::Type m_board;
97 unsigned int m_backLight;
98 int m_beepShow;
99 int m_beepVal;
104 // Each subclass is responsible for its own Ui
105 namespace Ui {
106 class SimulatedUIWidget9X;
107 class SimulatedUIWidgetX7;
108 class SimulatedUIWidgetX9;
109 class SimulatedUIWidgetX9E;
110 class SimulatedUIWidgetX12;
113 class SimulatedUIWidget9X: public SimulatedUIWidget
115 Q_OBJECT
117 public:
118 explicit SimulatedUIWidget9X(SimulatorInterface * simulator, QWidget * parent = NULL);
119 virtual ~SimulatedUIWidget9X();
121 protected:
122 void setLightOn(bool enable);
124 private:
125 Ui::SimulatedUIWidget9X * ui;
129 class SimulatedUIWidgetX7: public SimulatedUIWidget
131 Q_OBJECT
133 public:
134 explicit SimulatedUIWidgetX7(SimulatorInterface * simulator, QWidget * parent = NULL);
135 virtual ~SimulatedUIWidgetX7();
137 private:
138 Ui::SimulatedUIWidgetX7 * ui;
141 class SimulatedUIWidgetX9: public SimulatedUIWidget
143 Q_OBJECT
145 public:
146 explicit SimulatedUIWidgetX9(SimulatorInterface * simulator, QWidget * parent = NULL);
147 virtual ~SimulatedUIWidgetX9();
149 private:
150 Ui::SimulatedUIWidgetX9 * ui;
153 class SimulatedUIWidgetX9E: public SimulatedUIWidget
155 Q_OBJECT
157 public:
158 explicit SimulatedUIWidgetX9E(SimulatorInterface * simulator, QWidget * parent = NULL);
159 virtual ~SimulatedUIWidgetX9E();
161 private:
162 Ui::SimulatedUIWidgetX9E * ui;
165 class SimulatedUIWidgetX12: public SimulatedUIWidget
167 Q_OBJECT
169 public:
170 explicit SimulatedUIWidgetX12(SimulatorInterface * simulator, QWidget * parent = NULL);
171 virtual ~SimulatedUIWidgetX12();
173 private:
174 Ui::SimulatedUIWidgetX12 * ui;
177 #endif // SIMULATEDUIWIDGET_H