1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| //---------------------------------------------------------------------------
void __fastcall TVCLManipForm::BtnTreeViewMiscColumnAddClick(TObject *Sender)
{
AnsiString Value;
if (InputQuery("Ajout d'une Colonne", "Largeur ?", Value))
{
int ColWidth;
if (TryStrToInt(Value, ColWidth))
{
if (ColWidth > 0)
{
TreeViewColWidths.push_back(ColWidth);
TreeViewMisc->Invalidate();
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TVCLManipForm::BtnTreeViewMiscColumnDeleteClick(TObject *Sender)
{
AnsiString Value;
if (InputQuery("Suppression d'une Colonne", "Numéro (indice en base 0)", Value))
{
int ColIndex;
if (TryStrToInt(Value, ColIndex))
{
if ((0 <= ColIndex) && (ColIndex < (int)TreeViewColWidths.size()))
{
for (TTreeViewColWidthList::iterator it = TreeViewColWidths.begin(); it != TreeViewColWidths.end(); ++it)
{
if (ColIndex == 0)
{
TreeViewColWidths.erase(it);
}
else
ColIndex--;
}
TreeViewMisc->Invalidate();
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TVCLManipForm::BtnTreeViewNodeAddClick(TObject *Sender)
{
TreeViewMisc->Items->AddChild(TreeViewMisc->Selected, "Node N°" + IntToStr(TreeViewMisc->Items->Count))->MakeVisible();
}
//---------------------------------------------------------------------------
void __fastcall TVCLManipForm::TreeViewMiscAdvancedCustomDrawItem(
TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State,
TCustomDrawStage Stage, bool &PaintImages, bool &DefaultDraw)
{
if ((Stage == cdPostPaint) && Sender->InheritsFrom(__classid(TTreeView)))
{
TTreeView *Tree = (TTreeView*)Sender;
TRect NodeRect = Node->DisplayRect(true);
if (NodeRect.Left > 0)
{
Tree->Canvas->TextOut(NodeRect.Left + 2, NodeRect.Top + 2, Node->Text);
int ColIndex = 0;
for (TTreeViewColWidthList::const_iterator it = TreeViewColWidths.begin(); it != TreeViewColWidths.end(); ++it)
{
Tree->Canvas->TextOut(NodeRect.Left + *it + 2, NodeRect.Top + 2, AnsiString().sprintf("Col N°%d - %d [%s]", ColIndex, *it, Node->Text));
ColIndex++;
}
}
}
}
//--------------------------------------------------------------------------- |
Partager