use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method getClientArea.
@Override
public Bounds getClientArea() {
int width = getWidth();
int height = getHeight();
int titleBarHeight = titleBarTablePane.getHeight();
Frame frame = (Frame) getComponent();
boolean maximized = frame.isMaximized();
Bounds clientArea;
if (maximized && !getShowWindowControls()) {
clientArea = new Bounds(0, 0, width, height);
} else {
clientArea = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
}
return clientArea;
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method install.
@Override
public void install(Component component) {
super.install(component);
Frame frame = (Frame) getComponent();
if (!themeIsFlat()) {
// Attach the drop-shadow decorator
dropShadowDecorator = new DropShadowDecorator(5, 5, 5);
frame.getDecorators().add(dropShadowDecorator);
}
frame.add(titleBarTablePane);
// Create the frame buttons
minimizeButton = new FrameButton(minimizeImage);
maximizeButton = new FrameButton(maximizeImage);
closeButton = new FrameButton(closeImage);
buttonBoxPane.add(minimizeButton);
buttonBoxPane.add(maximizeButton);
buttonBoxPane.add(closeButton);
ButtonPressListener buttonPressListener = new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Frame frameLocal = (Frame) getComponent();
if (button == minimizeButton) {
frameLocal.setVisible(false);
} else if (button == maximizeButton) {
frameLocal.moveToFront();
frameLocal.setMaximized(!frameLocal.isMaximized());
} else if (button == closeButton) {
frameLocal.close();
}
}
};
minimizeButton.getButtonPressListeners().add(buttonPressListener);
maximizeButton.getButtonPressListeners().add(buttonPressListener);
closeButton.getButtonPressListeners().add(buttonPressListener);
frame.add(resizeHandle);
iconAdded(frame, null);
titleChanged(frame, null);
activeChanged(frame, null);
maximizedChanged(frame);
setShowMinimizeButton(false);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
Frame frame = (Frame) getComponent();
// Include title bar height plus top/bottom title bar borders
preferredHeight += titleBarTablePane.getPreferredHeight() + 2;
// Include menu bar height
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null) {
preferredHeight += menuBar.getPreferredHeight();
}
Component content = frame.getContent();
if (content != null) {
if (width != -1) {
// Subtract padding and left/right content borders from constraint
width -= (padding.left + padding.right) + 2;
width = Math.max(width, 0);
}
preferredHeight += content.getPreferredHeight(width);
}
// Add padding, top/bottom content borders, and content bevel
preferredHeight += (padding.top + padding.bottom) + (showContentBevel ? 1 : 0) + 2;
return preferredHeight;
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method keyPressed.
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = super.keyPressed(component, keyCode, keyLocation);
Frame frame = (Frame) component;
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null && keyCode == Keyboard.KeyCode.SPACE && Keyboard.isPressed(Keyboard.Modifier.ALT)) {
MenuBar.Item activeItem = menuBar.getActiveItem();
MenuBar.ItemSequence items = menuBar.getItems();
if (activeItem == null && items.getLength() > 0) {
items.get(0).setActive(true);
consumed = true;
}
}
return consumed;
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class TerraFrameSkin method paint.
@Override
public void paint(Graphics2D graphics) {
// Call the base class to paint the background
super.paint(graphics);
Frame frame = (Frame) getComponent();
int width = getWidth();
int height = getHeight();
boolean maximized = frame.isMaximized();
if (!maximized || getShowWindowControls()) {
int titleBarHeight = titleBarTablePane.getHeight();
// Draw the title area
Color titleBarBackgroundColorLocal = frame.isActive() ? this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
Color titleBarBorderColorLocal = frame.isActive() ? this.titleBarBorderColor : inactiveTitleBarBorderColor;
Color titleBarBevelColorLocal = frame.isActive() ? this.titleBarBevelColor : inactiveTitleBarBevelColor;
if (!themeIsFlat()) {
graphics.setPaint(new GradientPaint(width / 2f, 0, titleBarBevelColorLocal, width / 2f, titleBarHeight + 1, titleBarBackgroundColorLocal));
graphics.fillRect(0, 0, width, titleBarHeight + 1);
// Draw the border
graphics.setPaint(titleBarBorderColorLocal);
GraphicsUtilities.drawRect(graphics, 0, 0, width, titleBarHeight + 2);
// Draw the content area
Bounds contentAreaRectangle = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
graphics.setPaint(contentBorderColor);
GraphicsUtilities.drawRect(graphics, contentAreaRectangle.x, contentAreaRectangle.y, contentAreaRectangle.width, contentAreaRectangle.height);
if (showContentBevel) {
graphics.setPaint(contentBevelColor);
GraphicsUtilities.drawLine(graphics, contentAreaRectangle.x + 1, contentAreaRectangle.y + 1, contentAreaRectangle.width - 2, Orientation.HORIZONTAL);
}
} else {
graphics.setPaint(titleBarBackgroundColorLocal);
graphics.fillRect(0, 0, width, titleBarHeight + 1);
}
}
}
Aggregations