aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lam2011-12-06 14:09:18 (EST)
committerFelipe Heidrich2011-12-09 10:18:39 (EST)
commit093c5424ad9dd621b6f299675f1805e3a472a008 (patch)
tree5e38705315739c63c84a99d279a4d60d5deaf5bb
parent1c89c90eebf251a5fbcc2833e8758ef654d57e4e (diff)
downloadeclipse.platform.swt-093c5424ad9dd621b6f299675f1805e3a472a008.zip
eclipse.platform.swt-093c5424ad9dd621b6f299675f1805e3a472a008.tar.gz
eclipse.platform.swt-093c5424ad9dd621b6f299675f1805e3a472a008.tar.bz2
General code cleanup of AERO_WORK branch.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java364
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java98
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java67
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java129
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java82
10 files changed, 429 insertions, 475 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index c320875..c30f172 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -574,6 +574,93 @@ int defaultForeground () {
return OS.GetSysColor (OS.COLOR_BTNTEXT);
}
+/*
+ * Reference vsstyle.h in the Windows SDK.
+ *
+ * Return the button style for the PushButton or the ToggleButton. Button styles come in various flavors: disabled, pressed, hot, default
+ * and normal.
+ *
+ */
+int determineStateOfPushButton () {
+ POINT ptCursor = new POINT ();
+ RECT rectWindow = new RECT ();
+ OS.GetWindowRect (handle, rectWindow);
+ OS.GetCursorPos (ptCursor);
+ boolean hovering = OS.PtInRect (rectWindow, ptCursor);
+ boolean captured = OS.GetCapture () == handle;
+
+ if (!getEnabled ()) {
+ return OS.PBS_DISABLED;
+ }
+
+ if (hovering && captured) {
+ return OS.PBS_PRESSED;
+ }
+
+ if (hovering || captured) {
+ return OS.PBS_HOT;
+ }
+
+ int /*long*/ dwCheckState = OS.SendMessage(handle, OS.BM_GETCHECK, 0, 0);
+ if (dwCheckState == OS.BST_CHECKED) {
+ return OS.PBS_PRESSED;
+ }
+
+ if (getDefault ()) {
+ return OS.PBS_DEFAULTED;
+ }
+
+ return OS.PBS_NORMAL;
+}
+
+/*
+ * Reference vsstyle.h in the Windows SDK.
+ *
+ * Button states will determine which bitmap the theme will draw in the background. The visual state comes in 4 states: normal, hot, pressed or
+ * disabled. These 4 visual states are then combined with the checked/unchecked state of the button (in the case of the check box, there's
+ * a 3rd checked state of indeterminate), yielding the final button state that is returned.
+ *
+ */
+int determineStateOfRadioOrCheck () {
+ POINT ptCursor = new POINT ();
+ RECT rectWindow = new RECT ();
+ OS.GetWindowRect (handle, rectWindow);
+ OS.GetCursorPos (ptCursor);
+ boolean hovering = OS.PtInRect (rectWindow, ptCursor);
+ boolean captured = OS.GetCapture () == handle;
+ int /*long*/ dwCheckState = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
+
+ if (!getEnabled ()) {
+ if ((style & SWT.RADIO) != 0) {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDDISABLED : OS.RBS_UNCHECKEDDISABLED;
+ } else {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDDISABLED : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDDISABLED : OS.CBS_MIXEDDISABLED;
+ }
+ }
+
+ if (hovering && captured) {
+ if ((style & SWT.RADIO) != 0) {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDPRESSED : OS.RBS_UNCHECKEDPRESSED;
+ } else {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDPRESSED : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDPRESSED : OS.CBS_MIXEDPRESSED;
+ }
+ }
+
+ if (hovering || captured) {
+ if ((style & SWT.RADIO) != 0) {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDHOT : OS.RBS_UNCHECKEDHOT;
+ } else {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDHOT : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDHOT : OS.CBS_MIXEDHOT;
+ }
+ }
+
+ if ((style & SWT.RADIO) != 0) {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDNORMAL : OS.RBS_UNCHECKEDNORMAL;
+ } else {
+ return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDNORMAL : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDNORMAL : OS.CBS_MIXEDNORMAL;
+ }
+}
+
void enableWidget (boolean enabled) {
super.enableWidget (enabled);
/*
@@ -638,7 +725,7 @@ public int getAlignment () {
boolean getBufferredPaint() {
Shell shell = getShell ();
- if ((shell.style & SWT.TRIM_FILL) != 0 && (this.style & SWT.TRIM_FILL) != 0) {
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) {
if ((style & SWT.PUSH) != 0) return true;
if ((style & SWT.TOGGLE) != 0) return true;
if ((style & SWT.RADIO) != 0) return true;
@@ -754,6 +841,17 @@ public String getText () {
return text;
}
+/*
+ * Return the width of the bitmap that is drawn in the background for the radio or checkbox.
+ */
+int getThemeBitmapWidth (int /*long*/ hTheme, int iPartId, int iState) {
+ BITMAP bm = new BITMAP ();
+ int /*long*/ [] hBitmap = new int /*long*/ [1];
+ OS.GetThemeBitmap (hTheme, iPartId, iState, 0, OS.GBF_DIRECT, hBitmap);
+ OS.GetObject (hBitmap[0], BITMAP.sizeof, bm);
+ return bm.bmWidth;
+}
+
boolean isTabItem () {
if ((style & SWT.PUSH) != 0) return isTabGroup ();
return super.isTabItem ();
@@ -1227,18 +1325,6 @@ LRESULT WM_GETDLGCODE (int /*long*/ wParam, int /*long*/ lParam) {
return result;
}
-LRESULT WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) {
- /*
- * Ensure that there is an accessible object created for this
- * control because support for radio button position in group
- * accessibility is implemented in the accessibility package.
- */
- if ((style & SWT.RADIO) != 0) {
- if (accessible == null) accessible = new_Accessible (this);
- }
- return super.WM_GETOBJECT (wParam, lParam);
-}
-
LRESULT WM_KILLFOCUS (int /*long*/ wParam, int /*long*/ lParam) {
LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
if ((style & SWT.PUSH) != 0 && getDefault ()) {
@@ -1348,6 +1434,77 @@ LRESULT WM_UPDATEUISTATE (int /*long*/ wParam, int /*long*/ lParam) {
return result;
}
+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 rcClient = new RECT();
+ OS.GetClientRect (hWnd, rcClient);
+
+ // setup the theme parameters
+ int /*long*/ hTheme = display.hButtonTheme();
+ int iPartId = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? OS.BP_PUSHBUTTON : ((style & SWT.RADIO) != 0) ? OS.BP_RADIOBUTTON : OS.BP_CHECKBOX;
+ int iState = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? determineStateOfPushButton() : determineStateOfRadioOrCheck();
+
+ // initialize the buffered painting device context
+ BP_PAINTPARAMS params = new BP_PAINTPARAMS();
+ params.cbSize = BP_PAINTPARAMS.sizeof;
+ params.dwFlags = OS.BPPF_ERASE;
+ int /*long*/ [] hdcBuffered = new int /*long*/ [1];
+ int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(paintDC, rcClient, OS.BPBF_TOPDOWNDIB, params, hdcBuffered);
+ OS.PatBlt(hdcBuffered[0], 0, 0, rcClient.right, rcClient.bottom, OS.BLACKNESS);
+ OS.BufferedPaintSetAlpha(hdcBuffered[0], rcClient, (byte)0x00);
+
+ // the DrawThemeBackground will draw the radio button or checkbox in the middle of the button's client
+ // area, and hence we need shift the painting rectangle off to the left if this is not a pushbutton
+ int bitmapWidth = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? 0 : getThemeBitmapWidth(hTheme, iPartId, iState);
+ int bitmapOffset = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? 0 : (rcClient.right - rcClient.left) / 2 - bitmapWidth / 2;
+ RECT rcBackground = new RECT();
+ rcBackground.top = rcClient.top;
+ rcBackground.bottom = rcClient.bottom;
+ rcBackground.left = rcClient.left - bitmapOffset;
+ rcBackground.right = rcClient.right - bitmapOffset;
+
+ // get the coordinates of the content rectangle and draw the background bitmap (the content rectangle is later fed into
+ // DrawThemeTextEx and is also used for the focus rectangle)
+ RECT rcContent = new RECT();
+ OS.GetThemeBackgroundContentRect(hTheme, hdcBuffered[0], iPartId, iState, rcClient, rcContent);
+ OS.DrawThemeBackground(hTheme, hdcBuffered[0], iPartId, iState, rcBackground, null);
+
+ // setup the DTTOPTS structure for calling into DrawThemeTextEx - note how we call getThemeGlowSize()
+ // to apply a glow around the text we are drawing to enhance readability of the text against a glass background
+ DTTOPTS dttOpts =new DTTOPTS();
+ dttOpts.dwSize = DTTOPTS.sizeof;
+ dttOpts.dwFlags = OS.DTT_COMPOSITED | OS.DTT_GLOWSIZE;
+ dttOpts.iGlowSize = getThemeGlowSize();
+
+ // set font before drawing the text
+ int /*long*/ hFont = OS.SendMessage(handle, OS.WM_GETFONT, 0, 0);
+ if (hFont != 0) {
+ hFont = OS.SelectObject(hdcBuffered[0], hFont);
+ }
+
+ // draw the button text in an aero/glass friendly manner
+ rcContent.left += bitmapWidth; // adjust the drawing rectangle to accomodate for the bitmap in case of radio or checkbox
+ int dwFlags = OS.DT_SINGLELINE | OS.DT_CENTER | OS.DT_VCENTER;
+ TCHAR buffer = new TCHAR (getCodePage (), text, true);
+ OS.DrawThemeTextEx(hTheme, hdcBuffered[0], iPartId, iState, buffer.chars, buffer.length()-1, dwFlags, rcContent, dttOpts);
+
+ // draw the focus rectangle if needed
+ if (OS.GetFocus()==handle) {
+ OS.DrawFocusRect(hdcBuffered[0], rcContent);
+ }
+
+ if (hFont != 0) {
+ OS.SelectObject(hdcBuffered[0], hFont);
+ }
+
+ OS.EndBufferedPaint(hBufferedPaint, true);
+ OS.EndPaint (handle, ps);
+ return LRESULT.ZERO;
+}
+
LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
@@ -1440,185 +1597,4 @@ LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
return null;
}
-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 rcClient = new RECT();
- OS.GetClientRect (hWnd, rcClient);
-
- // setup the theme parameters
- int /*long*/ hTheme = OS.OpenThemeData(0, "Button;".toCharArray());
- int iPartId = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? OS.BP_PUSHBUTTON : ((style & SWT.RADIO) != 0) ? OS.BP_RADIOBUTTON : OS.BP_CHECKBOX;
- int iState = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? determineStateOfPushButton() : determineStateOfRadioOrCheck();
-
- // initialize the buffered painting device context
- BP_PAINTPARAMS params = new BP_PAINTPARAMS();
- params.cbSize = BP_PAINTPARAMS.sizeof;
- params.dwFlags = OS.BPPF_ERASE;
- int /*long*/ [] hdcBuffered = new int /*long*/ [1];
- int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(paintDC, rcClient, OS.BPBF_TOPDOWNDIB, params, hdcBuffered);
- OS.PatBlt(hdcBuffered[0], 0, 0, rcClient.right, rcClient.bottom, OS.BLACKNESS);
- OS.BufferedPaintSetAlpha(hdcBuffered[0], rcClient, (byte)0x00);
-
- // the DrawThemeBackground will draw the radio button or checkbox in the middle of the button's client
- // area, and hence we need shift the painting rectangle off to the left if this is not a pushbutton
- int bitmapWidth = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? 0 : this.getThemeBitmapWidth(hTheme, iPartId, iState);
- int bitmapOffset = ((style & SWT.PUSH) != 0 || (style & SWT.TOGGLE) != 0) ? 0 : (rcClient.right - rcClient.left) / 2 - bitmapWidth / 2;
- RECT rcBackground = new RECT();
- rcBackground.top = rcClient.top;
- rcBackground.bottom = rcClient.bottom;
- rcBackground.left = rcClient.left - bitmapOffset;
- rcBackground.right = rcClient.right - bitmapOffset;
-
- // get the coords of the content rectangle and draw the background bitmap (the content rectangle is later fed into
- // DrawThemeTextEx and is also used for the focus rectangle)
- RECT rcContent = new RECT();
- OS.GetThemeBackgroundContentRect(hTheme, hdcBuffered[0], iPartId, iState, rcClient, rcContent);
- OS.DrawThemeBackground(hTheme, hdcBuffered[0], iPartId, iState, rcBackground, null);
-
- // setup the DTTOPTS structure for calling into DrawThemeTextEx - note how we call getThemeGlowSize()
- // to apply a glow around the text we are drawing to enhance readability of the text against a glass background
- DTTOPTS dttOpts =new DTTOPTS();
- dttOpts.dwSize = DTTOPTS.sizeof;
- dttOpts.dwFlags = OS.DTT_COMPOSITED | OS.DTT_GLOWSIZE;
- dttOpts.iGlowSize = getThemeGlowSize();
-
- // set font before drawing the text
- int /*long*/ hFont = OS.SendMessage(this.handle, OS.WM_GETFONT, 0, 0);
- if (hFont != 0) {
- hFont = OS.SelectObject(hdcBuffered[0], hFont);
- }
-
- // draw the button text in an aero/glass friendly manner
- rcContent.left += bitmapWidth; // adjust the drawing rectangle to accomodate for the bitmap in case of radio or checkbox
- int dwFlags = OS.DT_SINGLELINE | OS.DT_CENTER | OS.DT_VCENTER;
- TCHAR buffer = new TCHAR (getCodePage (), text, true);
- OS.DrawThemeTextEx(hTheme, hdcBuffered[0], iPartId, iState, buffer.chars, buffer.length()-1, dwFlags, rcContent, dttOpts);
-
- // draw the focus rectangle if needed
- if (OS.GetFocus()==this.handle) {
- OS.DrawFocusRect(hdcBuffered[0], rcContent);
- }
-
- // restore font
- if (hFont != 0) {
- OS.SelectObject(hdcBuffered[0], hFont);
- }
-
- OS.EndBufferedPaint(hBufferedPaint, true);
- OS.CloseThemeData(hTheme);
- OS.EndPaint (handle, ps);
- return LRESULT.ZERO;
-}
-
-/*
- * Reference vsstyle.h in the Windows SDK.
- *
- * Return the button style for the PushButton or the ToggleButton. Button styles come in various flavors: disabled, pressed, hot, default
- * and normal.
- *
- */
-int determineStateOfPushButton () {
- POINT ptCursor = new POINT ();
- RECT rectWindow = new RECT ();
- OS.GetWindowRect (handle, rectWindow);
- OS.GetCursorPos (ptCursor);
- boolean hovering = OS.PtInRect (rectWindow, ptCursor);
- boolean captured = OS.GetCapture () == handle;
-
- // see if the button is in a disabled state
- if (!getEnabled ()) {
- return OS.PBS_DISABLED;
- }
-
- // is the button pressed?
- if (hovering && captured) {
- return OS.PBS_PRESSED;
- }
-
- // does the button have focus
- if (hovering || captured) {
- return OS.PBS_HOT;
- }
-
- // is the button toggled on?
- int /*long*/ dwCheckState = OS.SendMessage(this.handle, OS.BM_GETCHECK, 0, 0);
- if (dwCheckState == OS.BST_CHECKED) {
- return OS.PBS_PRESSED;
- }
-
- // is this the default button?
- if (getDefault ()) {
- return OS.PBS_DEFAULTED;
- }
-
- // normal button
- return OS.PBS_NORMAL;
-}
-
-
-/*
- * Reference vsstyle.h in the Windows SDK.
- *
- * Button states will determine which bitmap the theme will draw in the background. The visual state comes in 4 states: normal, hot, pressed or
- * disabled. These 4 visual states are then combined with the checked/unchecked state of the button (in the case of the check box, there's
- * a 3rd checked state of indeterminate), yielding the final button state that is returned.
- *
- */
-int determineStateOfRadioOrCheck () {
- POINT ptCursor = new POINT ();
- RECT rectWindow = new RECT ();
- OS.GetWindowRect (handle, rectWindow);
- OS.GetCursorPos (ptCursor);
- boolean hovering = OS.PtInRect (rectWindow, ptCursor);
- boolean captured = OS.GetCapture () == handle;
- int /*long*/ dwCheckState = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
-
- if (!getEnabled ()) {
- if ((style & SWT.RADIO) != 0) {
- return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDDISABLED : OS.RBS_UNCHECKEDDISABLED;
- } else {
- return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDDISABLED : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDDISABLED : OS.CBS_MIXEDDISABLED;
- }
- }
-
- // is the button pressed?
- if (hovering && captured) {
- if ((style & SWT.RADIO) != 0) {
- return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDPRESSED : OS.RBS_UNCHECKEDPRESSED;
- } else {
- return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDPRESSED : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDPRESSED : OS.CBS_MIXEDPRESSED;
- }
- }
-
- // does the button have focus?
- if (hovering || captured) {
- if ((style & SWT.RADIO) != 0) {
- return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDHOT : OS.RBS_UNCHECKEDHOT;
- } else {
- return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDHOT : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDHOT : OS.CBS_MIXEDHOT;
- }
- }
-
- // normal button
- if ((style & SWT.RADIO) != 0) {
- return (dwCheckState == OS.BST_CHECKED) ? OS.RBS_CHECKEDNORMAL : OS.RBS_UNCHECKEDNORMAL;
- } else {
- return (dwCheckState == OS.BST_CHECKED) ? OS.CBS_CHECKEDNORMAL : (dwCheckState == OS.BST_UNCHECKED) ? OS.CBS_UNCHECKEDNORMAL : OS.CBS_MIXEDNORMAL;
- }
-}
-
-/*
- * Return the width of the bitmap that is drawn in the background for the radio or checkbox.
- */
-int getThemeBitmapWidth (int /*long*/ hTheme, int iPartId, int iState) {
- BITMAP bm = new BITMAP ();
- int /*long*/ [] hBitmap = new int /*long*/ [1];
- OS.GetThemeBitmap (hTheme, iPartId, iState, 0, OS.GBF_DIRECT, hBitmap);
- OS.GetObject (hBitmap[0], BITMAP.sizeof, bm);
- return bm.bmWidth;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index b23aff1..78ba6b6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -97,6 +97,9 @@ public class Combo extends Composite {
ComboProc = lpWndClass.lpfnWndProc;
}
+ // this flag is used to prevent the Text#wmColorChild method from triggering a perpetual series of repaints
+ private boolean bPrintingClient = false;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -657,9 +660,38 @@ boolean dragDetect (int /*long*/ hwnd, int x, int y, boolean filter, boolean []
return super.dragDetect (hwnd, x, y, filter, detect, consume);
}
+LRESULT drawBufferedText (int /*long*/ hWnd) {
+ 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 will be 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(hWnd, 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;
+}
+
boolean getBufferredPaint() {
Shell shell = getShell ();
- if (((shell.style & SWT.TRIM_FILL) != 0) && ((this.style & SWT.TRIM_FILL) != 0)) return true;
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) return true;
return false;
}
@@ -2551,6 +2583,22 @@ LRESULT wmClipboard (int /*long*/ hwndText, int msg, int /*long*/ wParam, int /*
return null;
}
+LRESULT wmColorChild (int /*long*/ wParam, int /*long*/ lParam) {
+ int /*long*/ hwndEdit = OS.GetDlgItem (handle, CBID_EDIT);
+ if (lParam == hwndEdit) {
+ // 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 (getBufferredPaint() && !bPrintingClient) {
+ RECT lpRect = new RECT();
+ OS.GetClientRect(hwndEdit, lpRect);
+ OS.InvalidateRect(hwndEdit, lpRect, false);
+ }
+ }
+
+ return super.wmColorChild (wParam, lParam);
+}
+
LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
@@ -2716,52 +2764,4 @@ LRESULT wmSysKeyDown (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lPara
return result;
}
-LRESULT wmColorChild (int /*long*/ wParam, int /*long*/ lParam) {
- int /*long*/ hwndEdit = OS.GetDlgItem (handle, CBID_EDIT);
- if (lParam == hwndEdit) { // is this from the Edit control?
- // 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(hwndEdit, lpRect);
- OS.InvalidateRect(hwndEdit, lpRect, false);
- }
- }
-
- return super.wmColorChild (wParam, lParam);
-}
-
-// this flag is used to prevent the Text#wmColorChild method from triggering a perpetual series of repaints
-private boolean bPrintingClient = false;
-
-LRESULT drawBufferedText (int /*long*/ hWnd) {
- 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 will be 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(hWnd, 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;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 8268d57..e75a145 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -926,7 +926,7 @@ void drawBackground (int /*long*/ hDC) {
}
void drawBackground (int /*long*/ hDC, RECT rect) {
- if ((this.style & SWT.TRIM_FILL) != 0) {
+ if ((style & SWT.TRIM_FILL) != 0) {
drawBackgroundBuffered(hDC, rect);
return;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 0bf70ee..86ead1f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -155,14 +155,17 @@ public class Display extends Device {
}
/* XP Themes */
- int /*long*/ hButtonTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme;
+ int /*long*/ hButtonTheme, hCompositedWindowTheme, hControlPanelStyleTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme, hToolbarTheme;
static final char [] BUTTON = new char [] {'B', 'U', 'T', 'T', 'O', 'N', 0};
+ static final char [] COMPOSITEDWINDOW = new char [] {'C', 'O', 'M', 'P', 'O', 'S', 'I', 'T', 'E', 'D', 'W', 'I', 'N', 'D', 'O', 'W', ':', ':', 'W', 'I', 'N', 'D', 'O', 'W', 0};
+ static final char [] CONTROLPANELSTYLE = new char [] {'C', 'O', 'N', 'T', 'R', 'O', 'L', 'P', 'A', 'N', 'E', 'L', 'S', 'T', 'Y', 'L', 'E', 0};
static final char [] EDIT = new char [] {'E', 'D', 'I', 'T', 0};
static final char [] EXPLORER = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 0};
static final char [] EXPLORERBAR = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 'B', 'A', 'R', 0};
static final char [] SCROLLBAR = new char [] {'S', 'C', 'R', 'O', 'L', 'L', 'B', 'A', 'R', 0};
static final char [] LISTVIEW = new char [] {'L', 'I', 'S', 'T', 'V', 'I', 'E', 'W', 0};
static final char [] TAB = new char [] {'T', 'A', 'B', 0};
+ static final char [] TOOLBAR = new char [] {'T', 'O', 'O', 'L', 'B', 'A', 'R', 0};
static final char [] TREEVIEW = new char [] {'T', 'R', 'E', 'E', 'V', 'I', 'E', 'W', 0};
/* Focus */
@@ -2625,6 +2628,16 @@ int /*long*/ hButtonTheme () {
return hButtonTheme = OS.OpenThemeData (hwndMessage, BUTTON);
}
+int /*long*/ hControlPanelStyleTheme () {
+ if (hControlPanelStyleTheme != 0) return hControlPanelStyleTheme;
+ return hControlPanelStyleTheme = OS.OpenThemeData (hwndMessage, CONTROLPANELSTYLE);
+}
+
+int /*long*/ hCompositedWindowTheme () {
+ if (hCompositedWindowTheme != 0) return hCompositedWindowTheme;
+ return hCompositedWindowTheme = OS.OpenThemeData (hwndMessage, COMPOSITEDWINDOW);
+}
+
int /*long*/ hEditTheme () {
if (hEditTheme != 0) return hEditTheme;
return hEditTheme = OS.OpenThemeData (hwndMessage, EDIT);
@@ -2645,6 +2658,11 @@ int /*long*/ hTabTheme () {
return hTabTheme = OS.OpenThemeData (hwndMessage, TAB);
}
+int /*long*/ hToolbarTheme () {
+ if (hToolbarTheme != 0) return hToolbarTheme;
+ return hToolbarTheme = OS.OpenThemeData (hwndMessage, TOOLBAR);
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -3336,11 +3354,14 @@ int /*long*/ messageProc (int /*long*/ hwnd, int /*long*/ msg, int /*long*/ wPar
case OS.WM_THEMECHANGED: {
if (OS.COMCTL32_MAJOR >= 6) {
if (hButtonTheme != 0) OS.CloseThemeData (hButtonTheme);
+ if (hControlPanelStyleTheme != 0) OS.CloseThemeData (hControlPanelStyleTheme);
+ if (hCompositedWindowTheme != 0) OS.CloseThemeData (hCompositedWindowTheme);
if (hEditTheme != 0) OS.CloseThemeData (hEditTheme);
if (hExplorerBarTheme != 0) OS.CloseThemeData (hExplorerBarTheme);
if (hScrollBarTheme != 0) OS.CloseThemeData (hScrollBarTheme);
if (hTabTheme != 0) OS.CloseThemeData (hTabTheme);
- hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0;
+ if (hToolbarTheme != 0) OS.CloseThemeData (hToolbarTheme);
+ hButtonTheme = hControlPanelStyleTheme = hCompositedWindowTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = hToolbarTheme = 0;
}
break;
}
@@ -3828,11 +3849,14 @@ void releaseDisplay () {
/* Release XP Themes */
if (OS.COMCTL32_MAJOR >= 6) {
if (hButtonTheme != 0) OS.CloseThemeData (hButtonTheme);
+ if (hControlPanelStyleTheme != 0) OS.CloseThemeData (hControlPanelStyleTheme);
+ if (hCompositedWindowTheme != 0) OS.CloseThemeData (hCompositedWindowTheme);
if (hEditTheme != 0) OS.CloseThemeData (hEditTheme);
if (hExplorerBarTheme != 0) OS.CloseThemeData (hExplorerBarTheme);
if (hScrollBarTheme != 0) OS.CloseThemeData (hScrollBarTheme);
if (hTabTheme != 0) OS.CloseThemeData (hTabTheme);
- hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0;
+ if (hToolbarTheme != 0) OS.CloseThemeData (hToolbarTheme);
+ hButtonTheme = hControlPanelStyleTheme = hCompositedWindowTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = hToolbarTheme = 0;
}
/* Unhook the message hook */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index bfebc22..bc811f9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -51,7 +51,7 @@ public class Label extends Control {
String text = "";
Image image;
static final int MARGIN = 4;
- static /*final*/ boolean IMAGE_AND_TEXT = true;
+ static /*final*/ boolean IMAGE_AND_TEXT = false;
static final int /*long*/ LabelProc;
static final TCHAR LabelClass = new TCHAR (0, "STATIC", true);
static {
@@ -225,7 +225,7 @@ public int getAlignment () {
boolean getBufferredPaint() {
Shell shell = getShell ();
- if (((shell.style & SWT.TRIM_FILL) != 0) && ((this.style & SWT.TRIM_FILL) != 0)){
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) {
// if (image != null) return false;//note: can't be transparent for all images...
return true;//bad: should be transparent with custom draw
}
@@ -537,6 +537,11 @@ LRESULT WM_UPDATEUISTATE (int /*long*/ wParam, int /*long*/ lParam) {
return result;
}
+LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
+ // Label widgets are owner-drawn, so this is a no-op
+ return null; // return null so that wmDrawChild gets invoked
+}
+
LRESULT wmColorChild (int /*long*/ wParam, int /*long*/ lParam) {
/*
* Bug in Windows. For some reason, the HBRUSH that
@@ -646,7 +651,7 @@ LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
int height = struct.bottom - struct.top;
if (width != 0 && height != 0) {
boolean drawImage = image != null;
- boolean drawText = IMAGE_AND_TEXT && text.length () != 0;
+ boolean drawText = text.length () != 0 && (image == null || IMAGE_AND_TEXT);
int margin = drawText && drawImage ? MARGIN : 0;
int imageWidth = 0, imageHeight = 0;
if (drawImage) {
@@ -696,10 +701,13 @@ LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
rect.right += rect.left;
rect.top = Math.max (0, (height - textHeight) / 2);
rect.bottom += rect.top;
- if ((this.style & SWT.TRIM_FILL) == 0) {
+ if ((style & SWT.TRIM_FILL) == 0) {
OS.DrawText (struct.hDC, buffer, -1, rect, flags);
} else {
- drawBufferredText (struct.hDC, buffer, rect, flags);
+ int /*long*/ hFont = OS.SendMessage(this.handle, OS.WM_GETFONT, 0, 0);
+ int color = 0x000000;
+ int dwFlags = 0;
+ drawBufferredText(struct.hDC, buffer, rect, hFont, color, dwFlags);
}
}
}
@@ -707,53 +715,4 @@ LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
return null;
}
-LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
- // Label widgets are owner-drawn, so this is a no-op
- return null; // return null so that wmDrawChild gets invoked
-}
-
-int getThemeGlowSize () {
- int /*long*/ hTheme = OS.OpenThemeData(0, "CompositedWindow::Window;".toCharArray());
- int [] glowSize = new int[1];
- OS.GetThemeInt(hTheme, 0, 0, OS.TMT_TEXTGLOWSIZE, glowSize);
- OS.CloseThemeData(hTheme);
- return glowSize[0] > 0 ? glowSize[0] : 12;
-}
-
-void drawBufferredText (int /*long*/ targetDC, TCHAR textBuffer, RECT rect, int dwFlags) {
- // set up the buffered device context - the background is painted entirely black and its alpha
- // is set to zero, resulting in a device context that is 100% transparent (if nothing is drawn to this DC,
- // the glass background will just render through)
- int /*long*/ [] hdcBuffered = new int /*long*/ [1];
- int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(targetDC, rect, OS.BPBF_TOPDOWNDIB, null, hdcBuffered);
- OS.PatBlt(hdcBuffered[0], 0, 0, rect.right /* - rect.left */, rect.bottom /* - rect.top */, OS.BLACKNESS);
- OS.BufferedPaintSetAlpha(hBufferedPaint, rect, (byte)0x00);
-
- // setup the DTTOPTS structure for calling into DrawThemeTextEx - note how we call getThemeGlowSize()
- // to apply a glow around the text we are drawing to enhance readability of the text against a glass background
- DTTOPTS dttOpts = new DTTOPTS();
- dttOpts.dwSize = DTTOPTS.sizeof;
- dttOpts.dwFlags = OS.DTT_COMPOSITED | OS.DTT_GLOWSIZE;
- dttOpts.crText = 0x00FFFFFF;
- dttOpts.iGlowSize = getThemeGlowSize ();
-
- // select the window's font into the buffered device context
- int /*long*/ hFont = OS.SendMessage(this.handle, OS.WM_GETFONT, 0, 0);
- if (hFont != 0) {
- hFont = OS.SelectObject(hdcBuffered[0], hFont);
- }
-
- // draw the text using the special DrawThemeTextEx call
- int /*long*/ hTheme = OS.OpenThemeData(0, "ControlPanelStyle;".toCharArray());
- OS.DrawThemeTextEx(hTheme, hdcBuffered[0], 0, 0, textBuffer.chars, textBuffer.length(), dwFlags, rect, dttOpts);
- OS.CloseThemeData(hTheme);
-
- // restore the font
- if (hFont != 0) {
- OS.SelectObject(hdcBuffered[0], hFont);
- }
-
- OS.EndBufferedPaint(hBufferedPaint, true);
-
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
index bec112c..9d5afc1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -146,6 +146,14 @@ int defaultForeground () {
return OS.GetSysColor (OS.COLOR_HIGHLIGHT);
}
+boolean getBufferredPaint() {
+ Shell shell = getShell ();
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) {
+ return true;
+ }
+ return false;
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -445,14 +453,6 @@ LRESULT WM_TIMER (int /*long*/ wParam, int /*long*/ lParam) {
return result;
}
-boolean getBufferredPaint() {
- Shell shell = getShell ();
- if (((shell.style & SWT.TRIM_FILL) != 0) && ((this.style & SWT.TRIM_FILL) != 0)) {
- return true;
- }
- return false;
-}
-
LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
int /*long*/ paintDC = 0;
PAINTSTRUCT ps = new PAINTSTRUCT ();
@@ -467,7 +467,7 @@ LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lP
if (hdcBuffered[0] != 0) {
// ask the ProgressBar control to render itself into the buffered device context, entirely opaquely
- OS.SendMessage(this.handle, OS.WM_PRINTCLIENT, hdcBuffered[0], OS.PRF_CLIENT);
+ OS.SendMessage(handle, OS.WM_PRINTCLIENT, hdcBuffered[0], OS.PRF_CLIENT);
OS.BufferedPaintSetAlpha(hBufferedPaint, rect, (byte)0xFF); // 100% opaque
// round off the corners by drawing them as transparent single pixels
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 54af7c2..f25fc96 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
@@ -114,6 +114,9 @@ public class Text extends Scrollable {
// PASSWORD = echo != 0 ? echo : '*';
}
+ // this flag is used to prevent the Text#wmColorChild method from triggering a perpetual series of repaints
+ private boolean bPrintingClient = false;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -660,6 +663,14 @@ public int getBorderWidth () {
return super.getBorderWidth ();
}
+boolean getBufferredPaint() {
+ Shell shell = getShell ();
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) {
+ return true;
+ }
+ return false;
+}
+
/**
* Returns the line number of the caret.
* <p>
@@ -2488,6 +2499,35 @@ LRESULT WM_UNDO (int /*long*/ wParam, int /*long*/ lParam) {
return wmClipboard (OS.WM_UNDO, wParam, lParam);
}
+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 will be 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(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;
+}
+
LRESULT wmClipboard (int msg, int /*long*/ wParam, int /*long*/ lParam) {
if ((style & SWT.READ_ONLY) != 0) return null;
if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return null;
@@ -2590,10 +2630,10 @@ 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) {
+ if (getBufferredPaint() && !bPrintingClient) {
RECT lpRect = new RECT();
- OS.GetClientRect(this.handle, lpRect);
- OS.InvalidateRect(this.handle, lpRect, false);
+ OS.GetClientRect(handle, lpRect);
+ OS.InvalidateRect(handle, lpRect, false);
}
return super.wmColorChild (wParam, lParam);
@@ -2648,44 +2688,4 @@ 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 triggering a perpetual 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 will be 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;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index e93d88e..260cc42 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -478,6 +478,14 @@ void enableWidget (boolean enabled) {
}
}
+boolean getBufferredPaint() {
+ Shell shell = getShell ();
+ if ((shell.style & SWT.TRIM_FILL) != 0 && (style & SWT.TRIM_FILL) != 0) {
+ return true;
+ }
+ return false;
+}
+
ImageList getDisabledImageList () {
return disabledImageList;
}
@@ -1493,6 +1501,11 @@ LRESULT WM_WINDOWPOSCHANGING (int /*long*/ wParam, int /*long*/ lParam) {
return result;
}
+LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
+ // toolbar items are owner-draw during buffered painting
+ return null;
+}
+
LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
ToolItem child = items [OS.LOWORD (wParam)];
if (child == null) return null;
@@ -1564,7 +1577,7 @@ LRESULT wmNotifyChild (NMHDR hdr, int /*long*/ wParam, int /*long*/ lParam) {
}
case OS.CDDS_ITEMPREPAINT: {
if (getBufferredPaint ()) {
- // each ToolItem knows how to draw themself in an Aero/Glass friendly manner
+ // each ToolItem knows how to draw itself in an Aero/Glass friendly manner
ToolItem childItem = items [(int)/*64*/nmcd.dwItemSpec];
if (childItem != null) {
childItem.wmBufferedPaint (handle, wParam, lParam);
@@ -1617,17 +1630,4 @@ LRESULT wmNotifyChild (NMHDR hdr, int /*long*/ wParam, int /*long*/ lParam) {
return super.wmNotifyChild (hdr, wParam, lParam);
}
-boolean getBufferredPaint() {
- Shell shell = getShell ();
- if (((shell.style & SWT.TRIM_FILL) != 0) && ((this.style & SWT.TRIM_FILL) != 0)) {
- return true;
- }
- return false;
-}
-
-LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
- // toolbar items are owner-draw during buffered painting
- return null;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
index 39b759f..1140fc7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -47,7 +47,7 @@ public class ToolItem extends Item {
short cx;
// added to support the owner-draw operations performed in an Aero/Glass environment
- static final int MARGIN = 4;
+ static final int OWNERDRAW_MARGIN = 4;
/**
* Constructs a new instance of this class given its parent
@@ -223,6 +223,54 @@ void destroyWidget () {
releaseHandle ();
}
+/*
+ * Translates the item state into the equivalent button state.
+ * @param nmcd - the NMCUSTOMDRAW structure passed into owner-draw toolbar items
+ * @return
+ */
+int determineButtonState (NMCUSTOMDRAW nmcd) {
+ int btnState = OS.TS_NORMAL;
+
+ // translate the button state depending on the incoming item state
+ if ((nmcd.uItemState & OS.CDIS_HOT) != 0 && (nmcd.uItemState & OS.CDIS_CHECKED) != 0) { btnState = OS.TS_HOTCHECKED; }
+ else if ((nmcd.uItemState & OS.CDIS_HOT) != 0 && (nmcd.uItemState & OS.CDIS_SELECTED) != 0) {btnState = OS.TS_PRESSED; }
+ else if ((nmcd.uItemState & OS.CDIS_HOT) != 0) { btnState = OS.TS_HOT; }
+ else if ((nmcd.uItemState & OS.CDIS_SELECTED) != 0) { btnState = OS.TS_PRESSED; }
+ else if ((nmcd.uItemState & OS.CDIS_CHECKED) != 0) { btnState = OS.TS_CHECKED; }
+ return btnState;
+}
+
+/*
+ * Draws the outline of the ToolItem. This will make the ToolItem appear as pressed, checked, hot or normal depending
+ * on the UI state of the toolbar item.
+ * @param hDC - device context to paint in
+ * @param nmcd - the NMCUSTOMDRAW structure passed into owner-draw toolbar items
+ */
+void drawItemOutline (int /*long*/ hDC, NMCUSTOMDRAW nmcd) {
+ RECT rectClient = new RECT();
+ OS.SetRect (rectClient, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
+
+ // setup the theme parameters
+ int /*long*/ hTheme = display.hToolbarTheme();
+ int btnState = determineButtonState(nmcd);
+
+ // draw the button outline, depending on if it's a regular button or a drop-down button
+ if ((style & SWT.DROP_DOWN) != 0) {
+ // drop-down button: left half is a button with a right edge that is not rounded
+ int dropDownWidth = OS.GetSystemMetrics(OS.SM_CXVSCROLL);
+ rectClient.right -= dropDownWidth;
+ OS.DrawThemeBackground(hTheme, hDC, OS.TP_SPLITBUTTON, btnState, rectClient, null);
+
+ // drop-down button: right half is where the arrow is drawn
+ rectClient.left = rectClient.right;
+ rectClient.right += dropDownWidth;
+ OS.DrawThemeBackground(hTheme, hDC, OS.TP_SPLITBUTTONDROPDOWN, btnState, rectClient, null);
+ } else {
+ // regular button
+ OS.DrawThemeBackground(hTheme, hDC, OS.TP_BUTTON, btnState, rectClient, null);
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -1011,17 +1059,7 @@ int widgetStyle () {
return OS.BTNS_BUTTON;
}
-LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- sendSelectionEvent (SWT.Selection);
- return null;
-}
-
-/**
+/*
* Owner-draw painting of the ToolItem. Used in a shell where Aero/Glass painting has been turned on.
*/
LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lParam) {
@@ -1036,8 +1074,8 @@ LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lP
final boolean drawImage = image != null;
final boolean drawText = text.length () != 0;
final boolean drawTextBelow = (parent.style & SWT.RIGHT) == 0;
- final boolean drawDepressed = this.determineButtonState(nmcd) == OS.TS_HOTCHECKED || this.determineButtonState(nmcd) == OS.TS_CHECKED || this.determineButtonState(nmcd) == OS.TS_PRESSED;
- final int margin = drawText && drawImage && !drawTextBelow ? MARGIN : 0;
+ final boolean drawDepressed = determineButtonState(nmcd) == OS.TS_HOTCHECKED || determineButtonState(nmcd) == OS.TS_CHECKED || determineButtonState(nmcd) == OS.TS_PRESSED;
+ final int margin = drawText && drawImage && !drawTextBelow ? OWNERDRAW_MARGIN : 0;
final int width = rectClient.right - rectClient.left;
final int height = rectClient.bottom - rectClient.top;
final TCHAR textBuffer = new TCHAR (parent.getCodePage (), text, true);
@@ -1093,17 +1131,17 @@ LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lP
GCData data = new GCData();
data.device = display;
GC gc = GC.win32_new (hDC, data);
- Image image = getEnabled () ? this.image : (this.disabledImage != null) ? this.disabledImage : this.image;
+ Image image = getEnabled () ? this.image : (disabledImage != null) ? disabledImage : this.image;
gc.drawImage (image, x, y);
gc.dispose ();
}
// calculate the text (x,y) coordinate
if (drawTextBelow) {
- x = rectClient.left + MARGIN;
- y = height - textHeight - MARGIN;
+ x = rectClient.left + OWNERDRAW_MARGIN;
+ y = height - textHeight - OWNERDRAW_MARGIN;
} else {
- x += imageWidth + MARGIN;
+ x += imageWidth + OWNERDRAW_MARGIN;
y = rectClient.top + Math.max (0, (height - textHeight) / 2);
}
if (drawDepressed) {
@@ -1130,54 +1168,13 @@ LRESULT wmBufferedPaint (int /*long*/ hWnd, int /*long*/ wParam, int /*long*/ lP
return LRESULT.ZERO;
}
-/*
- * Draws the outline of the ToolItem. This will make the ToolItem appear as pressed, checked, hot or normal depending
- * on the UI state of the toolbar item.
- * @param hDC - device context to paint in
- * @param nmcd - the NMCUSTOMDRAW structure passed into owner-draw toolbar items
- */
-void drawItemOutline (int /*long*/ hDC, NMCUSTOMDRAW nmcd) {
- RECT rectClient = new RECT();
- OS.SetRect (rectClient, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
-
- // setup the theme parameters
- int /*long*/ hTheme = OS.OpenThemeData(0, "Toolbar;".toCharArray());
- int btnState = determineButtonState(nmcd);
-
- // draw the button outline, depending on if it's a regular button or a drop-down button
- if ((style & SWT.DROP_DOWN) != 0) {
- // drop-down button: left half is a button with a right edge that is not rounded
- int dropDownWidth = OS.GetSystemMetrics(OS.SM_CXVSCROLL);
- rectClient.right -= dropDownWidth;
- OS.DrawThemeBackground(hTheme, hDC, OS.TP_SPLITBUTTON, btnState, rectClient, null);
-
- // drop-down button: right half is where the arrow is drawn
- rectClient.left = rectClient.right;
- rectClient.right += dropDownWidth;
- OS.DrawThemeBackground(hTheme, hDC, OS.TP_SPLITBUTTONDROPDOWN, btnState, rectClient, null);
- } else {
- // regular button
- OS.DrawThemeBackground(hTheme, hDC, OS.TP_BUTTON, btnState, rectClient, null);
+LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
}
-
- OS.CloseThemeData(hTheme);
-}
-
-/*
- * Translates the item state into the equivalent button state.
- * @param nmcd - the NMCUSTOMDRAW structure passed into owner-draw toolbar items
- * @return
- */
-int determineButtonState (NMCUSTOMDRAW nmcd) {
- int btnState = OS.TS_NORMAL;
-
- // translate the button state depending on the incoming item state
- if ((nmcd.uItemState & OS.CDIS_HOT) != 0 && (nmcd.uItemState & OS.CDIS_CHECKED) != 0) { btnState = OS.TS_HOTCHECKED; }
- else if ((nmcd.uItemState & OS.CDIS_HOT) != 0 && (nmcd.uItemState & OS.CDIS_SELECTED) != 0) {btnState = OS.TS_PRESSED; }
- else if ((nmcd.uItemState & OS.CDIS_HOT) != 0) { btnState = OS.TS_HOT; }
- else if ((nmcd.uItemState & OS.CDIS_SELECTED) != 0) { btnState = OS.TS_PRESSED; }
- else if ((nmcd.uItemState & OS.CDIS_CHECKED) != 0) { btnState = OS.TS_CHECKED; }
- return btnState;
+ sendSelectionEvent (SWT.Selection);
+ return null;
}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 7e8c52b..66d1d8c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -456,6 +456,39 @@ boolean dragDetect (int /*long*/ hwnd, int x, int y, boolean filter, boolean []
return OS.DragDetect (hwnd, pt);
}
+void drawBufferredText (int /*long*/ targetDC, TCHAR textBuffer, RECT rect, int /*long*/ hFont, int color, int dwFlags) {
+ // set up the buffered device context - the background is painted entirely black and its alpha
+ // is set to zero, resulting in a device context that is 100% transparent (if nothing is drawn to this DC,
+ // the glass background will just render through)
+ int /*long*/ [] hdcBuffered = new int /*long*/ [1];
+ int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(targetDC, rect, OS.BPBF_TOPDOWNDIB, null, hdcBuffered);
+ OS.PatBlt (hdcBuffered [0], 0, 0, rect.right /* - rect.left */, rect.bottom /* - rect.top */, OS.BLACKNESS);
+ OS.BufferedPaintSetAlpha (hBufferedPaint, rect, (byte)0x00);
+
+ // setup the DTTOPTS structure for calling into DrawThemeTextEx - note how we call getThemeGlowSize()
+ // to apply a glow around the text we are drawing to enhance readability of the text against a glass background
+ DTTOPTS dttOpts = new DTTOPTS();
+ dttOpts.dwSize = DTTOPTS.sizeof;
+ dttOpts.dwFlags = OS.DTT_COMPOSITED | OS.DTT_GLOWSIZE | OS.DTT_TEXTCOLOR;
+ dttOpts.crText = color;
+ dttOpts.iGlowSize = getThemeGlowSize ();
+
+ OS.SetTextColor(hdcBuffered[0], color);
+ if (hFont != 0) {
+ hFont = OS.SelectObject(hdcBuffered[0], hFont);
+ }
+
+ // draw the text using the special DrawThemeTextEx call
+ int /*long*/ hTheme = display.hControlPanelStyleTheme();
+ OS.DrawThemeTextEx(hTheme, hdcBuffered[0], 0, 0, textBuffer.chars, textBuffer.length(), dwFlags, rect, dttOpts);
+
+ if (hFont != 0) {
+ OS.SelectObject(hdcBuffered[0], hFont);
+ }
+ OS.EndBufferedPaint(hBufferedPaint, true);
+
+}
+
/**
* Does whatever widget specific cleanup is required, and then
* uses the code in <code>SWTError.error</code> to handle the error.
@@ -641,6 +674,13 @@ String getNameText () {
return ""; //$NON-NLS-1$
}
+int getThemeGlowSize () {
+ int /*long*/ hTheme = display.hCompositedWindowTheme();
+ int [] glowSize = new int[1];
+ OS.GetThemeInt(hTheme, 0, 0, OS.TMT_TEXTGLOWSIZE, glowSize);
+ return glowSize[0] > 0 ? glowSize[0] : 12;
+}
+
/**
* Returns the receiver's style information.
* <p>
@@ -2682,46 +2722,4 @@ LRESULT wmXButtonUp (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lParam
}
return result;
}
-
-int getThemeGlowSize () {
- int /*long*/ hTheme = OS.OpenThemeData(0, "CompositedWindow::Window;".toCharArray());
- int [] glowSize = new int[1];
- OS.GetThemeInt(hTheme, 0, 0, OS.TMT_TEXTGLOWSIZE, glowSize);
- OS.CloseThemeData(hTheme);
- return glowSize[0] > 0 ? glowSize[0] : 12;
-}
-
-void drawBufferredText (int /*long*/ targetDC, TCHAR textBuffer, RECT rect, int /*long*/ hFont, int color, int dwFlags) {
- // set up the buffered device context - the background is painted entirely black and its alpha
- // is set to zero, resulting in a device context that is 100% transparent (if nothing is drawn to this DC,
- // the glass background will just render through)
- int /*long*/ [] hdcBuffered = new int /*long*/ [1];
- int /*long*/ hBufferedPaint = OS.BeginBufferedPaint(targetDC, rect, OS.BPBF_TOPDOWNDIB, null, hdcBuffered);
- OS.PatBlt (hdcBuffered [0], 0, 0, rect.right /* - rect.left */, rect.bottom /* - rect.top */, OS.BLACKNESS);
- OS.BufferedPaintSetAlpha (hBufferedPaint, rect, (byte)0x00);
-
- // setup the DTTOPTS structure for calling into DrawThemeTextEx - note how we call getThemeGlowSize()
- // to apply a glow around the text we are drawing to enhance readability of the text against a glass background
- DTTOPTS dttOpts = new DTTOPTS();
- dttOpts.dwSize = DTTOPTS.sizeof;
- dttOpts.dwFlags = OS.DTT_COMPOSITED | OS.DTT_GLOWSIZE | OS.DTT_TEXTCOLOR;
- dttOpts.crText = color;
- dttOpts.iGlowSize = getThemeGlowSize ();
-
- OS.SetTextColor(hdcBuffered[0], color);
- if (hFont != 0) {
- hFont = OS.SelectObject(hdcBuffered[0], hFont);
- }
-
- // draw the text using the special DrawThemeTextEx call
- int /*long*/ hTheme = OS.OpenThemeData(0, "ControlPanelStyle;".toCharArray());
- OS.DrawThemeTextEx(hTheme, hdcBuffered[0], 0, 0, textBuffer.chars, textBuffer.length(), dwFlags, rect, dttOpts);
- OS.CloseThemeData(hTheme);
-
- if (hFont != 0) {
- OS.SelectObject(hdcBuffered[0], hFont);
- }
- OS.EndBufferedPaint(hBufferedPaint, true);
-
-}
}