📄 sdainputpanel.java
字号:
return (char[]) (hashLowerKeyChars.get(String.valueOf(ch))); } protected char[] getUpperKeyChars(char ch) { charIndex = 0; return (char[]) (hashUpperKeyChars.get(String.valueOf(ch))); } protected char getKeyChar() { char ch = 0; if (numChars != null) { ch = numChars[charIndex]; charIndex = 0; } return ch; } public void paint() { if (!IsCanPaint()) { charsPanel.paint(); return; } Graphics g = form.getGraphics(); gg = g; form.AddControl(charsPanel); g.setFont(getFont()); SetClip(g); //画框 g.setColor(backColor); fillRect(g, 0, 0, width - 1, height - 1); g.setColor(borderColor); drawRect(g, 0, 0, width - 1, height - 1); if (ImeType != imNone) { paintInputPanel(g); } //判断是否是Bseedit组件 if (form.focusControl instanceof InputInterface) { //输入内容的选择框 if (inputChars.length() > 0 || (numChars != null && numChars.length > 0)) { paintInputChars(); } } else { inputChars.setLength(0); } } //根据不同的输入法画面板 private void paintInputPanel(Graphics g) { curHeight = 0; if (ImeType == imUpperCase) { //功能键 paintFunctionKey(g); //大写 paintUpperCase(g); //输入法选择 paintInputMethodSelect(g); } if (ImeType == imLowerCase) { //功能键 paintFunctionKey(g); //小写 paintLowerCase(g); //输入法选择 paintInputMethodSelect(g); } if (ImeType == imPinYin) { //功能键 paintFunctionKey(g); //小写 paintLowerCase(g); //输入法选择 paintInputMethodSelect(g); } if (ImeType == imDigit) { //功能键 paintFunctionKey(g); //数字 paintDigit(g); //输入法选择 paintInputMethodSelect(g); } if (ImeType == imSymbol) { //功能键 paintFunctionKey(g); //符号 paintSymbol(g); //输入法选择 paintInputMethodSelect(g); } if (ImeType == imPoint) { //功能键 paintFunctionKey(g); //标点 paintPoint(g); //输入法选择 paintInputMethodSelect(g); } } //计算输入法外框尺寸 public void setInputPanelSize() { //width = form.width; if (ImeType == imLowerCase || ImeType == imUpperCase || ImeType == imPinYin | ImeType == imPoint || ImeType == imSymbol) { height = getFont().getHeight() * 4; } if (ImeType == imDigit) { height = getFont().getHeight() * 3; } } public int getBorderColor() { return borderColor; } public void setBorderColor(int borderColor) { this.borderColor = borderColor; } public int getImeType() { return ImeType; } public void setImeType(int ImeType) { this.ImeType = ImeType; setInputPanelSize(); } public int getSelectedBackColor() { return selectedBackColor; } public void setSelectedBackColor(int selectedBackColor) { this.selectedBackColor = selectedBackColor; } public int getSelectedForeColor() { return selectedForeColor; } public void setSelectedForeColor(int selectedForeColor) { this.selectedForeColor = selectedForeColor; }//非触摸屏的不可见 public void setVisible(boolean visible) { if (form != null) { if (form.Application.hasPointer() && visible) { super.setVisible(true); } else { super.setVisible(false); } form.paint(); } else { super.setVisible(visible); } } public boolean isVisible() { boolean result = false; if (form != null) { if (form.Application.hasPointer()) { result = super.isVisible(); } else { result = false; } } return result; }//功能键 private void paintFunctionKey(Graphics g) { g.setColor(borderColor); drawRect(g, 0, 0, width - 1, getFont().getHeight()); int fontHeight = getFont().getHeight(); Font ft = getFont(); int[] rightPos = new int[9]; //画具体功能(Esc,tab,space,backSpace,enter,del,left,top,right,down) for (int i = 1; i < 10; i++) { drawLine(g, i * width / 10, curHeight, i * width / 10, curHeight + fontHeight); rightPos[i - 1] = i * width / 10; } if (charYPos == 0 && charXPos == 0) { g.setColor(selectedBackColor); fillRect(g, 1, curHeight + 1, rightPos[0] - 1, fontHeight - 1); g.setColor(selectedForeColor); //ESC selectedChar = 27; } else { g.setColor(foreColor); } drawString(g, "Esc", (width / 10 - ft.stringWidth("Esc")) / 2, curHeight); if (charYPos == 0 && charXPos == 1) { g.setColor(selectedBackColor); fillRect(g, width / 10 + 1, curHeight + 1, rightPos[1] - width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); //Tab selectedChar = 9; } else { g.setColor(foreColor); } drawLine(g, width / 10 + width / 10 / 4, curHeight + fontHeight / 2, width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2); drawLine(g, width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2 - 4, width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2 + 4); fillTriangle(g, width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2, width / 10 + 3 * width / 10 / 4 - 4, curHeight + fontHeight / 2 - 4, width / 10 + 3 * width / 10 / 4 - 4, curHeight + fontHeight / 2 + 4); //空格 if (charYPos == 0 && charXPos == 2) { g.setColor(selectedBackColor); fillRect(g, 2 * width / 10 + 1, curHeight + 1, rightPos[2] - 2 * width / 10 - 1, fontHeight - 1); if (!SBCCase) { selectedChar = ' '; } else { selectedChar = ' '; } } //← if (charYPos == 0 && charXPos == 3) { g.setColor(selectedBackColor); fillRect(g, 3 * width / 10 + 1, curHeight + 1, rightPos[3] - 3 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 37; } else { g.setColor(foreColor); } drawString(g, "←", 3 * width / 10 + (width / 10 - ft.stringWidth("←")) / 2, curHeight); /* drawLine(g, 3 * width / 10 + width / 10 / 4, curHeight + fontHeight / 2, 3 * width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2); fillTriangle(g, 3 * width / 10 + width / 10 / 4, curHeight + fontHeight / 2, 3 * width / 10 + width / 10 / 4 + 4, curHeight + fontHeight / 2 - 4, 3 * width / 10 + width / 10 / 4 + 4, curHeight + fontHeight / 2 + 4); */ //↑ if (charYPos == 0 && charXPos == 4) { g.setColor(selectedBackColor); fillRect(g, 4 * width / 10 + 1, curHeight + 1, rightPos[4] - 4 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 38; } else { g.setColor(foreColor); } drawString(g, "↑", 4 * width / 10 + (width / 10 - ft.stringWidth("↑")) / 2, curHeight); /* drawLine(g, 4 * width / 10 + width / 10 / 2, curHeight + fontHeight / 4, 4 * width / 10 + width / 10 / 2, curHeight + 3 * fontHeight / 4); fillTriangle(g, 4 * width / 10 + width / 10 / 2, curHeight + fontHeight / 4, 4 * width / 10 + width / 10 / 2 - 4, curHeight + fontHeight / 4 + 4, 4 * width / 10 + width / 10 / 2 + 4, curHeight + fontHeight / 4 + 4); */ //↓ if (charYPos == 0 && charXPos == 5) { g.setColor(selectedBackColor); fillRect(g, 5 * width / 10 + 1, curHeight + 1, rightPos[5] - 5 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 40; } else { g.setColor(foreColor); } drawString(g, "↓", 5 * width / 10 + (width / 10 - ft.stringWidth("↓")) / 2, curHeight); /* drawLine(g, 5 * width / 10 + width / 10 / 2, curHeight + fontHeight / 4, 5 * width / 10 + width / 10 / 2, curHeight + 3 * fontHeight / 4); fillTriangle(g, 5 * width / 10 + width / 10 / 2, curHeight + 3 * fontHeight / 4 , 5 * width / 10 + width / 10 / 2 - 4, curHeight + 3 * fontHeight / 4 - 4, 5 * width / 10 + width / 10 / 2 + 4, curHeight + 3 * fontHeight / 4 - 4); */ //→ if (charYPos == 0 && charXPos == 6) { g.setColor(selectedBackColor); fillRect(g, 6 * width / 10 + 1, curHeight + 1, rightPos[6] - 6 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 39; } else { g.setColor(foreColor); } drawString(g, "→", 6 * width / 10 + (width / 10 - ft.stringWidth("→")) / 2, curHeight); /* drawLine(g, 6 * width / 10 + width / 10 / 4, curHeight + fontHeight / 2, 6 * width / 10 + 3 * width / 10 / 4, curHeight + fontHeight / 2); fillTriangle(g, 6 * width / 10 + 3 * width / 10 / 4 + 1, curHeight + fontHeight / 2, 6 * width / 10 + 3 * width / 10 / 4 - 3, curHeight + fontHeight / 2 - 4, 6 * width / 10 + 3 * width / 10 / 4 - 3, curHeight + fontHeight / 2 + 4); */ if (charYPos == 0 && charXPos == 7) { g.setColor(selectedBackColor); fillRect(g, 7 * width / 10 + 1, curHeight + 1, rightPos[7] - 7 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 46; } else { g.setColor(foreColor); } drawString(g, "Del", 7 * width / 10 + (width / 10 - ft.stringWidth("Del")) / 2, curHeight); //退格 if (charYPos == 0 && charXPos == 8) { g.setColor(selectedBackColor); fillRect(g, 8 * width / 10 + 1, curHeight + 1, rightPos[8] - 8 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor); selectedChar = 8; } else { g.setColor(foreColor); } fillRect(g, 8 * width / 10 + width / 10 / 4 + 4, curHeight + fontHeight / 2 - 1, width / 10 / 3, 3); fillTriangle(g, 8 * width / 10 + width / 10 / 4, curHeight + fontHeight / 2, 8 * width / 10 + width / 10 / 4 + 5, curHeight + fontHeight / 2 - 5, 8 * width / 10 + width / 10 / 4 + 5, curHeight + fontHeight / 2 + 5); //回车 if (charYPos == 0 && charXPos == 9) { g.setColor(selectedBackColor); fillRect(g, 9 * width / 10 + 1, curHeight + 1, width - 9 * width / 10 - 1, fontHeight - 1); g.setColor(selectedForeColor);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -