📄 buttonpane.java
字号:
package com.catking.left;
import com.catking.mainFrm.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.*;
public class ButtonPane extends Composite implements DrawConstants{
private Button[][] buttons;
private int currentAction = PEN;
private static final String[][] tips = {
{"任意形状的裁剪","选定"},
{"橡皮","用颜色填充"},
{"取色","放大镜"},
{"铅笔","刷子"},
{"喷枪","文字"},
{"直线","曲线"},
{"矩形","多边形"},
{"椭圆","圆角椭圆"}
};
public ButtonPane(Composite shell){
super(shell, SWT.BORDER);
GridLayout layout = new GridLayout(2, true);
this.buttons = new Button[8][2];
this.setLayout(layout);
for(int j=1; j<= 8; j++){
for(int i=1; i<=2; i++){
this.buttons[j-1][i-1] = new Button(this, SWT.PUSH);
this.buttons[j-1][i-1].setImage(
SourceManager.buttonsMap.get(j+String.valueOf(i)));
this.buttons[j-1][i-1].setToolTipText(tips[j-1][i-1]);
}
}
this.setSize(90, 648);
this.buttons[3][0].setFocus();
//铅笔
this.buttons[3][0].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
currentAction = PEN;
}
});
//直线
this.buttons[5][0].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
currentAction = LINE;
}
});
//矩形
this.buttons[6][0].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
currentAction = RECT;
}
});
//椭圆
this.buttons[7][0].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
currentAction = ELLIPSE;
}
});
this.buttons[1][1].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
currentAction = FILL;
}
});
}
public int getAction(){
return this.currentAction;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -