LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pixmapfilmstripobject.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2011-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 PIXMAPFILMSTRIPOBJECT_H_
23 #define PIXMAPFILMSTRIPOBJECT_H_
24 
25 #include "pixmapobject.h"
26 #include <QRect>
27 #include <QRectF>
28 #include <QPointF>
29 #include <QSize>
30 #include <QSizeF>
31 #include <QList>
32 
33 class QPainter;
34 
35 namespace FrameDirection
36 {
37  enum Enum
38  {
44  };
45 }
47 {
48  Q_OBJECT
49  Q_PROPERTY(quint32 frameindex READ frameIndex WRITE setFrameIndex)
50  Q_PROPERTY(quint32 totalframes READ totalFrames)
51 
52 public:
53 
54  static const char * FrameIndexPropertyName;
55  static const char * TotalFramesPropertyName;
56 
57  PixmapFilmstripObject(const QList<QRect> frameCoordinates,const QString & fileName,
58  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor );
59  PixmapFilmstripObject(const QSize& frameSize,quint32 numFrames,FrameDirection::Enum direction,
60  const QString & fileName,
61  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor,
62  const QPoint& startOffset = QPoint(0,0));
63  virtual ~PixmapFilmstripObject();
64 
65  virtual QSize size() const;
66  virtual int width() const;
67  virtual int height() const;
68  virtual QSizeF sizeF() const;
69 
70  virtual void paint(QPainter * painter);
71  virtual void paint(QPainter * painter,const QPointF& targetOriginInPainterCS);
72  virtual void paint(QPainter * painter,const QRectF& targetRectInPainterCS);
73 
74  // (see comments in PixmapObject.h/cpp)
75  virtual void paint(QPainter * painter,const QRect& targetRectInPainterCS,
76  const QRect& sourceRect);
77 
78  virtual bool valid() const;
79 
80  // goes to the next frame. if last frame and rollover=true, then it goes to first frame. Else, it does nothing
81  virtual void nextFrame(bool rollOver=false);
82 
83  //goes all the way back to the beginning (frame 0)
84  virtual void rewind();
85 
86  //uses saturation mode: index > framelist.size-1 will = size-1
87  virtual void setFrameIndex(quint32 index);
88  virtual quint32 frameIndex() const;
89  virtual quint32 totalFrames() const;
90 
91  virtual QSize minFrame() const;
92  virtual QSize maxFrame() const;
93 
94 protected:
95 
96  // creates numFrames equal sized (frameSize) frames, optionally offset into the source pix
97  virtual void createFrames(const QSize& frameSize,quint32 numFrames,FrameDirection::Enum direction,const QPoint& startOffset = QPoint(0,0));
98 
99  // creates arbitrarily sourced frames from the source pix
100  virtual void createFrames(const QList<QRect>& frameCoordinates);
101 
102 protected:
103 
106  QSize m_minFrameSize; //the width and height of the single frame with the smallest area
107  QSize m_maxFrameSize; // the maximum width and height of all frames; i.e. the minimum area needed to display every frame fully
108  QList<QRect> m_frames; //in progression order
109 
110 };
111 
112 #endif /* PIXMAPFILMSTRIPOBJECT_H_ */