//---------------------------------------------------------------------------
#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->AddNL("Query", sncomHeading,1);

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

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

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

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

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

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

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

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

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

  rv->AddBulletEx("", 0, il, 0);
  rv->Add("Memo1: ",sncomKeyword);
  rv->AddTextNL(Memo1->Lines->Text,sncomNormal, -1, 0);
  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("This RichView is only for view, do not click it", "Info",
                         MB_OK | MB_ICONEXCLAMATION);
}
//---------------------------------------------------------------------------
