STINFPAN

Top  Previous  Next

{ StellaMAP komponens készlet:

 

TStInfopanel

------------

A TStellaMAP komponenssel együttműködve a rajzlemek láthatóságának beállítására

és számának kijelzésére szolgál.

}

 

unit Stinfpan;

 

interface

 

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,

Forms, Dialogs, ExtCtrls, StdCtrls, StMap16W, StMap16, AlmType, Szoveg;

 

type

TStInfopanel = class(TPanel)

private

  cbox : array[1..4] of TCheckBox;

  FStellaMap: TStMapW;

  FVisibleElements: TVisibleSet;

  procedure SetVisibleElements(Value:TVisibleSet);

  procedure SeTStMapW(Value:TStMapW);

  procedure WMSize(var Msg: TWMSize); message WM_SIZE;

protected

  ora : TTimer;

  procedure Resize; override;

  procedure Timer(Sender:TObject);

  procedure Click(Sender:TObject);

  procedure Notification(AComponent: TComponent;

    Operation: TOperation); override;

public

  constructor Create(AOwner:TComponent);override;

  destructor Destroy;override;

published

  property StellaMapSource: TStMapW read FStellaMap write SeTStMapW;

  property VisibleElements: TVisibleSet read FVisibleElements write SetVisibleElements;

  property Align;

end;

 

Var

StInfopanel: TStInfopanel;

stm: TStMapW;

belep: boolean;

i: integer;

szam: array[1..4] of longint;

lathato : array[1..4] of boolean;  {Rajzelemek láthatósága}

 

const s : array[1..4] of string = ('Pont','Vonal','Felirat','Jelkulcs');

 

implementation

 

constructor TStInfopanel.Create(AOwner:TComponent);

begin

   inherited Create(AOwner);

   stm:=nil;

   FStellaMap:=nil;

   For i:=1 to 4 do begin

       cbox[i]:=TCheckBox.Create(Self);

       cbox[i].Parent:=Self;

       cbox[i].Name := 'CBOX'+IntToStr(i);

       cbox[i].Tag := i;

       cbox[i].Hint:=s[i];

       cbox[i].OnClick := Click;

       cbox[i].Width:=50;

       cbox[i].Height:=10;

   end;

   belep:=True;

   Width := 90;

   Height := 74;

   Font.Name := 'Courier';

   Font.Size := 8;

   Caption := '';

   Resize;

   ora := TTimer.Create(Self);

   ora.OnTimer := Timer;

   ora.Interval:=100;

end;

 

destructor TStInfopanel.Destroy;

begin

   stm:=nil;

   ora.Free;

   For i:=1 to 4 do cbox[i].Free;

   inherited Destroy;

end;

 

procedure TStInfopanel.WMSize(var Msg: TWMSize);

begin

  inherited;

  Resize;

end;

 

procedure TStInfopanel.SeTStMapW(Value:TStMapW);

begin

   FStellaMap:=Value;

   stm:=StellaMapSource;

end;

 

procedure TStInfopanel.SetVisibleElements(Value:TVisibleSet);

begin

FVisibleElements := Value;

end;

 

procedure TStInfopanel.Resize;

var tav,t: integer;

begin

 Caption := '';

 tav := (Height-4*cbox[1].Height) div 5;

 For i:=1 to 4 do begin

     cbox[i].Width:=Width-10;

     cbox[i].Left := (Width - cbox[i].Width) div 2;

     If i=1 then cbox[i].Top := tav

        else cbox[i].Top  := cbox[i-1].Top + tav + cbox[1].Height;

 end;

 invalidate;

 inherited Resize;

end;

 

procedure TStInfopanel.Timer;

begin

   stm:=StellaMapSource;

 If stm<>nil then begin

    stm.Streammeretek(stm.cw);

    szam[1]:=stm.cw.pontszam;

    szam[2]:=stm.cw.vonalszam;

    szam[3]:=stm.cw.szovegszam;

    szam[4]:=stm.cw.jelkulcsszam;

    lathato[1]:=stm.cw.pontlatszik;

    lathato[2]:=stm.cw.vonallatszik;

    lathato[3]:=stm.cw.szoveglatszik;

    lathato[4]:=stm.cw.jelkulcslatszik;

 end;

 For i:=1 to 4 do

     cbox[i].Caption := Copy(s[i],1,1)+': '+PadR(IntToStr(szam[i]),' ',6);

 For i:=1 to 4 do begin

     Try

       If cbox[i].Checked <> lathato[i] then

          cbox[i].Checked := lathato[i];

     except

       On Exception do exit;

     end;

 end;

 belep:=False;

end;

 

procedure TStInfopanel.Click(Sender:TObject);

var lat: TVisibleRajzelem;

begin

If not belep then begin

 tag := (Sender as TCheckBox).Tag;

 lat := TVisibleRajzelem(Tag-1);

 If (Sender as TCheckBox).Checked then stm.Latszik := stm.Latszik+[lat]

 else stm.Latszik := stm.Latszik-[lat];

end;

end;

 

procedure TStInfopanel.Notification(AComponent: TComponent;

Operation: TOperation);

begin

inherited Notification(AComponent, Operation);

if (Operation = opRemove) and (AComponent = StellaMapSource)

then StellaMapSource := nil;

end;

 

end.