You've already forked lazarus-ccr
ExCtrls: Fix CheckComboboxEx having a zero-height dropdown after Laz commit e4043024. Minor optimization in MeasureItem.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8679 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -5,7 +5,8 @@ unit ExCheckCombo;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLIntf, LCLType, Classes, SysUtils, Controls, StdCtrls, ImgList,
|
LCLIntf, LCLType,
|
||||||
|
Classes, SysUtils, Controls, StdCtrls, ImgList,
|
||||||
GroupedEdit, EditBtn, CheckLst, Forms;
|
GroupedEdit, EditBtn, CheckLst, Forms;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -215,6 +216,17 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Buttons, Themes, WSForms;
|
Buttons, Themes, WSForms;
|
||||||
|
|
||||||
|
type
|
||||||
|
TCustomListboxHelper = class helper for TCustomListbox
|
||||||
|
public
|
||||||
|
function CalculateStandardItemHeight: Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomListboxHelper.CalculateStandardItemHeight: Integer;
|
||||||
|
begin
|
||||||
|
Result := inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCCBItem } // CCB = CheckComboBox
|
{ TCCBItem } // CCB = CheckComboBox
|
||||||
type
|
type
|
||||||
TCCBItem = class
|
TCCBItem = class
|
||||||
@ -481,6 +493,7 @@ type
|
|||||||
FCaller: TControl;
|
FCaller: TControl;
|
||||||
FCheckListBox: TCheckListBox;
|
FCheckListBox: TCheckListBox;
|
||||||
FDropDownCount: Integer;
|
FDropDownCount: Integer;
|
||||||
|
FStdItemHeight: Integer;
|
||||||
protected
|
protected
|
||||||
procedure ActivateDoubleBuffered;
|
procedure ActivateDoubleBuffered;
|
||||||
procedure DblClickHandler(Sender: TObject);
|
procedure DblClickHandler(Sender: TObject);
|
||||||
@ -503,6 +516,7 @@ begin
|
|||||||
FCheckListbox.OnDblClick := @DblClickHandler;
|
FCheckListbox.OnDblClick := @DblClickHandler;
|
||||||
FCheckListbox.OnKeyDown := @KeyDownHandler;
|
FCheckListbox.OnKeyDown := @KeyDownHandler;
|
||||||
FDropDownCount := 8;
|
FDropDownCount := 8;
|
||||||
|
FStdItemHeight := FCheckListbox.CalculateStandardItemHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCheckComboBoxForm.ActivateDoubleBuffered;
|
procedure TCheckComboBoxForm.ActivateDoubleBuffered;
|
||||||
@ -578,16 +592,20 @@ end;
|
|||||||
|
|
||||||
procedure TCheckComboBoxForm.MeasureHeight(out AHeight: Integer);
|
procedure TCheckComboBoxForm.MeasureHeight(out AHeight: Integer);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i, h, n: Integer;
|
||||||
h: Integer = 0;
|
|
||||||
begin
|
begin
|
||||||
AHeight := 0;
|
AHeight := 0;
|
||||||
for i := 0 to FCheckListbox.Items.Count-1 do
|
n := FCheckListbox.Items.Count;
|
||||||
if i < FDropDownCount then
|
if FDropDownCount < n then
|
||||||
begin
|
n := FDropDownCount;
|
||||||
FCheckListbox.MeasureItem(i, h);
|
for i := 0 to n-1 do
|
||||||
inc(AHeight,h);
|
begin
|
||||||
end;
|
h := -1;
|
||||||
|
FCheckListbox.MeasureItem(i, h);
|
||||||
|
if h = -1 then
|
||||||
|
h := FStdItemHeight;
|
||||||
|
inc(AHeight, h);
|
||||||
|
end;
|
||||||
inc(AHeight, 6);
|
inc(AHeight, 6);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user