⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 component.java

📁 moto手机专用的LWT类库源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Component.java

package com.motorola.lwt;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

// Referenced classes of package com.motorola.lwt:
//            ComponentScreen

public abstract class Component
{

    public static final int SCREEN_LEFT = 0;
    public static final int SCREEN_HCENTER = 1;
    public static final int SCREEN_RIGHT = 2;
    public static final int PREVIOUS_COMPONENT_LEFT = 3;
    public static final int PREVIOUS_COMPONENT_HCENTER = 4;
    public static final int PREVIOUS_COMPONENT_RIGHT = 5;
    public static final int WIDTH = 6;
    public static final int PREFERRED_WIDTH = 7;
    public static final int SCREEN_TOP = 8;
    public static final int PREVIOUS_COMPONENT_TOP = 9;
    public static final int PREVIOUS_COMPONENT_VCENTER = 10;
    public static final int PREVIOUS_COMPONENT_BOTTOM = 11;
    public static final int HEIGHT = 12;
    public static final int PREFERRED_HEIGHT = 13;
    int leftEdgeValue;
    int leftEdgeScheme;
    int rightEdgeValue;
    int rightEdgeScheme;
    int topEdgeValue;
    int topEdgeScheme;
    int bottomEdgeValue;
    int bottomEdgeScheme;
    int x;
    int y;
    int width;
    int height;
    boolean visible;
    boolean enabled;
    ComponentScreen parent;
    protected boolean acceptsKeyFocus;

    protected void invalidateParent()
    {
        if(parent != null)
            parent.invalidate();
    }

    public void setLeftEdge(int i, int j)
        throws IllegalArgumentException
    {
        if(i >= 0 && i <= 5)
        {
            leftEdgeScheme = i;
            leftEdgeValue = j;
            invalidateParent();
        } else
        {
            throw new IllegalArgumentException();
        }
    }

    public void setRightEdge(int i, int j)
        throws IllegalArgumentException
    {
        if(i >= 0 && i <= 7)
        {
            rightEdgeScheme = i;
            rightEdgeValue = j;
            invalidateParent();
        } else
        {
            throw new IllegalArgumentException();
        }
    }

    public void setTopEdge(int i, int j)
        throws IllegalArgumentException
    {
        if(i >= 8 && i <= 11)
        {
            topEdgeScheme = i;
            topEdgeValue = j;
            invalidateParent();
        } else
        {
            throw new IllegalArgumentException();
        }
    }

    public void setBottomEdge(int i, int j)
        throws IllegalArgumentException
    {
        if(i >= 8 && i <= 13)
        {
            bottomEdgeScheme = i;
            bottomEdgeValue = j;
            invalidateParent();
        } else
        {
            throw new IllegalArgumentException();
        }
    }

    boolean contains(int i, int j)
    {
        i -= x;
        j -= y;
        return i >= 0 && j >= 0 && i < width && j < height;
    }

    public boolean isVisible()
    {
        return visible;
    }

    public void setVisible(boolean flag)
    {
        if(visible != flag)
        {
            repaint();
            visible = flag;
            if(parent != null)
            {
                parent.invalidate();
                parent.repaint();
            }
        }
    }

    public boolean isEnabled()
    {
        return enabled;
    }

    public void setEnabled(boolean flag)
    {
        if(enabled != flag)
        {
            enabled = flag;
            repaint();
        }
    }

    public boolean hasFocus()
    {
        return parent != null && parent.getFocusOwner() == this;
    }

    public void requestFocus()
    {
        if(parent != null && acceptsFocus())
            parent.setFocusOwner(this);
    }

    public boolean acceptsFocus()
    {
        return acceptsKeyFocus & visible & enabled;
    }

    public int getX()
    {
        return x;
    }

    public int getY()
    {
        return y;
    }

    public int getWidth()
    {
        return width;
    }

    public int getHeight()
    {
        return height;
    }

    public abstract int getPreferredWidth();

    public abstract int getPreferredHeight();

    protected void preferredWidthChanged()
    {
        if(rightEdgeScheme == 7)
            invalidateParent();
    }

    protected void preferredHeightChanged()
    {
        if(bottomEdgeScheme == 13)
            invalidateParent();
    }

    public abstract void paint(Graphics g);

    public void repaint()
    {
        if(parent != null && visible)
            parent.repaint(x, y - parent.scrollOffset, width, height);
    }

    public void repaint(int i, int j, int k, int l)
    {
        if(parent != null && visible)
        {
            if(i < 0)
            {
                k += i;
                i = 0;
            }
            if(j < 0)
            {
                l += j;
                j = 0;
            }
            if(k + i > width)
                k = width - i;
            if(l + j > height)
                l = height - j;
            parent.repaint(x + i, (y + j) - parent.scrollOffset, k, l);
        }
    }

    public ComponentScreen getParent()
    {
        return parent;
    }

    public void gainedFocus()
    {
        repaint();
    }

    public void lostFocus()
    {
        repaint();
    }

    protected boolean keyPressed(int i)
    {
        return false;
    }

    protected boolean keyReleased(int i)
    {
        return false;
    }

    protected boolean keyRepeated(int i)
    {
        return false;
    }

    protected void pointerDragged(int i, int j)
    {
    }

    protected void pointerPressed(int i, int j)
    {
    }

    protected void pointerReleased(int i, int j)
    {
    }

    public Component()
    {
        leftEdgeValue = 0;
        leftEdgeScheme = 0;
        rightEdgeValue = 0;
        rightEdgeScheme = 7;
        topEdgeValue = 0;
        topEdgeScheme = 11;
        bottomEdgeValue = 0;
        bottomEdgeScheme = 13;
        x = 0;
        y = 0;
        width = 0;
        height = 0;
        visible = true;
        enabled = true;
        parent = null;
        acceptsKeyFocus = false;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -