本文整理汇总了Java中org.eclipse.swt.graphics.GC.drawRoundRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java GC.drawRoundRectangle方法的具体用法?Java GC.drawRoundRectangle怎么用?Java GC.drawRoundRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.GC
的用法示例。
在下文中一共展示了GC.drawRoundRectangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
// draw button background
int selShift = 0;
if(mouseIsOver && !isSelected){
g.setBackground(this.meColorMouseOver);
}else{
g.setBackground(this.meColorUnselected);
}
if(isSelected){
selShift = MEB_SIDE_SPACE-1;
g.setBackground(this.meColorSelected);
}
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
g.setForeground(this.meColorFocused);
}else{
g.setForeground(this.meColorOutline2);
}
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);
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
//
int usableHeight = height-4;
// draw button text
g.setForeground(this.meColorForeground);
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;
}
}
}