View Issue Details

IDProjectCategoryView StatusLast Update
0002127JEDI VCL00 JVCL Componentspublic2004-09-11 01:35
Reportermiracle2kAssigned ToAHUser 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 BETA 
Target VersionFixed in Version 
Summary0002127: JvgStaticText - ftaBroadwise painting
DescriptionIf the Alignment property of an TJvgStaticText component is set to ftaBroadwise, there is an issue when drawing the last line. If this line is only short (say two words for example), the first word is at the beginning of the line, the second one at the end. In such a case (were the width needed is considerably smaller than the amount available, the text should be painted left justified.
Additional InformationI made the following changes to achieve this, but it was only a quick hack and is probably not the prettiest solution.

In DrawTextBroadWise, replace

*************
      begin
        if LexemCount > 1 then
          Dec(LexemCount);
        DrawLine(Width - (LineWidth - Size.cx));
      end
      else
        DrawLine(Width - LineWidth)
      end;
*************

with

*************

      begin
        if LexemCount > 1 then
          Dec(LexemCount);
        DrawLine(Width - (LineWidth - Size.cx));
      end
      else begin
        if ((Width - LineWidth) / Width) < 0.3 then
          DrawLine(Width - LineWidth)
        else
          DrawLineLeftAligned;
      end;
*************

Note that 0.3 is a factor that specifies the percentage of space that the available width must exceed the width needed for the text. That could be made configurable via a property.

DrawLineLeftAligned() looks like this:

  procedure DrawLineLeftAligned;
  var
    i, DrawPos1, DrawPos2: Integer;
    Lexem: string;
  begin
    DrawPos1 := DrawPos;
    DrawPos2 := DrawPos;
    LineWidth := 0;
    for i := 1 to LexemCount do begin
      Lexem := Lexem + GetNextLexem(DrawPos1, DrawPos2, i = 1);
      DrawPos1 := DrawPos2;
    end;
    TextOut(Canvas.Handle, 0, LineNo * TextHeight, PChar(Lexem), Length(Lexem));
  end;
TagsNo tags attached.

Activities

AHUser

2004-09-11 01:35

developer   ~0005213

Thanks.

Fixed in CVS.

Issue History

Date Modified Username Field Change
2004-09-06 05:08 miracle2k New Issue
2004-09-11 01:35 AHUser Status new => resolved
2004-09-11 01:35 AHUser Resolution open => fixed
2004-09-11 01:35 AHUser Assigned To => AHUser
2004-09-11 01:35 AHUser Note Added: 0005213