⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caret.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	image = null;	font = null;	oldFont = null;}void resize () {	resized = false;	int hwnd = parent.handle;	OS.DestroyCaret ();			int hBitmap = image != null ? image.handle : 0;	OS.CreateCaret (hwnd, hBitmap, width, height);	OS.SetCaretPos (x, y);	OS.ShowCaret (hwnd);	move ();}void restoreIMEFont () {	if (!OS.IsDBLocale) return;	if (oldFont == null) return;	int hwnd = parent.handle;	int hIMC = OS.ImmGetContext (hwnd);	OS.ImmSetCompositionFont (hIMC, oldFont);	OS.ImmReleaseContext (hwnd, hIMC);	oldFont = null;}void saveIMEFont () {	if (!OS.IsDBLocale) return;	if (oldFont != null) return;	int hwnd = parent.handle;	int hIMC = OS.ImmGetContext (hwnd);	oldFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA ();	if (OS.ImmGetCompositionFont (hIMC, oldFont)) oldFont = null;	OS.ImmReleaseContext (hwnd, hIMC);}/** * Sets the receiver's size and location to the rectangular * area specified by the arguments. The <code>x</code> and  * <code>y</code> arguments are relative to the receiver's * parent (or its display if its parent is null). * * @param x the new x coordinate for the receiver * @param y the new y coordinate for the receiver * @param width the new width for the receiver * @param height the new height for the receiver * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setBounds (int x, int y, int width, int height) {	checkWidget();	boolean samePosition = this.x == x && this.y == y;	boolean sameExtent = this.width == width && this.height == height;	if (samePosition && sameExtent) return;	this.x = x;  this.y = y;	this.width = width;  this.height = height;	if (sameExtent) {		moved = true;		if (isVisible && hasFocus ()) move ();	} else {		resized = true;		if (isVisible && hasFocus ()) resize ();	}}/** * Sets the receiver's size and location to the rectangular * area specified by the argument. The <code>x</code> and  * <code>y</code> fields of the rectangle are relative to * the receiver's parent (or its display if its parent is null). * * @param rect the new bounds for the receiver * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setBounds (Rectangle rect) {	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);	setBounds (rect.x, rect.y, rect.width, rect.height);}void setFocus () {	int hwnd = parent.handle;	int hBitmap = 0;	if (image != null) hBitmap = image.handle;	OS.CreateCaret (hwnd, hBitmap, width, height);	move ();	if (font != null) {		int hFont = font.handle;		saveIMEFont ();		setIMEFont (hFont);	}	if (isVisible) OS.ShowCaret (hwnd);}/** * Sets the font that the receiver will use to paint textual information * to the font specified by the argument, or to the default font for that * kind of control if the argument is null. * * @param font the new font (or null) * * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li> * </ul>  * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setFont (Font font) {	checkWidget();	if (font != null && font.isDisposed ()) {		error (SWT.ERROR_INVALID_ARGUMENT);	}	this.font = font;	if (isVisible && hasFocus ()) {		int hFont = 0;		if (font != null) hFont = font.handle;		if (hFont == 0) hFont = defaultFont ();		saveIMEFont ();		setIMEFont (hFont);	}}/** * Sets the image that the receiver will use to paint the caret * to the image specified by the argument, or to the default * which is a filled rectangle if the argument is null * * @param image the new image (or null) * * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> * </ul>  * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setImage (Image image) {	checkWidget();	if (image != null && image.isDisposed ()) {		error (SWT.ERROR_INVALID_ARGUMENT);	}	this.image = image;	if (isVisible && hasFocus ()) resize ();}void setIMEFont (int hFont) {	if (!OS.IsDBLocale) return;	LOGFONT logFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA ();	if (OS.GetObject (hFont, LOGFONT.sizeof, logFont) != 0) {		int hwnd = parent.handle;		int hIMC = OS.ImmGetContext (hwnd);		OS.ImmSetCompositionFont (hIMC, logFont);		OS.ImmReleaseContext (hwnd, hIMC);	}}/** * Sets the receiver's location to the point specified by * the arguments which are relative to the receiver's * parent (or its display if its parent is null). * * @param x the new x coordinate for the receiver * @param y the new y coordinate for the receiver * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setLocation (int x, int y) {	checkWidget();	if (this.x == x && this.y == y) return;	this.x = x;  this.y = y;	moved = true;	if (isVisible && hasFocus ()) move ();}/** * Sets the receiver's location to the point specified by * the argument which is relative to the receiver's * parent (or its display if its parent is null). * * @param location the new location for the receiver * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setLocation (Point location) {	checkWidget();	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);	setLocation (location.x, location.y);}/** * Sets the receiver's size to the point specified by the arguments. * * @param width the new width for the receiver * @param height the new height for the receiver * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setSize (int width, int height) {	checkWidget();	if (this.width == width && this.height == height) return;	this.width = width;  this.height = height;	resized = true;	if (isVisible && hasFocus ()) resize ();}/** * Sets the receiver's size to the point specified by the argument. * * @param size the new extent for the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the point is null</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setSize (Point size) {	checkWidget();	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);	setSize (size.x, size.y);}/** * Marks the receiver as visible if the argument is <code>true</code>, * and marks it invisible otherwise.  * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, marking * it visible may not actually cause it to be displayed. * </p> * * @param visible the new visibility state * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */public void setVisible (boolean visible) {	checkWidget();	if (visible == isVisible) return;	isVisible = visible;	int hwnd = parent.handle;	if (OS.GetFocus () != hwnd) return;	if (!isVisible) {		OS.HideCaret (hwnd);	} else {		if (resized) {			resize ();		} else {			if (moved) move ();		}		OS.ShowCaret (hwnd);	}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -