Qtopia library API Documentation

qpeapplication.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef __QPE_APPLICATION_H__
00021 #define __QPE_APPLICATION_H__
00022 
00023 #include <stdlib.h> // for setenv()
00024 
00025 #include <qglobal.h>
00026 #include <qapplication.h>
00027 #include <qdialog.h>
00028 #include <qwsdisplay_qws.h>
00029 #if defined(_WS_QWS_) && !defined(Q_WS_QWS)
00030 #define Q_WS_QWS
00031 #endif
00032 #include "qpedecoration_qws.h"
00033 #include "timestring.h"
00034 
00035 class QCopChannel;
00036 class QPEApplicationData;
00037 class QWSEvent;
00038 class QWSKeyEvent;
00039 
00079 class QPEApplication : public QApplication
00080 {
00081     Q_OBJECT
00082 public:
00083     QPEApplication( int& argc, char **argv, Type=GuiClient );
00084     ~QPEApplication();
00085 
00086     static QString qpeDir();
00087     static QString documentDir();
00088     void applyStyle();
00089     void reset();
00090     static int defaultRotation();
00091     static void setDefaultRotation(int r);
00092     static void setCurrentRotation(int r);
00093     static void setCurrentMode(int x, int y, int depth );
00094     static void grabKeyboard();
00095     static void ungrabKeyboard();
00096 
00097     enum StylusMode {
00098         LeftOnly,
00099         RightOnHold
00100         // RightOnHoldLeftDelayed, etc.
00101     };
00102     static void setStylusOperation( QWidget*, StylusMode );
00103     static StylusMode stylusOperation( QWidget* );
00104 
00105     enum InputMethodHint {
00106         Normal,
00107         AlwaysOff,
00108         AlwaysOn
00109     };
00110 
00111     enum screenSaverHint {
00112         Disable = 0,
00113         DisableLightOff = 1,
00114         DisableSuspend = 2,
00115         Enable = 100
00116     };
00117 
00118     static void setInputMethodHint( QWidget *, InputMethodHint );
00119     static InputMethodHint inputMethodHint( QWidget * );
00120 
00121     void showMainWidget( QWidget*, bool nomax=FALSE );
00122     void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
00123     static void showDialog( QDialog*, bool nomax=FALSE );
00124     static int execDialog( QDialog*, bool nomax=FALSE );
00125     static void showWidget( QWidget*, bool nomax=FALSE );
00126     /* Merge setTempScreenSaverMode */
00127 #ifdef QTOPIA_INTERNAL_INITAPP
00128     void initApp( int argv, char **argv );
00129 #endif
00130 
00131     static void setKeepRunning();
00132     bool keepRunning() const;
00133 
00134     bool keyboardGrabbed() const;
00135 
00136     int exec();
00137 
00138 signals:
00139     void clientMoused();
00140     void timeChanged();
00141     void clockChanged( bool pm );
00142     void micChanged( bool muted );
00143     void volumeChanged( bool muted );
00144     void appMessage( const QCString& msg, const QByteArray& data);
00145     void weekChanged( bool startOnMonday );
00146     void dateFormatChanged( DateFormat );
00147     void flush();
00148     void reload();
00149     /* linkChanged signal */
00150 
00151 private slots:
00152     void systemMessage( const QCString &msg, const QByteArray &data );
00153     void pidMessage( const QCString &msg, const QByteArray &data );
00154     void removeSenderFromStylusDict();
00155     void hideOrQuit();
00156 
00157 protected:
00158     bool qwsEventFilter( QWSEvent * );
00159     void internalSetStyle( const QString &style );
00160     void prepareForTermination(bool willrestart);
00161     virtual void restart();
00162     virtual void shutdown();
00163     bool eventFilter( QObject *, QEvent * );
00164     void timerEvent( QTimerEvent * );
00165     bool raiseAppropriateWindow();
00166     virtual void tryQuit();
00167 #if QT_VERSION > 233
00168     virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
00169 #endif
00170 private:
00171 #ifndef QT_NO_TRANSLATION
00172     void installTranslation( const QString& baseName );
00173 #endif
00174     void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
00175     void processQCopFile();
00176 
00177 #if defined(Q_WS_QWS) && !defined(QT_NO_COP)
00178     QCopChannel *sysChannel;
00179     QCopChannel *pidChannel;
00180 #endif
00181     QPEApplicationData *d;
00182 
00183     bool reserved_sh;
00184 
00185 
00186 
00187 };
00188 
00189 inline void QPEApplication::showDialog( QDialog* d, bool nomax )
00190 {
00191     QSize sh = d->sizeHint();
00192     int w = QMAX(sh.width(),d->width());
00193     int h = QMAX(sh.height(),d->height());
00194     if ( !nomax
00195             && ( w > qApp->desktop()->width()*3/4
00196                  || h > qApp->desktop()->height()*3/4 ) )
00197     {
00198         d->showMaximized();
00199     } else {
00200         d->resize(w,h);
00201         d->show();
00202     }
00203 }
00204 
00205 inline int QPEApplication::execDialog( QDialog* d, bool nomax )
00206 {
00207     showDialog(d,nomax);
00208     return d->exec();
00209 }
00210 
00211 inline void QPEApplication::showWidget( QWidget* wg, bool nomax )
00212 {
00213     QSize sh = wg->sizeHint();
00214     int w = QMAX(sh.width(),wg->width());
00215     int h = QMAX(sh.height(),wg->height());
00216     if ( !nomax
00217             && ( w > qApp->desktop()->width()*3/4
00218                  || h > qApp->desktop()->height()*3/4 ) )
00219     {
00220         wg->showMaximized();
00221     } else {
00222         wg->resize(w,h);
00223         wg->show();
00224     }
00225 }
00226 
00227 enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
00228 
00229 inline int TransToDeg ( Transformation t )
00230 {
00231     int d = static_cast<int>( t );
00232     return d * 90;
00233 }
00234 
00235 inline Transformation DegToTrans ( int d )
00236 {
00237     Transformation t = static_cast<Transformation>( d / 90 );
00238     return t;
00239 }
00240 
00241 /*
00242  * Set current rotation of Opie, and rotation for newly started apps.
00243  * Differs from setDefaultRotation in that 1) it rotates currently running apps,
00244  * and 2) does not set deforient or save orientation to qpe.conf.
00245  */
00246 
00247 inline void QPEApplication::setCurrentRotation( int r )
00248 {
00249     // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
00250     // for compatibility with the SharpROM use fallback to setDefaultTransformation()
00251 #if QT_VERSION > 233
00252     Transformation e = DegToTrans( r );
00253     ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
00254     qApp->desktop()->qwsDisplay()->setTransformation( e );
00255 #else
00256     setDefaultRotation( r );
00257 #endif
00258 }
00259 
00260 
00261 #endif
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:07 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001