00001
00002
00003
00004 #ifndef _SLPAINT_H_INCLUDED
00005 #define _SLPAINT_H_INCLUDED
00006
00007 #include <qwidget.h>
00008 #include <qscrollview.h>
00009
00010 #if defined QT_NO_PICTURE
00011 #define ENABLE_UNDO
00012 #endif
00013 #define ENABLE_PARTIAL_DECODE
00014
00015 #define PIXMAP_MAX_WIDTH (1024)
00016 #define PIXMAP_MAX_HEIGHT (768)
00017
00018 struct SlImageEditPrivate;
00019
00020 class SlImageEdit : public QWidget
00021 {
00022 Q_OBJECT
00023 public:
00024 SlImageEdit(QWidget *parent=0,const char *name=NULL,WFlags f=0);
00025 ~SlImageEdit();
00026
00027
00028
00029 enum SlImageEditTool {
00030
00031 Pen,
00032
00033 Eraser,
00034
00035 Select,
00036
00037 Scroll,
00038
00039 Line,
00040
00041 Box,
00042
00043 Ellipse
00044 };
00045 void setPixmap(QPixmap*);
00046 void clearPartialInfo();
00047 void setPartialPixmap(QPixmap*,const QSize&,const QRect&);
00048 QPixmap *pixmap() const;
00049 void setMinimumSize(int,int);
00050 void setTool(SlImageEditTool);
00051 SlImageEditTool tool() const;
00052 void setPenAttr(const QPen&);
00053 void setEraserAttr(const QPen&);
00054 QPen penAttr() const;
00055 QPen eraserAttr() const;
00056 void setPenBrush(const QBrush&);
00057 void setEraserBrush(const QBrush&);
00058 QBrush penBrush() const;
00059 QBrush eraserBrush() const;
00060 void setPenColor(const QColor&);
00061 void setPenWidth(uint);
00062 const QColor& penColor() const;
00063 uint penWidth() const;
00064 bool isSelected() const;
00065 bool cutSelectedImage();
00066 bool copySelectedImage();
00067 bool pasteImage();
00068 bool clearSelectedImage();
00069 #if !defined QT_NO_PICTURE || defined ENABLE_UNDO
00070 void flushEdit();
00071 void undo();
00072 bool isUndoAvailable();
00073 #endif
00074 bool isModified();
00075 void editClear();
00076 bool isTracing();
00077 #if defined(ENABLE_PARTIAL_DECODE)
00078 bool isPartialPixmap() const;
00079 QSize partialRealImageSize() const;
00080 QRect partialImageRect() const;
00081 void setPartialPixmapEnabled(bool);
00082 #endif
00083 void setVisible(bool);
00084
00085 signals:
00086
00087
00088 void selected(QRect&);
00089
00090
00091 void dragStart(const QPoint&);
00092
00093
00094 void dragExec(const QPoint&);
00095
00096
00097 void undoStatusChanged(bool);
00098
00099
00100 void modifyStatusChanged(bool);
00101
00102
00103 void scrollFinished();
00104
00105
00106 void pressed(const QPoint &);
00107
00108
00109
00110 void clicked(const QPoint &);
00111
00112 protected:
00113 void paintEvent(QPaintEvent*);
00114 void mousePressEvent(QMouseEvent*);
00115 void mouseMoveEvent(QMouseEvent*);
00116 void mouseReleaseEvent(QMouseEvent*);
00117
00118 private:
00119 void drawSelectFrame(const QPaintDevice *,const QRect &);
00120 bool selectToClipBoard();
00121 SlImageEditPrivate *p;
00122 };
00123
00124 struct SlScrollImageEditPrivate;
00125 class SlScrollImageEdit : public QScrollView
00126 {
00127 Q_OBJECT
00128 public:
00129 SlScrollImageEdit(QWidget *parent=0,const char *name=NULL,WFlags f=0);
00130 ~SlScrollImageEdit();
00131 SlImageEdit *image() const;
00132 bool loadImage(const QString &);
00133 void clearImage();
00134 void newImage(int x,int y,const QColor& fillColor=Qt::white);
00135 bool saveImage(const QString &,const char *format=NULL);
00136 bool scroll(int,int);
00137 void scale(double,double,bool isToOrigin=FALSE);
00138 void scale(int,int);
00139 bool isScaleAvailable(double,double,bool isToOrigin=FALSE);
00140 void xFormPixmap(QWMatrix&);
00141 void fullScreen();
00142 void normalScreen();
00143 void normalScreen(bool isNoLoad);
00144 #if 0
00145 void resetMinimumSize();
00146 #endif
00147 #if !defined QT_NO_PICTURE || defined ENABLE_UNDO
00148 bool isUndoAvailable();
00149 #endif
00150 bool isModified() const;
00151 ulong orgImageWidth() const;
00152 ulong orgImageHeight() const;
00153 ulong scaledWidth() const;
00154 ulong scaledHeight() const;
00155 bool isPartialRequired() const;
00156 void setDialogMode(bool isOn);
00157 void setEnabledImage(bool isEnabled);
00158
00159 signals:
00160
00161
00162 void keyPressed(QKeyEvent*);
00163
00164
00165 void undoStatusChanged(bool);
00166
00167
00168 void modifyStatusChanged(bool);
00169
00170
00171 void resized(int,int);
00172
00173
00174 void clicked(const QPoint &);
00175
00176 protected:
00177 void keyPressEvent(QKeyEvent*);
00178 void resizeEvent(QResizeEvent*);
00179
00180 private slots:
00181 void slotDragStart(const QPoint&);
00182 void slotDragExec(const QPoint&);
00183 void slotScrollFinished();
00184
00185 private:
00186 SlScrollImageEditPrivate *p;
00187 void updateForImage();
00188 bool loadPartialImage(const QString&,const QSize&,const QRect&);
00189 void reloadImage(bool isPaint=TRUE);
00190 void reloadPartialImage(bool isPaint=TRUE);
00191 void killFlicker(bool isEnabled);
00192
00193 };
00194
00195 #endif
00196
00197