tags:

views:

186

answers:

0

Hi , I have to design a screen where i palce 5 images 1: An Image on the Left Side of the Screen lets say --Left Image (Thihs image comes from Web service) 2: A back Button Image on the Left image lets say-- BackLeft(Placed in the recources folder of the application) 3: A Image on the Middle of the screen lets say --Middle Image (Thihs image comes from Web service) 4: A Image on the Right Side of the Screen lets say---Right Image (Thihs image comes from Web service) 5: A Back Image on the Right Image lets say --BackRight (Placed in the recources folder of the application)

I want to set the focus on Backleft,MiddleImageand BackRight. However i just get the focus on the Middle Image , and not on the Backleft and BackRight Images.

Below is my code Please help

package ....;

import ICEControlEvent.CEMainMenu;
import ViewData.ViewData;
import net.rim.device.api.collection.util.BigIntVector;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;

import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
     import com.intelity.client.general.Controller;
     import com.intelity.client.general.CustomOpenImage;
     import com.intelity.client.general.SystemFunction;

     public class MainMenuConrol extends MainScreen implements ICEControl {
int _imageWidth = 0;
int _imageHeight = 0;

CustomOpenImage c;
HorizontalFieldManager verticalManager, _verticalManager_1,
        _verticalManager_2, _verticalManager_3;
LabelField menu_Label;
Font label_font;
/*Bitmap _RightCardImage, _LeftCardImage;
BitmapField _leftCard, _rightCard;

*/

public MainMenuConrol() {
    super((Screen.VERTICAL_SCROLL | Screen.VERTICAL_SCROLLBAR)&(Field.FOCUSABLE));

    // Set Font
    FontFamily f[] = FontFamily.getFontFamilies();
    label_font = f[1].getFont(FontFamily.SCALABLE_FONT, 15);
    // Initialise class to open Image
    try {
        c = new CustomOpenImage();
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }


}

public void Render(ViewData data) {

        add(new HorizontalFieldManager()
        {
             protected void sublayout(int maxWidth, int maxHeight)  {
                setExtent(Display.getWidth(), Display.getHeight()/25);
            }
        });
        //Adding the LeftCarner Card
        _verticalManager_1 = setLayout();
        BitmapField menu_image_field = null;
        try {
            menu_image_field = new BitmapField(c.OpenImage(data._MenuInfo[0].getMenuImage()));
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        _verticalManager_1.add(menu_image_field);


        //Adding the Back Button on Left Card
        Bitmap _LeftCardImage = Bitmap.getBitmapResource("RightCard.png");
        BitmapField _leftCard = new BitmapField(_LeftCardImage,(BitmapField.FOCUSABLE) )
        {
             protected void onFocus(int direction) { 
                    super.onFocus(direction); 

            } 


                protected boolean navigationClick(int status, int time) {
                super.setFocus();

                System.out.println("hello.....1");
                return true;
            }
        };
        _verticalManager_1.add(_leftCard);


        //Adding the Middle Card
        BitmapField menu_image_field2 = null;
        try {
            menu_image_field2 = new BitmapField(c.OpenImage(data._MenuInfo[1].getMenuImage()),BitmapField.FOCUSABLE);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //Adding the Right Card
        _verticalManager_1.add(menu_image_field2);

        BitmapField menu_image_field3 = null;
        try {
            menu_image_field3 = new BitmapField(c.OpenImage(data._MenuInfo[2].getMenuImage()));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        _verticalManager_1.add(menu_image_field3);

        //Adding the Back button on Right Card
        Bitmap _RightCardImage = Bitmap.getBitmapResource("RightCard.png");
        BitmapField _rightCard = new BitmapField(_LeftCardImage,(BitmapField.FOCUSABLE ) )
        {
            protected boolean navigationClick(int status, int time) {

                System.out.println("hello.....1");
                return true;
            }
        };
        _verticalManager_1.add(_rightCard);

        //Adding the Manager on the screen
        add(_verticalManager_1);

        setTitle("MainMenu Screen");
        UiApplication.getUiApplication().pushScreen(this);
}


public HorizontalFieldManager setLayout() {
    System.out.println("In Horizontal Bar");
    verticalManager = new HorizontalFieldManager() {

        protected void sublayout(int maxWidth, int maxHeight) {
            System.out.println("In Horizontal Bar.....1");
            Field field = null;
            int _LeftCardWidth=0;
            int _MiddleCardWidth=0;


            for (int i = 0; i < getFieldCount(); i++) {
                System.out.println("Horizontal manager_1..........1");
                field = getField(i);
                // if (field instanceof BitmapField) {
                if (i == 0) {
                    layoutChild(field, maxWidth/5, maxHeight);
                    setPositionChild(field, 0, Display.getHeight()/4);
                    _LeftCardWidth=maxWidth/5;

                } else if (i == 1) {
                    layoutChild(field, maxWidth, maxHeight );
                    setPositionChild(field, 0,(Display.getHeight()/4)+10);

                } else if (i == 2) {
                    layoutChild(field, maxWidth/2, maxHeight );
                    setPositionChild(field, _LeftCardWidth+5,Display.getHeight()/7);
                    _MiddleCardWidth= _LeftCardWidth+(maxWidth/2);

                }  else if (i == 3) {
                    layoutChild(field, maxWidth/5, maxHeight/5 );
                    setPositionChild(field, _MiddleCardWidth+15,Display.getHeight()/4);


                }else if (i == 4) {
                    layoutChild(field, maxWidth, maxHeight );
                    setPositionChild(field, _MiddleCardWidth+30,(Display.getHeight()/4)+10);

                } 
            }
            setExtent(Display.getWidth(), 3*Display.getHeight()/5);
        }

        protected void paintBackground(Graphics graphics) 
        {
            super.drawHighlightRegion(graphics, HIGHLIGHT_FOCUS, true, 0,
                    0, 10, 10);

            graphics.setBackgroundColor(Color.WHITE);
            graphics.setColor(Color.BLACK);
            graphics.clear();
            super.paint(graphics);
        }

        /*
         * protected void paint(Graphics graphics) {
         * graphics.drawBitmap(0,10, 50, 50, _LeftCardImage,0 ,20); }
         */

    };
    return verticalManager;
}

public void navigationClick(Field field, int status) {
    // TODO Auto-generated method stub

}

}