本文整理汇总了Java中org.eclipse.swt.widgets.Caret类的典型用法代码示例。如果您正苦于以下问题:Java Caret类的具体用法?Java Caret怎么用?Java Caret使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Caret类属于org.eclipse.swt.widgets包,在下文中一共展示了Caret类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getShell
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent a
* SWT object that manage a shell, <code>null</code> is returned.
*
* @param widget
* the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例2: getShell
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
* <code>null</code> is returned.
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget)
{
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例3: getShell
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent
* a SWT object that manage a shell, <code>null</code> is returned.
* @param widget the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
return ((Control)widget).getShell();
if (widget instanceof Caret)
return ((Caret)widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource)widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget)widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu)widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar)widget).getParent().getShell();
return null;
}
示例4: getShell
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent
* a SWT object that manage a shell, <code>null</code> is returned.
* @param widget the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control) {
return ((Control) widget).getShell();
}
if (widget instanceof Caret) {
return ((Caret) widget).getParent().getShell();
}
if (widget instanceof DragSource) {
return ((DragSource) widget).getControl().getShell();
}
if (widget instanceof DropTarget) {
return ((DropTarget) widget).getControl().getShell();
}
if (widget instanceof Menu) {
return ((Menu) widget).getParent().getShell();
}
if (widget instanceof ScrollBar) {
return ((ScrollBar) widget).getParent().getShell();
}
return null;
}
示例5: GridCopyEnable
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* @param gridTable
*/
public GridCopyEnable(Grid gridTable) {
Assert.isNotNull(gridTable);
this.gridTable = gridTable;
defaultCaret = new Caret(gridTable, SWT.NONE);
clipboard = new Clipboard(gridTable.getDisplay());
this.gridTable.setCaret(defaultCaret);
this.gridTable.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
initListener();
}
示例6: getPoint
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
public static Point getPoint(Caret c) {
Point p = new Point(c.getBounds().x + 46, c.getBounds().y
+ c.getBounds().height + 51);
Control control = c.getParent();
while (control.getParent() != null) {
control = control.getParent();
p.x += control.getBounds().x;
p.y += control.getBounds().y;
}
return p;
}
示例7: windowAlwaysInScreen
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* ��ֹ���ڳ�����Ļ
* �˷����������ձ��ԣ�����black�����ijЩShell�������
* @param location ����λ�õ�
* @param shell ��ҪУ��Shell����
* @param addvalue �ڻ���λ�õ�location֮�ϵ����긽��ֵ������Ϊnull
*
*/
public static Point windowAlwaysInScreen(Point location,Shell parent, Shell shell,Caret caret){
int newX = 0,newY = 0;
int width = 0, height = 0;
int lineheightatcaretoffset = (int)caret.getData();
int caretsizeX = 0,caretsizeY =0;
if(caret != null){
caretsizeX = caret.getSize().x;
caretsizeY = caret.getSize().y;
}
if(parent != null){
width = returnScreenWidth();
//width = parent.getSize().x;
height = parent.getSize().y;
}else{
width = returnScreenWidth();
height = returnScreenHeight();
}
int locationX = location.x;
int locationY = location.y;
int sizeX = shell.getSize().x;
int sizeY = shell.getSize().y;
if(locationX <= 0){
newX = 0;
}
if(locationX+sizeX+caretsizeX >= width){
newX = width-sizeX;
}
if(locationY <= 0){
newY = 0;
}
if(locationY+sizeY+caretsizeY >= height){
if(caret.getStyle() == SWT.VERTICAL)
newY = locationY-sizeY;
else newY = locationY-sizeY-lineheightatcaretoffset;
}
if(newX == 0) newX = locationX;
if(newY == 0) {
if(caret.getStyle() == SWT.VERTICAL)
newY = locationY+caretsizeY;
else newY = locationY+caret.getSize().y;
}
shell.setLocation(newX, newY);
return new Point(newX,newY);
}
示例8: CheckForUpdates
import org.eclipse.swt.widgets.Caret; //导入依赖的package包/类
/**
* Create the composite.
*
* @param parent
* @param style
*/
public CheckForUpdates(Composite parent, int style) {
super(parent, style);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 0;
setLayout(gridLayout);
setVisible(false);
txtStatus = new StyledText(this, SWT.WRAP);
txtStatus.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
txtStatus.setEditable(false);
txtStatus.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
txtStatus.setBackground(getBackground());
txtStatus.setFont(FontSize.getThisFontInNewSize(txtStatus.getFont(), 10, SWT.NORMAL));
txtStatus.addMouseListener(mouseHandler);
txtStatus.setCaret(new Caret(txtStatus, SWT.NONE));
setText("Rel updates?");
updateChecker = new UpdatesCheck(parent.getDisplay()) {
@Override
public void completed(SendStatus sendStatus) {
CheckForUpdates.this.completed(sendStatus);
}
};
TimerTask checkForUpdates = new TimerTask() {
@Override
public void run() {
if (CheckForUpdates.this.isDisposed())
return;
getDisplay().asyncExec(() -> {
if (CheckForUpdates.this.isDisposed())
return;
setVisible(true);
setText("Rel updates?");
System.out.println("CheckForUpdates: check for updates.");
updateChecker.doCancel();
updateChecker.doSend();
});
}
};
// Check for updates after 10 seconds, then every 12 hours
Timer checkTimer = new Timer();
checkTimer.schedule(checkForUpdates, 1000 * 5, 1000 * 60 * 60 * 12);
}