home *** CD-ROM | disk | FTP | other *** search
- unit Status;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: OBJECT4 }
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs,
- Messages, Classes, Graphics,
- Controls, Forms, Dialogs,
- StdCtrls, Gauges, ExtCtrls,
- Buttons, ClassDef;
-
- const
- MaxBlue = 10600;
- MaxYellow = 120;
- MaxGreen = 6000;
- MaxViolet = 6000;
-
- type
- TStatusForm = class(TForm)
- Panel1: TPanel;
- gBlue: TGauge;
- gYellow: TGauge;
- gGreen: TGauge;
- gViolet: TGauge;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- BitBtn1: TBitBtn;
- LBlue: TLabel;
- LYellow: TLabel;
- LGreen: TLabel;
- LViolet: TLabel;
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- FBlueTotal: LongInt;
- FYellowTotal: LongInt;
- FGreenTotal: LongInt;
- FVioletTotal: LongInt;
- procedure ZeroTotals;
- procedure TotalWidgets(Widget: TWidget);
- public
- { Public declarations }
- procedure RunAll(Components: TList);
- procedure CalcTotals(Components: TList);
- end;
-
- var
- StatusForm: TStatusForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TStatusForm.ZeroTotals;
- begin
- FYellowTotal := 0;
- FBlueTotal := 0;
- FGreenTotal := 0;
- FVioletTotal := 0;
- end;
-
- procedure TStatusForm.TotalWidgets(Widget: TWidget);
- begin
- if Widget is TYellow then
- FYellowTotal := FYellowTotal + Widget.Quantity;
- if Widget is TBlue then
- FBlueTotal := FBlueTotal + Widget.Quantity;
- if Widget is TGreen then
- FGreenTotal := FGreenTotal + Widget.Quantity;
- if Widget is TViolet then
- FVioletTotal := FVioletTotal + Widget.Quantity;
- end;
-
- procedure TStatusForm.CalcTotals(Components: TList);
- var
- Widget: TWidget;
- i: Integer;
- begin
- ZeroTotals;
- for i := 0 to Components.Count - 1 do begin
- Widget := TWidget(Components[i]);
- TotalWidgets(Widget);
- end;
- end;
-
- procedure TStatusForm.RunAll(Components: TList);
- begin
- CalcTotals(Components);
- LBlue.Caption := IntToStr(FBlueTotal) + '/' + IntToStr(GBlue.MaxValue);
- LYellow.Caption := IntToStr(FYellowTotal) + '/' + IntToStr(GYellow.MaxValue);
- LGreen.Caption := IntToStr(FGreenTotal) + '/' + IntToStr(GGreen.MaxValue);;
- LViolet.Caption := IntToStr(FVioletTotal)+ '/' + IntToStr(GViolet.MaxValue);;
- GBlue.Progress := FBlueTotal;
- GYellow.Progress := FYellowTotal;
- GGreen.Progress := FGreenTotal;
- GViolet.Progress := FVioletTotal;
- ShowModal;
- end;
-
- procedure TStatusForm.FormCreate(Sender: TObject);
- begin
- gBlue.MaxValue := MaxBlue;
- gYellow.MaxValue := MaxYellow;
- gGreen.MaxValue := MaxGreen;
- gViolet.MaxValue := MaxViolet;
- end;
-
- end.
-