LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
horizontallabeleddivider.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 HORIZONTALLABELEDDIVIDER_H_
23 #define HORIZONTALLABELEDDIVIDER_H_
24 
25 
26 #include "horizontaldivider.h"
27 
28 #include <QFont>
29 #include <QTextLayout>
30 
32 {
33  Q_OBJECT
34 
35 public:
36 
37  static HorizontalLabeledDivider * NewHorizontalLabeledDivider(const QString& label,quint32 width,PixmapObject * p_dividerPixmapObject);
38  virtual ~HorizontalLabeledDivider();
39 
40  // override the geometry logic from the base class...it must be done in order to make use of "alignment" geometry, if it is used
41  // see the icongeometrysettings.h/cpp files
42  // essentially, it's a way to trick the users of this class into thinking the geometry is actually different (intended only to be < than the actual geom)
43  virtual QRectF geometry() const;
44  virtual QRectF positionRelativeGeometry() const;
45 
46  virtual bool resize(const QSize& newSize);
47  virtual bool resize(quint32 newWidth,quint32 newHeight);
48 
49  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=0,QWidget *widget=0);
50  virtual void paint(QPainter *painter, const QRectF& sourceRect);
51  virtual void paint(QPainter *painter, const QRectF& sourceRect,qint32 renderOpts);
52  virtual void paintOffscreen(QPainter *painter);
53 
54  //TODO: temporary; remove when a better system (like styles) goes in place
55  static QFont staticLabelFontForHDiv();
56 
57  static QRectF AGEOM(const QRectF& geom); //alignment geom, if used
58 
59 protected Q_SLOTS:
60 
61  virtual void slotPixmapObjectInvalidated();
62 
63 
64 protected:
65 
67  HorizontalLabeledDivider(const QRectF& geom,const QString& label,PixmapObject * p_dividerPixmapObject);
68 
69  // PREREQUISITE: m_geom must be set correctly
70  // RESULT: m_textLayoutObject will have the correct layout, m_labelGeom will be set correctly for the current label,
71  virtual void redoLabelTextLayout(); //run this after the geometry changes. This is absolutely necessary
72  // ALSO run this after the label changes. don't ask, just do it. Not necessary now, but it most likely will be later
73 
74  // PREREQUISITE: m_geom and m_labelGeom are set
75  // RESULT: m_labelPosICS is set
76  virtual void recalculateLabelPosition();
77 
78  // PREREQUISITE: m_geom, m_labelGeom, m_labelPosICS, m_labelPixmapSpacing must be set correctly
79  // RESULT: m_pixmapGeom and m_pixmapPosICS will be set
81 
82  QRectF m_alignmentGeomPrecomputed; //populated only if StaticElementSettings::horizLabeledDivider_useAlignmentGeom is set true
83 
84  QPointer<PixmapObject> m_qp_divPixmap; // the graphic part of the divider
85  QPoint m_pixmapPosICS; //the position of the div pixmap (see base class) in ICS
86  QRect m_pixmapGeom; // using QRect so that it's easier on paint() (it doesn't have to pixalign constantly)
87 
88  qreal m_labelPixmapSpacing; //between the label and pixmap
89 
90  //text layout for the label
91  QString m_labelString;
93 
94  QPoint m_labelPosICS; // position in ICS, and corresponds to m_labelGeom
95  QRect m_labelGeom;
96 
97  QTextLayout m_textLayoutObject;
98 
99 };
100 
101 #endif /* HORIZONTALLABELEDDIVIDER_H_ */