mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 16:39:19 +02:00
lcl: ListView:
- add TIconOptions - win32 implement support for different IconOptions (issue #0014460) git-svn-id: trunk@21546 -
This commit is contained in:
parent
fa1b49813e
commit
4a0461a558
@ -655,6 +655,29 @@ type
|
|||||||
|
|
||||||
TDisplayCode = (drBounds, drIcon, drLabel, drSelectBounds);
|
TDisplayCode = (drBounds, drIcon, drLabel, drSelectBounds);
|
||||||
|
|
||||||
|
{ TIconOptions }
|
||||||
|
|
||||||
|
TIconArrangement = (iaTop, iaLeft);
|
||||||
|
|
||||||
|
TIconOptions = class(TPersistent)
|
||||||
|
private
|
||||||
|
FListView: TCustomListView;
|
||||||
|
FArrangement: TIconArrangement;
|
||||||
|
function GetAutoArrange: Boolean;
|
||||||
|
function GetWrapText: Boolean;
|
||||||
|
procedure SetArrangement(Value: TIconArrangement);
|
||||||
|
procedure SetAutoArrange(Value: Boolean);
|
||||||
|
procedure SetWrapText(Value: Boolean);
|
||||||
|
protected
|
||||||
|
procedure AssignTo(Dest: TPersistent); override;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TCustomListView);
|
||||||
|
published
|
||||||
|
property Arrangement: TIconArrangement read FArrangement write SetArrangement default iaTop;
|
||||||
|
property AutoArrange: Boolean read GetAutoArrange write SetAutoArrange default False;
|
||||||
|
property WrapText: Boolean read GetWrapText write SetWrapText default True;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TListItem }
|
{ TListItem }
|
||||||
|
|
||||||
TListItem = class(TPersistent)
|
TListItem = class(TPersistent)
|
||||||
@ -930,6 +953,7 @@ type
|
|||||||
FCanvas: TCanvas;
|
FCanvas: TCanvas;
|
||||||
FDefaultItemHeight: integer;
|
FDefaultItemHeight: integer;
|
||||||
FHotTrackStyles: TListHotTrackStyles;
|
FHotTrackStyles: TListHotTrackStyles;
|
||||||
|
FIconOptions: TIconOptions;
|
||||||
FOwnerData: Boolean;
|
FOwnerData: Boolean;
|
||||||
FOwnerDataItem: TOwnerDataListItem;
|
FOwnerDataItem: TOwnerDataListItem;
|
||||||
FListItems: TListItems;
|
FListItems: TListItems;
|
||||||
@ -984,6 +1008,7 @@ type
|
|||||||
procedure SetFocused(const AValue: TListItem);
|
procedure SetFocused(const AValue: TListItem);
|
||||||
procedure SetHotTrackStyles(const AValue: TListHotTrackStyles);
|
procedure SetHotTrackStyles(const AValue: TListHotTrackStyles);
|
||||||
procedure SetHoverTime(const AValue: Integer);
|
procedure SetHoverTime(const AValue: Integer);
|
||||||
|
procedure SetIconOptions(const AValue: TIconOptions);
|
||||||
procedure SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
|
procedure SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
|
||||||
procedure SetItems(const AValue : TListItems);
|
procedure SetItems(const AValue : TListItems);
|
||||||
procedure SetItemVisible(const AValue: TListItem; const APartialOK: Boolean);
|
procedure SetItemVisible(const AValue: TListItem; const APartialOK: Boolean);
|
||||||
@ -1079,6 +1104,7 @@ type
|
|||||||
property GridLines: Boolean index Ord(lvpGridLines) read GetProperty write SetProperty default False;
|
property GridLines: Boolean index Ord(lvpGridLines) read GetProperty write SetProperty default False;
|
||||||
property HotTrack: Boolean index Ord(lvpHotTrack) read GetProperty write SetProperty default False;
|
property HotTrack: Boolean index Ord(lvpHotTrack) read GetProperty write SetProperty default False;
|
||||||
property HotTrackStyles: TListHotTrackStyles read FHotTrackStyles write SetHotTrackStyles default [];
|
property HotTrackStyles: TListHotTrackStyles read FHotTrackStyles write SetHotTrackStyles default [];
|
||||||
|
property IconOptions: TIconOptions read FIconOptions write SetIconOptions;
|
||||||
property ItemFocused: TListItem read GetFocused write SetFocused;
|
property ItemFocused: TListItem read GetFocused write SetFocused;
|
||||||
property Items: TListItems read FListItems write SetItems;
|
property Items: TListItems read FListItems write SetItems;
|
||||||
// MultiSelect and ReadOnly should be protected, but can't because Carbon Interface
|
// MultiSelect and ReadOnly should be protected, but can't because Carbon Interface
|
||||||
@ -1124,6 +1150,7 @@ type
|
|||||||
// property HotTrack;
|
// property HotTrack;
|
||||||
// property HotTrackStyles;
|
// property HotTrackStyles;
|
||||||
// property HoverTime;
|
// property HoverTime;
|
||||||
|
property IconOptions;
|
||||||
property Items;
|
property Items;
|
||||||
property LargeImages;
|
property LargeImages;
|
||||||
property MultiSelect;
|
property MultiSelect;
|
||||||
|
@ -13,6 +13,60 @@
|
|||||||
* *
|
* *
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ TIconOptions }
|
||||||
|
|
||||||
|
procedure TIconOptions.SetArrangement(Value: TIconArrangement);
|
||||||
|
begin
|
||||||
|
if FArrangement <> Value then
|
||||||
|
begin
|
||||||
|
FArrangement := Value;
|
||||||
|
if FListView.HandleAllocated then
|
||||||
|
TWSCustomListViewClass(FListView.WidgetSetClass).SetIconArrangement(FListView, Arrangement);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIconOptions.GetAutoArrange: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FListView.GetProperty(Ord(lvpAutoArrange));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIconOptions.GetWrapText: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FListView.GetProperty(Ord(lvpWrapText));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIconOptions.SetAutoArrange(Value: Boolean);
|
||||||
|
begin
|
||||||
|
FListView.SetProperty(Ord(lvpAutoArrange), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIconOptions.SetWrapText(Value: Boolean);
|
||||||
|
begin
|
||||||
|
FListView.SetProperty(Ord(lvpWrapText), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIconOptions.AssignTo(Dest: TPersistent);
|
||||||
|
var
|
||||||
|
DestOptions: TIconOptions absolute Dest;
|
||||||
|
begin
|
||||||
|
if Dest is TIconOptions then
|
||||||
|
begin
|
||||||
|
DestOptions.Arrangement := Arrangement;
|
||||||
|
DestOptions.AutoArrange := AutoArrange;
|
||||||
|
DestOptions.WrapText := WrapText;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inherited AssignTo(Dest);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TIconOptions.Create(AOwner: TCustomListView);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FListView := AOwner;
|
||||||
|
FArrangement := iaTop;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TCustomListView Constructor
|
TCustomListView Constructor
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -22,8 +76,9 @@ var
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
ControlStyle := ControlStyle - [csCaptureMouse];
|
ControlStyle := ControlStyle - [csCaptureMouse];
|
||||||
FColumns := TListColumns.Create(self);
|
FIconOptions := TIconOptions.Create(Self);
|
||||||
FListItems := TListItems.Create(self);
|
FColumns := TListColumns.Create(Self);
|
||||||
|
FListItems := TListItems.Create(Self);
|
||||||
BorderStyle := bsSingle;
|
BorderStyle := bsSingle;
|
||||||
FScrollBars := ssBoth;
|
FScrollBars := ssBoth;
|
||||||
FCompStyle := csListView;
|
FCompStyle := csListView;
|
||||||
@ -42,7 +97,7 @@ begin
|
|||||||
Color := clWindow;
|
Color := clWindow;
|
||||||
FCanvas := TControlCanvas.Create;
|
FCanvas := TControlCanvas.Create;
|
||||||
TControlCanvas(FCanvas).Control := Self;
|
TControlCanvas(FCanvas).Control := Self;
|
||||||
FProperties := [lvpColumnClick, lvpHideSelection, lvpShowColumnHeaders, lvpToolTips];
|
FProperties := [lvpColumnClick, lvpHideSelection, lvpShowColumnHeaders, lvpToolTips, lvpWrapText];
|
||||||
|
|
||||||
FOwnerDataItem := TOwnerDataListItem.Create(FListItems);
|
FOwnerDataItem := TOwnerDataListItem.Create(FListItems);
|
||||||
end;
|
end;
|
||||||
@ -569,6 +624,7 @@ begin
|
|||||||
FreeAndNil(FImageChangeLinks[lvil]);
|
FreeAndNil(FImageChangeLinks[lvil]);
|
||||||
FreeAndNil(FOwnerDataItem);
|
FreeAndNil(FOwnerDataItem);
|
||||||
FreeAndNil(FListItems);
|
FreeAndNil(FListItems);
|
||||||
|
FreeAndNil(FIconOptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -814,6 +870,11 @@ begin
|
|||||||
TWSCustomListViewClass(WidgetSetClass).SetHoverTime(Self, FHoverTime);
|
TWSCustomListViewClass(WidgetSetClass).SetHoverTime(Self, FHoverTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomListView.SetIconOptions(const AValue: TIconOptions);
|
||||||
|
begin
|
||||||
|
FIconOptions.Assign(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomListView.SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
|
procedure TCustomListView.SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
|
||||||
var
|
var
|
||||||
lvil: TListViewImageList;
|
lvil: TListViewImageList;
|
||||||
|
@ -136,7 +136,7 @@ type
|
|||||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
|
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
|
||||||
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
|
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
|
||||||
// class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
|
class procedure SetIconArrangement(const ALV: TCustomListView; const AValue: TIconArrangement); override;
|
||||||
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); override;
|
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); override;
|
||||||
class procedure SetItemsCount(const ALV: TCustomListView; const AValue: Integer); override;
|
class procedure SetItemsCount(const ALV: TCustomListView; const AValue: Integer); override;
|
||||||
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); override;
|
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); override;
|
||||||
|
@ -477,6 +477,7 @@ class function TWin32WSCustomListView.CreateHandle(const AWinControl: TWinContro
|
|||||||
const AParams: TCreateParams): HWND;
|
const AParams: TCreateParams): HWND;
|
||||||
const
|
const
|
||||||
LISTVIEWSTYLES: array[TViewStyle] of DWORD = (LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT);
|
LISTVIEWSTYLES: array[TViewStyle] of DWORD = (LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT);
|
||||||
|
Arrangement: array[TIconArrangement] of DWord = (LVS_ALIGNTOP, LVS_ALIGNLEFT);
|
||||||
var
|
var
|
||||||
Params: TCreateWindowExParams;
|
Params: TCreateWindowExParams;
|
||||||
begin
|
begin
|
||||||
@ -487,7 +488,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
pClassName := WC_LISTVIEW;
|
pClassName := WC_LISTVIEW;
|
||||||
WindowTitle := StrCaption;
|
WindowTitle := StrCaption;
|
||||||
Flags := Flags or LISTVIEWSTYLES[TListView(AWinControl).ViewStyle] or LVS_SINGLESEL or LVS_SHAREIMAGELISTS;
|
Flags := Flags or LISTVIEWSTYLES[TListView(AWinControl).ViewStyle] or
|
||||||
|
LVS_SINGLESEL or LVS_SHAREIMAGELISTS or
|
||||||
|
Arrangement[TListView(AWinControl).IconOptions.Arrangement];
|
||||||
if TCustomListView(AWinControl).OwnerData then
|
if TCustomListView(AWinControl).OwnerData then
|
||||||
Flags := Flags or LVS_OWNERDATA;
|
Flags := Flags or LVS_OWNERDATA;
|
||||||
if TCustomListView(AWinControl).BorderStyle = bsSingle then
|
if TCustomListView(AWinControl).BorderStyle = bsSingle then
|
||||||
@ -746,6 +749,21 @@ begin
|
|||||||
SendMessage(ALV.Handle, LVM_SETHOVERTIME, 0, AValue);
|
SendMessage(ALV.Handle, LVM_SETHOVERTIME, 0, AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWin32WSCustomListView.SetIconArrangement(
|
||||||
|
const ALV: TCustomListView; const AValue: TIconArrangement);
|
||||||
|
const
|
||||||
|
ArrangementMap: array[TIconArrangement] of DWord = (
|
||||||
|
{ iaTop } LVS_ALIGNTOP,
|
||||||
|
{ iaLeft } LVS_ALIGNLEFT
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(ALV, 'SetIconArrangement')
|
||||||
|
then Exit;
|
||||||
|
|
||||||
|
// LVM_ALIGN styles are not implemented in windows (according to w7 sdk) => change style
|
||||||
|
UpdateStyle(ALV.Handle, LVS_ALIGNMASK, ArrangementMap[AValue]);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomListView.SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList);
|
class procedure TWin32WSCustomListView.SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList);
|
||||||
const
|
const
|
||||||
LIST_MAP: array[TListViewImageList] of WPARAM = (
|
LIST_MAP: array[TListViewImageList] of WPARAM = (
|
||||||
|
@ -128,7 +128,7 @@ type
|
|||||||
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); virtual;
|
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); virtual;
|
||||||
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); virtual;
|
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); virtual;
|
||||||
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); virtual;
|
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); virtual;
|
||||||
// class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); virtual;
|
class procedure SetIconArrangement(const ALV: TCustomListView; const AValue: TIconArrangement); virtual;
|
||||||
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); virtual;
|
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); virtual;
|
||||||
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); virtual;
|
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); virtual;
|
||||||
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); virtual;
|
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); virtual;
|
||||||
@ -454,6 +454,11 @@ class procedure TWSCustomListView.SetHoverTime(const ALV: TCustomListView; const
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomListView.SetIconArrangement(
|
||||||
|
const ALV: TCustomListView; const AValue: TIconArrangement);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWSCustomListView.SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList);
|
class procedure TWSCustomListView.SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user