Skip to main content
Version: 4.16

Screen

A Screen represents a full-screen drawable area. Applications create specific screens by subclassing this class. Each Screen has a root container to which drawables are added. The Screen makes sure to delegate draw requests and various events to the appropriate drawables in correct order.

Inherited by: View< T >

Public Functions#

virtual voidafterTransition()
Called by Application::handleTickEvent() when the transition to the screen is done.
voidbindTransition(Transition & trans)
Enables the transition to access the containers.
voiddraw()
Tells the screen to draw its entire area.
virtual voiddraw(Rect & rect)
Tell the screen to draw the specified area.
Container &getRootContainer()
Obtain a reference to the root container of this screen.
virtual voidhandleClickEvent(const ClickEvent & evt)
Traverse the drawables in reverse z-order and notify them of a click event.
virtual voidhandleDragEvent(const DragEvent & evt)
Traverse the drawables in reverse z-order and notify them of a drag event.
virtual voidhandleGestureEvent(const GestureEvent & evt)
Handle gestures.
virtual voidhandleKeyEvent(uint8_t key)
Called by the Application on the reception of a "key", the meaning of which is platform/application specific.
virtual voidhandleTickEvent()
Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.
voidJSMOC(const Rect & invalidatedArea, Drawable * widgetToDraw)
Recursive JSMOC function.
Screen()
Initializes a new instance of the Screen class.
virtual voidsetupScreen()
Called by Application::switchScreen() when this screen is going to be displayed.
voidstartSMOC(const Rect & invalidatedArea)
Starts a JSMOC run, analyzing what parts of what widgets should be redrawn.
virtual voidtearDownScreen()
Called by Application::switchScreen() when this screen will no longer be displayed.
boolusingSMOC() const
Determines if using JSMOC.
virtual ~Screen()
Finalizes an instance of the Screen class.

Protected Functions#

voidadd(Drawable & d)
Add a drawable to the content container.
voidremove(Drawable & d)
Removes a drawable from the content container.
voiduseSMOCDrawing(bool enabled)
Determines whether to use JSMOC or painter's algorithm for drawing.

Protected Attributes#

Containercontainer
The container contains the contents of the screen.
Drawable *focus
The drawable currently in focus (set when DOWN_PRESSED is received).

Public Functions Documentation#

afterTransition#

virtual void afterTransition()

Called by Application::handleTickEvent() when the transition to the screen is done.

Base version does nothing, but override to do screen specific initialization code that has to be done after the transition to the screen.

See also:

bindTransition#

Enables the transition to access the containers.

Parameters:
transThe transition to bind.

draw#

void draw()

Tells the screen to draw its entire area.

Note

The more specific draw(Rect&) version is preferred when possible.

draw#

virtual void draw(Rect &rect)

Tell the screen to draw the specified area.

Will traverse the drawables tree from in z-order and delegate draw to them.

Parameters:
rectThe area in absolute coordinates.
Note

The given rect must be in absolute coordinates.

getRootContainer#

Container & getRootContainer()

Obtain a reference to the root container of this screen.

Returns:

The root container.

handleClickEvent#

virtual void handleClickEvent(const ClickEvent &evt)

Traverse the drawables in reverse z-order and notify them of a click event.

Parameters:
evtThe event to handle.

handleDragEvent#

virtual void handleDragEvent(const DragEvent &evt)

Traverse the drawables in reverse z-order and notify them of a drag event.

Parameters:
evtThe event to handle.

handleGestureEvent#

virtual void handleGestureEvent(const GestureEvent &evt)

Handle gestures.

Traverses drawables in reverse-z and notifies them of the gesture.

Parameters:
evtThe event to handle.

handleKeyEvent#

virtual void handleKeyEvent(uint8_tkey)

Called by the Application on the reception of a "key", the meaning of which is platform/application specific.

Default implementation does nothing.

Parameters:
keyThe key to handle.

handleTickEvent#

virtual void handleTickEvent()

Called by the Application on the current screen with a frequency of Application::TICK_INTERVAL_MS.

JSMOC#

void JSMOC(const Rect &invalidatedArea ,
Drawable *widgetToDraw
)

Recursive JSMOC function.

This is the actual occlusion culling implementation.

Parameters:
invalidatedAreaThe area to redraw, expressed in absolute coordinates.
widgetToDrawWidget currently being drawn.
Note

JSMOC is an abbreviation of Jesper, Sren & Martin's Occlusion Culling.

Screen#

Initializes a new instance of the Screen class.

setupScreen#

virtual void setupScreen()

Called by Application::switchScreen() when this screen is going to be displayed.

Base version does nothing, but place any screen specific initialization code in an overridden version.

See also:

startSMOC#

void startSMOC(const Rect &invalidatedArea)

Starts a JSMOC run, analyzing what parts of what widgets should be redrawn.

Parameters:
invalidatedAreaThe area to redraw, expressed in absolute coordinates.
Note

SMOC is an abbreviation of Sren & Martin's Occlusion Culling.

tearDownScreen#

virtual void tearDownScreen()

Called by Application::switchScreen() when this screen will no longer be displayed.

Base version does nothing, but place any screen specific cleanup code in an overridden version.

See also:

usingSMOC#

bool usingSMOC()const

Determines if using JSMOC.

Returns:

true if this screen uses the JSMOC drawing algorithm.

~Screen#

virtual ~Screen()

Finalizes an instance of the Screen class.

Protected Functions Documentation#

add#

void add(Drawable &d)

Add a drawable to the content container.

Parameters:
dThe Drawable to add.
Note

Must not be called with a Drawable that was already added to the screen. If in doubt, call remove() first.

remove#

void remove(Drawable &d)

Removes a drawable from the content container.

Safe to call even if the drawable was never added (in which case nothing happens).

Parameters:
dThe Drawable to remove.

useSMOCDrawing#

void useSMOCDrawing(boolenabled)

Determines whether to use JSMOC or painter's algorithm for drawing.

Parameters:
enabledtrue if JSMOC should be enabled, false if disabled (meaning painter's algorithm is employed instead).

Protected Attributes Documentation#

container#

Container container

The container contains the contents of the screen.

focus#

Drawable * focus

The drawable currently in focus (set when DOWN_PRESSED is received).