LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MenuWindowManager.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 
22 #ifndef MENUWINDOWMANAGER_H
23 #define MENUWINDOWMANAGER_H
24 
25 #include "Common.h"
26 
27 #include "WindowManagerBase.h"
28 
29 #include "GraphicsItemContainer.h"
30 #include <QGraphicsPixmapItem>
31 #include <QGraphicsSceneMouseEvent>
32 #include <QVector>
33 #include "SystemMenu.h"
34 
35 class Window;
36 class QGestureEvent;
37 class StatusBar;
38 
40 {
41  Q_OBJECT
42 
43 public:
44 
45  MenuWindowManager(int maxWidth, int maxHeight);
46  virtual ~MenuWindowManager();
47 
48  virtual void init();
49 
50  bool showingMenu() const { return !m_winArray.empty(); }
51 
52  QGraphicsPixmapItem** cornerWindows() { return m_corners; }
53 
54  void showOrHideRoundedCorners(bool show);
55 
56  void resize(int width, int height);
57 
58 public Q_SLOTS:
59 
60  void closeMenu();
61 
62 protected:
63 
64  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
65  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
66  virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
67  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
68  void flickGestureEvent(QGestureEvent* event);
69 
70  virtual bool sceneEvent(QEvent* event);
71 
72 private Q_SLOTS:
73 
74  void slotPositiveSpaceChanged(const QRect& r);
75  void slotSystemMenuStateChanged(bool opened);
76  void slotCloseSystemMenu();
77 
78 private:
79 
80  void handleMousePress(QGraphicsSceneMouseEvent* event, int clickCount);
81 
82 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
83  void handleTouchBegin(QTouchEvent *te);
84  void handleTouchEnd(QTouchEvent *te);
85  void handleTouchUpdate(QTouchEvent *te);
86 #endif
87 
88  virtual void addWindow(Window* win);
89  virtual void removeWindow(Window* win);
90  virtual void focusWindow(Window* win);
91  virtual void unfocusWindow(Window* win);
92 
93  void positionCornerWindows(const QRect& r);
94  void mapCoordToWindow(Window* win, int& x, int& y);
95  void showMenuWindow(Window* win);
96  void hideMenuWindow(Window* win);
97 
98  void raiseWindow(Window* win);
99 private:
100 
101  enum PenDownState {
102  PenDownInvalid,
103  PenDownInMenu,
104  };
105 
106  GraphicsItemContainer* m_cornerContainer;
107  QGraphicsPixmapItem* m_corners[4];
108  StatusBar* m_statusBar;
109  QVector<Window*> m_winArray;
110  QRect m_positiveSpace;
111  PenDownState m_penDownState;
112  int m_penDownX;
113  int m_penDownY;
114 
115  SystemMenu* m_sysMenu;
116  bool m_systemMenuOpened;
117 };
118 
119 #endif /* MENUWINDOWMANAGER_H */