< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Checkbox.cpp

Print this page


   1 /*
   2  * Copyright (c) 1996, 2014, 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


 273         }
 274     }
 275 
 276     /* Draw focus rect */
 277     RECT focusRect;
 278     const int margin = 2; /*  2 is a heuristic number */
 279 
 280     focusRect.left = (GetRTL()) ? rect.right - checkSize - checkSize / 4 -
 281                                       2 * margin - size.cx
 282                                 : rect.left - margin;
 283     focusRect.top = (rect.top+rect.bottom-size.cy)/2;
 284     focusRect.right = (GetRTL()) ? rect.right - checkSize - checkSize / 4 +
 285                                       margin
 286                                  : focusRect.left + size.cx + 2 * margin;
 287     focusRect.bottom = focusRect.top + size.cy;
 288 
 289     /*  draw focus rect */
 290     if ((drawInfo.itemState & ODS_FOCUS) &&
 291         ((drawInfo.itemAction & ODA_FOCUS)||
 292          (drawInfo.itemAction &ODA_DRAWENTIRE))) {
 293         VERIFY(::DrawFocusRect(hDC, &focusRect));

 294     }
 295     /*  erase focus rect */
 296     else if (!(drawInfo.itemState & ODS_FOCUS) &&
 297              (drawInfo.itemAction & ODA_FOCUS)) {
 298         VERIFY(::DrawFocusRect(hDC, &focusRect));

 299     }
 300 
 301     /*  Notify any subclasses */
 302     rect = drawInfo.rcItem;
 303     DoCallback("handlePaint", "(IIII)V", rect.left, rect.top,
 304                rect.right-rect.left, rect.bottom-rect.top);
 305 
 306     env->DeleteLocalRef(target);
 307     env->DeleteLocalRef(font);
 308     env->DeleteLocalRef(str);
 309     env->DeleteLocalRef(group);
 310 
 311     return mrConsume;
 312 }
 313 
 314 MsgRouting AwtCheckbox::WmPaint(HDC)
 315 {
 316     /*  Suppress peer notification, because it's handled in WmDrawItem. */
 317     return mrDoDefault;
 318 }


   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


 273         }
 274     }
 275 
 276     /* Draw focus rect */
 277     RECT focusRect;
 278     const int margin = 2; /*  2 is a heuristic number */
 279 
 280     focusRect.left = (GetRTL()) ? rect.right - checkSize - checkSize / 4 -
 281                                       2 * margin - size.cx
 282                                 : rect.left - margin;
 283     focusRect.top = (rect.top+rect.bottom-size.cy)/2;
 284     focusRect.right = (GetRTL()) ? rect.right - checkSize - checkSize / 4 +
 285                                       margin
 286                                  : focusRect.left + size.cx + 2 * margin;
 287     focusRect.bottom = focusRect.top + size.cy;
 288 
 289     /*  draw focus rect */
 290     if ((drawInfo.itemState & ODS_FOCUS) &&
 291         ((drawInfo.itemAction & ODA_FOCUS)||
 292          (drawInfo.itemAction &ODA_DRAWENTIRE))) {
 293         if(::DrawFocusRect(hDC, &focusRect) == 0)
 294             VERIFY(::GetLastError() == 0);
 295     }
 296     /*  erase focus rect */
 297     else if (!(drawInfo.itemState & ODS_FOCUS) &&
 298              (drawInfo.itemAction & ODA_FOCUS)) {
 299         if(::DrawFocusRect(hDC, &focusRect) == 0)
 300             VERIFY(::GetLastError() == 0);
 301     }
 302 
 303     /*  Notify any subclasses */
 304     rect = drawInfo.rcItem;
 305     DoCallback("handlePaint", "(IIII)V", rect.left, rect.top,
 306                rect.right-rect.left, rect.bottom-rect.top);
 307 
 308     env->DeleteLocalRef(target);
 309     env->DeleteLocalRef(font);
 310     env->DeleteLocalRef(str);
 311     env->DeleteLocalRef(group);
 312 
 313     return mrConsume;
 314 }
 315 
 316 MsgRouting AwtCheckbox::WmPaint(HDC)
 317 {
 318     /*  Suppress peer notification, because it's handled in WmDrawItem. */
 319     return mrDoDefault;
 320 }


< prev index next >