Ginga  0.13.6
 All Classes Namespaces Functions Variables
LayoutRegion.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 _LAYOUTREGION_H_
51 #define _LAYOUTREGION_H_
52 
53 #include "../Entity.h"
54 using namespace ::br::pucrio::telemidia::ncl;
55 
56 #include "util/functions.h"
57 #include "util/Color.h"
58 using namespace ::br::pucrio::telemidia::util;
59 
60 #include <pthread.h>
61 //#include <limits>
62 #include <cstdlib>
63 #include <map>
64 #include <string>
65 #include <vector>
66 using namespace std;
67 
68 namespace br {
69 namespace pucrio {
70 namespace telemidia {
71 namespace ncl {
72 namespace layout {
73  class LayoutRegion : public Entity {
74  protected:
75  string title;
76  string outputMapRegionId;
77  LayoutRegion* outputMapRegion;
78 
79  double left;
80  bool leftPercentual;
81  double top;
82  bool topPercentual;
83  double right;
84  bool rightPercentual;
85  double bottom;
86  bool bottomPercentual;
87  double width;
88  bool widthPercentual;
89  double height;
90  bool heightPercentual;
91 
92  double* zIndex;
93  map<string, LayoutRegion*> regions;
94  vector<LayoutRegion*> sorted;
95  LayoutRegion* parent;
96  bool movable;
97  bool resizable;
98  bool decorated;
99  int devClass;
100  pthread_mutex_t mutex;
101 
102  public:
103  LayoutRegion(string id);
104  virtual ~LayoutRegion();
105  virtual void setOutputMapRegion(LayoutRegion* outMapRegion);
106  virtual LayoutRegion* getOutputMapRegion();
107  virtual string getOutputMapRegionId();
108  virtual void setDeviceClass(int deviceClass, string mapId);
109  virtual int getDeviceClass();
110  virtual void addRegion(LayoutRegion* region);
111  virtual LayoutRegion* cloneRegion();
112 
113  virtual LayoutRegion* copyRegion();
114 
115  virtual int compareWidthSize(string w);
116  virtual int compareHeightSize(string h);
117  virtual double getBottom();
118  virtual double getHeight();
119  virtual double getLeft();
120  virtual double getRight();
121  virtual LayoutRegion* getRegion(string id);
122  virtual LayoutRegion* getRegionRecursively(string id);
123  void printRegionIdsRecursively();
124  virtual vector<LayoutRegion*>* getRegions();
125  virtual string getTitle();
126  virtual double getTop();
127  virtual double getWidth();
128  virtual int getZIndex();
129  virtual int getZIndexValue();
130  virtual bool isBottomPercentual();
131  virtual bool isHeightPercentual();
132  virtual bool isLeftPercentual();
133  virtual bool isRightPercentual();
134  virtual bool isTopPercentual();
135  virtual bool isWidthPercentual();
136  virtual string toString();
137 
138  private:
139  virtual bool removeRegion(LayoutRegion *region);
140 
141  public:
142  virtual void removeRegions();
143 
144  private:
145  virtual LayoutRegion* getDeviceLayout();
146  virtual double getDeviceWidthInPixels();
147  virtual double getDeviceHeightInPixels();
148 
149  public:
150  virtual bool setBottom(double newBottom, bool isPercentual);
151  virtual bool setTargetBottom(double newBottom, bool isPercentual);
152  virtual bool setHeight(double newHeight, bool isPercentual);
153  virtual bool setTargetHeight(double newHeight, bool isPercentual);
154  virtual bool setLeft(double newLeft, bool isPercentual);
155  virtual bool setTargetLeft(double newLeft, bool isPercentual);
156  virtual bool setRight(double newRight, bool isPercentual);
157  virtual bool setTargetRight(double newRight, bool isPercentual);
158  virtual bool setTop(double newTop, bool isPercentual);
159  virtual bool setTargetTop(double newTop, bool isPercentual);
160  virtual bool setWidth(double newWidth, bool isPercentual);
161  virtual bool setTargetWidth(double newWidth, bool isPercentual);
162 
163  virtual void validateTarget();
164 
165  virtual void setTitle(string newTitle);
166  virtual void setZIndex(int newZIndex);
167  virtual vector<LayoutRegion*>* getRegionsSortedByZIndex();
168  virtual vector<LayoutRegion*>* getRegionsOverRegion(
169  LayoutRegion* region);
170 
171  virtual LayoutRegion* getParent();
172  virtual void setParent(LayoutRegion* parent);
173  virtual void refreshDeviceClassRegions();
174  virtual int getTopInPixels();
175  virtual int getBottomInPixels();
176  virtual int getRightInPixels();
177  virtual int getLeftInPixels();
178  virtual int getHeightInPixels();
179  virtual int getWidthInPixels();
180  virtual bool isMovable();
181  virtual bool isResizable();
182  virtual bool isDecorated();
183  virtual void setMovable(bool movable);
184  virtual void setResizable(bool resizable);
185  virtual void setDecorated(bool decorated);
186  virtual void resetTop();
187  virtual void resetBottom();
188  virtual void resetRight();
189  virtual void resetLeft();
190  virtual void resetHeight();
191  virtual void resetWidth();
192  virtual void resetZIndex();
193  virtual void resetDecorated();
194  virtual void resetMovable();
195  virtual void resetResizable();
196  virtual int getAbsoluteLeft();
197  virtual int getAbsoluteTop();
198  virtual bool intersects(LayoutRegion* r);
199  virtual bool intersects(int x, int y);
200 
201  private:
202  double getPercentualValue(string value);
203  bool isPercentualValue(string value);
204  void lock();
205  void unlock();
206  };
207 }
208 }
209 }
210 }
211 }
212 
213 #endif //_LAYOUTREGION_H_
Definition: Entity.h:68