You Are Here:

Community: Developer Discussion Boards

#1 Old Screen Width - 2003-08-13, 20:27

Join Date: Mar 2003
Posts: 21
rapix
Offline
Registered User
Hi,

I see that the screen width reported by Nokia 3650 device (canvas.getWidth()) is much wider than that of the actual screen width.

Is there a way to know the acurate screen width in Pixels on Nokia series 60 device?

-Nachiket
Reply With Quote

#2 Old 2003-08-14, 03:24

Join Date: Aug 2003
Posts: 26
ljioannou
Offline
Registered User
The only thing I can think of is are you creating an off screen buffer?

Otherwise it works fine for me.
Reply With Quote

#3 Old 2003-08-14, 04:07

Join Date: Mar 2003
Posts: 21
rapix
Offline
Registered User
What do you mean by off screen buffer?

Code Fragment:
-------------


Please note: RequestScreen is a Canvas type opject which is used to getWidth() of the screen.

private String[] screenFit(String[] rows)
{
RequestScreen req = new RequestScreen("","");
Font fnt = Font.getDefaultFont();
int screenWidth = req.getWidth();
for(int index = 0; index < rows.length ;index++)
{
int stringWidth = 0;
int lastWhiteSpaceIndex = 0;
for(int sindex = 0; sindex < rows[index].length(); sindex++)
{
if(rows[index].charAt(sindex) == ' ') lastWhiteSpaceIndex = sindex;
stringWidth += fnt.charWidth(rows[index].charAt(sindex));
if(stringWidth > screenWidth - 5) /*If the string width greater than Screen width, move the text from last white space to the next line*/
{
if(lastWhiteSpaceIndex!=0) {
String[] newRows = new String[rows.length + 1];
for(int newIndex = 0; newIndex <= index; newIndex++) newRows[newIndex] = rows[newIndex];
for(int newIndex = rows.length; newIndex > index; newIndex--) newRows[newIndex] = rows[newIndex-1];
newRows[index+1] = rows[index].substring(lastWhiteSpaceIndex+1, rows[index].length());
newRows[index] = rows[index].substring(0, lastWhiteSpaceIndex) ;
rows = newRows;
break;
}
}
}
}
return rows;
}


---------------



The result of the code is some characters (5-9 characters depending on the width of the characters) appear outside the screen and do not wrap around. I am trying to wrap string at the end of the screen width.


Your help is greatly appreciated,

Thanks.

-Nachiket
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