?? display.java
字號:
if (list == null) break; if (list.getImageSize().equals(size)) { list.addRef(); return list; } i++; } if (i == length) { ImageList [] newList = new ImageList [length + 4]; System.arraycopy (toolHotImageList, 0, newList, 0, length); toolHotImageList = newList; } ImageList list = new ImageList(); toolHotImageList [i] = list; list.addRef(); return list;}ImageList getToolDisabledImageList (Point size) { if (toolDisabledImageList == null) toolDisabledImageList = new ImageList [4]; int i = 0; int length = toolDisabledImageList.length; while (i < length) { ImageList list = toolDisabledImageList [i]; if (list == null) break; if (list.getImageSize().equals(size)) { list.addRef(); return list; } i++; } if (i == length) { ImageList [] newList = new ImageList [length + 4]; System.arraycopy (toolDisabledImageList, 0, newList, 0, length); toolDisabledImageList = newList; } ImageList list = new ImageList(); toolDisabledImageList [i] = list; list.addRef(); return list;}int getLastEventTime () { return OS.IsWinCE ? OS.GetTickCount () : OS.GetMessageTime ();}MenuItem getMenuItem (int id) { if (items == null) return null; id = id - ID_START; if (0 <= id && id < items.length) return items [id]; return null;}int getMessageCount () { return synchronizer.getMessageCount ();}Shell getModalShell () { if (modalShells == null) return null; int index = modalShells.length; while (--index >= 0) { Shell shell = modalShells [index]; if (shell != null) return shell; } return null;}Shell getModalDialogShell () { if (modalDialogShell != null && modalDialogShell.isDisposed ()) modalDialogShell = null; return modalDialogShell;}/** * Returns an array of monitors attached to the device. * * @return the array of monitors * * @since 3.0 */public Monitor [] getMonitors () { checkDevice (); if (OS.IsWinCE || (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { return new Monitor [] {getPrimaryMonitor ()}; } monitors = new Monitor [4]; Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$ int lpfnEnum = callback.getAddress (); OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); callback.dispose (); Monitor [] result = new Monitor [monitorCount]; System.arraycopy (monitors, 0, result, 0, monitorCount); monitors = null; monitorCount = 0; return result;}int getMsgProc (int code, int wParam, int lParam) { if (embeddedHwnd == 0) { int hInstance = OS.GetModuleHandle (null); embeddedHwnd = OS.CreateWindowEx (0, windowClass, null, OS.WS_OVERLAPPED, 0, 0, 0, 0, 0, 0, hInstance, null); embeddedCallback = new Callback (this, "embeddedProc", 4); //$NON-NLS-1$ embeddedProc = embeddedCallback.getAddress (); if (embeddedProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); OS.SetWindowLong (embeddedHwnd, OS.GWL_WNDPROC, embeddedProc); } if (code >= 0 && wParam != OS.PM_NOREMOVE) { MSG msg = new MSG (); OS.MoveMemory (msg, lParam, MSG.sizeof); switch (msg.message) { case SWT_RESIZE: { if (msg.hwnd == 0 && msg.wParam != 0) { OS.PostMessage (embeddedHwnd, SWT_RESIZE, msg.wParam, msg.lParam); msg.message = OS.WM_NULL; OS.MoveMemory (lParam, msg, MSG.sizeof); } break; } case OS.WM_KEYDOWN: case OS.WM_KEYUP: case OS.WM_SYSKEYDOWN: case OS.WM_SYSKEYUP: { int hHeap = OS.GetProcessHeap (); int keyMsg = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof); OS.MoveMemory (keyMsg, msg, MSG.sizeof); OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, keyMsg); msg.message = OS.WM_NULL; OS.MoveMemory (lParam, msg, MSG.sizeof); } } } return OS.CallNextHookEx (msgHook, code, wParam, lParam);}/** * Returns the primary monitor for that device. * * @return the primary monitor * * @since 3.0 */public Monitor getPrimaryMonitor () { checkDevice (); if (OS.IsWinCE || (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { Monitor monitor = new Monitor(); int width = OS.GetSystemMetrics (OS.SM_CXSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYSCREEN); monitor.width = width; monitor.height = height; RECT rect = new RECT (); OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0); monitor.clientX = rect.left; monitor.clientY = rect.top; monitor.clientWidth = rect.right - rect.left; monitor.clientHeight = rect.bottom - rect.top; return monitor; } monitors = new Monitor [4]; Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$ int lpfnEnum = callback.getAddress (); OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); callback.dispose (); Monitor result = null; MONITORINFO lpmi = new MONITORINFO (); lpmi.cbSize = MONITORINFO.sizeof; for (int i = 0; i < monitorCount; i++) { Monitor monitor = monitors [i]; OS.GetMonitorInfo (monitors [i].handle, lpmi); if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) != 0) { result = monitor; break; } } monitors = null; monitorCount = 0; return result; }/** * Returns an array containing all shells which have not been * disposed and have the receiver as their display. * * @return the receiver's shells * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */public Shell [] getShells () { checkDevice (); int count = 0; for (int i=0; i<controlTable.length; i++) { Control control = controlTable [i]; if (control != null && control instanceof Shell) count++; } int index = 0; Shell [] result = new Shell [count]; for (int i=0; i<controlTable.length; i++) { Control control = controlTable [i]; if (control != null && control instanceof Shell) { result [index++] = (Shell) control; } } return result;}/** * Returns the thread that has invoked <code>syncExec</code> * or null if no such runnable is currently being invoked by * the user-interface thread. * <p> * Note: If a runnable invoked by asyncExec is currently * running, this method will return null. * </p> * * @return the receiver's sync-interface thread * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */public Thread getSyncThread () { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); return synchronizer.syncThread;}/** * Returns the matching standard color for the given * constant, which should be one of the color constants * specified in class <code>SWT</code>. Any value other * than one of the SWT color constants which is passed * in will result in the color black. This color should * not be free'd because it was allocated by the system, * not the application. * * @param id the color constant * @return the matching color * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT */public Color getSystemColor (int id) { checkDevice (); int pixel = 0x02000000; switch (id) { case SWT.COLOR_WIDGET_DARK_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DDKSHADOW); break; case SWT.COLOR_WIDGET_NORMAL_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DSHADOW); break; case SWT.COLOR_WIDGET_LIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DLIGHT); break; case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DHIGHLIGHT); break; case SWT.COLOR_WIDGET_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_3DFACE); break; case SWT.COLOR_WIDGET_BORDER: pixel = OS.GetSysColor (OS.COLOR_WINDOWFRAME); break; case SWT.COLOR_WIDGET_FOREGROUND: case SWT.COLOR_LIST_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOWTEXT); break; case SWT.COLOR_LIST_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOW); break; case SWT.COLOR_LIST_SELECTION: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHT); break; case SWT.COLOR_LIST_SELECTION_TEXT: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);break; case SWT.COLOR_INFO_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOTEXT); break; case SWT.COLOR_INFO_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOBK); break; case SWT.COLOR_TITLE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_CAPTIONTEXT); break; case SWT.COLOR_TITLE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION); break; case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTACTIVECAPTION); if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION); break; case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTIONTEXT); break; case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION); break; case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTINACTIVECAPTION); if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION); break; default: return super.getSystemColor (id); } return Color.win32_new (this, pixel);}/** * Returns the matching standard platform cursor for the given * constant, which should be one of the cursor constants * specified in class <code>SWT</code>. This cursor should * not be free'd because it was allocated by the system, * not the application. A value of <code>null</code> will * be returned if the supplied constant is not an swt cursor * constant. * * @param id the swt cursor constant * @return the corresponding cursor or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT#CURSOR_ARROW * @see SWT#CURSOR_WAIT * @see SWT#CURSOR_CROSS * @see SWT#CURSOR_APPSTARTING * @see SWT#CURSOR_HELP * @see SWT#CURSOR_SIZEALL * @see SWT#CURSOR_SIZENESW * @see SWT#CURSOR_SIZENS * @see SWT#CURSOR_SIZENWSE * @see SWT#CURSOR_SIZEWE * @see SWT#CURSOR_SIZEN * @see SWT#CURSOR_SIZES * @see SWT#CURSOR_SIZEE * @see SWT#CURSOR_SIZEW * @see SWT#CURSOR_SIZENE * @see SWT#CURSOR_SIZESE * @see SWT#CURSOR_SIZESW * @see SWT#CURSOR_SIZENW * @see SWT#CURSOR_UPARROW * @see SWT#CURSOR_IBEAM * @see SWT#CURSOR_NO * @see SWT#CURSOR_HAND * * @since 3.0 */public Cursor getSystemCursor (int id) { checkDevice (); if (!(0 <= id && id < cursors.length)) return null; if (cursors [id] == null) { cursors [id] = new Cursor (this, id); } return cursors [id];}/** * Returns a reasonable font for applications to use. * On some platforms, this will match the "default font" * or "system font" if such can be found. This font * should not be free'd because it was allocated by the * system, not the application. * <p> * Typically, applications which want the default look * should simply not set the font on the widgets they * create. Widgets are always created with the correct * default font for the class of user-interface component * they represent. * </p> * * @return a font * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */public Font getSystemFont () { checkDevice (); int hFont = systemFont (); return Font.win32_new (this, hFont); }/** * Returns the matching standard platform image for the given * constant, which should be one of the icon constants * specified in class <code>SWT</code>. This image should * not be free'd because it was allocated by the system, * not the application. A value of <code>null</code> will * be returned either if the supplied constant is not an * swt icon constant or if the platform does not define an * image that corresponds to the constant. * * @param id the swt icon constant * @return the corresponding image or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT#ICON_ERROR * @see SWT#ICON_INFORMATION * @see SWT#ICON_QUESTION * @see SWT#ICON_WARNING * @see SWT#ICON_WORKING * * @since 3.0 */public Image getSystemImage (int id) { checkDevice (); int hIcon = 0; switch (id) { case SWT.ICON_ERROR: if (errorIcon == 0) { errorIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); } hIcon = errorIcon; break; case SWT.ICON_WORKING: case SWT.ICON_INFORMATION: if (infoIcon == 0) { infoIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); } hIcon = infoIcon; break; case SWT.ICON_QUESTION: if (questionIcon == 0) { questionIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); } hIcon = questionIcon; break; case SWT.ICON_WARNING: if (warningIcon == 0) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -