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

#ifndef VmxCustomTreeViewH
#define VmxCustomTreeViewH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <stdio.h>
//---------------------------------------------------------------------------

class TmTreeItem: public TObject
{
  public:
    bool Checked, Expanded, Hovered;
    AnsiString Text;
    TmTreeItem *Parent;
    int NChild;
    TmTreeItem *Childs[1024];
    TmTreeItem *AddChild (AnsiString T);
    TmTreeItem ();
    void __fastcall Assign (TmTreeItem *Item);
};

typedef void __fastcall (__closure *TOnClickItemEvent) (TObject *Sender, TmTreeItem *Item);

class PACKAGE TVmxCustomTreeView : public TGraphicControl
{
private:
protected:
        void __fastcall Paint (void);
        void __fastcall AnalyzeDraw (TmTreeItem*, int, int&, int&);
        void __fastcall AnalyzeC (TmTreeItem*, int, int&, int, int);
        void __fastcall AnalyzeH (TmTreeItem*, int, int&, int, int);
        DYNAMIC void __fastcall MouseDown (TMouseButton Button, TShiftState Shift, int X, int Y);
        DYNAMIC void __fastcall MouseMove (TShiftState Shift, int X, int Y);
        void __fastcall DelSub (TmTreeItem *Item);
        void __fastcall LoadItem (FILE *fp,TmTreeItem *Item);
        void __fastcall SaveItem (FILE *fp,TmTreeItem *Item);
        TOnClickItemEvent FOnClickItem;
        bool FChecks;
        void __fastcall SetChecks (bool New);
        TColor FLC;
        int FScrollPos;
        void __fastcall SetLC (TColor New);
        TNotifyEvent FOnChangeScrollMax;
        void __fastcall SetScrollPos (int New);
public:
        __fastcall TVmxCustomTreeView(TComponent* Owner);
        int ICount, ScrollMax;
        TmTreeItem *Items [1024];
        TmTreeItem* __fastcall Add (AnsiString T);
        void __fastcall LoadFromFILE (FILE *fp);
        void __fastcall SaveToFILE (FILE *fp);
        void __fastcall Clear (void);
        bool __fastcall Delete (TmTreeItem *Item);
__published:
        __property Font;
        __property Align;
        __property ParentFont;
        __property Anchors;
        __property Color;
        __property ParentColor;
        __property Visible;
        __property TColor LinesColor = {read = FLC, write = SetLC};
        __property TOnClickItemEvent OnClickItem = {read = FOnClickItem, write = FOnClickItem};
        __property bool Checkboxes = {read = FChecks, write = SetChecks};
        __property TNotifyEvent OnChangeScrollMax = {read = FOnChangeScrollMax, write = FOnChangeScrollMax};
        __property int ScrollPos = {read = FScrollPos, write = SetScrollPos};
};

//---------------------------------------------------------------------------
#endif
