unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TNeueComboBox =
class;
TNeuesComboBoxItem =
class
protected
FOwner: TNeueComboBox;
FItemIndex: Integer;
FListID : Integer;
FIndex: Integer;
FIndentLevel: Integer;
FImageIndex: Integer;
FOverlayIndex: Integer;
FCaption:
string;
FTag: Integer;
FData: Pointer;
procedure SetIndentLevel( Value: Integer );
procedure SetImageIndex( Value: Integer );
procedure SetCaption(
const Value:
string );
procedure SetOverlayIndex( Value: Integer );
public
constructor Create( AOwner: TNeueComboBox );
destructor Destroy;
override;
property Index: Integer
read FIndex;
property IndentLevel: Integer
read FIndentLevel
write SetIndentLevel;
property ImageIndex: Integer
read FImageIndex
write SetImageIndex;
property OverlayIndex: Integer
read FOverlayIndex
write SetOverlayIndex;
property Caption:
string read FCaption
write SetCaption;
property Data: Pointer
read FData
write FData;
property Tag: Integer
read FTag
write FTag;
property ListID: Integer
read FListID
write FListID;
end;
TNeueComboBox =
class(TCustomComboBox)
public
destructor Destroy;
override;
function AddItem(Caption:
string; ImageIndex: Integer; IndentLevel: Integer; ListID: Integer ): TNeuesComboBoxItem;
end;
type
TForm1 =
class(TForm)
btn_Hinzu: TButton;
btn_Delete: TButton;
procedure FormCreate(Sender: TObject);
procedure btn_HinzuClick(Sender: TObject);
procedure btn_DeleteClick(Sender: TObject);
private
FComboBox : TNeueComboBox;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TNeuesComboBoxItem.Create( AOwner: TNeueComboBox );
begin
inherited Create;
FOwner := aOwner;
FOverlayIndex := -1;
end;
destructor TNeuesComboBoxItem.Destroy;
begin
inherited;
end;
procedure TNeuesComboBoxItem.SetIndentLevel( Value: Integer );
begin
FIndentLevel := Value;
FOwner.Invalidate;
end;
procedure TNeuesComboBoxItem.SetImageIndex( Value: Integer );
begin
FImageIndex := Value;
FOwner.Invalidate;
end;
procedure TNeuesComboBoxItem.SetCaption(
const Value:
string );
begin
FCaption := Value;
FOwner.Invalidate;
end;
procedure TNeuesComboBoxItem.SetOverlayIndex( Value: Integer );
begin
FOverlayIndex := Value;
FOwner.Invalidate;
end;
function TNeueComboBox.AddItem( Caption:
string; ImageIndex: Integer; IndentLevel: Integer; ListID: Integer ): TNeuesComboBoxItem;
const NOSTRING:
string = '
';
begin
Result := TNeuesComboBoxItem.Create(Self);
Result.FCaption := Caption;
Result.FImageIndex := ImageIndex;
Result.FIndentLevel := IndentLevel;
Result.ListID := ListID;
Result.FIndex :=
inherited Items.AddObject( Caption, Result )
end;
destructor TNeueComboBox.Destroy;
begin
WHILE Items.Count > 0
DO Items.Delete(0);
inherited;
end;
procedure TForm1.btn_DeleteClick(Sender: TObject);
begin
FComboBox.Items.Clear;
end;
procedure TForm1.btn_HinzuClick(Sender: TObject);
begin
FComboBox.AddItem('
Name', 0, 0, 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FComboBox := TNeueComboBox.Create(self);
FComboBox.Parent := self;
end;
end.