Class Screen

Screen includes methods related to screen of the device.

Methods


screen.repaint

Requests a repaint of the screen. The application's "draw to" will be called when the other pending events have been processed.

Example

main
  system.run application new MyApplication
                
class MyApplication extends Application
                
  MyApplication
    screen.repaint            // Gets "draw to" to be called.

  draw to <Canvas g>
    // Perform required drawing
    return
                

(size) screen.get size

Get the size of the screen.

Return value

Example

main
  // Get current screen size
  size screenSize = screen.get size
                

screen.set orientation to <orientation newOrientation>

Set the orientation of the screen

Parameters

Example

main
  // Get screen orientation to landscape
  screen.set orientation to LANDSCAPE
                

(orientation) screen.get orientation

Get the orientation of the screen

Return value

Example

main
  // Get screen orientation to landscape
  orientation o = screen.get orientation
  
  if ( o == LANDSCAPE )
    print "Screen orientation is landscape."
  if ( o == PORTRAIT )
    print "Screen orientation is portrait."
                

screen.keep backlight on <bool keepOn>

Keeps the backlight on. If you call this method and the keepOn is true the backlight of the phone is kept on. You can reset this by calling the method with parameter keepOn as false. Note that the phone might switch the backlight on again from an user input event.

Parameters

Example

main
  // Set screen backlight as always on
  screen.keep backlight on true
                

screen.repaint<rectangle rect>

Requests a repaint part of the screen defined in rectangle. The application's "draw to" will be called when the other pending events have been processed.

Parameters

Example

main
  system.run application new MyApplication
                
class MyApplication extends Application
                
  MyApplication
    // Requests "draw to <canvas>" to be called on rectangle sized 100x100 and positioned at top left corner.
    screen.repaint 0,0 size 100,100

  draw to <canvas g>
    // Perform required drawing
    return
                

screen.add screen orientation listener <ScreenOrientationListener listener>

Requests notification of screen orientation changes to 'listener'.

Parameters

Example

main
  // Construct and run an origo application.
  system.run application new MyApplication


class MyApplication extends Application implements ScreenOrientationListener
  
  MyApplication 
    screen.add screen orientation listener this
  
  screen orientation changed to <orientation o>
    if ( o == PORTRAIT )
      print "screen changed to portrait mode"
    if ( o == LANDSCAPE )
      print "screen changed to landscape mode"
                

screen.remove screen orientation listener <ScreenOrientationListener listener>

Removes 'listener' from list of classes to be notified of screen orientation changes.

Parameters

Example

main
  // Construct and run an origo application.
  system.run application new MyApplication


class MyApplication extends Application implements ScreenOrientationListener
  
  MyApplication 
    screen.add screen orientation listener this
  
  screen orientation changed to <orientation o>
    print "screen orientation changed, removing listener"
    screen.remove screen orientation listener this