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 |
|
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]}}]
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]}}]
With my little hack it again looks like it should:
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 03:36:29 CEST 2024
Total time taken to generate the page: 0.02990 seconds
|