File: unitsummary.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (78 lines) | stat: -rw-r--r-- 1,832 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
unit UnitSummary;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, FPDocFiles, StdCtrls, ExtCtrls,
  LCLIntf;

type

  { TFormSummary }

  TFormSummary = class(TForm)
    Button1: TButton;
    Button2: TButton;
    LabelFileName: TLabel;
    PaintBox: TPaintBox;
    procedure PaintBoxPaint(Sender: TObject);
  private
  public
    OldInfo, NewInfo: TFPDocInfo;
  end; 

var
  FormSummary: TFormSummary;

implementation

{$R *.lfm}

{ TFormSummary }

procedure TFormSummary.PaintBoxPaint(Sender: TObject);
var
  Y: Integer;
  
  procedure AddItem(S: String; R: Integer);
  begin
    if R = 0 then Exit;
    if R > 0 then
    begin
      SetTextColor(PaintBox.Canvas.Handle, clGreen);
      PaintBox.Canvas.TextOut(4, Y, Format('Added ' + S + ': %d', [R]));
    end
    else
    begin
      SetTextColor(PaintBox.Canvas.Handle, clRed);
      PaintBox.Canvas.TextOut(4, Y, Format('Removed ' + S + ': %d', [-R]));
    end;
    
    Inc(Y, PaintBox.Canvas.TextHeight('W') + 4);
  end;
  
begin
  Y := 4;

  AddItem('packages', NewInfo.Packages - OldInfo.Packages);
  AddItem('modules', NewInfo.Modules - OldInfo.Modules);
  AddItem('topics', NewInfo.Topics - OldInfo.Topics);
  AddItem('elements', NewInfo.Elements - OldInfo.Elements);
  AddItem('non empty elements', NewInfo.ElementsNonEmpty - OldInfo.ElementsNonEmpty);
  AddItem('shorts', NewInfo.Shorts - OldInfo.Shorts);
  AddItem('descriptions', NewInfo.Descriptions - OldInfo.Descriptions);
  AddItem('errors', NewInfo.Errors - OldInfo.Errors);
  AddItem('see alsos', NewInfo.SeeAlsos - OldInfo.SeeAlsos);
  AddItem('examples', NewInfo.Examples - OldInfo.Examples);
  
  if Y = 4 then
  begin
    SetTextColor(PaintBox.Canvas.Handle, clBlack);
    PaintBox.Canvas.TextOut(4, Y, 'No change was made!');
  end;
end;

end.