StdTables.Table, aligning cell content to right or center

All graphical and user interfaces problems

StdTables.Table, aligning cell content to right or center

Postby manumart1 » Thu Mar 16, 2017 12:18 pm

Problem: if the string shown in a cell of StdTables.Table is very large, the aligning to right or center does not work.

StdTables, align to right or center.png
(11.66 KiB) Not downloaded yet

Module PrivTestStdTable and Formulary.txt
(3.55 KiB) Downloaded 23 times


In order to align to right, one must click on the right part of the column header. One can also change the width of the column dynamically (click and drag the border of the column), and the new content gets updated to the new size.

Same problem aligning to center.

Trying to solve this, I arrived to these changes to module StdTables:
Code: Select all
PROCEDURE DrawLabel ...
   VAR ...
      k, end, delta: INTEGER;
BEGIN
   ...
   sw := font.StringWidth(s);
   IF sw > w THEN
      IF (rw >= 0) & (LEN(s) >= 4) THEN
         IF mode = left THEN
            rw := w - font.StringWidth("...");
            i := f.CharIndex(0, rw, s, font);
            IF i > 0 THEN DEC(i) END;
            IF i > LEN(s) - 4 THEN i := LEN(s) - 4 END;
            s[i] := "."; s[i+1] := "."; s[i+2] := "."; s[i+3] := 0X;
         ELSIF mode = right THEN
            (* Instead of this, is it better to reverse array, align to left, and reverse again? *)
            s[0] := "."; s[1] := "."; s[2] := ".";
            i := f.CharIndex(0, w, s, font);
            end := LEN(s$) - 1;
            Log.String("Init: '" + s + "' "); Log.String("  len="); Log.Int(LEN(s$)); Log.String("  end="); Log.Int(end); Log.String("  i = "); Log.Int(i);Log.Ln;
            WHILE (i <= end) DO
               (* We could remove one char by one char to strinsg "s" from the left, until if fits, but instead, "delta" gives us a faster way to advance, although not very precise. *)
               delta := end - i + 2; IF delta < 1 THEN delta := 1 END;
               DEC(end, delta);
               FOR k := 3 TO end DO s[k] := s[k + delta] END;
               IF end >= -1 THEN s[end + 1] := 0X ELSE s[0] := 0X END;
               i := f.CharIndex(0, w, s, font);
               Log.String("delta="); Log.Int(delta); Log.String("   '" + s + "' "); Log.String("  len="); Log.Int(LEN(s$)); Log.String("  end="); Log.Int(end); Log.String("  i ="); Log.Int(i);Log.Ln;
            END;
         ELSE (* center *)
            s[0] := "."; s[1] := "."; s[2] := ".";
            end := LEN(s$) - 1;
            IF end > 2 THEN s[end - 2] := "."; s[end - 1] := "."; s[end] := "." END;
            i := f.CharIndex(0, w, s, font);
            Log.String("Init: '" + s + "' "); Log.String("  len="); Log.Int(LEN(s$)); Log.String("  end="); Log.Int(end); Log.String("  i = "); Log.Int(i);Log.Ln;
            WHILE (i <= end) DO
               (* We could remove to strinsg "s" in each iteration one char from the left and another from the right, until if fits, but instead, "delta" gives us a faster way to advance, although not very precise. *)
               delta := (end - i + 2) DIV 2; IF delta < 1 THEN delta := 1 END;
               DEC(end, delta * 2);
               FOR k := 3 TO end - 3 DO s[k] := s[k + delta] END;
               IF end > 2 THEN s[end - 2] := "."; s[end - 1] := "."; s[end] := "." END;
               IF end >= -1 THEN s[end + 1] := 0X ELSE s[0] := 0X END;
               i := f.CharIndex(0, w, s, font);
               Log.String("delta="); Log.Int(delta); Log.String("   '" + s + "' "); Log.String("  len="); Log.Int(LEN(s$)); Log.String("  end="); Log.Int(end); Log.String("  i ="); Log.Int(i);Log.Ln;
            END;
         END;
         sw := font.StringWidth(s)
      ELSE sw := 0
      END
   END;
   ...
END DrawLabel;

PROCEDURE DrawField ...
   same changes as DrawLabel
END DrawField;


I have not tried, but imagine same problem happens to SqlControls.DrawField.
manumart1
 
