1 /*
2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
225
226 /* Check whether the button is disabled. */
227 BOOL bEnabled = isEnabled();
228
229 int adjust = (nState & DFCS_PUSHED) ? 1 : 0;
230 int x = (rect.left + rect.right-size.cx) / 2 + adjust;
231 int y = (rect.top + rect.bottom-size.cy) / 2 + adjust;
232
233 if (bEnabled) {
234 AwtComponent::DrawWindowText(hDC, font, str, x, y);
235 } else {
236 AwtComponent::DrawGrayText(hDC, font, str, x, y);
237 }
238
239 /* Draw focus rect */
240 if (drawInfo.itemState & ODS_FOCUS){
241 const int inf = 3; /* heuristic decision */
242 RECT focusRect;
243 VERIFY(::CopyRect(&focusRect, &rect));
244 VERIFY(::InflateRect(&focusRect,-inf,-inf));
245 VERIFY(::DrawFocusRect(hDC, &focusRect));
246 }
247
248 /* Notify any subclasses */
249 DoCallback("handlePaint", "(IIII)V", rect.left, rect.top,
250 rect.right-rect.left, rect.bottom-rect.top);
251
252 env->DeleteLocalRef(target);
253 env->DeleteLocalRef(font);
254 env->DeleteLocalRef(str);
255
256 return mrConsume;
257 }
258
259 MsgRouting AwtButton::WmPaint(HDC)
260 {
261 /* Suppress peer notification, because it's handled in WmDrawItem. */
262 return mrDoDefault;
263 }
264
265 BOOL AwtButton::IsFocusingMouseMessage(MSG *pMsg) {
|
1 /*
2 * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
225
226 /* Check whether the button is disabled. */
227 BOOL bEnabled = isEnabled();
228
229 int adjust = (nState & DFCS_PUSHED) ? 1 : 0;
230 int x = (rect.left + rect.right-size.cx) / 2 + adjust;
231 int y = (rect.top + rect.bottom-size.cy) / 2 + adjust;
232
233 if (bEnabled) {
234 AwtComponent::DrawWindowText(hDC, font, str, x, y);
235 } else {
236 AwtComponent::DrawGrayText(hDC, font, str, x, y);
237 }
238
239 /* Draw focus rect */
240 if (drawInfo.itemState & ODS_FOCUS){
241 const int inf = 3; /* heuristic decision */
242 RECT focusRect;
243 VERIFY(::CopyRect(&focusRect, &rect));
244 VERIFY(::InflateRect(&focusRect,-inf,-inf));
245 if(::DrawFocusRect(hDC, &focusRect) == 0)
246 VERIFY(::GetLastError() == 0);
247 }
248
249 /* Notify any subclasses */
250 DoCallback("handlePaint", "(IIII)V", rect.left, rect.top,
251 rect.right-rect.left, rect.bottom-rect.top);
252
253 env->DeleteLocalRef(target);
254 env->DeleteLocalRef(font);
255 env->DeleteLocalRef(str);
256
257 return mrConsume;
258 }
259
260 MsgRouting AwtButton::WmPaint(HDC)
261 {
262 /* Suppress peer notification, because it's handled in WmDrawItem. */
263 return mrDoDefault;
264 }
265
266 BOOL AwtButton::IsFocusingMouseMessage(MSG *pMsg) {
|