fix logic
[personal-kdelibs.git] / khtml / imload / imagepainter.h
blob8a2167eeaa8ba8507c8a374d200248b41aab60fd
1 /*
2 Progressive image displaying library.
4 Copyright (C) 2004,2005 Maks Orlovich (maksim@kde.org)
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef IMAGE_PAINTER_H
26 #define IMAGE_PAINTER_H
28 class QPainter;
30 #include <QSize>
32 namespace khtmlImLoad {
34 class Image;
36 /**
37 An image painter let's one paint an image at the given size.
39 class ImagePainter
41 public:
42 /**
43 Creates an image painter for the given image...
45 ImagePainter(Image* image);
47 /**
48 Creates an image painter for the given image,
49 of given size
51 ImagePainter(Image* image, QSize size);
53 ImagePainter(const ImagePainter& src);
54 ImagePainter& operator=(const ImagePainter& src);
57 /**
58 Sets the size of the image.
60 void setSize(QSize size);
62 /**
63 Sets the image to the default size
65 void setDefaultSize();
67 /**
68 Cleans up
70 ~ImagePainter();
72 /**
73 Paints a portion of the image frame on the painter 'p' at dx and dy.
74 The source rectangle starts at sx, sy and has dimension width * height
76 void paint(int dx, int dy, QPainter* p, int sx = 0, int sy = 0,
77 int width = -1, int height = -1);
78 private:
79 // Note: we actually request/ref scaled version from Image
80 // lazily. This is because we may be constructed before there
81 // is anything to scale, so we check when painting..
82 Image* image;
83 QSize size;
84 bool sizeRefd;
89 #endif
90 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;