Posts: 60
Joined: Tue Sep 17, 2013 6:25 am

Re: StdTables.Table, aligning cell content to right or cente

Postby Josef Templ » Mon Mar 20, 2017 6:31 am

Since we are reading text from left to right, I am not sure if moving the "..."
symbols is a big advantage over the current solution.
In the case of centered columns you have "..." twice. This reduces the
readable part further.

- Josef
Josef Templ
 
Posts: 137
Joined: Tue Sep 17, 2013 6:50 am

Re: StdTables.Table, aligning cell content to right or cente

Postby manumart1 » Mon Mar 20, 2017 7:35 am

The advantage is that aligning to left one can see the beginning, and aligning to right one can see the ending. This way one has a chance to see the full string, without having to enlarge the column width.
manumart1
 
Posts: 60
Joined: Tue Sep 17, 2013 6:25 am

Re: StdTables.Table, aligning cell content to right or cente

Postby Josef Templ » Thu Mar 23, 2017 5:57 am

manumart1 wrote:The advantage is that aligning to left one can see the beginning, and aligning to right one can see the ending. This way one has a chance to see the full string, without having to enlarge the column width.


I see.
But for 'centered' it would not be required to have the '...' at both ends.

- Josef
Josef Templ
 
Posts: 137
Joined: Tue Sep 17, 2013 6:50 am

Re: StdTables.Table, aligning cell content to right or cente

Postby Ivan Denisov » Fri Mar 24, 2017 6:41 am

This is important for printing. For display it is possible to show full title in some rectangle like it is done in windows prompt dialog. What do you think?
User avatar
Ivan Denisov
 
Posts: 209
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: StdTables.Table, aligning cell content to right or cente

Postby manumart1 » Fri Mar 24, 2017 8:18 am

Ivan Denisov wrote:For display it is possible to show full title in some rectangle like it is done in windows prompt dialog.

I do not understand well.
A StdTables.Table has several rows. If I want to see the full string inside a cell, are you thinking about clicking the cell and then a window would be opened, showing the full string?
This leads me to the idea of tooltip, but I am not able to use the module CpcControlTips for a StdTables.Table ...
manumart1
 
Posts: 60
Joined: Tue Sep 17, 2013 6:25 am

Re: StdTables.Table, aligning cell content to right or cente

Postby Ivan Denisov » Fri Mar 24, 2017 9:52 am

For example, if user move a mouse to some cell and freeze for a second. In the Paint procedure we can draw some graphics over the table with some rectangle and the full text.
Better way is to install new frame with TextView and put the content of the string in this text view. One more idea is to make scrolling of the string inside the cell.

More easy way without modification of the StdTables is to add the Notifier to the table properties.
The Notifier allows to detect which cell was pressed and update some global variable with a string and update it in the form.
solution.png

NotifierDemo.txt
(4.03 KiB) Downloaded 10 times


Also Ivan Kuzmitsky did very nice work!
http://oberoncore.ru/bbcc/subs/grid/start
Did you try his advanced tables subsystem?
User avatar
Ivan Denisov
 
Posts: 209
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: StdTables.Table, aligning cell content to right or cente

Postby manumart1 » Fri Mar 24, 2017 12:47 pm

Thank you Ivan, for your Notifier example.

I installed the Grid subsystem, which requires two other subsystems:

I executed some examples from "Grid/Docu/Sys-Map.odc".
Looks fine, but I do not understand the Russian language.

The example "Grid/Docu/Obx3.odc" is similar to your Notifier example.
manumart1
 
Posts: 60
Joined: Tue Sep 17, 2013 6:25 am

Re: StdTables.Table, aligning cell content to right or cente

Postby Ivan Denisov » Fri Mar 24, 2017 4:10 pm

This month Google connect some great neural network for translation from Russian to English and vice versa.
In March 2017, these three more languages are enabled: Russian, Hindi and Vietnamese.

https://en.wikipedia.org/wiki/Google_Ne ... ranslation

So the quality of the translation increased a lot. Just copy documentation to Google Translator and you will get information you need.

Ivan's subsystem is more advanced in case of visual settings and even allow to add any views in the cells.
I have no mood now to translate and adopt it to English. But I think it can be done in future.
User avatar
Ivan Denisov
 
Posts: 209
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia


Return to GUI problems

Who is online

Users browsing this forum: No registered users and 1 guest

cron