
Originally Posted by
Aleksi
There's currently no way to force certain orientation for S60 Java applications using LCDUI.
Here's how I work around it. Draw the screen to an offscreen image and then rotate it. Have to adjust pointer events and arrow keys too.
Code:
public class BaseScreen extends FullCanvas{
private static Image offscreenImage = null;
public BaseScreen(String id) {
if (offscreenImage == null) {
offscreenImage = Image.createImage(Math.min(getWidth(), getHeight()), Math.max(getWidth(), getHeight()));
}
}
public void paint(Graphics g) {
if (getWidth() > getHeight()) {
old_paint(offscreenImage.getGraphics());
Image rotated = Image.createImage(offscreenImage, 0, 0, offscreenImage.getWidth(), offscreenImage.getHeight(), Sprite.TRANS_ROT270);
g.drawImage(rotated, 0, 0, Graphics.TOP | Graphics.LEFT);
} else {
old_paint(g);
}
}
private void old_paint(Graphics g) {
g.fillRect(0, 0, getWidth(), getHeight());
etc...
}
public void pointerPressed(int x, int y) {
int xAdjusted = x, yAdjusted = y;
if (getWidth() > getHeight()) {
xAdjusted = getHeight() - y;
yAdjusted = x;
}
handleEvent(xAdjusted, yAdjusted);
}