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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __TNENGINEHANDLER_H__ |
|
20 #define __TNENGINEHANDLER_H__ |
|
21 |
|
22 #include <QTimer> |
|
23 #include <QPainter> |
|
24 |
|
25 namespace WRT { |
|
26 |
|
27 class TnEngineGenerator; |
|
28 class TnEngineView; |
|
29 class WrtBrowserContainer; |
|
30 class WrtPageManager; |
|
31 |
|
32 class TnEngineHandler : public QObject |
|
33 { |
|
34 Q_OBJECT |
|
35 public: |
|
36 ~TnEngineHandler(); |
|
37 TnEngineHandler(WrtPageManager * mgr, QWidget * parent); |
|
38 |
|
39 public: |
|
40 void setVisible(bool visible); |
|
41 bool isVisible() const { return m_visible; } |
|
42 void setZoomOutLevel(int percent) { m_zoomOutLevel = percent; } |
|
43 int zoomOutLevel() const { return m_zoomOutLevel; } |
|
44 QRect theRect() const; |
|
45 QRect indicatorRect() const; |
|
46 TnEngineView* tnEngineView() { return m_TnEngineView; } |
|
47 |
|
48 void drawDocumentPart(QPainter& painter, const QRect& documentAreaToDraw); |
|
49 QRect documentViewport() const; |
|
50 void scaledPageChanged(const QRect& area, bool fullScreen, bool scroll); |
|
51 QSize documentSize() const; |
|
52 |
|
53 public slots: |
|
54 void documentStarted(); |
|
55 void documentChanged(); |
|
56 void documentCompleted(bool); |
|
57 void documentViewportMoved(); |
|
58 |
|
59 public: |
|
60 QRect TnEngineRect() const; |
|
61 void draw(QPainter& gc, const QRect& rect) const; |
|
62 QRect containerRect() const; |
|
63 void setContainerRect(const QRect& rect); |
|
64 bool isFullScreenMode() const; |
|
65 void setFullScreenMode(bool fullScreenMode); |
|
66 void updateNow(); |
|
67 QRect viewportOnDocument() const; |
|
68 |
|
69 public slots: |
|
70 |
|
71 void updateCbTimerCb(); |
|
72 void updateTimerCb(); |
|
73 void scrollBy(int x, int y); |
|
74 void draggingStarted(); |
|
75 void draggingEnded(); |
|
76 |
|
77 signals: |
|
78 void ok(int x, int y); |
|
79 |
|
80 private slots: |
|
81 void okInvoked(); |
|
82 |
|
83 private: |
|
84 friend class TnEngineGenerator; |
|
85 |
|
86 void createGenerator(); |
|
87 void destroyGenerator(); |
|
88 void createView(); |
|
89 void destroyView(); |
|
90 QRect fromDocCoords(const QRect& from) const; |
|
91 QPoint fromDocCoords(const QPoint& from) const; |
|
92 QSize fromDocCoords(const QSize& from) const; |
|
93 QRect toDocCoords(const QRect& from) const; |
|
94 QPoint toDocCoords(const QPoint& from) const; |
|
95 QSize toDocCoords(const QSize& from) const; |
|
96 bool checkAndCreateBitmap(QSize size, QPixmap*& image); |
|
97 QSize calcSize() const; |
|
98 QRect calcViewportOnDocument() const; |
|
99 void documentChangedCb(); |
|
100 void scrollTimerCb(); |
|
101 void visibilityTimerCb(); |
|
102 QRect viewportOnTnEngine() const; |
|
103 |
|
104 void activate(); |
|
105 void deactivate(); |
|
106 |
|
107 public: |
|
108 QWidget* widget(); |
|
109 bool isDocumentComplete() const { return m_documentComplete; } |
|
110 |
|
111 private: |
|
112 // Page Manager |
|
113 WrtPageManager * m_pageMgr; |
|
114 |
|
115 |
|
116 // generator |
|
117 TnEngineGenerator* m_generator; |
|
118 // zoom level of the TnEngine in percent |
|
119 int m_zoomOutLevel; |
|
120 QRect m_viewportOnDocument; |
|
121 bool m_needsUpdate; |
|
122 QTimer* m_updateTimer; |
|
123 QTimer* m_updateCbTimer; |
|
124 bool m_documentComplete; |
|
125 QRect m_containerRect; |
|
126 bool m_fullScreenMode; |
|
127 bool m_visible; |
|
128 bool m_pageScalerUpdating; |
|
129 WrtBrowserContainer* m_activePage; |
|
130 QPoint m_savedPointPageView; |
|
131 TnEngineView* m_TnEngineView; |
|
132 qreal m_scrollX; |
|
133 qreal m_scrollY; |
|
134 bool m_dragging; |
|
135 |
|
136 QWidget * m_parentWidget; |
|
137 }; |
|
138 |
|
139 } |
|
140 #endif |
|
141 |
|
142 // End of File |
|