Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

showimg.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of 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 
00021 #ifndef SHOWIMG_H
00022 #define SHOWIMG_H
00023 
00024 #include <qwidget.h>
00025 #include <qmainwindow.h>
00026 #include <qimage.h>
00027 #include <qlabel.h>
00028 #include <qlayout.h>
00029 #include <qscrollview.h>
00030 #include <qdialog.h>
00031 #include <qstringlist.h>
00032 #include <qvaluelist.h>
00033 #include <qwmatrix.h>
00034 
00035 
00036 class QAction;
00037 class QToolBar;
00038 class QMenuBar;
00039 class QPopupMenu;
00040 class QWidgetStack;
00041 class FileSelector;
00042 class DocLnk;
00043 class QLabel;
00044 class QAction;
00045 class QSpinBox;
00046 class ImageFileSelector;
00047 class QTimer;
00048 
00049 
00050 class ImageWidget : public QWidget
00051 {
00052     Q_OBJECT
00053  public:
00054     ImageWidget( QWidget *parent=0 )
00055         : QWidget( parent )   {
00056         setBackgroundMode(NoBackground);        
00057     }
00058     ~ImageWidget() {  }
00059 
00060     void setPixmap( const QPixmap &pm )  {
00061         pixmap = pm;
00062         show();
00063     }
00064 
00065 signals:
00066     void clicked();
00067 
00068 protected:
00069     void paintEvent( QPaintEvent * );
00070     void mouseReleaseEvent(QMouseEvent* event);
00071 
00072 private:
00073     QPixmap pixmap;
00074 };
00075 
00076 class InfoDialog:public QDialog
00077 {
00078     Q_OBJECT
00079 
00080 public:
00081 
00082     static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); 
00083 
00084 private:
00085 
00086     InfoDialog(const QString &caption,const QStringList text,   QWidget *parent);
00087 
00088 };  
00089 
00090 class ControlsDialog:public QDialog
00091 {
00092     Q_OBJECT
00093 
00094 public:
00095     ControlsDialog(const QString &caption,const QImage image,int *brightness,    QWidget *parent);
00096 
00097 
00098 private slots:
00099 
00100     void bValueChanged(int);
00101     void accept();
00102 
00103 
00104 private:
00105     ImageWidget *pixmap;
00106     QSpinBox *spb;
00107     QImage  img;
00108     int *b;
00109 }; 
00110 
00111 
00112 class ImagePane : public QWidget
00113 {
00114     Q_OBJECT
00115 public:
00116     ImagePane( QWidget *parent=0 );
00117     ~ImagePane() { }
00118 
00119     //void showStatus();
00120     //void hideStatus();
00121     //QLabel  *statusLabel()
00122     //{
00123     //    return status;
00124     //}
00125     void setPixmap( const QPixmap &pm );
00126 
00127 
00128     int  paneWidth() const {
00129         return image->visibleWidth(); 
00130     }
00131 
00132     int  paneHeight() const {
00133         return image->visibleHeight(); 
00134     }
00135 
00136     void setPosition(int x, int y) {
00137         image->setContentsPos (x,y );
00138     }
00139 
00140     void disable() {
00141         pic->hide();
00142     }
00143 
00144 signals:
00145     void clicked();
00146 
00147 private:
00148     QScrollView   *image;    
00149     ImageWidget  *pic;
00150     QVBoxLayout *vb;
00151 
00152 private slots:
00153     void imageClicked();
00154 };
00155 
00156 
00157 class ImageViewer : public QMainWindow
00158 {
00159     Q_OBJECT
00160 public:
00161     static QString appName() { return QString::fromLatin1("showimg"); }
00162     ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
00163     ~ImageViewer();
00164 
00165     void loadImage( const char *fileName );
00166     void show(const QString& fileref);
00167     void show();
00168 
00169 
00170     enum INFO_STRINGS {
00171         PATH,
00172         FORMAT,
00173         FILE_SIZE,
00174         SIZE,
00175         COLORS,
00176         ALPHA,
00177         LAST
00178     };
00179 
00180     enum RotateDirection   {
00181         Rotate90, Rotate180, Rotate270
00182     };
00183 
00184 
00185     static QImage  rotate(QImage &img, RotateDirection r);
00186     static QImage& intensity(QImage &image, float percent);
00187     static QImage& toGray(QImage &image, bool fast = false);
00188     bool showThumbView;              // a flag to indicate if FileSelector should be initialized with thumbnail view
00189 
00190 protected:
00191     void resizeEvent( QResizeEvent * );
00192     void closeEvent( QCloseEvent * );
00193 
00194 private:
00195     int  imageIndex(void);
00196 
00197     void updateCaption( QString name );
00198     bool loadSelected();
00199     void scale();
00200     bool reconvertImage();
00201     int calcHeight();
00202     void setImage(const QImage& newimage);
00203     void updateImageInfo(QString &filePath);
00204     void switchToFileSelector();
00205     void switchToImageView();
00206 
00207     void updateImage();
00208 
00209 private slots:
00210 
00211     void slideShow( bool on );
00212     void help(); 
00213     void slideUpdate();
00214     bool nextImage();
00215     bool prevImage();
00216     void settings();
00217 
00218     void switchThumbView();
00219     void switchSizeToScreen();
00220     void setDocument(const QString& fileref);
00221     void doDelayedLoad();
00222     void openFile( const DocLnk &file );
00223     void openFile();
00224     void open();
00225     void closeFileSelector();
00226     void hFlip();
00227     void vFlip();
00228     void rot180();
00229     void rot90();
00230     void rot270();
00231     void normalView();
00232     void fullScreen();
00233     void stopSlideShow();
00234     void blackAndWhite();
00235     void displayInfoDialog();
00236     void displayControlsDialog();
00237 private:
00238     QWMatrix matrix;
00239     bool rotated90;
00240     enum MENU_ITEMS  {
00241         SHOW_THUMBNAILS,
00242         SIZE_TO_SCREEN,
00243         BLACKANDWHITE
00244     };
00245 
00246     QString filename;
00247     QString delayLoad;
00248     QImage image;           // the loaded image
00249     QPixmap pm;         // the converted pixmap
00250     QPixmap pmScaled;       // the scaled pixmap
00251     QToolBar  *toolBar;
00252     QToolBar  *iconToolBar;
00253     QMenuBar  *menuBar;
00254     QMenuBar  *current;
00255 
00256 
00257     QPopupMenu  *fileMenuFile;
00258     QPopupMenu  *viewMenuFile;
00259     QPopupMenu  *optionsMenuFile;
00260     QPopupMenu  *fileMenuView;
00261     QPopupMenu  *viewMenuView;
00262 
00263     QAction     *sss;                // scale to screen size
00264 
00265     QLabel      *lab;
00266     ImagePane *imagePanel;
00267     QWidgetStack *stack;
00268     //FileSelector *fileSelector;
00269     ImageFileSelector *fileSelector;
00270     bool isFullScreen;
00271     bool isSized;                   // true if image is to be resized to fit the window size
00272     bool bFromDocView;              // a flag to indicate whether or not we were 
00273                                     // launched from the document view...
00274 
00275     int slideDelay;
00276     bool slideRepeat;
00277     bool slideReverse;      // show slideshow in reverse order
00278     bool rotateOnLoad;      // rotate by 90 degrees on loading
00279     bool fastLoad;
00280     QTimer *slideTimer;
00281     QValueList<DocLnk> imageList;
00282     QAction *slideAction;
00283     
00284 
00285     QString imageInfo[LAST];
00286 };
00287 
00288 
00289 #endif // SHOWIMG_H

Generated on Sat Nov 5 16:18:18 2005 for OPIE by  doxygen 1.4.2