2 * Copyright 2000-2016 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ui.plaf.gtk;
18 import com.intellij.util.ui.UIUtil;
19 import sun.swing.SwingUtilities2;
22 import javax.swing.plaf.MenuItemUI;
23 import javax.swing.plaf.synth.ColorType;
24 import javax.swing.plaf.synth.SynthContext;
25 import javax.swing.plaf.synth.SynthUI;
28 public class GtkPaintingUtil {
29 private GtkPaintingUtil() { }
31 public static void paintDisabledText(final SynthUI originalUI,
33 final JMenuItem menuItem,
34 final Rectangle textRect,
36 final FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
37 final int index = menuItem.getDisplayedMnemonicIndex();
39 final SynthContext context = originalUI.getContext(menuItem);
40 final Color fg = context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND);
41 final Color shadow = UIUtil.shade(menuItem.getBackground(), 1.24, 0.5);
44 SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x + 1, textRect.y + fm.getAscent() + 1);
46 SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x, textRect.y + fm.getAscent());
49 public static SynthContext getSynthContext(final MenuItemUI ui, final JComponent item) {
50 return ((SynthUI)ui).getContext(item);