blob: 1cfb91598baaa8c7a98c150a9a5b1b865ab08266 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef MTEXTMAGNIFIER_H
#define MTEXTMAGNIFIER_H
#include "mstylablewidget.h"
#include "mtextmagnifierstyle.h"
#include <MOverlay>
//! \internal
/*! \brief Magnifier widget to magnify text.
*
* The class magnifies contents of a certain source item.
* Position of the magnification is set by calling \a setMagnifiedPosition.
* Size of the magnification is determined entirely by style defined amount
* of magnification, and the size of the magnifier widget. Size of the widget
* on the other hand is defined by its frame image, read from style.
*
* To be always on top of other widgets in scene this magnifier uses
* MOverlay internally as a parent scene window.
*/
class MTextMagnifier : protected MStylableWidget
{
Q_OBJECT
public:
explicit MTextMagnifier(const QGraphicsItem &sourceItem);
virtual ~MTextMagnifier();
//! Show the magnifier. You should call \a setMagnifiedPosition before this.
void appear();
//! Hide magnifier.
void disappear();
//! Set magnified position in source item coordinates.
//! Magnifier is drawn at this position unless offset is defined in style.
void setMagnifiedPosition(const QPointF &sourceItemPos);
//! Tells whether magnifier is visible at the moment.
bool isAppeared() const;
protected:
//! \reimp
virtual void drawContents(QPainter *painter,
const QStyleOptionGraphicsItem *option) const;
virtual void applyStyle();
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
virtual QRectF boundingRect() const;
//! \reimp_end
private:
MTextMagnifier();
void prepareOffscreenSurface(const QSize &size);
const QGraphicsItem &sourceItem;
QScopedPointer<QPixmap> offscreenSurface;
QScopedPointer<QBitmap> mask;
MOverlay overlay;
M_STYLABLE_WIDGET(MTextMagnifierStyle)
};
//! \internal_end
#endif
|