LCL: Support WS binding for ListBox.SelectAll. New ListBox.SelectRange. Issue #36929.

git-svn-id: trunk@63329 -
This commit is contained in:
juha 2020-06-08 10:34:32 +00:00
parent 1df930db48
commit 77e76e66b8
5 changed files with 59 additions and 13 deletions

View File

@ -26,13 +26,13 @@ type
procedure TCustomListBox.AssignCacheToItemData(const AIndex: Integer;
const AData: Pointer);
var
SelectItem: Boolean;
SelectedItem: Boolean;
begin
if MultiSelect then
SelectItem := PCustomListBoxItemRecord(AData)^.Selected
SelectedItem := PCustomListBoxItemRecord(AData)^.Selected
else
SelectItem := FItemIndex = AIndex;
if SelectItem then
SelectedItem := FItemIndex = AIndex;
if SelectedItem then
begin
LockSelectionChange;
SendItemSelected(AIndex, True);
@ -166,7 +166,7 @@ begin
UnlockSelectionChange;
end;
procedure TCustomListbox.DestroyWnd;
procedure TCustomListBox.DestroyWnd;
begin
inherited;
if FCanvas <> nil then
@ -725,8 +725,7 @@ var
begin
if MultiSelect then
begin
for i := 0 to Items.Count - 1 do
Selected[i] := true;
TWSCustomListBoxClass(WidgetSetClass).SelectRange(Self, 0, Items.Count-1, True);
DoSelectionChange(false);
end else
begin
@ -736,6 +735,16 @@ begin
end;
end;
procedure TCustomListBox.SelectRange(ALow, AHigh: integer; ASelected: boolean);
begin
if (ALow<0) or (AHigh>=Items.Count) then Exit;
if MultiSelect then
begin
TWSCustomListBoxClass(WidgetSetClass).SelectRange(Self, ALow, AHigh, ASelected);
DoSelectionChange(false);
end;
end;
procedure TCustomListBox.DeleteSelected;
var
i: Integer;

View File

@ -133,7 +133,13 @@ type
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SelectItem(const ACustomListBox: TCustomListBox;
AIndex: integer; ASelected: boolean); override;
{ ToDo
class procedure SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean); override;
}
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
@ -908,7 +914,13 @@ begin
else
SetItemIndex(ACustomListBox, -1);
end;
{
class procedure SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean); override;
begin
ToDo: Send message LB_SELITEMRANGE
end;
}
class procedure TWin32WSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox);
var
Handle: HWND;

View File

@ -113,7 +113,12 @@ type
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SelectItem(const ACustomListBox: TCustomListBox;
AIndex: integer; ASelected: boolean); override;
{ ToDo
class procedure SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean); override;
}
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
@ -557,7 +562,13 @@ begin
else
SetItemIndex(ACustomListBox, -1);
end;
{
class procedure SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean); override;
begin
ToDo: Send message LB_SELITEMRANGE
end;
}
class procedure TWinCEWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox);
var
Handle: HWND;

View File

@ -603,6 +603,7 @@ type
procedure MakeCurrentVisible;
procedure MeasureItem(Index: Integer; var TheHeight: Integer); virtual;
procedure SelectAll; virtual;
procedure SelectRange(ALow, AHigh: integer; ASelected: boolean); virtual;
procedure DeleteSelected; virtual;
procedure UnlockSelectionChange;
public

View File

@ -119,7 +119,10 @@ type
class procedure FreeStrings(var AStrings: TStrings); virtual;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); virtual;
class procedure SelectItem(const ACustomListBox: TCustomListBox;
AIndex: integer; ASelected: boolean); virtual;
class procedure SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean); virtual;
class procedure SetBorder(const ACustomListBox: TCustomListBox); virtual;
class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); virtual;
@ -357,10 +360,20 @@ begin
Result := 0;
end;
class procedure TWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
class procedure TWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox;
AIndex: integer; ASelected: boolean);
begin
end;
class procedure TWSCustomListBox.SelectRange(const ACustomListBox: TCustomListBox;
ALow, AHigh: integer; ASelected: boolean);
var
i: Integer;
begin // A default implementation. A widgetset can override it with a better one.
for i := ALow to AHigh - 1 do
SelectItem(ACustomListBox, i, ASelected);
end;
class procedure TWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox);
begin
end;