type
TIBToolBar = class;
TIBItem = class;
TIBItemBox = class;
TIBToolClicked = (itNone, itCheckBox, itArrowUp, itArrowDown);
{ TIBToolItem }
TIBToolItem = class
private
FCanvas: TCanvas;
FChecked: Boolean;
FIndex: Integer;
FToolBar: TIBToolBar;
FVisible: Boolean;
function ClickNormal(const aParent: TScrollBox): TIBToolClicked; virtual;
procedure ClickShift(const aParent: TScrollBox); virtual;
procedure DoDraw(const aBackgroundColor: TColor; const X: Integer); virtual;
procedure LineRel(const X, Y: LongInt);
public
constructor Create; virtual;
procedure DrawToolItem(const aBackgroundColor: TColor; const X: Integer);
function Width: Integer; virtual;
end;
{ TIBToolCheckBox }
TIBToolCheckBox = class(TIBToolItem)
private
function ClickNormal(const aParent: TScrollBox): TIBToolClicked; override;
procedure ClickShift(const aParent: TScrollBox); override;
procedure DoDraw(const aBackgroundColor: TColor; const X: Integer); override;
public
function Width: Integer; override;
end;
{ TIBToolArrowUp }
TIBToolArrowUp = class(TIBToolItem)
private
function ClickNormal(const aParent: TScrollBox): TIBToolClicked; override;
procedure DoDraw(const aBackgroundColor: TColor; const X: Integer); override;
public
constructor Create; override;
function Width: Integer; override;
end;
{ TIBToolArrowDown }
TIBToolArrowDown = class(TIBToolItem)
private
function ClickNormal(const aParent: TScrollBox): TIBToolClicked; override;
procedure DoDraw(const aBackgroundColor: TColor; const X: Integer); override;
public
constructor Create; override;
function Width: Integer; override;
end;
{ TIBToolBar }
TIBToolBar = class(TFPObjectList)
private
FParent: TIBItem;
FPosX: Integer;
public
constructor Create(const aParent: TIBItem; const X: Integer); overload;
procedure Add(const aToolItem: TIBToolItem);
procedure DrawToolBar(const aBackgroundColor: TColor; const MouseX: Integer);
procedure ShowTool(const anIndex: Integer; const aStatus: Boolean);
end;
{ TIBItem }
TIBItem = class(TScrollBox)
const
FLeft = 70;
private
FColorHighLighted: TColor;
FColorNormal: TColor;
FContent: shortstring unimplemented;
FDoubleClickTesting: Boolean;
FLastClick: TDateTime;
FList: TIBItemBox; // Parent's list
FToolBar: TIBToolBar;
procedure DrawContent; virtual;
function IsMouseHovering: Boolean;
function IsMouseHoverToolItem(const anIndex, MouseX: Integer): Boolean;
function ItemHeight: Integer; virtual;
procedure EventAddClick(Sender: TObject);
procedure EventClick(Sender: TObject);
procedure EventDeleteClick(Sender: TObject);
procedure EventDblClick(Sender: TObject);
procedure EventEditClick(Sender: TObject);
procedure EventMouseEnter(Sender: TObject);
procedure EventMouseLeave(Sender: TObject);
procedure EventMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
public
constructor Create; overload;
constructor Create(aOwner: TComponent; const S: string = '');
procedure Paint; override;
property Data: shortstring read FContent write FContent;
end;
{ TIBItemEmpty }
TIBItemEmpty = class(TIBItem) // Used to pass @TIBItemBox to ItemBoxOf
public
constructor Create(aOwner: TComponent); override;
end;
{ TIBItemBox }
TIBItemBoxEventEnum = (ieToolUp, ieToolDown, ieEdit, ieInsert,
ieAdd, ieDelete, ieDisconnect);
TIBItemBoxEvent = procedure(ItemBox: TIBItemBox; Index1, Index2: Integer;
Event: TIBItemBoxEventEnum) of object;
TIBItemBox = class(TFPObjectList)
private
FHovering: Integer;
FEvent: TIBItemBoxEvent;
FMenuCaption: array[1..10] of string;
FMenuEvent: array[1..10] of TNotifyEvent;
FMenuCount: Integer;
FScrollBox: TScrollBox;
FTimerDelete: TTimer; // Prevent deleting while manipulating item
FTimerDisconnect: TTimer;
procedure EventAddClick(Sender: TObject);
procedure EventMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure EventResize(Sender: TObject);
procedure EventTimerDelete(Sender: TObject);
procedure EventTimerDisconnect(Sender: TObject);
public
constructor Create(const aScrollBox: TScrollBox);
procedure Add(const anItem: TIBItem);
procedure CheckedAdd;
procedure CheckedDelete;
function CheckedFirst: Integer;
function CheckedLast: Integer;
function Disconnect: Boolean;
function Hovering: Integer;
function isEmpty: Boolean;
procedure Migrate(const aSource: TIBItemBox; const anIndexFrom, anIndexTo: Integer);
function GetScrollBox: TScrollBox;
procedure Rename(const S: string);
procedure SetEventResponse(const anEvent: TIBItemBoxEvent);
procedure SetMenu(const aCaption: string; const anEvent: TNotifyEvent);
end;