📄 framedform.java
字号:
}
frame = this.leftFrame;
break;
default:
if (this.rightFrame == null) {
//#style rightframe, frame, default
this.rightFrame = new Container( false , de.enough.polish.ui.StyleSheet.defaultStyle );
}
frame = this.rightFrame;
}
frame.screen = this;
//#if polish.Container.allowCycling != false
frame.allowCycling = false;
//#endif
frame.add( item );
}
/* (non-Javadoc)
* @see de.enough.polish.ui.Screen#setContentArea(int, int, int, int)
*/
protected void calculateContentArea(int x, int y, int width, int height) {
super.calculateContentArea(x, y, width, height);
x = this.contentX;
y = this.contentY;
width = this.contentWidth;
height = this.contentHeight;
this.originalContentWidth = width;
this.originalContentHeight = height;
this.originalContentY = this.contentY;
this.originalContentX = this.contentX;
if (this.leftFrame != null) {
this.expandLeftFrame = (this.leftFrame.style.layout & Item.LAYOUT_VEXPAND) == Item.LAYOUT_VEXPAND;
if (this.expandLeftFrame) {
this.leftFrame.setStyle( this.leftFrame.style, true );
}
int frameWidth = this.leftFrame.getItemWidth(width/2, width/2);
x += frameWidth;
width -= frameWidth;
}
if (this.rightFrame != null) {
this.expandRightFrame = (this.rightFrame.style.layout & Item.LAYOUT_VEXPAND) == Item.LAYOUT_VEXPAND;
if (this.expandRightFrame) {
this.rightFrame.setStyle( this.rightFrame.style, true );
}
width -= this.rightFrame.getItemWidth(this.originalContentWidth/2, this.originalContentWidth/2);
}
if (this.topFrame != null ) {
int frameHeight = this.topFrame.getItemHeight(this.originalContentWidth, this.originalContentWidth);
y += frameHeight;
height -= frameHeight;
}
if (this.bottomFrame != null ) {
height -= this.bottomFrame.getItemHeight(this.originalContentWidth, this.originalContentWidth);
}
this.container.requestFullInit();
this.container.init(width, width);
this.contentX = x;
this.contentY = y;
this.contentWidth = width;
this.contentHeight = height;
this.container.setScrollHeight( height );
}
/* (non-Javadoc)
* @see de.enough.polish.ui.Screen#paintScreen(javax.microedition.lcdui.Graphics)
*/
protected void paintScreen(Graphics g) {
super.paintScreen(g);
//#ifdef tmp.menuFullScreen
//# g.setClip(0, 0, this.screenWidth, this.fullScreenHeight );
//#else
g.setClip(0, 0, this.screenWidth, this.originalScreenHeight );
//#endif
if (this.leftFrame != null) {
Style frameStyle = this.leftFrame.style;
if (this.expandLeftFrame) {
if ( frameStyle.background != null ) {
frameStyle.background.paint( frameStyle.marginLeft, frameStyle.marginTop, this.leftFrame.backgroundWidth, this.originalContentHeight - frameStyle.marginTop - frameStyle.marginBottom, g);
}
if ( frameStyle.border != null ) {
frameStyle.border.paint( frameStyle.marginLeft, frameStyle.marginTop, this.leftFrame.backgroundWidth, this.originalContentHeight - frameStyle.marginTop - frameStyle.marginBottom, g);
}
}
int y = this.originalContentY;
if ( (frameStyle.layout & Item.LAYOUT_VCENTER) == Item.LAYOUT_VCENTER ) {
y += (this.originalContentHeight - frameStyle.marginBottom - this.leftFrame.itemHeight) / 2;
} else if ( (frameStyle.layout & Item.LAYOUT_BOTTOM) == Item.LAYOUT_BOTTOM ) {
y += this.originalContentHeight - frameStyle.marginBottom - this.leftFrame.itemHeight;
}
this.leftFrame.relativeX = 0;
this.leftFrame.relativeY = y;
this.leftFrame.paint( 0, y, 0, this.contentWidth, g );
}
if (this.rightFrame != null) {
Style frameStyle = this.rightFrame.style;
if (this.expandRightFrame) {
if ( frameStyle.background != null ) {
frameStyle.background.paint( this.contentWidth + frameStyle.marginLeft, frameStyle.marginTop, this.rightFrame.backgroundWidth, this.originalContentHeight - frameStyle.marginTop - frameStyle.marginBottom, g);
}
if ( frameStyle.border != null ) {
frameStyle.border.paint( this.contentWidth + frameStyle.marginLeft, frameStyle.marginTop, this.rightFrame.backgroundWidth, this.originalContentHeight - frameStyle.marginTop - frameStyle.marginBottom, g);
}
}
int y = this.originalContentY;
if ( (frameStyle.layout & Item.LAYOUT_VCENTER) == Item.LAYOUT_VCENTER ) {
y += (this.originalContentHeight - frameStyle.marginBottom - this.rightFrame.itemHeight) / 2;
} else if ( (frameStyle.layout & Item.LAYOUT_BOTTOM) == Item.LAYOUT_BOTTOM ) {
y += this.originalContentHeight - frameStyle.marginBottom - this.rightFrame.itemHeight;
}
this.rightFrame.relativeX = this.contentWidth;
this.rightFrame.relativeY = y;
this.rightFrame.paint( this.contentWidth, y, this.contentWidth, this.screenWidth, g );
}
if (this.topFrame != null ) {
this.topFrame.relativeX = this.originalContentX;
this.topFrame.relativeY = this.originalContentY;
this.topFrame.paint( this.originalContentX, this.originalContentY, this.originalContentX, this.originalContentX + this.originalContentWidth, g );
}
if (this.bottomFrame != null ) {
this.bottomFrame.relativeX = this.originalContentX;
this.bottomFrame.relativeY = this.contentY + this.contentHeight;
this.bottomFrame.paint( this.originalContentX, this.contentY + this.contentHeight, this.originalContentX, this.originalContentX + this.originalContentWidth, g );
}
}
/* (non-Javadoc)
* @see de.enough.polish.ui.Screen#handleKeyPressed(int, int)
*/
protected boolean handleKeyPressed(int keyCode, int gameAction) {
boolean handled = this.currentlyActiveContainer.handleKeyPressed(keyCode, gameAction);
if (! handled ) {
Container newFrame = null;
if (this.currentlyActiveContainer == this.container ) {
Container[] nextFrames;
switch (gameAction) {
case DOWN:
nextFrames = new Container[]{ this.bottomFrame, this.leftFrame, this.rightFrame, this.topFrame };
break;
case UP:
nextFrames = new Container[]{ this.topFrame, this.leftFrame, this.rightFrame, this.bottomFrame };
break;
case LEFT:
nextFrames = new Container[]{ this.leftFrame, this.topFrame, this.bottomFrame, this.rightFrame };
break;
case RIGHT:
nextFrames = new Container[]{ this.rightFrame, this.topFrame, this.bottomFrame, this.leftFrame };
default:
return false;
}
for (int i = 0; i < nextFrames.length; i++) {
Container frame = nextFrames[i];
if (frame != null && frame.appearanceMode != Item.PLAIN) {
newFrame = frame;
break;
}
}
} else {
//System.out.println("Changing back to default container");
newFrame = this.container;
}
if ( newFrame != null && newFrame != this.currentlyActiveContainer ) {
setActiveFrame(newFrame);
handled = true;
}
//} else {
// System.out.println("currently active container has handled the key press event");
}
return handled;
}
/**
* Retrieves the currently focused item.
*
* @return the currently focused item, null when none is focused.
*/
public Item getCurrentItem() {
if (this.currentlyActiveContainer != null) {
return this.currentlyActiveContainer.focusedItem;
}
return null;
}
/**
* Activates another frame.
*
* @param newFrame the next frame
*/
private void setActiveFrame(Container newFrame) {
this.currentlyActiveContainer.defocus( this.currentlyActiveContainer.style );
newFrame.focus( StyleSheet.focusedStyle, 0 );
this.currentlyActiveContainer = newFrame;
if (this.screenStateListener != null) {
this.screenStateListener.screenStateChanged( this );
}
}
//#ifdef polish.hasPointerEvents
//# /* (non-Javadoc)
//# * @see de.enough.polish.ui.Screen#handlePointerPressed(int, int)
//# */
//# protected boolean handlePointerPressed(int x, int y) {
//# Container newFrame = null;
//# if (this.container.handlePointerPressed(x - this.container.relativeX, y - this.container.relativeY)) {
//# newFrame = this.container;
//# } else if ( this.topFrame != null && this.topFrame.handlePointerPressed(x - this.topFrame.relativeX, y - this.topFrame.relativeY) ) {
//# newFrame = this.topFrame;
//# } else if ( this.bottomFrame != null && this.bottomFrame.handlePointerPressed(x - this.bottomFrame.relativeX, y - this.bottomFrame.relativeY) ) {
//# newFrame = this.bottomFrame;
//# } else if ( this.leftFrame != null && this.leftFrame.handlePointerPressed(x - this.leftFrame.relativeX, y - this.leftFrame.relativeY) ) {
//# newFrame = this.leftFrame;
//# } else if ( this.rightFrame != null && this.rightFrame.handlePointerPressed(x - this.rightFrame.relativeX, y - this.rightFrame.relativeY) ) {
//# newFrame = this.rightFrame;
//# }
//# if (newFrame != null && newFrame != this.currentlyActiveContainer ) {
//# setActiveFrame(newFrame);
//# }
//# return (newFrame != null);
//# }
//#endif
/* (non-Javadoc)
* @see de.enough.polish.ui.Screen#animate()
*/
public boolean animate() {
boolean animated = super.animate()
| ( this.leftFrame != null && this.leftFrame.animate() )
| ( this.rightFrame != null && this.rightFrame.animate() )
| ( this.topFrame != null && this.topFrame.animate() )
| ( this.bottomFrame != null && this.bottomFrame.animate() );
return animated;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -