looks-2.2.0

 x1)
  {
    this(x0);
  }
  
  public void propertyChange(PropertyChangeEvent evt)
  {
    WindowsComboBoxUI.access$1002(this$0, WindowsComboBoxUI.access$1100(this$0));
    if ((WindowsComboBoxUI.access$1200(this$0).getRenderer() == null) || ((WindowsComboBoxUI.access$1300(this$0).getRenderer() instanceof UIResource))) {
      WindowsComboBoxUI.access$1400(this$0).setRenderer(this$0.createRenderer());
    }
    if ((WindowsComboBoxUI.access$1500(this$0).getEditor() == null) || ((WindowsComboBoxUI.access$1600(this$0).getEditor() instanceof UIResource))) {
      WindowsComboBoxUI.access$1700(this$0).setEditor(this$0.createEditor());
    }
  }
  
  private WindowsComboBoxUI$TableCellEditorPropertyChangeHandler(WindowsComboBoxUI paramWindowsComboBoxUI) {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsComboBoxUI.TableCellEditorPropertyChangeHandler
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.plaf.basic.BasicComboBoxUI.ComboBoxLayoutManager;

final class WindowsComboBoxUI$WindowsComboBoxLayoutManager
  extends BasicComboBoxUI.ComboBoxLayoutManager
{
  private final WindowsComboBoxUI this$0;
  
  private WindowsComboBoxUI$WindowsComboBoxLayoutManager(WindowsComboBoxUI paramWindowsComboBoxUI)
  {
    super(paramWindowsComboBoxUI);
  }
  
  WindowsComboBoxUI$WindowsComboBoxLayoutManager(WindowsComboBoxUI x0, WindowsComboBoxUI.1 x1)
  {
    this(x0);
  }
  
  public void layoutContainer(Container parent)
  {
    JComboBox cb = (JComboBox)parent;
    
    int width = cb.getWidth();
    int height = cb.getHeight();
    
    Insets insets = WindowsComboBoxUI.access$300(this$0);
    int buttonWidth = WindowsComboBoxUI.access$400(this$0);
    int buttonHeight = height - (top + bottom);
    if (WindowsComboBoxUI.access$500(this$0) != null) {
      if (cb.getComponentOrientation().isLeftToRight()) {
        WindowsComboBoxUI.access$600(this$0).setBounds(width - (right + buttonWidth), top, buttonWidth, buttonHeight);
      } else {
        WindowsComboBoxUI.access$700(this$0).setBounds(left, top, buttonWidth, buttonHeight);
      }
    }
    if (WindowsComboBoxUI.access$800(this$0) != null) {
      WindowsComboBoxUI.access$900(this$0).setBounds(this$0.rectangleForCurrentValue());
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsComboBoxUI.WindowsComboBoxLayoutManager
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.plaf.basic.BasicComboPopup;

final class WindowsComboBoxUI$WindowsComboPopup
  extends BasicComboPopup
{
  WindowsComboBoxUI$WindowsComboPopup(JComboBox x0, WindowsComboBoxUI.1 x1)
  {
    this(x0);
  }
  
  private WindowsComboBoxUI$WindowsComboPopup(JComboBox combo)
  {
    super(combo);
  }
  
  protected Rectangle computePopupBounds(int px, int py, int pw, int ph)
  {
    Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
    Object popupPrototypeDisplayValue = comboBox.getClientProperty("ComboBox.popupPrototypeDisplayValue");
    if (popupPrototypeDisplayValue == null) {
      return defaultBounds;
    }
    ListCellRenderer renderer = list.getCellRenderer();
    Component c = renderer.getListCellRendererComponent(list, popupPrototypeDisplayValue, -1, true, true);
    
    pw = getPreferredSizewidth;
    boolean hasVerticalScrollBar = comboBox.getItemCount() > comboBox.getMaximumRowCount();
    if (hasVerticalScrollBar)
    {
      JScrollBar verticalBar = scroller.getVerticalScrollBar();
      pw += getPreferredSizewidth;
    }
    Rectangle prototypeBasedBounds = super.computePopupBounds(px, py, pw, ph);
    return width > width ? prototypeBasedBounds : defaultBounds;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsComboBoxUI.WindowsComboPopup
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import com.jgoodies.looks.LookUtils;
import com.sun.java.swing.plaf.windows.WindowsTextFieldUI;
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.CellRendererPane;
import javax.swing.ComboBoxEditor;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import javax.swing.plaf.basic.BasicComboBoxRenderer.UIResource;
import javax.swing.plaf.basic.BasicComboBoxUI.ComboBoxLayoutManager;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;

public class WindowsComboBoxUI
  extends com.sun.java.swing.plaf.windows.WindowsComboBoxUI
{
  private static final String CELL_EDITOR_KEY = "JComboBox.isTableCellEditor";
  private static final JTextField PHANTOM = new JTextField("Phantom");
  private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
  private static final Border EMPTY_BORDER = new EmptyBorder(EMPTY_INSETS);
  private boolean tableCellEditor;
  private PropertyChangeListener propertyChangeListener;
  
  public static ComponentUI createUI(JComponent b)
  {
    ensurePhantomHasWindowsUI();
    return new WindowsComboBoxUI();
  }
  
  private static void ensurePhantomHasWindowsUI()
  {
    if (!(PHANTOM.getUI() instanceof WindowsTextFieldUI)) {
      PHANTOM.updateUI();
    }
  }
  
  public void installUI(JComponent c)
  {
    super.installUI(c);
    tableCellEditor = isTableCellEditor();
  }
  
  protected void installListeners()
  {
    super.installListeners();
    propertyChangeListener = new TableCellEditorPropertyChangeHandler(null);
    comboBox.addPropertyChangeListener("JComboBox.isTableCellEditor", propertyChangeListener);
  }
  
  protected void uninstallListeners()
  {
    super.uninstallListeners();
    comboBox.removePropertyChangeListener("JComboBox.isTableCellEditor", propertyChangeListener);
    propertyChangeListener = null;
  }
  
  protected JButton createArrowButton()
  {
    return LookUtils.IS_LAF_WINDOWS_XP_ENABLED ? super.createArrowButton() : new WindowsArrowButton(5);
  }
  
  protected ComboBoxEditor createEditor()
  {
    return new WindowsComboBoxEditor.UIResource(tableCellEditor);
  }
  
  protected LayoutManager createLayoutManager()
  {
    return new WindowsComboBoxLayoutManager(null);
  }
  
  protected void configureEditor()
  {
    super.configureEditor();
    if (!comboBox.isEnabled()) {
      editor.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
    }
  }
  
  protected ComboPopup createPopup()
  {
    return new WindowsComboPopup(comboBox, null);
  }
  
  protected ListCellRenderer createRenderer()
  {
    if (tableCellEditor) {
      return super.createRenderer();
    }
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
    renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
    return renderer;
  }
  
  public Dimension getMinimumSize(JComponent c)
  {
    if (!isMinimumSizeDirty) {
      return new Dimension(cachedMinimumSize);
    }
    Dimension size = getDisplaySize();
    Insets insets = getInsets();
    height += top + bottom;
    int buttonWidth = getEditableButtonWidth();
    width += left + right + buttonWidth;
    
    width += 1;
    
    ListCellRenderer renderer = comboBox.getRenderer();
    if ((renderer instanceof JComponent))
    {
      JComponent component = (JComponent)renderer;
      Insets rendererInsets = component.getInsets();
      Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
      int offsetLeft = Math.max(0, left - left);
      int offsetRight = Math.max(0, right - right);
      
      width += offsetLeft + offsetRight;
    }
    Dimension textFieldSize = PHANTOM.getMinimumSize();
    height = ((LookUtils.IS_OS_WINDOWS_VISTA) && (!LookUtils.IS_LAF_WINDOWS_XP_ENABLED) ? height : Math.max(height, height));
    
    cachedMinimumSize.setSize(width, height);
    isMinimumSizeDirty = false;
    
    return new Dimension(size);
  }
  
  public Dimension getPreferredSize(JComponent c)
  {
    return getMinimumSize(c);
  }
  
  public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
  {
    ListCellRenderer renderer = comboBox.getRenderer();
    
    boolean isVistaReadOnlyCombo = isVistaXPStyleReadOnlyCombo();
    Component c;
    Component c;
    if ((hasFocus) && (!isPopupVisible(comboBox)))
    {
      c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, true, false);
    }
    else
    {
      c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
      
      c.setBackground(UIManager.getColor("ComboBox.background"));
    }
    Border oldBorder = null;
    Rectangle originalBounds = new Rectangle(bounds);
    if (((c instanceof JComponent)) && (!tableCellEditor))
    {
      JComponent component = (JComponent)c;
      if (isRendererBorderRemovable(component))
      {
        oldBorder = component.getBorder();
        component.setBorder(EMPTY_BORDER);
      }
      Insets rendererInsets = component.getInsets();
      Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
      int offsetLeft = Math.max(0, left - left);
      int offsetRight = Math.max(0, right - right);
      int offsetTop = Math.max(0, top - top);
      int offsetBottom = Math.max(0, bottom - bottom);
      x += offsetLeft;
      y += offsetTop;
      width -= offsetLeft + offsetRight - 1;
      height -= offsetTop + offsetBottom;
    }
    c.setFont(comboBox.getFont());
    if ((hasFocus) && (!isPopupVisible(comboBox)) && (!isVistaReadOnlyCombo))
    {
      c.setForeground(listBox.getSelectionForeground());
      c.setBackground(listBox.getSelectionBackground());
    }
    else if (comboBox.isEnabled())
    {
      c.setForeground(comboBox.getForeground());
      c.setBackground(comboBox.getBackground());
    }
    else
    {
      c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
      c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
    }
    boolean shouldValidate = c instanceof JPanel;
    
    Boolean oldOpaque = null;
    if ((isVistaReadOnlyCombo) && ((c instanceof JComponent)) && (!(c instanceof DefaultListCellRenderer)))
    {
      oldOpaque = Boolean.valueOf(c.isOpaque());
      ((JComponent)c).setOpaque(false);
    }
    currentValuePane.paintComponent(g, c, comboBox, x, y, width, height, shouldValidate);
    if (hasFocus)
    {
      Color oldColor = g.getColor();
      g.setColor(comboBox.getForeground());
      if (isVistaReadOnlyCombo)
      {
        int width = width - 2;
        if (width % 2 == 0) {
          width++;
        }
        WindowsUtils.drawRoundedDashedRect(g, x + 1, y + 1, width, height - 2);
      }
      g.setColor(oldColor);
    }
    if (oldOpaque != null) {
      ((JComponent)c).setOpaque(oldOpaque.booleanValue());
    }
    if (oldBorder != null) {
      ((JComponent)c).setBorder(oldBorder);
    }
  }
  
  protected boolean isRendererBorderRemovable(JComponent rendererComponent)
  {
    if ((rendererComponent instanceof BasicComboBoxRenderer.UIResource)) {
      return true;
    }
    Object hint = rendererComponent.getClientProperty("isBorderRemovable");
    if (hint != null) {
      return Boolean.TRUE.equals(hint);
    }
    Border border = rendererComponent.getBorder();
    return border instanceof EmptyBorder;
  }
  
  private boolean isVistaXPStyleReadOnlyCombo()
  {
    return (LookUtils.IS_OS_WINDOWS_VISTA) && (LookUtils.IS_LAF_WINDOWS_XP_ENABLED) && (!comboBox.isEditable());
  }
  
  protected Rectangle rectangleForCurrentValue()
  {
    int width = comboBox.getWidth();
    int height = comboBox.getHeight();
    Insets insets = getInsets();
    int buttonWidth = getEditableButtonWidth();
    if (arrowButton != null) {
      buttonWidth = arrowButton.getWidth();
    }
    if (comboBox.getComponentOrientation().isLeftToRight()) {
      return new Rectangle(left, top, width - (left + right + buttonWidth), height - (top + bottom));
    }
    return new Rectangle(left + buttonWidth, top, width - (left + right + buttonWidth), height - (top + bottom));
  }
  
  private int getEditableButtonWidth()
  {
    return UIManager.getInt("ScrollBar.width");
  }
  
  private boolean isTableCellEditor()
  {
    return Boolean.TRUE.equals(comboBox.getClientProperty("JComboBox.isTableCellEditor"));
  }
  
  private final class WindowsComboBoxLayoutManager
    extends BasicComboBoxUI.ComboBoxLayoutManager
  {
    private WindowsComboBoxLayoutManager()
    {
      super();
    }
    
    WindowsComboBoxLayoutManager(WindowsComboBoxUI.1 x1)
    {
      this();
    }
    
    public void layoutContainer(Container parent)
    {
      JComboBox cb = (JComboBox)parent;
      
      int width = cb.getWidth();
      int height = cb.getHeight();
      
      Insets insets = getInsets();
      int buttonWidth = WindowsComboBoxUI.this.getEditableButtonWidth();
      int buttonHeight = height - (top + bottom);
      if (arrowButton != null) {
        if (cb.getComponentOrientation().isLeftToRight()) {
          arrowButton.setBounds(width - (right + buttonWidth), top, buttonWidth, buttonHeight);
        } else {
          arrowButton.setBounds(left, top, buttonWidth, buttonHeight);
        }
      }
      if (editor != null) {
        editor.setBounds(rectangleForCurrentValue());
      }
    }
  }
  
  private static final class WindowsComboPopup
    extends BasicComboPopup
  {
    WindowsComboPopup(JComboBox x0, WindowsComboBoxUI.1 x1)
    {
      this(x0);
    }
    
    private WindowsComboPopup(JComboBox combo)
    {
      super();
    }
    
    protected Rectangle computePopupBounds(int px, int py, int pw, int ph)
    {
      Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
      Object popupPrototypeDisplayValue = comboBox.getClientProperty("ComboBox.popupPrototypeDisplayValue");
      if (popupPrototypeDisplayValue == null) {
        return defaultBounds;
      }
      ListCellRenderer renderer = list.getCellRenderer();
      Component c = renderer.getListCellRendererComponent(list, popupPrototypeDisplayValue, -1, true, true);
      
      pw = getPreferredSizewidth;
      boolean hasVerticalScrollBar = comboBox.getItemCount() > comboBox.getMaximumRowCount();
      if (hasVerticalScrollBar)
      {
        JScrollBar verticalBar = scroller.getVerticalScrollBar();
        pw += getPreferredSizewidth;
      }
      Rectangle prototypeBasedBounds = super.computePopupBounds(px, py, pw, ph);
      return width > width ? prototypeBasedBounds : defaultBounds;
    }
  }
  
  private final class TableCellEditorPropertyChangeHandler
    implements PropertyChangeListener
  {
    TableCellEditorPropertyChangeHandler(WindowsComboBoxUI.1 x1)
    {
      this();
    }
    
    public void propertyChange(PropertyChangeEvent evt)
    {
      tableCellEditor = WindowsComboBoxUI.this.isTableCellEditor();
      if ((comboBox.getRenderer() == null) || ((comboBox.getRenderer() instanceof UIResource))) {
        comboBox.setRenderer(createRenderer());
      }
      if ((comboBox.getEditor() == null) || ((comboBox.getEditor() instanceof UIResource))) {
        comboBox.setEditor(createEditor());
      }
    }
    
    private TableCellEditorPropertyChangeHandler() {}
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsComboBoxUI
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

final class WindowsFieldCaret$1
  implements Runnable
{
  private final WindowsFieldCaret this$0;
  
  WindowsFieldCaret$1(WindowsFieldCaret paramWindowsFieldCaret) {}
  
  public void run()
  {
    WindowsFieldCaret.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsFieldCaret.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.BoundedRangeModel;
import javax.swing.JTextField;
import javax.swing.plaf.TextUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Position.Bias;

final class WindowsFieldCaret$SafeScroller
  implements Runnable
{
  private final Rectangle r;
  private final WindowsFieldCaret this$0;
  
  WindowsFieldCaret$SafeScroller(WindowsFieldCaret paramWindowsFieldCaret, Rectangle r)
  {
    this.r = r;
  }
  
  public void run()
  {
    JTextField field = (JTextField)WindowsFieldCaret.access$100(this$0);
    if (field != null)
    {
      TextUI ui = field.getUI();
      int dot = this$0.getDot();
      
      Position.Bias bias = Position.Bias.Forward;
      Rectangle startRect = null;
      try
      {
        startRect = ui.modelToView(field, dot, bias);
      }
      catch (BadLocationException ble) {}
      Insets i = field.getInsets();
      BoundedRangeModel vis = field.getHorizontalVisibility();
      int x = r.x + vis.getValue() - left;
      int quarterSpan = vis.getExtent() / 4;
      if (r.x < left) {
        vis.setValue(x - quarterSpan);
      } else if (r.x + r.width > left + vis.getExtent()) {
        vis.setValue(x - 3 * quarterSpan);
      }
      if (startRect != null) {
        try
        {
          Rectangle endRect = ui.modelToView(field, dot, bias);
          if ((endRect != null) && (!endRect.equals(startRect))) {
            WindowsFieldCaret.access$200(this$0, endRect);
          }
        }
        catch (BadLocationException ble) {}
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsFieldCaret.SafeScroller
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
import javax.swing.plaf.TextUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position.Bias;
import javax.swing.text.View;

final class WindowsFieldCaret$WindowsHighlightPainter
  extends DefaultHighlighter.DefaultHighlightPainter
{
  WindowsFieldCaret$WindowsHighlightPainter(Color c)
  {
    super(c);
  }
  
  public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c)
  {
    Rectangle alloc = bounds.getBounds();
    try
    {
      TextUI mapper = c.getUI();
      Rectangle p0 = mapper.modelToView(c, offs0);
      Rectangle p1 = mapper.modelToView(c, offs1);
      
      Color color = getColor();
      if (color == null) {
        g.setColor(c.getSelectionColor());
      } else {
        g.setColor(color);
      }
      boolean firstIsDot = false;
      boolean secondIsDot = false;
      if (c.isEditable())
      {
        int dot = c.getCaretPosition();
        firstIsDot = offs0 == dot;
        secondIsDot = offs1 == dot;
      }
      if (y == y)
      {
        Rectangle r = p0.union(p1);
        if (width > 0) {
          if (firstIsDot)
          {
            x += 1;
            width -= 1;
          }
          else if (secondIsDot)
          {
            width -= 1;
          }
        }
        g.fillRect(x, y, width, height);
      }
      else
      {
        int p0ToMarginWidth = x + width - x;
        if ((firstIsDot) && (p0ToMarginWidth > 0))
        {
          x += 1;
          p0ToMarginWidth--;
        }
        g.fillRect(x, y, p0ToMarginWidth, height);
        if (y + height != y) {
          g.fillRect(x, y + height, width, y - (y + height));
        }
        if ((secondIsDot) && (x > x)) {
          x -= 1;
        }
        g.fillRect(x, y, x - x, height);
      }
    }
    catch (BadLocationException e) {}
  }
  
  public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c, View view)
  {
    Color color = getColor();
    if (color == null) {
      g.setColor(c.getSelectionColor());
    } else {
      g.setColor(color);
    }
    boolean firstIsDot = false;
    boolean secondIsDot = false;
    if (c.isEditable())
    {
      int dot = c.getCaretPosition();
      firstIsDot = offs0 == dot;
      secondIsDot = offs1 == dot;
    }
    if ((offs0 == view.getStartOffset()) && (offs1 == view.getEndOffset()))
    {
      Rectangle alloc;
      Rectangle alloc;
      if ((bounds instanceof Rectangle)) {
        alloc = (Rectangle)bounds;
      } else {
        alloc = bounds.getBounds();
      }
      if ((firstIsDot) && (width > 0)) {
        g.fillRect(x + 1, y, width - 1, height);
      } else if ((secondIsDot) && (width > 0)) {
        g.fillRect(x, y, width - 1, height);
      } else {
        g.fillRect(x, y, width, height);
      }
      return alloc;
    }
    try
    {
      Shape shape = view.modelToView(offs0, Position.Bias.Forward, offs1, Position.Bias.Backward, bounds);
      
      Rectangle r = (shape instanceof Rectangle) ? (Rectangle)shape : shape.getBounds();
      if ((firstIsDot) && (width > 0)) {
        g.fillRect(x + 1, y, width - 1, height);
      } else if ((secondIsDot) && (width > 0)) {
        g.fillRect(x, y, width - 1, height);
      } else {
        g.fillRect(x, y, width, height);
      }
      return r;
    }
    catch (BadLocationException e) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsFieldCaret.WindowsHighlightPainter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import com.jgoodies.looks.Options;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import javax.swing.BoundedRangeModel;
import javax.swing.JFormattedTextField;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultCaret;
import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;
import javax.swing.text.Document;
import javax.swing.text.Highlighter.HighlightPainter;
import javax.swing.text.JTextComponent;
import javax.swing.text.LayeredHighlighter.LayerPainter;
import javax.swing.text.Position.Bias;
import javax.swing.text.View;

final class WindowsFieldCaret
  extends DefaultCaret
  implements UIResource
{
  private static final LayeredHighlighter.LayerPainter WindowsPainter = new WindowsHighlightPainter(null);
  private boolean isKeyboardFocusEvent = true;
  
  public void focusGained(FocusEvent e)
  {
    JTextComponent c = getComponent();
    if (c.isEnabled())
    {
      setVisible(true);
      setSelectionVisible(true);
    }
    if (!c.isEditable()) {
      return;
    }
    if ((c.isEnabled()) && (isKeyboardFocusEvent) && (Options.isSelectOnFocusGainActive(c))) {
      if ((c instanceof JFormattedTextField)) {
        EventQueue.invokeLater(new Runnable()
        {
          public void run()
          {
            WindowsFieldCaret.this.selectAll();
          }
        });
      } else {
        selectAll();
      }
    }
  }
  
  private void selectAll()
  {
    JTextComponent c = getComponent();
    boolean backward = Boolean.TRUE.equals(c.getClientProperty("JGoodies.invertSelection"));
    if (backward)
    {
      setDot(c.getDocument().getLength());
      moveDot(0);
    }
    else
    {
      setDot(0);
      moveDot(c.getDocument().getLength());
    }
  }
  
  public void focusLost(FocusEvent e)
  {
    super.focusLost(e);
    if (!e.isTemporary())
    {
      isKeyboardFocusEvent = true;
      if (Boolean.TRUE.equals(getComponent().getClientProperty("JGoodies.setCaretToStartOnFocusLost"))) {
        setDot(0);
      }
    }
  }
  
  public void mousePressed(MouseEvent e)
  {
    if ((SwingUtilities.isLeftMouseButton(e)) || (e.isPopupTrigger())) {
      isKeyboardFocusEvent = false;
    }
    super.mousePressed(e);
  }
  
  public void mouseReleased(MouseEvent e)
  {
    super.mouseReleased(e);
    if (e.isPopupTrigger())
    {
      isKeyboardFocusEvent = false;
      if ((getComponent() != null) && (getComponent().isEnabled()) && (getComponent().isRequestFocusEnabled())) {
        getComponent().requestFocus();
      }
    }
  }
  
  protected void adjustVisibility(Rectangle r)
  {
    SwingUtilities.invokeLater(new SafeScroller(r));
  }
  
  protected Highlighter.HighlightPainter getSelectionPainter()
  {
    return WindowsPainter;
  }
  
  private final class SafeScroller
    implements Runnable
  {
    private final Rectangle r;
    
    SafeScroller(Rectangle r)
    {
      this.r = r;
    }
    
    public void run()
    {
      JTextField field = (JTextField)getComponent();
      if (field != null)
      {
        TextUI ui = field.getUI();
        int dot = getDot();
        
        Position.Bias bias = Position.Bias.Forward;
        Rectangle startRect = null;
        try
        {
          startRect = ui.modelToView(field, dot, bias);
        }
        catch (BadLocationException ble) {}
        Insets i = field.getInsets();
        BoundedRangeModel vis = field.getHorizontalVisibility();
        int x = r.x + vis.getValue() - left;
        int quarterSpan = vis.getExtent() / 4;
        if (r.x < left) {
          vis.setValue(x - quarterSpan);
        } else if (r.x + r.width > left + vis.getExtent()) {
          vis.setValue(x - 3 * quarterSpan);
        }
        if (startRect != null) {
          try
          {
            Rectangle endRect = ui.modelToView(field, dot, bias);
            if ((endRect != null) && (!endRect.equals(startRect))) {
              damage(endRect);
            }
          }
          catch (BadLocationException ble) {}
        }
      }
    }
  }
  
  private static final class WindowsHighlightPainter
    extends DefaultHighlighter.DefaultHighlightPainter
  {
    WindowsHighlightPainter(Color c)
    {
      super();
    }
    
    public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c)
    {
      Rectangle alloc = bounds.getBounds();
      try
      {
        TextUI mapper = c.getUI();
        Rectangle p0 = mapper.modelToView(c, offs0);
        Rectangle p1 = mapper.modelToView(c, offs1);
        
        Color color = getColor();
        if (color == null) {
          g.setColor(c.getSelectionColor());
        } else {
          g.setColor(color);
        }
        boolean firstIsDot = false;
        boolean secondIsDot = false;
        if (c.isEditable())
        {
          int dot = c.getCaretPosition();
          firstIsDot = offs0 == dot;
          secondIsDot = offs1 == dot;
        }
        if (y == y)
        {
          Rectangle r = p0.union(p1);
          if (width > 0) {
            if (firstIsDot)
            {
              x += 1;
              width -= 1;
            }
            else if (secondIsDot)
            {
              width -= 1;
            }
          }
          g.fillRect(x, y, width, height);
        }
        else
        {
          int p0ToMarginWidth = x + width - x;
          if ((firstIsDot) && (p0ToMarginWidth > 0))
          {
            x += 1;
            p0ToMarginWidth--;
          }
          g.fillRect(x, y, p0ToMarginWidth, height);
          if (y + height != y) {
            g.fillRect(x, y + height, width, y - (y + height));
          }
          if ((secondIsDot) && (x > x)) {
            x -= 1;
          }
          g.fillRect(x, y, x - x, height);
        }
      }
      catch (BadLocationException e) {}
    }
    
    public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c, View view)
    {
      Color color = getColor();
      if (color == null) {
        g.setColor(c.getSelectionColor());
      } else {
        g.setColor(color);
      }
      boolean firstIsDot = false;
      boolean secondIsDot = false;
      if (c.isEditable())
      {
        int dot = c.getCaretPosition();
        firstIsDot = offs0 == dot;
        secondIsDot = offs1 == dot;
      }
      if ((offs0 == view.getStartOffset()) && (offs1 == view.getEndOffset()))
      {
        Rectangle alloc;
        Rectangle alloc;
        if ((bounds instanceof Rectangle)) {
          alloc = (Rectangle)bounds;
        } else {
          alloc = bounds.getBounds();
        }
        if ((firstIsDot) && (width > 0)) {
          g.fillRect(x + 1, y, width - 1, height);
        } else if ((secondIsDot) && (width > 0)) {
          g.fillRect(x, y, width - 1, height);
        } else {
          g.fillRect(x, y, width, height);
        }
        return alloc;
      }
      try
      {
        Shape shape = view.modelToView(offs0, Position.Bias.Forward, offs1, Position.Bias.Backward, bounds);
        
        Rectangle r = (shape instanceof Rectangle) ? (Rectangle)shape : shape.getBounds();
        if ((firstIsDot) && (width > 0)) {
          g.fillRect(x + 1, y, width - 1, height);
        } else if ((secondIsDot) && (width > 0)) {
          g.fillRect(x, y, width - 1, height);
        } else {
          g.fillRect(x, y, width, height);
        }
        return r;
      }
      catch (BadLocationException e) {}
      return null;
    }
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsFieldCaret
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicFormattedTextFieldUI;
import javax.swing.text.Caret;

public final class WindowsFormattedTextFieldUI
  extends BasicFormattedTextFieldUI
{
  public static ComponentUI createUI(JComponent c)
  {
    return new WindowsFormattedTextFieldUI();
  }
  
  protected Caret createCaret()
  {
    return new WindowsFieldCaret();
  }
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsFormattedTextFieldUI
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

class WindowsIconFactory$1 {}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsIconFactory.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.UIManager;

class WindowsIconFactory$CheckBoxIcon
  implements Icon, Serializable
{
  private static final int SIZE = 13;
  
  WindowsIconFactory$CheckBoxIcon(WindowsIconFactory.1 x0)
  {
    this();
  }
  
  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    JCheckBox cb = (JCheckBox)c;
    ButtonModel model = cb.getModel();
    if (!cb.isBorderPaintedFlat())
    {
      g.setColor(UIManager.getColor("CheckBox.shadow"));
      g.drawLine(x, y, x + 11, y);
      g.drawLine(x, y + 1, x, y + 11);
      
      g.setColor(UIManager.getColor("CheckBox.highlight"));
      g.drawLine(x + 12, y, x + 12, y + 12);
      g.drawLine(x, y + 12, x + 11, y + 12);
      
      g.setColor(UIManager.getColor("CheckBox.darkShadow"));
      g.drawLine(x + 1, y + 1, x + 10, y + 1);
      g.drawLine(x + 1, y + 2, x + 1, y + 10);
      
      g.setColor(UIManager.getColor("CheckBox.light"));
      g.drawLine(x + 1, y + 11, x + 11, y + 11);
      g.drawLine(x + 11, y + 1, x + 11, y + 10);
    }
    else
    {
      g.setColor(UIManager.getColor("CheckBox.shadow"));
      g.drawRect(x + 1, y + 1, 10, 10);
    }
    g.setColor(UIManager.getColor(((model.isPressed()) && (model.isArmed())) || (!model.isEnabled()) ? "CheckBox.background" : "CheckBox.interiorBackground"));
    
    g.fillRect(x + 2, y + 2, 9, 9);
    
    g.setColor(UIManager.getColor(model.isEnabled() ? "CheckBox.checkColor" : "CheckBox.shadow"));
    if (model.isSelected())
    {
      g.drawLine(x + 9, y + 3, x + 9, y + 3);
      g.drawLine(x + 8, y + 4, x + 9, y + 4);
      g.drawLine(x + 7, y + 5, x + 9, y + 5);
      g.drawLine(x + 6, y + 6, x + 8, y + 6);
      g.drawLine(x + 3, y + 7, x + 7, y + 7);
      g.drawLine(x + 4, y + 8, x + 6, y + 8);
      g.drawLine(x + 5, y + 9, x + 5, y + 9);
      g.drawLine(x + 3, y + 5, x + 3, y + 5);
      g.drawLine(x + 3, y + 6, x + 4, y + 6);
    }
  }
  
  public int getIconWidth()
  {
    return 13;
  }
  
  public int getIconHeight()
  {
    return 13;
  }
  
  private WindowsIconFactory$CheckBoxIcon() {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsIconFactory.CheckBoxIcon
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;

class WindowsIconFactory$RadioButtonIcon
  implements Icon, UIResource, Serializable
{
  private static final int SIZE = 13;
  
  WindowsIconFactory$RadioButtonIcon(WindowsIconFactory.1 x0)
  {
    this();
  }
  
  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    AbstractButton b = (AbstractButton)c;
    ButtonModel model = b.getModel();
    
    g.setColor(UIManager.getColor(((model.isPressed()) && (model.isArmed())) || (!model.isEnabled()) ? "RadioButton.background" : "RadioButton.interiorBackground"));
    
    g.fillRect(x + 2, y + 2, 8, 8);
    
    g.setColor(UIManager.getColor("RadioButton.shadow"));
    g.drawLine(x + 4, y + 0, x + 7, y + 0);
    g.drawLine(x + 2, y + 1, x + 3, y + 1);
    g.drawLine(x + 8, y + 1, x + 9, y + 1);
    g.drawLine(x + 1, y + 2, x + 1, y + 3);
    g.drawLine(x + 0, y + 4, x + 0, y + 7);
    g.drawLine(x + 1, y + 8, x + 1, y + 9);
    
    g.setColor(UIManager.getColor("RadioButton.highlight"));
    g.drawLine(x + 2, y + 10, x + 3, y + 10);
    g.drawLine(x + 4, y + 11, x + 7, y + 11);
    g.drawLine(x + 8, y + 10, x + 9, y + 10);
    g.drawLine(x + 10, y + 9, x + 10, y + 8);
    g.drawLine(x + 11, y + 7, x + 11, y + 4);
    g.drawLine(x + 10, y + 3, x + 10, y + 2);
    
    g.setColor(UIManager.getColor("RadioButton.darkShadow"));
    g.drawLine(x + 4, y + 1, x + 7, y + 1);
    g.drawLine(x + 2, y + 2, x + 3, y + 2);
    g.drawLine(x + 8, y + 2, x + 9, y + 2);
    g.drawLine(x + 2, y + 3, x + 2, y + 3);
    g.drawLine(x + 1, y + 4, x + 1, y + 7);
    g.drawLine(x + 2, y + 8, x + 2, y + 8);
    
    g.setColor(UIManager.getColor("RadioButton.light"));
    g.drawLine(x + 2, y + 9, x + 3, y + 9);
    g.drawLine(x + 4, y + 10, x + 7, y + 10);
    g.drawLine(x + 8, y + 9, x + 9, y + 9);
    g.drawLine(x + 9, y + 8, x + 9, y + 8);
    g.drawLine(x + 10, y + 7, x + 10, y + 4);
    g.drawLine(x + 9, y + 3, x + 9, y + 3);
    if (model.isSelected())
    {
      g.setColor(UIManager.getColor("RadioButton.checkColor"));
      g.fillRect(x + 4, y + 5, 4, 2);
      g.fillRect(x + 5, y + 4, 2, 4);
    }
  }
  
  public int getIconWidth()
  {
    return 13;
  }
  
  public int getIconHeight()
  {
    return 13;
  }
  
  private WindowsIconFactory$RadioButtonIcon() {}
}

/* Location:
 * Qualified Name:     com.jgoodies.looks.windows.WindowsIconFactory.RadioButtonIcon
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package com.jgoodies.looks.windows;

import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;

final class WindowsIconFactory
{
  private static Icon checkBoxIcon;
  private static Icon radioButtonIcon;
  
  static Icon getCheckBoxIcon()
  {
    if (checkBoxIcon == null) {
      checkBoxIcon = new CheckBoxIcon(null);
    }
    return checkBoxIcon;
  }
  
  static Icon getRadioButtonIcon()
  {
    if (radioButtonIcon == null) {
      radioButtonIcon = new RadioButtonIcon(null);
    }
    return radioButtonIcon;
  }
  
  private static class CheckBoxIcon
    implements Icon, Serializable
  {
    private static final int SIZE = 13;
    
    CheckBoxIcon(WindowsIconFactory.1 x0)
    {
      this();
    }
    
    public void paintIcon(Component c, Graphics g, int x, int y)
    {
      JCheckBox cb = (JCheckBox)c;
      ButtonModel model = cb.getModel();
      if (!cb.isBorderPaintedFlat())
      {
        g.setColor(UIManager.getColor("CheckBox.shadow"));
        g.drawLine(x, y, x + 11, y);
        g.drawLine(x, y + 1, x, y + 11);
        
        g.setColor(UIManager.getColor("CheckBox.highlight"));
        g.drawLine(x + 12, y, x + 12, y + 12);
        g.drawLine(x, y + 12, x + 11, y + 12);
        
        g.setColor(UIManager.getColor("CheckBox.darkShadow"));
        g.drawLine(x + 1, y + 1, x + 10, y + 1);
        g.drawLine(x + 1, y + 2, x + 1, y + 10);
        
        g.setColor(UIManager.getColor("CheckBox.light"));
        g.drawLine(x + 1, y + 11, x + 11, y + 11);
        g.drawLine(x + 11, y + 1, x + 11, y + 10);
      }
      else
      {
        g.setColor(UIManager.getColor("CheckBox.shadow"));
        g.drawRect(x + 1, y + 1, 10, 10);
      }
      g.setColor(UIManager.getColor(((model.isPressed()) && (model.isArmed())) || (!model.isEnabled()) ? "CheckBox.background" : "CheckBox.interiorBackground"));
      
      g.fillRect(x + 2, y + 2, 9, 9);
      
      g.setColor(UIManager.getColor(model.isEnabled() ? "CheckBox.checkColor" : "CheckBox.shadow"));
      if (model.isSelected())
      {
        g.drawLine(x + 9, y + 3, x + 9, y + 3);
        g.drawLine(x + 8, y + 4, x + 9, y + 4);
        g.drawLine(x + 7, y + 5, x + 9, y + 5);
        g.drawLine(x + 6, y + 6, x + 8, y + 6);
        g.drawLine(x + 3, y + 7, x + 7, y + 7);
        g.drawLine(x + 4, y + 8, x + 6, y + 8);
        g.drawLine(x + 5, y + 9, x + 5, y + 9);
        g.drawLine(x + 3, y + 5, x + 3, y + 5);
        g.drawLine(x + 3, y + 6, x + 4, y + 6);
      }
    }
    
    public int getIconWidth()
    {
      return 13;
    }
    
    public int getIconHeight()
    {
      return 13;
    }
    
    private CheckBoxIcon() {}
  }
  
  private static class RadioButtonIcon
    implements Icon, UIResource, Serializable
  {
    private static final int SIZE = 13;
    
    RadioButtonIcon(WindowsIconFactory.1 x0)
    {
      this();
    }
    
    public void paintIcon(Component c, Graphics g, int x, int y)
    {
      AbstractButton b = (AbstractButton)c;
      ButtonModel model = b.getModel();
      
      g.setColor(UIManager.getColor(((model.isPressed()) && (model.isArmed())) || (!model.isEnabled()) ? "RadioButton.background" : "RadioButton.interiorBackground"));
      
      g.fillRect(x + 2, y + 2, 8, 8);
      
      g.setColor(UIManager.getColor("RadioButton.shadow"));
      g.drawLine(x + 4, y + 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd