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
23 * questions.
24 */
25
26 package com.sun.javafx.scene.control.skin;
27
28 import javafx.scene.Node;
29 import javafx.scene.control.Label;
30 import javafx.scene.control.Skin;
31 import javafx.scene.control.Tooltip;
32
33 /**
34 * CSS based skin for Tooltip. It deals mostly with show hide logic for
35 * Popup based controls, and specifically in this case for tooltip. It also
36 * implements some of the Skin interface methods.
37 *
38 * TooltipContent class is the actual skin implementation of the tooltip.
39 */
40 public class TooltipSkin implements Skin<Tooltip> {
41 private Label tipLabel;
42
43 private Tooltip tooltip;
44
45 public TooltipSkin(Tooltip t) {
46 this.tooltip = t;
47 tipLabel = new Label();
48 tipLabel.contentDisplayProperty().bind(t.contentDisplayProperty());
49 tipLabel.fontProperty().bind(t.fontProperty());
50 tipLabel.graphicProperty().bind(t.graphicProperty());
51 tipLabel.graphicTextGapProperty().bind(t.graphicTextGapProperty());
52 tipLabel.textAlignmentProperty().bind(t.textAlignmentProperty());
53 tipLabel.textOverrunProperty().bind(t.textOverrunProperty());
54 tipLabel.textProperty().bind(t.textProperty());
55 tipLabel.wrapTextProperty().bind(t.wrapTextProperty());
56 tipLabel.minWidthProperty().bind(t.minWidthProperty());
57 tipLabel.prefWidthProperty().bind(t.prefWidthProperty());
58 tipLabel.maxWidthProperty().bind(t.maxWidthProperty());
59 tipLabel.minHeightProperty().bind(t.minHeightProperty());
60 tipLabel.prefHeightProperty().bind(t.prefHeightProperty());
61 tipLabel.maxHeightProperty().bind(t.maxHeightProperty());
62
63 // RT-7512 - skin needs to have styleClass of the control
64 // TODO - This needs to be bound together, not just set! Probably should
65 // do the same for id and style as well.
66 tipLabel.getStyleClass().setAll(t.getStyleClass());
67 tipLabel.setStyle(t.getStyle());
68 tipLabel.setId(t.getId());
69 }
70
71 @Override public Tooltip getSkinnable() {
72 return tooltip;
73 }
74
75 @Override public Node getNode() {
76 return tipLabel;
77 }
78
79 @Override public void dispose() {
80 tooltip = null;
81 tipLabel = null;
82 }
83 }
|
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
23 * questions.
24 */
25
26 package javafx.scene.control.skin;
27
28 import javafx.scene.Node;
29 import javafx.scene.control.Label;
30 import javafx.scene.control.Skin;
31 import javafx.scene.control.Tooltip;
32
33 /**
34 * CSS based skin for Tooltip. It deals mostly with show hide logic for
35 * Popup based controls, and specifically in this case for tooltip. It also
36 * implements some of the Skin interface methods.
37 *
38 * TooltipContent class is the actual skin implementation of the tooltip.
39 */
40 public class TooltipSkin implements Skin<Tooltip> {
41
42 /***************************************************************************
43 * *
44 * Private fields *
45 * *
46 **************************************************************************/
47
48 private Label tipLabel;
49
50 private Tooltip tooltip;
51
52
53
54 /***************************************************************************
55 * *
56 * Constructors *
57 * *
58 **************************************************************************/
59
60 /**
61 * Creates a new TooltipSkin instance for the given {@link Tooltip}.
62 */
63 public TooltipSkin(Tooltip t) {
64 this.tooltip = t;
65 tipLabel = new Label();
66 tipLabel.contentDisplayProperty().bind(t.contentDisplayProperty());
67 tipLabel.fontProperty().bind(t.fontProperty());
68 tipLabel.graphicProperty().bind(t.graphicProperty());
69 tipLabel.graphicTextGapProperty().bind(t.graphicTextGapProperty());
70 tipLabel.textAlignmentProperty().bind(t.textAlignmentProperty());
71 tipLabel.textOverrunProperty().bind(t.textOverrunProperty());
72 tipLabel.textProperty().bind(t.textProperty());
73 tipLabel.wrapTextProperty().bind(t.wrapTextProperty());
74 tipLabel.minWidthProperty().bind(t.minWidthProperty());
75 tipLabel.prefWidthProperty().bind(t.prefWidthProperty());
76 tipLabel.maxWidthProperty().bind(t.maxWidthProperty());
77 tipLabel.minHeightProperty().bind(t.minHeightProperty());
78 tipLabel.prefHeightProperty().bind(t.prefHeightProperty());
79 tipLabel.maxHeightProperty().bind(t.maxHeightProperty());
80
81 // RT-7512 - skin needs to have styleClass of the control
82 // TODO - This needs to be bound together, not just set! Probably should
83 // do the same for id and style as well.
84 tipLabel.getStyleClass().setAll(t.getStyleClass());
85 tipLabel.setStyle(t.getStyle());
86 tipLabel.setId(t.getId());
87 }
88
89
90
91 /***************************************************************************
92 * *
93 * Public API *
94 * *
95 **************************************************************************/
96
97 /** {@inheritDoc} */
98 @Override public Tooltip getSkinnable() {
99 return tooltip;
100 }
101
102 /** {@inheritDoc} */
103 @Override public Node getNode() {
104 return tipLabel;
105 }
106
107 /** {@inheritDoc} */
108 @Override public void dispose() {
109 tooltip = null;
110 tipLabel = null;
111 }
112 }
|