?? control.java
字號:
checkWidget (); return menu;}/** * Returns the receiver's monitor. * * @return the receiver's monitor * * @since 3.0 */public Monitor getMonitor () { checkWidget (); if (OS.IsWinCE || (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { return display.getPrimaryMonitor (); } int hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST); MONITORINFO lpmi = new MONITORINFO (); lpmi.cbSize = MONITORINFO.sizeof; OS.GetMonitorInfo (hmonitor, lpmi); Monitor monitor = new Monitor (); monitor.handle = hmonitor; monitor.x = lpmi.rcMonitor_left; monitor.y = lpmi.rcMonitor_top; monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left; monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top; monitor.clientX = lpmi.rcWork_left; monitor.clientY = lpmi.rcWork_top; monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left; monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top; return monitor;}/** * Returns the receiver's parent, which must be a <code>Composite</code> * or null when the receiver is a shell that was created with null or * a display for a parent. * * @return the receiver's parent * * @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 Composite getParent () { checkWidget (); return parent;}Control [] getPath () { int count = 0; Shell shell = getShell (); Control control = this; while (control != shell) { count++; control = control.parent; } control = this; Control [] result = new Control [count]; while (control != shell) { result [--count] = control; control = control.parent; } return result;}/** * Returns the receiver's shell. For all controls other than * shells, this simply returns the control's nearest ancestor * shell. Shells return themselves, even if they are children * of other shells. * * @return the receiver's shell * * @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> * * @see #getParent */public Shell getShell () { checkWidget (); return parent.getShell ();}/** * Returns a point describing the receiver's size. The * x coordinate of the result is the width of the receiver. * The y coordinate of the result is the height of the * receiver. * * @return the receiver's size * * @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 Point getSize () { checkWidget (); forceResize (); RECT rect = new RECT (); OS.GetWindowRect (handle, rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; return new Point (width, height);}/** * Returns the receiver's tool tip text, or null if it has * not been set. * * @return the receiver's tool tip text * * @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 String getToolTipText () { checkWidget (); return toolTipText;}/** * Returns <code>true</code> if the receiver is visible, and * <code>false</code> otherwise. * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, this method * may still indicate that it is considered visible even though * it may not actually be showing. * </p> * * @return the receiver's 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 boolean getVisible () { checkWidget (); if (drawCount != 0) return (state & HIDDEN) == 0; int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); return (bits & OS.WS_VISIBLE) != 0;}boolean hasCursor () { RECT rect = new RECT (); if (!OS.GetClientRect (handle, rect)) return false; if (OS.MapWindowPoints (handle, 0, rect, 2) == 0) return false; POINT pt = new POINT (); return OS.GetCursorPos (pt) && OS.PtInRect (rect, pt);}boolean hasFocus () { /* * If a non-SWT child of the control has focus, * then this control is considered to have focus * even though it does not have focus in Windows. */ int hwndFocus = OS.GetFocus (); while (hwndFocus != 0) { if (hwndFocus == handle) return true; if (display.getControl (hwndFocus) != null) { return false; } hwndFocus = OS.GetParent (hwndFocus); } return false;}/** * Invokes platform specific functionality to allocate a new GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Control</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param data the platform specific GC data * @return the platform specific GC handle */public int internal_new_GC (GCData data) { checkWidget(); int hDC; if (data == null || data.ps == null) { hDC = OS.GetDC (handle); } else { hDC = OS.BeginPaint (handle, data.ps); } if (hDC == 0) SWT.error(SWT.ERROR_NO_HANDLES); if (data != null) { if (!OS.IsWinCE && (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (4 << 16 | 10)) { int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if ((data.style & mask) != 0) { data.layout = (data.style & SWT.RIGHT_TO_LEFT) != 0 ? OS.LAYOUT_RTL : 0; } else { int flags = OS.GetLayout (hDC); if ((flags & OS.LAYOUT_RTL) != 0) { data.style |= SWT.RIGHT_TO_LEFT | SWT.MIRRORED; } else { data.style |= SWT.LEFT_TO_RIGHT; } } } else { data.style |= SWT.LEFT_TO_RIGHT; } data.device = display; data.foreground = getForegroundPixel (); data.background = getBackgroundPixel (); data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); data.hwnd = handle; } return hDC;}/** * Invokes platform specific functionality to dispose a GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Control</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param hDC the platform specific GC handle * @param data the platform specific GC data */public void internal_dispose_GC (int hDC, GCData data) { checkWidget (); if (data == null || data.ps == null) { OS.ReleaseDC (handle, hDC); } else { OS.EndPaint (handle, data.ps); }}boolean isActive () { Shell dialogShell = display.getModalDialogShell (); if (dialogShell != null && dialogShell != getShell ()) { return false; } Shell shell = null; Shell [] modalShells = display.modalShells; if (modalShells != null) { int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; int index = modalShells.length; while (--index >= 0) { Shell modal = modalShells [index]; if (modal != null) { if ((modal.style & bits) != 0) { Control control = this; while (control != null) { if (control == modal) break; control = control.parent; } if (control != modal) return false; break; } if ((modal.style & SWT.PRIMARY_MODAL) != 0) { if (shell == null) shell = getShell (); if (modal.parent == shell) return false; } } } } if (shell == null) shell = getShell (); return shell.getEnabled ();}/** * Returns <code>true</code> if the receiver is enabled and all * of the receiver's ancestors are enabled, and <code>false</code> * otherwise. A disabled control is typically not selectable from the * user interface and draws with an inactive or "grayed" look. * * @return the receiver's enabled 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> * * @see #getEnabled */public boolean isEnabled () { checkWidget (); return getEnabled () && parent.isEnabled ();}/** * Returns <code>true</code> if the receiver has the user-interface * focus, and <code>false</code> otherwise. * * @return the receiver's focus 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 boolean isFocusControl () { checkWidget (); return hasFocus ();}boolean isFocusAncestor (Control control) { while (control != null && control != this) { control = control.parent; } return control == this;}/** * Returns <code>true</code> if the underlying operating * system supports this reparenting, otherwise <code>false</code> * * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code> * * @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 boolean isReparentable () { checkWidget (); return true;}boolean isShowing () { /* * This is not complete. Need to check if the * widget is obscurred by a parent or sibling. */ if (!isVisible ()) return false; Control control = this; while (control != null) { Point size = control.getSize (); if (size.x == 0 || size.y == 0) { return false; } control = control.parent; } return true; /* * Check to see if current damage is included. */// if (!OS.IsWindowVisible (handle)) return false;// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;// int hDC = OS.GetDCEx (handle, 0, flags);// int result = OS.GetClipBox (hDC, new RECT ());// OS.ReleaseDC (handle, hDC);// return result != OS.NULLREGION;}boolean isTabGroup () { Control [] tabList = parent._getTabList (); if (tabList != null) { for (int i=0; i<tabList.length; i++) { if (tabList [i] == this) return true; } } int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); return (bits & OS.WS_TABSTOP) != 0;}boolean isTabItem () { Control [] tabList = parent._getTabList (); if (tabList != null) { for (int i=0; i<tabList.length; i++) { if (tabList [i] == this) return false; } } int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); if ((bits & OS.WS_TABSTOP) != 0) return false; int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0); if ((code & OS.DLGC_STATIC) != 0) return false; if ((code & OS.DLGC_WANTALLKEYS) != 0) return false; if ((code & OS.DLGC_WANTARROWS) != 0) return false; if ((code & OS.DLGC_WANTTAB) != 0) return false; return true;}/** * Returns <code>true</code> if the receiver is visible and all * of the receiver's ancestors are visible and <code>false</code> * otherwise. * * @return the receiver's 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> * * @see #getVisible */public boolean isVisible () { checkWidget (); if (OS.IsWindowVisible (handle)) return true; return getVisible () && parent.isVisible ();}Decorations menuShell () { return parent.menuShell ();}boolean mnemonicHit (char key) { return false;}boolean mnemonicMatch (char key) { return false;}/** * Moves the receiver above the specified control in the
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -