1 /*
2 * Copyright (c) 1997, 2010, 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
73
74 private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer {
75 Skin skin;
76 boolean isSelected, hasFocus, hasRollover;
77 int column;
78
79 XPDefaultRenderer() {
80 setHorizontalAlignment(LEADING);
81 }
82
83 public Component getTableCellRendererComponent(JTable table, Object value,
84 boolean isSelected, boolean hasFocus,
85 int row, int column) {
86 super.getTableCellRendererComponent(table, value, isSelected,
87 hasFocus, row, column);
88 this.isSelected = isSelected;
89 this.hasFocus = hasFocus;
90 this.column = column;
91 this.hasRollover = (column == getRolloverColumn());
92 if (skin == null) {
93 skin = XPStyle.getXP().getSkin(header, Part.HP_HEADERITEM);
94 }
95 Insets margins = skin.getContentMargin();
96 Border border = null;
97 int contentTop = 0;
98 int contentLeft = 0;
99 int contentBottom = 0;
100 int contentRight = 0;
101 if (margins != null) {
102 contentTop = margins.top;
103 contentLeft = margins.left;
104 contentBottom = margins.bottom;
105 contentRight = margins.right;
106 }
107 /* idk:
108 * Both on Vista and XP there is some offset to the
109 * HP_HEADERITEM content. It does not seem to come from
110 * Prop.CONTENTMARGINS. Do not know where it is defined.
111 * using some hardcoded values.
112 */
113 contentLeft += 5;
114 contentBottom += 4;
115 contentRight += 5;
|
1 /*
2 * Copyright (c) 1997, 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
73
74 private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer {
75 Skin skin;
76 boolean isSelected, hasFocus, hasRollover;
77 int column;
78
79 XPDefaultRenderer() {
80 setHorizontalAlignment(LEADING);
81 }
82
83 public Component getTableCellRendererComponent(JTable table, Object value,
84 boolean isSelected, boolean hasFocus,
85 int row, int column) {
86 super.getTableCellRendererComponent(table, value, isSelected,
87 hasFocus, row, column);
88 this.isSelected = isSelected;
89 this.hasFocus = hasFocus;
90 this.column = column;
91 this.hasRollover = (column == getRolloverColumn());
92 if (skin == null) {
93 XPStyle xp = XPStyle.getXP();
94 skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null;
95 }
96 Insets margins = (skin != null) ? skin.getContentMargin() : null;
97 Border border = null;
98 int contentTop = 0;
99 int contentLeft = 0;
100 int contentBottom = 0;
101 int contentRight = 0;
102 if (margins != null) {
103 contentTop = margins.top;
104 contentLeft = margins.left;
105 contentBottom = margins.bottom;
106 contentRight = margins.right;
107 }
108 /* idk:
109 * Both on Vista and XP there is some offset to the
110 * HP_HEADERITEM content. It does not seem to come from
111 * Prop.CONTENTMARGINS. Do not know where it is defined.
112 * using some hardcoded values.
113 */
114 contentLeft += 5;
115 contentBottom += 4;
116 contentRight += 5;
|