jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 438 2ae294e4518c
child 1299 027d966d5658
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 438
diff changeset
     2
 * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.swing.plaf.synth.SynthUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Synth's SplitPaneUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
class SynthSplitPaneUI extends BasicSplitPaneUI implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                    PropertyChangeListener, SynthUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Keys to use for forward focus traversal when the JComponent is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * managing focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static Set managingFocusForwardTraversalKeys;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Keys to use for backward focus traversal when the JComponent is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * managing focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static Set managingFocusBackwardTraversalKeys;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Style for the JSplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private SynthStyle style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Style for the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private SynthStyle dividerStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Creates a new SynthSplitPaneUI instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public static ComponentUI createUI(JComponent x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return new SynthSplitPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Installs the UI defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        updateStyle(splitPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        setOrientation(splitPane.getOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        setContinuousLayout(splitPane.isContinuousLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        resetLayoutManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        /* Install the nonContinuousLayoutDivider here to avoid having to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        add/remove everything later. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        if(nonContinuousLayoutDivider == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            setNonContinuousLayoutDivider(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                createDefaultNonContinuousLayoutDivider(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        // focus forward traversal key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (managingFocusForwardTraversalKeys==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            managingFocusForwardTraversalKeys = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            managingFocusForwardTraversalKeys.add(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                                        managingFocusForwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // focus backward traversal key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (managingFocusBackwardTraversalKeys==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            managingFocusBackwardTraversalKeys = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            managingFocusBackwardTraversalKeys.add(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                                        managingFocusBackwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private void updateStyle(JSplitPane splitPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        SynthContext context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                          ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        SynthStyle oldDividerStyle = dividerStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        dividerStyle = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        context = getContext(splitPane, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        SynthStyle oldStyle = style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        style = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (style != oldStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            Object value = style.get(context, "SplitPane.size");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (value == null) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   130
                value = Integer.valueOf(6);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            LookAndFeel.installProperty(splitPane, "dividerSize", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            value = style.get(context, "SplitPane.oneTouchExpandable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                LookAndFeel.installProperty(splitPane, "oneTouchExpandable", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            if (divider != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                splitPane.remove(divider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                divider.setDividerSize(splitPane.getDividerSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            if (oldStyle != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (style != oldStyle || dividerStyle != oldDividerStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            // Only way to force BasicSplitPaneDivider to reread the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            // necessary properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            if (divider != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                splitPane.remove(divider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            divider = createDefaultDivider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            divider.setBasicSplitPaneUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            splitPane.add(divider, JSplitPane.DIVIDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Installs the event listeners for the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        super.installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        splitPane.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Uninstalls the UI defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        SynthContext context = getContext(splitPane, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        style.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        style = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        dividerStyle.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        dividerStyle = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        super.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Uninstalls the event listeners for the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        super.uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        splitPane.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public SynthContext getContext(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return getContext(c, getComponentState(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    private SynthContext getContext(JComponent c, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return SynthContext.getContext(SynthContext.class, c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    SynthLookAndFeel.getRegion(c), style, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    private Region getRegion(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return SynthLookAndFeel.getRegion(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    private int getComponentState(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        return SynthLookAndFeel.getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    SynthContext getContext(JComponent c, Region region) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return getContext(c, region, getComponentState(c, region));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    private SynthContext getContext(JComponent c, Region region, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (region == Region.SPLIT_PANE_DIVIDER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            return SynthContext.getContext(SynthContext.class, c, region,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                           dividerStyle, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return SynthContext.getContext(SynthContext.class, c, region,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                       style, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    private int getComponentState(JComponent c, Region subregion) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        int state = SynthLookAndFeel.getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (divider.isMouseOver()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            state |= MOUSE_OVER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            updateStyle((JSplitPane)e.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Creates the default divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public BasicSplitPaneDivider createDefaultDivider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        SynthSplitPaneDivider divider = new SynthSplitPaneDivider(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        divider.setDividerSize(splitPane.getDividerSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return divider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    protected Component createDefaultNonContinuousLayoutDivider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return new Canvas() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                paintDragDivider(g, 0, 0, getWidth(), getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public void update(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        SynthLookAndFeel.update(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        context.getPainter().paintSplitPaneBackground(context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                          g, 0, 0, c.getWidth(), c.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public void paint(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    protected void paint(SynthContext context, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // This is done to update package private variables in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // BasicSplitPaneUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        super.paint(g, splitPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public void paintBorder(SynthContext context, Graphics g, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                            int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        context.getPainter().paintSplitPaneBorder(context, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    private void paintDragDivider(Graphics g, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        SynthContext context = getContext(splitPane,Region.SPLIT_PANE_DIVIDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        context.setComponentState(((context.getComponentState() | MOUSE_OVER) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                   MOUSE_OVER) | PRESSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        Shape oldClip = g.getClip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        g.clipRect(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                           splitPane.getOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        g.setClip(oldClip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public void finishedPaintingChildren(JSplitPane jc, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if(jc == splitPane && getLastDragLocation() != -1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                              !isContinuousLayout() && !draggingHW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            if(jc.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                paintDragDivider(g, getLastDragLocation(), 0, dividerSize - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                                 splitPane.getHeight() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                paintDragDivider(g, 0, getLastDragLocation(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                 splitPane.getWidth() - 1, dividerSize - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
}