📄 mainform.cpp
字号:
INI = new TIniFile(IniFileName);
InspCat = new TJvInspectorCustomCategoryItem(JvInspector1->Root, NULL);
InspCat->DisplayName = "INI files (INI-file data layer).";
TJvInspectorINIFileData::New(__classid(TJvInspectorINIFileData), InspCat, INI, &OnINISection, &OnINIKey);
}
void __fastcall TfrmMain::AddVarious()
{
TJvInspectorCustomCategoryItem* InspCat;
TJvCustomInspectorItem* NewItem;
InspCat = new TJvInspectorCustomCategoryItem(JvInspector1->Root, NULL);
InspCat->DisplayName = "Various tests.";
TJvInspectorVarData::New(__classid(TJvInspectorVarData), InspCat, "Date/time", TypeInfo(TDateTime), &ADate);
/* Duplicate the columns of the compound items test. This will return the same data instance as
used by the columns; a new item will be added to it. We change the name of this item, but the
name of the data instance and the columns remain what they were. If we would change the Name
of the data instance, this will result in all items that have the same name as the data instance
to be renamed as well. */
TJvInspectorVarData::New(__classid(TJvInspectorVarData), InspCat, "First", TypeInfo(AnsiString), &FirstName)->DisplayName = "Copy of first name";
TJvInspectorVarData::New(__classid(TJvInspectorVarData), InspCat, "Initial", TypeInfo(AnsiString), &Initial)->DisplayName = "Copy of initial";
TJvInspectorVarData::New(__classid(TJvInspectorVarData), InspCat, "Last", TypeInfo(AnsiString), &LastName)->DisplayName = "Copy of last name";
// Add an ImageIndex test item
NewItem = TJvInspectorVarData::New(__classid(TJvInspectorVarData), InspCat, "ImageIndex", TypeInfo(TImageIndex), &ImgIdx);
if (dynamic_cast<TJvInspectorTImageIndexItem*>(NewItem))
dynamic_cast<TJvInspectorTImageIndexItem*>(NewItem)->Images = TestImageList;
// NewItem.RowSizing.MinHeight := 24;
InspCat->Expanded = True;
}
void __fastcall TfrmMain::ChangeChkState(TJvCustomInspectorItem* Item)
{
if (dynamic_cast<TJvInspectorBooleanItem*>(Item))
dynamic_cast<TJvInspectorBooleanItem*>(Item)->ShowAsCheckBox = BoolsAsChecks;
for(int I = 0; I < Item->Count; I++)
ChangeChkState(Item->Items[I]); // Do not use Item[I], as Item is a pointer itself
}
void __fastcall TfrmMain::Edit1Change2(TObject* Sender)
{
frmTest->mmChanges->Lines->Add("Edit1Change2 event");
}
void __fastcall TfrmMain::GetBoolsAsChecks(TJvInspectorEventData* Sender, __int64& Value)
{
Value = static_cast<__int64>(BoolsAsChecks);
}
void __fastcall TfrmMain::SetBoolsAsChecks(TJvInspectorEventData* Sender, __int64& Value)
{
if ((Value != 0) != BoolsAsChecks)
{
BoolsAsChecks = Value != 0;
JvInspector1->BeginUpdate();
try
{
ChangeChkState(JvInspector1->Root);
}
__finally
{
JvInspector1->EndUpdate();
}
}
}
int TextIndex(const AnsiString S, const AnsiString * List, int LastIndex)
{
int Result = LastIndex;
while ((Result >= 0) && !AnsiSameText(S, List[Result]))
Result--;
return Result;
}
void __fastcall TfrmMain::OnINISection(AnsiString& SectionName, bool& Parse)
{
switch(TextIndex(SectionName, OPENARRAY(AnsiString, ("", "Global", "Section2", "TypedKeys", "EmptySection"))))
{
case 0:
SectionName = "(no section)";
break;
case 1:
SectionName = "First section";
break;
case 2:
SectionName = "Second section";
break;
case 3:
SectionName = "Typed elements";
break;
case 4:
SectionName = "Empty section, has no keys";
break;
default:
Parse = False;
}
}
void __fastcall TfrmMain::OnINIKey(const AnsiString SectionName, AnsiString& ItemName, PTypeInfo& ATypeInfo, bool& Allow)
{
switch(TextIndex(SectionName, OPENARRAY(AnsiString, ("", "Global", "Section2", "TypedKeys", "EmptySection"))))
{
case 0:
switch(TextIndex(ItemName, OPENARRAY(AnsiString, ("Key1WithoutSection", "Key2WithoutSection"))))
{
case 0:
ItemName = "First key";
break;
case 1:
ItemName = "Second key";
break;
default:
Allow = False;
}
break;
case 1:
switch(TextIndex(ItemName, OPENARRAY(AnsiString, ("Key1", "Key2"))))
{
case 0:
ItemName = "First key";
break;
case 1:
ItemName = "Second key";
break;
default:
Allow = False;
}
break;
case 2:
switch(TextIndex(ItemName, OPENARRAY(AnsiString, ("Key1", "Key2"))))
{
case 0:
ItemName = "First key";
break;
case 1:
ItemName = "Second key";
break;
default:
Allow = False;
}
break;
case 3:
switch(TextIndex(ItemName, OPENARRAY(AnsiString, ("Options", "IsValid", "Float", "Range_Int", "SomeEnum", "NewEnum"))))
{
case 0:
ATypeInfo = TypeInfo(TTestOptions);
break;
case 1:
ItemName = "Valid info";
ATypeInfo = TypeInfo(bool);
break;
case 2:
ItemName = "Test float value";
ATypeInfo = TypeInfo(double);
break;
case 3:
ItemName = "Last digit";
ATypeInfo = TypeInfo(TTestRange);
break;
case 4:
ItemName = "Required number of items";
ATypeInfo = TypeInfo(TTestEnum);
break;
case 5:
ItemName = "Who or what is cool?";
ATypeInfo = GeneratedTestEnum;
break;
default:
Allow = false;
}
break;
default:
Allow = False;
}
}
//---------------------------------------------------------------------------
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormShow(TObject *Sender)
{
AddFormAndControls();
JvInspector1->EndUpdate();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormCreate(TObject *Sender)
{
BoolsAsChecks = True;
JvInspector1->BeginUpdate();
JvInspector1->Root->SortKind = iskNone;
AddGlobalSettings();
AddInspectorSettings();
AddCompoundTest();
AddINIFile();
AddVarious();
JvInspector1->SelectedIndex = 0;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::JvInspector1AfterItemCreate(TObject *Sender,
TJvCustomInspectorItem *Item)
{
if (dynamic_cast<TJvInspectorBooleanItem*>(Item))
dynamic_cast<TJvInspectorBooleanItem*>(Item)->ShowAsCheckBox = True;
if ((Item->Data != NULL) && (CompareText(Item->Data->Name, "AboutJVCL") == 0))
Item->ReadOnly = true;
if ((Item->Data != NULL) && (CompareText(Item->Data->Name, "Painter") == 0))
dynamic_cast<TJvInspectorComponentItem*>(Item)->AddOwner(this);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -