//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "VmxLabel.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TVmxLabel *)
{
        new TVmxLabel(NULL);
}
//---------------------------------------------------------------------------
__fastcall TVmxLabel::TVmxLabel(TComponent* Owner)
        : TGraphicControl(Owner)
{
  FLines = new TStringList;
  FMax = 0;
}
//---------------------------------------------------------------------------

void __fastcall TVmxLabel::SetLines (TStrings *New)
{
  FLines->Assign(New);
  FPos = 0;
  Invalidate();
}

void __fastcall TVmxLabel::SetPos (int New)
{
  FPos = New;
  Invalidate ();
}

void __fastcall TVmxLabel::Paint (void)
{
  Canvas->Font->Assign(Font);
  Canvas->Brush->Style=bsClear;
  int cy = 2-FPos*(Canvas->TextHeight("TEXT")+4);
  for (int i = 0; i < FLines->Count; i++)
  {
    Canvas->TextOutA(2,cy,FLines->Strings[i]);
    cy+=Canvas->TextHeight(FLines->Strings[i])+4;
  }
  if (FPos==0&&cy>Height)
  {
    FMax = (cy-Height)/(Canvas->TextHeight("TEXT")+4);
    if (FOnChangeScrollMax != NULL)
      FOnChangeScrollMax(this);
  }
}

namespace Vmxlabel
{
        void __fastcall PACKAGE Register()
        {
                 TComponentClass classes[1] = {__classid(TVmxLabel)};
                 RegisterComponents("VMX", classes, 0);
        }
}
//---------------------------------------------------------------------------
 