LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pixmap9tileobject.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef PIXMAP9TILEOBJECT_H_
23 #define PIXMAP9TILEOBJECT_H_
24 
25 #include "pixmapobject.h"
26 #include <QRectF>
27 #include <QObject>
28 
29 class QPainter;
30 
31 namespace PixmapTilingStyle
32 {
33  enum Enum
34  {
37  };
38 }
39 
41 {
42  Q_OBJECT
43 
44 public:
45 
47  Pixmap9TileObject(const quint32 width, const quint32 height,
48  const QString& imageFilename,
49  const QVector<QRect>& sliceCoordinates,
52  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
53 
54  //this is the more friendly variant
55  Pixmap9TileObject( const quint32 width, const quint32 height,
56  const QString& imageFilename,
57  const quint32 topIn,const quint32 bottomIn,
58  const quint32 leftIn,const quint32 rightIn,
61  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
62 
63  virtual ~Pixmap9TileObject();
64 
65  virtual QSize size() const;
66  virtual int width() const;
67  virtual int height() const;
68  virtual QSizeF sizeF() const;
69 
70  //isSquare() from PixmapObject intentionally omitted because it's used for determining operations on the underlying pixmap,
71  // not the rendered version of the pixmaptileobject
72  //sizeOf() from PixmapObject intentionally omitted, since the underlying mem size of the pixmap is not affected by
73  // how the tiles are defined
74 
75  //WARNING: no guard on validity on undelying pixmap! check in caller if unsure
76  virtual void paint(QPainter * painter,const QPointF& targetOriginInPainterCS);
77 
78  virtual bool resize(const QSize& size);
79  virtual bool resize(const quint32 w,const quint32 h);
80 
81  virtual bool retile(const quint32 topIn,const quint32 bottomIn,
82  const quint32 leftIn,const quint32 rightIn,
85 
86  virtual bool retile(const QVector<QRect>& sliceCoordinates,
89 
90  static bool makeSlices(const quint32 width, const quint32 height,
91  const quint32 topIn,const quint32 bottomIn,
92  const quint32 leftIn,const quint32 rightIn,
93  QVector<QRect>& r_slices,
94  QRect& r_inCoords);
95 
96  friend class PixPager;
97  friend class PixPagerPage;
98  friend class PixPagerAtlasPage;
99 
100 protected:
101 
103  QSize m_destinationSizeRequested; //how large this needs to paint itself.
104  //geom and boundingrect are computed from this
105  QRect m_inCoords; //using QRect as a convenient way to store topIn,leftIn..etc passed in
106  //this is used by resize() so it can reuse the original "in" coords
107  //
108  QRectF m_geom; //calculated automatically from the slice coordinate setup
109  QRectF m_boundingRect; //derived from m_geom
110 
111  /*
112  [0][1][2]
113  [3][4][5]
114  [6][7][8]
115  */
116 
117  QVector<QRect> m_sourceRects;
118  QVector<QRectF> m_destRects;
119 
122 
123 };
124 
125 #endif /* PIXMAP9TILEOBJECT_H_ */