46
|
1 |
/*!
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implements grid of numeric buttons
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef DIALPADNUMERICBUTTONGRID_H
|
|
19 |
#define DIALPADNUMERICBUTTONGRID_H
|
|
20 |
|
|
21 |
#include <QTextLayout>
|
|
22 |
#include <QColor>
|
|
23 |
#include <hbinputbuttongroup.h>
|
|
24 |
|
|
25 |
class DialpadNumericButton;
|
|
26 |
|
|
27 |
class DialpadNumericButtonGrid : public HbInputButtonGroup
|
|
28 |
{
|
|
29 |
Q_OBJECT
|
|
30 |
|
|
31 |
public:
|
|
32 |
explicit DialpadNumericButtonGrid(
|
|
33 |
const HbMainWindow& mainWindow,
|
|
34 |
QGraphicsItem* parent=0);
|
|
35 |
|
|
36 |
~DialpadNumericButtonGrid();
|
|
37 |
|
|
38 |
public:
|
|
39 |
void resetButtons();
|
|
40 |
|
|
41 |
QChar inputCharacter(int keyCode) const;
|
|
42 |
|
|
43 |
protected slots:
|
|
44 |
void setButtonTexts();
|
|
45 |
void updateButtonLabels();
|
|
46 |
void cancelButtonPress();
|
|
47 |
|
|
48 |
protected:
|
|
49 |
inline DialpadNumericButton* button(int i) const;
|
|
50 |
void updateColorArray();
|
|
51 |
void updateIconColor();
|
|
52 |
void updateTextLayouts(const QSizeF &size);
|
|
53 |
void resolveTextContent(QList<QString> &content, bool& useTwoRows);
|
|
54 |
void createTextLayouts(const QSizeF &size,
|
|
55 |
const QList<QString> &content,
|
|
56 |
bool useTwoRows);
|
|
57 |
void layoutTextLines(const QSizeF &size,
|
|
58 |
QTextLayout &textLayout,
|
|
59 |
int state,
|
|
60 |
int type,
|
|
61 |
bool useTwoRows);
|
|
62 |
inline void layoutPrimaryText(
|
|
63 |
QTextLayout& layout,
|
|
64 |
DialpadNumericButton& button,
|
|
65 |
qreal cellWidth,
|
|
66 |
qreal cellHeight,
|
|
67 |
qreal textHeight) const;
|
|
68 |
inline void layoutSecondaryText(
|
|
69 |
QTextLayout& layout,
|
|
70 |
DialpadNumericButton& button,
|
|
71 |
qreal cellWidth,
|
|
72 |
qreal cellHeight,
|
|
73 |
qreal textHeight,
|
|
74 |
qreal textDescent,
|
|
75 |
bool useTwoRows) const;
|
|
76 |
bool isButtonPressed() const;
|
|
77 |
void updateIconSizes();
|
|
78 |
|
|
79 |
protected:
|
|
80 |
void paint(QPainter* painter,
|
|
81 |
const QStyleOptionGraphicsItem* option,
|
|
82 |
QWidget* widget);
|
|
83 |
void setGeometry(const QRectF &rect);
|
|
84 |
void changeEvent(QEvent *event);
|
|
85 |
|
|
86 |
private:
|
|
87 |
enum ButtonState {
|
|
88 |
Normal = 0,
|
|
89 |
Pressed,
|
|
90 |
StateCount
|
|
91 |
};
|
|
92 |
|
|
93 |
enum TextType {
|
|
94 |
PrimaryText = 0,
|
|
95 |
SecondaryText,
|
|
96 |
TextTypeCount
|
|
97 |
};
|
|
98 |
|
|
99 |
private:
|
|
100 |
const HbMainWindow& mMainWindow;
|
|
101 |
QList<QColor> mColors;
|
|
102 |
QList<QTextLayout*> mTextLayouts;
|
|
103 |
qreal mUnit;
|
|
104 |
qreal mMaxPrimaryLineWidth;
|
|
105 |
qreal mPrimaryTextBaseline;
|
|
106 |
QMap<int,QChar> mGeneratedChar;
|
|
107 |
};
|
|
108 |
|
|
109 |
#endif // DIALPADNUMERICBUTTONGRID_H
|