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

ZMessageBox.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------------------------------
00002 //
00003 //   Header Name: ZMessageBox.h
00004 //
00005 //   General Description: EZX Message box class
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_MESSAGEBOX_H
00016 #define Z_MESSAGEBOX_H
00017 
00018 #ifndef __cplusplus
00019 #error "This is a C++ header file; it requires C++ to compile."
00020 #endif
00021 
00022 #include "ZBaseDialog.h"
00023 
00024 class  QLabel;
00025 struct ZMessageBoxPrivate;
00026 
00027 /**
00028  * Displays a brief message, an icon, and some buttons.
00029  *
00030  * ZMessageBox provides two types of dialogs: a dialog with up to three buttons 
00031  * and a dialog which will automatically disappear after specified seconds.
00032  *
00033  * As ZMessageBox inherits from ZBaseDialog, the ZMessageBox modal can be 
00034  * modeless, modal, and system modal. @see ZBaseDialog 
00035  *
00036  * For the message box with buttons, the class takes care of the buttons' 
00037  * geometry management. The return value of exec function is the button index
00038  * which was clicked. For example, if the leftmost button was clicked, return 
00039  * valus is 0.
00040  *
00041  * @code
00042  *  ZMessageBox* msgbox = new ZMessageBox(this, pixmapPhone,
00043  *                            "System Failure\nUnleashing fury upon the world now....",
00044  *                            "OK",
00045  *                            "Cancel",
00046  *                            NULL
00047  *                            );
00048  *  int reply = msgbox->exec();
00049  *
00050  *  delete msgbox;
00051  * 
00052  *  switch(reply)
00053  *  {
00054  *    case 0:
00055  *        cout<<"OK was Pressed"<<endl;
00056  *        break;
00057  *    case 1:
00058  *        cout<<"Cancel was Pressed"<<endl;
00059  *        break;
00060  *  }
00061  * @endcode
00062  *  
00063  * Below is the example of a message box which will automitically disappear 
00064  * after 2 seconds.
00065  *
00066  * @code
00067  *  ZMessageBox* msgbox = new ZMessageBox(this, pixmapPhone,
00068  *                            "System Failure\nFormatting Disk C:",
00069  *                             2);
00070  *  msgbox->exec();
00071  *  delete msgbox;
00072  * @endcode
00073  */
00074 
00075 class Q_EXPORT ZMessageBox : public ZBaseDialog
00076 {
00077     Q_OBJECT
00078 
00079 public:
00080 
00081     /**
00082      * Constructor for a message box with a text, an icon and up 
00083      * to three buttons.
00084      *
00085      * @param parent The parent object of this widget.
00086      * @param iconPixmap Icon shown on the dialog.
00087      * @param text Content text on the dialog
00088      * @param button0Text the leftmost button text
00089      * @param button1Text the middle button text
00090      * @param button2Text the rightmost button text
00091      * @param modal the modal of the message box 
00092      */
00093     ZMessageBox( QWidget *parent, const QPixmap& iconPixmap,
00094             const QString& text, 
00095             const QString& button0Text = QString::null,
00096             const QString& button1Text = QString::null,
00097             const QString& button2Text = QString::null,
00098             int modal = ZBaseDialog::APP_MODAL );
00099 
00100     /**
00101      * Constructor for a message box with a text, an icon.
00102      * The message box will automatically disappear after nseconds.
00103      *
00104      * @param parent The parent object of this widget.
00105      * @param iconPixmap Icon shown on the dialog
00106      * @param text Content text on the dialog
00107      * @param nseconds Seconds the dialog will disappear
00108      * @param modal The modal of the dialog
00109      */
00110     ZMessageBox( QWidget *parent, const QPixmap& iconPixmap,
00111             const QString& text, const int nseconds,
00112             int modal = ZBaseDialog::APP_MODAL );
00113 
00114 
00115     /**
00116      * Destructor.
00117      */
00118     ~ZMessageBox();
00119 
00120     /**
00121      * Sets the message box text to be displayed.
00122      * 
00123      * @param text the string will be shown
00124      */
00125     void setText( const QString &text );
00126 
00127     /**
00128      * Sets the message box icon to be displayed.
00129      * 
00130      * @param pixmap the icon will be shown.
00131      */
00132     void setIconPixmap( const QPixmap &pixmap );
00133 
00134     /**
00135      * Sets the text of the message box button.
00136      * 
00137      * @param button the button index, begin from 0.
00138      * @param text the string will be shown on the button.
00139      */
00140     void setButtonText( int button, const QString &text );
00141 
00142     /**
00143      * Adjusts the size of the message box to fit the contents just before
00144      * QDialog::exec() or QDialog::show() is called.
00145      */
00146     void adjustSize();
00147 
00148     /**
00149      * Opens an message box with a text and up to three buttons.
00150      * 
00151      * @param parent The parent object of this widget
00152      * @param iconPixmap the icon on the message box
00153      * @param text the content text on the message box
00154      * @param button0Text the leftmost button text
00155      * @param button1Text the middle button text
00156      * @param button2Text the rightmost button text
00157      * @param modal the modal of the message box 
00158      * 
00159      * @return the identifier of the button that was clicked. 
00160      */
00161     static int information( QWidget *parent, 
00162                 const QPixmap& iconPixmap,
00163                 const QString& text, 
00164                 const QString& button0Text = QString::null,
00165                 const QString& button1Text = QString::null,
00166                 const QString& button2Text = QString::null,
00167                 int modal = ZBaseDialog::APP_MODAL );
00168 
00169     /**
00170      * Opens an information message box with a text and up to threee buttons.
00171      * The message box will return if timer is set. 
00172      * 
00173      * @param parent the parent of the message box
00174      * @param iconPixmap the icon on the message box
00175      * @param text the content text on the message box
00176      * @param nseconds the seconds the message box will time out
00177      * @param button0Text the leftmost button text
00178      * @param button1Text the middle button text
00179      * @param button2Text the rightmost button text
00180      * @param modal the modal of the message box 
00181      * 
00182      * @return the identifier of the button that was clicked. If timer is set, 
00183      * when the time timeout, the return value is -1.
00184      */
00185     static int timerInformation( QWidget *parent, 
00186                 const QPixmap& iconPixmap,
00187                 const QString& text, 
00188                 int nseconds,
00189                 const QString& button0Text = QString::null,
00190                 const QString& button1Text = QString::null,
00191                 const QString& button2Text = QString::null,
00192                 int modal = ZBaseDialog::APP_MODAL );
00193 
00194     /**
00195      * Opens an information message box with a text and no button.
00196      * The message box will return if timer is set. 
00197      * 
00198      * @param parent the parent of the message box
00199      * @param iconPixmap the icon on the message box
00200      * @param text the content text on the message box
00201      * @param nseconds the seconds the message box will time out
00202      * @param modal the modal of the message box 
00203      */
00204     static void timerMessage( QWidget *parent, const QPixmap& iconPixmap,
00205                  const QString& text, const int nseconds, 
00206                  int modal = ZBaseDialog::APP_MODAL );
00207 
00208 protected:
00209     
00210     /**
00211      * @reimplemented
00212      */
00213     void resizeEvent( QResizeEvent * );
00214 
00215     /**
00216      * @reimplemented
00217      */
00218     void keyPressEvent( QKeyEvent * );
00219 
00220 private slots:
00221     
00222     void slotButtonClicked();
00223     void slotTimerOutForDlgWithBtn();
00224     void slotTimerDone();
00225 
00226 private:
00227     
00228     void init( int, int, int );
00229     int indexOf( int ) const;
00230     void resizeButtons();
00231     QLabel *label;
00232     ZMessageBoxPrivate *d;
00233 };
00234 
00235 #endif // Z_MESSAGEBOX_H

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