Page 1 of 1

AutoSize

PostPosted: 05 May 2014 15:00
by etwoss
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

Re: AutoSize

PostPosted: 02 Jun 2014 09:19
by etwoss
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

Re: AutoSize

PostPosted: 04 Jun 2014 15:38
by assapan
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 ?

Re: AutoSize

PostPosted: 04 Jun 2014 15:46
by etwoss
Hi

Have not seen any problems so far

Eric

Re: AutoSize

PostPosted: 04 Jun 2014 15:50
by Jorge Sousa
we agree absolutely with assapan

Re: AutoSize

PostPosted: 05 Jun 2014 08:18
by etwoss
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

Re: AutoSize

PostPosted: 05 Jun 2014 09:40
by Jorge Sousa
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

Re: AutoSize

PostPosted: 06 Jun 2014 09:40
by etwoss
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

Re: AutoSize

PostPosted: 06 Jun 2014 10:16
by Jorge Sousa
Still showing whole text


This is the purpose of AutoSize, the text is always displayed.