home *** CD-ROM | disk | FTP | other *** search
- {************************************************}
- { }
- { Turbo Vision 2.0 Demo }
- { Copyright (c) 1992 by Borland International }
- { }
- {************************************************}
- { }
- { With hungarian extension. Copyright '97 R4s ! }
- { }
- {************************************************}
-
- {$X+,V-}
-
- unit Count;
-
- INTERFACE
-
- uses Objects, Drivers, Views;
-
-
- type
- PCountView = ^TCountView;
- TCountView = Object(TView)
- Current: Longint;
- Count : Longint;
- constructor Init(var Bounds: TRect);
- constructor Load(var S: TStream);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure SetCount(NewCount: Longint);
- procedure IncCount;
- procedure DecCount;
- procedure SetCurrent(NewCurrent: Longint);
- procedure IncCurrent;
- procedure DecCurrent;
- procedure Store(var S: TStream); virtual;
- end;
-
- procedure RegisterCount;
-
- const
- CCountView = #1#2#3#8#9;
-
- RCountView: TStreamRec = (
- ObjType: 992;
- VmtLink: Ofs(TypeOf(TCountView)^);
- Load : @TCountView.Load;
- Store : @TCountView.Store
- );
-
- IMPLEMENTATION
-
- { TCountView }
- constructor TCountView.Init(var Bounds:TRect);
- begin
- Inherited Init(Bounds);
- SetCount(0);
- SetCurrent(1);
- end;
-
- constructor TCountView.Load(var S: TStream);
- begin
- Inherited Load(S);
- S.Read(Current, SizeOf(Current));
- S.Read(Count, SizeOf(Count));
- end;
-
- procedure TCountView.Draw;
-
- function GetRag(ForRag: Longint): String;
- begin
- case ForRag mod 10 of
- 0, 3, 6, 8: GetRag:='ból';
- 1, 2, 4, 5, 7, 9, 10: GetRag:='bôl';
- else GetRag:='bôl';
- end;
- end;
-
- function ConvertLongintToString(d: Longint): String;
- var S: String;
- begin
- Str(d,s);
- ConvertLongintToString:=S;
- end;
-
- function GetNevelo(ANevelo: Longint): String;
- var
- S: String;
- B, i: Byte;
- L: Longint;
- begin
- S:=ConvertLongintToString(ANevelo);
- B:=Byte(Length(S));
- L:=10;
- for i:=1 to B-1 do L:=L*10;
- B:=ANevelo mod L;
- case B of
- 0, 2, 3, 4, 6, 7, 8, 9: GetNevelo:='A';
- 1, 5, 10: GetNevelo:='Az';
- else GetNevelo:='A';
- end;
- end;
-
- function GetHanyadik(ADik: Longint): String;
- begin
- if ADik = 1 then GetHanyadik:='elsô'
- else GetHanyadik:=ConvertLongintToString(ADik)+'.';
- end;
-
- var
- B: TDrawBuffer;
- C: Word;
- {Params : Array[0..1] of Longint;} {Remarked By R4s}
- Start : Word;
- First : String[10];
- Display: String[20];
- begin
- C := GetColor(2); { Uses same color as frame }
- MoveChar(B, '═', C, Size.X);
-
- {Params[0] := Current;
- Params[1] := Count;
- FormatStr(Display, ' ~%d~ of %d ', Params);} {Remarked By R4s}
- FormatStr(Display, ' '+GetNevelo(Current)+' '+GetHanyadik(Current)+' a %d-'+GetRag(Count), Count);
-
- { If Current is greater than Count, display Current as highlighted }
- if Current > Count then C := GetColor($0504)
- else C := GetColor($0202);
-
- MoveCStr(B, Display, C);
- WriteLine(0, 0, Size.X, Length(Display), B);
- end;
-
- function TCountView.GetPalette: PPalette;
- const
- P: string[Length(CCountView)] = CCountView;
- begin
- GetPalette := @P;
- end;
-
- procedure TCountView.SetCount(NewCount:Longint);
- begin
- Count := NewCount;
- DrawView;
- end;
-
- procedure TCountView.IncCount;
- begin
- SetCount(Count + 1);
- end;
-
- procedure TCountView.DecCount;
- begin
- SetCount(Count - 1);
- end;
-
- procedure TCountView.SetCurrent(NewCurrent:Longint);
- begin
- Current := NewCurrent;
- DrawView;
- end;
-
- procedure TCountView.IncCurrent;
- begin
- SetCurrent(Current + 1);
- end;
-
- procedure TCountView.DecCurrent;
- begin
- SetCurrent(Current - 1);
- end;
-
- procedure TCountView.Store(var S: TStream);
- begin
- Inherited Store(S);
- S.Write(Current, SizeOf(Current));
- S.Write(Count, SizeOf(Count));
- end;
-
- procedure RegisterCount;
- begin
- RegisterType(RCountView);
- end;
-
- END.