package com.bitrazor.tivo.trafficcam;
import java.awt.Color;

import com.tivo.hme.bananas.BApplication;
import com.tivo.hme.bananas.BScreen;
import com.tivo.hme.bananas.BText;

public class ScreenTemplate extends BScreen { 

    public ScreenTemplate(BApplication app) {
        super(app);

        // Set background and title
        getBelow().setResource("blue.jpg"); 
        setTitle(this.toString());

    }

    // Set the title of the window in a safe area of the screen.
    private void setTitle(String t) {
        BText title = new BText(getNormal(), SAFE_TITLE_H+100, SAFE_TITLE_V, 
            (getWidth()-(SAFE_TITLE_H*2))-100, 54);
        title.setValue(t);
        title.setColor(Color.yellow);
        title.setShadow(Color.black, 3);
        title.setFlags(RSRC_VALIGN_TOP);
        title.setFont("default-48.font");
    }

    // If the left key is pressed, return to the calling screen.
    public boolean handleKeyPress(int code, long rawcode) {
        switch (code) {
            case KEY_LEFT:
                getBApp().pop();
                return true;
        }

        return super.handleKeyPress(code, rawcode);
    }

}
