1 /*
2  *  ppui/Screen.cpp
3  *
4  *  Copyright 2009 Peter Barth
5  *
6  *  This file is part of Milkytracker.
7  *
8  *  Milkytracker is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Milkytracker is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Milkytracker.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include "DisplayDeviceBase.h"
24 #include "GraphicsAbstract.h"
25 #include "Screen.h"
26 #include "Event.h"
27 #include "ContextMenu.h"
28 #include "TransparentContainer.h"
29 
paintDragHighlite(PPGraphicsAbstract * g)30 void PPScreen::paintDragHighlite(PPGraphicsAbstract* g)
31 {
32 	g->setRect(0,0,getWidth(), getHeight());
33 	g->setColor(46517>>8, 54740>>8, 65535>>8);
34 	g->drawHLine(0, getWidth(), 0);
35 	g->drawHLine(0, getWidth(), 1);
36 	g->drawHLine(0, getWidth(), 2);
37 
38 	g->drawHLine(0, getWidth(), getHeight() - 1);
39 	g->drawHLine(0, getWidth(), getHeight() - 2);
40 	g->drawHLine(0, getWidth(), getHeight() - 3);
41 
42 	g->drawVLine(0, getHeight(), 0);
43 	g->drawVLine(0, getHeight(), 1);
44 	g->drawVLine(0, getHeight(), 2);
45 
46 	g->drawVLine(0, getHeight(), getWidth() - 1);
47 	g->drawVLine(0, getHeight(), getWidth() - 2);
48 	g->drawVLine(0, getHeight(), getWidth() - 3);
49 }
50 
PPScreen(PPDisplayDeviceBase * displayDevice,EventListenerInterface * eventListener)51 PPScreen::PPScreen(PPDisplayDeviceBase* displayDevice, EventListenerInterface* eventListener /* = NULL */) :
52 	displayDevice(displayDevice),
53 	eventListener(eventListener),
54 	focusedControl(NULL),
55 	beforeModalFocusedControl(NULL),
56 	modalControl(NULL),
57 	showDragHilite(false),
58 	rootContainer(NULL),
59 	lastMouseOverControl(NULL)
60 {
61 	contextMenuControls = new PPSimpleVector<PPControl>(16, false);
62 	timerEventControls = new PPSimpleVector<PPControl>(16, false);
63 
64 	rootContainer = new PPTransparentContainer(-1, this, eventListener,
65 											   PPPoint(0, 0),
66 											   PPSize(displayDevice->getSize()));
67 }
68 
~PPScreen()69 PPScreen::~PPScreen()
70 {
71 	delete contextMenuControls;
72 	delete timerEventControls;
73 }
74 
adjustEventMouseCoordinates(PPEvent * event)75 void PPScreen::adjustEventMouseCoordinates(PPEvent* event)
76 {
77 	if (!displayDevice->supportsScaling())
78 		return;
79 
80 	const pp_int32 scaleFactor = displayDevice->getScaleFactor();
81 
82 	if (scaleFactor == 1)
83 		return;
84 
85 	PPPoint* p = (PPPoint*)event->getDataPtr();
86 
87 	p->x /= scaleFactor;
88 	p->y /= scaleFactor;
89 }
90 
raiseEvent(PPEvent * event)91 void PPScreen::raiseEvent(PPEvent* event)
92 {
93 	if (event->isMouseEvent())
94 		adjustEventMouseCoordinates(event);
95 
96 	// route events to event listener first
97 	eventListener->handleEvent(reinterpret_cast<PPObject*>(this), event);
98 
99 	if (event->getID() == eInvalid)
100 		return;
101 
102 	// route timer event
103 	if (event->getID() == eTimer)
104 	{
105 		for (pp_int32 i = 0; i < timerEventControls->size(); i++)
106 		{
107 			PPControl* control = timerEventControls->get(i);
108 			if (!control->isVisible() || !control->receiveTimerEvent())
109 				continue;
110 
111 			control->dispatchEvent(event);
112 		}
113 		return;
114 	}
115 
116 	if (modalControl && modalControl->isVisible())
117 	{
118 		// listener of the modal control also gets a chance to listen to these events
119 		if (modalControl->getEventListener() &&
120 			modalControl->getEventListener() != eventListener)
121 			modalControl->getEventListener()->handleEvent(reinterpret_cast<PPObject*>(this), event);
122 
123 		// if the above listener removed the control we're out of here
124 		if (!modalControl)
125 			return;
126 
127 		modalControl->dispatchEvent(event);
128 		return;
129 	}
130 
131 	// ------- handle context menu -----------------------------------
132 	if (contextMenuControls->size())
133 	{
134 		pp_int32 i;
135 		bool handled = true;
136 
137 		bool mouseMoveHandeled = false;
138 		if (event->getID() == eMouseMoved || event->getID() == eLMouseDrag)
139 		{
140 			for (i = 0; i < contextMenuControls->size(); i++)
141 			{
142 				PPControl* contextMenuControl = contextMenuControls->get(contextMenuControls->size()-1);
143 				PPPoint* p = (PPPoint*)event->getDataPtr();
144 
145 				if (contextMenuControl->hit(*p) && contextMenuControl->isActive())
146 				{
147 					contextMenuControl->dispatchEvent(event);
148 					mouseMoveHandeled = true;
149 				}
150 			}
151 		}
152 		if (mouseMoveHandeled)
153 			return;
154 
155 		for (i = 0; i < contextMenuControls->size(); i++)
156 		{
157 			PPControl* contextMenuControl = contextMenuControls->get(i);
158 			if (contextMenuControl && contextMenuControl->isVisible())
159 			{
160 				switch (event->getID())
161 				{
162 					case eLMouseDown:
163 					case eRMouseDown:
164 					{
165 						PPPoint* p = (PPPoint*)event->getDataPtr();
166 
167 						if (contextMenuControl->hit(*p) && contextMenuControl->isActive())
168 						{
169 							contextMenuControl->dispatchEvent(event);
170 						}
171 						else
172 						{
173 							bool inOtherMenu = false;
174 							for (pp_int32 j = 0; j < contextMenuControls->size(); j++)
175 								if (contextMenuControls->get(j) != contextMenuControl &&
176 									contextMenuControls->get(j)->hit(*p))
177 								{
178 									inOtherMenu = true;
179 									break;
180 								}
181 
182 							if (!inOtherMenu)
183 							{
184 								if (event->getID() == eRMouseDown ||
185 									event->getID() == eLMouseDown)
186 									handled = true;
187 
188 								if (static_cast<PPContextMenu*>(contextMenuControl)->getNotifyParentOnHide())
189 								{
190 									setContextMenuControl(NULL, false);
191 									paint(false);
192 
193 									EventListenerInterface* listener = contextMenuControl->getEventListener();
194 
195 									struct MetaData
196 									{
197 										pp_int32 id;
198 										PPPoint p;
199 									} metaData;
200 
201 									metaData.id = event->getID();
202 									metaData.p = *p;
203 
204 									PPEvent e(eRemovedContextMenu, &metaData, sizeof(metaData));
205 									listener->handleEvent(reinterpret_cast<PPObject*>(contextMenuControl), &e);
206 
207 									update();
208 								}
209 								else
210 								{
211 									setContextMenuControl(NULL);
212 								}
213 
214 							}
215 						}
216 						break;
217 					}
218 					default:
219 						contextMenuControl->dispatchEvent(event);
220 				}
221 			}
222 		}
223 		if (handled)
224 			return;
225 	}
226 
227 	rootContainer->dispatchEvent(event);
228 }
229 
pauseUpdate(bool pause)230 void PPScreen::pauseUpdate(bool pause)
231 {
232 	displayDevice->allowForUpdates(!pause);
233 }
234 
enableDisplay(bool enable)235 void PPScreen::enableDisplay(bool enable)
236 {
237 	displayDevice->enable(enable);
238 }
239 
isDisplayEnabled()240 bool PPScreen::isDisplayEnabled()
241 {
242 	return displayDevice->isEnabled();
243 }
244 
clear()245 void PPScreen::clear()
246 {
247 	PPGraphicsAbstract* g = displayDevice->open();
248 	if (!g)
249 		return;
250 
251 	g->setColor(0,0,0);
252 	g->setRect(0, 0, g->getWidth(), g->getHeight());
253 	g->fill();
254 
255 	displayDevice->close();
256 	displayDevice->update();
257 }
258 
paint(bool update,bool clean)259 void PPScreen::paint(bool update/*= true*/, bool clean/*=false*/)
260 {
261 	if (displayDevice == NULL)
262 		return;
263 
264 	PPGraphicsAbstract* g = displayDevice->open();
265 	if (!g)
266 		return;
267 
268 	if (clean)
269 	{
270 		g->setColor(0,0,0);
271 
272 		g->setRect(0, 0, g->getWidth(), g->getHeight());
273 
274 		g->fill();
275 	}
276 
277 	/*g->setColor(255, 255, 255);
278 
279 	pp_int32 step = 0;
280 	for (pp_int32 y = 0; y < sizeof(characters)/sizeof(pp_uint16); y++)
281 	{
282 
283 		for (pp_int32 x = 0; x < 4; x++)
284 		{
285 
286 			if ((characters[y]>>((3-x)<<2))&1)
287 			{
288 				g->setPixel(x+32,y+32+step);
289 			}
290 
291 		}
292 
293 		step += ((y%5)==4)*2;
294 
295 	}*/
296 
297 	//g->setFont(PPFont::getFont(PPFont::FONT_SYSTEM));
298 	//g->setColor(255, 255, 255);
299 	//g->drawChar('A',0,0);
300 
301 	pp_int32 i;
302 
303 	/*for (i = 0; i < controls.size(); i++)
304 	{
305 		PPControl* control = controls.get(i);
306 		if (control->isVisible())
307 			controls.get(i)->paint(g);
308 	}*/
309 
310 	// modal control overlapping everything
311 	if (!(modalControl && modalControl->isVisible() &&
312 		  modalControl->getLocation().x == 0 &&
313 		  modalControl->getLocation().y == 0 &&
314 		  modalControl->getSize().width == getWidth() &&
315 		  modalControl->getSize().height == getHeight()))
316 	{
317 		rootContainer->paint(g);
318 
319 		for (i = 0; i < contextMenuControls->size(); i++)
320 		{
321 			PPControl* control = contextMenuControls->get(i);
322 			control->paint(g);
323 		}
324 	}
325 
326 	if (modalControl)
327 		modalControl->paint(g);
328 
329 	if (showDragHilite)
330 		paintDragHighlite(g);
331 
332 	displayDevice->close();
333 
334 	if (update)
335 		displayDevice->update();
336 }
337 
paintContextMenuControl(PPControl * control,bool update)338 void PPScreen::paintContextMenuControl(PPControl* control, bool update/* = true*/)
339 {
340 	if (displayDevice == NULL || !control->isVisible())
341 		return;
342 
343 	PPGraphicsAbstract* g = displayDevice->open();
344 	if (!g)
345 		return;
346 
347 	for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
348 	{
349 		PPControl* ctrl = contextMenuControls->get(i);
350 		ctrl->paint(g);
351 	}
352 
353 	if (modalControl)
354 	{
355 		PPControl* ctrl = modalControl;
356 		ctrl->paint(g);
357 	}
358 
359 	displayDevice->close();
360 
361 	if (update)
362 	{
363 		PPRect rect = control->getBoundingRect();
364 
365 		rect.x1--;
366 		if (rect.x1 < 0) rect.x1 = 0;
367 		rect.y1--;
368 		if (rect.y1 < 0) rect.y1 = 0;
369 
370 		rect.x2++;
371 		if (rect.x2 > getWidth()) rect.x2 = getWidth();
372 		rect.y2++;
373 		if (rect.y2 > getHeight()) rect.y2 = getHeight();
374 
375 		displayDevice->update(rect);
376 	}
377 
378 }
379 
paintControl(PPControl * control,bool update)380 void PPScreen::paintControl(PPControl* control, bool update/*= true*/)
381 {
382 	if (displayDevice == NULL || !control->isVisible())
383 		return;
384 
385 	PPGraphicsAbstract* g = displayDevice->open();
386 	if (!g)
387 		return;
388 
389 	// modal control overlapping everything
390 	if (modalControl && modalControl->isVisible() &&
391 		modalControl->getLocation().x == 0 &&
392 		modalControl->getLocation().y == 0 &&
393 		modalControl->getSize().width == getWidth() &&
394 		modalControl->getSize().height == getHeight())
395 	{
396 		// see whether the control we shall paint is a child of the modal control
397 		// if it's not, we don't need to paint it, because the modal control overlaps us
398 		PPControl* parent = control->getOwnerControl();
399 
400 		bool isModalControlChild = (parent == NULL);
401 
402 		while (parent != NULL)
403 		{
404 			if (parent == modalControl)
405 			{
406 				isModalControlChild = true;
407 				break;
408 			}
409 
410 			control = parent;
411 			parent = control->getOwnerControl();
412 		}
413 
414 		if (!isModalControlChild)
415 			return;
416 	}
417 
418 	control->paint(g);
419 
420 	bool paintContextMenus = false;
421 	for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
422 	{
423 		PPControl* ctrl = contextMenuControls->get(i);
424 
425 		if (ctrl->getBoundingRect().intersect(control->getBoundingRect()))
426 		{
427 			paintContextMenus = true;
428 			break;
429 		}
430 	}
431 
432 	if (paintContextMenus)
433 	{
434 		for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
435 		{
436 			PPControl* ctrl = contextMenuControls->get(i);
437 			ctrl->paint(g);
438 		}
439 	}
440 
441 	if (modalControl)
442 	{
443 		// if the modal control hits the control to draw we also need to refresh the modal control
444 		if (modalControl->getBoundingRect().intersect(control->getBoundingRect()))
445 			modalControl->paint(g);
446 	}
447 
448 	displayDevice->close();
449 
450 	if (update)
451 	{
452 		updateControl(control);
453 	}
454 
455 }
456 
paintSplash(const pp_uint8 * rawData,pp_uint32 width,pp_uint32 height,pp_uint32 pitch,pp_uint32 bpp,pp_int32 intensity)457 void PPScreen::paintSplash(const pp_uint8* rawData, pp_uint32 width, pp_uint32 height, pp_uint32 pitch, pp_uint32 bpp, pp_int32 intensity/* = 256*/)
458 {
459 	PPGraphicsAbstract* g = displayDevice->open();
460 	if (!g)
461 		return;
462 
463 	PPPoint p;
464 	p.x = g->getWidth() / 2 - width / 2;
465 	p.y = g->getHeight() / 2 - height / 2;
466 
467 	PPSize s;
468 	s.width = width; s.height = height;
469 	g->blit(rawData, p, s, pitch, bpp, intensity);
470 
471 	displayDevice->close();
472 
473 	displayDevice->update();
474 }
475 
update()476 void PPScreen::update()
477 {
478 	if (displayDevice)
479 	{
480 		if (showDragHilite)
481 		{
482 			PPGraphicsAbstract* g = displayDevice->open();
483 			paintDragHighlite(g);
484 			displayDevice->close();
485 		}
486 		displayDevice->update();
487 	}
488 }
489 
updateControl(PPControl * control)490 void PPScreen::updateControl(PPControl* control)
491 {
492 	PPRect rect = control->getBoundingRect();
493 
494 	rect.x1--;
495 	if (rect.x1 < 0) rect.x1 = 0;
496 	rect.y1--;
497 	if (rect.y1 < 0) rect.y1 = 0;
498 
499 	rect.x2++;
500 	if (rect.x2 > getWidth()) rect.x2 = getWidth();
501 	rect.y2++;
502 	if (rect.y2 > getHeight()) rect.y2 = getHeight();
503 
504 	displayDevice->update(rect);
505 }
506 
setFocus(PPControl * control,bool repaint)507 void PPScreen::setFocus(PPControl* control, bool repaint/* = true*/)
508 {
509 	PPSimpleVector<PPControl> chain(0, false);
510 
511 	PPControl* ctrl = NULL;
512 	if (control == NULL)
513 	{
514 		rootContainer->setFocus(NULL);
515 		return;
516 	}
517 	else
518 	{
519 		ctrl = control;
520 		chain.add(ctrl);
521 	}
522 
523 	if (ctrl == NULL)
524 		return;
525 
526 	while (ctrl->getOwnerControl())
527 	{
528 		PPControl* parent = ctrl->getOwnerControl();
529 		ctrl = parent;
530 		if (ctrl->isContainer())
531 			chain.add(ctrl);
532 	}
533 
534 	for (pp_int32 i = chain.size()-1; i > 0; i--)
535 	{
536 		if (chain.get(i)->isContainer())
537 		{
538 			static_cast<PPContainer*>(chain.get(i))->setFocus(chain.get(i-1), repaint);
539 		}
540 	}
541 }
542 
getFocusedControl() const543 PPControl* PPScreen::getFocusedControl() const
544 {
545 	// first we need to find the control which is at the end of the focus hierarchy
546 	PPControl* parent = rootContainer;
547 	while (parent->isContainer() && static_cast<PPContainer*>(parent)->getFocusedControl())
548 	{
549 		parent = static_cast<PPContainer*>(parent)->getFocusedControl();
550 	}
551 
552 	// if this is still a container this is not what we want => NULL
553 	return parent->isContainer() ? NULL : parent;
554 }
555 
hasFocus(PPControl * control) const556 bool PPScreen::hasFocus(PPControl* control) const
557 {
558 	// if the client is asking for container focus we first need to find the control
559 	// which is at the end of the focus hierarchy (see above)
560 	PPControl* parent = control;
561 	while (parent->isContainer() && static_cast<PPContainer*>(parent)->getFocusedControl())
562 	{
563 		parent = static_cast<PPContainer*>(parent)->getFocusedControl();
564 	}
565 
566 	// now if those controls match, we're in focus
567 	return getFocusedControl() == parent;
568 }
569 
addControl(PPControl * control)570 void PPScreen::addControl(PPControl* control)
571 {
572 	rootContainer->addControl(control);
573 }
574 
removeControl(PPControl * control)575 bool PPScreen::removeControl(PPControl* control)
576 {
577 	return rootContainer->removeControl(control);
578 }
579 
addTimerEventControl(PPControl * control)580 void PPScreen::addTimerEventControl(PPControl* control)
581 {
582 	if (control->receiveTimerEvent() && !control->isContainer())
583 		timerEventControls->add(control);
584 }
585 
removeTimerEventControl(PPControl * control)586 bool PPScreen::removeTimerEventControl(PPControl* control)
587 {
588 	bool res = false;
589 	for (pp_int32 i = 0; i < timerEventControls->size(); i++)
590 	{
591 		if (timerEventControls->get(i) == control)
592 		{
593 			timerEventControls->remove(i);
594 			res = true;
595 		}
596 	}
597 
598 	return res;
599 }
600 
601 
getControlByID(pp_int32 id) const602 PPControl* PPScreen::getControlByID(pp_int32 id) const
603 {
604 	return rootContainer->getControlByID(id);
605 }
606 
releaseCaughtControls()607 void PPScreen::releaseCaughtControls()
608 {
609 	// uncatch controls within containers
610 	PPControl* parent = rootContainer;
611 	while (parent->isContainer() &&
612 		   static_cast<PPContainer*>(parent)->caughtControl &&
613 		   static_cast<PPContainer*>(parent)->currentlyPressedMouseButtons != 0)
614 	{
615 		PPControl* caughtControl = static_cast<PPContainer*>(parent)->caughtControl;
616 		static_cast<PPContainer*>(parent)->caughtControl = NULL;
617 		static_cast<PPContainer*>(parent)->currentlyPressedMouseButtons = 0;
618 		parent = caughtControl;
619 	}
620 }
621 
setModalControl(PPControl * control,bool repaint)622 void PPScreen::setModalControl(PPControl* control, bool repaint/* = true*/)
623 {
624 	// Hide open menus first
625 	setContextMenuControl(NULL, false);
626 
627 	if (modalControl)
628 	{
629 		PPEvent event(eFocusLostNoRepaint);
630 		modalControl->dispatchEvent(&event);
631 		modalControl->show(false);
632 	}
633 
634 	if (control)
635 	{
636 		// uncatch controls within containers
637 		releaseCaughtControls();
638 		PPEvent event(eFocusGainedNoRepaint);
639 		control->dispatchEvent(&event);
640 		control->show(true);
641 	}
642 	else if (focusedControl)
643 	{
644 		PPEvent event(eFocusGainedNoRepaint);
645 		focusedControl->dispatchEvent(&event);
646 	}
647 
648 	modalControl = control;
649 
650 	if (repaint)
651 		paint();
652 }
653 
654 
setContextMenuControl(PPControl * control,bool repaint)655 void PPScreen::setContextMenuControl(PPControl* control, bool repaint/* = true*/)
656 {
657 	if (control == NULL && !contextMenuControls->size())
658 		return;
659 
660 	PPEvent event(eFocusLost);
661 	PPEvent event2(eFocusGained);
662 
663 	for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
664 		contextMenuControls->get(i)->dispatchEvent(&event);
665 
666 	delete contextMenuControls;
667 	contextMenuControls = new PPSimpleVector<PPControl>(16, false);
668 
669 	if (control)
670 	{
671 		// uncatch controls within containers
672 		releaseCaughtControls();
673 		control->dispatchEvent(&event2);
674 		contextMenuControls->add(control);
675 	}
676 
677 	if (repaint)
678 		paint();
679 }
680 
addContextMenuControl(PPControl * control,bool repaint)681 void PPScreen::addContextMenuControl(PPControl* control, bool repaint/* = true*/)
682 {
683 	PPEvent event(eFocusLost);
684 	PPEvent event2(eFocusGained);
685 
686 	if (control)
687 	{
688 		control->dispatchEvent(&event2);
689 		contextMenuControls->add(control);
690 	}
691 
692 	if (repaint)
693 		paint();
694 }
695 
removeContextMenuControl(PPControl * control,bool repaint)696 bool PPScreen::removeContextMenuControl(PPControl* control, bool repaint/* = true*/)
697 {
698 	if (!contextMenuControls->size())
699 		return false;
700 
701 	bool res = false;
702 	for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
703 		if (contextMenuControls->get(i) == control)
704 		{
705 			contextMenuControls->remove(i);
706 			res = true;
707 		}
708 
709 	if (res && repaint)
710 		paint();
711 
712 	return res;
713 }
714 
removeLastContextMenuControl(bool repaint)715 bool PPScreen::removeLastContextMenuControl(bool repaint/* = true*/)
716 {
717 	if (contextMenuControls->size())
718 	{
719 		contextMenuControls->remove(contextMenuControls->size()-1);
720 
721 		if (repaint)
722 			paint();
723 
724 		return true;
725 	}
726 
727 	return false;
728 }
729 
hasContextMenu(PPControl * control) const730 bool PPScreen::hasContextMenu(PPControl* control) const
731 {
732 	if (!contextMenuControls->size())
733 		return false;
734 
735 	for (pp_int32 i = 0; i < contextMenuControls->size(); i++)
736 		if (contextMenuControls->get(i) == control)
737 			return true;
738 
739 	return false;
740 }
741 
setShowDragHilite(bool b)742 void PPScreen::setShowDragHilite(bool b)
743 {
744 	showDragHilite = b;
745 
746 	if (!b)
747 	{
748 		PPGraphicsAbstract* g = displayDevice->open();
749 		paintDragHighlite(g);
750 		displayDevice->close();
751 	}
752 
753 	paint();
754 }
755 
getWidth() const756 pp_int32 PPScreen::getWidth() const
757 {
758 	if (displayDevice == NULL)
759 		return -1;
760 
761 	return displayDevice->getSize().width;
762 }
763 
getHeight() const764 pp_int32 PPScreen::getHeight() const
765 {
766 	if (displayDevice == NULL)
767 		return -1;
768 
769 	return displayDevice->getSize().height;
770 }
771 
getDefaultWidth()772 pp_int32 PPScreen::getDefaultWidth()
773 {
774 	return PPDisplayDeviceBase::getDefaultWidth();
775 }
776 
getDefaultHeight()777 pp_int32 PPScreen::getDefaultHeight()
778 {
779 	return PPDisplayDeviceBase::getDefaultHeight();
780 }
781 
setTitle(const PPSystemString & title)782 void PPScreen::setTitle(const PPSystemString& title)
783 {
784 	if (displayDevice)
785 		displayDevice->setTitle(title);
786 }
787 
setSize(const PPSize & size)788 void PPScreen::setSize(const PPSize& size)
789 {
790 	if (displayDevice)
791 		displayDevice->setSize(size);
792 
793 	rootContainer->setSize(size);
794 }
795 
supportsScaling() const796 bool PPScreen::supportsScaling() const
797 {
798 	if (displayDevice)
799 		return displayDevice->supportsScaling();
800 
801 	return false;
802 }
803 
getScaleFactor() const804 pp_int32 PPScreen::getScaleFactor() const
805 {
806 	if (displayDevice)
807 		return displayDevice->getScaleFactor();
808 
809 	return 1;
810 }
811 
812 
goFullScreen(bool b)813 bool PPScreen::goFullScreen(bool b)
814 {
815 	if (displayDevice)
816 		return displayDevice->goFullScreen(b);
817 
818 	return false;
819 }
820 
isFullScreen() const821 bool PPScreen::isFullScreen() const
822 {
823 	if (displayDevice)
824 		return displayDevice->isFullScreen();
825 
826 	return false;
827 }
828 
getDisplayResolution() const829 PPSize PPScreen::getDisplayResolution() const
830 {
831 	PPSize size(-1, -1);
832 
833 	if (displayDevice)
834 		size = displayDevice->getDisplayResolution();
835 
836 	return size;
837 }
838 
signalWaitState(bool b,const PPColor & color)839 void PPScreen::signalWaitState(bool b, const PPColor& color)
840 {
841 	if (displayDevice)
842 		displayDevice->signalWaitState(b, color);
843 }
844 
setMouseCursor(MouseCursorTypes type)845 void PPScreen::setMouseCursor(MouseCursorTypes type)
846 {
847 	if (displayDevice)
848 		displayDevice->setMouseCursor(type);
849 }
850 
getCurrentActiveMouseCursor() const851 MouseCursorTypes PPScreen::getCurrentActiveMouseCursor() const
852 {
853 	if (displayDevice)
854 		return (MouseCursorTypes)displayDevice->getCurrentActiveMouseCursor();
855 
856 	return MouseCursorTypeStandard;
857 }
858 
shutDown()859 void PPScreen::shutDown()
860 {
861 	if (displayDevice)
862 		displayDevice->shutDown();
863 }
864 
865