webappmanager
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CardWebApp.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 #ifndef __CardWebApp_h__
22 #define __CardWebApp_h__
23 
24 #include "Common.h"
25 
26 #include <sptr.h>
27 
28 #include "WindowedWebApp.h"
29 #include "WindowTypes.h"
30 #include "SysMgrDefs.h"
31 #include <QGraphicsItem>
32 #include <QGraphicsView>
33 
34 class PIpcChannel;
35 class NativeGraphicsContext;
36 class NativeGraphicsSurface;
37 class QGraphicsView;
38 class QGraphicsScene;
39 class QGraphicsWebView;
40 class QGLWidget;
41 class myGraphicsView;
42 
43 class CardWebApp : public WindowedWebApp, public QGraphicsView
44 {
45 public:
46 
47  CardWebApp(WindowType::Type winType, PIpcChannel *channel, ApplicationDescription* desc = 0);
48  ~CardWebApp( );
49 
50  virtual void thawFromCache();
51  virtual void freezeInCache();
52 
53  virtual bool isCardApp() const { return true; }
54  virtual bool isChildApp() const;
55 
56  virtual void paint();
57 
58 
59  virtual void inputEvent(sptr<Event> e);
60  virtual void keyEvent(QKeyEvent* e);
61  virtual void focusedEvent(bool focused);
62  virtual int resizeEvent(int newWidth, int newHeight, bool resizeBuffer);
63  virtual void flipEvent(int newWidth, int newHeight);
64  virtual void asyncFlipEvent(int newWidth, int newHeight, int newScreenWidth, int newScreenHeight);
65 
66  virtual void setOrientation(Event::Orientation orient);
67  Event::Orientation orientation() const;
68 
69  void setFixedOrientation(Event::Orientation orient);
70  void setAllowOrientationChange(bool value);
71  bool allowsOrientationChange() const;
72 
73  virtual void enableFullScreenMode(bool enable);
74 
75  void receivePageUpDownInLandscape(bool val);
76 
77  virtual void invalidate();
78 
79  virtual void displayOn();
80  virtual void displayOff();
81 
82  void allowResizeOnPositiveSpaceChange(bool allowResize);
83 
85 
86  CardWebApp* parentWebApp() const;
87  void resizeWebPage(uint32_t width, uint32_t height);
88 
89 private:
90 
91  virtual void attach(SysMgrWebBridge* page);
92  virtual SysMgrWebBridge* detach();
93  virtual bool isWindowed() const;
94  virtual bool isLeafApp() const;
95 
96  void addChildCardWebApp(CardWebApp* app);
97  void removeChildCardWebApp(CardWebApp* app);
98  void setParentCardWebApp(CardWebApp* app);
99 
100  virtual void resizeWindowForOrientation(Event::Orientation orient);
101  virtual void resizeWindowForFixedOrientation(Event::Orientation orient);
102  virtual void getFixedOrientationDimensions(int& width, int& height, int& wAdjust, int& hAdjust);
103  bool isOrientationPortrait(Event::Orientation orient);
104  void handlePendingChanges();
105 
106  virtual void invalContents(int x, int y, int width, int height);
107  virtual void loadFinished();
108 
109  void callMojoScreenOrientationChange();
110  void callMojoScreenOrientationChange(Event::Orientation orient);
111  virtual void onSetComposingText(const std::string& text);
112  virtual void onCommitComposingText();
113  virtual void onCommitText(const std::string& text);
114  virtual void onPerformEditorAction(int action);
115  virtual void onRemoveInputFocus();
116 
117  virtual void onInputEvent(const SysMgrEventWrapper& wrapper);
118  virtual Event::Orientation orientationForThisCard(Event::Orientation orient);
119 
120 protected:
121  int angleForOrientation(Event::Orientation orient) const;
122  void updateWindowProperties();
123  void animationFinished();
124 
125  virtual void setVisibleDimensions(int width, int height);
126  virtual void onDirectRenderingChanged();
127 
128  virtual void directRenderingChanged(bool directRendering, int renderX, int renderY, SysMgrEvent::Orientation angle);
129  virtual void directRenderingAllowed();
130  virtual void directRenderingDisallowed();
131 
132  virtual void focus();
133  virtual void screenSize(int& width, int& height);
134 
135  void forcePaint();
136 
143  void applyCardOrientation();
144 
145 public:
146  virtual void suspendAppRendering();
147  virtual void resumeAppRendering();
148 
149 protected: // QGraphicsView overloads
150 #ifdef GFX_DEBUGGING
151  bool event(QEvent* event);
152  bool viewportEvent(QEvent* event);
153 #endif
154  void paintEvent(QPaintEvent* event);
155 
156 protected:
157 
160 
161  // these are the dimensions of the paint buffer seen by webkit
162  // (are adjusted to app rotation)
165 
166  // m_CardOrientation is to keep track of the current orientation
167  // of the card. m_orientation & m_fixedOrientation cannot be used
168  // reliably always to query current orientation of the CardWebApp
169  Event::Orientation m_CardOrientation;
170  Event::Orientation m_orientation;
171  Event::Orientation m_fixedOrientation;
173 
176 
179  Event::Orientation m_pendingOrientation;
181 
184 
186 
188 
192  SysMgrEvent::Orientation m_renderOrientation;
194 
196 
197  QGraphicsWebView* m_webview;
198  QGLWidget* m_glw;
200 private:
201 
202  CardWebApp& operator=( const CardWebApp& );
203  CardWebApp( const CardWebApp& );
204 };
205 
206 #endif
207 
208