📄 sdabasecontrol.java
字号:
int clientX = x;
SDABaseControl ctrl = this;
while (ctrl != null) {
clientX -= ctrl.getLeft();
ctrl = ctrl.parent;
}
return clientX;
}
public int screenYToClient(int y) {
int clientY = y;
SDABaseControl ctrl = this;
while (ctrl != null) {
clientY -= ctrl.getTop();
ctrl = ctrl.parent;
}
return clientY;
}
public int clientXToScreen(int x) {
int clientX = x;
SDABaseControl ctrl = this.parent;
while (ctrl != null) {
clientX += ctrl.getLeft();
ctrl = ctrl.parent;
}
return clientX;
}
public int clientYToScreen(int y) {
int clientY = y;
SDABaseControl ctrl = this.parent;
while (ctrl != null) {
clientY += ctrl.getTop();
ctrl = ctrl.parent;
}
return clientY;
}
public void fillRect(Graphics g, int left, int top, int width, int height) {
g.fillRect(this.originLeft + left, this.originTop + top, width, height);
}
public void drawRect(Graphics g, int left, int top, int width, int height) {
g.drawRect(this.originLeft + left, this.originTop + top, width, height);
}
public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
g.drawLine(this.originLeft + x1, this.originTop + y1,
this.originLeft + x2, this.originTop + y2);
}
public void drawString(Graphics g, String text, int left, int top) {
g.drawString(text, this.originLeft + left, this.originTop + top, 0);
}
public void drawImage(Graphics g, Image img, int x, int y, int anchor) {
g.drawImage(img, this.originLeft + x, this.originTop + y, anchor);
}
public void drawCircle(Graphics g, double x, double y, double r,
int startAngle,
int arcAngle) {
g.drawArc((int) (this.originLeft + x - r),
(int) (this.originTop + y - r), (int) (r * 2), (int) (r * 2),
startAngle, arcAngle);
}
public void fillCircel(Graphics g, double x, double y, double r,
int startAngle,
int arcAngle) {
g.fillArc((int) (this.originLeft + x - r),
(int) (this.originTop + y - r), (int) (r * 2), (int) (r * 2),
startAngle, arcAngle);
}
public void fillTriangle(Graphics g, int x1, int y1, int x2, int y2, int x3,
int y3) {
g.fillTriangle(this.originLeft + x1, this.originTop + y1,
this.originLeft + x2, this.originTop + y2,
this.originLeft + x3, this.originTop + y3);
}
public void fillArc(Graphics g, int x, int y, int xWidth, int yHeight,
int startAngle,
int arcAngle) {
g.fillArc(this.originLeft + x - xWidth / 2,
this.originTop + y - yHeight / 2, xWidth, yHeight,
startAngle, arcAngle);
}
public void DrawDotRect(Graphics g, int left, int top, int width,
int height) {
int storkeStyle = g.getStrokeStyle();
g.setStrokeStyle(Graphics.DOTTED);
g.drawRect(this.originLeft + left, this.originTop + top, width, height);
g.setStrokeStyle(storkeStyle);
}
public void drawDotLine(Graphics g, int x1, int y1, int xWidth, int yHeight) {
g.setStrokeStyle(Graphics.DOTTED);
//画x方向
for (int i = 0; i < xWidth; i += 2) {
drawLine(g, x1 + i, y1, x1 + i + 1, y1);
}
//画y方向
for (int i = 0; i < yHeight; i += 2) {
drawLine(g, x1, y1 + i, x1, y1 + i + 1);
}
g.setStrokeStyle(Graphics.SOLID);
}
public int getForeColor() {
return foreColor;
}
public boolean isEnabled() {
return enabled;
}
public int getHeight() {
return height;
}
public int getLeft() {
return left;
}
public int getOriginLeft() {
return originLeft;
}
public int getOriginTop() {
return originTop;
}
public SDABaseControl getParent() {
return parent;
}
public int getBackColor() {
return backColor;
}
public int getTop() {
return top;
}
public boolean isVisible() {
return visible;
}
public int getWidth() {
return width;
}
public boolean isCtl3d() {
return ctl3d;
}
public Font getFont() {
return Font.getFont(this.fontFace, this.fontStyle, this.fontSize);
}
public boolean isParentFont() {
return parentFont;
}
public String getText() {
return text;
}
public int getFontFace() {
return fontFace;
}
public int getFontSize() {
return fontSize;
}
public int getFontStyle() {
return fontStyle;
}
public boolean isTransparent() {
return transparent;
}
public boolean isFoucsed() {
return this.form == null ? false : this.equals(this.form.focusControl);
}
public int getAlignment() {
return alignment;
}
public boolean isTabStop() {
return tabStop;
}
public boolean isDown() {
return down;
}
public String getName() {
return name;
}
public NotifyEvent getOnClick() {
return onClick;
}
public void setWidth(int width) {
this.width = width;
}
public void setVisible(boolean visible) {
this.visible = visible;
if (visible) {
repaintControl();
}
}
public void setTop(int top) {
this.top = top;
}
public void setBackColor(int backColor) {
this.backColor = backColor;
}
public void setParent(SDABaseControl parent) {
this.parent = parent;
}
public void setLeft(int left) {
this.left = left;
}
public void setHeight(int height) {
this.height = height;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public void setForeColor(int foreColor) {
this.foreColor = foreColor;
}
public void setCtl3d(boolean ctl3d) {
this.ctl3d = ctl3d;
}
public void setParentFont(boolean parentFont) {
this.parentFont = parentFont;
}
public void setText(String text) {
this.text = text;
repaintControl();
}
public void setFont(Font font) {
this.fontFace = font.getFace();
this.fontStyle = font.getStyle();
this.fontSize = font.getSize();
}
public void setFontStyle(int fontStyle) {
this.fontStyle = fontStyle;
}
public void setFontSize(int fontSize) {
this.fontSize = fontSize;
}
public void setFontFace(int fontFace) {
this.fontFace = fontFace;
}
public void setTransparent(boolean transparent) {
this.transparent = transparent;
}
public final boolean CanFocused() {
return this.tabStop && this.visible && this.enabled && this.form != null;
}
public final void setFoucsed() {
if (CanFocused() && !isFoucsed()) {
System.out.println("focused=" + this.getClass().getName());
SDABaseControl ctrl = this.form.focusControl;
this.form.focusControl = this;
if (ctrl != null) {
ctrl.setDown(false);
if (ctrl.isTransparent() && this.parent != null) {
this.parent.paint();
} else {
ctrl.paint();
}
if (ctrl.onInternalLostFocused != null) {
ctrl.onInternalLostFocused.Event(ctrl);
}
if (ctrl.onLostFocused != null) {
ctrl.onLostFocused.Event(ctrl);
}
}
if (this.onInternalFocused != null) {
this.onInternalFocused.Event(this);
}
if (this.onFocused != null) {
this.onFocused.Event(this);
}
this.paint();
}
}
public void setAlignment(int alignment) {
this.alignment = alignment;
}
public void setOnClick(NotifyEvent onClick) {
this.onClick = onClick;
}
public void setDown(boolean down) {
this.down = down;
this.paint();
}
public void setName(String name) {
this.name = name;
}
public boolean hasChild() {
return ctrlList.size() > 0;
}
public int getDock() {
return dock;
}
public boolean isPopVisible() {
if (this.form == null) {
return false;
}
return this.equals(this.form.popControl);
}
public void setDock(int dock) {
this.dock = dock;
}
public void setOnKeyDown(KeybordEvent onKeyDown) {
this.onKeyDown = onKeyDown;
}
public void setOnKeyPress(KeybordEvent onKeyPress) {
this.onKeyPress = onKeyPress;
}
public void setOnKeyUp(KeybordEvent onKeyUp) {
this.onKeyUp = onKeyUp;
}
public void setOnPointerDragged(PointerEvent onPointerDragged) {
this.onPointerDragged = onPointerDragged;
}
public void setOnPointerPressed(PointerEvent onPointerPressed) {
this.onPointerPressed = onPointerPressed;
}
public void setOnPointerReleased(PointerEvent onPointerReleased) {
this.onPointerReleased = onPointerReleased;
}
protected void setOriginTop(int originTop) {
this.originTop = originTop;
}
protected void setOriginLeft(int originLeft) {
this.originLeft = originLeft;
}
public void setOnLostFocused(NotifyEvent onLostFocused) {
this.onLostFocused = onLostFocused;
}
public void setOnFocused(NotifyEvent onFocused) {
this.onFocused = onFocused;
}
public void setTabStop(boolean tabStop) {
this.tabStop = tabStop;
}
public void setPopVisible() {
if (this.form != null) {
this.form.popControl = this;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -