lcl: ListView:

- add TIconOptions
  - win32 implement support for different IconOptions (issue #0014460)

git-svn-id: trunk@21546 -
This commit is contained in:
paul 2009-09-03 02:48:41 +00:00
parent fa1b49813e
commit 4a0461a558
5 changed files with 117 additions and 6 deletions

View File

@ -655,6 +655,29 @@ type
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 = class(TPersistent)
@ -930,6 +953,7 @@ type
FCanvas: TCanvas;
FDefaultItemHeight: integer;
FHotTrackStyles: TListHotTrackStyles;
FIconOptions: TIconOptions;
FOwnerData: Boolean;
FOwnerDataItem: TOwnerDataListItem;
FListItems: TListItems;
@ -984,6 +1008,7 @@ type
procedure SetFocused(const AValue: TListItem);
procedure SetHotTrackStyles(const AValue: TListHotTrackStyles);
procedure SetHoverTime(const AValue: Integer);
procedure SetIconOptions(const AValue: TIconOptions);
procedure SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
procedure SetItems(const AValue : TListItems);
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 HotTrack: Boolean index Ord(lvpHotTrack) read GetProperty write SetProperty default False;
property HotTrackStyles: TListHotTrackStyles read FHotTrackStyles write SetHotTrackStyles default [];
property IconOptions: TIconOptions read FIconOptions write SetIconOptions;
property ItemFocused: TListItem read GetFocused write SetFocused;
property Items: TListItems read FListItems write SetItems;
// MultiSelect and ReadOnly should be protected, but can't because Carbon Interface
@ -1124,6 +1150,7 @@ type
// property HotTrack;
// property HotTrackStyles;
// property HoverTime;
property IconOptions;
property Items;
property LargeImages;
property MultiSelect;

View File

@ -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
------------------------------------------------------------------------------}
@ -22,8 +76,9 @@ var
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csCaptureMouse];
FColumns := TListColumns.Create(self);
FListItems := TListItems.Create(self);
FIconOptions := TIconOptions.Create(Self);
FColumns := TListColumns.Create(Self);
FListItems := TListItems.Create(Self);
BorderStyle := bsSingle;
FScrollBars := ssBoth;
FCompStyle := csListView;
@ -42,7 +97,7 @@ begin
Color := clWindow;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
FProperties := [lvpColumnClick, lvpHideSelection, lvpShowColumnHeaders, lvpToolTips];
FProperties := [lvpColumnClick, lvpHideSelection, lvpShowColumnHeaders, lvpToolTips, lvpWrapText];
FOwnerDataItem := TOwnerDataListItem.Create(FListItems);
end;
@ -569,6 +624,7 @@ begin
FreeAndNil(FImageChangeLinks[lvil]);
FreeAndNil(FOwnerDataItem);
FreeAndNil(FListItems);
FreeAndNil(FIconOptions);
end;
{------------------------------------------------------------------------------
@ -814,6 +870,11 @@ begin
TWSCustomListViewClass(WidgetSetClass).SetHoverTime(Self, FHoverTime);
end;
procedure TCustomListView.SetIconOptions(const AValue: TIconOptions);
begin
FIconOptions.Assign(AValue);
end;
procedure TCustomListView.SetImageList(const ALvilOrd: Integer; const AValue: TCustomImageList);
var
lvil: TListViewImageList;

View File

@ -136,7 +136,7 @@ type
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); 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 SetItemsCount(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); override;

View File

@ -477,6 +477,7 @@ class function TWin32WSCustomListView.CreateHandle(const AWinControl: TWinContro
const AParams: TCreateParams): HWND;
const
LISTVIEWSTYLES: array[TViewStyle] of DWORD = (LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT);
Arrangement: array[TIconArrangement] of DWord = (LVS_ALIGNTOP, LVS_ALIGNLEFT);
var
Params: TCreateWindowExParams;
begin
@ -487,7 +488,9 @@ begin
begin
pClassName := WC_LISTVIEW;
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
Flags := Flags or LVS_OWNERDATA;
if TCustomListView(AWinControl).BorderStyle = bsSingle then
@ -746,6 +749,21 @@ begin
SendMessage(ALV.Handle, LVM_SETHOVERTIME, 0, AValue);
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);
const
LIST_MAP: array[TListViewImageList] of WPARAM = (

View File

@ -128,7 +128,7 @@ type
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); virtual;
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); 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 SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); virtual;
class procedure SetOwnerData(const ALV: TCustomListView; const AValue: Boolean); virtual;
@ -454,6 +454,11 @@ class procedure TWSCustomListView.SetHoverTime(const ALV: TCustomListView; const
begin
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);
begin
end;