import org.eclipse.swt.graphics.GC; //導入方法依賴的package包/類
void paintElement(PaintEvent e) {
GC g = e.gc;
graphics java?g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
java中gc是什么、g.fillRectangle(0, 0, width, height);
// draw button background
int selShift = 0;
if(mouseIsOver && !isSelected){
java頂級容器?g.setBackground(this.meColorMouseOver);
}else{
g.setBackground(this.meColorUnselected);
}
drawImage,if(isSelected){
selShift = MEB_SIDE_SPACE-1;
g.setBackground(this.meColorSelected);
}
java decompiler?g.fillRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
// draw button outline
g.setLineWidth(1);
if(mouseIsOver){ // || isFocused, but not currently used
java abstract。g.setForeground(this.meColorFocused);
}else{
g.setForeground(this.meColorOutline2);
}
java.awt?g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1), height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-1, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-2, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.setForeground(this.meColorOutline);
java gc算法,g.setLineWidth(1);
g.drawRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
//
// handle position of Text/Icon within MEButton
java的gc機制,//
int usableHeight = height-4;
// draw button text
g.setForeground(this.meColorForeground);
java輸入。FontData fd = new FontData();
fd.setHeight(8);
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
switch(this.meDispOptions){
case(MenuetElement.ME_ICON_ONLY): {
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
break;
}
case(MenuetElement.ME_TEXT_ONLY): {
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
case(MenuetElement.ME_TRY_ICON): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
}
break;
}
case(MenuetElement.ME_TRY_TEXT):{
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
}
break;
}
default:{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
}
}
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态