diff options
54 files changed, 0 insertions, 5918 deletions
diff --git a/utils/wpseditor/README b/utils/wpseditor/README deleted file mode 100644 index ebdfd7a5a3..0000000000 --- a/utils/wpseditor/README +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | __________ __ ___. | ||
2 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | \/ \/ \/ \/ \/ | ||
7 | |||
8 | /----------------------------------------------------------------\ | ||
9 | | Installation | | ||
10 | \----------------------------------------------------------------/ | ||
11 | |||
12 | To make a release version, change the value CONFIG in gui.pro and QPropertyEditor.pro from "debug" to "release". | ||
13 | |||
14 | |||
15 | /----------------------------------------------------------------\ | ||
16 | | Windows | | ||
17 | \----------------------------------------------------------------/ | ||
18 | |||
19 | * make sure that you have properly installed MingW, Qt > 4.3.* and bin directories are set properly | ||
20 | * if you want to debug wpseditor, you'll have to build Qt debug libraries | ||
21 | * if you don't have qmake in your PATH environment, use the Qt command prompt | ||
22 | * run 'qmake && make' in utils\wpseditor\ | ||
23 | * the binary is then in utils\wpseditor\gui\bin\wpseditor.exe | ||
24 | |||
25 | /----------------------------------------------------------------\ | ||
26 | | Linux | | ||
27 | \----------------------------------------------------------------/ | ||
28 | |||
29 | * make sure you have libqt4-dev installed and you have a working Rockbox environment | ||
30 | * cd to utils/wpseditor/ and run 'qmake-qt4 && make' | ||
31 | * cd to gui/bin/ and start WPS editor with './wpseditord' | ||
diff --git a/utils/wpseditor/TODO b/utils/wpseditor/TODO deleted file mode 100644 index a42230bff4..0000000000 --- a/utils/wpseditor/TODO +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | * Make better logging system | ||
2 | * Replace checkwps functionality | ||
3 | * Include 'screenshot utility' functionality | ||
4 | * Options | ||
5 | * Enable animation (timers, sliding lines, etc) | ||
6 | * Test on Mac OS | ||
7 | * Redesign GUI for more usability | ||
8 | * Make editing via gui | ||
9 | * Use native rockbox fonts | ||
10 | * Replace shared libs as Qt Plugins | ||
11 | * Edit wiki :-) | ||
12 | |||
13 | Partially solved | ||
14 | * Enable ability in gui to load different targets on the fly [Not all targets are built yet] | ||
15 | * Syntax highlight [Comments are done; enable for logEdit; tag highlight] | ||
16 | |||
17 | THE BUGZ ARE COMING! | ||
18 | * While loading wps for the first time, gui doesn't show properties from editor properly | ||
19 | * Strange text horizontal position in cabbiev2 (probably other themes too) | ||
diff --git a/utils/wpseditor/gui/gui.pro b/utils/wpseditor/gui/gui.pro deleted file mode 100644 index 088ab04119..0000000000 --- a/utils/wpseditor/gui/gui.pro +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | TEMPLATE = app | ||
2 | TARGET = | ||
3 | DEPENDPATH += . build src ui | ||
4 | INCLUDEPATH += . src src/QPropertyEditor ../libwps/src | ||
5 | DESTDIR = bin | ||
6 | OBJECTS_DIR = build | ||
7 | MOC_DIR = build | ||
8 | UI_DIR = build | ||
9 | QMAKE_LIBDIR += lib | ||
10 | QT = gui core | ||
11 | CONFIG += qt warn_on debug | ||
12 | HEADERS += ../libwps/src/api.h \ | ||
13 | ../libwps/src/defs.h \ | ||
14 | src/slider.h \ | ||
15 | src/qtrackstate.h \ | ||
16 | src/qwpsstate.h \ | ||
17 | src/qwpseditorwindow.h \ | ||
18 | src/utils.h \ | ||
19 | src/qwpsdrawer.h \ | ||
20 | src/qsyntaxer.h \ | ||
21 | src/numberedtextview.h | ||
22 | |||
23 | FORMS += ui/mainwindow.ui ui/slider.ui | ||
24 | SOURCES += src/main.cpp \ | ||
25 | src/slider.cpp \ | ||
26 | src/qtrackstate.cpp \ | ||
27 | src/qwpsstate.cpp \ | ||
28 | src/qwpseditorwindow.cpp \ | ||
29 | src/utils.cpp \ | ||
30 | src/qwpsdrawer.cpp \ | ||
31 | src/qwpsdrawer_static.cpp \ | ||
32 | src/qsyntaxer.cpp \ | ||
33 | src/numberedtextview.cpp | ||
34 | |||
35 | LIBS += -Lbin | ||
36 | CONFIG(debug, debug|release) { | ||
37 | LIBS += -lQPropertyEditord | ||
38 | TARGET = wpseditord | ||
39 | CONFIG += console | ||
40 | } | ||
41 | CONFIG(release, debug|release) { | ||
42 | LIBS += -lQPropertyEditor | ||
43 | TARGET = wpseditor | ||
44 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp deleted file mode 100644 index f5eeb030dc..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // | ||
24 | // This class is based on the Color Editor Factory Example by Trolltech | ||
25 | // | ||
26 | // ************************************************************************************************* | ||
27 | |||
28 | #include "ColorCombo.h" | ||
29 | |||
30 | #include <Qt/qcolordialog.h> | ||
31 | |||
32 | ColorCombo::ColorCombo(QWidget* parent /*= 0*/) : QComboBox(parent) { | ||
33 | QStringList colorNames = QColor::colorNames(); | ||
34 | for (int i = 0; i < colorNames.size(); ++i) { | ||
35 | QColor color(colorNames[i]); | ||
36 | insertItem(i, colorNames[i]); | ||
37 | setItemData(i, color, Qt::DecorationRole); | ||
38 | } | ||
39 | addItem(tr("Custom"), QVariant((int)QVariant::UserType)); | ||
40 | connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(currentChanged(int))); | ||
41 | } | ||
42 | |||
43 | |||
44 | ColorCombo::~ColorCombo() {} | ||
45 | |||
46 | |||
47 | QColor ColorCombo::color() const { | ||
48 | return qVariantValue<QColor>(itemData(currentIndex(), Qt::DecorationRole)); | ||
49 | } | ||
50 | |||
51 | void ColorCombo::setColor(QColor color) { | ||
52 | m_init = color; | ||
53 | setCurrentIndex(findData(color, int(Qt::DecorationRole))); | ||
54 | if (currentIndex() == -1) { | ||
55 | addItem(color.name()); | ||
56 | setItemData(count()-1, color, Qt::DecorationRole); | ||
57 | setCurrentIndex(count()-1); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | void ColorCombo::currentChanged(int index) { | ||
62 | if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { | ||
63 | QColor color = QColorDialog::getColor(m_init, this); | ||
64 | if (color.isValid()) { | ||
65 | if (findData(color, int(Qt::DecorationRole)) == -1) { | ||
66 | addItem(color.name()); | ||
67 | setItemData(count()-1, color, Qt::DecorationRole); | ||
68 | } | ||
69 | setCurrentIndex(findData(color, int(Qt::DecorationRole))); | ||
70 | } else | ||
71 | setCurrentIndex(findData(m_init)); | ||
72 | } | ||
73 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h deleted file mode 100644 index 530b05bbc5..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // | ||
24 | // This class is based on the Color Editor Factory Example by Trolltech | ||
25 | // | ||
26 | // ************************************************************************************************* | ||
27 | |||
28 | #ifndef COLORCOMBO_H_ | ||
29 | #define COLORCOMBO_H_ | ||
30 | |||
31 | #include <Qt/qcombobox.h> | ||
32 | |||
33 | class ColorCombo : public QComboBox { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | ColorCombo(QWidget* parent = 0); | ||
37 | virtual ~ColorCombo(); | ||
38 | |||
39 | QColor color() const; | ||
40 | void setColor(QColor c); | ||
41 | |||
42 | private slots: | ||
43 | void currentChanged(int index); | ||
44 | |||
45 | private: | ||
46 | QColor m_init; | ||
47 | |||
48 | }; | ||
49 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp b/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp deleted file mode 100644 index 0746d15140..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | // **************************************************************************************** | ||
2 | // | ||
3 | // QPropertyEditor Library | ||
4 | // -------------------------------------- | ||
5 | // Copyright (C) 2007 Volker Wiendl | ||
6 | // | ||
7 | // This file is part of the Horde3D Scene Editor. | ||
8 | // | ||
9 | // The QPropertyEditor Library is free software; you can redistribute it and/or modify | ||
10 | // it under the terms of the GNU General Public License as published by | ||
11 | // the Free Software Foundation version 3 of the License | ||
12 | // | ||
13 | // The Horde3D Scene Editor is distributed in the hope that it will be useful, | ||
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | // GNU General Public License for more details. | ||
17 | // | ||
18 | // You should have received a copy of the GNU General Public License | ||
19 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | // | ||
21 | // **************************************************************************************** | ||
22 | |||
23 | #include "Property.h" | ||
24 | #include "ColorCombo.h" | ||
25 | |||
26 | #include <Qt/qmetaobject.h> | ||
27 | #include <Qt/qspinbox.h> | ||
28 | |||
29 | #include <limits.h> | ||
30 | |||
31 | Property::Property(const QString& name /*= QString()*/, QObject* propertyObject /*= 0*/, QObject* parent /*= 0*/) : QObject(parent), | ||
32 | m_propertyObject(propertyObject) { | ||
33 | setObjectName(name); | ||
34 | } | ||
35 | |||
36 | QVariant Property::value(int /*role = Qt::UserRole*/) const { | ||
37 | if (m_propertyObject) | ||
38 | return m_propertyObject->property(qPrintable(objectName())); | ||
39 | else | ||
40 | return QVariant(); | ||
41 | } | ||
42 | |||
43 | void Property::setValue(const QVariant &value) { | ||
44 | if (m_propertyObject) | ||
45 | m_propertyObject->setProperty(qPrintable(objectName()), value); | ||
46 | } | ||
47 | |||
48 | bool Property::isReadOnly() { | ||
49 | if (m_propertyObject && m_propertyObject->metaObject()->property(m_propertyObject->metaObject()->indexOfProperty(qPrintable(objectName()))).isWritable()) | ||
50 | return false; | ||
51 | else | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | QWidget* Property::createEditor(QWidget *parent, const QStyleOptionViewItem &option) { | ||
56 | (void)option; | ||
57 | QWidget* editor = 0; | ||
58 | switch (value().type()) { | ||
59 | case QVariant::Color: | ||
60 | editor = new ColorCombo(parent); | ||
61 | break; | ||
62 | case QVariant::Int: | ||
63 | editor = new QSpinBox(parent); | ||
64 | editor->setProperty("minimum", -INT_MAX); | ||
65 | editor->setProperty("maximum", INT_MAX); | ||
66 | connect(editor, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); | ||
67 | break; | ||
68 | case QMetaType::Float: | ||
69 | case QVariant::Double: | ||
70 | editor = new QDoubleSpinBox(parent); | ||
71 | editor->setProperty("minimum", -INT_MAX); | ||
72 | editor->setProperty("maximum", INT_MAX); | ||
73 | connect(editor, SIGNAL(valueChanged(double)), this, SLOT(setValue(double))); | ||
74 | break; | ||
75 | default: | ||
76 | return editor; | ||
77 | } | ||
78 | return editor; | ||
79 | } | ||
80 | |||
81 | bool Property::setEditorData(QWidget *editor, const QVariant &data) { | ||
82 | switch (value().type()) { | ||
83 | case QVariant::Color: | ||
84 | static_cast<ColorCombo*>(editor)->setColor(data.value<QColor>()); | ||
85 | return true; | ||
86 | ; | ||
87 | case QVariant::Int: | ||
88 | editor->blockSignals(true); | ||
89 | static_cast<QSpinBox*>(editor)->setValue(data.toInt()); | ||
90 | editor->blockSignals(false); | ||
91 | return true; | ||
92 | case QMetaType::Float: | ||
93 | case QVariant::Double: | ||
94 | editor->blockSignals(true); | ||
95 | static_cast<QDoubleSpinBox*>(editor)->setValue(data.toDouble()); | ||
96 | editor->blockSignals(false); | ||
97 | return true; | ||
98 | default: | ||
99 | return false; | ||
100 | } | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | QVariant Property::editorData(QWidget *editor) { | ||
105 | switch (value().type()) { | ||
106 | case QVariant::Color: | ||
107 | return QVariant::fromValue(static_cast<ColorCombo*>(editor)->color()); | ||
108 | case QVariant::Int: | ||
109 | return QVariant(static_cast<QSpinBox*>(editor)->value()); | ||
110 | case QMetaType::Float: | ||
111 | case QVariant::Double: | ||
112 | return QVariant(static_cast<QDoubleSpinBox*>(editor)->value()); | ||
113 | break; | ||
114 | default: | ||
115 | return QVariant(); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | Property* Property::findPropertyObject(QObject* propertyObject) { | ||
120 | if (m_propertyObject == propertyObject) | ||
121 | return this; | ||
122 | for (int i=0; i<children().size(); ++i) { | ||
123 | Property* child = static_cast<Property*>(children()[i])->findPropertyObject(propertyObject); | ||
124 | if (child) | ||
125 | return child; | ||
126 | } | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | void Property::setValue(double value) { | ||
131 | setValue(QVariant(value)); | ||
132 | } | ||
133 | |||
134 | void Property::setValue(int value) { | ||
135 | setValue(QVariant(value)); | ||
136 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/Property.h b/utils/wpseditor/gui/src/QPropertyEditor/Property.h deleted file mode 100644 index 52d6842987..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/Property.h +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef PROPERTY_H_ | ||
26 | #define PROPERTY_H_ | ||
27 | |||
28 | #include <Qt/qwidget.h> | ||
29 | #include <Qt/qstyleoption.h> | ||
30 | #include <Qt/qvariant.h> | ||
31 | |||
32 | /** | ||
33 | * The Property class is the base class for all properties in the QPropertyEditor | ||
34 | * You can implement custom properties inherited from this class to further enhence the | ||
35 | * functionality of the QPropertyEditor | ||
36 | */ | ||
37 | class Property : public QObject { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | |||
42 | /** | ||
43 | * Constructor | ||
44 | * | ||
45 | * @param name the name of the property within the propertyObject (will be used in the QPropertyEditorWidget view too) | ||
46 | * @param propertyObject the object that contains the property | ||
47 | * @param parent optional parent object | ||
48 | */ | ||
49 | Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0); | ||
50 | |||
51 | /** | ||
52 | * The value stored by this property | ||
53 | * @return QVariant the data converted to a QVariant | ||
54 | */ | ||
55 | virtual QVariant value(int role = Qt::UserRole) const; | ||
56 | /** | ||
57 | * Sets the value stored by this property | ||
58 | * @param value the data converted to a QVariant | ||
59 | */ | ||
60 | virtual void setValue(const QVariant& value); | ||
61 | |||
62 | /** | ||
63 | * Returns the QObject which contains the property managed by this instance | ||
64 | * @return QObject* pointer to the QObject that contains user defined properties | ||
65 | */ | ||
66 | QObject* propertyObject() { | ||
67 | return m_propertyObject; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Flag if property is used for indicating a group or really manages a property | ||
72 | * @return bool true if this property is only used to display a category in the QPropertyEditorWidget | ||
73 | */ | ||
74 | bool isRoot() { | ||
75 | return m_propertyObject == 0; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * Flag if the property can be set | ||
80 | * @return bool true if this property has no set method | ||
81 | */ | ||
82 | bool isReadOnly(); | ||
83 | |||
84 | /** | ||
85 | * Returns the row of this instance within the QPropertyModel | ||
86 | * @return int row within the QPropertyModel | ||
87 | */ | ||
88 | int row() { | ||
89 | return parent()->children().indexOf(this); | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * returns optional settings for the editor widget that is used to manipulate the properties value | ||
94 | * @return QString a string that contains property settings for the editor widget (e.g. "minimum=1.0;maximum=10.0;") | ||
95 | */ | ||
96 | QString editorHints() { | ||
97 | return m_hints; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Sets properties for the editor widget that is used to manipulate the data value managed by this instance | ||
102 | * @param hints a string containing property settings for the editor widget that manipulates this property | ||
103 | */ | ||
104 | virtual void setEditorHints(const QString& hints) { | ||
105 | m_hints = hints; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * Creates an editor for the data managed by this instance | ||
110 | * @param parent widget the newly created editor widget will be child of | ||
111 | * @param option currently not used | ||
112 | * @return QWidget* pointer to the editor widget | ||
113 | */ | ||
114 | virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option); | ||
115 | |||
116 | /** | ||
117 | * Returns the data of the editor widget used to manipulate this instance | ||
118 | * @return QVariant the data converted to a QVariant | ||
119 | */ | ||
120 | virtual QVariant editorData(QWidget *editor); | ||
121 | |||
122 | /** | ||
123 | * Changes the editor widget's data to a specific value | ||
124 | * @param editor the editor widget | ||
125 | * @param data the data to set in the editor widget | ||
126 | * @return bool true if editor widget was set to the given data successfully, false if the data can not be set in the editor (e.g. wrong datatype) | ||
127 | */ | ||
128 | virtual bool setEditorData(QWidget *editor, const QVariant& data); | ||
129 | |||
130 | /** | ||
131 | * Tries to find the first property that manages the given propertyObject | ||
132 | * @param propertyObject | ||
133 | * @return Property | ||
134 | */ | ||
135 | Property* findPropertyObject(QObject* propertyObject); | ||
136 | |||
137 | private slots: | ||
138 | /** | ||
139 | * This slot is used to immediately set the properties when the editor widget's value of a double or float | ||
140 | * property has changed | ||
141 | * @param value the new value | ||
142 | */ | ||
143 | void setValue(double value); | ||
144 | /** | ||
145 | * This slot is used to immediately set the properties when the editor widget's value of an integer | ||
146 | * property has changed | ||
147 | * @param value the new value | ||
148 | */ | ||
149 | void setValue(int value); | ||
150 | |||
151 | private: | ||
152 | QObject* m_propertyObject; | ||
153 | QString m_hints; | ||
154 | |||
155 | }; | ||
156 | |||
157 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro deleted file mode 100644 index ad1e31ce9a..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += staticlib debug | ||
3 | SOURCES = ColorCombo.cpp \ | ||
4 | Property.cpp \ | ||
5 | QPropertyEditorWidget.cpp \ | ||
6 | QPropertyModel.cpp \ | ||
7 | QVariantDelegate.cpp | ||
8 | HEADERS = ColorCombo.h \ | ||
9 | Property.h \ | ||
10 | QPropertyEditorWidget.h \ | ||
11 | QPropertyModel.h \ | ||
12 | QVariantDelegate.h | ||
13 | INCLUDEPATH += . | ||
14 | DESTDIR = ../../lib | ||
15 | UI_DIR = . | ||
16 | CONFIG(debug, debug|release) { | ||
17 | TARGET = QPropertyEditord | ||
18 | OBJECTS_DIR = ../../build/QPropertyEditor/debug | ||
19 | MOC_DIR = ../../build/QPropertyEditor/debug | ||
20 | } | ||
21 | CONFIG(release, debug|release) { | ||
22 | TARGET = QPropertyEditor | ||
23 | OBJECTS_DIR = ../../build/QPropertyEditor/release | ||
24 | MOC_DIR = ../../build/QPropertyEditor/release | ||
25 | DEFINES += QT_NO_DEBUG | ||
26 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp deleted file mode 100644 index fc4b90c227..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QPropertyEditorWidget.h" | ||
26 | #include "QPropertyModel.h" | ||
27 | #include "QVariantDelegate.h" | ||
28 | #include "Property.h" | ||
29 | |||
30 | QPropertyEditorWidget::QPropertyEditorWidget(QWidget* parent /*= 0*/) : QTreeView(parent) { | ||
31 | m_model = new QPropertyModel(this); | ||
32 | setModel(m_model); | ||
33 | setItemDelegate(new QVariantDelegate(this)); | ||
34 | } | ||
35 | |||
36 | |||
37 | QPropertyEditorWidget::~QPropertyEditorWidget() {} | ||
38 | |||
39 | void QPropertyEditorWidget::addObject(QObject* propertyObject) { | ||
40 | m_model->addItem(propertyObject); | ||
41 | expandToDepth(0); | ||
42 | } | ||
43 | |||
44 | void QPropertyEditorWidget::setObject(QObject* propertyObject) { | ||
45 | m_model->clear(); | ||
46 | if (propertyObject) | ||
47 | addObject(propertyObject); | ||
48 | } | ||
49 | |||
50 | void QPropertyEditorWidget::updateObject(QObject* propertyObject) { | ||
51 | m_model->updateItem(propertyObject); | ||
52 | } | ||
53 | |||
54 | void QPropertyEditorWidget::setCustomPropertyCB(UserTypeCB callback) { | ||
55 | m_model->setCustomPropertyCB(callback); | ||
56 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h deleted file mode 100644 index 2dab87722a..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef QPROPERTYEDITORWIDGET_H_ | ||
26 | #define QPROPERTYEDITORWIDGET_H_ | ||
27 | |||
28 | #include <Qt/qtreeview.h> | ||
29 | |||
30 | class QPropertyModel; | ||
31 | class Property; | ||
32 | |||
33 | /** | ||
34 | * \mainpage QPropertyEditor | ||
35 | * | ||
36 | * \section intro_sec Introduction | ||
37 | * | ||
38 | * The main purpose for the QPropertyEditor is the visualization and manipulation of properties defined via the Q_PROPERTY macro in | ||
39 | * QObject based classes. | ||
40 | */ | ||
41 | |||
42 | /** | ||
43 | * \brief The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherited from QObject. | ||
44 | * | ||
45 | * Qt provides a nice way to define class properties by using the Q_PROPERTY macro. The purpose of the QPropertyEditor | ||
46 | * is to visualize these properties in an easy way. | ||
47 | * | ||
48 | * To use the property editor, all you have to do is to create a class that defines it's properties by using Q_PROPERTY | ||
49 | * and to add this class by using the addObject() method of this QPropertyEditorWidget class. | ||
50 | * The QPropertyEditorWidget is inherited from QTreeView and will display the properties in a tree with two columns: Name and Value | ||
51 | * | ||
52 | * For basic data types the build in editor widgets of Qt will be used. The QPropertyEditor itself only defines an additional | ||
53 | * editor for QColor (based on the Color Editor Factory Example from Trolltech). But it can easily be extended by yourself | ||
54 | * either within the library or for special datatypes also outside of the library in your application. | ||
55 | */ | ||
56 | class QPropertyEditorWidget : public QTreeView { | ||
57 | Q_OBJECT | ||
58 | public: | ||
59 | |||
60 | /** | ||
61 | * A typedef for a callback used to create user defined properties for custom datatypes | ||
62 | */ | ||
63 | typedef Property* (*UserTypeCB)(const QString& name, QObject* propertyObject, Property* parent); | ||
64 | |||
65 | /** | ||
66 | * \brief Constructor | ||
67 | * | ||
68 | * Creates a new editor widget based on QTreeView | ||
69 | * @param parent optional parent widget | ||
70 | */ | ||
71 | QPropertyEditorWidget(QWidget* parent = 0); | ||
72 | |||
73 | /// Destructor | ||
74 | virtual ~QPropertyEditorWidget(); | ||
75 | |||
76 | /** | ||
77 | * Adds the user properties of the given class to the QPropertyModel associated with this view | ||
78 | * | ||
79 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
80 | * managed by the QPropertyModel associated with this view | ||
81 | */ | ||
82 | void addObject(QObject* propertyObject); | ||
83 | |||
84 | /** | ||
85 | * Similar to the addObject() method this method adds the properties of the given class to the QPropertyModel | ||
86 | * associated with this view. But in contrast to addObject() it will clear the model before, removing all | ||
87 | * previously added objects. | ||
88 | * | ||
89 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
90 | * managed by the QPropertyModel associated with this view | ||
91 | */ | ||
92 | void setObject(QObject* propertyObject); | ||
93 | |||
94 | /** | ||
95 | * Updates the view for the given object. This can be usefull if a property was changed programmatically instead | ||
96 | * of using the view. In this case the view normally will display the new property values only after the user clicked | ||
97 | * on it. To overcome this problem you can call updateObject with the object whose property was changed. | ||
98 | */ | ||
99 | void updateObject(QObject* propertyObject); | ||
100 | |||
101 | /** | ||
102 | * If you define custom datatypes outside of this library the QPropertyModel will check if you | ||
103 | * also defined a callback that is responsible to create custom property classes inherited from Property to handle | ||
104 | * these datatypes. With this method you can set such a callback that will create custom properties for custom datatypes. | ||
105 | */ | ||
106 | void setCustomPropertyCB(UserTypeCB callback); | ||
107 | |||
108 | private: | ||
109 | /// The Model for this view | ||
110 | QPropertyModel* m_model; | ||
111 | |||
112 | }; | ||
113 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp deleted file mode 100644 index b147cd089d..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp +++ /dev/null | |||
@@ -1,236 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QPropertyModel.h" | ||
26 | |||
27 | #include "Property.h" | ||
28 | |||
29 | #include <Qt/qapplication.h> | ||
30 | #include <Qt/qmetaobject.h> | ||
31 | #include <Qt/qitemeditorfactory.h> | ||
32 | |||
33 | struct PropertyPair { | ||
34 | PropertyPair(const QMetaObject* obj, QMetaProperty property) : Property(property), Object(obj) {} | ||
35 | |||
36 | QMetaProperty Property; | ||
37 | const QMetaObject* Object; | ||
38 | |||
39 | bool operator==(const PropertyPair& other) const { | ||
40 | return QString(other.Property.name()) == QString(Property.name()); | ||
41 | } | ||
42 | }; | ||
43 | |||
44 | |||
45 | QPropertyModel::QPropertyModel(QObject* parent /*= 0*/) : QAbstractItemModel(parent), m_userCallback(0) { | ||
46 | m_rootItem = new Property("Root",0, this); | ||
47 | } | ||
48 | |||
49 | |||
50 | QPropertyModel::~QPropertyModel() {} | ||
51 | |||
52 | QModelIndex QPropertyModel::index ( int row, int column, const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
53 | Property *parentItem = m_rootItem; | ||
54 | if (parent.isValid()) | ||
55 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
56 | if (row >= parentItem->children().size()) | ||
57 | return QModelIndex(); | ||
58 | return createIndex(row, column, parentItem->children().at(row)); | ||
59 | |||
60 | } | ||
61 | |||
62 | QModelIndex QPropertyModel::parent ( const QModelIndex & index ) const { | ||
63 | if (!index.isValid()) | ||
64 | return QModelIndex(); | ||
65 | |||
66 | Property *childItem = static_cast<Property*>(index.internalPointer()); | ||
67 | Property *parentItem = qobject_cast<Property*>(childItem->parent()); | ||
68 | |||
69 | if (!parentItem || parentItem == m_rootItem) | ||
70 | return QModelIndex(); | ||
71 | |||
72 | return createIndex(parentItem->row(), 0, parentItem); | ||
73 | } | ||
74 | |||
75 | int QPropertyModel::rowCount ( const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
76 | Property *parentItem = m_rootItem; | ||
77 | if (parent.isValid()) | ||
78 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
79 | return parentItem->children().size(); | ||
80 | } | ||
81 | |||
82 | int QPropertyModel::columnCount ( const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
83 | (void)parent; | ||
84 | return 2; | ||
85 | } | ||
86 | |||
87 | QVariant QPropertyModel::data ( const QModelIndex & index, int role /*= Qt::DisplayRole*/ ) const { | ||
88 | if (!index.isValid()) | ||
89 | return QVariant(); | ||
90 | |||
91 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
92 | switch (role) { | ||
93 | case Qt::ToolTipRole: | ||
94 | case Qt::DecorationRole: | ||
95 | case Qt::DisplayRole: | ||
96 | case Qt::EditRole: | ||
97 | if (index.column() == 0) | ||
98 | return item->objectName(); | ||
99 | if (index.column() == 1) | ||
100 | return item->value(role); | ||
101 | case Qt::BackgroundRole: | ||
102 | if (item->isRoot()) return QApplication::palette("QTreeView").brush(QPalette::Normal, QPalette::Button).color(); | ||
103 | break; | ||
104 | }; | ||
105 | return QVariant(); | ||
106 | } | ||
107 | |||
108 | // edit methods | ||
109 | bool QPropertyModel::setData ( const QModelIndex & index, const QVariant & value, int role /*= Qt::EditRole*/ ) { | ||
110 | if (index.isValid() && role == Qt::EditRole) { | ||
111 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
112 | item->setValue(value); | ||
113 | emit dataChanged(index, index); | ||
114 | return true; | ||
115 | } | ||
116 | return false; | ||
117 | } | ||
118 | |||
119 | Qt::ItemFlags QPropertyModel::flags ( const QModelIndex & index ) const { | ||
120 | if (!index.isValid()) | ||
121 | return Qt::ItemIsEnabled; | ||
122 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
123 | // only allow change of value attribute | ||
124 | if (item->isRoot()) | ||
125 | return Qt::ItemIsEnabled; | ||
126 | else if (item->isReadOnly()) | ||
127 | return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable; | ||
128 | else | ||
129 | return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; | ||
130 | } | ||
131 | |||
132 | |||
133 | QVariant QPropertyModel::headerData ( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ ) const { | ||
134 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | ||
135 | switch (section) { | ||
136 | case 0: | ||
137 | return tr("Name"); | ||
138 | case 1: | ||
139 | return tr("Value"); | ||
140 | } | ||
141 | } | ||
142 | return QVariant(); | ||
143 | } | ||
144 | |||
145 | QModelIndex QPropertyModel::buddy ( const QModelIndex & index ) const { | ||
146 | if (index.isValid() && index.column() == 0) | ||
147 | return createIndex(index.row(), 1, index.internalPointer()); | ||
148 | return index; | ||
149 | } | ||
150 | |||
151 | void QPropertyModel::addItem(QObject *propertyObject) { | ||
152 | // first create property <-> class hierarchy | ||
153 | QList<PropertyPair> propertyMap; | ||
154 | QList<const QMetaObject*> classList; | ||
155 | const QMetaObject* metaObject = propertyObject->metaObject(); | ||
156 | do { | ||
157 | int count = metaObject->propertyCount(); | ||
158 | for (int i=0; i<count; ++i) { | ||
159 | QMetaProperty property = metaObject->property(i); | ||
160 | if (property.isUser()) // Hide Qt specific properties | ||
161 | { | ||
162 | PropertyPair pair(metaObject, property); | ||
163 | int index = propertyMap.indexOf(pair); | ||
164 | if (index != -1) | ||
165 | propertyMap[index] = pair; | ||
166 | else | ||
167 | propertyMap.push_back(pair); | ||
168 | } | ||
169 | } | ||
170 | classList.push_front(metaObject); | ||
171 | } while ((metaObject = metaObject->superClass())!=0); | ||
172 | |||
173 | QList<const QMetaObject*> finalClassList; | ||
174 | // remove empty classes from hierarchy list | ||
175 | foreach(const QMetaObject* obj, classList) { | ||
176 | bool keep = false; | ||
177 | foreach(PropertyPair pair, propertyMap) { | ||
178 | if (pair.Object == obj) { | ||
179 | keep = true; | ||
180 | break; | ||
181 | } | ||
182 | } | ||
183 | if (keep) | ||
184 | finalClassList.push_back(obj); | ||
185 | } | ||
186 | |||
187 | // finally insert properties for classes containing them | ||
188 | int i=rowCount(); | ||
189 | beginInsertRows(QModelIndex(), i, i + finalClassList.count()); | ||
190 | foreach(const QMetaObject* metaObject, finalClassList) { | ||
191 | // Set default name of the hierarchy property to the class name | ||
192 | QString name = metaObject->className(); | ||
193 | // Check if there is a special name for the class | ||
194 | int index = metaObject->indexOfClassInfo(qPrintable(name)); | ||
195 | if (index != -1) | ||
196 | name = metaObject->classInfo(index).value(); | ||
197 | // Create Property Item for class node | ||
198 | Property* propertyItem = new Property(name, 0, m_rootItem); | ||
199 | foreach(PropertyPair pair, propertyMap) { | ||
200 | // Check if the property is associated with the current class from the finalClassList | ||
201 | if (pair.Object == metaObject) { | ||
202 | QMetaProperty property(pair.Property); | ||
203 | Property* p = 0; | ||
204 | if (property.type() == QVariant::UserType && m_userCallback) | ||
205 | p = m_userCallback(property.name(), propertyObject, propertyItem); | ||
206 | else | ||
207 | p = new Property(property.name(), propertyObject, propertyItem); | ||
208 | int index = metaObject->indexOfClassInfo(property.name()); | ||
209 | if (index != -1) | ||
210 | p->setEditorHints(metaObject->classInfo(index).value()); | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | endInsertRows(); | ||
215 | } | ||
216 | |||
217 | void QPropertyModel::updateItem ( QObject* propertyObject, const QModelIndex& parent /*= QModelIndex() */ ) { | ||
218 | Property *parentItem = m_rootItem; | ||
219 | if (parent.isValid()) | ||
220 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
221 | if (parentItem->propertyObject() != propertyObject) | ||
222 | parentItem = parentItem->findPropertyObject(propertyObject); | ||
223 | if (parentItem) // Indicate view that the data for the indices have changed | ||
224 | dataChanged(createIndex(parentItem->row(), 0, static_cast<Property*>(parentItem)), createIndex(parentItem->row(), 1, static_cast<Property*>(parentItem))); | ||
225 | } | ||
226 | |||
227 | void QPropertyModel::clear() { | ||
228 | beginRemoveRows(QModelIndex(), 0, rowCount()); | ||
229 | delete m_rootItem; | ||
230 | m_rootItem = new Property("Root",0, this); | ||
231 | endRemoveRows(); | ||
232 | } | ||
233 | |||
234 | void QPropertyModel::setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback) { | ||
235 | m_userCallback = callback; | ||
236 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h deleted file mode 100644 index 8a52bbe87c..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | #ifndef QPROPERTYMODEL_H_ | ||
25 | #define QPROPERTYMODEL_H_ | ||
26 | |||
27 | #include <Qt/qabstractitemmodel.h> | ||
28 | #include <Qt/qmap.h> | ||
29 | |||
30 | #include "QPropertyEditorWidget.h" | ||
31 | |||
32 | class Property; | ||
33 | |||
34 | /** | ||
35 | * The QPropertyModel handles the user defined properties of QObjects | ||
36 | */ | ||
37 | class QPropertyModel : public QAbstractItemModel { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | /** | ||
41 | * Constructor | ||
42 | * @param parent optional parent object | ||
43 | */ | ||
44 | QPropertyModel(QObject* parent = 0); | ||
45 | /// Destructor | ||
46 | virtual ~QPropertyModel(); | ||
47 | |||
48 | /// QAbstractItemModel implementation | ||
49 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; | ||
50 | |||
51 | /// QAbstractItemModel implementation | ||
52 | QModelIndex parent ( const QModelIndex & index ) const; | ||
53 | /// QAbstractItemModel implementation | ||
54 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | ||
55 | /// QAbstractItemModel implementation | ||
56 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | ||
57 | /// QAbstractItemModel implementation | ||
58 | QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; | ||
59 | |||
60 | /// QAbstractItemModel implementation | ||
61 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); | ||
62 | /// QAbstractItemModel implementation | ||
63 | Qt::ItemFlags flags ( const QModelIndex & index ) const; | ||
64 | |||
65 | /// QAbstractItemModel implementation | ||
66 | QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; | ||
67 | |||
68 | /// QAbstractItemModel implementation | ||
69 | QModelIndex buddy ( const QModelIndex & index ) const; | ||
70 | |||
71 | /** | ||
72 | * Adds the user properties of the given class to the QPropertyModel instance | ||
73 | * | ||
74 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
75 | * managed by this instance | ||
76 | */ | ||
77 | void addItem(QObject* propertyObject); | ||
78 | |||
79 | /** | ||
80 | * Creates a dataChanged signal for the given object | ||
81 | * @param propertyObject the instance of a QObject based class that should be updated | ||
82 | * @param parent optional model index the propertyObject is child of | ||
83 | */ | ||
84 | void updateItem ( QObject* propertyObject, const QModelIndex& parent = QModelIndex() ) ; | ||
85 | |||
86 | /** | ||
87 | * Removes all objects from the model | ||
88 | */ | ||
89 | void clear(); | ||
90 | |||
91 | /** | ||
92 | * Sets custom callback that will be used to create Property instances for custom datatypes | ||
93 | */ | ||
94 | void setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback); | ||
95 | |||
96 | private: | ||
97 | |||
98 | /// The Root Property for all objects | ||
99 | Property* m_rootItem; | ||
100 | |||
101 | /// Custom callback | ||
102 | QPropertyEditorWidget::UserTypeCB m_userCallback; | ||
103 | |||
104 | }; | ||
105 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp deleted file mode 100644 index ebda9b2c31..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QVariantDelegate.h" | ||
26 | |||
27 | #include "Property.h" | ||
28 | |||
29 | #include <Qt/qabstractitemview.h> | ||
30 | |||
31 | |||
32 | QVariantDelegate::QVariantDelegate(QObject* parent) : QItemDelegate(parent) {} | ||
33 | |||
34 | |||
35 | QVariantDelegate::~QVariantDelegate() {} | ||
36 | |||
37 | QWidget *QVariantDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option , const QModelIndex & index ) const { | ||
38 | QWidget* editor = 0; | ||
39 | Property* p = static_cast<Property*>(index.internalPointer()); | ||
40 | switch (p->value().type()) { | ||
41 | case QVariant::Color: | ||
42 | case QVariant::Int: | ||
43 | case QMetaType::Float: | ||
44 | case QVariant::Double: | ||
45 | case QVariant::UserType: | ||
46 | editor = p->createEditor(parent, option); | ||
47 | if (editor) break; // if no editor could be created take default case | ||
48 | default: | ||
49 | editor = QItemDelegate::createEditor(parent, option, index); | ||
50 | } | ||
51 | parseEditorHints(editor, p->editorHints()); | ||
52 | return editor; | ||
53 | } | ||
54 | |||
55 | void QVariantDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { | ||
56 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
57 | switch (data.type()) { | ||
58 | case QVariant::Color: | ||
59 | case QMetaType::Double: | ||
60 | case QMetaType::Float: | ||
61 | case QVariant::UserType: | ||
62 | if (static_cast<Property*>(index.internalPointer())->setEditorData(editor, data)) // if editor couldn't be recognized use default | ||
63 | break; | ||
64 | default: | ||
65 | QItemDelegate::setEditorData(editor, index); | ||
66 | break; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void QVariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { | ||
71 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
72 | switch (data.type()) { | ||
73 | case QVariant::Color: | ||
74 | case QMetaType::Double: | ||
75 | case QMetaType::Float: | ||
76 | case QVariant::UserType: { | ||
77 | QVariant data = static_cast<Property*>(index.internalPointer())->editorData(editor); | ||
78 | if (data.isValid()) { | ||
79 | model->setData(index, data , Qt::EditRole); | ||
80 | break; | ||
81 | } | ||
82 | } | ||
83 | default: | ||
84 | QItemDelegate::setModelData(editor, model, index); | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void QVariantDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index ) const { | ||
90 | return QItemDelegate::updateEditorGeometry(editor, option, index); | ||
91 | } | ||
92 | |||
93 | void QVariantDelegate::parseEditorHints(QWidget* editor, const QString& editorHints) const { | ||
94 | if (editor && !editorHints.isEmpty()) { | ||
95 | // Parse for property values | ||
96 | QRegExp rx("(.*)(=\\s*)(.*)(;{1})"); | ||
97 | rx.setMinimal(true); | ||
98 | int pos = 0; | ||
99 | while ((pos = rx.indexIn(editorHints, pos)) != -1) { | ||
100 | qDebug("Setting %s to %s", qPrintable(rx.cap(1)), qPrintable(rx.cap(3))); | ||
101 | editor->setProperty(qPrintable(rx.cap(1).trimmed()), rx.cap(3).trimmed()); | ||
102 | pos += rx.matchedLength(); | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h deleted file mode 100644 index e06265af82..0000000000 --- a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef COLORSELECTIONBUTTON_H_ | ||
26 | #define COLORSELECTIONBUTTON_H_ | ||
27 | |||
28 | #include <Qt/qitemdelegate.h> | ||
29 | |||
30 | |||
31 | /** | ||
32 | * This class is used to create the editor widgets for datatypes encapsulated in QVariant variables | ||
33 | */ | ||
34 | class QVariantDelegate : public QItemDelegate { | ||
35 | Q_OBJECT | ||
36 | |||
37 | public: | ||
38 | /** | ||
39 | * Constructor | ||
40 | * @param parent optional parent object | ||
41 | */ | ||
42 | QVariantDelegate(QObject* parent = 0); | ||
43 | /// Destructor | ||
44 | virtual ~QVariantDelegate(); | ||
45 | |||
46 | /** | ||
47 | * Creates an editor widget as child of a given widget for a specific QModelIndex | ||
48 | * | ||
49 | * @param parent the parent widget for the editor | ||
50 | * @param option some style options that the editor should use | ||
51 | * @param index the index of the item the editor will be created for | ||
52 | * @return QWidget the editor widget | ||
53 | */ | ||
54 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
55 | |||
56 | /** | ||
57 | * Tries to set the editor data based on the value stored at a specific QModelIndex | ||
58 | * @param editor the editor widget | ||
59 | * @param index the model index of the value that should be used in the editor | ||
60 | */ | ||
61 | virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; | ||
62 | |||
63 | /** | ||
64 | * Sets the data of a specific QModelIndex to tha value of the editor widget | ||
65 | * @param editor the editor widget that contains the new value | ||
66 | * @param model the model that contains the index | ||
67 | * @param index the index within the model whose data value should be set to the data value of the editor | ||
68 | */ | ||
69 | virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; | ||
70 | |||
71 | /// QItemDelegate implementation | ||
72 | virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
73 | |||
74 | protected: | ||
75 | void parseEditorHints(QWidget* editor, const QString& editorHints) const; | ||
76 | |||
77 | }; | ||
78 | #endif | ||
diff --git a/utils/wpseditor/gui/src/main.cpp b/utils/wpseditor/gui/src/main.cpp deleted file mode 100644 index 9c07120007..0000000000 --- a/utils/wpseditor/gui/src/main.cpp +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <QApplication> | ||
23 | #include "qwpseditorwindow.h" | ||
24 | #include "utils.h" | ||
25 | #include <QPointer> | ||
26 | |||
27 | QPointer<QWpsEditorWindow> win; | ||
28 | |||
29 | int main(int argc, char ** argv) { | ||
30 | QApplication app( argc, argv ); | ||
31 | |||
32 | win = new QWpsEditorWindow; | ||
33 | win->show(); | ||
34 | app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) ); | ||
35 | |||
36 | return app.exec(); | ||
37 | } | ||
diff --git a/utils/wpseditor/gui/src/numberedtextview.cpp b/utils/wpseditor/gui/src/numberedtextview.cpp deleted file mode 100644 index 81c4208b59..0000000000 --- a/utils/wpseditor/gui/src/numberedtextview.cpp +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 2005, 2006 KJSEmbed Authors | ||
3 | See included AUTHORS file. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | |||
20 | |||
21 | -------------------------------------------------------------------------------------- | ||
22 | Imported into the WPS editor and simplified by Dominik Wenger | ||
23 | |||
24 | */ | ||
25 | |||
26 | |||
27 | #include <QTextDocument> | ||
28 | #include <QTextBlock> | ||
29 | #include <QTextEdit> | ||
30 | #include <QHBoxLayout> | ||
31 | #include <QScrollBar> | ||
32 | #include <QPainter> | ||
33 | #include <QAbstractTextDocumentLayout> | ||
34 | #include <QDebug> | ||
35 | |||
36 | #include "numberedtextview.h" | ||
37 | |||
38 | NumberBar::NumberBar( QWidget *parent ) | ||
39 | : QWidget( parent ), edit(0), markedLine(-1) | ||
40 | { | ||
41 | // Make room for 4 digits and the breakpoint icon | ||
42 | setFixedWidth( fontMetrics().width( QString("0000") + 10 + 32 ) ); | ||
43 | markerIcon = QPixmap( "images/marker.png" ); | ||
44 | } | ||
45 | |||
46 | NumberBar::~NumberBar() | ||
47 | { | ||
48 | } | ||
49 | |||
50 | |||
51 | void NumberBar::markLine( int lineno ) | ||
52 | { | ||
53 | markedLine = lineno; | ||
54 | } | ||
55 | |||
56 | void NumberBar::setTextEdit( QTextEdit *edit ) | ||
57 | { | ||
58 | this->edit = edit; | ||
59 | connect( edit->document()->documentLayout(), SIGNAL( update(const QRectF &) ), | ||
60 | this, SLOT( update() ) ); | ||
61 | connect( edit->verticalScrollBar(), SIGNAL(valueChanged(int) ), | ||
62 | this, SLOT( update() ) ); | ||
63 | } | ||
64 | |||
65 | void NumberBar::paintEvent( QPaintEvent * ) | ||
66 | { | ||
67 | QAbstractTextDocumentLayout *layout = edit->document()->documentLayout(); | ||
68 | int contentsY = edit->verticalScrollBar()->value(); | ||
69 | qreal pageBottom = contentsY + edit->viewport()->height(); | ||
70 | const QFontMetrics fm = fontMetrics(); | ||
71 | const int ascent = fontMetrics().ascent() + 1; // height = ascent + descent + 1 | ||
72 | int lineCount = 1; | ||
73 | |||
74 | QPainter p(this); | ||
75 | |||
76 | markedRect = QRect(); | ||
77 | |||
78 | for ( QTextBlock block = edit->document()->begin(); | ||
79 | block.isValid(); block = block.next(), ++lineCount ) | ||
80 | { | ||
81 | |||
82 | const QRectF boundingRect = layout->blockBoundingRect( block ); | ||
83 | |||
84 | QPointF position = boundingRect.topLeft(); | ||
85 | if ( position.y() + boundingRect.height() < contentsY ) | ||
86 | continue; | ||
87 | if ( position.y() > pageBottom ) | ||
88 | break; | ||
89 | |||
90 | const QString txt = QString::number( lineCount ); | ||
91 | p.drawText( width() - fm.width(txt), qRound( position.y() ) - contentsY + ascent, txt ); | ||
92 | |||
93 | // marker | ||
94 | if ( markedLine == lineCount ) | ||
95 | { | ||
96 | p.drawPixmap( 1, qRound( position.y() ) - contentsY, markerIcon ); | ||
97 | markedRect = QRect( 1, qRound( position.y() ) - contentsY, markerIcon.width(), markerIcon.height() ); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | NumberedTextView::NumberedTextView( QWidget *parent ) | ||
103 | : QFrame( parent ) | ||
104 | { | ||
105 | setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); | ||
106 | setLineWidth( 2 ); | ||
107 | |||
108 | // Setup the main view | ||
109 | view = new QTextEdit( this ); | ||
110 | //view->setFontFamily( "Courier" ); | ||
111 | view->setLineWrapMode( QTextEdit::NoWrap ); | ||
112 | view->setFrameStyle( QFrame::NoFrame ); | ||
113 | |||
114 | connect( view->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(textChanged(int,int,int)) ); | ||
115 | |||
116 | // Setup the line number pane | ||
117 | numbers = new NumberBar( this ); | ||
118 | numbers->setTextEdit( view ); | ||
119 | |||
120 | // Test | ||
121 | markLine(2); | ||
122 | |||
123 | //setup layout | ||
124 | box = new QHBoxLayout( this ); | ||
125 | box->setSpacing( 0 ); | ||
126 | box->setMargin( 0 ); | ||
127 | box->addWidget( numbers ); | ||
128 | box->addWidget( view ); | ||
129 | } | ||
130 | |||
131 | NumberedTextView::~NumberedTextView() | ||
132 | { | ||
133 | } | ||
134 | |||
135 | void NumberedTextView::markLine( int lineno ) | ||
136 | { | ||
137 | markedLine = lineno; | ||
138 | numbers->markLine( lineno ); | ||
139 | textChanged(1,1,1); | ||
140 | } | ||
141 | |||
142 | void NumberedTextView::scrolltoLine( int lineno ) | ||
143 | { | ||
144 | int max = view->verticalScrollBar()->maximum(); | ||
145 | int min = view->verticalScrollBar()->minimum(); | ||
146 | int lines = view->document()->blockCount(); | ||
147 | view->verticalScrollBar()->setValue( (max*lineno)/lines+min ); | ||
148 | } | ||
149 | |||
150 | void NumberedTextView::textChanged( int pos, int removed, int added ) | ||
151 | { | ||
152 | Q_UNUSED( pos ); | ||
153 | |||
154 | if ( removed == 0 && added == 0 ) | ||
155 | return; | ||
156 | |||
157 | QTextBlock block = highlight.block(); | ||
158 | QTextBlockFormat fmt = block.blockFormat(); | ||
159 | QColor bg = view->palette().base().color(); | ||
160 | fmt.setBackground( bg ); | ||
161 | highlight.setBlockFormat( fmt ); | ||
162 | |||
163 | int lineCount = 1; | ||
164 | for ( QTextBlock block = view->document()->begin(); | ||
165 | block.isValid(); block = block.next(), ++lineCount ) | ||
166 | { | ||
167 | if ( lineCount == markedLine ) | ||
168 | { | ||
169 | fmt = block.blockFormat(); | ||
170 | QColor bg = Qt::red; | ||
171 | fmt.setBackground( bg.light(150) ); | ||
172 | |||
173 | highlight = QTextCursor( block ); | ||
174 | highlight.movePosition( QTextCursor::EndOfBlock, QTextCursor::KeepAnchor ); | ||
175 | highlight.setBlockFormat( fmt ); | ||
176 | |||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
diff --git a/utils/wpseditor/gui/src/numberedtextview.h b/utils/wpseditor/gui/src/numberedtextview.h deleted file mode 100644 index 2a0d1de068..0000000000 --- a/utils/wpseditor/gui/src/numberedtextview.h +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 2005, 2006 KJSEmbed Authors | ||
3 | See included AUTHORS file. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | |||
20 | -------------------------------------------------------------------------------------- | ||
21 | Imported into the WPS editor and simplified by Dominik Wenger | ||
22 | |||
23 | */ | ||
24 | |||
25 | |||
26 | #ifndef NUMBERED_TEXT_VIEW_H | ||
27 | #define NUMBERED_TEXT_VIEW_H | ||
28 | |||
29 | #include <QFrame> | ||
30 | #include <QPixmap> | ||
31 | #include <QTextCursor> | ||
32 | |||
33 | class QTextEdit; | ||
34 | class QHBoxLayout; | ||
35 | |||
36 | // Shows the Line numbers | ||
37 | class NumberBar : public QWidget | ||
38 | { | ||
39 | Q_OBJECT | ||
40 | |||
41 | public: | ||
42 | NumberBar( QWidget *parent ); | ||
43 | ~NumberBar(); | ||
44 | |||
45 | void markLine( int lineno ); | ||
46 | |||
47 | void setTextEdit( QTextEdit *edit ); | ||
48 | void paintEvent( QPaintEvent *ev ); | ||
49 | |||
50 | private: | ||
51 | QTextEdit *edit; | ||
52 | QPixmap markerIcon; | ||
53 | int markedLine; | ||
54 | QRect markedRect; | ||
55 | }; | ||
56 | |||
57 | // Shows a QTextEdit with Line numbers | ||
58 | class NumberedTextView : public QFrame | ||
59 | { | ||
60 | Q_OBJECT | ||
61 | |||
62 | public: | ||
63 | NumberedTextView( QWidget *parent = 0 ); | ||
64 | ~NumberedTextView(); | ||
65 | |||
66 | /** Returns the QTextEdit of the main view. */ | ||
67 | QTextEdit *textEdit() const { return view; } | ||
68 | |||
69 | /* marks the line with a icon */ | ||
70 | void markLine( int lineno ); | ||
71 | |||
72 | void scrolltoLine( int lineno ); | ||
73 | |||
74 | private slots: | ||
75 | void textChanged( int pos, int removed, int added ); | ||
76 | |||
77 | private: | ||
78 | QTextEdit *view; | ||
79 | NumberBar *numbers; | ||
80 | QHBoxLayout *box; | ||
81 | QTextCursor highlight; | ||
82 | int markedLine; | ||
83 | }; | ||
84 | |||
85 | |||
86 | #endif // NUMBERED_TEXT_VIEW_H | ||
87 | |||
diff --git a/utils/wpseditor/gui/src/qsyntaxer.cpp b/utils/wpseditor/gui/src/qsyntaxer.cpp deleted file mode 100644 index 5a0b6cd97c..0000000000 --- a/utils/wpseditor/gui/src/qsyntaxer.cpp +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <QTextCharFormat> | ||
23 | |||
24 | #include "qsyntaxer.h" | ||
25 | |||
26 | QSyntaxer::QSyntaxer(QTextDocument *parent) | ||
27 | : QSyntaxHighlighter(parent) { | ||
28 | HighlightingRule rule; | ||
29 | |||
30 | hrules[0].pattern = QRegExp("%[^\\| \n<\\?%]{1,2}"); | ||
31 | hrules[0].format.setFontWeight(QFont::Bold); | ||
32 | hrules[0].format.setForeground(Qt::darkBlue); | ||
33 | |||
34 | |||
35 | hrules[1].pattern = QRegExp("%[\\?]{1}[^<]{1,2}"); | ||
36 | hrules[1].format.setForeground(Qt::darkMagenta); | ||
37 | |||
38 | hrules[2].pattern = QRegExp("(<|>)"); | ||
39 | hrules[2].format.setForeground(Qt::red); | ||
40 | |||
41 | hrules[3].pattern = QRegExp("\\|"); | ||
42 | hrules[3].format.setForeground(Qt::darkRed); | ||
43 | |||
44 | hrules[4].pattern = QRegExp("#[^\n]*"); | ||
45 | hrules[4].format.setForeground(Qt::darkGreen); | ||
46 | hrules[4].format.setFontItalic(true); | ||
47 | } | ||
48 | // | ||
49 | void QSyntaxer::highlightBlock(const QString &text) { | ||
50 | QTextCharFormat wholeText; | ||
51 | wholeText.setFont(QFont("arial",11,QFont::Normal)); | ||
52 | setFormat(0,text.length(),wholeText); | ||
53 | |||
54 | foreach (HighlightingRule rule, hrules) { | ||
55 | QRegExp expression(rule.pattern); | ||
56 | int index = text.indexOf(expression); | ||
57 | while (index >= 0) { | ||
58 | int length = expression.matchedLength(); | ||
59 | setFormat(index, length, rule.format); | ||
60 | index = text.indexOf(expression, index + length); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | } | ||
diff --git a/utils/wpseditor/gui/src/qsyntaxer.h b/utils/wpseditor/gui/src/qsyntaxer.h deleted file mode 100644 index 56f7cfaf48..0000000000 --- a/utils/wpseditor/gui/src/qsyntaxer.h +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef QSYNTAXER_H | ||
23 | #define QSYNTAXER_H | ||
24 | // | ||
25 | #include <QSyntaxHighlighter> | ||
26 | |||
27 | class QTextCharFormat; | ||
28 | |||
29 | class QSyntaxer : public QSyntaxHighlighter { | ||
30 | Q_OBJECT | ||
31 | struct HighlightingRule { | ||
32 | QRegExp pattern; | ||
33 | QTextCharFormat format; | ||
34 | }; | ||
35 | QMap<int,HighlightingRule> hrules; | ||
36 | public: | ||
37 | QSyntaxer(QTextDocument *parent = 0); | ||
38 | |||
39 | protected: | ||
40 | void highlightBlock(const QString &text); | ||
41 | }; | ||
42 | #endif | ||
diff --git a/utils/wpseditor/gui/src/qtrackstate.cpp b/utils/wpseditor/gui/src/qtrackstate.cpp deleted file mode 100644 index 85398971b0..0000000000 --- a/utils/wpseditor/gui/src/qtrackstate.cpp +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "qtrackstate.h" | ||
23 | #include <stdlib.h> | ||
24 | |||
25 | // | ||
26 | QTrackState::QTrackState( ) | ||
27 | : QObject() { | ||
28 | memset(&state,0,sizeof(state)); | ||
29 | state.title = (char*)"title"; | ||
30 | state.artist = (char*)"artist"; | ||
31 | state.album = (char*)"album"; | ||
32 | state.length = 100; | ||
33 | state.elapsed = 50; | ||
34 | } | ||
35 | |||
36 | void QTrackState::setTitle(const QString& name) { | ||
37 | state.title = new char[name.length()]; | ||
38 | strcpy(state.title,name.toAscii()); | ||
39 | emit stateChanged(state); | ||
40 | } | ||
41 | |||
42 | void QTrackState::setArtist(const QString& name) { | ||
43 | state.artist = new char[name.length()]; | ||
44 | strcpy(state.artist,name.toAscii()); | ||
45 | emit stateChanged(state); | ||
46 | } | ||
47 | |||
48 | void QTrackState::setAlbum(const QString& name) { | ||
49 | state.album = new char[name.length()]; | ||
50 | strcpy(state.album,name.toAscii()); | ||
51 | emit stateChanged(state); | ||
52 | } | ||
53 | |||
54 | void QTrackState::setLength(int le) { | ||
55 | state.length = le; | ||
56 | emit stateChanged(state); | ||
57 | } | ||
58 | |||
59 | void QTrackState::setElapsed(int le) { | ||
60 | state.elapsed = le; | ||
61 | emit stateChanged(state); | ||
62 | } | ||
diff --git a/utils/wpseditor/gui/src/qtrackstate.h b/utils/wpseditor/gui/src/qtrackstate.h deleted file mode 100644 index ebe000dd25..0000000000 --- a/utils/wpseditor/gui/src/qtrackstate.h +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __QTRACKSTATE_H__ | ||
23 | #define __QTRACKSTATE_H__ | ||
24 | |||
25 | #include "wpsstate.h" | ||
26 | #include <QObject> | ||
27 | |||
28 | class QTrackState : public QObject { | ||
29 | Q_OBJECT | ||
30 | Q_CLASSINFO ( "QTrackState", "Track State" ); | ||
31 | Q_PROPERTY ( QString Title READ title WRITE setTitle DESIGNABLE true USER true ) | ||
32 | Q_PROPERTY ( QString Artist READ artist WRITE setArtist DESIGNABLE true USER true ) | ||
33 | Q_PROPERTY ( QString Album READ album WRITE setAlbum DESIGNABLE true USER true ) | ||
34 | Q_PROPERTY ( int Length READ length WRITE setLength DESIGNABLE true USER true ) | ||
35 | Q_CLASSINFO("Length", "readOnly=true;value=100"); | ||
36 | Q_PROPERTY ( int Elapsed READ elapsed WRITE setElapsed DESIGNABLE true USER true ) | ||
37 | Q_CLASSINFO("Elapsed", "minimum=0;maximum=100;value=50"); | ||
38 | |||
39 | trackstate state; | ||
40 | |||
41 | public: | ||
42 | QTrackState(); | ||
43 | |||
44 | public slots: | ||
45 | QString title() const { | ||
46 | return state.title; | ||
47 | } | ||
48 | void setTitle ( const QString& name ); | ||
49 | |||
50 | QString artist() const { | ||
51 | return state.artist; | ||
52 | } | ||
53 | void setArtist ( const QString& name ); | ||
54 | |||
55 | QString album() const { | ||
56 | return state.album; | ||
57 | } | ||
58 | void setAlbum ( const QString& name ); | ||
59 | |||
60 | int length() const { | ||
61 | return state.length; | ||
62 | } | ||
63 | void setLength ( int l ); | ||
64 | |||
65 | int elapsed() const { | ||
66 | return state.elapsed; | ||
67 | } | ||
68 | void setElapsed ( int l ); | ||
69 | |||
70 | signals: | ||
71 | void stateChanged ( trackstate state ); | ||
72 | |||
73 | }; | ||
74 | |||
75 | #endif // __QTRACKSTATE_H__ | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer.cpp b/utils/wpseditor/gui/src/qwpsdrawer.cpp deleted file mode 100644 index ce2dbd0149..0000000000 --- a/utils/wpseditor/gui/src/qwpsdrawer.cpp +++ /dev/null | |||
@@ -1,274 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdarg.h> | ||
23 | |||
24 | #include <QtGui> | ||
25 | #include <QLibrary> | ||
26 | |||
27 | #include "qwpsdrawer.h" | ||
28 | #include "slider.h" | ||
29 | #include "utils.h" | ||
30 | #include "qtrackstate.h" | ||
31 | #include "qwpsstate.h" | ||
32 | #include "api.h" | ||
33 | |||
34 | QPointer<QWpsDrawer> drawer; | ||
35 | QPixmap *QWpsDrawer::pix = NULL; | ||
36 | QString QWpsDrawer::mTmpWpsString; | ||
37 | QImage QWpsDrawer::backdrop; | ||
38 | proxy_api QWpsDrawer::api; | ||
39 | |||
40 | QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) | ||
41 | : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget(qApp->applicationDirPath()+"/libwps_IRIVER_H10_5GB") { | ||
42 | |||
43 | tryResolve(); | ||
44 | newTempWps(); | ||
45 | } | ||
46 | |||
47 | bool QWpsDrawer::tryResolve() { | ||
48 | QLibrary lib(mCurTarget); | ||
49 | lib_wps_init = (pfwps_init)lib.resolve("wps_init"); | ||
50 | lib_wps_display = (pfwps_display)lib.resolve("wps_display"); | ||
51 | lib_wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); | ||
52 | lib_get_model_name = (pfget_model_name)lib.resolve("get_model_name"); | ||
53 | mResolved = lib_wps_init && lib_wps_display && lib_wps_refresh && lib_get_model_name; | ||
54 | if (!mResolved) | ||
55 | DEBUGF1(tr("ERR: Failed to resolve funcs!")); | ||
56 | else { | ||
57 | int v = api.verbose; | ||
58 | memset(&api,0,sizeof(struct proxy_api)); | ||
59 | api.verbose = v; | ||
60 | api.putsxy = &QWpsDrawer::putsxy; | ||
61 | api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; | ||
62 | api.bitmap_part = &QWpsDrawer::bitmap_part; | ||
63 | api.drawpixel = &QWpsDrawer::drawpixel; | ||
64 | api.fillrect = &QWpsDrawer::fillrect; | ||
65 | api.hline = &QWpsDrawer::hline; | ||
66 | api.vline = &QWpsDrawer::vline; | ||
67 | api.clear_viewport = &QWpsDrawer::clear_viewport; | ||
68 | api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; | ||
69 | api.read_bmp_file = &QWpsDrawer::read_bmp_file; | ||
70 | api.debugf = &qlogger; | ||
71 | qDebug()<<(mCurTarget+" resolved"); | ||
72 | } | ||
73 | return mResolved; | ||
74 | } | ||
75 | QWpsDrawer::~QWpsDrawer() { | ||
76 | qDebug()<<"QWpsDrawer::~QWpsDrawer()"; | ||
77 | cleanTemp(); | ||
78 | } | ||
79 | |||
80 | void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) { | ||
81 | Q_UNUSED(event); | ||
82 | /*int x = event->x() - (this->width()-pix->width())/2, | ||
83 | y = event->y() - (this->height()-pix->height())/2; | ||
84 | DEBUGF1("x=%d,y=%d",x,y);*/ | ||
85 | } | ||
86 | void QWpsDrawer::newTempWps() { | ||
87 | QTemporaryFile tmpWps; | ||
88 | tmpWps.setAutoRemove(false); | ||
89 | tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); | ||
90 | if (tmpWps.open()) { | ||
91 | QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); | ||
92 | if (QDir::temp().mkpath(tmpDir)) { | ||
93 | mTmpWpsString = tmpDir; | ||
94 | DEBUGF3(QString("Created :"+mTmpWpsString).toAscii()); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | void QWpsDrawer::WpsInit(QString buffer, bool isFile) { | ||
100 | DEBUGF3("QWpsDrawer::WpsInit"); | ||
101 | if (!mResolved) | ||
102 | if (!tryResolve()) | ||
103 | return; | ||
104 | if (isFile) { | ||
105 | cleanTemp(); | ||
106 | DEBUGF1( tr("Loading %1").arg(buffer)); | ||
107 | QFile file(buffer); | ||
108 | if (file.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
109 | mWpsString = file.readAll(); | ||
110 | newTempWps(); | ||
111 | } else | ||
112 | mWpsString = buffer; | ||
113 | { | ||
114 | QFile tfile(mTmpWpsString+".wps"); | ||
115 | if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) | ||
116 | tfile.write(mWpsString.toAscii(),mWpsString.length()); | ||
117 | } | ||
118 | backdrop.fill(Qt::black); | ||
119 | DEBUGF3("clear backdrop"); | ||
120 | if (isFile) | ||
121 | lib_wps_init(buffer.toAscii(), &api, isFile); | ||
122 | else | ||
123 | lib_wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); | ||
124 | pix = new QPixmap(api.getwidth(),api.getheight()); | ||
125 | pix->fill(Qt::black); | ||
126 | |||
127 | drawBackdrop(); | ||
128 | |||
129 | setMinimumWidth(api.getwidth()); | ||
130 | setMinimumHeight(api.getheight()); | ||
131 | update(); | ||
132 | } | ||
133 | |||
134 | void QWpsDrawer::paintEvent(QPaintEvent * event) { | ||
135 | DEBUGF3("QWpsDrawer::paintEvent()"); | ||
136 | if (!mResolved) | ||
137 | return; | ||
138 | if (pix==NULL) | ||
139 | return; | ||
140 | QPainter p(this); | ||
141 | QRect rect = event->rect(); | ||
142 | |||
143 | drawBackdrop(); | ||
144 | lib_wps_refresh(); | ||
145 | |||
146 | if (showGrid) { | ||
147 | QPainter g(pix); | ||
148 | viewport_api avp; | ||
149 | api.get_current_vp(&avp); | ||
150 | |||
151 | g.setPen(Qt::green); | ||
152 | |||
153 | for (int i=0;i*avp.fontheight/1.5<avp.width ;i++) { | ||
154 | g.drawLine(int(i*avp.fontheight/1.5), 0, int(i*avp.fontheight/1.5), avp.height); | ||
155 | } | ||
156 | for (int j=0;j*avp.fontheight<avp.height; j++) { | ||
157 | g.drawLine(0,j*avp.fontheight,avp.width,j*avp.fontheight); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | p.drawPixmap((rect.width()-pix->width())/2,(rect.height()-pix->height())/2,*pix); | ||
162 | |||
163 | } | ||
164 | |||
165 | void QWpsDrawer::clear_viewport(int x,int y,int w,int h, int color) { | ||
166 | DEBUGF2("clear_viewport(int x=%d,int y=%d,int w=%d,int h=%d, int color)",x,y,w,h); | ||
167 | QPainter p(pix); | ||
168 | //p.setOpacity(0.1); | ||
169 | //QImage img = backdrop.copy(x,y,w,h); | ||
170 | //p.drawImage(x,y,img); | ||
171 | } | ||
172 | |||
173 | void QWpsDrawer::slotSetVolume() { | ||
174 | Slider *slider = new Slider(this, tr("Volume"),-74,10); | ||
175 | slider->show(); | ||
176 | connect(slider, SIGNAL(valueChanged(int)), wpsState, SLOT(setVolume(int))); | ||
177 | connect(this, SIGNAL(destroyed()),slider, SLOT(close())); | ||
178 | } | ||
179 | |||
180 | void QWpsDrawer::slotSetProgress() { | ||
181 | Slider *slider = new Slider(this,tr("Progress"),0,100); | ||
182 | slider->show(); | ||
183 | connect(slider, SIGNAL(valueChanged(int)), trackState, SLOT(setElapsed(int))); | ||
184 | connect(this, SIGNAL(destroyed()),slider, SLOT(close())); | ||
185 | } | ||
186 | |||
187 | void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) { | ||
188 | if (api.set_wpsstate) | ||
189 | api.set_wpsstate(ws_); | ||
190 | update(); | ||
191 | } | ||
192 | |||
193 | void QWpsDrawer::slotTrackStateChanged(trackstate ms_) { | ||
194 | if (api.set_wpsstate) | ||
195 | api.set_trackstate(ms_); | ||
196 | update(); | ||
197 | } | ||
198 | |||
199 | void QWpsDrawer::slotShowGrid(bool show) { | ||
200 | showGrid = show; | ||
201 | update(); | ||
202 | } | ||
203 | |||
204 | void QWpsDrawer::drawBackdrop() { | ||
205 | DEBUGF3("QWpsDrawer::drawBackdrop()"); | ||
206 | if (backdrop.isNull()) | ||
207 | return; | ||
208 | QPainter b(pix); | ||
209 | QImage pink = backdrop.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); | ||
210 | backdrop.setAlphaChannel(pink); | ||
211 | b.drawImage(0,0,backdrop,0,0,pix->width(),pix->height()); | ||
212 | } | ||
213 | |||
214 | void QWpsDrawer::slotSetAudioStatus(int status) { | ||
215 | api.set_audio_status(status); | ||
216 | update(); | ||
217 | } | ||
218 | |||
219 | void QWpsDrawer::cleanTemp(bool fileToo) { | ||
220 | if (fileToo) | ||
221 | QFile::remove(mTmpWpsString+".wps"); | ||
222 | QDirIterator it(mTmpWpsString, QDirIterator::Subdirectories); | ||
223 | while (it.hasNext()) { | ||
224 | QFile::remove(it.next()); | ||
225 | } | ||
226 | QDir(mTmpWpsString).rmdir(mTmpWpsString); | ||
227 | } | ||
228 | |||
229 | void QWpsDrawer::closeEvent(QCloseEvent *event) { | ||
230 | qDebug()<<"QWpsDrawer::closeEvent()"; | ||
231 | cleanTemp(); | ||
232 | event->accept(); | ||
233 | } | ||
234 | |||
235 | QString QWpsDrawer::getModelName(QString libraryName) { | ||
236 | QLibrary lib(libraryName); | ||
237 | if ((pfget_model_name)lib.resolve("get_model_name")) | ||
238 | return ((pfget_model_name)lib.resolve("get_model_name"))(); | ||
239 | DEBUGF1("ERR: failed to resolve <get_model_name>"); | ||
240 | return "unknown"; | ||
241 | } | ||
242 | |||
243 | QList<QString> QWpsDrawer::getTargets() { | ||
244 | QList<QString> list ; | ||
245 | QDir d = QDir(qApp->applicationDirPath()); | ||
246 | QFileInfoList libs = d.entryInfoList(QStringList("libwps_*")); | ||
247 | qDebug() << libs.size()<<"libs found"; | ||
248 | for (int i = 0; i < libs.size(); i++) { | ||
249 | QString modelName = getModelName(libs[i].absoluteFilePath()); | ||
250 | qDebug() << libs[i].fileName()<<modelName; | ||
251 | if (modelName == "unknown") | ||
252 | continue; | ||
253 | list.append(modelName); | ||
254 | libs_array[i].target_name = modelName; | ||
255 | libs_array[i].lib = libs[i].absoluteFilePath(); | ||
256 | } | ||
257 | return list; | ||
258 | } | ||
259 | bool QWpsDrawer::setTarget(QString target) { | ||
260 | foreach(lib_t cur_lib, libs_array) | ||
261 | { | ||
262 | if(cur_lib.target_name == target) | ||
263 | { | ||
264 | QLibrary lib(cur_lib.lib); | ||
265 | //lib.unload(); | ||
266 | if (getModelName(cur_lib.lib) != "unknown") | ||
267 | { | ||
268 | mCurTarget = cur_lib.lib; | ||
269 | return tryResolve(); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | return false; | ||
274 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer.h b/utils/wpseditor/gui/src/qwpsdrawer.h deleted file mode 100644 index fd290a24ae..0000000000 --- a/utils/wpseditor/gui/src/qwpsdrawer.h +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef WPSDRAWER_H | ||
23 | #define WPSDRAWER_H | ||
24 | |||
25 | #include <QWidget> | ||
26 | #include <QPixmap> | ||
27 | #include <QPointer> | ||
28 | #include <QTemporaryFile> | ||
29 | #include <QMap> | ||
30 | |||
31 | #include "wpsstate.h" | ||
32 | |||
33 | struct proxy_api; | ||
34 | |||
35 | class QWpsState; | ||
36 | class QTrackState; | ||
37 | |||
38 | typedef int (*pfwps_init)(const char* buff,struct proxy_api *api, bool isfile); | ||
39 | typedef int (*pfwps_display)(); | ||
40 | typedef int (*pfwps_refresh)(); | ||
41 | typedef const char* (*pfget_model_name)(); | ||
42 | |||
43 | class QWpsDrawer : public QWidget { | ||
44 | Q_OBJECT | ||
45 | |||
46 | pfwps_init lib_wps_init; | ||
47 | pfwps_display lib_wps_display; | ||
48 | pfwps_refresh lib_wps_refresh; | ||
49 | pfget_model_name lib_get_model_name; | ||
50 | |||
51 | static QPixmap *pix; | ||
52 | static QImage backdrop; | ||
53 | |||
54 | QWpsState *wpsState; | ||
55 | QTrackState *trackState; | ||
56 | |||
57 | bool showGrid; | ||
58 | bool mResolved; | ||
59 | QString mWpsString; | ||
60 | QString mCurTarget; | ||
61 | static QString mTmpWpsString; | ||
62 | |||
63 | struct lib_t | ||
64 | { | ||
65 | QString target_name; | ||
66 | QString lib; | ||
67 | }; | ||
68 | QMap<int, lib_t> libs_array; | ||
69 | |||
70 | |||
71 | protected: | ||
72 | virtual void paintEvent(QPaintEvent * event); | ||
73 | virtual void closeEvent(QCloseEvent *event); | ||
74 | virtual void mouseReleaseEvent ( QMouseEvent * event ) ; | ||
75 | void drawBackdrop(); | ||
76 | void newTempWps(); | ||
77 | void cleanTemp(bool fileToo=true); | ||
78 | bool tryResolve(); | ||
79 | QString getModelName(QString libraryName); | ||
80 | public: | ||
81 | QWpsDrawer(QWpsState *ws,QTrackState *ms, QWidget *parent=0); | ||
82 | ~QWpsDrawer(); | ||
83 | void WpsInit(QString buffer, bool isFile = true); | ||
84 | |||
85 | QString wpsString() const { | ||
86 | return mWpsString; | ||
87 | }; | ||
88 | QString tempWps() const { | ||
89 | return mTmpWpsString; | ||
90 | }; | ||
91 | QList<QString> getTargets(); | ||
92 | bool setTarget(QString target); | ||
93 | |||
94 | |||
95 | static proxy_api api; | ||
96 | /***********Drawing api******************/ | ||
97 | static void putsxy(int x, int y, const unsigned char *str); | ||
98 | static void transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
99 | int stride, int x, int y, int width, int height); | ||
100 | static void bitmap_part(const void *src, int src_x, int src_y, | ||
101 | int stride, int x, int y, int width, int height); | ||
102 | static void drawpixel(int x, int y); | ||
103 | static void fillrect(int x, int y, int width, int height); | ||
104 | static void hline(int x1, int x2, int y); | ||
105 | static void vline(int x, int y1, int y2); | ||
106 | static void clear_viewport(int x,int y,int w,int h, int color); | ||
107 | static bool load_wps_backdrop(char* filename); | ||
108 | static int read_bmp_file(const char* filename,int *width, int *height); | ||
109 | /****************************************/ | ||
110 | public slots: | ||
111 | void slotSetVolume(); | ||
112 | void slotSetProgress(); | ||
113 | void slotShowGrid(bool); | ||
114 | void slotWpsStateChanged(wpsstate); | ||
115 | void slotTrackStateChanged(trackstate); | ||
116 | void slotSetAudioStatus(int); | ||
117 | }; | ||
118 | #endif | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp deleted file mode 100644 index d5da623722..0000000000 --- a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "qwpsdrawer.h" | ||
23 | #include <QPainter> | ||
24 | #include <QFile> | ||
25 | #include <QFileInfo> | ||
26 | #include "utils.h" | ||
27 | #include "api.h" | ||
28 | |||
29 | void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { | ||
30 | DEBUGF3("putsxy(int x=%d, int y=%d, *str=%s)",x,y,str); | ||
31 | QPainter p(pix); | ||
32 | viewport_api avp; | ||
33 | api.get_current_vp(&avp); | ||
34 | p.setPen(Qt::gray); | ||
35 | QFont font("times",avp.fontheight,QFont::Bold); | ||
36 | p.setFont(font); | ||
37 | p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); | ||
38 | } | ||
39 | void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
40 | int stride, int x, int y, int width, int height) { | ||
41 | QImage img; | ||
42 | img.load((char*)src); | ||
43 | DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d,int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y,stride, x, y, width, height); | ||
44 | QPainter p(pix); | ||
45 | QPoint target(x,y); | ||
46 | QRectF source(src_x, src_y, width, height); | ||
47 | |||
48 | QImage pink = img.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); | ||
49 | img.setAlphaChannel(pink); | ||
50 | |||
51 | p.drawImage(target, img, source); | ||
52 | } | ||
53 | void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, | ||
54 | int stride, int x, int y, int width, int height) { | ||
55 | transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); | ||
56 | } | ||
57 | void QWpsDrawer::drawpixel(int x, int y) { | ||
58 | QPainter p(pix); | ||
59 | p.setPen(Qt::blue); | ||
60 | p.drawPoint(x,y); | ||
61 | } | ||
62 | void QWpsDrawer::fillrect(int x, int y, int width, int height) { | ||
63 | QPainter p(pix); | ||
64 | DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); | ||
65 | p.setPen(Qt::green); | ||
66 | } | ||
67 | void QWpsDrawer::hline(int x1, int x2, int y) { | ||
68 | QPainter p(pix); | ||
69 | p.setPen(Qt::black); | ||
70 | p.drawLine(x1,y,x2,y); | ||
71 | } | ||
72 | void QWpsDrawer::vline(int x, int y1, int y2) { | ||
73 | QPainter p(pix); | ||
74 | p.setPen(Qt::black); | ||
75 | p.drawLine(x,y1,x,y2); | ||
76 | } | ||
77 | bool QWpsDrawer::load_wps_backdrop(char* filename) { | ||
78 | DEBUGF3("load backdrop: %s", filename); | ||
79 | QFile file(filename); | ||
80 | QFileInfo info(file); | ||
81 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
82 | backdrop.load(filename); | ||
83 | return true; | ||
84 | } | ||
85 | |||
86 | int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { | ||
87 | QImage img; | ||
88 | |||
89 | QFile file(filename); | ||
90 | QFileInfo info(file); | ||
91 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
92 | |||
93 | img.load(filename); | ||
94 | *width = img.width(); | ||
95 | *height = img.height(); | ||
96 | return 1; | ||
97 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.cpp b/utils/wpseditor/gui/src/qwpseditorwindow.cpp deleted file mode 100644 index 1527fef57a..0000000000 --- a/utils/wpseditor/gui/src/qwpseditorwindow.cpp +++ /dev/null | |||
@@ -1,191 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <QFileDialog> | ||
23 | #include <QDebug> | ||
24 | #include <QInputDialog> | ||
25 | #include "api.h" | ||
26 | #include "qwpseditorwindow.h" | ||
27 | #include "utils.h" | ||
28 | #include "qsyntaxer.h" | ||
29 | |||
30 | |||
31 | enum api_playmode playmodes[PLAYMODES_NUM] = { | ||
32 | API_STATUS_PLAY, | ||
33 | API_STATUS_STOP, | ||
34 | API_STATUS_PAUSE, | ||
35 | API_STATUS_FASTFORWARD, | ||
36 | API_STATUS_FASTBACKWARD | ||
37 | }; | ||
38 | |||
39 | const char *playmodeNames[] = { | ||
40 | "Play", | ||
41 | "Stop", | ||
42 | "Pause", | ||
43 | "FastForward", | ||
44 | "FastBackward" | ||
45 | }; | ||
46 | |||
47 | QWpsEditorWindow::QWpsEditorWindow( QWidget * parent, Qt::WFlags f) | ||
48 | : QMainWindow(parent, f) { | ||
49 | logEdit = 0; | ||
50 | scrollingLine = -1; | ||
51 | setupUi(this); | ||
52 | drawer = new QWpsDrawer(&wpsState,&trackState, this); | ||
53 | QWpsDrawer::api.verbose = 1; | ||
54 | setCentralWidget(drawer); | ||
55 | connectActions(); | ||
56 | m_propertyEditor->addObject(&trackState); | ||
57 | m_propertyEditor->addObject(&wpsState); | ||
58 | new QSyntaxer(plainWpsEdit->textEdit()->document()); | ||
59 | plainWpsEdit->markLine(-1); | ||
60 | } | ||
61 | |||
62 | void QWpsEditorWindow::connectActions() { | ||
63 | DEBUGF3("connect actions"); | ||
64 | connect(actOpenWps, SIGNAL(triggered()), this, SLOT(slotOpenWps())); | ||
65 | connect(actSetVolume, SIGNAL(triggered()), drawer, SLOT(slotSetVolume())); | ||
66 | connect(actSetProgress, SIGNAL(triggered()), drawer, SLOT(slotSetProgress())); | ||
67 | connect(actShowGrid, SIGNAL(triggered(bool)), drawer, SLOT(slotShowGrid(bool))); | ||
68 | |||
69 | connect(actUpdatePlainWps, SIGNAL(triggered()), SLOT(slotUpdatePlainWps())); | ||
70 | connect(plainWpsEdit->textEdit()->document(),SIGNAL(modificationChanged(bool)),SLOT(slotPlainDocModChanged(bool))); | ||
71 | |||
72 | connect(&wpsState, SIGNAL(stateChanged(wpsstate)), drawer, SLOT(slotWpsStateChanged(wpsstate))); | ||
73 | connect(&trackState, SIGNAL(stateChanged(trackstate)), drawer, SLOT(slotTrackStateChanged(trackstate))); | ||
74 | connect(&wpsState, SIGNAL(stateChanged(wpsstate)), this, SLOT(slotWpsStateChanged(wpsstate))); | ||
75 | connect(&trackState, SIGNAL(stateChanged(trackstate)), this, SLOT(slotTrackStateChanged(trackstate))); | ||
76 | |||
77 | connect(actClearLog, SIGNAL(triggered()), logEdit, SLOT(clear())); | ||
78 | connect(actVerboseLevel, SIGNAL(triggered()), SLOT(slotVerboseLevel())); | ||
79 | |||
80 | actGroupAudios = new QActionGroup(this); | ||
81 | audiosSignalMapper = new QSignalMapper(this); | ||
82 | for (int i=0;i<PLAYMODES_NUM;i++) { | ||
83 | QAction *act = new QAction(playmodeNames[i],this); | ||
84 | act->setCheckable(true); | ||
85 | actGroupAudios->addAction(act); | ||
86 | connect(act,SIGNAL(triggered()),audiosSignalMapper,SLOT(map())); | ||
87 | audiosSignalMapper->setMapping(act, i); | ||
88 | menuPlay->addAction(act); | ||
89 | actAudios[playmodes[i]] = act; | ||
90 | } | ||
91 | connect(audiosSignalMapper, SIGNAL(mapped(int)), SIGNAL(signalAudioStatusChanged(int))); | ||
92 | connect(this, SIGNAL(signalAudioStatusChanged(int)), drawer, SLOT(slotSetAudioStatus(int))); | ||
93 | actGroupAudios->setEnabled(false); | ||
94 | |||
95 | QList<QString> targets = drawer->getTargets(); | ||
96 | actGroupTargets = new QActionGroup(this); | ||
97 | targetsSignalMapper = new QSignalMapper(this); | ||
98 | |||
99 | for (int i=0;i<targets.size();i++) { | ||
100 | QAction *act = new QAction(targets[i],this); | ||
101 | act->setCheckable(true); | ||
102 | actGroupTargets->addAction(act); | ||
103 | connect(act,SIGNAL(triggered()),targetsSignalMapper,SLOT(map())); | ||
104 | targetsSignalMapper->setMapping(act, targets[i]); | ||
105 | menuTarget->addAction(act); | ||
106 | actTargets[targets[i]] = act; | ||
107 | } | ||
108 | connect(targetsSignalMapper, SIGNAL(mapped(const QString &)),this, SIGNAL(signalSetTarget(const QString &))); | ||
109 | connect(this, SIGNAL(signalSetTarget(const QString &)),this, SLOT(slotSetTarget(const QString &))); | ||
110 | } | ||
111 | |||
112 | void QWpsEditorWindow::slotWpsStateChanged(wpsstate) { | ||
113 | m_propertyEditor->updateObject(&wpsState); | ||
114 | m_propertyEditor->update(); | ||
115 | } | ||
116 | |||
117 | void QWpsEditorWindow::slotTrackStateChanged(trackstate) { | ||
118 | m_propertyEditor->updateObject(&trackState); | ||
119 | m_propertyEditor->update(); | ||
120 | } | ||
121 | |||
122 | void QWpsEditorWindow::slotOpenWps() { | ||
123 | QString wpsfile = QFileDialog::getOpenFileName(this, | ||
124 | tr("Open WPS"), "", tr("WPS Files (*.wps);; All Files (*.*)")); | ||
125 | if (wpsfile == "") { | ||
126 | DEBUGF1(tr("File wasn't chosen")); | ||
127 | return; | ||
128 | } | ||
129 | scrollingLine = -1; | ||
130 | drawer->WpsInit(wpsfile); | ||
131 | plainWpsEdit->textEdit()->clear(); | ||
132 | plainWpsEdit->textEdit()->append(drawer->wpsString()); | ||
133 | postWpsUpdate(); | ||
134 | } | ||
135 | |||
136 | void QWpsEditorWindow::logMsg(QString s) { | ||
137 | logEdit->append(s); | ||
138 | // check for error line: | ||
139 | if (s.contains("ERR: Failed parsing on line ")) { | ||
140 | QRegExp error("\\d+"); | ||
141 | if (error.indexIn(s) != -1) { | ||
142 | scrollingLine = error.cap(0).toInt(); | ||
143 | plainWpsEdit->markLine(scrollingLine); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | |||
148 | void QWpsEditorWindow::slotVerboseLevel() { | ||
149 | bool ok; | ||
150 | int i = QInputDialog::getInteger(this, tr("Set Verbose Level"),tr("Level:"), QWpsDrawer::api.verbose, 0, 3, 1, &ok); | ||
151 | if (ok) | ||
152 | QWpsDrawer::api.verbose = i; | ||
153 | } | ||
154 | |||
155 | void QWpsEditorWindow::slotUpdatePlainWps() { | ||
156 | DEBUGF1(tr("Updating WPS")); | ||
157 | scrollingLine = -1; | ||
158 | drawer->WpsInit(plainWpsEdit->textEdit()->toPlainText(),false); | ||
159 | postWpsUpdate(); | ||
160 | } | ||
161 | |||
162 | void QWpsEditorWindow::slotPlainDocModChanged(bool changed) { | ||
163 | if (changed) { | ||
164 | dockPlainWps->setWindowTitle(tr("PlainWps*")); | ||
165 | plainWpsEdit->markLine(-1); | ||
166 | } else { | ||
167 | dockPlainWps->setWindowTitle(tr("PlainWps")); | ||
168 | } | ||
169 | } | ||
170 | void QWpsEditorWindow::slotSetTarget(const QString & target) { | ||
171 | if (drawer->setTarget(target)) { | ||
172 | DEBUGF1(tr("New target <%1> switched").arg(target)); | ||
173 | actTargets[target]->setChecked(true); | ||
174 | } else | ||
175 | DEBUGF1(tr("ERR: Target <%1> failed!").arg(target)); | ||
176 | update(); | ||
177 | slotUpdatePlainWps(); | ||
178 | } | ||
179 | |||
180 | void QWpsEditorWindow::postWpsUpdate() { | ||
181 | m_propertyEditor->setEnabled(true); | ||
182 | actGroupAudios->setEnabled(true); | ||
183 | trackState.setAlbum(trackState.album()); ////updating property editor | ||
184 | plainWpsEdit->markLine(scrollingLine); | ||
185 | plainWpsEdit->textEdit()->document()->setModified(false); | ||
186 | plainWpsEdit->scrolltoLine(scrollingLine); | ||
187 | scrollingLine = -1; | ||
188 | } | ||
189 | |||
190 | |||
191 | |||
diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.h b/utils/wpseditor/gui/src/qwpseditorwindow.h deleted file mode 100644 index 0009548be2..0000000000 --- a/utils/wpseditor/gui/src/qwpseditorwindow.h +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef MAINWINDOWIMPL_H | ||
23 | #define MAINWINDOWIMPL_H | ||
24 | // | ||
25 | #include <QMainWindow> | ||
26 | #include <QActionGroup> | ||
27 | #include <QSignalMapper> | ||
28 | |||
29 | #include "wpsstate.h" | ||
30 | #include "ui_mainwindow.h" | ||
31 | #include "wpsstate.h" | ||
32 | #include "qwpsstate.h" | ||
33 | #include "qtrackstate.h" | ||
34 | #include "qwpsdrawer.h" | ||
35 | |||
36 | class QWpsEditorWindow : public QMainWindow, public Ui::MainWindow { | ||
37 | Q_OBJECT | ||
38 | |||
39 | QWpsState wpsState; | ||
40 | QTrackState trackState; | ||
41 | QPointer<QWpsDrawer> drawer; | ||
42 | |||
43 | QHash<int, QAction*> actAudios; | ||
44 | QActionGroup *actGroupAudios; | ||
45 | QSignalMapper *audiosSignalMapper; | ||
46 | |||
47 | QHash<QString,QAction *> actTargets; | ||
48 | QActionGroup *actGroupTargets; | ||
49 | QSignalMapper *targetsSignalMapper; | ||
50 | |||
51 | int scrollingLine; | ||
52 | protected: | ||
53 | void connectActions(); | ||
54 | void postWpsUpdate(); | ||
55 | public: | ||
56 | QWpsEditorWindow( QWidget * parent = 0, Qt::WFlags f = 0 ); | ||
57 | void logMsg(QString s); | ||
58 | private slots: | ||
59 | void slotOpenWps(); | ||
60 | void slotVerboseLevel(); | ||
61 | void slotWpsStateChanged(wpsstate); | ||
62 | void slotTrackStateChanged(trackstate); | ||
63 | |||
64 | void slotUpdatePlainWps(); | ||
65 | void slotPlainDocModChanged(bool m); | ||
66 | void slotSetTarget(const QString &); | ||
67 | |||
68 | signals: | ||
69 | void signalAudioStatusChanged(int); | ||
70 | void signalSetTarget(const QString &); | ||
71 | |||
72 | }; | ||
73 | #endif | ||
74 | |||
75 | |||
76 | |||
77 | |||
78 | |||
79 | |||
diff --git a/utils/wpseditor/gui/src/qwpsstate.cpp b/utils/wpseditor/gui/src/qwpsstate.cpp deleted file mode 100644 index 7afeee4332..0000000000 --- a/utils/wpseditor/gui/src/qwpsstate.cpp +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "qwpsstate.h" | ||
23 | |||
24 | QWpsState::QWpsState(): QObject() { | ||
25 | state.fontheight = 8; | ||
26 | state.fontwidth = 5; | ||
27 | state.volume = -30; | ||
28 | state.battery_level = 50; | ||
29 | |||
30 | } | ||
31 | |||
32 | void QWpsState::setFontHeight(int val) { | ||
33 | state.fontheight = val; | ||
34 | emit stateChanged(state); | ||
35 | } | ||
36 | |||
37 | void QWpsState::setFontWidth(int val) { | ||
38 | state.fontwidth = val; | ||
39 | emit stateChanged(state); | ||
40 | } | ||
41 | |||
42 | void QWpsState::setVolume(int val) { | ||
43 | state.volume = val; | ||
44 | emit stateChanged(state); | ||
45 | } | ||
46 | |||
47 | void QWpsState::setBattery(int val) { | ||
48 | state.battery_level = val; | ||
49 | emit stateChanged(state); | ||
50 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpsstate.h b/utils/wpseditor/gui/src/qwpsstate.h deleted file mode 100644 index 4e250079da..0000000000 --- a/utils/wpseditor/gui/src/qwpsstate.h +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __WPSSTATE_H__ | ||
23 | #define __WPSSTATE_H__ | ||
24 | |||
25 | #include <QObject> | ||
26 | #include "wpsstate.h" | ||
27 | |||
28 | class QWpsState : public QObject { | ||
29 | Q_OBJECT | ||
30 | |||
31 | |||
32 | Q_CLASSINFO("QWpsState", "WPS State"); | ||
33 | Q_PROPERTY(int FontHeight READ fontHeight WRITE setFontHeight DESIGNABLE true USER true) | ||
34 | Q_CLASSINFO("FontHeight", "minimum=6;maximum=20;value=10"); | ||
35 | Q_PROPERTY(int FontWidth READ fontWidth WRITE setFontWidth DESIGNABLE true USER true) | ||
36 | Q_CLASSINFO("FontWidth", "minimum=4;maximum=20;value=8"); | ||
37 | Q_PROPERTY(int Volume READ volume WRITE setVolume DESIGNABLE true USER true) | ||
38 | Q_CLASSINFO("Volume", "minimum=-74;maximum=24;value=-15"); | ||
39 | Q_PROPERTY(int Battery READ battery WRITE setBattery DESIGNABLE true USER true) | ||
40 | Q_CLASSINFO("Battery", "minimum=0;maximum=100;value=50"); | ||
41 | |||
42 | wpsstate state; | ||
43 | |||
44 | public: | ||
45 | QWpsState(); | ||
46 | |||
47 | int fontHeight() const { | ||
48 | return state.fontheight; | ||
49 | } | ||
50 | void setFontHeight(int val); | ||
51 | |||
52 | int fontWidth() const { | ||
53 | return state.fontwidth; | ||
54 | } | ||
55 | void setFontWidth(int val); | ||
56 | |||
57 | int battery() const { | ||
58 | return state.battery_level; | ||
59 | } | ||
60 | void setBattery(int val); | ||
61 | |||
62 | int volume() const { | ||
63 | return state.volume; | ||
64 | } | ||
65 | public slots: | ||
66 | void setVolume(int val); | ||
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||
72 | signals: | ||
73 | void stateChanged ( wpsstate state ); | ||
74 | }; | ||
75 | #endif // __WPSSTATE_H__ | ||
diff --git a/utils/wpseditor/gui/src/slider.cpp b/utils/wpseditor/gui/src/slider.cpp deleted file mode 100644 index 32b79f5047..0000000000 --- a/utils/wpseditor/gui/src/slider.cpp +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "slider.h" | ||
23 | #include <QDebug> | ||
24 | // | ||
25 | Slider::Slider(QWidget *parent, QString caption, int min, int max ):QDialog(parent),mCaption(caption) { | ||
26 | setupUi ( this ); | ||
27 | connect(horslider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); | ||
28 | connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int))); | ||
29 | setWindowTitle(mCaption); | ||
30 | horslider->setMinimum(min); | ||
31 | horslider->setMaximum(max); | ||
32 | } | ||
33 | // | ||
34 | int Slider::value() { | ||
35 | return horslider->value(); | ||
36 | } | ||
37 | void Slider::slotValueChanged(int step) { | ||
38 | setWindowTitle(tr("%1 = %2 ").arg(mCaption).arg(step)); | ||
39 | } | ||
40 | |||
41 | |||
42 | |||
diff --git a/utils/wpseditor/gui/src/slider.h b/utils/wpseditor/gui/src/slider.h deleted file mode 100644 index 5ece49d596..0000000000 --- a/utils/wpseditor/gui/src/slider.h +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef SLIDERIMPL_H | ||
23 | #define SLIDERIMPL_H | ||
24 | // | ||
25 | #include <QWidget> | ||
26 | #include <QDialog> | ||
27 | #include "ui_slider.h" | ||
28 | // | ||
29 | class Slider : public QDialog , Ui::slider { | ||
30 | Q_OBJECT | ||
31 | QString mCaption; | ||
32 | public slots: | ||
33 | void slotValueChanged(int step); | ||
34 | signals: | ||
35 | void valueChanged(int); | ||
36 | public: | ||
37 | Slider(QWidget *parent, QString caption, int min, int max ); | ||
38 | int value(); | ||
39 | |||
40 | |||
41 | |||
42 | }; | ||
43 | #endif | ||
diff --git a/utils/wpseditor/gui/src/utils.cpp b/utils/wpseditor/gui/src/utils.cpp deleted file mode 100644 index 74e4c907c8..0000000000 --- a/utils/wpseditor/gui/src/utils.cpp +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "utils.h" | ||
23 | #include <QPointer> | ||
24 | #include <QtGlobal> | ||
25 | #include "qwpseditorwindow.h" | ||
26 | |||
27 | extern QPointer<QWpsEditorWindow> win; | ||
28 | |||
29 | int qlogger(const char* fmt,...) { | ||
30 | va_list ap; | ||
31 | va_start(ap, fmt); | ||
32 | QString s; | ||
33 | s.vsprintf(fmt,ap); | ||
34 | va_end(ap); | ||
35 | s.replace("\n",""); | ||
36 | //qDebug()<<s; | ||
37 | if (win==0) | ||
38 | qDebug()<<s; | ||
39 | if (s.indexOf("ERR")>=0) | ||
40 | s = "<font color=red>"+s+"</font>"; | ||
41 | if (win!=0) | ||
42 | win->logMsg(s); | ||
43 | return s.length(); | ||
44 | } | ||
45 | |||
46 | int qlogger(const QString& s) { | ||
47 | return qlogger(s.toAscii().data()); | ||
48 | } | ||
diff --git a/utils/wpseditor/gui/src/utils.h b/utils/wpseditor/gui/src/utils.h deleted file mode 100644 index 144f9f0f0b..0000000000 --- a/utils/wpseditor/gui/src/utils.h +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __UTILS_H__ | ||
23 | #define __UTILS_H__ | ||
24 | |||
25 | #include <QDebug> | ||
26 | |||
27 | #define DEBUGF1 qlogger | ||
28 | #define DEBUGF2(...) | ||
29 | #define DEBUGF3 qDebug | ||
30 | |||
31 | extern int qlogger(const char* fmt,...); | ||
32 | extern int qlogger(const QString& s); | ||
33 | |||
34 | #endif // __UTILS_H__ | ||
diff --git a/utils/wpseditor/gui/ui/mainwindow.ui b/utils/wpseditor/gui/ui/mainwindow.ui deleted file mode 100644 index a14eb832ad..0000000000 --- a/utils/wpseditor/gui/ui/mainwindow.ui +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>MainWindow</class> | ||
3 | <widget class="QMainWindow" name="MainWindow" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>882</width> | ||
9 | <height>669</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>WPS Editor</string> | ||
14 | </property> | ||
15 | <widget class="QWidget" name="centralwidget" /> | ||
16 | <widget class="QMenuBar" name="menubar" > | ||
17 | <property name="geometry" > | ||
18 | <rect> | ||
19 | <x>0</x> | ||
20 | <y>0</y> | ||
21 | <width>882</width> | ||
22 | <height>21</height> | ||
23 | </rect> | ||
24 | </property> | ||
25 | <widget class="QMenu" name="menuFile" > | ||
26 | <property name="title" > | ||
27 | <string>File</string> | ||
28 | </property> | ||
29 | <addaction name="actOpenWps" /> | ||
30 | <addaction name="actSetVolume" /> | ||
31 | <addaction name="actSetProgress" /> | ||
32 | <addaction name="actShowGrid" /> | ||
33 | <addaction name="actClearLog" /> | ||
34 | <addaction name="actVerboseLevel" /> | ||
35 | <addaction name="actQuit" /> | ||
36 | </widget> | ||
37 | <widget class="QMenu" name="menuPlay" > | ||
38 | <property name="title" > | ||
39 | <string>Play</string> | ||
40 | </property> | ||
41 | </widget> | ||
42 | <widget class="QMenu" name="menuTarget" > | ||
43 | <property name="title" > | ||
44 | <string>Target</string> | ||
45 | </property> | ||
46 | </widget> | ||
47 | <addaction name="menuFile" /> | ||
48 | <addaction name="menuPlay" /> | ||
49 | <addaction name="menuTarget" /> | ||
50 | </widget> | ||
51 | <widget class="QStatusBar" name="statusbar" /> | ||
52 | <widget class="QDockWidget" name="dockPlainWps" > | ||
53 | <property name="minimumSize" > | ||
54 | <size> | ||
55 | <width>0</width> | ||
56 | <height>30</height> | ||
57 | </size> | ||
58 | </property> | ||
59 | <property name="windowTitle" > | ||
60 | <string>PlainWps</string> | ||
61 | </property> | ||
62 | <attribute name="dockWidgetArea" > | ||
63 | <number>8</number> | ||
64 | </attribute> | ||
65 | <widget class="QWidget" name="dockWidgetContents_3" > | ||
66 | <layout class="QGridLayout" name="gridLayout_2" > | ||
67 | <item row="0" column="1" > | ||
68 | <widget class="QPushButton" name="btnUpdatePlainWps" > | ||
69 | <property name="text" > | ||
70 | <string>Update WPS</string> | ||
71 | </property> | ||
72 | </widget> | ||
73 | </item> | ||
74 | <item row="1" column="1" > | ||
75 | <spacer name="verticalSpacer" > | ||
76 | <property name="orientation" > | ||
77 | <enum>Qt::Vertical</enum> | ||
78 | </property> | ||
79 | <property name="sizeHint" stdset="0" > | ||
80 | <size> | ||
81 | <width>20</width> | ||
82 | <height>211</height> | ||
83 | </size> | ||
84 | </property> | ||
85 | </spacer> | ||
86 | </item> | ||
87 | <item rowspan="2" row="0" column="0" > | ||
88 | <widget class="NumberedTextView" name="plainWpsEdit" > | ||
89 | <property name="sizePolicy" > | ||
90 | <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > | ||
91 | <horstretch>2</horstretch> | ||
92 | <verstretch>0</verstretch> | ||
93 | </sizepolicy> | ||
94 | </property> | ||
95 | <property name="frameShape" > | ||
96 | <enum>QFrame::StyledPanel</enum> | ||
97 | </property> | ||
98 | <property name="frameShadow" > | ||
99 | <enum>QFrame::Raised</enum> | ||
100 | </property> | ||
101 | </widget> | ||
102 | </item> | ||
103 | </layout> | ||
104 | </widget> | ||
105 | </widget> | ||
106 | <widget class="QDockWidget" name="m_dockWidget" > | ||
107 | <property name="windowTitle" > | ||
108 | <string>Property Editor</string> | ||
109 | </property> | ||
110 | <attribute name="dockWidgetArea" > | ||
111 | <number>1</number> | ||
112 | </attribute> | ||
113 | <widget class="QPropertyEditorWidget" name="m_propertyEditor" > | ||
114 | <property name="enabled" > | ||
115 | <bool>false</bool> | ||
116 | </property> | ||
117 | </widget> | ||
118 | </widget> | ||
119 | <widget class="QDockWidget" name="dockWidget" > | ||
120 | <property name="minimumSize" > | ||
121 | <size> | ||
122 | <width>0</width> | ||
123 | <height>30</height> | ||
124 | </size> | ||
125 | </property> | ||
126 | <property name="windowTitle" > | ||
127 | <string>Log</string> | ||
128 | </property> | ||
129 | <attribute name="dockWidgetArea" > | ||
130 | <number>2</number> | ||
131 | </attribute> | ||
132 | <widget class="QWidget" name="dockWidgetContents" > | ||
133 | <layout class="QGridLayout" name="gridLayout" > | ||
134 | <item row="0" column="0" > | ||
135 | <widget class="QTextEdit" name="logEdit" > | ||
136 | <property name="autoFillBackground" > | ||
137 | <bool>false</bool> | ||
138 | </property> | ||
139 | <property name="readOnly" > | ||
140 | <bool>true</bool> | ||
141 | </property> | ||
142 | </widget> | ||
143 | </item> | ||
144 | </layout> | ||
145 | </widget> | ||
146 | </widget> | ||
147 | <action name="actQuit" > | ||
148 | <property name="text" > | ||
149 | <string>Quit</string> | ||
150 | </property> | ||
151 | </action> | ||
152 | <action name="actOpenWps" > | ||
153 | <property name="text" > | ||
154 | <string>Open WPS</string> | ||
155 | </property> | ||
156 | </action> | ||
157 | <action name="actSetVolume" > | ||
158 | <property name="text" > | ||
159 | <string>Set Volume</string> | ||
160 | </property> | ||
161 | </action> | ||
162 | <action name="actSetProgress" > | ||
163 | <property name="text" > | ||
164 | <string>Set Progress</string> | ||
165 | </property> | ||
166 | </action> | ||
167 | <action name="actShowGrid" > | ||
168 | <property name="checkable" > | ||
169 | <bool>true</bool> | ||
170 | </property> | ||
171 | <property name="checked" > | ||
172 | <bool>false</bool> | ||
173 | </property> | ||
174 | <property name="text" > | ||
175 | <string>Show Grid</string> | ||
176 | </property> | ||
177 | </action> | ||
178 | <action name="actClearLog" > | ||
179 | <property name="text" > | ||
180 | <string>Clear Log</string> | ||
181 | </property> | ||
182 | </action> | ||
183 | <action name="actVerboseLevel" > | ||
184 | <property name="text" > | ||
185 | <string>Verbose Level</string> | ||
186 | </property> | ||
187 | </action> | ||
188 | <action name="actUpdatePlainWps" > | ||
189 | <property name="text" > | ||
190 | <string>Update WPS</string> | ||
191 | </property> | ||
192 | </action> | ||
193 | </widget> | ||
194 | <customwidgets> | ||
195 | <customwidget> | ||
196 | <class>QPropertyEditorWidget</class> | ||
197 | <extends>QTreeView</extends> | ||
198 | <header>QPropertyEditorWidget.h</header> | ||
199 | </customwidget> | ||
200 | <customwidget> | ||
201 | <class>NumberedTextView</class> | ||
202 | <extends>QFrame</extends> | ||
203 | <header>numberedtextview.h</header> | ||
204 | <container>1</container> | ||
205 | </customwidget> | ||
206 | </customwidgets> | ||
207 | <resources/> | ||
208 | <connections> | ||
209 | <connection> | ||
210 | <sender>btnUpdatePlainWps</sender> | ||
211 | <signal>clicked()</signal> | ||
212 | <receiver>actUpdatePlainWps</receiver> | ||
213 | <slot>trigger()</slot> | ||
214 | <hints> | ||
215 | <hint type="sourcelabel" > | ||
216 | <x>835</x> | ||
217 | <y>411</y> | ||
218 | </hint> | ||
219 | <hint type="destinationlabel" > | ||
220 | <x>-1</x> | ||
221 | <y>-1</y> | ||
222 | </hint> | ||
223 | </hints> | ||
224 | </connection> | ||
225 | <connection> | ||
226 | <sender>actQuit</sender> | ||
227 | <signal>triggered()</signal> | ||
228 | <receiver>MainWindow</receiver> | ||
229 | <slot>close()</slot> | ||
230 | <hints> | ||
231 | <hint type="sourcelabel" > | ||
232 | <x>-1</x> | ||
233 | <y>-1</y> | ||
234 | </hint> | ||
235 | <hint type="destinationlabel" > | ||
236 | <x>440</x> | ||
237 | <y>334</y> | ||
238 | </hint> | ||
239 | </hints> | ||
240 | </connection> | ||
241 | </connections> | ||
242 | </ui> | ||
diff --git a/utils/wpseditor/gui/ui/slider.ui b/utils/wpseditor/gui/ui/slider.ui deleted file mode 100644 index 24fff0bf23..0000000000 --- a/utils/wpseditor/gui/ui/slider.ui +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>slider</class> | ||
3 | <widget class="QWidget" name="slider" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>295</width> | ||
9 | <height>37</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Value</string> | ||
14 | </property> | ||
15 | <widget class="QSlider" name="horslider" > | ||
16 | <property name="geometry" > | ||
17 | <rect> | ||
18 | <x>0</x> | ||
19 | <y>10</y> | ||
20 | <width>291</width> | ||
21 | <height>21</height> | ||
22 | </rect> | ||
23 | </property> | ||
24 | <property name="minimum" > | ||
25 | <number>-78</number> | ||
26 | </property> | ||
27 | <property name="maximum" > | ||
28 | <number>24</number> | ||
29 | </property> | ||
30 | <property name="singleStep" > | ||
31 | <number>1</number> | ||
32 | </property> | ||
33 | <property name="value" > | ||
34 | <number>-78</number> | ||
35 | </property> | ||
36 | <property name="orientation" > | ||
37 | <enum>Qt::Horizontal</enum> | ||
38 | </property> | ||
39 | </widget> | ||
40 | </widget> | ||
41 | <resources/> | ||
42 | <connections/> | ||
43 | </ui> | ||
diff --git a/utils/wpseditor/libwps/Makefile b/utils/wpseditor/libwps/Makefile deleted file mode 100644 index e74e26701b..0000000000 --- a/utils/wpseditor/libwps/Makefile +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | ROOT=../../.. | ||
10 | |||
11 | ifneq ($or($(findstring MINGW,$(shell uname)),$(findstring Windows_NT,$(OS))),) | ||
12 | OS = w32 | ||
13 | CC = mingw32-gcc | ||
14 | COPY = copy /Y | ||
15 | COPY_TO = ..\\gui\\bin | ||
16 | RM = del | ||
17 | EXT = .dll | ||
18 | LDFLAGS = -DBUILD_DLL | ||
19 | endif | ||
20 | |||
21 | ifeq ($(findstring Linux,$(shell uname)),Linux) | ||
22 | OS = linux | ||
23 | CC = gcc | ||
24 | COPY = cp -f | ||
25 | COPY_TO = ../gui/bin | ||
26 | RM = rm -f | ||
27 | EXT = .so | ||
28 | LDFLAGS = -fPIC | ||
29 | endif | ||
30 | |||
31 | TARGETS=IRIVER_H10 \ | ||
32 | IRIVER_H10_5GB \ | ||
33 | IPOD_COLOR \ | ||
34 | IPOD_NANO \ | ||
35 | IPOD_VIDEO \ | ||
36 | IPOD_3G \ | ||
37 | IPOD_4G \ | ||
38 | IPOD_MINI \ | ||
39 | IPOD_MINI2G \ | ||
40 | IPOD_1G2G \ | ||
41 | GIGABEAT_F \ | ||
42 | GIGABEAT_S \ | ||
43 | SANSA_E200 \ | ||
44 | SANSA_C200 \ | ||
45 | IRIVER_H100 \ | ||
46 | IRIVER_H120 \ | ||
47 | IRIVER_H300 \ | ||
48 | IAUDIO_X5 \ | ||
49 | IAUDIO_M5 \ | ||
50 | IAUDIO_M3 \ | ||
51 | |||
52 | SOURCES= \ | ||
53 | src/api.c \ | ||
54 | src/dummies.c \ | ||
55 | src/lcd.c \ | ||
56 | src/proxy.c \ | ||
57 | $(ROOT)/apps/gui/scrollbar.c \ | ||
58 | $(ROOT)/apps/gui/music_screen.c \ | ||
59 | $(ROOT)/apps/gui/wps_engine/wps_display.c \ | ||
60 | $(ROOT)/apps/gui/wps_engine/wps_tokens.c \ | ||
61 | $(ROOT)/apps/gui/wps_engine/wps_parser.c \ | ||
62 | $(ROOT)/apps/gui/wps_parser/wps_debug.c \ | ||
63 | $(ROOT)/apps/recorder/peakmeter.c \ | ||
64 | $(ROOT)/apps/recorder/icons.c \ | ||
65 | $(ROOT)/apps/misc.c \ | ||
66 | $(ROOT)/apps/status.c \ | ||
67 | $(ROOT)/firmware/common/ctype.c \ | ||
68 | $(ROOT)/firmware/common/timefuncs.c \ | ||
69 | $(ROOT)/firmware/common/unicode.c \ | ||
70 | $(ROOT)/firmware/font.c \ | ||
71 | $(ROOT)/firmware/font_cache.c \ | ||
72 | $(ROOT)/firmware/id3.c \ | ||
73 | $(ROOT)/firmware/lru.c \ | ||
74 | $(ROOT)/firmware/mp3data.c \ | ||
75 | $(ROOT)/firmware/replaygain.c | ||
76 | # $(ROOT)/apps/recorder/bmp.c | ||
77 | # $(ROOT)/apps/abrepeat.c \ | ||
78 | # $(ROOT)/apps/action.c \ | ||
79 | # $(ROOT)/apps/cuesheet.c \ | ||
80 | # $(ROOT)/apps/gui/statusbar.c \ | ||
81 | # $(ROOT)/apps/gui/gwps.c \ | ||
82 | |||
83 | INCLUDE=-I src/include \ | ||
84 | -I $(ROOT)/apps/gui \ | ||
85 | -I $(ROOT)/firmware/export \ | ||
86 | -I $(ROOT)/firmware/include \ | ||
87 | -I $(ROOT)/apps/recorder \ | ||
88 | -I $(ROOT)/apps \ | ||
89 | -I src | ||
90 | |||
91 | CFLAGS = -g -Wall -Wno-format -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE | ||
92 | |||
93 | RESULTS := $(patsubst %,libwps_%$(EXT),$(TARGETS)) | ||
94 | |||
95 | all: $(RESULTS) | ||
96 | |||
97 | libwps_%$(EXT): $(SOURCES) | ||
98 | @echo CC [$(subst libwps_,,$(subst $(EXT),,$@))] | ||
99 | @$(CC) $(INCLUDE) $(CFLAGS) -D$(subst libwps_,,$(subst $(EXT),,$@)) $(LDFLAGS) -shared -o $@ $+ | ||
100 | @$(COPY) $@ $(COPY_TO) | ||
101 | |||
102 | clean: | ||
103 | $(RM) $(RESULTS) | ||
diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c deleted file mode 100644 index f926f8bd90..0000000000 --- a/utils/wpseditor/libwps/src/api.c +++ /dev/null | |||
@@ -1,289 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include "sound.h" | ||
25 | #include "api.h" | ||
26 | #include "proxy.h" | ||
27 | #include "dummies.h" | ||
28 | #include "scroll_engine.h" | ||
29 | #include "wpsstate.h" | ||
30 | #include <string.h> | ||
31 | |||
32 | struct proxy_api *xapi; | ||
33 | |||
34 | void get_current_vp(struct viewport_api *avp); | ||
35 | /************************************************************* | ||
36 | |||
37 | *************************************************************/ | ||
38 | #ifdef HAVE_LCD_BITMAP | ||
39 | void screen_clear_area(struct screen * display, int xstart, int ystart, | ||
40 | int width, int height) { | ||
41 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
42 | display->fillrect(xstart, ystart, width, height); | ||
43 | display->set_drawmode(DRMODE_SOLID); | ||
44 | } | ||
45 | #endif | ||
46 | |||
47 | bool load_wps_backdrop(char* filename) { | ||
48 | return xapi->load_wps_backdrop(filename); | ||
49 | } | ||
50 | |||
51 | bool load_remote_wps_backdrop(char* filename) { | ||
52 | return xapi->load_remote_wps_backdrop(filename); | ||
53 | } | ||
54 | |||
55 | int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { | ||
56 | if (!xapi->read_bmp_file) { | ||
57 | DEBUGF1("can't read bmp file! NULL api!\n"); | ||
58 | return -1; | ||
59 | } | ||
60 | bm->format = 3;//FORMAT_ANY? | ||
61 | bm->data = (unsigned char*)malloc(255); | ||
62 | memset(bm->data,0,255); | ||
63 | strcpy((char*)bm->data,filename); | ||
64 | //bm->data[strlen(filename)] = '\0'; | ||
65 | xapi->read_bmp_file(filename,&bm->width, &bm->height); | ||
66 | return 1; | ||
67 | } | ||
68 | |||
69 | bool load_wps_backdrop2(char* filename) { | ||
70 | DEBUGF1("load_wps_backdrop(char* filename='%s')",filename); | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | bool load_remote_wps_backdrop2(char* filename) { | ||
75 | DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename); | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | void stop_scroll() { | ||
80 | DEBUGF3("stop_scroll\n"); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | void puts_scroll(int x, int y, const unsigned char *string) { | ||
85 | DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string); | ||
86 | } | ||
87 | |||
88 | void putsxy(int x, int y, const unsigned char *str) { | ||
89 | DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str); | ||
90 | } | ||
91 | |||
92 | void lcd_update() { | ||
93 | DEBUGF3("update\n"); | ||
94 | } | ||
95 | |||
96 | void clear_viewport(int x, int y, int w, int h, int color) { | ||
97 | DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color); | ||
98 | }; | ||
99 | |||
100 | int getstringsize(const unsigned char *str, int *w, int *h) { | ||
101 | //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h); | ||
102 | *w=strlen((char*)str)*sysfont.maxwidth; | ||
103 | *h=sysfont.height; | ||
104 | return 1; | ||
105 | } | ||
106 | |||
107 | void set_wpsstate(struct wpsstate state) { | ||
108 | sysfont.height = state.fontheight; | ||
109 | sysfont.maxwidth = state.fontwidth; | ||
110 | global_settings.volume = state.volume; | ||
111 | battery_percent = state.battery_level; | ||
112 | _audio_status = state.audio_status; | ||
113 | } | ||
114 | |||
115 | void set_trackstate(struct trackstate state) { | ||
116 | if (!(gui_wps[0].state) || | ||
117 | !(gui_wps[0].state->id3)) | ||
118 | return; | ||
119 | gui_wps[0].state->id3->title = state.title; | ||
120 | gui_wps[0].state->id3->artist = state.artist; | ||
121 | gui_wps[0].state->id3->album = state.album; | ||
122 | gui_wps[0].state->id3->elapsed = state.elapsed; | ||
123 | gui_wps[0].state->id3->length = state.length; | ||
124 | } | ||
125 | |||
126 | void set_next_trackstate(struct trackstate state) { | ||
127 | gui_wps[0].state->nid3->title = state.title; | ||
128 | gui_wps[0].state->nid3->artist = state.artist; | ||
129 | gui_wps[0].state->nid3->album = state.album; | ||
130 | gui_wps[0].state->nid3->elapsed = state.elapsed; | ||
131 | gui_wps[0].state->nid3->length = state.length; | ||
132 | } | ||
133 | |||
134 | enum api_playmode playmodes[PLAYMODES_NUM] = { | ||
135 | API_STATUS_PLAY, | ||
136 | API_STATUS_STOP, | ||
137 | API_STATUS_PAUSE, | ||
138 | API_STATUS_FASTFORWARD, | ||
139 | API_STATUS_FASTBACKWARD | ||
140 | }; | ||
141 | |||
142 | const char *playmodeNames[] = { | ||
143 | "Play", "Stop", "Pause", "FastForward", "FastBackward" | ||
144 | }; | ||
145 | |||
146 | |||
147 | void set_audio_status(int status) { | ||
148 | DEBUGF1("%s",playmodeNames[status]); | ||
149 | switch (status) { | ||
150 | case API_STATUS_PLAY: | ||
151 | _audio_status = AUDIO_STATUS_PLAY; | ||
152 | status_set_ffmode(STATUS_PLAY); | ||
153 | break; | ||
154 | case API_STATUS_STOP: | ||
155 | _audio_status = 0; | ||
156 | status_set_ffmode(STATUS_STOP); | ||
157 | break; | ||
158 | case API_STATUS_PAUSE: | ||
159 | _audio_status = AUDIO_STATUS_PAUSE; | ||
160 | status_set_ffmode(STATUS_PLAY); | ||
161 | break; | ||
162 | case API_STATUS_FASTFORWARD: | ||
163 | status_set_ffmode(STATUS_FASTFORWARD); | ||
164 | break; | ||
165 | case API_STATUS_FASTBACKWARD: | ||
166 | status_set_ffmode(STATUS_FASTBACKWARD); | ||
167 | break; | ||
168 | default: | ||
169 | DEBUGF1("ERR: Unknown status"); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | void test_api(struct proxy_api *api) { | ||
174 | if (!api->stop_scroll) | ||
175 | api->stop_scroll=stop_scroll; | ||
176 | if (!api->set_viewport) | ||
177 | api->set_viewport=lcd_set_viewport; | ||
178 | if (!api->clear_viewport) | ||
179 | api->clear_viewport=clear_viewport; | ||
180 | if (!api->getstringsize) | ||
181 | api->getstringsize=getstringsize; | ||
182 | if (!api->getwidth) | ||
183 | api->getwidth=lcd_getwidth; | ||
184 | if (!api->getheight) | ||
185 | api->getheight=lcd_getheight; | ||
186 | if (!api->set_drawmode) | ||
187 | api->set_drawmode=lcd_set_drawmode; | ||
188 | if (!api->puts_scroll) | ||
189 | api->puts_scroll=puts_scroll; | ||
190 | if (!api->update) | ||
191 | api->update=lcd_update; | ||
192 | if (!api->clear_display) | ||
193 | api->clear_display=lcd_clear_display; | ||
194 | if (!api->getfont) | ||
195 | api->getfont=lcd_getfont; | ||
196 | if (!api->putsxy) | ||
197 | api->putsxy=putsxy; | ||
198 | |||
199 | #if LCD_DEPTH > 1 | ||
200 | if (!api->get_foreground) | ||
201 | api->get_foreground=lcd_get_foreground; | ||
202 | if (!api->get_background) | ||
203 | api->get_background=lcd_get_background; | ||
204 | #endif | ||
205 | if (!api->load_remote_wps_backdrop) | ||
206 | api->load_remote_wps_backdrop = load_remote_wps_backdrop2; | ||
207 | if (!api->load_wps_backdrop) | ||
208 | api->load_wps_backdrop = load_wps_backdrop2; | ||
209 | //dbgf = printf; | ||
210 | } | ||
211 | |||
212 | /************************************************************** | ||
213 | |||
214 | **************************************************************/ | ||
215 | |||
216 | int set_api(struct proxy_api* api) { | ||
217 | if (api->debugf) | ||
218 | dbgf = api->debugf; | ||
219 | screens[0].screen_type=SCREEN_MAIN; | ||
220 | screens[0].lcdwidth=LCD_WIDTH; | ||
221 | screens[0].lcdheight=LCD_HEIGHT; | ||
222 | screens[0].depth=LCD_DEPTH; | ||
223 | #ifdef HAVE_LCD_COLOR | ||
224 | screens[0].is_color=true; | ||
225 | #else | ||
226 | screens[0].is_color=false; | ||
227 | #endif | ||
228 | if (api->stop_scroll) | ||
229 | screens[0].stop_scroll=api->stop_scroll; | ||
230 | screens[0].scroll_stop = lcd_scroll_stop; | ||
231 | if (api->set_viewport) | ||
232 | screens[0].set_viewport=api->set_viewport; | ||
233 | if (api->clear_viewport) | ||
234 | screens[0].clear_viewport=lcd_clear_viewport; | ||
235 | if (api->getstringsize) | ||
236 | screens[0].getstringsize=api->getstringsize; | ||
237 | if (api->getwidth) | ||
238 | screens[0].getwidth=api->getwidth; | ||
239 | if (api->getheight) | ||
240 | screens[0].getheight=api->getheight; | ||
241 | if (api->set_drawmode) | ||
242 | screens[0].set_drawmode=api->set_drawmode; | ||
243 | if (api->fillrect) | ||
244 | screens[0].fillrect=api->fillrect; | ||
245 | if (api->puts_scroll) | ||
246 | screens[0].puts_scroll=api->puts_scroll; | ||
247 | if (api->transparent_bitmap_part) | ||
248 | screens[0].transparent_bitmap_part=api->transparent_bitmap_part; | ||
249 | if (api->update) | ||
250 | screens[0].update=api->update; | ||
251 | if (api->clear_display) | ||
252 | screens[0].clear_display=api->clear_display; | ||
253 | if (api->getfont) | ||
254 | screens[0].getfont=api->getfont; | ||
255 | if (api->hline) | ||
256 | screens[0].hline=api->hline; | ||
257 | if (api->vline) | ||
258 | screens[0].vline=api->vline; | ||
259 | if (api->drawpixel) | ||
260 | screens[0].drawpixel=api->drawpixel; | ||
261 | if (api->putsxy) | ||
262 | screens[0].putsxy=api->putsxy; | ||
263 | #if LCD_DEPTH > 1 | ||
264 | if (api->get_foreground) | ||
265 | screens[0].get_foreground=api->get_foreground; | ||
266 | if (api->get_background) | ||
267 | screens[0].get_background=api->get_background; | ||
268 | #endif | ||
269 | |||
270 | screens[0].bitmap_part = api->bitmap_part; | ||
271 | /************************** | ||
272 | * OUT * | ||
273 | **************************/ | ||
274 | api->get_model_name = get_model_name; | ||
275 | api->get_current_vp = get_current_vp; | ||
276 | api->set_wpsstate = set_wpsstate; | ||
277 | api->set_trackstate = set_trackstate; | ||
278 | api->set_next_trackstate= set_next_trackstate; | ||
279 | api->set_audio_status= set_audio_status; | ||
280 | xapi = api; | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||
diff --git a/utils/wpseditor/libwps/src/api.h b/utils/wpseditor/libwps/src/api.h deleted file mode 100644 index 3fa351609f..0000000000 --- a/utils/wpseditor/libwps/src/api.h +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef API_H_INCLUDED | ||
23 | #define API_H_INCLUDED | ||
24 | #include <stdbool.h> | ||
25 | #include <stddef.h> | ||
26 | #include "defs.h" | ||
27 | #include "wpsstate.h" | ||
28 | #ifdef __PCTOOL__ | ||
29 | #include "dummies.h" | ||
30 | #endif | ||
31 | |||
32 | struct viewport_api { | ||
33 | int x; | ||
34 | int y; | ||
35 | int width; | ||
36 | int height; | ||
37 | int font; | ||
38 | int drawmode; | ||
39 | unsigned fg_pattern; | ||
40 | unsigned bg_pattern; | ||
41 | unsigned lss_pattern; | ||
42 | unsigned lse_pattern; | ||
43 | unsigned lst_pattern; | ||
44 | |||
45 | //TODO: ?? | ||
46 | int fontheight; | ||
47 | int fontwidth; | ||
48 | }; | ||
49 | |||
50 | struct proxy_api | ||
51 | { | ||
52 | bool (*load_remote_wps_backdrop)(char* file_name); | ||
53 | bool (*load_wps_backdrop)(char* file_name); | ||
54 | |||
55 | unsigned (*get_foreground)(void); | ||
56 | unsigned (*get_background)(void); | ||
57 | int (*getwidth)(void); | ||
58 | int (*getheight)(void); | ||
59 | |||
60 | void (*puts_scroll)(int x, int y, const unsigned char *string); | ||
61 | void (*putsxy)(int x, int y, const unsigned char *str); | ||
62 | int (*getfont)(); | ||
63 | int (*getstringsize)(const unsigned char *str, int *w, int *h); | ||
64 | void (*stop_scroll)(); | ||
65 | |||
66 | void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, | ||
67 | int stride, int x, int y, int width, int height); | ||
68 | void (*bitmap_part)(const void *src, int src_x, int src_y, | ||
69 | int stride, int x, int y, int width, int height); | ||
70 | void (*hline)(int x1, int x2, int y); | ||
71 | void (*vline)(int x, int y1, int y2); | ||
72 | void (*drawpixel)(int x, int y); | ||
73 | void (*set_drawmode)(int mode); | ||
74 | void (*fillrect)(int x, int y, int width, int height); | ||
75 | |||
76 | |||
77 | void (*update)(); | ||
78 | void (*set_viewport)(struct viewport* vp); | ||
79 | void (*clear_display)(void); | ||
80 | void (*clear_viewport)(int x,int y,int w,int h, int color); | ||
81 | |||
82 | void* (*plugin_get_buffer)(size_t *buffer_size); | ||
83 | int (*read_bmp_file)(const char* filename,int *width, int *height); | ||
84 | void (*set_wpsstate)(struct wpsstate state); | ||
85 | void (*set_trackstate)(struct trackstate state); | ||
86 | void (*set_next_trackstate)(struct trackstate state); | ||
87 | void (*set_audio_status)(int status); | ||
88 | |||
89 | pfdebugf debugf; | ||
90 | int verbose; | ||
91 | |||
92 | |||
93 | /************************** | ||
94 | * OUT * | ||
95 | **************************/ | ||
96 | const char* (*get_model_name)(); | ||
97 | void (*get_current_vp)(struct viewport_api *avp); | ||
98 | |||
99 | |||
100 | }; | ||
101 | |||
102 | extern struct proxy_api *xapi; | ||
103 | |||
104 | EXPORT int set_api(struct proxy_api* api); | ||
105 | |||
106 | #endif // API_H_INCLUDED | ||
diff --git a/utils/wpseditor/libwps/src/defs.h b/utils/wpseditor/libwps/src/defs.h deleted file mode 100644 index 077fc5894c..0000000000 --- a/utils/wpseditor/libwps/src/defs.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef DEFS_H_INCLUDED | ||
23 | #define DEFS_H_INCLUDED | ||
24 | |||
25 | typedef int (*pfdebugf)(const char* fmt,...); | ||
26 | extern pfdebugf dbgf; | ||
27 | |||
28 | #ifdef BUILD_DLL | ||
29 | # define EXPORT __declspec(dllexport) | ||
30 | #else | ||
31 | # define EXPORT | ||
32 | #endif | ||
33 | |||
34 | #ifndef MIN | ||
35 | # define MIN(a, b) (((a)<(b))?(a):(b)) | ||
36 | #endif | ||
37 | |||
38 | #ifndef MAX | ||
39 | # define MAX(a, b) (((a)>(b))?(a):(b)) | ||
40 | #endif | ||
41 | |||
42 | #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ | ||
43 | ((unsigned short)(x) << 8))) | ||
44 | |||
45 | #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \ | ||
46 | (((unsigned long)(x) & 0xff0000ul) >> 8) | \ | ||
47 | (((unsigned long)(x) & 0xff00ul) << 8) | \ | ||
48 | ((unsigned long)(x) << 24))) | ||
49 | |||
50 | #define PLAYMODES_NUM 5 | ||
51 | enum api_playmode { | ||
52 | API_STATUS_PLAY, | ||
53 | API_STATUS_STOP, | ||
54 | API_STATUS_PAUSE, | ||
55 | API_STATUS_FASTFORWARD, | ||
56 | API_STATUS_FASTBACKWARD | ||
57 | }; | ||
58 | |||
59 | extern enum api_playmode playmodes[PLAYMODES_NUM]; | ||
60 | extern const char *playmodeNames[]; | ||
61 | |||
62 | #endif // DEFS_H_INCLUDED | ||
diff --git a/utils/wpseditor/libwps/src/dummies.c b/utils/wpseditor/libwps/src/dummies.c deleted file mode 100644 index faeba63ea7..0000000000 --- a/utils/wpseditor/libwps/src/dummies.c +++ /dev/null | |||
@@ -1,389 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <string.h> | ||
23 | #include <stdio.h> | ||
24 | #include "dummies.h" | ||
25 | #include "proxy.h" | ||
26 | |||
27 | struct user_settings global_settings; | ||
28 | |||
29 | struct wps_state wps_state; | ||
30 | struct gui_wps gui_wps[NB_SCREENS]; | ||
31 | struct wps_data wps_datas[NB_SCREENS]; | ||
32 | struct cuesheet *curr_cue; | ||
33 | struct system_status global_status; | ||
34 | struct gui_syncstatusbar statusbars; | ||
35 | struct playlist_info current_playlist; | ||
36 | struct font sysfont; | ||
37 | int battery_percent = 100; | ||
38 | struct mp3entry current_song, next_song; | ||
39 | int _audio_status; | ||
40 | |||
41 | charger_input_state_type charger_input_state; | ||
42 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
43 | charge_state_type charge_state; | ||
44 | #endif | ||
45 | |||
46 | #if defined(CPU_PP) && defined(BOOTLOADER) | ||
47 | /* We don't enable interrupts in the iPod bootloader, so we need to fake | ||
48 | the current_tick variable */ | ||
49 | #define current_tick (signed)(USEC_TIMER/10000) | ||
50 | #else | ||
51 | volatile long current_tick; | ||
52 | #endif | ||
53 | |||
54 | |||
55 | void dummies_init(){ | ||
56 | sysfont.height = 9; | ||
57 | sysfont.maxwidth = 6; | ||
58 | global_settings.statusbar=true; | ||
59 | } | ||
60 | |||
61 | int playlist_amount_ex(const struct playlist_info* playlist); | ||
62 | void sound_set_volume(int value) | ||
63 | { | ||
64 | DEBUGF3("sound_set_volume(int value=%d)",value); | ||
65 | global_settings.volume = value; | ||
66 | } | ||
67 | int sound_get_pitch(void) | ||
68 | { | ||
69 | return 0; | ||
70 | } | ||
71 | int sound_min(int setting) | ||
72 | { | ||
73 | DEBUGF3("sound_min(int setting=%d)",setting); | ||
74 | return -78; //audiohw_settings[setting].minval; | ||
75 | } | ||
76 | |||
77 | void sleep(int hz) | ||
78 | { | ||
79 | } | ||
80 | |||
81 | void audio_init(void){} | ||
82 | void audio_wait_for_init(void){} | ||
83 | void audio_play(long offset){} | ||
84 | void audio_stop(void){} | ||
85 | void audio_pause(void){} | ||
86 | void audio_resume(void){} | ||
87 | void audio_next(void){} | ||
88 | void audio_prev(void){} | ||
89 | int audio_status(void) | ||
90 | { | ||
91 | return _audio_status; | ||
92 | } | ||
93 | |||
94 | #if CONFIG_CODEC == SWCODEC | ||
95 | int audio_track_count(void){return 0;} /* SWCODEC only */ | ||
96 | long audio_filebufused(void){return 0;} /* SWCODEC only */ | ||
97 | void audio_pre_ff_rewind(void){} /* SWCODEC only */ | ||
98 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
99 | void audio_ff_rewind(long newtime){} | ||
100 | void audio_flush_and_reload_tracks(void){} | ||
101 | #ifdef HAVE_ALBUMART | ||
102 | int audio_current_aa_hid(void){return -1;} | ||
103 | #endif | ||
104 | struct mp3entry* audio_current_track(void){return 0;} | ||
105 | struct mp3entry* audio_next_track(void){return 0;} | ||
106 | bool audio_has_changed_track(void) | ||
107 | { | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | int get_sleep_timer(void){return 0;} | ||
112 | |||
113 | |||
114 | int battery_level(void){return battery_percent;} /* percent */ | ||
115 | int battery_time(void){return 0;} /* minutes */ | ||
116 | unsigned int battery_adc_voltage(void){return 0;} /* voltage from ADC in millivolts */ | ||
117 | unsigned int battery_voltage(void){return 0;} /* filtered batt. voltage in millivolts */ | ||
118 | int get_radio_status(void){return 0;} | ||
119 | |||
120 | |||
121 | /* returns full path of playlist (minus extension) */ | ||
122 | char *playlist_name(const struct playlist_info* playlist, char *buf, | ||
123 | int buf_size) | ||
124 | { | ||
125 | char *sep; | ||
126 | |||
127 | if (!playlist) | ||
128 | return "no"; | ||
129 | |||
130 | snprintf(buf, buf_size, "%s", playlist->filename+playlist->dirlen); | ||
131 | |||
132 | if (!buf[0]) | ||
133 | return NULL; | ||
134 | |||
135 | /* Remove extension */ | ||
136 | sep = strrchr(buf, '.'); | ||
137 | if(sep) | ||
138 | *sep = 0; | ||
139 | |||
140 | return buf; | ||
141 | } | ||
142 | int playlist_get_display_index(void) | ||
143 | { | ||
144 | return 1; | ||
145 | } | ||
146 | |||
147 | void gui_syncsplash(int ticks, const unsigned char *fmt, ...) | ||
148 | { | ||
149 | |||
150 | } | ||
151 | |||
152 | void splash(int ticks, const unsigned char *fmt, ...) | ||
153 | { | ||
154 | |||
155 | } | ||
156 | |||
157 | void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){ | ||
158 | DEBUGF3("gui_statusbar_draw"); | ||
159 | } | ||
160 | |||
161 | void yield(void){} | ||
162 | |||
163 | |||
164 | /* returns true if cuesheet support is initialised */ | ||
165 | bool cuesheet_is_enabled(void){return false;} | ||
166 | |||
167 | /* allocates the cuesheet buffer */ | ||
168 | void cuesheet_init(void){} | ||
169 | |||
170 | /* looks if there is a cuesheet file that has a name matching "trackpath" */ | ||
171 | bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path){return false;} | ||
172 | |||
173 | /* parse cuesheet "file" and store the information in "cue" */ | ||
174 | bool parse_cuesheet(char *file, struct cuesheet *cue){return false;} | ||
175 | |||
176 | /* reads a cuesheet to find the audio track associated to it */ | ||
177 | bool get_trackname_from_cuesheet(char *filename, char *buf){return false;} | ||
178 | |||
179 | /* display a cuesheet struct */ | ||
180 | void browse_cuesheet(struct cuesheet *cue){} | ||
181 | |||
182 | /* display a cuesheet file after parsing and loading it to the plugin buffer */ | ||
183 | bool display_cuesheet_content(char* filename){return false;} | ||
184 | |||
185 | /* finds the index of the current track played within a cuesheet */ | ||
186 | int cue_find_current_track(struct cuesheet *cue, unsigned long curpos){return 0;} | ||
187 | |||
188 | /* update the id3 info to that of the currently playing track in the cuesheet */ | ||
189 | void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3){} | ||
190 | |||
191 | /* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */ | ||
192 | bool curr_cuesheet_skip(int direction, unsigned long curr_pos){return false;} | ||
193 | |||
194 | #ifdef HAVE_LCD_BITMAP | ||
195 | /* draw track markers on the progressbar */ | ||
196 | void cue_draw_markers(struct screen *screen, unsigned long tracklen, | ||
197 | int x, int y, int w, int h){} | ||
198 | #endif | ||
199 | |||
200 | #ifdef HAVE_ALBUMART | ||
201 | void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) | ||
202 | { | ||
203 | if (!gwps || !gwps->data || !gwps->display || handle_id < 0) | ||
204 | return; | ||
205 | |||
206 | struct wps_data *data = gwps->data; | ||
207 | |||
208 | #ifdef HAVE_REMOTE_LCD | ||
209 | /* No album art on RWPS */ | ||
210 | if (data->remote_wps) | ||
211 | return; | ||
212 | #endif | ||
213 | |||
214 | struct bitmap *bmp; | ||
215 | /* if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0) | ||
216 | return;*/ | ||
217 | |||
218 | short x = data->albumart_x; | ||
219 | short y = data->albumart_y; | ||
220 | short width = bmp->width; | ||
221 | short height = bmp->height; | ||
222 | |||
223 | if (data->albumart_max_width > 0) | ||
224 | { | ||
225 | /* Crop if the bitmap is too wide */ | ||
226 | width = MIN(bmp->width, data->albumart_max_width); | ||
227 | |||
228 | /* Align */ | ||
229 | if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT) | ||
230 | x += data->albumart_max_width - width; | ||
231 | else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER) | ||
232 | x += (data->albumart_max_width - width) / 2; | ||
233 | } | ||
234 | |||
235 | if (data->albumart_max_height > 0) | ||
236 | { | ||
237 | /* Crop if the bitmap is too high */ | ||
238 | height = MIN(bmp->height, data->albumart_max_height); | ||
239 | |||
240 | /* Align */ | ||
241 | if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM) | ||
242 | y += data->albumart_max_height - height; | ||
243 | else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER) | ||
244 | y += (data->albumart_max_height - height) / 2; | ||
245 | } | ||
246 | |||
247 | if (!clear) | ||
248 | { | ||
249 | /* Draw the bitmap */ | ||
250 | gwps->display->set_drawmode(DRMODE_FG); | ||
251 | gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, bmp->width, | ||
252 | x, y, width, height); | ||
253 | gwps->display->set_drawmode(DRMODE_SOLID); | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | /* Clear the bitmap */ | ||
258 | gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
259 | gwps->display->fillrect(x, y, width, height); | ||
260 | gwps->display->set_drawmode(DRMODE_SOLID); | ||
261 | } | ||
262 | } | ||
263 | #endif | ||
264 | /* Update the "data" pointer to make the handle's data available to the caller. | ||
265 | Return the length of the available linear data or < 0 for failure (handle | ||
266 | not found). | ||
267 | The caller is blocked until the requested amount of data is available. | ||
268 | size is the amount of linear data requested. it can be 0 to get as | ||
269 | much as possible. | ||
270 | The guard buffer may be used to provide the requested size. This means it's | ||
271 | unsafe to request more than the size of the guard buffer. | ||
272 | */ | ||
273 | size_t bufgetdata(int handle_id, size_t size, void **data) | ||
274 | { | ||
275 | |||
276 | |||
277 | return size; | ||
278 | } | ||
279 | |||
280 | |||
281 | void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, | ||
282 | bool force_redraw) | ||
283 | { | ||
284 | #ifdef HAVE_LCD_BITMAP | ||
285 | if(!global_settings.statusbar) | ||
286 | return; | ||
287 | #endif /* HAVE_LCD_BITMAP */ | ||
288 | int i; | ||
289 | FOR_NB_SCREENS(i) { | ||
290 | gui_statusbar_draw( &(bars->statusbars[i]), force_redraw ); | ||
291 | } | ||
292 | } | ||
293 | void unload_wps_backdrop(void) | ||
294 | { | ||
295 | |||
296 | } | ||
297 | void unload_remote_wps_backdrop(void) | ||
298 | { | ||
299 | |||
300 | } | ||
301 | |||
302 | #if CONFIG_CODEC == SWCODEC | ||
303 | int get_replaygain_mode(bool have_track_gain, bool have_album_gain) | ||
304 | { | ||
305 | int type; | ||
306 | |||
307 | bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) | ||
308 | || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) | ||
309 | && global_settings.playlist_shuffle)); | ||
310 | |||
311 | type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM | ||
312 | : have_track_gain ? REPLAYGAIN_TRACK : -1; | ||
313 | |||
314 | return type; | ||
315 | } | ||
316 | #endif | ||
317 | |||
318 | /* Common functions for all targets */ | ||
319 | void rtc_init(void){} | ||
320 | int rtc_read_datetime(unsigned char* buf){return 0;} | ||
321 | int rtc_write_datetime(unsigned char* buf){return 0;} | ||
322 | |||
323 | void backlight_on(void){} | ||
324 | void backlight_off(void){} | ||
325 | |||
326 | void remote_backlight_on(void){} | ||
327 | void remote_backlight_off(void){} | ||
328 | |||
329 | void debugf(const char *fmt, ...) | ||
330 | {} | ||
331 | void panicf( const char *fmt, ...) | ||
332 | { | ||
333 | } | ||
334 | |||
335 | off_t filesize(int fd){return 0;} | ||
336 | |||
337 | int playlist_amount(void) | ||
338 | { | ||
339 | return playlist_amount_ex(NULL); | ||
340 | } | ||
341 | int playlist_amount_ex(const struct playlist_info* playlist) | ||
342 | { | ||
343 | if (!playlist) | ||
344 | playlist = ¤t_playlist; | ||
345 | |||
346 | return playlist->amount; | ||
347 | } | ||
348 | |||
349 | int get_action(int context, int timeout) | ||
350 | { | ||
351 | return 0; | ||
352 | } | ||
353 | |||
354 | void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, | ||
355 | int height){} | ||
356 | |||
357 | void pcm_calculate_rec_peaks(int *left, int *right) | ||
358 | { | ||
359 | } | ||
360 | void pcm_calculate_peaks(int *left, int *right) | ||
361 | { | ||
362 | } | ||
363 | bool led_read(int delayticks) /* read by status bar update */ | ||
364 | { | ||
365 | return false; | ||
366 | } | ||
367 | |||
368 | #ifndef HAS_BUTTON_HOLD | ||
369 | bool is_keys_locked(void) | ||
370 | { | ||
371 | return false; | ||
372 | } | ||
373 | #endif | ||
374 | |||
375 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter) | ||
376 | { | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | long default_event_handler(long event) | ||
381 | { | ||
382 | return default_event_handler_ex(event, NULL, NULL); | ||
383 | } | ||
384 | |||
385 | void ab_draw_markers(struct screen * screen, int capacity, | ||
386 | int x, int y, int w, int h) | ||
387 | { | ||
388 | } | ||
389 | void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude){} | ||
diff --git a/utils/wpseditor/libwps/src/dummies.h b/utils/wpseditor/libwps/src/dummies.h deleted file mode 100644 index 15ee29cca1..0000000000 --- a/utils/wpseditor/libwps/src/dummies.h +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #ifndef DUMMIES_H_INCLUDED | ||
24 | #define DUMMIES_H_INCLUDED | ||
25 | |||
26 | #include <stdio.h> | ||
27 | |||
28 | #include "settings.h" | ||
29 | #include "gwps.h" | ||
30 | #include "lang.h" | ||
31 | #include "powermgmt.h" | ||
32 | #include "font.h" | ||
33 | #include "playlist.h" | ||
34 | |||
35 | #include "defs.h" | ||
36 | |||
37 | extern struct font sysfont; | ||
38 | extern struct user_settings global_settings; | ||
39 | extern struct wps_state wps_state; | ||
40 | extern struct gui_wps gui_wps[NB_SCREENS]; | ||
41 | extern struct wps_data wps_datas[NB_SCREENS]; | ||
42 | extern struct cuesheet *curr_cue; | ||
43 | extern struct system_status global_status; | ||
44 | extern struct gui_syncstatusbar statusbars; | ||
45 | extern struct playlist_info current_playlist; | ||
46 | extern int battery_percent; | ||
47 | extern struct mp3entry current_song, next_song; | ||
48 | extern int _audio_status; | ||
49 | |||
50 | charger_input_state_type charger_input_state; | ||
51 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
52 | extern charge_state_type charge_state; | ||
53 | #endif | ||
54 | |||
55 | #if defined(CPU_PP) && defined(BOOTLOADER) | ||
56 | /* We don't enable interrupts in the iPod bootloader, so we need to fake | ||
57 | the current_tick variable */ | ||
58 | #define current_tick (signed)(USEC_TIMER/10000) | ||
59 | #else | ||
60 | extern volatile long current_tick; | ||
61 | #endif | ||
62 | |||
63 | void dummies_init(); | ||
64 | |||
65 | #endif /*DUMMIES_H_INCLUDED*/ | ||
diff --git a/utils/wpseditor/libwps/src/include/lang.h b/utils/wpseditor/libwps/src/include/lang.h deleted file mode 100644 index 87fc5ec012..0000000000 --- a/utils/wpseditor/libwps/src/include/lang.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #define LANG_END_PLAYLIST (signed char)1 | ||
23 | #define LANG_KEYLOCK_ON (signed char)2 | ||
24 | #define LANG_KEYLOCK_OFF (signed char)3 | ||
25 | #define LANG_WEEKDAY_SUNDAY (signed char)4 | ||
26 | #define LANG_MONTH_JANUARY (signed char)5 | ||
27 | #define VOICE_PAUSE (signed char)6 | ||
28 | #define LANG_BATTERY_TIME (signed char)7 | ||
29 | #define UNIT_PERCENT (signed char)8 | ||
30 | |||
31 | #define str(...) "empty" | ||
diff --git a/utils/wpseditor/libwps/src/include/remote_rockboxlogo.h b/utils/wpseditor/libwps/src/include/remote_rockboxlogo.h deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/utils/wpseditor/libwps/src/include/remote_rockboxlogo.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | |||
diff --git a/utils/wpseditor/libwps/src/include/rockboxlogo.h b/utils/wpseditor/libwps/src/include/rockboxlogo.h deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/utils/wpseditor/libwps/src/include/rockboxlogo.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | |||
diff --git a/utils/wpseditor/libwps/src/include/sysfont.h b/utils/wpseditor/libwps/src/include/sysfont.h deleted file mode 100644 index 0b25ed836e..0000000000 --- a/utils/wpseditor/libwps/src/include/sysfont.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #define SYSFONT_HEIGHT 9 | ||
diff --git a/utils/wpseditor/libwps/src/include/system-target.h b/utils/wpseditor/libwps/src/include/system-target.h deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/utils/wpseditor/libwps/src/include/system-target.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | |||
diff --git a/utils/wpseditor/libwps/src/lcd.c b/utils/wpseditor/libwps/src/lcd.c deleted file mode 100644 index d78024d374..0000000000 --- a/utils/wpseditor/libwps/src/lcd.c +++ /dev/null | |||
@@ -1,179 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "font.h" | ||
23 | #include "screen_access.h" | ||
24 | //#include <windef.h> | ||
25 | #include "api.h" | ||
26 | #include "defs.h" | ||
27 | #include "proxy.h" | ||
28 | #include "dummies.h" | ||
29 | |||
30 | static struct viewport default_vp = | ||
31 | { | ||
32 | .x = 0, | ||
33 | .y = 0, | ||
34 | .width = LCD_WIDTH, | ||
35 | .height = LCD_HEIGHT, | ||
36 | #ifdef HAVE_LCD_BITMAP | ||
37 | .font = FONT_SYSFIXED, | ||
38 | .drawmode = DRMODE_SOLID, | ||
39 | #endif | ||
40 | #if LCD_DEPTH > 1 | ||
41 | .fg_pattern = LCD_DEFAULT_FG, | ||
42 | .bg_pattern = LCD_DEFAULT_BG, | ||
43 | #ifdef HAVE_LCD_COLOR | ||
44 | .lss_pattern = LCD_DEFAULT_BG, | ||
45 | .lse_pattern = LCD_DEFAULT_BG, | ||
46 | .lst_pattern = LCD_DEFAULT_BG, | ||
47 | #endif | ||
48 | #endif | ||
49 | }; | ||
50 | |||
51 | struct viewport* current_vp = &default_vp; | ||
52 | |||
53 | void get_current_vp(struct viewport_api *avp){ | ||
54 | avp->x = current_vp->x; | ||
55 | avp->y = current_vp->y; | ||
56 | avp->width = current_vp->width; | ||
57 | avp->height = current_vp->height; | ||
58 | |||
59 | //TODO: font_get(current_vp->font)->height; | ||
60 | avp->fontheight = sysfont.height; | ||
61 | } | ||
62 | |||
63 | void lcd_set_viewport(struct viewport* vp) | ||
64 | { | ||
65 | if (vp == NULL){ | ||
66 | current_vp = &default_vp; | ||
67 | DEBUGF3("lcd_set_viewport(struct viewport* vp= DEFAULT)\n"); | ||
68 | } | ||
69 | else{ | ||
70 | current_vp = vp; | ||
71 | DEBUGF3("lcd_set_viewport(struct viewport* vp=%x,vpx=%d,vpy=%d,vpw=%d,vph=%d)\n",vp,vp->x,vp->y,vp->width,vp->height); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void lcd_update_viewport(void) | ||
76 | { | ||
77 | //lcd_update_rect(current_vp->x, current_vp->y,current_vp->width, current_vp->height); | ||
78 | } | ||
79 | |||
80 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
81 | { | ||
82 | //lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
83 | } | ||
84 | /*** parameter handling ***/ | ||
85 | |||
86 | void lcd_set_drawmode(int mode) | ||
87 | { | ||
88 | current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); | ||
89 | } | ||
90 | |||
91 | int lcd_get_drawmode(void) | ||
92 | { | ||
93 | return current_vp->drawmode; | ||
94 | } | ||
95 | #if LCD_DEPTH > 1 | ||
96 | void lcd_set_foreground(unsigned color) | ||
97 | { | ||
98 | current_vp->fg_pattern = color; | ||
99 | } | ||
100 | |||
101 | unsigned lcd_get_foreground(void) | ||
102 | { | ||
103 | return current_vp->fg_pattern; | ||
104 | } | ||
105 | |||
106 | void lcd_set_background(unsigned color) | ||
107 | { | ||
108 | current_vp->bg_pattern = color; | ||
109 | } | ||
110 | |||
111 | unsigned lcd_get_background(void) | ||
112 | { | ||
113 | return current_vp->bg_pattern; | ||
114 | } | ||
115 | |||
116 | #ifdef HAVE_LCD_COLOR | ||
117 | void lcd_set_selector_start(unsigned color) | ||
118 | { | ||
119 | current_vp->lss_pattern = color; | ||
120 | } | ||
121 | |||
122 | void lcd_set_selector_end(unsigned color) | ||
123 | { | ||
124 | current_vp->lse_pattern = color; | ||
125 | } | ||
126 | |||
127 | void lcd_set_selector_text(unsigned color) | ||
128 | { | ||
129 | current_vp->lst_pattern = color; | ||
130 | } | ||
131 | |||
132 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | ||
133 | { | ||
134 | //lcd_set_drawmode(mode); | ||
135 | current_vp->fg_pattern = fg_color; | ||
136 | current_vp->bg_pattern = bg_color; | ||
137 | } | ||
138 | #endif | ||
139 | #endif | ||
140 | int lcd_getwidth(void) | ||
141 | { | ||
142 | return current_vp->width; | ||
143 | } | ||
144 | |||
145 | int lcd_getheight(void) | ||
146 | { | ||
147 | return current_vp->height; | ||
148 | } | ||
149 | |||
150 | void lcd_setfont(int newfont) | ||
151 | { | ||
152 | current_vp->font = newfont; | ||
153 | } | ||
154 | |||
155 | int lcd_getfont(void) | ||
156 | { | ||
157 | return current_vp->font; | ||
158 | } | ||
159 | |||
160 | /* Clear the whole display */ | ||
161 | void lcd_clear_display(void) | ||
162 | { | ||
163 | struct viewport* old_vp = current_vp; | ||
164 | |||
165 | current_vp = &default_vp; | ||
166 | |||
167 | lcd_clear_viewport(); | ||
168 | |||
169 | current_vp = old_vp; | ||
170 | } | ||
171 | |||
172 | void lcd_clear_viewport(){ | ||
173 | DEBUGF2("lcd_clear_viewport()\n"); | ||
174 | xapi->clear_viewport(current_vp->x,current_vp->y,current_vp->width,current_vp->height,current_vp->bg_pattern); | ||
175 | |||
176 | } | ||
177 | void lcd_scroll_stop(struct viewport* vp){ | ||
178 | DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp); | ||
179 | } | ||
diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c deleted file mode 100644 index 315cf971ab..0000000000 --- a/utils/wpseditor/libwps/src/proxy.c +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include "dummies.h" | ||
25 | #include "proxy.h" | ||
26 | #include "api.h" | ||
27 | #include "gwps.h" | ||
28 | #include "gwps-common.h" | ||
29 | #include <string.h> | ||
30 | |||
31 | struct screen screens[NB_SCREENS]; | ||
32 | struct wps_data wpsdata; | ||
33 | struct gui_wps gwps; | ||
34 | struct mp3entry id3; | ||
35 | struct mp3entry nid3; | ||
36 | |||
37 | extern void test_api(struct proxy_api *api); | ||
38 | |||
39 | bool debug_wps = true; | ||
40 | int wps_verbose_level = 0; | ||
41 | int errno_; | ||
42 | pfdebugf dbgf = 0; | ||
43 | |||
44 | static char pluginbuf[PLUGIN_BUFFER_SIZE]; | ||
45 | |||
46 | const char* get_model_name(){ | ||
47 | #ifdef MODEL_NAME | ||
48 | return MODEL_NAME; | ||
49 | #else | ||
50 | return "unknown"; | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | int read_line(int fd, char* buffer, int buffer_size) | ||
55 | { | ||
56 | int count = 0; | ||
57 | int num_read = 0; | ||
58 | |||
59 | errno_ = 0; | ||
60 | |||
61 | while (count < buffer_size) | ||
62 | { | ||
63 | unsigned char c; | ||
64 | |||
65 | if (1 != read(fd, &c, 1)) | ||
66 | break; | ||
67 | |||
68 | num_read++; | ||
69 | |||
70 | if ( c == '\n' ) | ||
71 | break; | ||
72 | |||
73 | if ( c == '\r' ) | ||
74 | continue; | ||
75 | |||
76 | buffer[count++] = c; | ||
77 | } | ||
78 | |||
79 | buffer[MIN(count, buffer_size - 1)] = 0; | ||
80 | |||
81 | return errno_ ? -1 : num_read; | ||
82 | } | ||
83 | |||
84 | void* plugin_get_buffer(size_t *buffer_size) | ||
85 | { | ||
86 | *buffer_size = PLUGIN_BUFFER_SIZE; | ||
87 | return pluginbuf; | ||
88 | } | ||
89 | |||
90 | int checkwps(const char *filename, int verbose){ | ||
91 | int res; | ||
92 | int fd; | ||
93 | |||
94 | struct wps_data wps; | ||
95 | wps_verbose_level = verbose; | ||
96 | |||
97 | fd = open(filename, O_RDONLY); | ||
98 | if (fd < 0) { | ||
99 | DEBUGF1("Failed to open %s\n",filename); | ||
100 | return 2; | ||
101 | } | ||
102 | close(fd); | ||
103 | |||
104 | res = wps_data_load(&wps, &screens[0], filename, true); | ||
105 | |||
106 | if (!res) { | ||
107 | DEBUGF1("WPS parsing failure\n"); | ||
108 | return 3; | ||
109 | } | ||
110 | |||
111 | DEBUGF1("WPS parsed OK\n"); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | int wps_init(const char* filename,struct proxy_api *api, bool isfile){ | ||
116 | int res; | ||
117 | if (!api) | ||
118 | return 4; | ||
119 | dummies_init(); | ||
120 | test_api(api); | ||
121 | set_api(api); | ||
122 | wps_data_init(&wpsdata); | ||
123 | wps_verbose_level = api->verbose; | ||
124 | res = wps_data_load(&wpsdata, &screens[0], filename, isfile); | ||
125 | if (!res) | ||
126 | { | ||
127 | DEBUGF1("ERR: WPS parsing failure\n"); | ||
128 | } else | ||
129 | DEBUGF1("WPS parsed OK\n"); | ||
130 | DEBUGF1("\n-------------------------------------------------\n"); | ||
131 | wps_state.paused = true; | ||
132 | gwps.data = &wpsdata; | ||
133 | gwps.display = &screens[0]; | ||
134 | gwps.state = &wps_state; | ||
135 | gwps.state->id3 = &id3; | ||
136 | gwps.state->nid3 = &nid3; | ||
137 | gui_wps[0] = gwps; | ||
138 | return (res?res:3); | ||
139 | } | ||
140 | |||
141 | int wps_display(){ | ||
142 | DEBUGF3("wps_display(): begin\n"); | ||
143 | int res = gui_wps_display(); | ||
144 | DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not ")); | ||
145 | return res; | ||
146 | } | ||
147 | int wps_refresh(){ | ||
148 | DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n"); | ||
149 | int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL); | ||
150 | DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not ")); | ||
151 | return res; | ||
152 | } | ||
diff --git a/utils/wpseditor/libwps/src/proxy.h b/utils/wpseditor/libwps/src/proxy.h deleted file mode 100644 index 2f8e984aaa..0000000000 --- a/utils/wpseditor/libwps/src/proxy.h +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef PROXY_H | ||
23 | #define PROXY_h | ||
24 | |||
25 | #include <stdio.h> | ||
26 | |||
27 | #include "screen_access.h" | ||
28 | #include "api.h" | ||
29 | #include "defs.h" | ||
30 | |||
31 | #define DEBUGF dbgf | ||
32 | #define DEBUGF1 dbgf | ||
33 | #define DEBUGF2(...) | ||
34 | #define DEBUGF3(...) | ||
35 | #define DEBUGF4(...) | ||
36 | |||
37 | EXPORT int checkwps(const char *filename, int verbose); | ||
38 | EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile); | ||
39 | EXPORT int wps_display(); | ||
40 | EXPORT int wps_refresh(); | ||
41 | EXPORT const char* get_model_name(); | ||
42 | |||
43 | extern struct screen screens[NB_SCREENS]; | ||
44 | extern bool debug_wps; | ||
45 | extern int wps_verbose_level; | ||
46 | |||
47 | |||
48 | #endif | ||
diff --git a/utils/wpseditor/libwps/src/wpsstate.h b/utils/wpseditor/libwps/src/wpsstate.h deleted file mode 100644 index 3fa36436e2..0000000000 --- a/utils/wpseditor/libwps/src/wpsstate.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef STATES_H | ||
23 | #define STATES_H | ||
24 | // | ||
25 | struct trackstate | ||
26 | { | ||
27 | char* title; | ||
28 | char* artist; | ||
29 | char* album; | ||
30 | char* genre_string; | ||
31 | char* disc_string; | ||
32 | char* track_string; | ||
33 | char* year_string; | ||
34 | char* composer; | ||
35 | char* comment; | ||
36 | char* albumartist; | ||
37 | char* grouping; | ||
38 | int discnum; | ||
39 | int tracknum; | ||
40 | int version; | ||
41 | int layer; | ||
42 | int year; | ||
43 | |||
44 | int length; | ||
45 | int elapsed; | ||
46 | }; | ||
47 | |||
48 | struct wpsstate{ | ||
49 | int volume; | ||
50 | int fontheight; | ||
51 | int fontwidth; | ||
52 | int battery_level; | ||
53 | int audio_status; | ||
54 | }; | ||
55 | #endif | ||
diff --git a/utils/wpseditor/screenshot/Makefile b/utils/wpseditor/screenshot/Makefile deleted file mode 100644 index f9309f58a5..0000000000 --- a/utils/wpseditor/screenshot/Makefile +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | ROOT=../../.. | ||
10 | |||
11 | CC = gcc | ||
12 | RM = rm -f | ||
13 | |||
14 | COMMON = main.c gd_bmp.c | ||
15 | |||
16 | INCLUDE = -I ../libwps/src \ | ||
17 | -I $(ROOT)/apps/gui \ | ||
18 | -I $(ROOT)/firmware/export \ | ||
19 | -I $(ROOT)/apps/recorder \ | ||
20 | -I $(ROOT)/apps \ | ||
21 | -I . | ||
22 | |||
23 | CFLAGS = -g -Wall | ||
24 | |||
25 | all: | ||
26 | $(CC) $(INCLUDE) $(CFLAGS) $(COMMON) -rdynamic -ldl -lgd -lpng -o screenshot | ||
27 | |||
28 | clean: | ||
29 | $(RM) screenshot | ||
diff --git a/utils/wpseditor/screenshot/bmp.h b/utils/wpseditor/screenshot/bmp.h deleted file mode 100644 index 71d5a4a5bc..0000000000 --- a/utils/wpseditor/screenshot/bmp.h +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | #ifdef __cplusplus | ||
3 | extern "C" { | ||
4 | #endif | ||
5 | |||
6 | /* | ||
7 | gd_bmp.c | ||
8 | |||
9 | Bitmap format support for libgd | ||
10 | |||
11 | * Written 2007, Scott MacVicar | ||
12 | --------------------------------------------------------------------------- | ||
13 | |||
14 | Todo: | ||
15 | |||
16 | RLE4, RLE8 and Bitfield encoding | ||
17 | Add full support for Windows v4 and Windows v5 header formats | ||
18 | |||
19 | ---------------------------------------------------------------------------- | ||
20 | */ | ||
21 | |||
22 | #ifndef BMP_H | ||
23 | #define BMP_H 1 | ||
24 | |||
25 | #define BMP_PALETTE_3 1 | ||
26 | #define BMP_PALETTE_4 2 | ||
27 | |||
28 | #define BMP_WINDOWS_V3 40 | ||
29 | #define BMP_OS2_V1 12 | ||
30 | #define BMP_OS2_V2 64 | ||
31 | #define BMP_WINDOWS_V4 108 | ||
32 | #define BMP_WINDOWS_V5 124 | ||
33 | |||
34 | #define BMP_BI_RGB 0 | ||
35 | #define BMP_BI_RLE8 1 | ||
36 | #define BMP_BI_RLE4 2 | ||
37 | #define BMP_BI_BITFIELDS 3 | ||
38 | #define BMP_BI_JPEG 4 | ||
39 | #define BMP_BI_PNG 5 | ||
40 | |||
41 | #define BMP_RLE_COMMAND 0 | ||
42 | #define BMP_RLE_ENDOFLINE 0 | ||
43 | #define BMP_RLE_ENDOFBITMAP 1 | ||
44 | #define BMP_RLE_DELTA 2 | ||
45 | |||
46 | #define BMP_RLE_TYPE_RAW 0 | ||
47 | #define BMP_RLE_TYPE_RLE 1 | ||
48 | |||
49 | /* BMP header. */ | ||
50 | typedef struct | ||
51 | { | ||
52 | /* 16 bit - header identifying the type */ | ||
53 | signed short int magic; | ||
54 | |||
55 | /* 32bit - size of the file */ | ||
56 | int size; | ||
57 | |||
58 | /* 16bit - these two are in the spec but "reserved" */ | ||
59 | signed short int reserved1; | ||
60 | signed short int reserved2; | ||
61 | |||
62 | /* 32 bit - offset of the bitmap header from data in bytes */ | ||
63 | signed int off; | ||
64 | |||
65 | } bmp_hdr_t; | ||
66 | |||
67 | /* BMP info. */ | ||
68 | typedef struct | ||
69 | { | ||
70 | /* 16bit - Type, ie Windows or OS/2 for the palette info */ | ||
71 | signed short int type; | ||
72 | /* 32bit - The length of the bitmap information header in bytes. */ | ||
73 | signed int len; | ||
74 | |||
75 | /* 32bit - The width of the bitmap in pixels. */ | ||
76 | signed int width; | ||
77 | |||
78 | /* 32bit - The height of the bitmap in pixels. */ | ||
79 | signed int height; | ||
80 | |||
81 | /* 8 bit - The bitmap data is specified in top-down order. */ | ||
82 | signed char topdown; | ||
83 | |||
84 | /* 16 bit - The number of planes. This must be set to a value of one. */ | ||
85 | signed short int numplanes; | ||
86 | |||
87 | /* 16 bit - The number of bits per pixel. */ | ||
88 | signed short int depth; | ||
89 | |||
90 | /* 32bit - The type of compression used. */ | ||
91 | signed int enctype; | ||
92 | |||
93 | /* 32bit - The size of the image in bytes. */ | ||
94 | signed int size; | ||
95 | |||
96 | /* 32bit - The horizontal resolution in pixels/metre. */ | ||
97 | signed int hres; | ||
98 | |||
99 | /* 32bit - The vertical resolution in pixels/metre. */ | ||
100 | signed int vres; | ||
101 | |||
102 | /* 32bit - The number of color indices used by the bitmap. */ | ||
103 | signed int numcolors; | ||
104 | |||
105 | /* 32bit - The number of color indices important for displaying the bitmap. */ | ||
106 | signed int mincolors; | ||
107 | |||
108 | } bmp_info_t; | ||
109 | |||
110 | #endif | ||
111 | |||
112 | #ifdef __cplusplus | ||
113 | } | ||
114 | #endif | ||
diff --git a/utils/wpseditor/screenshot/gd_bmp.c b/utils/wpseditor/screenshot/gd_bmp.c deleted file mode 100644 index 8fe737da03..0000000000 --- a/utils/wpseditor/screenshot/gd_bmp.c +++ /dev/null | |||
@@ -1,778 +0,0 @@ | |||
1 | /* | ||
2 | Stolen from http://cvs.php.net/viewcvs.cgi/gd/playground/gdbmp/ | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | gd_bmp.c | ||
7 | |||
8 | Bitmap format support for libgd | ||
9 | |||
10 | * Written 2007, Scott MacVicar | ||
11 | --------------------------------------------------------------------------- | ||
12 | |||
13 | Todo: | ||
14 | |||
15 | Bitfield encoding | ||
16 | |||
17 | ---------------------------------------------------------------------------- | ||
18 | */ | ||
19 | /* $Id$ */ | ||
20 | #ifdef HAVE_CONFIG_H | ||
21 | #include "config.h" | ||
22 | #endif | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <math.h> | ||
26 | #include <string.h> | ||
27 | #include <stdlib.h> | ||
28 | #include "gd.h" | ||
29 | #include "bmp.h" | ||
30 | |||
31 | extern void* gdCalloc (size_t nmemb, size_t size); | ||
32 | |||
33 | static int bmp_read_header(gdIOCtxPtr infile, bmp_hdr_t *hdr); | ||
34 | static int bmp_read_info(gdIOCtxPtr infile, bmp_info_t *info); | ||
35 | static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info); | ||
36 | static int bmp_read_os2_v1_info(gdIOCtxPtr infile, bmp_info_t *info); | ||
37 | static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info); | ||
38 | |||
39 | static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header); | ||
40 | static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header); | ||
41 | static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header); | ||
42 | static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header); | ||
43 | static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info); | ||
44 | |||
45 | #if GD_MAJOR_VERSION == 2 && GD_MINOR_VERSION < 1 | ||
46 | /* Byte helper functions, since added to GD 2.1 */ | ||
47 | static int gdGetIntLSB(signed int *result, gdIOCtx * ctx); | ||
48 | static int gdGetWordLSB(signed short int *result, gdIOCtx * ctx); | ||
49 | #endif | ||
50 | |||
51 | #define BMP_DEBUG(s) | ||
52 | |||
53 | gdImagePtr gdImageCreateFromBmpCtx(gdIOCtxPtr infile); | ||
54 | |||
55 | gdImagePtr gdImageCreateFromBmp(FILE * inFile) | ||
56 | { | ||
57 | gdImagePtr im = 0; | ||
58 | gdIOCtx *in = gdNewFileCtx(inFile); | ||
59 | im = gdImageCreateFromBmpCtx(in); | ||
60 | in->gd_free(in); | ||
61 | return im; | ||
62 | } | ||
63 | |||
64 | gdImagePtr gdImageCreateFromBmpPtr(int size, void *data) | ||
65 | { | ||
66 | gdImagePtr im; | ||
67 | gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0); | ||
68 | im = gdImageCreateFromBmpCtx(in); | ||
69 | in->gd_free(in); | ||
70 | return im; | ||
71 | } | ||
72 | |||
73 | gdImagePtr gdImageCreateFromBmpCtx(gdIOCtxPtr infile) | ||
74 | { | ||
75 | bmp_hdr_t *hdr; | ||
76 | bmp_info_t *info; | ||
77 | gdImagePtr im = NULL; | ||
78 | int error = 0; | ||
79 | |||
80 | if (!(hdr= (bmp_hdr_t *)gdCalloc(1, sizeof(bmp_hdr_t)))) { | ||
81 | return NULL; | ||
82 | } | ||
83 | |||
84 | if (bmp_read_header(infile, hdr)) { | ||
85 | gdFree(hdr); | ||
86 | return NULL; | ||
87 | } | ||
88 | |||
89 | if (hdr->magic != 0x4d42) { | ||
90 | gdFree(hdr); | ||
91 | return NULL; | ||
92 | } | ||
93 | |||
94 | if (!(info = (bmp_info_t *)gdCalloc(1, sizeof(bmp_info_t)))) { | ||
95 | gdFree(hdr); | ||
96 | return NULL; | ||
97 | } | ||
98 | |||
99 | if (bmp_read_info(infile, info)) { | ||
100 | gdFree(hdr); | ||
101 | gdFree(info); | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | BMP_DEBUG(printf("Numcolours: %d\n", info->numcolors)); | ||
106 | BMP_DEBUG(printf("Width: %d\n", info->width)); | ||
107 | BMP_DEBUG(printf("Height: %d\n", info->height)); | ||
108 | BMP_DEBUG(printf("Planes: %d\n", info->numplanes)); | ||
109 | BMP_DEBUG(printf("Depth: %d\n", info->depth)); | ||
110 | BMP_DEBUG(printf("Offset: %d\n", hdr->off)); | ||
111 | |||
112 | if (info->depth >= 16) { | ||
113 | im = gdImageCreateTrueColor(info->width, info->height); | ||
114 | } else { | ||
115 | im = gdImageCreate(info->width, info->height); | ||
116 | } | ||
117 | |||
118 | if (!im) { | ||
119 | gdFree(hdr); | ||
120 | gdFree(info); | ||
121 | return NULL; | ||
122 | } | ||
123 | |||
124 | switch (info->depth) { | ||
125 | case 1: | ||
126 | BMP_DEBUG(printf("1-bit image\n")); | ||
127 | error = bmp_read_1bit(im, infile, info, hdr); | ||
128 | break; | ||
129 | case 4: | ||
130 | BMP_DEBUG(printf("4-bit image\n")); | ||
131 | error = bmp_read_4bit(im, infile, info, hdr); | ||
132 | break; | ||
133 | case 8: | ||
134 | BMP_DEBUG(printf("8-bit image\n")); | ||
135 | error = bmp_read_8bit(im, infile, info, hdr); | ||
136 | break; | ||
137 | case 16: | ||
138 | case 24: | ||
139 | case 32: | ||
140 | BMP_DEBUG(printf("Direct BMP image\n")); | ||
141 | error = bmp_read_direct(im, infile, info, hdr); | ||
142 | break; | ||
143 | default: | ||
144 | BMP_DEBUG(printf("Unknown bit count\n")); | ||
145 | error = 1; | ||
146 | } | ||
147 | |||
148 | gdFree(hdr); | ||
149 | gdFree(info); | ||
150 | |||
151 | if (error) { | ||
152 | gdImageDestroy(im); | ||
153 | return NULL; | ||
154 | } | ||
155 | |||
156 | return im; | ||
157 | } | ||
158 | |||
159 | static int bmp_read_header(gdIOCtx *infile, bmp_hdr_t *hdr) | ||
160 | { | ||
161 | if( | ||
162 | !gdGetWordLSB(&hdr->magic, infile) || | ||
163 | !gdGetIntLSB(&hdr->size, infile) || | ||
164 | !gdGetWordLSB(&hdr->reserved1, infile) || | ||
165 | !gdGetWordLSB(&hdr->reserved2 , infile) || | ||
166 | !gdGetIntLSB(&hdr->off , infile) | ||
167 | ) { | ||
168 | return 1; | ||
169 | } | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | static int bmp_read_info(gdIOCtx *infile, bmp_info_t *info) | ||
174 | { | ||
175 | /* read BMP length so we can work out the version */ | ||
176 | if (!gdGetIntLSB(&info->len, infile)) { | ||
177 | return 1; | ||
178 | } | ||
179 | |||
180 | switch (info->len) { | ||
181 | /* For now treat Windows v4 + v5 as v3 */ | ||
182 | case BMP_WINDOWS_V3: | ||
183 | case BMP_WINDOWS_V4: | ||
184 | case BMP_WINDOWS_V5: | ||
185 | BMP_DEBUG(printf("Reading Windows Header\n")); | ||
186 | if (bmp_read_windows_v3_info(infile, info)) { | ||
187 | return 1; | ||
188 | } | ||
189 | break; | ||
190 | case BMP_OS2_V1: | ||
191 | if (bmp_read_os2_v1_info(infile, info)) { | ||
192 | return 1; | ||
193 | } | ||
194 | break; | ||
195 | case BMP_OS2_V2: | ||
196 | if (bmp_read_os2_v2_info(infile, info)) { | ||
197 | return 1; | ||
198 | } | ||
199 | break; | ||
200 | default: | ||
201 | BMP_DEBUG(printf("Unhandled bitmap\n")); | ||
202 | return 1; | ||
203 | } | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info) | ||
208 | { | ||
209 | if ( | ||
210 | !gdGetIntLSB(&info->width, infile) || | ||
211 | !gdGetIntLSB(&info->height, infile) || | ||
212 | !gdGetWordLSB(&info->numplanes, infile) || | ||
213 | !gdGetWordLSB(&info->depth, infile) || | ||
214 | !gdGetIntLSB(&info->enctype, infile) || | ||
215 | !gdGetIntLSB(&info->size, infile) || | ||
216 | !gdGetIntLSB(&info->hres, infile) || | ||
217 | !gdGetIntLSB(&info->vres, infile) || | ||
218 | !gdGetIntLSB(&info->numcolors, infile) || | ||
219 | !gdGetIntLSB(&info->mincolors, infile) | ||
220 | ) { | ||
221 | return 1; | ||
222 | } | ||
223 | |||
224 | if (info->height < 0) { | ||
225 | info->topdown = 1; | ||
226 | info->height = -info->height; | ||
227 | } else { | ||
228 | info->topdown = 0; | ||
229 | } | ||
230 | |||
231 | info->type = BMP_PALETTE_4; | ||
232 | |||
233 | if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || | ||
234 | info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { | ||
235 | return 1; | ||
236 | } | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static int bmp_read_os2_v1_info(gdIOCtxPtr infile, bmp_info_t *info) | ||
242 | { | ||
243 | if ( | ||
244 | !gdGetWordLSB((signed short int *)&info->width, infile) || | ||
245 | !gdGetWordLSB((signed short int *)&info->height, infile) || | ||
246 | !gdGetWordLSB(&info->numplanes, infile) || | ||
247 | !gdGetWordLSB(&info->depth, infile) | ||
248 | ) { | ||
249 | return 1; | ||
250 | } | ||
251 | |||
252 | /* OS2 v1 doesn't support topdown */ | ||
253 | info->topdown = 0; | ||
254 | |||
255 | info->numcolors = 1 << info->depth; | ||
256 | info->type = BMP_PALETTE_3; | ||
257 | |||
258 | if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || | ||
259 | info->depth <= 0 || info->numcolors < 0) { | ||
260 | return 1; | ||
261 | } | ||
262 | |||
263 | return 0; | ||
264 | } | ||
265 | |||
266 | static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info) | ||
267 | { | ||
268 | char useless_bytes[24]; | ||
269 | if ( | ||
270 | !gdGetIntLSB(&info->width, infile) || | ||
271 | !gdGetIntLSB(&info->height, infile) || | ||
272 | !gdGetWordLSB(&info->numplanes, infile) || | ||
273 | !gdGetWordLSB(&info->depth, infile) || | ||
274 | !gdGetIntLSB(&info->enctype, infile) || | ||
275 | !gdGetIntLSB(&info->size, infile) || | ||
276 | !gdGetIntLSB(&info->hres, infile) || | ||
277 | !gdGetIntLSB(&info->vres, infile) || | ||
278 | !gdGetIntLSB(&info->numcolors, infile) || | ||
279 | !gdGetIntLSB(&info->mincolors, infile) | ||
280 | ) { | ||
281 | return 1; | ||
282 | } | ||
283 | |||
284 | /* Lets seek the next 24 pointless bytes, we don't care too much about it */ | ||
285 | if (!gdGetBuf(useless_bytes, 24, infile)) { | ||
286 | return 1; | ||
287 | } | ||
288 | |||
289 | if (info->height < 0) { | ||
290 | info->topdown = 1; | ||
291 | info->height = -info->height; | ||
292 | } else { | ||
293 | info->topdown = 0; | ||
294 | } | ||
295 | |||
296 | info->type = BMP_PALETTE_4; | ||
297 | |||
298 | if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || | ||
299 | info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { | ||
300 | return 1; | ||
301 | } | ||
302 | |||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) | ||
308 | { | ||
309 | int ypos = 0, xpos = 0, row = 0; | ||
310 | int padding = 0, alpha = 0, red = 0, green = 0, blue = 0; | ||
311 | signed short int data = 0; | ||
312 | |||
313 | switch(info->enctype) { | ||
314 | case BMP_BI_RGB: | ||
315 | /* no-op */ | ||
316 | break; | ||
317 | |||
318 | case BMP_BI_BITFIELDS: | ||
319 | if (info->depth == 24) { | ||
320 | BMP_DEBUG(printf("Bitfield compression isn't supported for 24-bit\n")); | ||
321 | return 1; | ||
322 | } | ||
323 | BMP_DEBUG(printf("Currently no bitfield support\n")); | ||
324 | return 1; | ||
325 | break; | ||
326 | |||
327 | case BMP_BI_RLE8: | ||
328 | if (info->depth != 8) { | ||
329 | BMP_DEBUG(printf("RLE is only valid for 8-bit images\n")); | ||
330 | return 1; | ||
331 | } | ||
332 | case BMP_BI_RLE4: | ||
333 | if (info->depth != 4) { | ||
334 | BMP_DEBUG(printf("RLE is only valid for 4-bit images\n")); | ||
335 | return 1; | ||
336 | } | ||
337 | case BMP_BI_JPEG: | ||
338 | case BMP_BI_PNG: | ||
339 | default: | ||
340 | BMP_DEBUG(printf("Unsupported BMP compression format\n")); | ||
341 | return 1; | ||
342 | } | ||
343 | |||
344 | /* There is a chance the data isn't until later, would be wierd but it is possible */ | ||
345 | if (gdTell(infile) != header->off) { | ||
346 | /* Should make sure we don't seek past the file size */ | ||
347 | gdSeek(infile, header->off); | ||
348 | } | ||
349 | |||
350 | /* The line must be divisible by 4, else its padded with NULLs */ | ||
351 | padding = ((int)(info->depth / 8) * info->width) % 4; | ||
352 | if (padding) { | ||
353 | padding = 4 - padding; | ||
354 | } | ||
355 | |||
356 | |||
357 | for (ypos = 0; ypos < info->height; ++ypos) { | ||
358 | if (info->topdown) { | ||
359 | row = ypos; | ||
360 | } else { | ||
361 | row = info->height - ypos - 1; | ||
362 | } | ||
363 | |||
364 | for (xpos = 0; xpos < info->width; xpos++) { | ||
365 | if (info->depth == 16) { | ||
366 | if (!gdGetWordLSB(&data, infile)) { | ||
367 | return 1; | ||
368 | } | ||
369 | BMP_DEBUG(printf("Data: %X\n", data)); | ||
370 | red = ((data & 0x7C00) >> 10) << 3; | ||
371 | green = ((data & 0x3E0) >> 5) << 3; | ||
372 | blue = (data & 0x1F) << 3; | ||
373 | BMP_DEBUG(printf("R: %d, G: %d, B: %d\n", red, green, blue)); | ||
374 | } else if (info->depth == 24) { | ||
375 | if (!gdGetByte(&blue, infile) || !gdGetByte(&green, infile) || !gdGetByte(&red, infile)) { | ||
376 | return 1; | ||
377 | } | ||
378 | } else { | ||
379 | if (!gdGetByte(&blue, infile) || !gdGetByte(&green, infile) || !gdGetByte(&red, infile) || !gdGetByte(&alpha, infile)) { | ||
380 | return 1; | ||
381 | } | ||
382 | } | ||
383 | /*alpha = gdAlphaMax - (alpha >> 1);*/ | ||
384 | gdImageSetPixel(im, xpos, row, gdTrueColor(red, green, blue)); | ||
385 | } | ||
386 | for (xpos = padding; xpos > 0; --xpos) { | ||
387 | if (!gdGetByte(&red, infile)) { | ||
388 | return 1; | ||
389 | } | ||
390 | } | ||
391 | } | ||
392 | |||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | static int bmp_read_palette(gdImagePtr im, gdIOCtxPtr infile, int count, int read_four) | ||
397 | { | ||
398 | int i; | ||
399 | int r, g, b, z; | ||
400 | |||
401 | for (i = 0; i < count; i++) { | ||
402 | if ( | ||
403 | !gdGetByte(&r, infile) || | ||
404 | !gdGetByte(&g, infile) || | ||
405 | !gdGetByte(&b, infile) || | ||
406 | (read_four && !gdGetByte(&z, infile)) | ||
407 | ) { | ||
408 | return 1; | ||
409 | } | ||
410 | im->red[i] = r; | ||
411 | im->green[i] = g; | ||
412 | im->blue[i] = b; | ||
413 | im->open[i] = 1; | ||
414 | } | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) | ||
419 | { | ||
420 | int ypos = 0, xpos = 0, row = 0, index = 0; | ||
421 | int padding = 0, current_byte = 0, bit = 0; | ||
422 | |||
423 | if (info->enctype != BMP_BI_RGB) { | ||
424 | return 1; | ||
425 | } | ||
426 | |||
427 | if (!info->numcolors) { | ||
428 | info->numcolors = 2; | ||
429 | } else if (info->numcolors < 0 || info->numcolors > 2) { | ||
430 | return 1; | ||
431 | } | ||
432 | |||
433 | if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { | ||
434 | return 1; | ||
435 | } | ||
436 | |||
437 | im->colorsTotal = info->numcolors; | ||
438 | |||
439 | /* There is a chance the data isn't until later, would be wierd but it is possible */ | ||
440 | if (gdTell(infile) != header->off) { | ||
441 | /* Should make sure we don't seek past the file size */ | ||
442 | gdSeek(infile, header->off); | ||
443 | } | ||
444 | |||
445 | /* The line must be divisible by 4, else its padded with NULLs */ | ||
446 | padding = ((int)ceill(0.1 * info->width)) % 4; | ||
447 | if (padding) { | ||
448 | padding = 4 - padding; | ||
449 | } | ||
450 | |||
451 | for (ypos = 0; ypos < info->height; ++ypos) { | ||
452 | if (info->topdown) { | ||
453 | row = ypos; | ||
454 | } else { | ||
455 | row = info->height - ypos - 1; | ||
456 | } | ||
457 | |||
458 | for (xpos = 0; xpos < info->width; xpos += 8) { | ||
459 | /* Bitmaps are always aligned in bytes so we'll never overflow */ | ||
460 | if (!gdGetByte(¤t_byte, infile)) { | ||
461 | return 1; | ||
462 | } | ||
463 | |||
464 | for (bit = 0; bit < 8; bit++) { | ||
465 | index = ((current_byte & (0x80 >> bit)) != 0 ? 0x01 : 0x00); | ||
466 | if (im->open[index]) { | ||
467 | im->open[index] = 0; | ||
468 | } | ||
469 | gdImageSetPixel(im, xpos + bit, row, index); | ||
470 | /* No need to read anything extra */ | ||
471 | if ((xpos + bit) >= info->width) { | ||
472 | break; | ||
473 | } | ||
474 | } | ||
475 | } | ||
476 | |||
477 | for (xpos = padding; xpos > 0; --xpos) { | ||
478 | if (!gdGetByte(&index, infile)) { | ||
479 | return 1; | ||
480 | } | ||
481 | } | ||
482 | } | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) | ||
487 | { | ||
488 | int ypos = 0, xpos = 0, row = 0, index = 0; | ||
489 | int padding = 0, current_byte = 0; | ||
490 | |||
491 | if (info->enctype != BMP_BI_RGB && info->enctype != BMP_BI_RLE4) { | ||
492 | return 1; | ||
493 | } | ||
494 | |||
495 | if (!info->numcolors) { | ||
496 | info->numcolors = 16; | ||
497 | } else if (info->numcolors < 0 || info->numcolors > 16) { | ||
498 | return 1; | ||
499 | } | ||
500 | |||
501 | if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { | ||
502 | return 1; | ||
503 | } | ||
504 | |||
505 | im->colorsTotal = info->numcolors; | ||
506 | |||
507 | /* There is a chance the data isn't until later, would be wierd but it is possible */ | ||
508 | if (gdTell(infile) != header->off) { | ||
509 | /* Should make sure we don't seek past the file size */ | ||
510 | gdSeek(infile, header->off); | ||
511 | } | ||
512 | |||
513 | /* The line must be divisible by 4, else its padded with NULLs */ | ||
514 | padding = ((int)ceil(0.5 * info->width)) % 4; | ||
515 | if (padding) { | ||
516 | padding = 4 - padding; | ||
517 | } | ||
518 | |||
519 | switch (info->enctype) { | ||
520 | case BMP_BI_RGB: | ||
521 | for (ypos = 0; ypos < info->height; ++ypos) { | ||
522 | if (info->topdown) { | ||
523 | row = ypos; | ||
524 | } else { | ||
525 | row = info->height - ypos - 1; | ||
526 | } | ||
527 | |||
528 | for (xpos = 0; xpos < info->width; xpos += 2) { | ||
529 | if (!gdGetByte(¤t_byte, infile)) { | ||
530 | return 1; | ||
531 | } | ||
532 | |||
533 | index = (current_byte >> 4) & 0x0f; | ||
534 | if (im->open[index]) { | ||
535 | im->open[index] = 0; | ||
536 | } | ||
537 | gdImageSetPixel(im, xpos, row, index); | ||
538 | |||
539 | /* This condition may get called often, potential optimsations */ | ||
540 | if (xpos >= info->width) { | ||
541 | break; | ||
542 | } | ||
543 | |||
544 | index = current_byte & 0x0f; | ||
545 | if (im->open[index]) { | ||
546 | im->open[index] = 0; | ||
547 | } | ||
548 | gdImageSetPixel(im, xpos + 1, row, index); | ||
549 | } | ||
550 | |||
551 | for (xpos = padding; xpos > 0; --xpos) { | ||
552 | if (!gdGetByte(&index, infile)) { | ||
553 | return 1; | ||
554 | } | ||
555 | } | ||
556 | } | ||
557 | break; | ||
558 | |||
559 | case BMP_BI_RLE4: | ||
560 | if (bmp_read_rle(im, infile, info)) { | ||
561 | return 1; | ||
562 | } | ||
563 | break; | ||
564 | |||
565 | default: | ||
566 | return 1; | ||
567 | } | ||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) | ||
572 | { | ||
573 | int ypos = 0, xpos = 0, row = 0, index = 0; | ||
574 | int padding = 0; | ||
575 | |||
576 | if (info->enctype != BMP_BI_RGB && info->enctype != BMP_BI_RLE8) { | ||
577 | return 1; | ||
578 | } | ||
579 | |||
580 | if (!info->numcolors) { | ||
581 | info->numcolors = 256; | ||
582 | } else if (info->numcolors < 0 || info->numcolors > 256) { | ||
583 | return 1; | ||
584 | } | ||
585 | |||
586 | if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { | ||
587 | return 1; | ||
588 | } | ||
589 | |||
590 | im->colorsTotal = info->numcolors; | ||
591 | |||
592 | /* There is a chance the data isn't until later, would be wierd but it is possible */ | ||
593 | if (gdTell(infile) != header->off) { | ||
594 | /* Should make sure we don't seek past the file size */ | ||
595 | gdSeek(infile, header->off); | ||
596 | } | ||
597 | |||
598 | /* The line must be divisible by 4, else its padded with NULLs */ | ||
599 | padding = (1 * info->width) % 4; | ||
600 | if (padding) { | ||
601 | padding = 4 - padding; | ||
602 | } | ||
603 | |||
604 | switch (info->enctype) { | ||
605 | case BMP_BI_RGB: | ||
606 | for (ypos = 0; ypos < info->height; ++ypos) { | ||
607 | if (info->topdown) { | ||
608 | row = ypos; | ||
609 | } else { | ||
610 | row = info->height - ypos - 1; | ||
611 | } | ||
612 | |||
613 | for (xpos = 0; xpos < info->width; ++xpos) { | ||
614 | if (!gdGetByte(&index, infile)) { | ||
615 | return 1; | ||
616 | } | ||
617 | |||
618 | if (im->open[index]) { | ||
619 | im->open[index] = 0; | ||
620 | } | ||
621 | gdImageSetPixel(im, xpos, row, index); | ||
622 | } | ||
623 | /* Could create a new variable, but it isn't really worth it */ | ||
624 | for (xpos = padding; xpos > 0; --xpos) { | ||
625 | if (!gdGetByte(&index, infile)) { | ||
626 | return 1; | ||
627 | } | ||
628 | } | ||
629 | } | ||
630 | break; | ||
631 | |||
632 | case BMP_BI_RLE8: | ||
633 | if (bmp_read_rle(im, infile, info)) { | ||
634 | return 1; | ||
635 | } | ||
636 | break; | ||
637 | |||
638 | default: | ||
639 | return 1; | ||
640 | } | ||
641 | return 0; | ||
642 | } | ||
643 | |||
644 | static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info) | ||
645 | { | ||
646 | int ypos = 0, xpos = 0, row = 0, index = 0; | ||
647 | int rle_length = 0, rle_data = 0; | ||
648 | int padding = 0; | ||
649 | int i = 0, j = 0; | ||
650 | int pixels_per_byte = 8 / info->depth; | ||
651 | |||
652 | for (ypos = 0; ypos < info->height && xpos <= info->width;) { | ||
653 | if (!gdGetByte(&rle_length, infile) || !gdGetByte(&rle_data, infile)) { | ||
654 | return 1; | ||
655 | } | ||
656 | row = info->height - ypos - 1; | ||
657 | |||
658 | if (rle_length != BMP_RLE_COMMAND) { | ||
659 | if (im->open[rle_data]) { | ||
660 | im->open[rle_data] = 0; | ||
661 | } | ||
662 | |||
663 | for (i = 0; (i < rle_length) && (xpos < info->width);) { | ||
664 | for (j = 1; (j <= pixels_per_byte) && (xpos < info->width) && (i < rle_length); j++, xpos++, i++) { | ||
665 | index = (rle_data & (((1 << info->depth) - 1) << (8 - (j * info->depth)))) >> (8 - (j * info->depth)); | ||
666 | if (im->open[index]) { | ||
667 | im->open[index] = 0; | ||
668 | } | ||
669 | gdImageSetPixel(im, xpos, row, index); | ||
670 | } | ||
671 | } | ||
672 | } else if (rle_length == BMP_RLE_COMMAND && rle_data > 2) { | ||
673 | /* Uncompressed RLE needs to be even */ | ||
674 | padding = 0; | ||
675 | for (i = 0; (i < rle_data) && (xpos < info->width); i += pixels_per_byte) { | ||
676 | int max_pixels = pixels_per_byte; | ||
677 | |||
678 | if (!gdGetByte(&index, infile)) { | ||
679 | return 1; | ||
680 | } | ||
681 | padding++; | ||
682 | |||
683 | if (rle_data - i < max_pixels) { | ||
684 | max_pixels = rle_data - i; | ||
685 | } | ||
686 | |||
687 | for (j = 1; (j <= max_pixels) && (xpos < info->width); j++, xpos++) { | ||
688 | int temp = (index >> (8 - (j * info->depth))) & ((1 << info->depth) - 1); | ||
689 | if (im->open[temp]) { | ||
690 | im->open[temp] = 0; | ||
691 | } | ||
692 | gdImageSetPixel(im, xpos, row, temp); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | /* Make sure the bytes read are even */ | ||
697 | if (padding % 2 && !gdGetByte(&index, infile)) { | ||
698 | return 1; | ||
699 | } | ||
700 | } else if (rle_length == BMP_RLE_COMMAND && rle_data == BMP_RLE_ENDOFLINE) { | ||
701 | /* Next Line */ | ||
702 | xpos = 0; | ||
703 | ypos++; | ||
704 | } else if (rle_length == BMP_RLE_COMMAND && rle_data == BMP_RLE_DELTA) { | ||
705 | /* Delta Record, used for bmp files that contain other data*/ | ||
706 | if (!gdGetByte(&rle_length, infile) || !gdGetByte(&rle_data, infile)) { | ||
707 | return 1; | ||
708 | } | ||
709 | xpos += rle_length; | ||
710 | ypos += rle_data; | ||
711 | } else if (rle_length == BMP_RLE_COMMAND && rle_data == BMP_RLE_ENDOFBITMAP) { | ||
712 | /* End of bitmap */ | ||
713 | break; | ||
714 | } | ||
715 | } | ||
716 | return 0; | ||
717 | } | ||
718 | |||
719 | #if GD_MAJOR_VERSION == 2 && GD_MINOR_VERSION < 1 | ||
720 | static int gdGetWordLSB(signed short int *result, gdIOCtx * ctx) | ||
721 | { | ||
722 | unsigned int high = 0, low = 0; | ||
723 | low = (ctx->getC) (ctx); | ||
724 | if (low == EOF) { | ||
725 | return 0; | ||
726 | } | ||
727 | |||
728 | high = (ctx->getC) (ctx); | ||
729 | if (high == EOF) { | ||
730 | return 0; | ||
731 | } | ||
732 | |||
733 | if (result) { | ||
734 | *result = (high << 8) | low; | ||
735 | } | ||
736 | |||
737 | return 1; | ||
738 | } | ||
739 | |||
740 | static int gdGetIntLSB(signed int *result, gdIOCtx * ctx) | ||
741 | { | ||
742 | int c = 0; | ||
743 | unsigned int r = 0; | ||
744 | |||
745 | c = (ctx->getC) (ctx); | ||
746 | if (c == EOF) { | ||
747 | return 0; | ||
748 | } | ||
749 | r |= (c << 24); | ||
750 | r >>= 8; | ||
751 | |||
752 | c = (ctx->getC) (ctx); | ||
753 | if (c == EOF) { | ||
754 | return 0; | ||
755 | } | ||
756 | r |= (c << 24); | ||
757 | r >>= 8; | ||
758 | |||
759 | c = (ctx->getC) (ctx); | ||
760 | if (c == EOF) { | ||
761 | return 0; | ||
762 | } | ||
763 | r |= (c << 24); | ||
764 | r >>= 8; | ||
765 | |||
766 | c = (ctx->getC) (ctx); | ||
767 | if (c == EOF) { | ||
768 | return 0; | ||
769 | } | ||
770 | r |= (c << 24); | ||
771 | |||
772 | if (result) { | ||
773 | *result = (signed int)r; | ||
774 | } | ||
775 | |||
776 | return 1; | ||
777 | } | ||
778 | #endif | ||
diff --git a/utils/wpseditor/screenshot/main.c b/utils/wpseditor/screenshot/main.c deleted file mode 100644 index 72d75ab54d..0000000000 --- a/utils/wpseditor/screenshot/main.c +++ /dev/null | |||
@@ -1,377 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdarg.h> | ||
24 | #include <string.h> | ||
25 | #include <dlfcn.h> | ||
26 | #include <unistd.h> | ||
27 | #include "gd.h" | ||
28 | #include "gdfonts.h" | ||
29 | #include "api.h" | ||
30 | |||
31 | #define DEBUGF1 _debug | ||
32 | #define DEBUGF2 if(verbose) _debug | ||
33 | |||
34 | #define getFont() gdFontGetSmall() | ||
35 | |||
36 | static struct trackstate mp3data = | ||
37 | { | ||
38 | (char*)"Test title", | ||
39 | (char*)"Test artist", | ||
40 | (char*)"Test album", | ||
41 | (char*)"Test genre", | ||
42 | (char*)"Test disc", | ||
43 | (char*)"Test track", | ||
44 | (char*)"Test year", | ||
45 | (char*)"Test composer", | ||
46 | (char*)"Test comment", | ||
47 | (char*)"Test album artist", | ||
48 | (char*)"Test grouping", | ||
49 | 1, /* int discnum */ | ||
50 | 1, /* int tracknum */ | ||
51 | 1, /* int version */ | ||
52 | 1, /* int layer */ | ||
53 | 2008, /* int year */ | ||
54 | |||
55 | 100, /* int length */ | ||
56 | 70 /* int elapsed */ | ||
57 | }; | ||
58 | |||
59 | static struct wpsstate wpsdata = {-20, -1, -1, 70, API_STATUS_FASTFORWARD}; | ||
60 | /* volume, fontheight, fontwidth, battery_level, audio_status */ | ||
61 | |||
62 | static struct proxy_api api; | ||
63 | static bool verbose = false; | ||
64 | static int (*wps_init)(const char* buff, struct proxy_api *api, bool isfile); | ||
65 | static int (*wps_display)(); | ||
66 | static int (*wps_refresh)(); | ||
67 | static gdImagePtr framebuffer; | ||
68 | static gdImagePtr backdrop; | ||
69 | |||
70 | extern gdImagePtr gdImageCreateFromBmp(FILE * inFile); | ||
71 | extern char *get_current_dir_name (void) __THROW; | ||
72 | |||
73 | static bool next_nl = false; | ||
74 | |||
75 | int _debug(const char* fmt,...) | ||
76 | { | ||
77 | va_list ap; | ||
78 | |||
79 | va_start(ap, fmt); | ||
80 | |||
81 | if(!next_nl) | ||
82 | fprintf(stdout, "[DBG] "); | ||
83 | |||
84 | vfprintf(stdout, fmt, ap); | ||
85 | |||
86 | if(fmt[strlen(fmt)-1] != 0xa) | ||
87 | next_nl = true; | ||
88 | else | ||
89 | next_nl = false; | ||
90 | |||
91 | va_end(ap); | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | void _putsxy(int x, int y, const unsigned char *str) | ||
97 | { | ||
98 | struct viewport_api avp; | ||
99 | int black = gdImageColorAllocate(framebuffer, 0, 0, 0); | ||
100 | |||
101 | api.get_current_vp(&avp); | ||
102 | |||
103 | gdImageString(framebuffer, getFont(), x + avp.x, y + avp.y - avp.fontheight, (unsigned char*)str, black); | ||
104 | } | ||
105 | |||
106 | void _transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
107 | int stride, int x, int y, int width, int height) | ||
108 | { | ||
109 | FILE *_image; | ||
110 | gdImagePtr image; | ||
111 | int pink; | ||
112 | |||
113 | DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d, int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d\n", (char*)src, src_x, src_y, stride, x, y, width, height); | ||
114 | |||
115 | _image = fopen(src, "rb"); | ||
116 | if(_image == NULL) | ||
117 | return; | ||
118 | |||
119 | image = gdImageCreateFromBmp(_image); | ||
120 | fclose(_image); | ||
121 | |||
122 | pink = gdTrueColor(255, 0, 255); | ||
123 | gdImageColorTransparent(image, pink); | ||
124 | |||
125 | gdImageCopy(framebuffer, image, x, y, src_x, src_y, width, height); | ||
126 | |||
127 | gdImageDestroy(image); | ||
128 | } | ||
129 | |||
130 | void _bitmap_part(const void *src, int src_x, int src_y, | ||
131 | int stride, int x, int y, int width, int height) | ||
132 | { | ||
133 | FILE *_image; | ||
134 | gdImagePtr image; | ||
135 | |||
136 | DEBUGF2("bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d, int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d\n", (char*)src, src_x, src_y, stride, x, y, width, height); | ||
137 | |||
138 | _image = fopen(src, "rb"); | ||
139 | if(_image == NULL) | ||
140 | return; | ||
141 | |||
142 | image = gdImageCreateFromBmp(_image); | ||
143 | fclose(_image); | ||
144 | |||
145 | gdImageCopy(framebuffer, image, x, y, src_x, src_y, width, height); | ||
146 | |||
147 | gdImageDestroy(image); | ||
148 | } | ||
149 | |||
150 | void _drawpixel(int x, int y) | ||
151 | { | ||
152 | int black = gdImageColorAllocate(framebuffer, 0, 0, 0); | ||
153 | gdImageSetPixel(framebuffer, x, y, black); | ||
154 | } | ||
155 | |||
156 | void _fillrect(int x, int y, int width, int height) | ||
157 | { | ||
158 | /* Don't draw this as backdrop is used */ | ||
159 | #if 0 | ||
160 | int black = gdImageColorAllocate(framebuffer, 0, 0, 0); | ||
161 | gdImageFilledRectangle(framebuffer, x, y, x+width, y+height, black); | ||
162 | #endif | ||
163 | } | ||
164 | |||
165 | void _hline(int x1, int x2, int y) | ||
166 | { | ||
167 | int black = gdImageColorAllocate(framebuffer, 0, 0, 0); | ||
168 | gdImageLine(framebuffer, x1, y, x2, y, black); | ||
169 | } | ||
170 | |||
171 | void _vline(int x, int y1, int y2) | ||
172 | { | ||
173 | int black = gdImageColorAllocate(framebuffer, 0, 0, 0); | ||
174 | gdImageLine(framebuffer, x, y1, x, y2, black); | ||
175 | } | ||
176 | |||
177 | void _clear_viewport(int x, int y, int w, int h, int color) | ||
178 | { | ||
179 | if(backdrop == NULL) | ||
180 | return; | ||
181 | |||
182 | gdImageCopy(framebuffer, backdrop, x, y, x, y, w, h); | ||
183 | } | ||
184 | |||
185 | static bool _load_wps_backdrop(char* filename) | ||
186 | { | ||
187 | FILE *image; | ||
188 | if(backdrop != NULL) | ||
189 | gdImageDestroy(backdrop); | ||
190 | |||
191 | DEBUGF2("load backdrop: %s", filename); | ||
192 | |||
193 | image = fopen(filename, "rb"); | ||
194 | if(image == NULL) | ||
195 | return false; | ||
196 | |||
197 | backdrop = gdImageCreateFromBmp(image); | ||
198 | fclose(image); | ||
199 | |||
200 | return true; | ||
201 | } | ||
202 | |||
203 | int _read_bmp_file(const char* filename, int *width, int *height) | ||
204 | { | ||
205 | FILE *_image; | ||
206 | gdImagePtr image; | ||
207 | |||
208 | DEBUGF2("load backdrop: %s", filename); | ||
209 | |||
210 | _image = fopen(filename, "rb"); | ||
211 | if(_image == NULL) | ||
212 | return 0; | ||
213 | |||
214 | image = gdImageCreateFromBmp(_image); | ||
215 | fclose(_image); | ||
216 | |||
217 | *width = image->sx; | ||
218 | *height = image->sy; | ||
219 | |||
220 | gdImageDestroy(image); | ||
221 | |||
222 | return 1; | ||
223 | } | ||
224 | |||
225 | static void _drawBackdrop() | ||
226 | { | ||
227 | if(backdrop == NULL) | ||
228 | return; | ||
229 | |||
230 | gdImageCopy(framebuffer, backdrop, 0, 0, 0, 0, backdrop->sx, backdrop->sy); | ||
231 | } | ||
232 | |||
233 | static int screenshot(char *model, char *wps, char *png) | ||
234 | { | ||
235 | char lib[255]; | ||
236 | void *handle; | ||
237 | FILE *out, *in; | ||
238 | int res; | ||
239 | |||
240 | in = fopen(wps, "rb"); | ||
241 | if(in == NULL) | ||
242 | { | ||
243 | fprintf(stderr, "[ERR] Cannot open WPS: %s\n", wps); | ||
244 | return -1; | ||
245 | } | ||
246 | fclose(in); | ||
247 | |||
248 | out = fopen(png, "wb"); | ||
249 | if(out == NULL) | ||
250 | { | ||
251 | fprintf(stderr, "[ERR] Cannot open PNG: %s\n", png); | ||
252 | return -2; | ||
253 | } | ||
254 | |||
255 | snprintf(lib, 255, "%s/libwps_%s.so", (char*)get_current_dir_name(), (char*)model); | ||
256 | handle = dlopen(lib, RTLD_LAZY); | ||
257 | if (!handle) | ||
258 | { | ||
259 | fprintf(stderr, "[ERR] Cannot open library: %s\n", dlerror()); | ||
260 | fclose(out); | ||
261 | return -3; | ||
262 | } | ||
263 | |||
264 | wps_init = dlsym(handle, "wps_init"); | ||
265 | wps_display = dlsym(handle, "wps_display"); | ||
266 | wps_refresh = dlsym(handle, "wps_refresh"); | ||
267 | |||
268 | if (!wps_init || !wps_display || !wps_refresh) | ||
269 | { | ||
270 | fprintf(stderr, "[ERR] Failed to resolve funcs!"); | ||
271 | dlclose(handle); | ||
272 | fclose(out); | ||
273 | return -4; | ||
274 | } | ||
275 | |||
276 | memset(&api, 0, sizeof(struct proxy_api)); | ||
277 | |||
278 | if(verbose) | ||
279 | api.verbose = 3; | ||
280 | else | ||
281 | api.verbose = 0; | ||
282 | |||
283 | api.putsxy = &_putsxy; | ||
284 | api.transparent_bitmap_part = &_transparent_bitmap_part; | ||
285 | api.bitmap_part = &_bitmap_part; | ||
286 | api.drawpixel = &_drawpixel; | ||
287 | api.fillrect = &_fillrect; | ||
288 | api.hline = &_hline; | ||
289 | api.vline = &_vline; | ||
290 | api.clear_viewport = &_clear_viewport; | ||
291 | api.load_wps_backdrop = &_load_wps_backdrop; | ||
292 | api.read_bmp_file = &_read_bmp_file; | ||
293 | api.debugf = &_debug; | ||
294 | |||
295 | res = wps_init(wps, &api, true); | ||
296 | if(res != 1) | ||
297 | { | ||
298 | fprintf(stderr, "[ERR] WPS wasn't correctly inited\n"); | ||
299 | dlclose(handle); | ||
300 | fclose(out); | ||
301 | return -5; | ||
302 | } | ||
303 | |||
304 | framebuffer = gdImageCreateTrueColor(api.getwidth(), api.getheight()); | ||
305 | |||
306 | _drawBackdrop(); | ||
307 | |||
308 | fprintf(stdout, "[INFO] Model: %s\n", api.get_model_name()); | ||
309 | |||
310 | wpsdata.fontheight = getFont()->h; | ||
311 | wpsdata.fontwidth = getFont()->w; | ||
312 | api.set_wpsstate(wpsdata); | ||
313 | api.set_trackstate(mp3data); | ||
314 | api.set_next_trackstate(mp3data); | ||
315 | |||
316 | _drawBackdrop(); | ||
317 | wps_refresh(); | ||
318 | gdImagePng(framebuffer, out); | ||
319 | |||
320 | fprintf(stdout, "[INFO] Image written\n"); | ||
321 | |||
322 | dlclose(handle); | ||
323 | fclose(out); | ||
324 | gdImageDestroy(framebuffer); | ||
325 | if(backdrop != NULL) | ||
326 | gdImageDestroy(backdrop); | ||
327 | |||
328 | wps_init = NULL; | ||
329 | wps_display = NULL; | ||
330 | wps_refresh = NULL; | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static void usage(void) | ||
336 | { | ||
337 | fprintf(stderr, "Rockbox WPS screenshot utility\n"); | ||
338 | fprintf(stderr, "Made by Maurus Cuelenaere\n"); | ||
339 | fprintf(stderr, "\n"); | ||
340 | fprintf(stderr, "Usage: screenshot [-V] <MODEL> <WPS> <OUT>.png\n"); | ||
341 | fprintf(stderr, " -> creates a PNG screenshot of the WPS for the specific MODEL\n"); | ||
342 | fprintf(stderr, " -> libwps_<MODEL>.so must be present in the same directory\n"); | ||
343 | fprintf(stderr, " -> -V sets verbose mode ON\n"); | ||
344 | fprintf(stderr, "\n"); | ||
345 | fprintf(stderr, "Example: screenshot IRIVER_H10_5GB iCatcher.wps out.png\n"); | ||
346 | } | ||
347 | |||
348 | int main(int argc, char ** argv) | ||
349 | { | ||
350 | if(argc < 4) | ||
351 | { | ||
352 | usage(); | ||
353 | return -1; | ||
354 | } | ||
355 | |||
356 | if(argv[1] == NULL || argv[2] == NULL || | ||
357 | argv[3] == NULL || | ||
358 | (strcmp(argv[1], "-V") == 0 && argv[4] == NULL) | ||
359 | ) | ||
360 | { | ||
361 | usage(); | ||
362 | return -1; | ||
363 | } | ||
364 | |||
365 | if(strcmp(argv[1], "-V") == 0) | ||
366 | { | ||
367 | verbose = true; | ||
368 | return screenshot(argv[2], argv[3], argv[4]); | ||
369 | } | ||
370 | else | ||
371 | { | ||
372 | verbose = false; | ||
373 | return screenshot(argv[1], argv[2], argv[3]); | ||
374 | } | ||
375 | |||
376 | return 0; | ||
377 | } | ||
diff --git a/utils/wpseditor/wpseditor.pro b/utils/wpseditor/wpseditor.pro deleted file mode 100644 index df954ed68a..0000000000 --- a/utils/wpseditor/wpseditor.pro +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | TEMPLATE = subdirs | ||
2 | SUBDIRS = gui/src/QPropertyEditor gui libwps | ||
3 | libwps.commands = @$(MAKE) -C libwps | ||
4 | QMAKE_EXTRA_TARGETS += libwps | ||