use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class CardPaneTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame(new BoxPane());
frame.getStyles().put(Style.padding, 0);
frame.setTitle("Component Pane Test");
frame.setPreferredSize(800, 600);
frame.setLocation(20, 20);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
sheet = (Sheet) bxmlSerializer.readObject(CardPaneTest.class, "card_pane_test.bxml");
cardPane = (CardPane) bxmlSerializer.getNamespace().get("cardPane");
sizeGroup = (ButtonGroup) bxmlSerializer.getNamespace().get("sizeGroup");
sizeGroup.getButtonGroupListeners().add(new ButtonGroupListener() {
@Override
public void selectionChanged(ButtonGroup buttonGroup, Button previousSelection) {
final Button selection = buttonGroup.getSelection();
int selectedIndex = selection == null ? -1 : selection.getParent().indexOf(selection);
cardPane.getCardPaneListeners().add(new CardPaneListener() {
@Override
public Vote previewSelectedIndexChange(CardPane cardPaneArgument, int selectedIndexArgument) {
if (selection != null) {
selection.getParent().setEnabled(false);
}
return Vote.APPROVE;
}
@Override
public void selectedIndexChangeVetoed(CardPane cardPaneArgument, Vote reason) {
if (selection != null && reason == Vote.DENY) {
selection.getParent().setEnabled(true);
}
}
@Override
public void selectedIndexChanged(CardPane cardPaneArgument, int previousSelectedIndex) {
if (selection != null) {
selection.getParent().setEnabled(true);
}
}
});
cardPane.setSelectedIndex(selectedIndex);
}
});
frame.open(display);
ApplicationContext.queueCallback(() -> sheet.open(frame));
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class LabelTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame();
frame.setTitle("Label Test");
String line1 = "There's a lady who's sure all that glitters is gold, and " + "she's buying a stairway to heaven. When she gets there she knows, " + "if the stores are closed, with a word she can get what she came " + "for. Woe oh oh oh oh oh and she's buying a stairway to heaven. " + "There's a sign on the wall, but she wants to be sure, and you know " + "sometimes words have two meanings. In a tree by the brook there's " + "a songbird who sings, sometimes all of our thoughts are misgiven. " + "Woe oh oh oh oh oh and she's buying a stairway to heaven.";
String line2 = "And as we wind on down the road, our shadows taller than " + "our souls, there walks a lady we all know who shines white light " + "and wants to show how everything still turns to gold; and if you " + "listen very hard the tune will come to you at last when all are " + "one and one is all:\nto be a rock and not to roll.";
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
Label label1 = new Label(line1);
label1.getStyles().put(Style.wrapText, true);
label1.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
boxPane.add(label1);
// strikethrough
Label label2 = new Label(line2);
label2.getStyles().put(Style.wrapText, true);
label2.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
label2.getStyles().put(Style.textDecoration, TextDecoration.STRIKETHROUGH);
boxPane.add(label2);
// disabled
Label label3 = new Label(line2);
label3.getStyles().put(Style.wrapText, true);
label3.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
label3.setEnabled(false);
boxPane.add(label3);
boxPane.getStyles().put(Style.fill, true);
boxPane.getStyles().put(Style.padding, new Insets(10));
frame.setContent(boxPane);
frame.setPreferredSize(340, 400);
frame.open(display);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class SpinnerFocusTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
Action action = new Action() {
@Override
public String getDescription() {
return null;
}
@Override
public void perform(final Component source) {
String msg = "Selected: " + spinner.getSelectedItem().toString();
Alert.alert(msg, frame);
spinner.requestFocus();
System.out.println("Focus transferred to spinner");
}
};
Action.getNamedActions().put("buttonAction", action);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("spinner_focus_test.bxml")));
frame.setTitle("Spinner Focus Test");
frame.open(display);
spinner = (Spinner) bxmlSerializer.getNamespace().get("spinner");
spinner.requestFocus();
// action.setEnabled(false);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method mouseDown.
@Override
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
boolean consumed = super.mouseDown(component, button, x, y);
Frame frame = (Frame) getComponent();
boolean maximized = frame.isMaximized();
if (button == Mouse.Button.LEFT && !maximized) {
Bounds titleBarBounds = titleBarTablePane.getBounds();
if (titleBarBounds.contains(x, y)) {
dragOffset = new Point(x, y);
Mouse.capture(component);
} else {
if (resizable && x > resizeHandle.getX() && y > resizeHandle.getY()) {
resizeOffset = new Point(getWidth() - x, getHeight() - y);
Mouse.capture(component);
}
}
}
return consumed;
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
Frame frame = (Frame) getComponent();
// Include title bar width plus left/right title bar borders
Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
preferredWidth = Math.max(titleBarSize.width + 2, preferredWidth);
if (height != -1) {
// Subtract title bar height and top/bottom title bar borders
// from height constraint
height -= titleBarSize.height + 2;
}
// Include menu bar width
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null) {
Dimensions menuBarSize = menuBar.getPreferredSize();
preferredWidth = Math.max(preferredWidth, menuBarSize.width);
if (height != -1) {
// Subtract menu bar height from height constraint
height -= menuBarSize.height;
}
}
Component content = frame.getContent();
if (content != null) {
if (height != -1) {
// Subtract padding, top/bottom content borders, and content bevel
// from height constraint
height -= (padding.top + padding.bottom) + (showContentBevel ? 1 : 0) + 2;
height = Math.max(height, 0);
}
preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(height));
}
// Add padding and left/right content borders
preferredWidth += (padding.left + padding.right) + 2;
return preferredWidth;
}
Aggregations