src/hbinput/inputwidgets/hbinputscreenshotwidget.cpp
changeset 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbInput module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 #include <QPixmap>
       
    26 #include <QPainter>
       
    27 
       
    28 #include <hbframedrawer.h>
       
    29 #include <hbeffect.h>
       
    30 #include <hbwidget_p.h>
       
    31 
       
    32 #include "hbinputscreenshotwidget.h"
       
    33 #include "hbinputvkbwidget.h"
       
    34 
       
    35 
       
    36 /*!
       
    37 @proto
       
    38 @hbinput
       
    39 \class HbInputVkbWidget
       
    40 \brief A base class for touch keypads.
       
    41 
       
    42 This class implements default mechanisms for opening and closing touch keypads.
       
    43 It know how to operate in landscape and in portait modes and it know how
       
    44 implement split view -mechasnism for S60 QT UI's Hb library. It also implements
       
    45 closing mechansim, where used is able to close the touch keypad by sliding it downwards
       
    46 with a finger. This class also implements background drawing for touch keypads.
       
    47 */
       
    48 
       
    49 /// @cond
       
    50 
       
    51 class HbInputScreenshotWidgetPrivate : public HbWidgetPrivate
       
    52 {
       
    53     Q_DECLARE_PUBLIC(HbInputScreenshotWidget)
       
    54 
       
    55 public:
       
    56     HbInputScreenshotWidgetPrivate();
       
    57     virtual ~HbInputScreenshotWidgetPrivate();
       
    58 
       
    59     QPixmap mPixmap;
       
    60     HbFrameDrawer *mIconDrawer;
       
    61 
       
    62 };
       
    63 
       
    64 HbInputScreenshotWidgetPrivate::HbInputScreenshotWidgetPrivate()
       
    65 {
       
    66     mIconDrawer = new HbFrameDrawer();
       
    67 }
       
    68 
       
    69 HbInputScreenshotWidgetPrivate::~HbInputScreenshotWidgetPrivate()
       
    70 {
       
    71     delete mIconDrawer;
       
    72 }
       
    73 
       
    74 
       
    75 /// @endcond
       
    76 
       
    77 /*!
       
    78 Costructs the object.
       
    79 */
       
    80 HbInputScreenshotWidget::HbInputScreenshotWidget(QGraphicsItem* parent)
       
    81     : HbWidget(*new HbInputScreenshotWidgetPrivate, parent)
       
    82 {
       
    83     Q_D(HbInputScreenshotWidget);
       
    84     d->q_ptr = this;
       
    85 
       
    86     setPos(QPointF(0,0));
       
    87 
       
    88 #ifdef HB_EFFECTS
       
    89     HbEffect::disable(this);
       
    90 #endif // HB_EFFECTS
       
    91 
       
    92 #if QT_VERSION >= 0x040600
       
    93     // Make sure the keypad never steals focus.
       
    94     setFlag(QGraphicsItem::ItemIsPanel, true);
       
    95     setActive(false);
       
    96 #endif
       
    97 }
       
    98 
       
    99 /*!
       
   100 Destructs the object.
       
   101 */
       
   102 HbInputScreenshotWidget::~HbInputScreenshotWidget()
       
   103 { 
       
   104 }
       
   105 
       
   106 void HbInputScreenshotWidget::setScreenshot(QPixmap &pixmap)
       
   107 {
       
   108     Q_D(HbInputScreenshotWidget);
       
   109     d->mPixmap = pixmap;
       
   110 }
       
   111 
       
   112 /*!
       
   113 handles mouse press event.
       
   114 */
       
   115 void HbInputScreenshotWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
       
   116 {
       
   117     Q_UNUSED(event);
       
   118 }
       
   119 
       
   120 /*!
       
   121 Handles mouse release event.
       
   122 */
       
   123 void HbInputScreenshotWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
       
   124 {
       
   125     Q_UNUSED(event);
       
   126 }
       
   127 
       
   128 /*!
       
   129 The paint method. Draws the widget.
       
   130 */
       
   131 void HbInputScreenshotWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
       
   132 {
       
   133     Q_UNUSED(option);
       
   134     Q_UNUSED(widget);
       
   135 
       
   136     Q_D(HbInputScreenshotWidget);
       
   137     if (!d->mPixmap.isNull()){
       
   138         d->mIconDrawer->setFrameType(HbFrameDrawer::OnePiece);
       
   139         QRectF rect = boundingRect();
       
   140         rect.setLeft(rect.width()/2 - HbCloseHandleHeight*3);
       
   141         rect.setWidth(HbCloseHandleHeight*6);
       
   142         rect.setHeight(HbCloseHandleHeight);
       
   143 		d->mIconDrawer->setFrameGraphicsName(HbInputVkbHandleIcon);
       
   144         d->mIconDrawer->paint(painter, rect);
       
   145     	painter->drawPixmap(0, (int)HbCloseHandleHeight, d->mPixmap);
       
   146     }
       
   147 }
       
   148 
       
   149 
       
   150 /*!
       
   151 shape function actually refines the bounding rect. This function is used for collision detection
       
   152 and hit test.
       
   153 */
       
   154 QPainterPath HbInputScreenshotWidget::shape() const
       
   155 {
       
   156     QRectF rect = boundingRect();
       
   157     QPainterPath path;
       
   158     path.addRect(rect);
       
   159     return path;
       
   160 }
       
   161 
       
   162 
       
   163 // End of file