/*Copyright 2011 indiandragon

 This file is part of j2me2AB.

 J2meAB is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 j2me2AB is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with j2me2AB.  If not, see <http://www.gnu.org/licenses/>.
 */
package javax.microedition.lcdui;

import java.util.ArrayList;

import android.view.View;
import android.widget.LinearLayout;

public class Item extends LinearLayout {

    public static final int PLAIN = 0;
    public static final int BUTTON = 1;
    public static final int HYPERLINK = 2;
    public static final int LAYOUT_2 = 0x0001;
    public static final int LAYOUT_BOTTOM = 0x0002;
    public static final int LAYOUT_CENTER = 0x0004;
    public static final int LAYOUT_DEFAULT = 0x0008;
    public static final int LAYOUT_EXPAND = 0x0010;
    public static final int LAYOUT_LEFT = 0x0020;
    public static final int LAYOUT_NEWLINE_AFTER = 0x0040;
    public static final int LAYOUT_NEWLINE_BEFORE = 0x0080;
    public static final int LAYOUT_RIGHT = 0x0100;
    public static final int LAYOUT_SHRINK = 0x0200;
    public static final int LAYOUT_TOP = 0x0400;
    public static final int LAYOUT_VCENTER = 0x0800;
    public static final int LAYOUT_VEXPAND = 0x1000;
    public static final int LAYOUT_VSHRINK = 0x2000;

    public Item() {
        super(UIGlobal.APP_CONTEXT);
    }
    ArrayList<Command> arrayListCommands = new ArrayList<Command>();
    private int itemlayout;

    public int getItemlayout() {
        return itemlayout;
    }

    public void setItemlayout(int itemlayout) {
        this.itemlayout = itemlayout;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }
    String text = null;

    public String getText() {
        return text;
    }

    public void setText(String label) {
        this.text = label;
    }

    public int getMinimumHeight() {
        return minimumHeight;
    }

    public void setMinimumHeight(int minimumHeight) {
        this.minimumHeight = minimumHeight;
    }

    public int getMinimumWidth() {
        return minimumWidth;
    }

    public void setMinimumWidth(int minimumWidth) {
        this.minimumWidth = minimumWidth;
    }

    public int getPreferredHeight() {
        return preferredHeight;
    }

    public void setPreferredHeight(int preferredHeight) {
        this.preferredHeight = preferredHeight;
    }

    public int getPreferredWidth() {
        return preferredWidth;
    }

    public void setPreferredWidth(int preferredWidth) {
        this.preferredWidth = preferredWidth;
    }
    public String label;
    private int minimumHeight;
    private int minimumWidth;
    private int preferredHeight;
    private int preferredWidth;
    public Command defaultCommand = new Command("OK", Command.ITEM, 0);
    public Command command = new Command("OK", Command.ITEM, 0);
    public ItemCommandListener itemCommandListener;
    public ItemStateListener itemStateListener;

    public void setDefaultCommand(Command cmd) {
        arrayListCommands.add(defaultCommand = cmd);
    }

    public void removeDefaultCommand(Command cmd) {
        defaultCommand = null;
        arrayListCommands.remove(cmd);
    }

    public void addCommand(Command cmd) {
        arrayListCommands.add(command = cmd);
    }

    public void removeCommand(Command cmd) {
        command = null;
        arrayListCommands.remove(cmd);
    }

    public void setItemCommandListener(ItemCommandListener l) {
        this.itemCommandListener = l;
    }

    public ItemCommandListener getItemCommandListener() {
        return this.itemCommandListener;
    }

    public void setItemStateListener(ItemStateListener l) {
        this.itemStateListener = l;
    }

    public ItemStateListener getItemStateListener() {
        return this.itemStateListener;
    }

    public View getView() {
        return this;
    }
}
