diff options
| author | Raymond Lam | 2011-09-26 22:18:28 +0000 |
|---|---|---|
| committer | Felipe Heidrich | 2011-10-11 15:32:26 +0000 |
| commit | e57a283bb3e1c571d364404c0719ef9b9dbf09f2 (patch) | |
| tree | f073f287a09e4190b036b61fe285393c684dc175 | |
| parent | e359af64dcf22b6c5ed365038a6b225c756b8c5d (diff) | |
| download | eclipse.platform.swt-e57a283bb3e1c571d364404c0719ef9b9dbf09f2.tar.gz eclipse.platform.swt-e57a283bb3e1c571d364404c0719ef9b9dbf09f2.tar.xz eclipse.platform.swt-e57a283bb3e1c571d364404c0719ef9b9dbf09f2.zip | |
Glassify the SWT Text widget.
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 38f0451215..3ec9f5c8ef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -2586,6 +2586,16 @@ LRESULT wmColorChild (int /*long*/ wParam, int /*long*/ lParam) { } } } + + // a WM_CTLCOLOREDIT message is issued by the Win32 Edit control whenever it's about to be redrawn; the + // Control#windowProc routes that message into here, and if glass is turned on we invalidate the window to + // trigger a glass-aware repaint of the control + if (this.getBufferredPaint() && !bPrintingClient) { + RECT lpRect = new RECT(); + OS.GetClientRect(this.handle, lpRect); + OS.InvalidateRect(this.handle, lpRect, false); + } + return super.wmColorChild (wParam, lParam); } @@ -2638,4 +2648,44 @@ LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) { return super.wmCommandChild (wParam, lParam); } +boolean getBufferredPaint() { + Shell shell = getShell (); + if (((shell.style & SWT.TRIM_FILL) != 0) && ((this.style & SWT.TRIM_FILL) != 0)) { + return true; + } + return false; +} + +// this flag is used to prevent the Text#wmColorChild method from endlessly triggering a series of repaints +private boolean bPrintingClient = false; + +LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) { + int /*long*/ paintDC = 0; + PAINTSTRUCT ps = new PAINTSTRUCT (); + paintDC = OS.BeginPaint (hWnd, ps); + + RECT rect = new RECT(); + OS.GetClientRect(hWnd, rect); + + // set up the buffered device context - the alpha is set to 100%, making the device context entirely opaque + int /*long*/ [] hdcBuffered = new int /*long*/ [1]; + int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(paintDC, rect, OS.BPBF_TOPDOWNDIB, null, hdcBuffered); + + if (hdcBuffered[0] != 0) { + // ask the Edit control to render itself into the buffered device context; note that this will result in + // the Edit control issuing a WM_CTLCOLOREDIT message and we need to set the 'bPrintingClient' flag to prevent + // a perpetual paint sequence from being triggered + bPrintingClient = true; + OS.SendMessage(this.handle, OS.WM_PRINTCLIENT, hdcBuffered[0], OS.PRF_CLIENT); + bPrintingClient = false; + + // entirely opaque + OS.BufferedPaintSetAlpha(hBufferedPaint, rect, (byte)0xFF); + OS.EndBufferedPaint(hBufferedPaint, true); + } + + OS.EndPaint (handle, ps); + return LRESULT.ZERO; +} + } |
