tests/benchmarks/uimodels/GraphicsViewBenchmark/widgets/topbar.h
changeset 3 41300fa6a67c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     5 **
       
     6 ** This file is part of the examples of the Qt Toolkit.
       
     7 **
       
     8 ** $QT_BEGIN_LICENSE:LGPL$
       
     9 ** No Commercial Usage
       
    10 ** This file contains pre-release code and may not be distributed.
       
    11 ** You may use this file in accordance with the terms and conditions
       
    12 ** contained in the either Technology Preview License Agreement or the
       
    13 ** Beta Release License Agreement.
       
    14 **
       
    15 ** GNU Lesser General Public License Usage
       
    16 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    17 ** General Public License version 2.1 as published by the Free Software
       
    18 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    19 ** packaging of this file.  Please review the following information to
       
    20 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    22 **
       
    23 ** In addition, as a special exception, Nokia gives you certain
       
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
       
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
       
    26 ** package.
       
    27 **
       
    28 ** GNU General Public License Usage
       
    29 ** Alternatively, this file may be used under the terms of the GNU
       
    30 ** General Public License version 3.0 as published by the Free Software
       
    31 ** Foundation and appearing in the file LICENSE.GPL included in the
       
    32 ** packaging of this file.  Please review the following information to
       
    33 ** ensure the GNU General Public License version 3.0 requirements will be
       
    34 ** met: http://www.gnu.org/copyleft/gpl.html.
       
    35 **
       
    36 ** If you are unsure which license is appropriate for your use, please
       
    37 ** contact the sales department at http://qt.nokia.com/contact.
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef __TOPBAR_H__
       
    43 #define __TOPBAR_H__
       
    44 
       
    45 #include <QObject>
       
    46 #include <QHash>
       
    47 
       
    48 #include "gvbwidget.h"
       
    49 
       
    50 class QPixmap;
       
    51 class QPoint;
       
    52 class QGraphicsView;
       
    53 class QFont;
       
    54 
       
    55 class TopBar : public GvbWidget
       
    56 {
       
    57     Q_OBJECT
       
    58     
       
    59 public:
       
    60     enum Orientation
       
    61     {
       
    62         Portrait,
       
    63         Landscape,
       
    64         None
       
    65     };
       
    66     
       
    67 public:
       
    68     TopBar(QGraphicsView* mainView, QGraphicsWidget* parent);
       
    69     ~TopBar();
       
    70     
       
    71 public:
       
    72     void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
       
    73     QRectF boundingRect() const;
       
    74     void resizeEvent(QGraphicsSceneResizeEvent *event);
       
    75     inline QPoint getStatusBarLocation() { return m_topBarStatusBarMiddlePoint + 
       
    76         m_topBarStatusBarMiddle.rect().bottomLeft(); }
       
    77     
       
    78 public slots:
       
    79     void themeChange();
       
    80     
       
    81 protected:
       
    82     void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
    83     
       
    84 signals:
       
    85     void clicked(bool checked = false);
       
    86     
       
    87 private:
       
    88     QSizeF sizeHint(Qt::SizeHint which, 
       
    89         const QSizeF &constraint = QSizeF()) const;
       
    90     void setDefaultSizes();
       
    91     
       
    92     
       
    93 private:
       
    94     Q_DISABLE_COPY(TopBar)
       
    95 
       
    96     QGraphicsView* m_mainView;
       
    97     bool m_isLimeTheme;
       
    98     Orientation m_orientation;
       
    99 
       
   100     //Fonts
       
   101     QFont m_titleFont;
       
   102     QFont m_statusFont;
       
   103     
       
   104     //Pixmaps
       
   105     QPixmap m_topBarPixmap;
       
   106     QPixmap m_topBarUserIcon;
       
   107     QPixmap m_topBarUserStatus;
       
   108     QPixmap m_topBarStatusBarLeft;
       
   109     QPixmap m_topBarStatusBarRight;
       
   110     QPixmap m_topBarStatusBarMiddle;
       
   111     
       
   112     //Drawing points
       
   113     QPoint m_topBarUserIconPoint;
       
   114     QPoint m_topBarUserStatusPoint;
       
   115     QPoint m_topBarStatusBarLeftPoint;
       
   116     QPoint m_topBarStatusBarRightPoint;
       
   117     QPoint m_topBarStatusBarMiddlePoint;
       
   118     QPoint m_topBarStatusBarTextPoint;
       
   119     QPoint m_topBarTitlePoint;
       
   120     
       
   121     //Sizes
       
   122     QHash<QString, QSize> m_sizesBlue;
       
   123     QHash<QString, QSize> m_sizesLime;
       
   124 };
       
   125 
       
   126 #endif // __TOPBAR_H__