Mercurial > projects > dwt-win
diff dwt/widgets/Canvas.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | d7264281cb4a |
children | fd9c62a2998e |
line wrap: on
line diff
--- a/dwt/widgets/Canvas.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Canvas.d Sat May 17 17:34:28 2008 +0200 @@ -24,6 +24,7 @@ import dwt.widgets.Caret; import dwt.widgets.Control; import dwt.widgets.Display; +import dwt.widgets.IME; import dwt.dwthelper.utils; @@ -53,6 +54,7 @@ alias Composite.windowProc windowProc; Caret caret; + IME ime; /** * Prevents uninitialized instances from being created outside the package. @@ -103,37 +105,6 @@ } /** - * Returns the caret. - * <p> - * The caret for the control is automatically hidden - * and shown when the control is painted or resized, - * when focus is gained or lost and when an the control - * is scrolled. To avoid drawing on top of the caret, - * the programmer must hide and show the caret when - * drawing in the window any other time. - * </p> - * - * @return the caret - * - * @exception DWTException <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 Caret getCaret () { - checkWidget (); - return caret; -} - -override void releaseChildren (bool destroy) { - if (caret !is null) { - caret.release (false); - caret = null; - } - super.releaseChildren (destroy); -} - -/** * Fills the interior of the rectangle specified by the arguments, * with the receiver's background. * @@ -166,6 +137,58 @@ } /** + * Returns the caret. + * <p> + * The caret for the control is automatically hidden + * and shown when the control is painted or resized, + * when focus is gained or lost and when an the control + * is scrolled. To avoid drawing on top of the caret, + * the programmer must hide and show the caret when + * drawing in the window any other time. + * </p> + * + * @return the caret + * + * @exception DWTException <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 Caret getCaret () { + checkWidget (); + return caret; +} + +/** + * Returns the IME. + * + * @return the IME + * + * @exception DWTException <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> + * + * @since 3.4 + */ +public IME getIME () { + checkWidget (); + return ime; +} + +void releaseChildren (bool destroy) { + if (caret !is null) { + caret.release (false); + caret = null; + } + if (ime !is null) { + ime.release (false); + ime = null; + } + super.releaseChildren (destroy); +} + +/** * Scrolls a rectangular area of the receiver by first copying * the source area to the destination and then causing the area * of the source which is not covered by the destination to @@ -296,6 +319,27 @@ super.setFont (font); } +/** + * Sets the receiver's IME. + * + * @param ime the new IME for the receiver, may be null + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the IME has been disposed</li> + * </ul> + * @exception DWTException <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> + * + * @since 3.4 + */ +public void setIME (IME ime) { + checkWidget (); + if (ime !is null && ime.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT); + this.ime = ime; +} + override int windowProc (HWND hwnd, int msg, int wParam, int lParam) { if (msg is Display.SWT_RESTORECARET) { if ((state & CANVAS) !is 0) { @@ -309,8 +353,34 @@ return super.windowProc (hwnd, msg, wParam, lParam); } -override LRESULT WM_IME_COMPOSITION (int wParam, int lParam) { - LRESULT result = super.WM_IME_COMPOSITION (wParam, lParam); +override LRESULT WM_CHAR (int wParam, int lParam) { + LRESULT result = super.WM_CHAR (wParam, lParam); + if (result !is null) return result; + if (caret !is null) { + switch (wParam) { + case DWT.DEL: + case DWT.BS: + case DWT.ESC: + break; + default: { + if (OS.GetKeyState (OS.VK_CONTROL) >= 0) { + int value; + if (OS.SystemParametersInfo (OS.SPI_GETMOUSEVANISH, 0, &value, 0)) { + if (value !is 0) OS.SetCursor (null); + } + } + } + } + } + return result; +} + +override LRESULT WM_IME_COMPOSITION (int /*long*/ wParam, int /*long*/ lParam) { + if (ime !is null) { + LRESULT result = ime.WM_IME_COMPOSITION (wParam, lParam); + if (result !is null) return result; + } + /* * Bug in Windows. On Korean Windows XP, the IME window * for the Korean Input System (MS-IME 2002) always opens @@ -339,7 +409,23 @@ } } } - return result; + return super.WM_IME_COMPOSITION (wParam, lParam); +} + +override LRESULT WM_IME_COMPOSITION_START (int /*long*/ wParam, int /*long*/ lParam) { + if (ime !is null) { + LRESULT result = ime.WM_IME_COMPOSITION_START (wParam, lParam); + if (result !is null) return result; + } + return super.WM_IME_COMPOSITION_START (wParam, lParam); +} + +override LRESULT WM_IME_ENDCOMPOSITION (int /*long*/ wParam, int /*long*/ lParam) { + if (ime !is null) { + LRESULT result = ime.WM_IME_ENDCOMPOSITION (wParam, lParam); + if (result !is null) return result; + } + return super.WM_IME_ENDCOMPOSITION (wParam, lParam); } override LRESULT WM_INPUTLANGCHANGE (int wParam, int lParam) { @@ -352,11 +438,23 @@ } override LRESULT WM_KILLFOCUS (int wParam, int lParam) { + if (ime !is null) { + LRESULT result = ime.WM_KILLFOCUS (wParam, lParam); + if (result !is null) return result; + } LRESULT result = super.WM_KILLFOCUS (wParam, lParam); if (caret !is null) caret.killFocus (); return result; } +override LRESULT WM_LBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) { + if (ime !is null) { + LRESULT result = ime.WM_LBUTTONDOWN (wParam, lParam); + if (result !is null) return result; + } + return super.WM_LBUTTONDOWN (wParam, lParam); +} + override LRESULT WM_SETFOCUS (int wParam, int lParam) { LRESULT result = super.WM_SETFOCUS (wParam, lParam); if (caret !is null) caret.setFocus (); @@ -371,7 +469,7 @@ override LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) { LRESULT result = super.WM_WINDOWPOSCHANGED (wParam, lParam); - if (result !is null) return result; + //if (result !is null) return result; /* * Bug in Windows. When a window with style WS_EX_LAYOUTRTL * that contains a caret is resized, Windows does not move the