Carbon: Implement TListBox.ScrollWidth. Issue #31011, patch from Stefan Kopf.

git-svn-id: trunk@54565 -
This commit is contained in:
juha 2017-04-07 21:57:41 +00:00
parent f49fbe25f1
commit 9c8139c410
2 changed files with 37 additions and 2 deletions

View File

@ -148,7 +148,7 @@ type
function GetItemChecked(AIndex: Integer): Boolean;
function GetItemIndex: Integer;
function GetItemsRect: TRect;
function GetItemsRect: TRect; virtual;
function GetItemsCount: Integer;
function GetItemRect(AIndex: Integer): TRect;
function GetItemRect(AIndex, {%H-}ASubIndex: Integer; {%H-}ACode: TDisplayCode): TRect;
@ -262,6 +262,8 @@ type
{ TCarbonListBox }
TCarbonListBox = class(TCarbonDataBrowser)
private
FScrollWidth : Integer;
protected
procedure CreateWidget(const AParams: TCreateParams); override;
protected
@ -1948,7 +1950,7 @@ begin
if (LCLObject as TCustomListBox).Style = lbOwnerDrawFixed then
SetItemsHeight((LCLObject as TCustomListBox).ItemHeight);
SetRowSelect(True);
SetScrollBars(ssAutoVertical);
SetScrollBars(ssAutoBoth);
SetSelectionMode((LCLObject as TCustomListBox).ExtendedSelect,
(LCLObject as TCustomListBox).MultiSelect);
//Set BorderStyle according to the provided Params
@ -2020,6 +2022,23 @@ begin
SetItemsHeight((LCLObject as TCustomListBox).ItemHeight);
end;
function TCarbonListBox.GetItemsRect: TRect;
begin
Result := inherited GetItemsRect;
If FScrollWidth > 0 then
Result.Right := FScrollWidth;
end;
procedure TCarbonListBox.SetScrollWidth(AScrollWidth: Integer);
begin
FScrollWidth := AScrollWidth;
If AScrollWidth > 0 then
FCaptionListColumn.SetWidth(AScrollWidth)
Else
FCaptionListColumn.SetWidth($FFFF);
CheckNeedsScrollBars();
end;
{ TCarbonCheckListBox }
procedure TCarbonCheckListBox.CreateWidget(const AParams: TCreateParams);

View File

@ -104,6 +104,7 @@ type
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
//class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetScrollWidth(const ACustomListBox: TCustomListBox; const AScrollWidth: Integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
@ -688,6 +689,21 @@ begin
TCarbonListBox(ACustomListBox.Handle).SetItemIndex(AIndex);
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomListBox.SetScrollWidth
Params: ACustomListBox - LCL custom list box
AScrollWidth - Scroll width
Sets scroll width of list box in Carbon interface
------------------------------------------------------------------------------}
class procedure TCarbonWSCustomListBox.SetScrollWidth(
const ACustomListBox: TCustomListBox; const AScrollWidth: Integer);
begin
if not CheckHandle(ACustomListBox, Self, 'SetScrollWidth') then Exit;
TCarbonListBox(ACustomListBox.Handle).SetScrollWidth(AScrollWidth);
end;
{------------------------------------------------------------------------------
Method: TCarbonWSCustomListBox.SetSelectionMode
Params: ACustomListBox - LCL custom list box