1 /* 2 * Copyright (c) 2011, 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 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 }