use of org.apache.pivot.wtk.Component in project pivot by apache.
the class FakeWindowSkin method layout.
@Override
public void layout() {
FakeWindow frame = (FakeWindow) getComponent();
int width = getWidth();
int height = getHeight();
int clientX = 1;
int clientY = 1;
int clientWidth = Math.max(width - 2, 0);
int clientHeight = Math.max(height - 2, 0);
// Size/position title bar
titleBarTablePane.setLocation(clientX, clientY);
titleBarTablePane.setSize(clientWidth, titleBarTablePane.getPreferredHeight());
titleBarTablePane.setVisible(true);
// Add bottom title bar border, top content border, and content bevel
clientY += titleBarTablePane.getHeight() + (1) + 2;
// Size/position content
Component content = frame.getContent();
if (content != null) {
int contentX = clientX + padding.left;
int contentY = clientY + padding.top;
int contentWidth = Math.max(clientWidth - padding.getWidth(), 0);
int contentHeight = Math.max(clientHeight - (clientY + padding.getHeight()) + (1), 0);
content.setLocation(contentX, contentY);
content.setSize(contentWidth, contentHeight);
}
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class FakeWindowSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
int widthMutable = width;
FakeWindow frame = (FakeWindow) getComponent();
// Include title bar height plus top/bottom title bar borders
preferredHeight += titleBarTablePane.getPreferredHeight() + 2;
Component content = frame.getContent();
if (content != null) {
if (widthMutable != -1) {
// Subtract padding and left/right content borders from
// constraint
widthMutable -= padding.getWidth() + 2;
widthMutable = Math.max(widthMutable, 0);
}
preferredHeight += content.getPreferredHeight(widthMutable);
}
// Add padding, top/bottom content borders, and content bevel
preferredHeight += padding.getHeight() + (1) + 2;
return preferredHeight;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class FakeWindowSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
int heightMutable = height;
FakeWindow frame = (FakeWindow) getComponent();
// Include title bar width plus left/right title bar borders
Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
preferredWidth = Math.max(titleBarSize.width + 2, preferredWidth);
if (heightMutable != -1) {
// Subtract title bar height and top/bottom title bar borders
// from height constraint
heightMutable -= titleBarSize.height + 2;
}
Component content = frame.getContent();
if (content != null) {
if (heightMutable != -1) {
// Subtract padding, top/bottom content borders, and content
// bevel from height constraint
heightMutable -= padding.getHeight() + (1) + 2;
heightMutable = Math.max(heightMutable, 0);
}
preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(heightMutable));
}
// Add padding and left/right content borders
preferredWidth += padding.getWidth() + 2;
return preferredWidth;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class Transitions method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
button1 = (PushButton) namespace.get("button1");
button2 = (PushButton) namespace.get("button2");
button3 = (PushButton) namespace.get("button3");
button4 = (PushButton) namespace.get("button4");
ButtonPressListener buttonPressListener = new ButtonPressListener() {
@Override
public void buttonPressed(final Button button) {
if (collapseTransition == null) {
collapseTransition = new CollapseTransition(button, TRANSITION_DURATION, TRANSITION_RATE);
TransitionListener transitionListener = new TransitionListener() {
@Override
public void transitionCompleted(Transition transition) {
CollapseTransition collapseTransitionLocal = (CollapseTransition) transition;
if (!transition.isReversed()) {
Component component = collapseTransitionLocal.getComponent();
component.getParent().remove(component);
}
Transitions.this.collapseTransition = null;
}
};
collapseTransition.start(transitionListener);
} else {
collapseTransition.reverse();
if (collapseTransition.getComponent() != button) {
collapseTransition.end();
}
}
}
};
button1.getButtonPressListeners().add(buttonPressListener);
button2.getButtonPressListeners().add(buttonPressListener);
button3.getButtonPressListeners().add(buttonPressListener);
button4.getButtonPressListeners().add(buttonPressListener);
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class WindowTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) {
window1.setTitle("Window 1");
window1.setPreferredSize(640, 480);
window1.setMaximumWidth(640);
window1.setMaximumHeight(480);
window1.setMinimumWidth(320);
window1.setMinimumHeight(240);
window1.getComponentListeners().add(new ComponentListener() {
@Override
public void sizeChanged(final Component component, final int previousWidth, final int previousHeight) {
window1.align(window1.getDisplay().getBounds(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
window1.getComponentListeners().remove(this);
}
});
display.getStyles().put(Style.backgroundColor, new Color(0, 127, 127));
window1.setContent(new Label("Hello Bar"));
window1.open(display);
ApplicationContext.queueCallback(() -> {
final Sheet sheet = new Sheet();
sheet.setPreferredSize(120, 60);
sheet.open(window1);
ApplicationContext.queueCallback(() -> {
Sheet sheet2 = new Sheet();
sheet2.setPreferredSize(60, 30);
sheet2.open(sheet);
});
});
Frame window1a = new Frame();
window1a.setTitle("Window 1 A");
window1a.setLocation(30, 280);
window1a.setPreferredSize(160, 120);
window1a.open(window1);
Frame window1ai = new Frame();
window1ai.setTitle("Window 1 A I");
window1ai.setLocation(150, 300);
window1ai.setPreferredSize(320, 200);
window1ai.open(window1a);
window1ai.getDecorators().update(0, new ReflectionDecorator());
Frame window1aii = new Frame();
window1aii.setTitle("Window 1 A II");
window1aii.setLocation(50, 400);
window1aii.setPreferredSize(320, 200);
window1aii.open(window1a);
Frame window1b = new Frame();
window1b.setTitle("Window 1 B");
window1b.setPreferredSize(160, 120);
window1b.setLocation(260, 60);
window1b.open(window1);
Frame window1bi = new Frame();
window1bi.setTitle("Window 1 B I");
window1bi.setPreferredSize(180, 60);
window1bi.setLocation(270, 160);
window1bi.setContent(new Label("This window is not enabled"));
// to test even a not enabled window ...
window1bi.setEnabled(false);
window1bi.open(window1b);
Frame window1bii = new Frame();
window1bii.setTitle("Window 1 B II");
window1bii.setPreferredSize(160, 60);
window1bii.setLocation(320, 10);
window1bii.open(window1b);
Palette palette1 = new Palette();
palette1.setTitle("Palette 1bii 1");
palette1.setPreferredSize(160, 60);
palette1.setLocation(290, 210);
palette1.open(window1bii);
Palette palette2 = new Palette();
palette2.setTitle("Palette 1bii 2");
palette2.setPreferredSize(160, 60);
palette2.setLocation(600, 200);
palette2.setContent(new Label("This palette is not enabled"));
// to test even a not enabled palette ...
palette2.setEnabled(false);
palette2.open(window1bii);
dialogOwner.setTitle("Dialog Owner");
dialogOwner.setPreferredSize(320, 120);
dialogOwner.open(display);
// window1bii.requestFocus();
ApplicationContext.queueCallback(() -> {
final Dialog dialog = new Dialog();
dialog.setTitle("Dialog 1");
dialog.setPreferredSize(280, 100);
dialog.open(dialogOwner);
ApplicationContext.queueCallback(() -> {
Dialog dialog2 = new Dialog();
dialog2.setTitle("Dialog 2");
dialog2.setPreferredSize(220, 80);
dialog2.open(dialog);
});
});
}
Aggregations