Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZMainWidget.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------------------------------
00002 //
00003 // Header Name: ZMainWidget.h
00004 //
00005 // General Description: EZX Mainwidget.
00006 //
00007 //-------------------------------------------------------------------------------------------------
00008 //
00009 //                            Motorola Confidential Proprietary
00010 //                     Template ID and version: TMP_LFC_50068  Version 1.2
00011 //                      (c) Copyright Motorola 200{x}, All Rights Reserved
00012 //
00013 //-------------------------------------------------------------------------------------------------
00014 
00015 #ifndef Z_MAINWIDGET_H
00016 #define Z_MAINWIDGET_H
00017 
00018 #ifndef __cplusplus
00019 #error "This is a C++ header file;it requires C++ to compile."
00020 #endif
00021 
00022 
00023 #include <qscrollview.h>
00024 #include <qlayout.h>
00025 #include <qpopupmenu.h>
00026 #include <qstringlist.h>
00027 
00028 #include "ZGlobal.h"
00029 
00030 class QUuid;
00031 class ZPushButton;
00032 class ZMainWidgetData;
00033 
00034 /**
00035  * The ZMainWidget class implements the EZX style's base screen which consists
00036  * of two parts, a content Area and a CST Area.
00037  *
00038  * |--------------|
00039  * |              |
00040  * | Content Area |
00041  * |              |
00042  * |------------- |
00043  * | CST Area     |
00044  * |--------------|
00045  
00046  * You can use getContentWidget()/getCSTWidget() to get a default content/cst widget
00047  * which is ZScrollView/QFrame.
00048  *
00049  * You can also can use setContentWidget()/setCSTWidget() to set your own Content/CST 
00050  * widget.
00051  *
00052  * The class has two modes:
00053  *
00054  * 1. Edit mode (note: set constructor's param editorMode true): this class 
00055  * encapsulates some input methods relating functions.
00056  *
00057  * 2. Non-edit mode: in this mode, the input methods functions are not available.
00058  * The class is a simple container class. 
00059  *
00060  * For an application's to add its own input widget (like MMS object keyboard),
00061  * override showToolBar(), setToolBar(), hideToolBar(), and return true in these 
00062  * functions to indicate it is the application's special keyboard.
00063  *
00064  * @code
00065  * //set to edit mode
00066  * ZMainWidget* w = new ZMainWidget(true);
00067  *
00068  * ZScrollView* sv =  (ZScrollView*)w->getContentWidget();
00069  * ZMultiLineEdit* ml = new ZMultiLineEdit( sv->viewport(), true );
00070  * sv->addChild( ml, 0, 0 );
00071  * w->showMaximized();
00072  * @endcode
00073  */
00074 
00075 class ZMainWidget: public QWidget
00076 {
00077     Q_OBJECT
00078 
00079 public:
00080 
00081     /**
00082      * Constructor of ZMainWidget.
00083      * 
00084      * @param editorMode if true, it is edit mode, some input methods' functions 
00085      * are available; if false, it uses non-edit mode, making this just a container
00086      * class
00087      */
00088     ZMainWidget( bool editorMode, QWidget* parent,const char* name = 0,WFlags f = 0 );
00089 
00090     /**
00091      * Constructor of non-edit-mode ZMainWidget.
00092      * Just for convenience
00093      */
00094     ZMainWidget( QWidget* parent,const char* name = 0,WFlags f = 0 );
00095 
00096     /**
00097      * Destructor of ZApplication. 
00098      */
00099     virtual ~ZMainWidget();
00100 
00101 public:
00102 
00103     /**
00104      * Get the edit mode flag
00105      */
00106     bool getEditMode(); 
00107 
00108     /**
00109      * Get the content widget, if you do not set content widget before
00110      * calling this, the default content widget, a ZScrollView, will be 
00111      * created and returned.
00112      */
00113     QWidget* getContentWidget();
00114 
00115     /**
00116      * Set the content widget.
00117      *
00118      *@param w the content widget,
00119      *if NULL, a default content widget, a ZScrollView, is created.
00120      */
00121     virtual bool setContentWidget( QWidget* w = NULL );
00122 
00123     /**
00124      * Get the CST widget, if you do not set CST widget before calling
00125      * this, the default CST widget, a QFrame, will be created.
00126      */
00127     QWidget* getCSTWidget(); 
00128 
00129     /**
00130      * Set the CST widget.
00131      *
00132      *@param w the CST widget,
00133      *if is NULL, a default CST widget, a QFrame, is created.
00134      *
00135      * @note for A760 and A768, you can not set CST in the edit mode.
00136      */
00137     virtual bool setCSTWidget( QWidget* w = NULL );
00138 
00139     /**
00140      * Get the popup menu which lists the input methods' names.
00141      *
00142      * @note after A768, it will be obsolete, because the design is changed
00143      * so that there is no keyboad button. 
00144      *
00145      * New applications should not use this function.
00146      */
00147     QPopupMenu* getKbPopupMenu();
00148 
00149     /**
00150      * Get the popup menu which lists the input methods' names
00151      *
00152      * @note after A768, it will be obsolete, because the design is changed
00153      * so that there is no keyboad button. 
00154      *
00155      * New applications should not use this function.
00156      */
00157     ZPushButton* getKbBtn();
00158 
00159     enum
00160     {
00161         INPUTWIDGET_HIDE = 0, ///< \a \c input widget is hidden 
00162         INPUTWIDGET_SHOW,     ///< \a \c input widget is shown 
00163     };
00164 
00165     /**
00166      * Get the input widget status
00167      *
00168      * @see the enum above
00169      */
00170     int getKbState();
00171 
00172     /**
00173      * Set the current input method.
00174      *
00175      * This method will call setToolbar(). So, if want implement your
00176      * own input widget, you only need to override setToolbar() and return 
00177      * true
00178      *
00179      * @param method input method name
00180      *
00181      * @code
00182      * //set to edit mode
00183      * ZMainWidget* w = new ZMainWidget(true);
00184      * if ( w )
00185      * {
00186      *     //set english key board
00187      *     w->setInputMethod(IMID_ENGLISH_KB);
00188      * }
00189      * @endcode
00190      *
00191      * @see ZGlobal for system default input methods name list.
00192      *
00193      * @see setToolbar()
00194      */
00195     void setInputMethod( const QUuid& method = IMID_UNDEFINED );
00196 
00197     /**
00198      * Show the main widget and input widget at the same time.
00199      *
00200      * @param method input method name
00201      *
00202      * @code
00203      * //set to edit mode
00204      * ZMainWidget* w = new ZMainWidget(true);
00205      * if ( w )
00206      * {
00207      *     //set english key board and show the main widget 
00208      *     w->showWithInputMethod(IMID_ENGLISH_KB);
00209      * }
00210      * @endcode
00211      *
00212      * @see ZGlobal for system default input methods name list.
00213      */
00214     void showWithInputMethod( const QUuid & method = IMID_UNDEFINED );
00215 
00216     /**
00217      * Specify some input methods to the ZMainWidget, the user can see these candidates.
00218      * if do not set widget favour list, the default is the all input methods that
00219      * the application knows.
00220      * 
00221      * @param imList the ZMainWidget's favour input mathods list
00222      *
00223      * @see ZGlobal for system default input methods name list.
00224      *
00225      * @see setFavoriteInputMethods
00226      */
00227     void setFavoriteInputMethods( const QValueList<QUuid> & imList );
00228 
00229     /**
00230      * Bind the default input method and input methods names list that can 
00231      * be seen in the menu when the text entry focuses to the text entry.
00232      *
00233      * If you do not set the widget's favourite list, the default list is 
00234      * ZMainWidget's list.
00235      *
00236      * @param widget text entry
00237      * @param defaultIM the default input method
00238      * @param favourIMList the widget's favour input mathods name list
00239      *
00240      * @code
00241      * ZMultiLineEdit* ml = new UTIL_MultiLineEdit(sv->viewport(),true,2);
00242      * ml->setFixedWidth(230);
00243      * sv->addChild(ml,3,30,true);
00244      *
00245      * //set the input methods names list and set the default input method
00246      * QValueList<QUuid> flist1;
00247      * flist1.append( IMID_NUMBER_KB );
00248      * flist1.append( IMID_PINYIN_KB );
00249      * setInputMethods(ml,IMID_NUMBER_KB, flist1);
00250      * @endcode
00251      *
00252      * @see ZGlobal for system default input methods name list.
00253      *
00254      * @see setFavoriteInputMethods
00255      */
00256     void setInputMethods( QWidget* widget, const QUuid& defaultIM, 
00257                           const QValueList<QUuid> & favourIMList );
00258 
00259     /**
00260      * Almost the same as the above function, but there are all the input 
00261      * methods are available, just for convenience
00262      *
00263      * @param widget text entry
00264      * @param defaultIM the widget's default input mathod
00265      *
00266      * @see ZGlobal for system default input methods name list.
00267      */
00268     void setInputMethods( QWidget* widget, const QUuid& defaultIM );
00269 
00270 
00271 public:
00272 
00273     /**
00274      * Reimplement
00275      */
00276     virtual void show();
00277 
00278     /**
00279      * Reimplement
00280      */
00281     virtual void hide();
00282 
00283 
00284     /**
00285      * Raise the ZMainWidget
00286      */
00287     void raise();
00288 
00289     /**
00290      * Raise the ZMainWidget
00291      */
00292     void lower();
00293 
00294 public slots:
00295 
00296     /**
00297      * Hide the input widget
00298      */
00299     virtual void hideInputWidget(); 
00300 
00301     /**
00302      * The slot for the popup menu item is selected,
00303      * You can override it for the application own input widget
00304      *
00305      * @param id the id of the menu item
00306      */
00307     virtual void slotPopupMenu( int id );
00308 
00309     /**
00310      * Invoke the input widget
00311      *
00312      * @see setInputMethod()
00313      *
00314      * @internal, please use setInputMethod() 
00315      */
00316     virtual void invokeInputWidget(); 
00317 
00318 protected slots:
00319 
00320     /**
00321      * Update the input widget state
00322      *
00323      * @internal
00324      */
00325     virtual void updateInputWidgetState( int mwId,bool canClick );
00326 
00327 signals:
00328 
00329     /**
00330      * The signal is emitted when input widget's status is changed
00331      *
00332      * @param show if true, input widget is shown, or it is hidden
00333      */
00334     void kbStateChanged( bool show );
00335 
00336 protected:
00337 
00338     /**
00339      * Reimplement
00340      */
00341     virtual bool event( QEvent* e);
00342 
00343     /**
00344      * Reimplement
00345      */
00346     virtual bool qwsEvent( QWSEvent* e);
00347 
00348     /**
00349      * Reimplement
00350      */
00351     virtual void keyPressEvent( QKeyEvent* e );
00352 
00353     /**
00354      * Show a custom input widget, instead of the standard ones.
00355      *
00356      * @retval if true, the ZMainWidget has defined its own input widget
00357      *
00358      * @note need to care for your own content widget's geometry
00359      */
00360     virtual bool showToolBar() { return FALSE; } 
00361 
00362     /**
00363      * Set a custom input widget, instead of the standard ones.
00364      * 
00365      * @retval if true, the ZMainWidget has set its own input widget
00366      *
00367      * @note need to care for your own content widget's geometry
00368      */
00369     virtual bool setToolBar( const QUuid& ) { return FALSE; } 
00370 
00371     /**
00372      * Hide a custom input widget, instead of the standard ones.
00373      * 
00374      * @retval if true, the ZMainWidget has hide its ownreadConfig input widget
00375      *
00376      * @note need to care for your own content widget's geometry
00377      */
00378     virtual bool hideToolBar() { return FALSE; } 
00379 
00380     /**
00381      * Get ZMainWidget's current input method 
00382      * 
00383      * @param readConfig if true when there is no default input method, the function will
00384      * read the system config to get the application current input method name
00385      */
00386     QUuid getCurrentInputMethodName( bool readConfig = false );  
00387 
00388     /**
00389      * Set up the input method menu
00390      *
00391      * @internal
00392      */
00393     virtual void setupInputMethodsPopupMenu();
00394 
00395     /**
00396      * Check the menu item
00397      * 
00398      * @internal
00399      */
00400     void checkMenuItem( QPopupMenu* popup,QString text,bool select );
00401 
00402     /**
00403      * Get the loaded input methods list
00404      * 
00405      * @internal
00406      */
00407     QIMMap&  getIMList();
00408 
00409 private:
00410 
00411     void init();
00412     void updateAppDefaultInputMethod();
00413     void setPreDefinedKBFuncs();
00414 
00415 private slots:
00416 
00417     void popupKBMenu();
00418     void removeWidgetInputMethod();
00419     void objectDestroyed();
00420 
00421     void slotAppMessage( const QCString &msg, const QByteArray &data );
00422 
00423 private:
00424 
00425     QWidget* sv ;
00426     QWidget* cst;
00427     QVBoxLayout* vBox;
00428     bool editMode;
00429     int kbState;
00430     ZPushButton* kbBtn;
00431     QPopupMenu* kbPopupMenu;
00432 
00433     ZMainWidgetData* d;
00434 };
00435 
00436 #endif
00437 

Generated at Wed Mar 3 13:22:01 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001