| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: showimg.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of an example program for Qt. This example
|
|---|
| 7 | ** program may be used, distributed and modified without limitation.
|
|---|
| 8 | **
|
|---|
| 9 | *****************************************************************************/
|
|---|
| 10 |
|
|---|
| 11 | #ifndef SHOWIMG_H
|
|---|
| 12 | #define SHOWIMG_H
|
|---|
| 13 |
|
|---|
| 14 | #include <qwidget.h>
|
|---|
| 15 | #include <qimage.h>
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | class QLabel;
|
|---|
| 19 | class QMenuBar;
|
|---|
| 20 | class QPopupMenu;
|
|---|
| 21 |
|
|---|
| 22 | class ImageViewer : public QWidget
|
|---|
| 23 | {
|
|---|
| 24 | Q_OBJECT
|
|---|
| 25 | public:
|
|---|
| 26 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
|
|---|
| 27 | ~ImageViewer();
|
|---|
| 28 | bool loadImage( const QString& );
|
|---|
| 29 | protected:
|
|---|
| 30 | void paintEvent( QPaintEvent * );
|
|---|
| 31 | void resizeEvent( QResizeEvent * );
|
|---|
| 32 | void mousePressEvent( QMouseEvent * );
|
|---|
| 33 | void mouseReleaseEvent( QMouseEvent * );
|
|---|
| 34 | void mouseMoveEvent( QMouseEvent * );
|
|---|
| 35 |
|
|---|
| 36 | private:
|
|---|
| 37 | void scale();
|
|---|
| 38 | int conversion_flags;
|
|---|
| 39 | bool smooth() const;
|
|---|
| 40 | bool useColorContext() const;
|
|---|
| 41 | int alloc_context;
|
|---|
| 42 | bool convertEvent( QMouseEvent* e, int& x, int& y );
|
|---|
| 43 | QString filename;
|
|---|
| 44 | QImage image; // the loaded image
|
|---|
| 45 | QPixmap pm; // the converted pixmap
|
|---|
| 46 | QPixmap pmScaled; // the scaled pixmap
|
|---|
| 47 |
|
|---|
| 48 | QMenuBar *menubar;
|
|---|
| 49 | QPopupMenu *file;
|
|---|
| 50 | QPopupMenu *saveimage;
|
|---|
| 51 | QPopupMenu *savepixmap;
|
|---|
| 52 | QPopupMenu *edit;
|
|---|
| 53 | QPopupMenu *options;
|
|---|
| 54 |
|
|---|
| 55 | QWidget *helpmsg;
|
|---|
| 56 | QLabel *status;
|
|---|
| 57 | int si, sp, ac, co, mo, fd, bd, // Menu item ids
|
|---|
| 58 | td, ta, ba, fa, au, ad, dd,
|
|---|
| 59 | ss, cc, t1, t8, t32;
|
|---|
| 60 | void updateStatus();
|
|---|
| 61 | void setMenuItemFlags();
|
|---|
| 62 | bool reconvertImage();
|
|---|
| 63 | int pickx, picky;
|
|---|
| 64 | int clickx, clicky;
|
|---|
| 65 | bool may_be_other;
|
|---|
| 66 | static ImageViewer* other;
|
|---|
| 67 | void setImage(const QImage& newimage);
|
|---|
| 68 |
|
|---|
| 69 | private slots:
|
|---|
| 70 | void to1Bit();
|
|---|
| 71 | void to8Bit();
|
|---|
| 72 | void to32Bit();
|
|---|
| 73 | void toBitDepth(int);
|
|---|
| 74 |
|
|---|
| 75 | void copy();
|
|---|
| 76 | void paste();
|
|---|
| 77 |
|
|---|
| 78 | void hFlip();
|
|---|
| 79 | void vFlip();
|
|---|
| 80 | void rot180();
|
|---|
| 81 |
|
|---|
| 82 | void editText();
|
|---|
| 83 |
|
|---|
| 84 | void newWindow();
|
|---|
| 85 | void openFile();
|
|---|
| 86 | void saveImage(int);
|
|---|
| 87 | void savePixmap(int);
|
|---|
| 88 | void giveHelp();
|
|---|
| 89 | void doOption(int);
|
|---|
| 90 | void copyFrom(ImageViewer*);
|
|---|
| 91 | };
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | #endif // SHOWIMG_H
|
|---|