1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
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 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
11 * |
8 * |
12 * Contributors: |
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * Description: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
|
18 |
21 |
19 #ifndef __GINEBRA_CHROMESNIPPET_H__ |
22 #ifndef __GINEBRA_CHROMESNIPPET_H__ |
20 #define __GINEBRA_CHROMESNIPPET_H__ |
23 #define __GINEBRA_CHROMESNIPPET_H__ |
21 |
24 |
22 #include <QString> |
25 #include <QString> |
23 #include <QObject> |
26 #include <QObject> |
24 #include <QTransform> |
27 #include <QTransform> |
25 #include <QWebElement> |
28 #include <QWebElement> |
26 #include "ChromeWidget.h" |
29 #include "ChromeWidget.h" |
|
30 #include "ChromeLayout.h" |
27 |
31 |
28 class QGraphicsWidget; |
32 class QGraphicsWidget; |
29 |
33 |
30 namespace GVA { |
34 namespace GVA { |
31 |
35 |
32 class VisibilityAnimator; |
36 class VisibilityAnimator; |
33 |
37 |
34 /*! \ingroup JavascriptAPI |
38 /*! \ingroup JavascriptAPI |
|
39 * \brief This class encapsulates an element of the browser's chrome. |
|
40 * |
|
41 * Example HTML declaration of a snippet. |
|
42 * \code |
|
43 * <div class = "GinebraSnippet" id="StatusBarChromeId" name="statusbar" data-GinebraAnchor="AnchorTop" data-GinebraVisible="true"> |
|
44 * <link rel="stylesheet" id="CSSLink" type="text/css" href="statusbar.snippet/statusbar.css"/> |
|
45 * <script type="text/javascript"> |
|
46 * new StatusBar(); |
|
47 * </script> |
|
48 * </div> |
|
49 * \endcode |
|
50 * Example javascript code to toggle the visibility of the snippet defined ablove: |
|
51 * \code |
|
52 * snippets.StatusBarChromeId.toggleVisibility(); |
|
53 * \endcode |
35 */ |
54 */ |
36 class ChromeSnippet : public QObject |
55 class ChromeSnippet : public QObject |
37 { |
56 { |
38 Q_OBJECT |
57 Q_OBJECT |
39 public: |
58 public: |
40 ChromeSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); |
59 ChromeSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); |
41 virtual ~ChromeSnippet(); |
60 virtual ~ChromeSnippet(); |
42 ChromeWidget* chrome() { return m_chrome; } |
61 ChromeWidget * chrome() { return m_chrome; } |
43 void setInitiallyVisible(bool initiallyVisible) { m_initiallyVisible = initiallyVisible; } //NB: needed? |
62 void setInitiallyVisible(bool initiallyVisible) { m_initiallyVisible = initiallyVisible; } //NB: needed? |
44 void setHidesContent(bool hidesContent) { m_hidesContent = hidesContent; } |
63 void setHidesContent(bool hidesContent) { m_hidesContent = hidesContent; } |
45 void setAnchor(ChromeAnchor anchor) {m_anchor = anchor;} |
64 void setAnchor(ChromeAnchor anchor) {m_anchor = anchor;} |
46 ChromeAnchor anchor() { return m_anchor; } |
65 ChromeAnchor anchor() { return m_anchor; } |
47 int anchorOffset() {return m_anchorOffset;} |
66 int anchorOffset() {return m_anchorOffset;} |
48 bool initiallyVisible() { return m_initiallyVisible; } //NB: needed? |
67 bool initiallyVisible() { return m_initiallyVisible; } //NB: needed? |
49 bool hidesContent() { return m_hidesContent; } |
68 bool hidesContent() { return m_hidesContent; } |
50 QString elementId() { return m_elementId; } |
69 QString elementId() { return m_elementId; } |
51 QGraphicsWidget* widget() { return m_widget; } |
70 QGraphicsWidget* widget() { return m_widget; } |
52 virtual void setWidget(QGraphicsWidget * widget) { m_widget = widget; } |
71 QGraphicsWidget const * constWidget() const { return m_widget; } |
|
72 virtual void setChromeWidget(QGraphicsWidget * widget); |
53 QString parentId() { return m_parentId; } |
73 QString parentId() { return m_parentId; } |
54 void setParentId(const QString& parent) { m_parentId = parent; } |
74 void setParentId(const QString& parent) { m_parentId = parent; } |
55 void setTransform(QTransform transform); |
75 void setTransform(QTransform transform); |
56 QTransform transform(); |
76 QTransform transform(); |
57 QPointF position() const; |
77 QPointF position() const; |
58 virtual void addChild(ChromeSnippet * child); |
78 virtual void addChild(ChromeSnippet * child); |
59 QWebElement element() {return m_element;} |
79 QWebElement element() {return m_element;} |
60 void dump(); |
80 void dump(); |
61 void addLink(ChromeSnippet*); |
81 void addLink(ChromeSnippet*); |
62 QList<ChromeSnippet *> links() {return m_links;} |
82 ChromeSnippet * linkedSnippet() {return m_link;} |
63 public slots: |
83 public slots: |
64 void setAnchor(const QString& anchor, bool update = true); |
84 void setAnchor(const QString& anchor, bool update = true); |
65 void setAnchorOffset(int offset, bool update = true); |
85 void setAnchorOffset(int offset, bool update = true); |
66 virtual void toggleVisibility(bool animate = true); |
86 virtual void toggleVisibility(bool animate = true); |
67 void setVisible(bool visiblity, bool animate = true); |
87 virtual void setVisible(bool visiblity, bool animate = true); |
68 void show(bool animate = true) { setVisible(true, animate);} |
88 void show(bool animate = true) { setVisible(true, animate);} |
69 virtual void hide(bool animate = true) { setVisible(false, animate);} |
89 virtual void hide(bool animate = true) { setVisible(false, animate);} |
70 void setOpacity(qreal opacity); |
90 void setOpacity(qreal opacity); |
71 qreal opacity(); |
91 qreal opacity(); |
72 void setEffect(const QString & effect); |
92 void setEffect(const QString & effect); |
73 void enableEffect(bool enable); |
93 void enableEffect(bool enable); |
74 void toggleEffect(); |
94 void toggleEffect(); |
75 void grabFocus(); |
95 void grabFocus(); |
76 void setVisibilityAnimator(const QString& animator); |
96 QObject *setVisibilityAnimator(const QString& animator); |
77 void visibilityFinished(bool visiblity); |
97 void visibilityFinished(bool visiblity); |
78 void moveBy(int dx, int dy); |
98 void moveBy(int dx, int dy); |
79 void anchorTo(const QString & id, int x = 0, int y = 0); |
99 void anchorTo(const QString & id, int x = 0, int y = 0); |
80 void unAnchor(); |
100 void unAnchor(); |
81 void anchorToView(const QString& view, const QString& where="top"); |
101 void anchorToView(const QString& view, const QString& where="top"); |