| Reply | « Previous Thread | Next Thread » |
|
Hi all,
I am trying to do a scrolling menu for my canvas using the series 40 sdk. Is it possible? Please help. Thank you in advance. Cheers, Ram Kumar |
|
I assume you're writing the menu entirely from scratch (using Canvas and Graphics methods). Here is a scrolling example I wrote and use, where smOffscreenOutputImg is the image i write to, containing the display, and smScrollOutputImg is a temporary hidden image (intermediate buffer)
... smGraphScroll = smScrollOutputImg.getGraphics(); smGraphOffscreen = smOffscreenOutputImg.getGraphics(); ... ... // negative value fo yPixels when scrolling down. private static void scrollUp(int yPixels) { final int width = smOffscreenOutputImg.getWidth(); final int height = smOffscreenOutputImg.getHeight(); drawRegion(smGraphScroll, smOffscreenOutputImg, 0, yPixels, width, height - yPixels, 0, 0, Graphics.TOP | Graphics.LEFT); drawRegion(smGraphOffscreen, smScrollOutputImg, 0, 0, width, height - yPixels, 0, 0, Graphics.TOP | Graphics.LEFT); g.setClip(0, 0, width, height); // Remove this line for MIDP2.0 final int y = (yPixels < 0 ? 0 : height - yPixels); g.setColor(mBackColor); g.fillRect(0, y, width, yPixels < 0 ? -yPixels : yPixels); } private static void drawRegion(Graphics g, Image img, int xSrc, int ySrc, int width, int height, int xDst, int yDst, int anchor) { /** MIDP1.0 */ g.setClip(xDst, yDst, width, height); g.drawImage(img, xDst - xSrc, yDst - ySrc, anchor); /** MIDP2.0 g.drawRegion(img, xSrc, ySrc, width, height, 0, xDst, yDst, anchor); */ } |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|