package com.bitrazor.tivo.trafficcam;

import com.tivo.hme.bananas.BEvent;
import com.tivo.hme.bananas.BList;
import com.tivo.hme.bananas.BText;
import com.tivo.hme.bananas.BView;

// Heavily leveraged from the Bananas sample source
class ScreenList extends BList {

    public ScreenList(BView parent, int x, int y, int width, int height, int rowHeight) {
        super(parent, x, y, width, height, rowHeight);
        setBarAndArrows(BAR_HANG, BAR_DEFAULT, null, "push");
    }


    protected void createRow(BView parent, int index)
    {   
        BText text = new BText(parent, 10, 4, parent.getWidth()-40, parent.getHeight() - 4);
        text.setShadow(true);
        text.setFlags(RSRC_HALIGN_LEFT);
        text.setValue(get(index).toString());
    }

    public boolean handleKeyPress(int code, long rawcode) 
    {
        switch (code) {
          case KEY_SELECT:
            postEvent(new BEvent.Action(this, "push"));
            return true;
        }
        return super.handleKeyPress(code, rawcode);
    }
}

