//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "PopupFrm.h"
#include "MainFrm.h"
//---------------------------------------------------------------------------
#pragma link "RichView"
#pragma link "RVScroll"
#pragma link "RVStyle"
#pragma resource "*.dfm"
TfrmPopup *frmPopup;
//---------------------------------------------------------------------------
__fastcall TfrmPopup::TfrmPopup(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TfrmPopup::Build(int DemoNo)
{
  switch (DemoNo)
  {
    case 1:
    {
      rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("'Checkpoints'", 1, -1, 0);
	  rv->AddNLWTag("Synchronizing document scrolling with list of contents", 0,0,0);
	  rv->AddNLWTag("(This demo loads *.cpp files from application directory)", 0,0,0);
	  break;
	}
	case 2:
	{
	  rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Customizing Styles", 1, -1, 0);
	  rv->AddNLWTag("Interactive customization of document", 0,0,0);
	  break;
	}
	case 3:
	{
	  rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Query Summary", 1, -1, 0);
	  rv->AddNLWTag("Complex query at one look", 0,0,0);
	  break;
	}
	case 4:
	{
	  rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Interactive document", 1, -1, 0);
	  rv->AddNLWTag("Document is a control itself", 0,0,0);
	  break;
	}
	case 5:
	{
	  rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Chat Simulation", 1, -1, 0);
	  rv->AddNLWTag("Autoscroll, URL detection", 0,0,0);
	  break;
	}
    case 6:
    {
      rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Credits Demo:", 1, -1, 0);
	  rv->AddNLWTag("Scrolling text and images on timer", 0,0,0);
	  break;
	}
	case 7:
	{
	  rv->AddBulletEx("",1,frmMain->il,1);
	  rv->AddNLWTag("Search and mark:", 1, -1, 0);
	  rv->AddNLWTag("Search and mark words in editor", 0,0,0);
	  rv->AddNLWTag("(This demo loads MainFrm.cpp from application directory)", 0,0,0);
      break;
    }
  }
  rv->Format();
  Height = rv->DocumentHeight+20;
}
//---------------------------------------------------------------------------
void TfrmPopup::MoveToMouse()
{
  TPoint p;
  GetCursorPos(&p);
  if (p.x+Width>Screen->Width)
    p.x = Screen->Width-Width;
  if (p.y+Height>Screen->Height)
    p.y = Screen->Height-Height;
  Left = p.x;
  Top  = p.y;
}
//---------------------------------------------------------------------------
void TfrmPopup::ShowTopic(int DemoNo)
{
  Build(DemoNo);
  MoveToMouse();
  Show();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPopup::FormKeyPress(TObject *Sender, wchar_t &Key)
{
  Key = 0;
  Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPopup::rvClick(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPopup::FormDeactivate(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPopup::FormClose(TObject *Sender, TCloseAction &Action)
{
  Action = caFree;
}
//---------------------------------------------------------------------------
