ginebra2/ContentViews/GWebContentViewJSObject.h
changeset 3 0954f5dd2cd0
parent 0 1450b09d0cfd
child 9 b39122337a00
equal deleted inserted replaced
1:b0dd75e285d2 3:0954f5dd2cd0
     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 #ifndef GWebContentViewJSObject_H_
    21 #ifndef GWebContentViewJSObject_H_
    19 #define GWebContentViewJSObject_H_
    22 #define GWebContentViewJSObject_H_
    20 
    23 
    21 #include <QObject>
    24 #include <QObject>
    22 #include "controllableviewimpl.h"
    25 #include "controllableviewimpl.h"
    23 #include "GWebContentView.h"
    26 #include "GWebContentView.h"
       
    27 #include "GSuperWebPage.h"
    24 
    28 
    25 class WebViewEventContext;
    29 class WebViewEventContext;
    26 
    30 
    27 namespace GVA {
    31 namespace GVA {
    28 
    32 
    33     Q_OBJECT
    37     Q_OBJECT
    34   public:
    38   public:
    35     GWebContentViewJSObject(GWebContentView *contentView, ::QWebFrame *chromeFrame, const QString &objectName)
    39     GWebContentViewJSObject(GWebContentView *contentView, ::QWebFrame *chromeFrame, const QString &objectName)
    36       : ::ControllableViewJSObject(contentView, chromeFrame, objectName)
    40       : ::ControllableViewJSObject(contentView, chromeFrame, objectName)
    37     {
    41     {
    38       qDebug() << "GWebContentViewJSObject::GWebContentViewJSObject: " << this;
    42       //qDebug() << "GWebContentViewJSObject::GWebContentViewJSObject: " << this;
    39     }
    43     }
    40 
    44 
    41     qreal getZoomFactor() const { return webContentViewConst()->getZoomFactor(); }
    45     qreal getZoomFactor() const { return webContentViewConst()->getZoomFactor(); }
    42     void setZoomFactor(qreal factor)  { webContentView()->setZoomFactor(factor); }
    46     void setZoomFactor(qreal factor)  { webContentView()->setZoomFactor(factor); }
    43     Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
    47     Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
    46     QObjectList getSuperPages() { return webContentView()->getSuperPages(); }
    50     QObjectList getSuperPages() { return webContentView()->getSuperPages(); }
    47 
    51 
    48     /*! This property holds whether touch navigation is enabled.
    52     /*! This property holds whether touch navigation is enabled.
    49      */
    53      */
    50     Q_PROPERTY(bool gesturesEnabled READ getGesturesEnabled WRITE setGesturesEnabled)
    54     Q_PROPERTY(bool gesturesEnabled READ getGesturesEnabled WRITE setGesturesEnabled)
    51     bool getGesturesEnabled() const { return webContentViewConst()->gesturesEnabled(); }
    55     bool getGesturesEnabled() const
    52     void setGesturesEnabled(bool value) { webContentView()->setGesturesEnabled(value); }
    56     {
       
    57 #ifdef BEDROCK_TILED_BACKING_STORE
       
    58         return false;
       
    59 #else
       
    60         return webContentViewConst()->gesturesEnabled();
       
    61 #endif
       
    62     }
       
    63     void setGesturesEnabled(bool value)
       
    64     {
       
    65 #ifndef BEDROCK_TILED_BACKING_STORE
       
    66         webContentView()->setGesturesEnabled(value);
       
    67 #endif
       
    68     }
       
    69 
       
    70     Q_PROPERTY(bool enabled WRITE setEnabled READ enabled)
       
    71     bool enabled() const { return webContentViewConst()->enabled(); }
       
    72     void setEnabled(bool value) { webContentView()->setEnabled(value); }
    53 
    73 
    54 public slots:
    74 public slots:
    55     void loadUrlToCurrentPage(const QString & url)
    75     void loadUrlToCurrentPage(const QString & url)
    56         { webContentView()->loadUrlToCurrentPage(url); }
    76         { webContentView()->loadUrlToCurrentPage(url); }
    57     QObject *currentPage() { return webContentView()->currentPage(); }
    77     QObject *currentPage() { return webContentView()->currentPage(); }
    58     void back() { webContentView()->back(); }
    78     void back() { webContentView()->back(); }
    59     void forward() { webContentView()->forward(); }
    79     void forward() { webContentView()->forward(); }
    60     void reload() { webContentView()->reload(); }
    80     void reload() { webContentView()->reload(); }
       
    81 #ifndef BEDROCK_TILED_BACKING_STORE
    61     void zoomIn(qreal deltaPercent = 0.1) { webContentView()->zoomIn(deltaPercent); }
    82     void zoomIn(qreal deltaPercent = 0.1) { webContentView()->zoomIn(deltaPercent); }
    62     void zoomOut(qreal deltaPercent = 0.1) { webContentView()->zoomOut(deltaPercent); }
    83     void zoomOut(qreal deltaPercent = 0.1) { webContentView()->zoomOut(deltaPercent); }
    63     void zoomBy(qreal delta) { zoomIn(delta); }
    84     void zoomBy(qreal delta) { zoomIn(delta); }
       
    85 #endif	
    64     void zoom(bool in) { webContentView()->zoom(in); }
    86     void zoom(bool in) { webContentView()->zoom(in); }
    65     void toggleZoom() { webContentView()->toggleZoom(); }
    87     void toggleZoom() { webContentView()->toggleZoom(); }
    66     void stopZoom() { webContentView()->stopZoom(); }
    88     void stopZoom() { webContentView()->stopZoom(); }
    67     void scrollBy(int deltaX, int deltaY) { webContentView()->scrollBy(deltaX, deltaY); }
    89     void scrollBy(int deltaX, int deltaY) { webContentView()->scrollBy(deltaX, deltaY); }
       
    90     void scrollTo(int x, int y) { webContentView()->scrollTo(x, y); }
    68     int scrollX() { return webContentView()->scrollX(); }
    91     int scrollX() { return webContentView()->scrollX(); }
    69     int scrollY() { return webContentView()->scrollY(); }
    92     int scrollY() { return webContentView()->scrollY(); }
    70     int contentWidth() { return webContentView()->contentWidth(); }
    93     int contentWidth() { return webContentView()->contentWidth(); }
    71     int contentHeight() { return webContentView()->contentHeight(); }
    94     int contentHeight() { return webContentView()->contentHeight(); }
    72     void showNormalPage() { return webContentView()->showNormalPage(); }
    95     void showNormalPage() { return webContentView()->showNormalPage(); }
    73     bool currentPageIsSuperPage() { return webContentView()->currentPageIsSuperPage(); }
    96     bool currentPageIsSuperPage() { return webContentView()->currentPageIsSuperPage(); }
    74     void dump() { return webContentView()->dump(); }
    97     void dump() { return webContentView()->dump(); }
    75     
    98     bool frozen() const { return webContentViewConst()->frozen(); }
       
    99     void freeze() { return webContentView()->freeze(); }
       
   100     void unfreeze() { return webContentView()->unfreeze(); }
       
   101 
    76     // Super page slots.
   102     // Super page slots.
    77     QObject * createSuperPage(const QString &name) { return webContentView()->createSuperPage(name); }
   103     QObject * createSuperPage(const QString &name, bool persist=false) { return webContentView()->createSuperPage(name, persist); }
    78     void destroySuperPage(const QString &name) { webContentView()->destroySuperPage(name); }
   104     void destroySuperPage(const QString &name) { webContentView()->destroySuperPage(name); }
    79     void setCurrentSuperPage(const QString &name) { webContentView()->setCurrentSuperPage(name); }
   105     void setCurrentSuperPage(const QString &name) { webContentView()->setCurrentSuperPage(name); }
    80     QObject * currentSuperPage() { return webContentView()->currentSuperPage(); }
   106     QObject * currentSuperPage() { return webContentView()->currentSuperPage(); }
    81 	QString currentSuperPageName() { return webContentView()->currentSuperPage()->objectName(); }
   107     QString currentSuperPageName() { return webContentView()->currentSuperPage()->objectName(); }
    82     void showSuperPage(const QString &name) { webContentView()->showSuperPage(name); }
   108     void showSuperPage(const QString &name) { webContentView()->showSuperPage(name); }
    83     QObject * superPage(const QString &name) { return webContentView()->superPage(name); }
   109     QObject * superPage(const QString &name) { return webContentView()->superPage(name); }
    84     bool isSuperPage(const QString &name) { return webContentView()->isSuperPage(name); }
   110     bool isSuperPage(const QString &name) { return webContentView()->isSuperPage(name); }
       
   111 
       
   112     bool bedrockTiledBackingStoreEnabled() 
       
   113     {
       
   114 #ifdef BEDROCK_TILED_BACKING_STORE
       
   115         return true;
       
   116 #else
       
   117         return false;
       
   118 #endif
       
   119     }
    85 
   120 
    86 signals:
   121 signals:
    87     void ContextChanged();
   122     void ContextChanged();
    88     void iconChanged();
   123     void iconChanged();
    89     void loadFinished(bool ok);
   124     void loadFinished(bool ok);
   100 
   135 
   101     // Sent when the display mode changes from landscape to protrait or vice versa.
   136     // Sent when the display mode changes from landscape to protrait or vice versa.
   102     void onDisplayModeChanged(const QString &orientation);
   137     void onDisplayModeChanged(const QString &orientation);
   103 
   138 
   104     void contextEvent(QObject *context);
   139     void contextEvent(QObject *context);
       
   140 	void superPageShown(const QString &name);
       
   141     
   105 
   142 
   106 private slots:
   143 private slots:
   107     void statusBarMessage( const QString & text );
   144     void statusBarMessage( const QString & text );
   108     void statusBarVisibilityChangeRequested(bool visible);
   145     void statusBarVisibilityChangeRequested(bool visible);
   109     void onContextEvent(::WebViewEventContext *context);
   146     void onContextEvent(::WebViewEventContext *context);