1 /*
2 * Copyright (c) 2002, 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
621 if (icon != null) {
622 Rectangle iconRect = lr.getIconRect();
623 paintIcon(icon, lh.getContext(), g, iconRect.x,
624 iconRect.y, iconRect.width, iconRect.height);
625 }
626 }
627 }
628
629 static void paintCheckIcon(Graphics g, SynthMenuItemLayoutHelper lh,
630 MenuItemLayoutHelper.LayoutResult lr) {
631 if (lh.getCheckIcon() != null) {
632 Rectangle checkRect = lr.getCheckRect();
633 paintIcon(lh.getCheckIcon(), lh.getContext(), g,
634 checkRect.x, checkRect.y, checkRect.width, checkRect.height);
635 }
636 }
637
638 static void paintAccText(Graphics g, SynthMenuItemLayoutHelper lh,
639 MenuItemLayoutHelper.LayoutResult lr) {
640 String accText = lh.getAccText();
641 if (accText != null && !accText.equals("")) {
642 g.setColor(lh.getAccStyle().getColor(lh.getAccContext(),
643 ColorType.TEXT_FOREGROUND));
644 g.setFont(lh.getAccStyle().getFont(lh.getAccContext()));
645 lh.getAccGraphicsUtils().paintText(lh.getAccContext(), g, accText,
646 lr.getAccRect().x, lr.getAccRect().y, -1);
647 }
648 }
649
650 static void paintText(Graphics g, SynthMenuItemLayoutHelper lh,
651 MenuItemLayoutHelper.LayoutResult lr) {
652 if (!lh.getText().equals("")) {
653 if (lh.getHtmlView() != null) {
654 // Text is HTML
655 lh.getHtmlView().paint(g, lr.getTextRect());
656 } else {
657 // Text isn't HTML
658 g.setColor(lh.getStyle().getColor(
659 lh.getContext(), ColorType.TEXT_FOREGROUND));
660 g.setFont(lh.getStyle().getFont(lh.getContext()));
661 lh.getGraphicsUtils().paintText(lh.getContext(), g, lh.getText(),
662 lr.getTextRect().x, lr.getTextRect().y,
663 lh.getMenuItem().getDisplayedMnemonicIndex());
664 }
665 }
666 }
667
668 static void paintArrowIcon(Graphics g, SynthMenuItemLayoutHelper lh,
669 MenuItemLayoutHelper.LayoutResult lr) {
670 if (lh.getArrowIcon() != null) {
671 Rectangle arrowRect = lr.getArrowRect();
672 paintIcon(lh.getArrowIcon(), lh.getContext(), g,
|
1 /*
2 * Copyright (c) 2002, 2019, 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
621 if (icon != null) {
622 Rectangle iconRect = lr.getIconRect();
623 paintIcon(icon, lh.getContext(), g, iconRect.x,
624 iconRect.y, iconRect.width, iconRect.height);
625 }
626 }
627 }
628
629 static void paintCheckIcon(Graphics g, SynthMenuItemLayoutHelper lh,
630 MenuItemLayoutHelper.LayoutResult lr) {
631 if (lh.getCheckIcon() != null) {
632 Rectangle checkRect = lr.getCheckRect();
633 paintIcon(lh.getCheckIcon(), lh.getContext(), g,
634 checkRect.x, checkRect.y, checkRect.width, checkRect.height);
635 }
636 }
637
638 static void paintAccText(Graphics g, SynthMenuItemLayoutHelper lh,
639 MenuItemLayoutHelper.LayoutResult lr) {
640 String accText = lh.getAccText();
641 if (accText != null && !accText.isEmpty()) {
642 g.setColor(lh.getAccStyle().getColor(lh.getAccContext(),
643 ColorType.TEXT_FOREGROUND));
644 g.setFont(lh.getAccStyle().getFont(lh.getAccContext()));
645 lh.getAccGraphicsUtils().paintText(lh.getAccContext(), g, accText,
646 lr.getAccRect().x, lr.getAccRect().y, -1);
647 }
648 }
649
650 static void paintText(Graphics g, SynthMenuItemLayoutHelper lh,
651 MenuItemLayoutHelper.LayoutResult lr) {
652 if (!lh.getText().isEmpty()) {
653 if (lh.getHtmlView() != null) {
654 // Text is HTML
655 lh.getHtmlView().paint(g, lr.getTextRect());
656 } else {
657 // Text isn't HTML
658 g.setColor(lh.getStyle().getColor(
659 lh.getContext(), ColorType.TEXT_FOREGROUND));
660 g.setFont(lh.getStyle().getFont(lh.getContext()));
661 lh.getGraphicsUtils().paintText(lh.getContext(), g, lh.getText(),
662 lr.getTextRect().x, lr.getTextRect().y,
663 lh.getMenuItem().getDisplayedMnemonicIndex());
664 }
665 }
666 }
667
668 static void paintArrowIcon(Graphics g, SynthMenuItemLayoutHelper lh,
669 MenuItemLayoutHelper.LayoutResult lr) {
670 if (lh.getArrowIcon() != null) {
671 Rectangle arrowRect = lr.getArrowRect();
672 paintIcon(lh.getArrowIcon(), lh.getContext(), g,
|