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

📄 sdabaseedit.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    if (keyCode > 47 && keyCode < 58) {                        form.Application.inputPanel.selectedHanziIndex = Integer.parseInt(String.valueOf(ch)) - 1;                        if (!form.Application.inputPanel.charsPanel.getHanziByIndex()) {                            form.Application.inputPanel.numChars = null;                            form.Application.inputPanel.charsPanel.visible = false;                            form.Application.inputPanel.inputChars.setLength(0);                            form.Application.inputPanel.hanziChars = null;                            form.repaintControl();                        }                        return;                    }                }            }            if (form.Application.inputPanel.ImeType == SDAInputPanel.imLowerCase) {                charArray = form.Application.inputPanel.getLowerKeyChars(ch);            }            if (form.Application.inputPanel.ImeType == SDAInputPanel.imUpperCase) {                charArray = form.Application.inputPanel.getUpperKeyChars(ch);            }            if (charArray != null) {                form.Application.inputPanel.numChars = charArray;                form.Application.inputPanel.setCharsPanelPos();                form.Application.inputPanel.charsPanel.visible = true;                form.Application.inputPanel.charsPanel.repaintControl();            } else {                if (form.Application.inputPanel.charsPanel.visible) {                    form.Application.inputPanel.numChars = null;                    form.Application.inputPanel.charsPanel.visible = false;                    form.repaintControl();                }                inputVisibleChar(ch);            }        }    }    //向前删除    private void backDeleteChar() {        strBuffer.setLength(0);        strBuffer.append(getText());        if (cursorCol > 0) {            cursorCol--;            if (cursorLineStartPos + cursorCol < strBuffer.length()) {                strBuffer.deleteCharAt(cursorLineStartPos + cursorCol);                setText(strBuffer.toString());                doTextChange();            }            if (cursorCol == 0) {                if (cursorRow > lineNum - 1) {                    cursorRow = lineNum - 1;                    paintString(gg, getText(), 2, -100);                    cursorCol = cursorLineText.length();                }            }        } else {            //System.out.println(cursorLineStartPos);            if (strBuffer.length() > 0 && cursorLineStartPos > 0 &&                    (strBuffer.charAt(cursorLineStartPos - 1) == '\n' || strBuffer.charAt(cursorLineStartPos - 1) == '\r')) {                strBuffer.deleteCharAt(cursorLineStartPos - 1);                if (cursorRow > 0) {                    cursorRow--;                    cursorCol = priorLineLen;                    setText(strBuffer.toString());                    doTextChange();                    if (cursorCol < 0) {                        cursorCol = 0;                    }                }            } else if (cursorRow > 0) {                cursorRow--;                paintString(gg, getText(), 2, -100);                cursorCol = cursorLineText.length();            }        }    }    //向后删除    private void deleteChar() {        strBuffer.setLength(0);        strBuffer.append(getText());        if (cursorCol < cursorLineText.length()) {            strBuffer.deleteCharAt(cursorLineStartPos + cursorCol);            setText(strBuffer.toString());            doTextChange();        } else {            if (cursorLineStartPos + cursorCol < strBuffer.length()) {                strBuffer.deleteCharAt(cursorLineStartPos + cursorCol);                setText(strBuffer.toString());                doTextChange();            }        }    }    //输入内容    public void InputVisibleString(String inString) {        inputVisibleString(inString);    }    protected void inputVisibleString(String inString) {        if (readOnly) {            return;        }        strBuffer.setLength(0);        strBuffer.append(getText());        strBuffer.insert(cursorLineStartPos + cursorCol, inString);        cursorCol += inString.length();        setText(strBuffer.toString());        doTextChange();        setCursorVisible();    }    public void InputVisibleChar(char inChar) {        inputVisibleChar(inChar);    }    protected void inputVisibleChar(char inChar) {        if (readOnly) {            return;        }        strBuffer.setLength(0);        strBuffer.append(getText());        if (cursorLineStartPos + cursorCol > -1 && cursorLineStartPos + cursorCol < strBuffer.length() + 1) {            strBuffer.insert(cursorLineStartPos + cursorCol, inChar);            cursorCol += 1;        } else {            cursorCol = strBuffer.length() + 1 - cursorLineStartPos;        }        setText(strBuffer.toString());        doTextChange();        setCursorVisible();    }    public void InputFuncChar(char inChar, boolean sbc) {        inputFuncChar(inChar, sbc);    }    protected void inputFuncChar(char inChar, boolean sbc) {        //左        if (inChar == 37) {            if (cursorCol > 0) {                cursorCol--;            } else {                if (cursorRow > 0) {                    cursorRow--;                    paintString(gg, getText(), 2, -100);                    cursorCol = cursorLineText.length();                }            }        }        //上        if (inChar == 38) {            if (cursorRow > 0) {                cursorRow--;            }        }        //右        if (inChar == 39) {            if (cursorCol < cursorLineText.length()) {                cursorCol++;            } else {                if (cursorRow < lineNum - 1) {                    cursorRow++;                    paintString(gg, getText(), 2, -100);                    cursorCol = 0;                }            }        }        //下        if (inChar == 40) {            if (cursorRow < lineNum - 1) {                cursorRow++;            }        }        //删除        if (inChar == 46) {            if (!readOnly) {                deleteChar();            }        }        //退格        if (inChar == 8) {            if (!readOnly) {                backDeleteChar();            }        }        //回车        if (inChar == 13) {            if (!isMultiLine()) {                return;            }            //全角半角            if (!readOnly) {                if (cursorCol > 0) {                    if (!sbc) {                        inputVisibleString("\n  ");                    } else {                        inputVisibleString("\n  ");                    }                    cursorCol = 2;                } else {                    inputVisibleString("\n");                    cursorCol = 0;                }                cursorRow++;            }        }        //空格        if (inChar == ' ' || inChar == ' ') {            if (!readOnly) {                inputVisibleChar(inChar);            }        }        setCursorVisible();    }    //获取当前行    public int getCursorRow() {        return cursorRow;    }    //获取当前列    public int getCursorCol() {        return cursorCol;    }    //获取当前位置    public int getCursorX() {        Font ft = getFont();        if (isMultiLine()) {            cursorX = getOriginLeft() + ft.stringWidth(cursorLineText.substring(0, cursorCol)) - startLeft;        } else {            cursorX = getOriginLeft() + ft.stringWidth(getText().substring(0, cursorCol)) - startLeft;        }        return cursorX;    }    public int getCursorY() {        cursorY = getOriginTop() + (cursorRow - startLine) * getFont().getHeight();        return cursorY;    }    //如果当前行不可见,设置为可见区域(startLine,startLeft)    protected void setCursorVisible() {        Font ft = getFont();        if (isMultiLine()) {            //行            if (cursorRow < startLine) {                startLine = cursorRow;            }            if (cursorRow > startLine + getMaxVisibleLineNum() - 1) {                startLine = cursorRow - getMaxVisibleLineNum() + 1;            }        }        //列        int leftWidth = 0;        int tp = 0;        leftWidth = ft.stringWidth(cursorLineText.substring(0, cursorCol));        tp = cursorCol < cursorLineText.length() ? ft.charWidth(cursorLineText.charAt(cursorCol)) : 0;        if (leftWidth - startLeft + tp > width) {            startLeft += width / 3;            if (startLeft + width - 6 > ft.stringWidth(cursorLineText)) {                startLeft = ft.stringWidth(cursorLineText) - width + 6;            }        } else if (ft.stringWidth(cursorLineText) < startLeft + width) {            startLeft = ft.stringWidth(cursorLineText) - width;            if (startLeft < 0) {                startLeft = 0;            }        }        if (leftWidth < startLeft) {            startLeft -= width / 3;            if (startLeft < 0) {                startLeft = 0;            }        }        repaintControl();    }    protected boolean canDownTabNext() {        boolean result = true;        if (form.Application.inputPanel.charsPanel.isVisible()) {            result = false;        }        if (cursorRow < lineNum - 1) {            result = false;        }        return result;    }    //焦点方法处理    protected boolean canLeftTabPrior() {        boolean result = true;        if (form.Application.inputPanel.charsPanel.isVisible()) {            result = false;        }        if (cursorRow > 0 || cursorCol > 0) {            result = false;        }        return result;    }    protected boolean canRightTabNext() {        boolean result = true;        if (form.Application.inputPanel.charsPanel.isVisible()) {            result = false;        }        if (cursorCol < cursorLineText.length() || cursorRow < lineNum - 1) {            result = false;        }        return result;    }    protected boolean canUpTabPrior() {        boolean result = true;        if (form.Application.inputPanel.charsPanel.isVisible()) {            result = false;        }        if (cursorRow > 0) {            result = false;        }        return result;    }    //焦点处理    private void doLostFocus() {        //对齐方式        textAlign = oldAlignType;        if (form.Application.inputPanel.charsPanel.visible) {            form.Application.inputPanel.numChars = null;            form.Application.inputPanel.charsPanel.visible = false;            form.Application.inputPanel.inputChars.setLength(0);            form.Application.inputPanel.hanziChars = null;            form.repaintControl();        } else {            repaintControl();        }    }    private void doGetFocus() {        //对齐方式(编辑状态左对齐)        oldAlignType = textAlign;        textAlign = SDAConsts.alignLeft;        //输入法        if (imeType != SDAInputPanel.imNone) {            form.Application.inputPanel.setImeType(imeType);            if (form.Application.inputPanel.visible) {                form.repaintControl();            } else {                if (form.getMainMemu() != null) {                    form.getMainMemu().repaintControl();                }            }        } else {            repaintControl();        }    }    //输入法    public int getImeType() {        return imeType;    }    public void setImeType(int imeType) {        this.imeType = imeType;    }    //文字变动    public void setOnTextChange(BaseEditTextChangeEvent onTextChange) {        this.onTextChange = onTextChange;    }    private void doTextChange() {        if (onTextChange != null) {            onTextChange.Event(this);        }    }}

⌨️ 快捷键说明

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