License text

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER 
 * Copyright  2008, 2010 Oracle and/or its affiliates.  All rights reserved. 
 * Use is subject to license terms.
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer. 
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Oracle Corporation nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

    

package cssfun;

import javafx.geometry.HPos;
import javafx.geometry.VPos;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Stack;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.LayoutInfo;

var scene: Scene;
var stylesheets: String = "{__DIR__}default.css";

// This LayoutInfo is used on all of the Buttons, making them all the same width
def btnLayout = LayoutInfo{ width: 65 };

scene = Scene {
    stylesheets: bind stylesheets
    width: 400
    height: 230
    content: [
        Rectangle {
            width: bind scene.width
            height: bind scene.height
            styleClass: "scene"
        },
        // The buttons are laid out in an HBox which makes
        // horizontal layout a snap. Notice that each Button uses
        // the same LayoutInfo, btnLayout, which is declared above.
        HBox {
            layoutX: 10
            layoutY: 10
            spacing: 5
            content:[
                Button {
                    text: "Default"
                    layoutInfo: btnLayout
                    action: function() {
                        stylesheets = "{__DIR__}default.css";
                    }
                },
                 Button {
                    text: "Clean"
                    layoutInfo: btnLayout
                    action: function() {
                        stylesheets = "{__DIR__}clean.css";
                    }
                },
                 Button {
                    text: "Dark"
                    layoutInfo: btnLayout
                    action: function() {
                        stylesheets = "{__DIR__}dark.css";
                    }
                }
            ]
        },
        // Like HBox, Stack is another layout Container. Stack simplifies
        // laying out one node atop another. By default, the nodes will
        // be centered. Thus, placing the Rectangle and Text in a Stack
        // nicely centers the text in the rectangle.
        Stack {
            layoutX: 10 layoutY: 70
            content: [
                Rectangle {
                    width: 200 height: 50
                    styleClass: "bg"
                },
                Text {
                    content: "Do it with"
                    styleClass: "text"
                }
            ]
        }
        // Label is a control and, as such, has a much richer CSS environment
        // than the Rectangle and Text used above. Label can take advantage of
        // CSS backgrounds and borders to accomplish a wide variety of styles.
        Label {
            layoutX: 10 layoutY: 130
            // Here, LayoutInfo makes the Label the same size as the Rectangle
            // above. Rectangle ignores LayoutInfo since it is not Resizable.
            layoutInfo: LayoutInfo { width: 200 height: 50 }
            hpos: HPos.CENTER
            styleClass: "styleText"
            text: "Style"
        },

        Circle {
            layoutX: 270 layoutY: 125
            radius: 40
            styleClass: "fg"
        }
    ]
}

Stage {
    title: "CSSTest"
    scene: scene;
}