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

#include "Demo3Frm.h"
#include "MainFrm.h"
//---------------------------------------------------------------------------
#pragma link "RichView"
#pragma link "RVScroll"
#pragma resource "*.dfm"
TfrmDemo3 *frmDemo3;
//---------------------------------------------------------------------------
__fastcall TfrmDemo3::TfrmDemo3(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TfrmDemo3::BuildSummary()
{
  const AnsiString OffOn[2] = {"Off", "On"};
  const int       Checks[2] = {1, 2};

  rv->Clear();
  rv->AddNLWTag("Query", sncomHeading,1,0);

  rv->AddBulletEx("", 0, il, 0);
  rv->AddNLWTag("Edit1: ", sncomKeyword,-1,0);
  rv->AddNLWTag(Edit1->Text, sncomNormal,-1,0);

  rv->AddBulletEx("", 0, il, 0);
  rv->AddNLWTag("Edit2: ", sncomKeyword,-1,0);
  rv->AddNLWTag(Edit2->Text, sncomNormal,-1,0);

  rv->AddBreakEx(1, rvbsLine, clRed);

  if (RadioGroup1->ItemIndex!=-1)
  {
	rv->AddBulletEx("", 3, il, 0);
	rv->AddNLWTag("Menu: ", sncomKeyword,-1,0);
	rv->AddNLWTag(RadioGroup1->Items->Strings[RadioGroup1->ItemIndex],
	  sncomNormal, -1, 0);
  }

  rv->AddBreakEx(1, rvbsLine, clRed);

  rv->AddNLWTag("Check1: ", sncomKeyword, 0,0);
  rv->AddBulletEx("", Checks[CheckBox1->Checked], il, -1);
  rv->AddNLWTag(OffOn[CheckBox1->Checked], sncomNormal,-1,0);

  rv->AddNLWTag("Check2: ", sncomKeyword, 0,0);
  rv->AddBulletEx("", Checks[CheckBox2->Checked], il, -1);
  rv->AddNLWTag(OffOn[CheckBox2->Checked], sncomNormal,-1,0);

  rv->AddNLWTag("Check3: ", sncomKeyword, 0,0);
  rv->AddBulletEx("", Checks[CheckBox3->Checked], il, -1);
  rv->AddNLWTag(OffOn[CheckBox3->Checked], sncomNormal,-1,0);

  rv->AddBreakEx(1, rvbsLine, clRed);

  rv->AddBulletEx("", 0, il, 0);
  rv->AddNLWTag("Memo1: ",sncomKeyword,-1,0);
  rv->AddTextNLW(Memo1->Lines->Text,sncomNormal, -1, 0, false);
  rv->Format();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo3::Change(TObject *Sender)
{
  BuildSummary();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo3::FormKeyDown(TObject *Sender, WORD &Key,
    TShiftState Shift)
{
  if (Key==VK_ESCAPE)
    Close();  
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo3::rvClick(TObject *Sender)
{
  if (! rv->SelectionExists())
	Application->MessageBox(L"This RichView is only for view, do not click it",
	  L"Info", MB_OK | MB_ICONEXCLAMATION);
}
//---------------------------------------------------------------------------
