Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / kstyles / oxygen / tileset.h
blob6f9fb3335a7ad98a7d9a4eae1fd5fe4642b77ac8
1 /*
2 * Copyright 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License version 2 as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public License
14 * along with this library; see the file COPYING.LIB. If not, write to
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
19 #ifndef TILESET_H
20 #define TILESET_H
22 #include <QtGui/QPixmap>
23 #include <QtCore/QRect>
25 class TileSet
27 public:
28 /**
29 * Create a TileSet from a pixmap. The size of the bottom/right chunks is
30 * whatever is left over from the other chunks, whose size is specified
31 * in the required parameters.
33 * @param w1 width of the left chunks
34 * @param h1 height of the top chunks
35 * @param w2 width of the not-left-or-right chunks
36 * @param h2 height of the not-top-or-bottom chunks
38 TileSet(const QPixmap&, int w1, int h1, int w2, int h2);
40 /**
41 * Create a TileSet from a pixmap. The size of the top/left and bottom/right
42 * chunks is specified, with the middle chunks created from the specified
43 * portion of the pixmap. This allows the middle chunks to overlap the outer
44 * chunks (or to not use all pixels). The top/left and bottom/right chunks
45 * are carved out of the corners of the pixmap.
47 * @param w1 width of the left chunks
48 * @param h1 height of the top chunks
49 * @param w3 width of the right chunks
50 * @param h3 height of bottom chunks
51 * @param x2 x-coordinate of the top of the not-left-or-right chunks
52 * @param y2 y-coordinate of the left of the not-top-or-bottom chunks
53 * @param w2 width of the not-left-or-right chunks
54 * @param h2 height of the not-top-or-bottom chunks
56 TileSet(const QPixmap &pix, int w1, int h1, int w3, int h3, int x2, int y2, int w2, int h2);
58 TileSet() : _empty(true) {}
59 TileSet(const TileSet&);
61 virtual ~TileSet() {}
63 TileSet& operator=(const TileSet&);
65 /**
66 * Flags specifying what sides to draw in ::render. Corners are drawn when
67 * the sides forming that corner are drawn, e.g. Top|Left draws the
68 * top-center, center-left, and top-left chunks. The center-center chunk is
69 * only drawn when Center is requested.
71 enum Tile {
72 Top = 0x1,
73 Left = 0x2,
74 Right = 0x8,
75 Bottom = 0x4,
76 Center = 0x10,
77 Ring = 0x0f,
78 Horizontal = 0x1a,
79 Vertical = 0x15,
80 Full = 0x1f
82 Q_DECLARE_FLAGS(Tiles, Tile)
84 /**
85 * Fills the specified rect with tiled chunks. Corners are never tiled,
86 * edges are tiled in one direction, and the center chunk is tiled in both
87 * directions. Partial tiles are used as needed so that the entire rect is
88 * perfectly filled. Filling is performed as if all chunks are being drawn.
90 void render(const QRect&, QPainter*, Tiles = Ring) const;
92 protected:
93 void initPixmap(int s, const QPixmap&, int w, int h, const QRect &region);
95 bool _empty;
96 QPixmap _pixmap[9];
97 int _w1, _h1, _w3, _h3;
100 Q_DECLARE_OPERATORS_FOR_FLAGS(TileSet::Tiles)
102 #endif //TILESET_H