The Motorola Development Community


Go Back   MotorolaFans.com Forums > Developments > Development > Development Stickys
Notices

 

MotoFans JUNR

donga's Avatar

Join Date: Jul 2007
Posts: 79
Thanks: 2
Thanked 57 Times in 17 Posts
Location: Samut Prakarn, Thailand

 
#1
09-22-2007
Lightbulb 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 xint yint wint h);
    
virtual void move(int xint y);
    
virtual void resize(int wint h);
    
virtual void show();
    
virtual void hide();
    
virtual void showNormal();
    
virtual void showFullScreen();
    
virtual QSize sizeHint() const { return QSize(m_widthm_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_xm_ym_widthm_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(0name),
    
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(parentname),
    
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_Widgetm_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_Widgetm_Widget->installEventFilter(this);
    else
        if (
m_Widgetm_Widget->removeEventFilter(this);
}

/** event handles */
bool QEObject::eventFilter(QObject *objQEvent *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(objev);
            break;
    }
    return (
endEvent) ? endEvent obj->eventFilter(objev);
}

void QEObject::setGeometry(int xint yint wint h)
{
    if (
m_Widgetm_Widget->setGeometry(xywh);
    
m_ix m_x x;
    
m_iy m_y y;
    
m_width  w;
    
m_height h;
}

void QEObject::move(int xint y)
{
    if (
m_Widgetm_Widget->move(xy);
    
m_x x;
    
m_y y;
}

void QEObject::resize(int wint h)
{
    if (
m_Widgetm_Widget->resize(wh);
    
m_width  w;
    
m_height h;
}

void QEObject::show()
{
    if (
m_Widgetm_Widget->show();
}

void QEObject::hide()
{
    if (
m_Widgetm_Widget->hide();
}

void QEObject::showNormal()
{
    if (
m_Widgetm_Widget->showNormal();
    
m_isFullScreen FALSE;
}

void QEObject::showFullScreen()
{
    if (
m_Widgetm_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 &titleQWidget *parent=0, const char *name 0WFlags f=0);
    
QEWidget(QWidget *parent, const char *name 0WFlags f=0);
    
QEWidget(const char *name 0);
    
QEWidget(bool editorModeQWidget *parent=0, const char *name=0WFlags 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_Widgetm_Widget->setBackgroundPixmap(pix); };
    
virtual void setBackgroundMode(const QWidget::BackgroundMode &);
    
virtual void setBackgroundColor(const QColor &clr) { if (m_Widgetm_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 &titleQWidget *parent, const char *nameWFlags f)
  : 
QEObject(parentname), m_WFlags(f)
{
    
m_Widget = new ZMainWidget(titleFALSEparentnamef);
    
CHECK_PTR(m_Widget);
    
widget()->getTitleBarWidget()->hide();
}

QEWidget::QEWidget(QWidget *parent, const char *nameWFlags f)
  : 
QEObject(parentname), m_WFlags(f)
{
    
m_Widget = new ZMainWidget(""FALSEparentnamef);
    
CHECK_PTR(m_Widget);
    
widget()->getTitleBarWidget()->hide();
}

QEWidget::QEWidget(const char *name)
  : 
QEObject(0name)
{
    
m_Widget = new ZMainWidget(nameFALSE0name);
    
CHECK_PTR(m_Widget);
    
widget()->getTitleBarWidget()->hide();
}

QEWidget::QEWidget(bool editorModeQWidget *parent, const char *nameWFlags f)
  : 
QEObject(parentname), m_WFlags(f)
{
    
m_Widget = new ZMainWidget(editorModeparentnamef);
    
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_Widgetm_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.


User Information
Current Phone: E6
Location: Samut Prakarn, Thailand

donga is offlineReport Post
The Following 2 Users Say Thank You to donga For This Useful Post:
Dark Avenger (09-14-2008), Konig (01-30-2008)
MotoFans JUNR

donga's Avatar

Join Date: Jul 2007
Posts: 79
Thanks: 2
Thanked 57 Times in 17 Posts
Location: Samut Prakarn, Thailand

 
#2
09-22-2007
Default 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-e