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

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "NxInspector"
#pragma link "NxScrollControl"
#pragma link "NxPropertyItemClasses"
#pragma link "NxPropertyItems"
#pragma link "NxEdit"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        NxTrackBarItem1->Value = "50";                
}
//---------------------------------------------------------------------------
void __fastcall TForm1::cmbStyleChange(TObject *Sender)
{
        switch(cmbStyle->ItemIndex)
        {
                case 0: {
                        NextInspector1->Style = psDefault;
                        break;
                }
                case 1: {
                        NextInspector1->Style = psOffice2003;
                        break;
                }
                case 2: {
                        NextInspector1->Style = psOffice2007;
                        break;
                }
                case 3: {
                        NextInspector1->Style = psWhidbey;
                        break;
                }
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
        NxProgressItem1->ProgressColor = clBlue;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::edtRowSizeChange(TObject *Sender)
{
        NextInspector1->RowHeight = edtRowSize->AsInteger;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::chbExpandedClick(TObject *Sender)
{
        if(NextInspector1->SelectedItem != NULL)
        {
                NextInspector1->SelectedItem->Expanded = (chbExpanded->Checked);
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NextInspector1SelectItem(TObject *Sender,
      TNxPropertyItem *Item)
{
        chbExpanded->Checked = NextInspector1->SelectedItem->Expanded;

        chbBoldNonDefault->Checked = NextInspector1->SelectedItem->Options.Contains(itoBoldNonDefault);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
        if(NextInspector1->SelectedItem != NULL)
        {
                NextInspector1->SelectedItem->Visible = False;
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NextInspector1ToolbarClick(TObject *Sender,
      TNxPropertyItem *Item, int ButtonIndex)
{
        /*
                Because Item parameter is TNxPropertyItem, we will declare
                new local variable of TNxToolbarItem and use typecasting
        */
        TNxToolbarItem *AItem = (TNxToolbarItem*)Item;

        switch(ButtonIndex)
        {
                /*
                        If button with ButtonIndex = 0 is checked,
                        we will set ExpandLock property to True of Item
                */
                case 0: {
                        AItem->ExpandLock = AItem->Buttons->Items[ButtonIndex]->Checked;
                }
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::cmbColorChange(TObject *Sender)
{
        if(NextInspector1->SelectedItem != NULL)
        {
                NextInspector1->SelectedItem->Color = cmbColor->SelectedColor;
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NxToolbarItem3ToolButtonClick(
      TNxPropertyItem *Sender, int ButtonIndex)
{
        switch(ButtonIndex)
        {
                case 4: {
                        ShowMessage("Click on Button with Index = 3");
                }
                break;
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::chbBoldNonDefaultClick(TObject *Sender)
{
        if(NextInspector1->SelectedItem != NULL)
        {
                if (chbBoldNonDefault->Checked)
                {
                        NextInspector1->SelectedItem->Options = NextInspector1->SelectedItem->Options << itoBoldNonDefault;
                } else
                {
                        NextInspector1->SelectedItem->Options = NextInspector1->SelectedItem->Options >> itoBoldNonDefault;
                }
        }
        
}
//---------------------------------------------------------------------------
