📄 selectablelabel.java
字号:
/*******************************************************************************
* $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/figure/SelectableLabel.java,v 1.1 2006/11/22 07:07:38 niegy Exp $
* $Revision: 1.1 $
* $Date: 2006/11/22 07:07:38 $
*
*==============================================================================
*
* Copyright (c) 2001-2006 Primeton Technologies, Ltd.
* All rights reserved.
*
* Created on 2006-11-21
*******************************************************************************/
package com.primeton.studio.gef.ui.figure;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
/**
* TODO 此处填写 class 信息
*
* @author niegy (mailto:niegy@primeton.com)
*/
/*
* 修改历史
* $Log: SelectableLabel.java,v $
* Revision 1.1 2006/11/22 07:07:38 niegy
* 增加table
*
*/
public class SelectableLabel extends Label {
private boolean selected;
private boolean hasFocus;
private Rectangle getSelectionRectangle() {
Rectangle bounds = getTextBounds();
bounds.expand(new Insets(2,2,0,0));
translateToParent(bounds);
bounds.intersect(getBounds());
return bounds;
}
/**
* @see org.eclipse.draw2d.Label#paintFigure(org.eclipse.draw2d.Graphics)
*/
protected void paintFigure(Graphics graphics) {
if (selected) {
graphics.pushState();
graphics.setBackgroundColor(ColorConstants.menuBackgroundSelected);
graphics.fillRectangle(getSelectionRectangle());
graphics.popState();
graphics.setForegroundColor(ColorConstants.white);
}
if (hasFocus) {
graphics.pushState();
graphics.setXORMode(true);
graphics.setForegroundColor(ColorConstants.menuBackgroundSelected);
graphics.setBackgroundColor(ColorConstants.white);
graphics.drawFocus(getSelectionRectangle().resize(-1, -1));
graphics.popState();
}
super.paintFigure(graphics);
}
/**
* Sets the selection state of this SimpleActivityLabel
* @param b true will cause the label to appear selected
*/
public void setSelected(boolean b) {
if (selected != b) {
selected = b;
repaint();
}
}
/**
* Sets the focus state of this SimpleActivityLabel
* @param b true will cause a focus rectangle to be drawn around the text of the Label
*/
public void setFocus(boolean b) {
if (hasFocus != b) {
hasFocus = b;
repaint();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -