Search in sources :

Example 16 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class TerraPromptSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Prompt prompt = (Prompt) component;
    prompt.setPreferredWidth(320);
    prompt.setMinimumWidth(160);
    prompt.getPromptListeners().add(this);
    // Load the prompt content
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    Component content;
    try {
        content = (Component) bxmlSerializer.readObject(TerraPromptSkin.class, "terra_prompt_skin.bxml");
    } catch (Exception exception) {
        throw new RuntimeException(exception);
    }
    prompt.setContent(content);
    typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
    messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
    messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
    optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
    for (Object option : prompt.getOptions()) {
        PushButton optionButton = new PushButton(option);
        optionButton.setStyleName(BUTTON_STYLE_NAME);
        optionButton.getButtonPressListeners().add(optionButtonPressListener);
        optionButtonBoxPane.add(optionButton);
    }
    messageTypeChanged(prompt, null);
    messageChanged(prompt, null);
    bodyChanged(prompt, null);
}
Also used : Prompt(org.apache.pivot.wtk.Prompt) Component(org.apache.pivot.wtk.Component) PushButton(org.apache.pivot.wtk.PushButton) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 17 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class TerraPushButtonSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    PushButton pushButton = (PushButton) getComponent();
    Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
    dataRenderer.render(pushButton.getButtonData(), pushButton, false);
    Dimensions preferredContentSize = dataRenderer.getPreferredSize();
    int preferredWidth = preferredContentSize.width + paddingWidth();
    int preferredHeight = preferredContentSize.height + paddingHeight();
    // Adjust for preferred aspect ratio
    float aspectRatio = (float) preferredWidth / (float) preferredHeight;
    if (!Float.isNaN(minimumAspectRatio) && aspectRatio < minimumAspectRatio) {
        preferredWidth = (int) (preferredHeight * minimumAspectRatio);
    }
    if (!Float.isNaN(maximumAspectRatio) && aspectRatio > maximumAspectRatio) {
        preferredHeight = (int) (preferredWidth / maximumAspectRatio);
    }
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Dimensions(org.apache.pivot.wtk.Dimensions) PushButton(org.apache.pivot.wtk.PushButton) GradientPaint(java.awt.GradientPaint)

Example 18 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class TerraPushButtonSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    PushButton pushButton = (PushButton) getComponent();
    Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
    dataRenderer.render(pushButton.getButtonData(), pushButton, false);
    int clientWidth = Math.max(width - paddingWidth(), 0);
    int clientHeight = Math.max(height - paddingHeight(), 0);
    int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
    if (baseline != -1) {
        baseline += padding.top + 1;
    }
    return baseline;
}
Also used : PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) PushButton(org.apache.pivot.wtk.PushButton) GradientPaint(java.awt.GradientPaint)

Example 19 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class TerraAlertSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Alert alert = (Alert) component;
    alert.setPreferredWidth(320);
    alert.setMinimumWidth(160);
    alert.getAlertListeners().add(this);
    // Load the alert content
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    Component content;
    try {
        content = (Component) bxmlSerializer.readObject(TerraAlertSkin.class, "terra_alert_skin.bxml");
    } catch (Exception exception) {
        throw new RuntimeException(exception);
    }
    alert.setContent(content);
    typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
    messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
    messageBorder = (Border) bxmlSerializer.getNamespace().get("messageBorder");
    messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
    optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
    // Explicitly set the message border color and background color, this can't be done properly in the constructor
    // as messageBorder is null at that point.
    setBorderBackgroundColor(borderBackgroundColor);
    setBorderColor(borderColor);
    for (Object option : alert.getOptions()) {
        PushButton optionButton = new PushButton(option);
        optionButton.setStyleName(BUTTON_STYLE_NAME);
        optionButton.getButtonPressListeners().add(optionButtonPressListener);
        optionButtonBoxPane.add(optionButton);
    }
    messageTypeChanged(alert, null);
    messageChanged(alert, null);
    bodyChanged(alert, null);
}
Also used : Alert(org.apache.pivot.wtk.Alert) Component(org.apache.pivot.wtk.Component) PushButton(org.apache.pivot.wtk.PushButton) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 20 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class ActivityIndicators method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    activityIndicator1 = (ActivityIndicator) namespace.get("activityIndicator1");
    activityIndicator2 = (ActivityIndicator) namespace.get("activityIndicator2");
    activityIndicator3 = (ActivityIndicator) namespace.get("activityIndicator3");
    activityButton = (PushButton) namespace.get("activityButton");
    activityButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            activityIndicator1.setActive(!activityIndicator1.isActive());
            activityIndicator2.setActive(!activityIndicator2.isActive());
            activityIndicator3.setActive(!activityIndicator3.isActive());
            updateButtonData();
        }
    });
    updateButtonData();
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Aggregations

PushButton (org.apache.pivot.wtk.PushButton)39 Button (org.apache.pivot.wtk.Button)29 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)23 Window (org.apache.pivot.wtk.Window)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Component (org.apache.pivot.wtk.Component)6 GradientPaint (java.awt.GradientPaint)5 ListButton (org.apache.pivot.wtk.ListButton)5 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)4 Path (org.apache.pivot.collections.Sequence.Tree.Path)3 Checkbox (org.apache.pivot.wtk.Checkbox)3 Frame (org.apache.pivot.wtk.Frame)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 TreeView (org.apache.pivot.wtk.TreeView)3 TreeViewSelectionListener (org.apache.pivot.wtk.TreeViewSelectionListener)3 TreeBranch (org.apache.pivot.wtk.content.TreeBranch)3 File (java.io.File)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2 Alert (org.apache.pivot.wtk.Alert)2