You Are Here:

Community: Developer Discussion Boards

#1 Old Canvas Scrolling - 2004-01-19, 03:44

Join Date: Mar 2003
Posts: 15
Location: Malaysia
Send a message via MSN to ramka001 Send a message via Yahoo to ramka001 Send a message via Skype™ to ramka001
ramka001's Avatar
ramka001
Offline
Registered User
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
Reply With Quote

#2 Old 2004-01-19, 04:37

Join Date: Apr 2003
Posts: 61
aspaans
Offline
Regular Contributor
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia