CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

AutoSize

by etwoss » 05 May 2014 15:00

Hi

If i set AutoSize to false, should the labels text not become wider than made in design?

In design the labels text goes until the chart
It would be nice if the control shows ... at the end and a hint with the complete text

is there any way to test the length of the text value?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by etwoss » 02 Jun 2014 09:19

I understand AutoSize does nothing

I played around with ResizeOptions like Max but whatever i do i can't get the labelEx to have a Max width.

A workaround is to get '...'behind the text if it does not fit , and put the complete value in the hint:

Code: Select all
procedure IMSetText(var ALabel: TIWCGJQLabelEx);
var
  Width: Integer;
  i : Integer;
  WPunt: Integer;

  function CalcTextWidth(const AText : String; const AFont: TFont) : Integer;
  var
    bmp: TBitmap;
  begin
    bmp := TBitmap.Create;
    try
      bmp.Canvas.Font.Assign(AFont);
      Result := bmp.Canvas.TextWidth(AText);
    finally
      bmp.Free;
    end;
  end;
begin
  Width := CalcTextWidth(ALabel.Text, TFont(ALabel.Font));

  if (Width > ALabel.Width)  then
  begin
    WPunt := CalcTextWidth('...', TFont(ALabel.Font));

    i := Length(ALabel.Text);

    while (Width > (ALabel.Width - WPunt)) do
    begin
      Width := CalcTextWidth(Copy(ALabel.Text, 1, i), TFont(ALabel.Font));
      i := i - 1;
    end;


   ALabel.Hint :=  ALabel.Text;
   ALabel.Text := Copy(ALabel.Text, 1, i) + '...';

  end;

end;


Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by assapan » 04 Jun 2014 15:38

Hi etwoss,

If i understand well what you are trying to do , you are calculating the drawing width of the characters but this is done on the server side with server resolution so it not related with client side ?!
Have i missed something ?
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by etwoss » 04 Jun 2014 15:46

Hi

Have not seen any problems so far

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 04 Jun 2014 15:50

we agree absolutely with assapan
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 05 Jun 2014 08:18

Hi

So are there any other solutions?

It would be nice give the LabelEx the possisbility to have a max with and if you put in a text which needs more space it will automatically shorten it and add ... at the end, and sets its hint to the full value.

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 05 Jun 2014 09:40

One of possible solution is setting StyleRenderOptions.RenderSize=False

Another, much more complex, is calculating the size in browser, with javascript, as described in

http://www.cgdevtools.com/cgforum/viewtopic.php?f=3&t=1078&hilit=.width
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 06 Jun 2014 09:40

Hi

Tried StyleRenderOptions.RenderSize=False

Code: Select all
      object IWCGJQLabelEx1: TIWCGJQLabelEx
        Left = 32
        Top = 32
        Width = 33
        Height = 21
        TabOrder = 15
        Version = '1.0'
        StyleRenderOptions.RenderSize = False
        Text = 'This is a loooooooooooooooong text'
        NoWrap = True
      end


Still showing whole text

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 06 Jun 2014 10:16

Still showing whole text


This is the purpose of AutoSize, the text is always displayed.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to JQLabelEx

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.