LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pixmapjupocobject.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 PIXMAPJUPOCOBJECT_H_
23 #define PIXMAPJUPOCOBJECT_H_
24 
25 #include "pixmapobject.h"
26 #include <QRect>
27 #include <QUuid>
28 #include <QMap>
29 
31 
33 {
34  Q_OBJECT
35 
36 public:
37 
38  friend class PixmapJUPOCRefObject;
39 
40  //adds the pixmap to this JUPOC, if it can be added. Only a part of the pixmap can be added, by specifying a srcRect (if it's empty, then
41  // the whole pixmap is added). If successfull, a Uid is returned that can be used to retrieve the part with getPart(), later.
42  QUuid addPart(QPixmap& srcPixmap,const QRect& srcRect = QRect());
43  PixmapJUPOCRefObject * addAndGetPart(QPixmap& srcPixmap,const QRect& srcRect = QRect());
44  PixmapJUPOCRefObject * getPart(const QUuid& partUid);
45 
46  //copies the Pmo p_src to the jupoc.
47  // if return != null, then the object was copied and p_src disposed (do not attempt to use it after)
48  // if return == null, then the call failed, nothing was copied, and p_src is untouched
49  static PixmapJUPOCRefObject * transfer(PixmapJUPOCObject * p_jupoc,PixmapObject * p_src);
50 
51  virtual void fill(const QColor& c);
52 
53  static PixmapJUPOCObject * newJUPOC(quint32 width,quint32 height);
54  virtual ~PixmapJUPOCObject();
55 protected:
56 
58 
59  virtual QRect findSpace(QSize s);
60  bool advanceRow(quint32 heightNeeded);
61  //uses following return values: 0 = no space , 1 = try new row , 2 = rect allocated
62  int trySize(QSize s,QRect& r_rect);
63 protected:
64 
65  QMap<QUuid,QRect> m_parts;
66  QRect m_gridLocator; //my findSpace() uses this as well as m_lastRectAdded to do its little naive space finding algo
68 };
69 
70 #endif /* PIXMAPJUPOCOBJECT_H_ */