Ginga  0.13.6
 All Classes Namespaces Functions Variables
FormatterFocusManager.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef FORMATTERFOCUSMANAGER_H_
51 #define FORMATTERFOCUSMANAGER_H_
52 
53 #include "util/functions.h"
54 #include "util/Color.h"
55 
56 #include "mb/IMBDefs.h"
57 #include "mb/IInputManager.h"
58 #include "mb/interface/IInputEventListener.h"
59 #include "mb/interface/CodeMap.h"
60 using namespace ::br::pucrio::telemidia::ginga::core::mb;
61 
62 #include "../model/CascadingDescriptor.h"
63 #include "../model/ExecutionObject.h"
64 using namespace ::br::pucrio::telemidia::ginga::ncl::model::components;
65 
66 #include "../model/SelectionEvent.h"
67 using namespace ::br::pucrio::telemidia::ginga::ncl::model::event;
68 
69 #include "../model/ILinkActionListener.h"
70 #include "../model/LinkSimpleAction.h"
71 using namespace ::br::pucrio::telemidia::ginga::ncl::model::link;
72 
73 #include "../model/FormatterRegion.h"
74 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
75 
76 #include "../adaptation/context/IPresentationContext.h"
77 using namespace ::br::pucrio::telemidia::ginga::ncl::adaptation::context;
78 
79 #include "../adapters/FormatterPlayerAdapter.h"
80 #include "../adapters/PlayerAdapterManager.h"
81 using namespace ::br::pucrio::telemidia::ginga::ncl::adapters;
82 
83 #include "../multidevice/IFormatterMultiDevice.h"
84 using namespace ::br::pucrio::telemidia::ginga::ncl::multidevice;
85 
86 #include "IFormatterFocusManager.h"
87 
88 #include <string>
89 #include <vector>
90 #include <set>
91 #include <map>
92 using namespace std;
93 
94 namespace br {
95 namespace pucrio {
96 namespace telemidia {
97 namespace ginga {
98 namespace ncl {
99 namespace focus {
101  public IFormatterFocusManager,
102  public IInputEventListener {
103 
104  private:
105  IInputManager* im;
106 
107  GingaScreenID myScreen;
108  IPresentationContext* presContext;
109  map<string, set<ExecutionObject*>*>* focusTable;
110  bool isHandler;
111  string currentFocus;
112  string objectToSelect;
113  ExecutionObject* selectedObject;
114 
115  Color* defaultFocusBorderColor;
116  int defaultFocusBorderWidth;
117  Color* defaultSelBorderColor;
118  PlayerAdapterManager* playerManager;
119  FormatterFocusManager* parentManager;
120  IFormatterMultiDevice* multiDevice;
121  ILinkActionListener* settingActions;
122 
123  int xOffset;
124  int yOffset;
125  int width;
126  int height;
127 
128  double focusHandlerTS;
129 
130  void* converter;
131  pthread_mutex_t mutexFocus;
132  pthread_mutex_t mutexTable;
133 
134  static bool init;
135  static set<FormatterFocusManager*> instances;
136  static pthread_mutex_t iMutex;
137 
138  public:
140  PlayerAdapterManager* playerManager,
141  IPresentationContext* presContext,
142  IFormatterMultiDevice* multiDevice,
143  ILinkActionListener* settingActions,
144  void* converter);
145 
146  virtual ~FormatterFocusManager();
147 
148  private:
149  static void checkInit();
150  static bool hasInstance(
151  FormatterFocusManager* instance, bool remove);
152 
153  public:
154  void setParent(FormatterFocusManager* parent);
155  bool isKeyHandler();
156  bool setKeyHandler(bool isHandler);
157 
158  private:
159  void setHandlingObjects(bool isHandling);
160  void resetKeyMaster();
161 
162  public:
163  void tapObject(void* executionObject);
164  void setKeyMaster(string mediaId);
165  //void setStandByState(bool standBy);
166  void setFocus(string focusIndex);
167 
168  private:
169  void setFocus(CascadingDescriptor* descriptor);
170  void recoveryDefaultState(ExecutionObject* object);
171 
172  public:
173  void showObject(ExecutionObject* object);
174  void hideObject(ExecutionObject* object);
175 
176  private:
177  ExecutionObject* getObjectFromFocusIndex(string focusIndex);
178  void insertObject(ExecutionObject* object, string focusIndex);
179  void removeObject(ExecutionObject* object, string focusIndex);
180 
181  bool keyCodeOk(ExecutionObject* currentObject);
182  bool keyCodeBack();
183  bool enterSelection(FormatterPlayerAdapter* player);
184  void exitSelection(FormatterPlayerAdapter* player);
185  void registerNavigationKeys();
186  void registerBackKeys();
187  void unregister();
188 
189  public:
190  void setDefaultFocusBorderColor(Color* color);
191  void setDefaultFocusBorderWidth(int width);
192  void setDefaultSelBorderColor(Color* color);
193 
194  void setMotionBoundaries(int x, int y, int w, int h);
195 
196  private:
197  void changeSettingState(string name, string act);
198 
199  public:
200  bool userEventReceived(IInputEvent* ev);
201  bool motionEventReceived(int x, int y, int z);
202  };
203 }
204 }
205 }
206 }
207 }
208 }
209 
210 #endif /*FORMATTERFOCUSMANAGER_H_*/
Definition: Color.h:62