Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » "\n" does not work on DrawText
"\n" does not work on DrawText [message #46089] Thu, 03 March 2016 08:33 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
following my post DrawText and carriage return, I decided to insert the carriage return using some lines of code. The code is really simple but should do the trick. I basically add a "\n" after 35 chars, but it seems something is going wrong. The code add a char in the WString (I notice an extra space in the phrase), but it actually does not make a carriage return: the WString is still on a line. What is the escape sequence to be used with DrawText to have a carriage return?
Regards,
Gio
Re: "\n" does not work on DrawText [message #46091 is a reply to message #46089] Thu, 03 March 2016 11:11 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Hello,

DrawTexe does not interprete \n, you have to split the string, and to call DrawTexe repeatedly to display each line.

for example:
void DrawAsLines(Draw& w, int x, int y, WString s)
{
	int n = 0;
	int dh = 14;
	
	int line_size = 13;
	
	while (n + line_size < s.GetCount())
	{
		String next = s.Mid(n, line_size);
		n += line_size;
		w.DrawTexe(x, y, next);
		y += dh;
	}
	
	String next = s.Mid(n);
	w.DrawTexe(x, y, next);
}


regards
omari.
Re: "\n" does not work on DrawText [message #46121 is a reply to message #46091] Fri, 11 March 2016 22:13 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Thanks Smile
Previous Topic: Can't Ultimate++ use Japanese?
Next Topic: Can't Ultimate++ use Japanese?
Goto Forum:
  


Current Time: Fri Apr 19 21:00:37 CEST 2024

Total time taken to generate the page: 0.05312 seconds