|
@@ -19,21 +19,24 @@ type
|
|
|
FHoverItem: integer;
|
|
FHoverItem: integer;
|
|
|
FListBox: TListBox;
|
|
FListBox: TListBox;
|
|
|
procedure ButtonClick(Sender: TObject);
|
|
procedure ButtonClick(Sender: TObject);
|
|
|
|
|
+ function GetItemIndex: integer;
|
|
|
function GetItems: TStrings;
|
|
function GetItems: TStrings;
|
|
|
procedure ListBoxClick(Sender: TObject);
|
|
procedure ListBoxClick(Sender: TObject);
|
|
|
procedure ListBoxMouseLeave(Sender: TObject);
|
|
procedure ListBoxMouseLeave(Sender: TObject);
|
|
|
procedure ListBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
|
|
procedure ListBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
|
|
|
Y: Integer);
|
|
Y: Integer);
|
|
|
procedure ListBoxSelectionChange(Sender: TObject; User: boolean);
|
|
procedure ListBoxSelectionChange(Sender: TObject; User: boolean);
|
|
|
|
|
+ procedure SetItemIndex(AValue: integer);
|
|
|
procedure SetItems(AValue: TStrings);
|
|
procedure SetItems(AValue: TStrings);
|
|
|
protected
|
|
protected
|
|
|
-
|
|
|
|
|
|
|
+ procedure UpdateCaption;
|
|
|
public
|
|
public
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
property HoverItem: integer read FHoverItem;
|
|
property HoverItem: integer read FHoverItem;
|
|
|
property Button: TBCButton read FButton write FButton;
|
|
property Button: TBCButton read FButton write FButton;
|
|
|
property ListBox: TListBox read FListBox write FListBox;
|
|
property ListBox: TListBox read FListBox write FListBox;
|
|
|
property Items: TStrings read GetItems write SetItems;
|
|
property Items: TStrings read GetItems write SetItems;
|
|
|
|
|
+ property ItemIndex: integer read GetItemIndex write SetItemIndex;
|
|
|
published
|
|
published
|
|
|
|
|
|
|
|
end;
|
|
end;
|
|
@@ -78,6 +81,11 @@ begin
|
|
|
end;
|
|
end;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+function TBCComboBox.GetItemIndex: integer;
|
|
|
|
|
+begin
|
|
|
|
|
+ result := FListBox.ItemIndex;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
function TBCComboBox.GetItems: TStrings;
|
|
function TBCComboBox.GetItems: TStrings;
|
|
|
begin
|
|
begin
|
|
|
Result := FListBox.Items;
|
|
Result := FListBox.Items;
|
|
@@ -86,7 +94,6 @@ end;
|
|
|
procedure TBCComboBox.ListBoxClick(Sender: TObject);
|
|
procedure TBCComboBox.ListBoxClick(Sender: TObject);
|
|
|
begin
|
|
begin
|
|
|
FForm.Visible := false;
|
|
FForm.Visible := false;
|
|
|
- FButton.Caption := FListBox.Items[FListBox.ItemIndex];
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TBCComboBox.ListBoxMouseLeave(Sender: TObject);
|
|
procedure TBCComboBox.ListBoxMouseLeave(Sender: TObject);
|
|
@@ -111,7 +118,12 @@ end;
|
|
|
|
|
|
|
|
procedure TBCComboBox.ListBoxSelectionChange(Sender: TObject; User: boolean);
|
|
procedure TBCComboBox.ListBoxSelectionChange(Sender: TObject; User: boolean);
|
|
|
begin
|
|
begin
|
|
|
- FButton.Caption := FListBox.Items[FListBox.ItemIndex];
|
|
|
|
|
|
|
+ UpdateCaption;
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
|
|
+procedure TBCComboBox.SetItemIndex(AValue: integer);
|
|
|
|
|
+begin
|
|
|
|
|
+ FListBox.ItemIndex := AValue;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TBCComboBox.SetItems(AValue: TStrings);
|
|
procedure TBCComboBox.SetItems(AValue: TStrings);
|
|
@@ -119,6 +131,14 @@ begin
|
|
|
Items := AValue;
|
|
Items := AValue;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+procedure TBCComboBox.UpdateCaption;
|
|
|
|
|
+begin
|
|
|
|
|
+ if FListBox.ItemIndex<>-1 then
|
|
|
|
|
+ FButton.Caption := FListBox.Items[FListBox.ItemIndex]
|
|
|
|
|
+ else
|
|
|
|
|
+ FButton.Caption := '';
|
|
|
|
|
+end;
|
|
|
|
|
+
|
|
|
constructor TBCComboBox.Create(AOwner: TComponent);
|
|
constructor TBCComboBox.Create(AOwner: TComponent);
|
|
|
begin
|
|
begin
|
|
|
inherited Create(AOwner);
|
|
inherited Create(AOwner);
|