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

📄 sdaform.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }
        }
        if (this.equals(Application.getFoucsedForm())) {
            this.serviceRepaints();
        }
    }

    protected final void keyReleased(int keyCode) {
        String keyName = getKeyName(keyCode).toUpperCase();
        Object hotKeyEvent = hotKeyList.get(keyName);
        if (hotKeyEvent != null) {
            ((HotKeyEvent) hotKeyEvent).Event(keyName);
            inputAbort = true;
        }

        if (inputAbort) {
            return;
        }
        if (popControl != null) {
            if (popControl.onKeyUp != null) {
                popControl.onKeyUp.Event(popControl, keyCode);
                if (popControl != null) {
                    popControl.paint();
                }
            }
        } else {
            if (focusControl == null ||
                    (keyName.equals(SDAConsts.KEY_UP) && focusControl.canUpTabPrior()) ||
                    (keyName.equals(SDAConsts.KEY_LEFT) &&
                    focusControl.canLeftTabPrior())) {
                this.PriorTabOrder();
                operateControl = null;
            }
            if (focusControl == null ||
                    (keyName.equals(SDAConsts.KEY_DOWN) &&
                    focusControl.canDownTabNext()) ||
                    (keyName.equals(SDAConsts.KEY_RIGHT) &&
                    focusControl.canRightTabNext())) {
                this.NextTabOrder();
                operateControl = null;
            }
            if (operateControl != null) {
                if (operateControl.onKeyUp != null) {
                    operateControl.onKeyUp.Event(operateControl, keyCode);
                }
                if (keyName.equals(SDAConsts.KEY_SELECT) ||
                        keyName.equals(SDAConsts.KEY_ENTER)) {
                    operateControl.Click();
                }
            }
        }

        if (this.equals(Application.getFoucsedForm())) {
            this.serviceRepaints();
        }
    }

    protected void InternalShow() {
        this.onShow();
        inputAbort = true;
        this.visible = true;
        this.operateControl = null;
        Application.ShowForm(this);
    }

    public void Show() {
        setInputPanel(Application.inputPanel);
        InternalShow();
    }

    public void Close() {
        if (!this.onCloseQuery()) {
            return;
        }
        this.onClose();
        inputAbort = true;
        this.visible = false;
        this.focusControl = null;
        Application.CloseForm(this);
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    protected void setInputAbort(boolean inputAbort) {
        this.inputAbort = inputAbort;
    }

    public void setInputPanel(SDAInputPanel inputPanel) {
        if (this.inputPanel == null) {
            this.inputPanel = inputPanel;
            this.AddControl(this.inputPanel);
            AddControl(inputPanel.charsPanel);
        } else {
            this.inputPanel.parent = this;
            this.inputPanel.form = this;
            this.inputPanel.charsPanel.parent = this;
            this.inputPanel.charsPanel.form = this;
        }
    }

    public boolean isShowCaption() {
        return this.formCatpion.visible;
    }

    public void setShowCaption(boolean showCaption) {
        this.formCatpion.visible = showCaption;
    }

    public Graphics getGraphics() {
        return graphics;
    }

    public SDABaseControl getOperateControl() {
        return operateControl;
    }

    public void registerHotKey(String keyName, HotKeyEvent enent) {
        hotKeyList.put(keyName, enent);
    }

    private class SDAFormCaption extends SDABaseControl {

        public SDAFormCaption() {
            this.height = getFont().getHeight() + 2;
            this.width = 100;
            this.tabStop = false;
            backColor = SDAConsts.clActiveCaption;
            foreColor = SDAConsts.clWhite;
            setOnPointerPressed(new PointerEvent() {

                public void Event(SDABaseControl ctrl, int x, int y) {
                    doPointerPressed(x, y);
                }
            });
        }

        private final void DrawCaption() {
            graphics.setColor(backColor);
            fillRect(graphics, 0, 0, this.width, this.height);
            //背景
            if (captionBackImage != null) {
                Image img = SDAImageUtils.processImage(captionBackImage, width,
                        height, SDAImageUtils.MODE_STRETCH);
                drawImage(graphics, img, 0, 0, 0);
            }
            //图标
            if (captionIcon != null) {
                drawImage(graphics, captionIcon, 2,
                        (height - captionIcon.getHeight()) / 2, 0);
            }
            //字体
            graphics.setColor(foreColor);
            graphics.setFont(getFont());
            int leftPos = 0;
            if (captionAlignType == SDAConsts.alignLeft) {
                leftPos = 2 + (captionIcon != null ? getFont().getHeight() : 0);
            }
            if (captionAlignType == SDAConsts.alignCenter) {
                leftPos = (width - getFont().stringWidth(caption)) / 2;
            }
            if (captionAlignType == SDAConsts.alignRight) {
                leftPos = width - getFont().stringWidth(caption) - height - 1;
            }
            drawString(graphics, this.form.caption, leftPos, 1);
            //关闭按钮
            graphics.setColor(foreColor);
            drawRect(graphics, width - 4 * height / 5 - 1, height / 5 - 1,
                    3 * height / 5, 3 * height / 5);
            //画叉
            drawLine(graphics, width - 4 * height / 5 - 1, height / 5 - 1,
                    width - height / 5 - 1, 4 * height / 5 - 1);
            drawLine(graphics, width - 4 * height / 5 - 1, 4 * height / 5 - 1,
                    width - height / 5 - 1, height / 5 - 1);
        }

        public void paint() {
            if (IsCanPaint()) {
                SetClip(graphics, 0, 0, this.width, this.height);
                DrawCaption();
            }
        }

        private void doPointerPressed(int x, int y) {
            int posx = screenXToClient(x);
            int posy = screenYToClient(y);
            if (InClientRect(posx, posy, width - height, 0, height, height)) {
                //关闭
                form.Close();
            }
        }
    }

    private class SDAFormContainer extends SDABaseControl {

        public SDAFormContainer() {
            this.setLeft(0);
            this.setTop(0);
        }

        public void paint() {
            if (IsCanPaint()) {
                SetClip(this.form.graphics, 0, 0, this.width, this.height);
                this.form.graphics.setColor(SDAConsts.clBtnShadow);
                drawRect(this.form.graphics, 0, 0, this.width - 1,
                        this.height - 1);
                setChildsLayout();
            //画主菜单

            }
        }
    }

    public int getCaptionAlignType() {
        return captionAlignType;
    }

    public void setCaptionAlignType(int captionAlignType) {
        this.captionAlignType = captionAlignType;
    }

    public Image getCaptionBackImage() {
        return captionBackImage;
    }

    public void setCaptionBackImage(Image captionBackImage) {
        this.captionBackImage = captionBackImage;
    }

    public Image getCaptionIcon() {
        return captionIcon;
    }

    public void setCaptionIcon(Image captionIcon) {
        this.captionIcon = captionIcon;
    }

    public boolean isShowCloseButton() {
        return showCloseButton;
    }

    public void setShowCloseButton(boolean showCloseButton) {
        this.showCloseButton = showCloseButton;
    }

    protected void onShow() {

    }

    protected boolean onCloseQuery() {
        return true;
    }

    protected void onClose() {

    }

    public SDAMainMenu getMainMemu() {
        return mainMemu;
    }

    public void setMainMemu(SDAMainMenu mainMemu) {
        if (this.mainMemu != null) {
            RemoveControl(this.mainMemu);
            this.mainMemu = null;
        }
        if (mainMemu != null) {
            this.mainMemu = mainMemu;
            if (!ctrlList.contains(mainMemu)) {
                ctrlList.addElement(mainMemu);
                mainMemu.parent = this;
                mainMemu.SetForm(this);
            }
        }
    }
}

⌨️ 快捷键说明

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