You Are Here:

Community: Developer Discussion Boards

#1 Old Garbled text in DrawText using a TBuf - 2008-07-07, 06:17

Join Date: Jul 2008
Posts: 5
Send a message via ICQ to natios
natios
Offline
Registered User
Hey guys,

I'm trying to draw fomatted text on the screen, but the text goes out garbled - usually squares, but sometimes other garbage.
The problem is either with TBuf's Format method, or with DrawText getting TBuf.
Anyway, it doesn't happen when I just use the resource directly, as can be seen in the code below.

Code:
_LIT(KREPORT, "%s");
_LIT(KRESOURCE, "something");
	
TBuf<10> message;
message.Format(KREPORT, "something");
   
CWindowGc& gc = SystemGc();
gc.Activate(Window());
gc.UseFont(CEikonEnv::Static()->TitleFont());
gc.SetPenColor(KRgbGreen);
    
TPoint p1(10, 20);
gc.DrawText(message, p1);
TPoint p2(10, 60);
gc.DrawText(KRESOURCE, p2);
gc.Deactivate();
The first DrawText garbles the text, while the second one doesn't.

Anyone got an idea why this should happen or how to solve it?

Cheers,
Nate.


Cheers,
Nate
Reply With Quote

#2 Old Re: Garbled text in DrawText using a TBuf - 2008-07-07, 07:04

Join Date: Jun 2006
Posts: 2,323
Location: India
Send a message via MSN to kkrish Send a message via Yahoo to kkrish Send a message via Skype™ to kkrish
kkrish's Avatar
kkrish
Offline
Forum Nokia Champion
Hi,
Why you need this line
Quote:
message.Format(KREPORT, "something");
This statement not looking correct. what your exact requirements and you can also go through with helloworldplus example.


=============================
Before to ask the question, Few things to be remind
1- Check wiki.forum.nokia
2- Forum.nokia.com, developer.symbian.org
3- Check on google
Reply With Quote

#3 Old Re: Garbled text in DrawText using a TBuf - 2008-07-08, 01:25

Join Date: Jul 2008
Posts: 5
Send a message via ICQ to natios
natios
Offline
Registered User
Quote:
Originally Posted by kkrish View Post
Hi,
Why you need this line

This statement not looking correct. what your exact requirements and you can also go through with helloworldplus example.
Hey kkrish,

Thanks for your answer.
I'm trying to save four messages in an array and draw them on the four corners of the screen. They keep being updated, so I need to draw directly from the array and update the array from char *.

Code:
class CSomething
{
...
private:
TBuf<10> iMessages[4];   
int ixOffset;
int iyOffset;
TPoint iCorners[4];
}

void CSomething::InitReport()
{
	const TText *t = _S("");
	for (int i=0; i<4; i++)
		iMessages[i] = t;
		
	ixOffset = 10;
	iyOffset = 20;
	
	iCorners[0] = TPoint(ixOffset, iyOffset); 
	iCorners[1] = TPoint(IMAGE_WIDTH-ixOffset, iyOffset); 
	iCorners[2] = TPoint(ixOffset, IMAGE_HEIGHT-iyOffset);
	iCorners[3] = TPoint(IMAGE_WIDTH-ixOffset, IMAGE_HEIGHT-iyOffset); 
}

void CSomething::Report(char *aWhat, TCorner aCorner)
{
	_LIT(KREPORT, "%s");
	
	switch (aCorner)
	{
	case ETL:
		iMessages[0].Format(KREPORT, aWhat);
		break;
	case ETR:
		iMessages[1].Format(KREPORT, aWhat);
		break;		
	case EBL:
		iMessages[2].Format(KREPORT, aWhat);
		break;
	case EBR:
		iMessages[3].Format(KREPORT, aWhat);
		break;
	}
}
	
void CSomething::DrawText(char *aWhat, TCorner aCorner)
{
	CWindowGc& gc = SystemGc();
	gc.Activate(Window());
	gc.UseFont(CEikonEnv::Static()->TitleFont());
	gc.SetPenColor(KRgbGreen);
	
	for (int i=0; i<4; i++)
		gc.DrawText(iMessages[i], iCorners[i]);
	
	gc.Deactivate();
}
If you know why the text is garbled or if you have a better idea of how to do the whole thing please let me know

Cheers,
Nate.


Cheers,
Nate
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 On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display text stored in a TBuf or TDesc? s3ni Symbian User Interface 17 2009-08-10 09:45
Exit form from edit mode tqchcm Symbian User Interface 13 2007-10-31 07:06
How can I get the text buffer after DrawText()? danie78 General Symbian C++ 2 2006-06-08 13:13
Persist text value of user defined option in Enumerated Text Settings List leethomso Symbian User Interface 0 2004-11-24 19:49
How to display text stored in a TBuf or TDesc? s3ni General Symbian C++ 1 2003-07-16 09:07

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