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.
22 #include <QtGui/QPixmap>
23 #include <QtCore/QRect>
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
);
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
&);
63 TileSet
& operator=(const TileSet
&);
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.
82 Q_DECLARE_FLAGS(Tiles
, Tile
)
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;
93 void initPixmap(int s
, const QPixmap
&, int w
, int h
, const QRect
®ion
);
97 int _w1
, _h1
, _w3
, _h3
;
100 Q_DECLARE_OPERATORS_FOR_FLAGS(TileSet::Tiles
)