#1 2017-08-20 17:41:47

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

(TGDIPages) DrawText display the text vertically instead of horizontal

probably a newbie issue...

I'm trying to do a report, and columns work great, however when I tried to use DrawText, it seems like the library is doing a new line after each letter!, again no problem when I use DrawTextAcrossCols.

procedure TSignalTicket.Execute;
var
  arr_ind : integer;
  FData : TData;
  FQuery, qSignalDetail  : TFDQuery;
  n : String;
  qry : String;
  whr : String;
  evts: String;

  procedure addWhere(stm : String);
  begin
    if whr = '' then
      whr := ' where (' + stm + ')'
    else
      whr := whr + ' and (' + stm + ')';
  end;

begin
  Title := 'Signal Ticket';

  inherited;

  qry :=
    ' SELECT c.name AS "Customer",  s.utc, ulc.name AS "Classification", s.UL_KEy, s.ul_sounder, s.NAME AS "Site", st.name AS "Type", sr.name AS "Resolution", sh.* FROM SIGNAL_HISTORY sh ' +
    ' INNER JOIN SIGNAL_TYPES st ON st.id= sh.signal_type ' +
    ' LEFT JOIN SIGNAL_RESOLUTIONS sr ON sr.id=sh.SIGNAL_RESOLUTION_ID ' +
    ' INNER JOIN CUSTOMERS c ON c.id=sh.CUSTOMER_ID ' +
    ' INNER JOIN SITES s ON s.id = sh.SITE_ID ' +
    ' LEFT JOIN UL_CLASSIFICATIONS ulc ON ulc.id = s.UL_CLASSIFICATION' ;


  //addWhere('sh.id = ' + QuotedStr(FParams.Values['signal_id']));
  addWhere('sh.id = ' + QuotedStr('3b938dd1-9f34-4ab2-bcc5-b9b9c34c2b15'));


  FData := ConnCached.GetDataObj;
  try
    FQuery := FData.GetQuery;

    FQuery.Open(qry + whr);

    RepObj.Font.Style := [];
    RepObj.AddColumns([10,40,10,40]);
    RepObj.DrawTextAcrossCols(['Customer', FQuery.FieldByName('Customer').AsString,'Date', FQuery.FieldByName('dt').AsString]);
    RepObj.DrawTextAcrossCols(['Site', FQuery.FieldByName('Site').AsString,'Signal', FQuery.FieldByName('Type').AsString]);

    RepObj.DrawTextAcrossCols(['Panel', FQuery.FieldByName('Panel').AsString,'Resolution', FQuery.FieldByName('Resolution').AsString]);
    RepObj.DrawTextAcrossCols(['Priority', FQuery.FieldByName('Priority').AsString,'UL Class',FQuery.FieldByName('Classification').AsString]);
    RepObj.DrawTextAcrossCols(['Signal', FQuery.FieldByName('Code').AsString,'UL Keys', FQuery.FieldByName('UL_KEY').AsString]);
    RepObj.DrawTextAcrossCols(['Zone', FQuery.FieldByName('Zone').AsString,'UL Sounder', IIF(FQuery.FieldByName('UL_SOUNDER').AsString = 't', 'Yes','No' )]);

    RepObj.DrawTextAcrossCols(['Active', IIF(FQuery.FieldByName('active').AsString = 't', 'Yes','No' ),'UTC', FQuery.FieldByName('UTC').AsString]);

    RepObj.NewLine;
    RepObj.ClearColumns;
    RepObj.DrawText('Log',true);
    RepObj.AddColumns([20,20, 70]);
    RepObj.AddColumnHeaders(['Time', 'Operator', 'Description'],true,true);
    qSignalDetail := FData.GetQuery;

    qSignalDetail.Open(
      ' SELECT u.name AS "Operator", shd.* FROM SIGNAL_HISTORY_DETAIL shd ' +
      ' LEFT JOIN USERS u ON shd.user_id = u.id ' +
      '  where signal_id = ' + QuotedStr(FQuery.FieldByName('ID').AsString) + ' order by dt' );

    while not qSignalDetail.Eof do  begin
      RepObj.DrawTextAcrossCols([
         qSignalDetail.FieldByName('dt').AsString,
         qSignalDetail.FieldByName('Operator').AsString,
         qSignalDetail.FieldByName('data').AsString]);

      qSignalDetail.Next;
    end;


    RepObj.NewLine;
    RepObj.DrawText('Runners',False);
    RepObj.ClearColumns;
    RepObj.AddColumns([15, 16, 16, 4, 4, 4,20]);
    RepObj.AddColumnHeaders(['Runner', 'Dispatched', 'Arrived', 'Min','Key','Ver','Notes'],true,true);
    qSignalDetail := FData.GetQuery;

    qSignalDetail.Open(
      ' SELECT re.* FROM UL_RUNNER_EVENTS re where signal_id = ' + QuotedStr(FQuery.FieldByName('ID').AsString) + ' order by dispatch_time' );

    while not qSignalDetail.Eof do  begin
      RepObj.DrawTextAcrossCols([
         qSignalDetail.FieldByName('name').AsString,
         qSignalDetail.FieldByName('dispatch_time').AsString,
         qSignalDetail.FieldByName('arrival_time').AsString,
         qSignalDetail.FieldByName('ul_travel_time').AsString,
         qSignalDetail.FieldByName('key_used').AsString,
         qSignalDetail.FieldByName('verification_method').AsString,
         qSignalDetail.FieldByName('notes').AsString
         ]);

      qSignalDetail.Next;
    end;

    RepObj.NewLine;

  finally
    ConnCached.ReleaseDataObj(FData);
  end;

  RepObj.EndDoc;
