ExCtrls: Improvements in TCheckComboBoxEx.ButtonWidth.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8138 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-11-01 15:21:42 +00:00
parent 1cf6ae5b98
commit 2f7c57e770

View File

@ -39,7 +39,7 @@ type
property State[AIndex: Integer]: TCheckboxState read GetState write SetState; property State[AIndex: Integer]: TCheckboxState read GetState write SetState;
end; end;
TCheckComboBoxEx = class(TEditButton) TCheckComboBoxEx = class(TCustomEditButton)
private private
FAllowGrayed: Boolean; FAllowGrayed: Boolean;
FAutoDropDown: Boolean; FAutoDropDown: Boolean;
@ -61,14 +61,16 @@ type
FOnItemChange: TCheckItemChange; FOnItemChange: TCheckItemChange;
FOnItemClick: TCheckListClicked; FOnItemClick: TCheckListClicked;
procedure CheckComboBoxFormCloseHandler(Sender: TObject; var CloseAction: TCloseAction); procedure CheckComboBoxFormCloseHandler(Sender: TObject; var CloseAction: TCloseAction);
// procedure CloseUpHandler(Sender: TObject); function GetButtonWidth: Integer;
function GetChecked(AIndex: Integer): Boolean; function GetChecked(AIndex: Integer): Boolean;
function GetItemEnabled(AIndex: Integer): Boolean; function GetItemEnabled(AIndex: Integer): Boolean;
function GetItems: TStrings; function GetItems: TStrings;
function GetState(AIndex: Integer): TCheckBoxState; function GetState(AIndex: Integer): TCheckBoxState;
function IsButtonWidthStored: Boolean;
procedure ItemClickHandler(Sender: TObject; AIndex: Integer); procedure ItemClickHandler(Sender: TObject; AIndex: Integer);
procedure ItemsToCheckListbox(ACheckListbox: TCheckListbox); procedure ItemsToCheckListbox(ACheckListbox: TCheckListbox);
procedure SetAllowGrayed(AValue: Boolean); procedure SetAllowGrayed(AValue: Boolean);
procedure SetButtonWidth(AValue: Integer);
procedure SetChecked(AIndex: Integer; const AValue: Boolean); procedure SetChecked(AIndex: Integer; const AValue: Boolean);
procedure SetDelimiter(AValue: Char); procedure SetDelimiter(AValue: Char);
procedure SetDropDownCount(AValue: Integer); procedure SetDropDownCount(AValue: Integer);
@ -111,6 +113,7 @@ type
published published
property AllowGrayed: Boolean read FAllowGrayed write SetAllowGrayed default false; property AllowGrayed: Boolean read FAllowGrayed write SetAllowGrayed default false;
property AutoDropDown: Boolean read FAutoDropDown write FAutoDropDown default false; property AutoDropDown: Boolean read FAutoDropDown write FAutoDropDown default false;
property ButtonWidth: Integer read GetButtonWidth write SetButtonWidth stored IsButtonWidthStored;
property Delimiter: char read FDelimiter write SetDelimiter default ';'; property Delimiter: char read FDelimiter write SetDelimiter default ';';
property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8; property DropDownCount: Integer read FDropDownCount write SetDropDownCount default 8;
property EscCancels: Boolean read FEscCancels write FEscCancels default true; property EscCancels: Boolean read FEscCancels write FEscCancels default true;
@ -632,6 +635,11 @@ begin
Result := TCCBButton; Result := TCCBButton;
end; end;
function TCheckComboBoxEx.GetButtonWidth: Integer;
begin
Result := Buddy.Width;
end;
function TCheckComboBoxEx.GetChecked(AIndex: Integer): Boolean; function TCheckComboBoxEx.GetChecked(AIndex: Integer): Boolean;
begin begin
Result := FItems.Checked[AIndex]; Result := FItems.Checked[AIndex];
@ -657,6 +665,11 @@ begin
Result := FItems.State[AIndex]; Result := FItems.State[AIndex];
end; end;
function TCheckComboBoxEx.IsButtonWidthStored: Boolean;
begin
Result := Buddy.Width <> GetSystemMetrics(SM_CXVSCROLL);
end;
procedure TCheckComboBoxEx.ItemClickHandler(Sender: TObject; AIndex: Integer); procedure TCheckComboBoxEx.ItemClickHandler(Sender: TObject; AIndex: Integer);
begin begin
UpdateCaption; UpdateCaption;
@ -735,6 +748,14 @@ begin
UpdateCaption; UpdateCaption;
end; end;
procedure TCheckComboBoxEx.SetButtonWidth(AValue: Integer);
begin
if AValue < 0 then
AValue := GetSystemMetrics(SM_CXVSCROLL);
if Buddy.Width <> AValue then
Buddy.Width := AValue;
end;
procedure TCheckComboBoxEx.SetChecked(AIndex: Integer; const AValue: Boolean); procedure TCheckComboBoxEx.SetChecked(AIndex: Integer; const AValue: Boolean);
begin begin
if FItems.Checked[AIndex] = AValue then if FItems.Checked[AIndex] = AValue then