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 » U++ Library support » RichText,QTF,RTF... » Possible bug with RichText table zoom (Zooming a richtext text containing tables.)
Possible bug with RichText table zoom [message #43261] Wed, 18 June 2014 10:14 Go to next message
steffen is currently offline  steffen
Messages: 38
Registered: May 2007
Location: Denmark
Member

Hi,

Sorry I don't have time to make a better example right now, but I see this bug after a recent upgrade. The bug was introduced with the RichTable GetWidth implementation in rev. 7361.

I have for some time used the following code to auto adjust the text size in some controls I made for a touch screen:

void DtsLabel::PaintText(Draw &w, String &text, const DtsCtrl::Style *st, TStates state, const Rect& r)
{
	Size txtsz;
	if(text[0] == '\1')
	{
		RichText txt = ParseQTF(text.Begin() + 1, 0);
		Zoom z = GetRichTextStdScreenZoom();
		if (!mScrollable)
		{
			while (z.m)
			{
				txt.ApplyZoom(z);
				txtsz.cx = min(INT_MAX, txt.GetWidth());
				txtsz.cy = txt.GetHeight(Zoom(1, 1), txtsz.cx);
				if ((txtsz.cx != 10000) && (txtsz.cx > r.GetWidth() || txtsz.cy > r.GetHeight()))
					z.m--;
				else
					break;
			}
		}
		else
			txt.ApplyZoom(z);
		txt.Paint(Zoom(1, 1), w, r.left, r.top, r.GetWidth());
	}
	else
	{
...

It should decrease the text size if it does not fit inside the control.
I do this because the entire layout is read from a Json file and parts of the text is dynamic and controlled by some external hardware. So I'm not able to make custom alignments on every layout.

Earlier GetWidth for tables returned 10000, so zooming did not happen, but now it returns a valid width and is zoomed.
Problem is it zooms way too much.

I don't know if my code is any good at all, but it has worked for a couple of years with simpler texts (no tables) in buttons.

I have temporarily avoided the table zoom by adding the following line to my code, after the initial txt.ApplyZoom(z).
				if (txt.IsTable(0)) // TODO: Temporary hack. Tables are zoomed since rev 7361 but they get very small.
					break;


My richtext string looks like this:
[1*@0 {{2:4~a0/0b/15t/15@N [< Status:]::@(252.229.17) [=+76 Idle]}}&{{1:1~B16a0/0@N Selection`::: 60%:: Spray Temp.`::: 58°C:: OAT`::: [$(0.225.0) -5°C]}}]
index.php?t=getfile&id=4565&private=0

But when selection the "Hot At Nozzle" button:
[1*@0 {{2:4~a0/0b/15t/15@N [< Status:]::@(252.229.17) [=+76 Idle]}}&{{1:1~B16a0/0@N Selection`::: Hot At Nozzle:: Spray Temp.`::: 58°C:: OAT`::: [$(0.225.0) -5°C]}}]
index.php?t=getfile&id=4566&private=0

With my little hack it again looks like it should:
index.php?t=getfile&id=4567&private=0
Re: Possible bug with RichText table zoom [message #43393 is a reply to message #43261] Wed, 23 July 2014 08:52 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I would say that the problem is that ApplyZoom actually changes the RichText - and you are applying it repeatedly.

I would perhaps try somtehing like

			while (z.m)
			{
				txt = ParseQTF(text.Begin() + 1, 0);
				txt.ApplyZoom(z);
				txtsz.cx = min(INT_MAX, txt.GetWidth());
				txtsz.cy = txt.GetHeight(Zoom(1, 1), txtsz.cx);
				if ((txtsz.cx != 10000) && (txtsz.cx > r.GetWidth() || txtsz.cy > r.GetHeight()))
					z.m--;
				else
					break;
			}

Previous Topic: Spell-checking
Next Topic: link option
Goto Forum:
  


Current Time: Fri Apr 19 23:53:34 CEST 2024

Total time taken to generate the page: 0.02612 seconds