end;

Last edited by mrluis (2017-08-20 17:45:49)

Offline

#2 2017-08-20 17:43:48

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Ups, forgot there is an init section that runs before the posted code....

procedure TReport.InitReport;
begin
  RepObj := TGDIPages.Create(FAOwner);
  RepObj.BeginDoc;
  // header and footer
  RepObj.AddTextToHeader('User Access Report');
  RepObj.AddLineToHeader(false);
  RepObj.AddLineToFooter(false);

  RepObj.BeginDoc;
  // header and footer
  RepObj.AddTextToHeader(FTitle);
  if FParamHeader <> '' then begin

    RepObj.Font.Size := 8;
    RepObj.AddTextToHeader('Params:' + FParamHeader);
    end;
  RepObj.AddLineToHeader(false);
  RepObj.AddLineToFooter(false);

  RepObj.Font.Size := 8;

  RepObj.Font.Style := [fsItalic];
  RepObj.SaveLayout;
  RepObj.TextAlign :=taRight;
  RepObj.AddTextToFooterAt('Page <<pagenumber>>',RepObj.RightMarginPos);
  RepObj.TextAlign :=taJustified;
  RepObj.Font.Style := [];

  RepObj.RestoreSavedLayout;

  RepObj.AddTextToFooter(DateTimeToStr(Now));

end;

Last edited by mrluis (2017-08-20 17:46:04)

Offline

#3 2017-08-20 17:51:47

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Notice how "Log" and "Runners" goes downward (and also how the last character of "Runner" overstep on the next section (columns)

RepObj.DrawText('Log',true);
RepObj.DrawText('Runners',False);

I assume the new line parameter on runners is why the last character is overriding, however, I still can't figure how to draw the text normally

FluxBB bbcode test

Last edited by mrluis (2017-08-20 17:54:11)

Offline

#4 2017-08-20 19:29:16

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Offline

#5 2017-08-20 20:45:15

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

I dislike to modify someone else code, but by changing this I fixed the problem. I'm sure the code is correct and that I forgot to setup something... but not sure what...

in the procedure TrimLine I changed....

Old code...

  if not Fits then // fix API error (too big text) by rough binary approximation
    repeat
      len := len shr 1;
    until (len=0) or Fits;

change to simply...

  
  Fits;

after that modification, my report shows correctly...

any suggestion what I might have done wrong!

Offline

#6 2017-08-21 09:44:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

I am not able to reproduce the issue here.

Are you using latest version of the unit?
Current is 1.18.3799.

Offline

#7 2017-08-21 10:28:55

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

going to the file, the last modification was Version 1.18 ( - renamed SQLite3Pages.pas to mORMotReport.pas.....)

but I just downloaded!  did I picked up the wrong one!  neutral

I assume that's a file version, how can I check my full version?

Last edited by mrluis (2017-08-21 10:37:43)

Offline

#8 2017-08-21 14:44:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Check the SynopseCommit.inc file in your download.

Offline

#9 2017-08-21 23:09:24

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

sorry for the late response....   1.18.1417

Offline

#10 2017-08-21 23:13:12

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Offline

#11 2017-08-21 23:31:58

mrluis
Member
From: Florida
Registered: 2017-08-20
Posts: 24

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

Updated to the latest (from github) and the problem is still there!

Offline

#12 2017-08-22 06:17:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Re: (TGDIPages) DrawText display the text vertically instead of horizontal

I'm not able to fix the problem.

Please provide some reproducible example, stand-alone, and not inlined within the forum messages, as stated by the forum rules.

Offline

Board footer

Powered by FluxBB