
09-22-2007
|  | MotoFans JUNR | | Join Date: Jul 2007 Location: Samut Prakarn, Thailand
Posts: 79
Thanks: 2
Thanked 58 Times in 17 Posts
| | The way to E6/A1200 Native EZX Application Preface
Since i bought my ROKR E6 3-4 months ago, i need to develop the native app for the phone.
But look bad, the MOTOROLA have not been released anything about native SDK for EZX platform.
Yes, Java is be good but does everybody wants this ?
After hard searching on the net, i found the weakness SDK by yan0 and samr,
but seem it not ready to develop native app on the E6/A1200.
Well, i try to put and cutoff method on any class of that weak SDK.. but still can not work.
It can not derive or inherit class for extend the capability of the class which is the main important thing of the C++ programming.
After hard trying i have found the technic which brought me to handling the widget events, paint it etc.
So i made the new class with this technic, this technic may call "WRAPPER". The Wrapper technic
The main function of this technic is void QObject::installEventFilter ( const QObject * obj )
Let see the following code of the QEObject class HEADER - qeobject.h: PHP Code: /***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef __QEOBJECT_H__
#define __QEOBJECT_H__
#include <qobject.h>
#include <qwidget.h>
/**
***********************************************
Base Object for handle Widget's events
***********************************************
*/
class QEObject : public QObject
{
Q_OBJECT
public:
QEObject(QWidget *parent, const char *name = 0);
QEObject(const char *name = 0);
virtual ~QEObject();
QWidget *widget() const { return m_Widget; };
/**
hook Widget events
please call this after init and show object already
*/
void hookEvents(bool hook = TRUE);
virtual void requestDestroy() {};
void setMouseBlocked(bool block = FALSE);
virtual void setGeometry(int x, int y, int w, int h);
virtual void move(int x, int y);
virtual void resize(int w, int h);
virtual void show();
virtual void hide();
virtual void showNormal();
virtual void showFullScreen();
virtual QSize sizeHint() const { return QSize(m_width, m_height); };
int ix() const { return m_ix; };
int iy() const { return m_iy; };
int x() const { return m_x; };
int y() const { return m_y; };
int left() const { return m_x; };
int top() const { return m_y; };
int width() const { return m_width; };
int height() const { return m_height; };
QRect rect() const { return QRect(m_x, m_y, m_width, m_height); };
/** GUI creation */
virtual void setupGUI() {};
virtual void setupContent() {};
protected:
void setHookObject(QWidget *);
virtual void setupCST() {};
virtual void setupTitleBar() {};
/** event handles */
virtual bool eventFilter(QObject *, QEvent *);
/** Event handling method */
virtual bool mousePressEvent(QMouseEvent *) { return FALSE; };
virtual bool mouseReleaseEvent(QMouseEvent *) { return FALSE; };
virtual bool mouseMoveEvent(QMouseEvent *) { return FALSE; };
virtual bool mouseDblClickEvent(QMouseEvent *) { return FALSE; };
virtual bool mouseEnterEvent(QMouseEvent *) { return FALSE; };
virtual bool mouseLeaveEvent(QMouseEvent *) { return FALSE; };
virtual bool keyPressEvent(QKeyEvent *) { return FALSE; };
virtual bool keyReleaseEvent(QKeyEvent *) { return FALSE; };
virtual bool focusInEvent(QFocusEvent *) { return FALSE; };
virtual bool focusOutEvent(QFocusEvent *) { return FALSE; };
virtual bool paintEvent(QPaintEvent *) { return FALSE; };
virtual bool resizeEvent(QResizeEvent *) { return FALSE; };
virtual bool windowActivateEvent(QEvent *) { return FALSE; };
virtual bool windowDeactivateEvent(QEvent *) { return FALSE; };
virtual bool closeEvent(QCloseEvent *ev) { ev->accept(); return FALSE; };
protected:
int m_ix;
int m_iy;
int m_x;
int m_y;
int m_width;
int m_height;
bool m_isFullScreen;
bool m_isOnHookEvent;
bool m_isMouseBlocked;
QWidget *m_Widget;
};
#endif // __QEWIDGET_H__
CPP BODY - qeobject.cpp: PHP Code: /***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <stdio.h>
#include "qeobject.h"
/**
===========================================================================
QEObject class implementations
===========================================================================
*/
QEObject::QEObject(const char *name)
: QObject(0, name),
m_ix(0), m_iy(0), m_x(0), m_y(0), m_width(0), m_height(0),
m_isFullScreen(FALSE), m_isOnHookEvent(FALSE), m_isMouseBlocked(FALSE),
m_Widget(0)
{
}
QEObject::QEObject(QWidget *parent, const char *name)
: QObject(parent, name),
m_ix(0), m_iy(0), m_x(0), m_y(0), m_width(0), m_height(0),
m_isFullScreen(FALSE), m_isOnHookEvent(FALSE), m_isMouseBlocked(FALSE),
m_Widget(parent)
{
}
QEObject::~QEObject()
{
hookEvents(FALSE);
requestDestroy();
killTimers();
if (m_Widget) m_Widget->close(TRUE);
printf("(%s)->QEObject<-::destroy()\n", name());
}
void QEObject::setHookObject(QWidget *widget)
{
m_Widget = widget;
}
void QEObject::setMouseBlocked(bool block)
{
m_isMouseBlocked = block;
}
void QEObject::hookEvents(bool hook)
{
if (m_isOnHookEvent == hook) return;
m_isOnHookEvent = hook;
if (hook)
if (m_Widget) m_Widget->installEventFilter(this);
else
if (m_Widget) m_Widget->removeEventFilter(this);
}
/** event handles */
bool QEObject::eventFilter(QObject *obj, QEvent *ev)
{
bool endEvent = FALSE;
switch (ev->type())
{
case QEvent::MouseButtonPress:
if (m_isMouseBlocked) return TRUE;
endEvent = mousePressEvent((QMouseEvent *) ev);
break;
case QEvent::MouseButtonRelease:
if (m_isMouseBlocked) return TRUE;
endEvent = mouseReleaseEvent((QMouseEvent *) ev);
break;
case QEvent::MouseButtonDblClick:
if (m_isMouseBlocked) return TRUE;
endEvent = mouseDblClickEvent((QMouseEvent *) ev);
break;
case QEvent::MouseMove:
if (m_isMouseBlocked) return TRUE;
endEvent = mouseMoveEvent((QMouseEvent *) ev);
break;
case QEvent::Enter:
if (m_isMouseBlocked) return TRUE;
endEvent = mouseEnterEvent((QMouseEvent *) ev);
break;
case QEvent::Leave:
if (m_isMouseBlocked) return TRUE;
endEvent = mouseLeaveEvent((QMouseEvent *) ev);
break;
case QEvent::KeyPress:
endEvent = keyPressEvent((QKeyEvent *) ev);
break;
case QEvent::KeyRelease:
endEvent = keyReleaseEvent((QKeyEvent *) ev);
break;
case QEvent::FocusIn:
endEvent = focusInEvent((QFocusEvent *) ev);
break;
case QEvent::FocusOut:
endEvent = focusInEvent((QFocusEvent *) ev);
break;
case QEvent::Paint:
endEvent = paintEvent((QPaintEvent *) ev);
break;
case QEvent::Resize:
endEvent = resizeEvent((QResizeEvent *) ev);
break;
case QEvent::WindowActivate:
endEvent = windowActivateEvent((QEvent *) ev);
break;
case QEvent::WindowDeactivate:
endEvent = windowDeactivateEvent((QEvent *) ev);
break;
case QEvent::Close:
endEvent = closeEvent((QCloseEvent *) ev);
break;
default:
endEvent = obj->eventFilter(obj, ev);
break;
}
return (endEvent) ? endEvent : obj->eventFilter(obj, ev);
}
void QEObject::setGeometry(int x, int y, int w, int h)
{
if (m_Widget) m_Widget->setGeometry(x, y, w, h);
m_ix = m_x = x;
m_iy = m_y = y;
m_width = w;
m_height = h;
}
void QEObject::move(int x, int y)
{
if (m_Widget) m_Widget->move(x, y);
m_x = x;
m_y = y;
}
void QEObject::resize(int w, int h)
{
if (m_Widget) m_Widget->resize(w, h);
m_width = w;
m_height = h;
}
void QEObject::show()
{
if (m_Widget) m_Widget->show();
}
void QEObject::hide()
{
if (m_Widget) m_Widget->hide();
}
void QEObject::showNormal()
{
if (m_Widget) m_Widget->showNormal();
m_isFullScreen = FALSE;
}
void QEObject::showFullScreen()
{
if (m_Widget) m_Widget->showFullScreen();
m_isFullScreen = TRUE;
}
With the above try i had try to implement another class especialy the QWidget but it seem can not work.
Ok, i found the ZMainWidget can work with my technic, so i used it to my main widget for implement anothers. QEWidget class HEADER - qewidget.h PHP Code: /***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef __QEWIDGET_H__
#define __QEWIDGET_H__
#include <stdio.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qwidget.h>
#include <zmainwidget.h>
#include "qeglobal.h"
#include "qeobject.h"
/**
*****************************************************************************
class QEWidget definition
*****************************************************************************
*/
class QEWidget : public QEObject
{
Q_OBJECT
public:
QEWidget(const QString &title, QWidget *parent=0, const char *name = 0, WFlags f=0);
QEWidget(QWidget *parent, const char *name = 0, WFlags f=0);
QEWidget(const char *name = 0);
QEWidget(bool editorMode, QWidget *parent=0, const char *name=0, WFlags f=0);
virtual ~QEWidget();
ZMainWidget *widget() const { return (ZMainWidget*) m_Widget; };
WId winId() const { return (m_Widget) ? m_Widget->winId() : (unsigned int)-1; };
virtual void setBackgroundPixmap(const QPixmap &pix) { if (m_Widget) m_Widget->setBackgroundPixmap(pix); };
virtual void setBackgroundMode(const QWidget::BackgroundMode &);
virtual void setBackgroundColor(const QColor &clr) { if (m_Widget) m_Widget->setBackgroundColor(clr); };
protected:
WFlags m_WFlags;
};
#endif // __QEWIDGET_H__
and the BODY - qewidget.cpp PHP Code: /***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <qpainter.h>
#include "qewidget.h"
/**
*****************************************************************************
class QEWidget implementation
*****************************************************************************
*/
QEWidget::QEWidget(const QString &title, QWidget *parent, const char *name, WFlags f)
: QEObject(parent, name), m_WFlags(f)
{
m_Widget = new ZMainWidget(title, FALSE, parent, name, f);
CHECK_PTR(m_Widget);
widget()->getTitleBarWidget()->hide();
}
QEWidget::QEWidget(QWidget *parent, const char *name, WFlags f)
: QEObject(parent, name), m_WFlags(f)
{
m_Widget = new ZMainWidget("", FALSE, parent, name, f);
CHECK_PTR(m_Widget);
widget()->getTitleBarWidget()->hide();
}
QEWidget::QEWidget(const char *name)
: QEObject(0, name)
{
m_Widget = new ZMainWidget(name, FALSE, 0, name);
CHECK_PTR(m_Widget);
widget()->getTitleBarWidget()->hide();
}
QEWidget::QEWidget(bool editorMode, QWidget *parent, const char *name, WFlags f)
: QEObject(parent, name), m_WFlags(f)
{
m_Widget = new ZMainWidget(editorMode, parent, name, f);
CHECK_PTR(m_Widget);
widget()->getTitleBarWidget()->hide();
}
QEWidget::~QEWidget()
{
if (m_Widget) {
delete m_Widget;
m_Widget = 0;
}
printf("(%s)->QEWidget<-::destroy()\n", name());
}
void QEWidget::setBackgroundMode(const QWidget::BackgroundMode &bgm)
{
if (m_Widget) m_Widget->setBackgroundMode(bgm);
}
Because the ZMainWidget object have the title bar, then i hide it in the constructor of the class.
Well, lets go to the next section. | | The Following 2 Users Say Thank You to donga For This Useful Post: | | 
09-22-2007
|  | MotoFans JUNR | | Join Date: Jul 2007 Location: Samut Prakarn, Thailand
Posts: 79
Thanks: 2
Thanked 58 Times in 17 Posts
| | Components TOOLS- Linux box, i used OpenSUSE 10.2 (Yeah my default desktop in my life
). - CrossTool chain for make the arm binary from MkEzx.org
- Header of qt-embedded (if needed, see the attachments).
- Header of Samr7's dev-ezx (with my little modified, see the attachments).
- Header of my QE Library (see the attachments).
- Other tools, eg. progen, tmake (if needed see the attachments).
Uncompress samr7's header and qte-header to anywhere you want. (but may need to modified the enviroment to point to it).
Here is my enviroment scripts: Code: #!/bin/bash
export ARM_DEV_DIR=/opt/cross/arm
export CROSSTOOLS_DIR=/opt/cross/tools
export PATH=/opt/cross/tools/bin:/sbin:/usr/sbin:/usr/local/sbin:/opt/kde3/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin
export QTDIR=/home/EZX/dev-ezx
export TMAKEPATH=/opt/cross/tools/tmakespec/qws/linux-ezx-g++
Also you may used my tmakespec for your project (see the attachment).
For my QE Library you may links it to your project as neccessary, because i have never build it and pack to .so library coz it not stable yet.
In the next section, i'll show you how to use it. About LICENSE
All of my codes (QE Library) are released under the term of the GNU General Public License Version 2.0
Please send the code back if you modified it. Come on E6/A1200 developers, Lets join this project for made it better,
It's time to ROCK N ROLL
Last edited by donga; 09-24-2007 at 01:51 PM.
| 
09-22-2007
|  | MotoFans JUNR | | Join Date: Jul 2007 Location: Samut Prakarn, Thailand
Posts: 79
Thanks: 2
Thanked 58 Times in 17 Posts
| | The Application Template The Application Template
Well, this section will show you how to create the native ezx app woth QE Library.
First, i created the directory for contains the project sources, Code: donga@linux> mkdir QEAppTemplate
donga@linux> cd QEAppTemplate
donga@linux> mkdir -p src/lib
After that i'd link (or you may copy) neccessary class from the QE library to the src/lib directory: Code: lib/qeconfig.cpp
lib/qeobject.cpp
lib/qeglobal.h
lib/qeconfig.h
lib/qeapplication.h
lib/qewidget.h
lib/qeapplication.cpp
lib/qeglobal.cpp
lib/qeobject.h
lib/qepixmap_inc.h
lib/qemainwidget.cpp
lib/qewidget.cpp
lib/qemainwidget.h
well, after that lets open the editor for coding now.
Lets create the header class and the c++ body for main program, qeapptemplate.h and qeapptemplate.cpp qeapptemplate.h Code: #ifndef __QEAPPTEMPLATE_H__
#define __QEAPPTEMPLATE_H__
#include "lib/qemainwidget.h"
/**
*****************************************************************************
QEAppTemplate class definition
*****************************************************************************
*/
class QEAppTemplate : public QEMainWidget
{
Q_OBJECT
public:
QEAppTemplate(const char *name = 0);
~QEAppTemplate();
/** GUI creation */
virtual void setupGUI();
virtual void setupContent();
protected:
/** Event handling */
virtual bool mousePressEvent(QMouseEvent *) { qApp->quit(); return TRUE; };
};
#endif //__QEAPPTEMPLATE_H__
qeapptemplate.cpp Code:
#include "qeapptemplate.h"
/**
*****************************************************************************
QEAppTemplate class implementation
*****************************************************************************
*/
QEAppTemplate::QEAppTemplate(const char *name)
: QEMainWidget(0, name)
{
}
QEAppTemplate::~QEAppTemplate()
{
//delete cst;
printf("(%s)->QEAppTemplate<-::destroy()\n", name());
}
/** GUI creation */
void QEAppTemplate::setupGUI()
{
/* Show normal mode */
showNormalMode(TRUE, TRUE);
/* Setup CST Bar */
getCSTBarWidget(TRUE);
ZPushButton *btn = CSTwidget()->getRightBtn();
connect(btn, SIGNAL(clicked()), qApp, SLOT(slotQuickQuit()));
/* Set Title text */
((QLabel*)getTitleBarWidget())->setText("QE App Template");
/* Get Content widget */
(QScrollView*)getContentWidget(TRUE);
}
void QEAppTemplate::setupContent()
{
}
Then, create the main.cpp main.cpp Code: #include "lib/qeapplication.h"
#include "qeapptemplate.h"
int main(int argc, char** argv)
{
initApplication(argc, argv);
QEApplication app(argc, argv);
QEAppTemplate *mwg = new QEAppTemplate("QEAppTemplate");
app.showMainWidget(mwg);
int result = app.exec();
finishApplication();
return result;
}
After complete all of the aboves, lets generate the project .pro and Makefile woth the progen and tmake Code: donga@linux> cd ..
donga@linux> pwd
/home/EZX/DISTS/QEAppTemplate
donga@linux> . ENV.sh
donga@linux> progen -o qeapptemplate.pro && tmake qeapptemplate.pro -o Makefile
then make and strip the program Code: donga@linux> make && arm-linux-strip qeapptemplate
That's it. Now you already have the arm-binary qeapptemplate in the current directory.
Lets transfer it to your phone on the SD card,
telnet to the phone,
change directory to the directory ehich you transfer,
call profile script to set environment,
and call the program and watch the result on your phone. Code: linux:~ # telnet 192.168.1.2
Trying 192.168.1.2...
Connected to 192.168.1.2.
Escape character is '^]'.
MontaVista(R) Linux(R) Consumer Electronics Edition 3.1
Linux/armv5tel 2.4.20_mvlcee31-mainstone_pxa27x
(none) login: root
MontaVista(R) Linux(R) Consumer Electronics Edition 3.1
No directory /root!
Logging in with home = "/".
# cd /mmc/mmca1/qeapptemplate
# . /home/native/.profile
# ./qeapptemplate
And the result on the phone is:
That's it.......
Last edited by donga; 09-22-2007 at 05:36 PM.
| 
09-23-2007
| | MotoFans MODR | | Join Date: Aug 2007
Posts: 227
Thanks: 4
Thanked 6 Times in 6 Posts
| | Donga! I LOVE YOU!
You're My Hero Man.
I lost my phone, but I think i'll devleop some apps for you to test... in case i get it back :P | 
09-23-2007
|  | Moto Fans SENR | | Join Date: Oct 2006 Location: Lansing, MI, USA
Posts: 611
Thanks: 1
Thanked 16 Times in 11 Posts
| | Seriously... sick... Bloody sick!! I think that I may move my focus from writing apps to learing cpp so I can port them to cpp. More power for sure. | 
09-23-2007
| | MotoFans NWBE | | Join Date: Jul 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
| | very good!
Thanks ! | 
09-23-2007
|  | MotoFans MODR | | Join Date: Oct 2006 Location: Trinidad & Tobago
Posts: 168
Thanks: 12
Thanked 12 Times in 9 Posts
| | Very interesting progress! makes me want to brush up on my C++! Haven't done any serious programming in that language for years
__________________ "If I am somewhere where no one knows me,
And I also know no one,
What I thought I'd do there was,
I'd become one of those deaf mutes..." | 
09-24-2007
|  | Moderator | | Join Date: Jul 2005 Location: Thailand
Posts: 833
Thanks: 25
Thanked 233 Times in 80 Posts
| | Superb donga.
and how about header file for another ezx library? I think not all of samr7 's header file can work in A1200/e6. | 
09-24-2007
|  | MotoFans JUNR | | Join Date: Jul 2007 Location: Samut Prakarn, Thailand
Posts: 79
Thanks: 2
Thanked 58 Times in 17 Posts
| | @eakrin
Ake, the attachments are all of the headers i used to develop such qezxplayer, qeilock.
Or does it have more than that i have ?
I don't know, there are all of headers which i found on the net. | 
09-24-2007
| | Moto Fans SENR | | Join Date: Sep 2005 Location: Jakarta, Indonesia
Posts: 1,091
Thanks: 0
Thanked 135 Times in 67 Posts
| | I will try to port EditorE to A1200/E6 if possible. Thanks donga. How about share your qeiLock code?
__________________ eXMMS and Rockbox running on E680, E680i, E680g, A780, A1200 and ROKR E6 | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | |