1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Libraries\UI\Model; |
4 | | | |
5 | | | use Doctrine\Common\Annotations\AnnotationReader; |
6 | | | use Phem\Core\Collection; |
7 | | | use Phem\Core\Object; |
8 | | | use Phem\Environment\EnvironmentManager; |
9 | | | use Phem\Libraries\UI\Annotations\ContentAttr; |
10 | | | use Phem\Libraries\UI\Annotations\DomAttr; |
11 | | | use Phem\Libraries\UI\Annotations\NoUpdateAttr; |
12 | | | use Phem\Libraries\UI\Annotations\StyleAttr; |
13 | | | use Phem\ToolSuite; |
14 | | | use Ratchet\Wamp\Exception; |
15 | | | use ReflectionProperty; |
16 | | | |
17 | | | /** |
18 | | | * @author Jakub PetrĹžĂlka <petrzilka@czweb.net> |
19 | | | */ |
20 | | | abstract class Window extends Component |
21 | | | { |
22 | | | protected $name; |
23 | | | protected $title; |
24 | | | protected $titleIcon; |
25 | | | /* protected $size; |
26 | | | protected $position; */ |
27 | | | /** |
28 | | | * @\Phem\Libraries\UI\Annotations\StyleAttr(name="z-index") |
29 | | | */ |
30 | | | protected $zIndex; |
31 | | | |
32 | | | /** |
33 | | | * @\Phem\Libraries\UI\Annotations\StyleAttr(name="left") |
34 | | | */ |
35 | | | protected $left; |
36 | | | |
37 | | | /** |
38 | | | * @\Phem\Libraries\UI\Annotations\StyleAttr(name="top") |
39 | | | */ |
40 | | | protected $top; |
41 | | | protected $width; |
42 | | | protected $height; |
43 | | | protected $backgroundColor; |
44 | | | protected $draggable; |
45 | | | protected $parent; |
46 | | | protected $scope; |
47 | | | protected $sharePosition; |
48 | | | private $onDrag; |
49 | | | private $onMouseDown; |
50 | | | |
51 | | | function __construct($parent) |
52 | | | { |
53 | | | $this->parent = $parent; |
54 | | | $this->onDrag = new Collection(); |
55 | | | $this->onMouseDown = new Collection(); |
56 | | | |
57 | | | $this->onMouseDown->add(array($this,"window_onMouseDown")); |
58 | | | } |
59 | | | |
60 | | | public function getTemplateName() |
61 | | | { |
62 | | | return "Window"; |
63 | | | } |
64 | | | |
65 | | | public function getTitleIcon() |
66 | | | { |
67 | | | return $this->titleIcon; |
68 | | | } |
69 | | | |
70 | | | protected function setTitleIcon($titleIcon) |
71 | | | { |
72 | | | $this->titleIcon = $titleIcon; |
73 | | | } |
74 | | | |
75 | | | public function getName() |
76 | | | { |
77 | | | return $this->name; |
78 | | | } |
79 | | | |
80 | | | protected function setName($name) |
81 | | | { |
82 | | | $this->name = $name; |
83 | | | } |
84 | | | |
85 | | | public function getTitle() |
86 | | | { |
87 | | | return $this->title; |
88 | | | } |
89 | | | |
90 | | | protected function setTitle($title) |
91 | | | { |
92 | | | $this->title = $title; |
93 | | | } |
94 | | | |
95 | | | /* public function getSize() |
96 | | | { |
97 | | | return $this->size; |
98 | | | } |
99 | | | |
100 | | | protected function setSize(Size $size) |
101 | | | { |
102 | | | $this->size = $size; |
103 | | | } |
104 | | | |
105 | | | public function getPosition() |
106 | | | { |
107 | | | return $this->position; |
108 | | | } |
109 | | | |
110 | | | protected function setPosition(Position $position) |
111 | | | { |
112 | | | $this->position = $position; |
113 | | | } */ |
114 | | | |
115 | | | public function getZIndex() |
116 | | | { |
117 | | | return $this->zIndex; |
118 | | | } |
119 | | | |
120 | | | public function getLeft() |
121 | | | { |
122 | | | return $this->left; |
123 | | | } |
124 | | | |
125 | | | public function getTop() |
126 | | | { |
127 | | | return $this->top; |
128 | | | } |
129 | | | |
130 | | | public function getWidth() |
131 | | | { |
132 | | | return $this->width; |
133 | | | } |
134 | | | |
135 | | | public function getHeight() |
136 | | | { |
137 | | | return $this->height; |
138 | | | } |
139 | | | |
140 | | | protected function setZIndex($zIndex) |
141 | | | { |
142 | | | $this->zIndex = $zIndex; |
143 | | | } |
144 | | | |
145 | | | protected function setLeft($left) |
146 | | | { |
147 | | | $this->left = $left; |
148 | | | } |
149 | | | |
150 | | | protected function setTop($top) |
151 | | | { |
152 | | | $this->top = $top; |
153 | | | } |
154 | | | |
155 | | | protected function setWidth($width) |
156 | | | { |
157 | | | $this->width = $width; |
158 | | | } |
159 | | | |
160 | | | protected function setHeight($height) |
161 | | | { |
162 | | | $this->height = $height; |
163 | | | } |
164 | | | |
165 | | | public function getBackgroundColor() |
166 | | | { |
167 | | | return $this->backgroundColor; |
168 | | | } |
169 | | | |
170 | | | protected function setBackgroundColor($backgroundColor) |
171 | | | { |
172 | | | $this->backgroundColor = $backgroundColor; |
173 | | | } |
174 | | | |
175 | | | public function getDraggable() |
176 | | | { |
177 | | | return $this->draggable; |
178 | | | } |
179 | | | |
180 | | | protected function setDraggable($draggable) |
181 | | | { |
182 | | | $this->draggable = $draggable; |
183 | | | } |
184 | | | |
185 | | | public function getParent() |
186 | | | { |
187 | | | return $this->parent; |
188 | | | } |
189 | | | |
190 | | | protected function setParent($parent) |
191 | | | { |
192 | | | $this->parent = $parent; |
193 | | | } |
194 | | | |
195 | | | public function getSharePosition() |
196 | | | { |
197 | | | return $this->sharePosition; |
198 | | | } |
199 | | | |
200 | | | public function setSharePosition($sharePosition) |
201 | | | { |
202 | | | $this->sharePosition = $sharePosition; |
203 | | | } |
204 | | | |
205 | | | public function getScope() |
206 | | | { |
207 | | | return $this->scope; |
208 | | | } |
209 | | | |
210 | | | public function setScope($scope) |
211 | | | { |
212 | | | $this->scope = $scope; |
213 | | | } |
214 | | | |
215 | | | |
216 | | | public function OnDrag() |
217 | | | { |
218 | | | return $this->onDrag; |
219 | | | } |
220 | | | |
221 | | | public function OnMouseDown() |
222 | | | { |
223 | | | return $this->onMouseDown; |
224 | | | } |
225 | | | |
226 | | | public function window_onMouseDown() |
227 | | | { |
228 | | | foreach ($this->getWorkspace()->getWindows() as $window) |
229 | | | { |
230 | | | $window->__call("setZIndex", array(0)); |
231 | | | } |
232 | | | |
233 | | | $this->__call("setZIndex", array(1)); |
234 | | | } |
235 | | | |
236 | | | public function getControls() |
237 | | | { |
238 | | | |
239 | | | $controls = new Collection(); |
240 | | | |
241 | | | $methods = get_class_methods($this); |
242 | | | foreach ($methods as $method) |
243 | | | { |
244 | | | if ((ToolSuite::startsWith($method, 'get') !== false) && ($method != "getControls")) |
245 | | | { |
246 | | | $val = $this->$method(); |
247 | | | if (is_a($val, '\Phem\Libraries\UI\Model\Control')) |
248 | | | { |
249 | | | $controls->put(lcfirst(substr($method, 3)), $val); |
250 | | | } |
251 | | | } |
252 | | | } |
253 | | | return $controls; |
254 | | | } |
255 | | | |
256 | | | } |