mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 08:51:17 +02:00
Cocoa/ListView: checkBoxes supported, Merge branch 'cocoa/listview'
This commit is contained in:
commit
15826f4f01
@ -10,40 +10,52 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
MacOSAll, CocoaAll,
|
MacOSAll, CocoaAll,
|
||||||
CocoaPrivate, Cocoa_Extra, CocoaCallback, CocoaConfig, CocoaUtils,
|
CocoaPrivate, Cocoa_Extra, CocoaCallback, CocoaConfig, CocoaConst, CocoaUtils,
|
||||||
CocoaListView, CocoaTextEdits,
|
CocoaListView, CocoaTextEdits,
|
||||||
LCLType, Controls, ComCtrls, StdCtrls, ImgList, Forms;
|
LCLType, Controls, ComCtrls, StdCtrls, ImgList, Forms;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TCocoaCollectionItem }
|
||||||
|
TCocoaCollectionItem = objcclass(NSCollectionViewItem)
|
||||||
|
private
|
||||||
|
_checkBox: NSButton;
|
||||||
|
private
|
||||||
|
procedure checkboxAction(sender: NSButton); message 'checkboxAction:';
|
||||||
|
public
|
||||||
|
procedure loadView; override;
|
||||||
|
function checkBox: NSButton; message 'checkBox';
|
||||||
|
procedure createCheckBox; message 'createCheckBox';
|
||||||
|
procedure prepareForReuse; message 'prepareForReuse';
|
||||||
|
procedure dealloc; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaListView_CollectionView_StyleHandler }
|
{ TCocoaListView_CollectionView_StyleHandler }
|
||||||
TCocoaListView_CollectionView_StyleHandler = class
|
TCocoaListView_CollectionView_StyleHandler = class
|
||||||
private
|
private
|
||||||
_collectionView: NSCollectionView;
|
_collectionView: NSCollectionView;
|
||||||
public
|
public
|
||||||
constructor Create( collectionView: NSCollectionView ); virtual;
|
constructor Create( collectionView: NSCollectionView ); virtual;
|
||||||
|
function hasCheckBoxes: Boolean;
|
||||||
public
|
public
|
||||||
procedure onInit; virtual; abstract;
|
procedure resetSize; virtual; abstract;
|
||||||
|
procedure onInit; virtual;
|
||||||
procedure onUpdateItemValue( indexPath:NSIndexPath;
|
procedure onUpdateItemValue( indexPath:NSIndexPath;
|
||||||
cocoaItem:NSCollectionViewItem ); virtual; abstract;
|
cocoaItem:TCocoaCollectionItem ); virtual; abstract;
|
||||||
procedure onUpdateItemSize( baseSize: NSSize ); virtual; abstract;
|
procedure onUpdateItemSize( baseSize: NSSize ); virtual; abstract;
|
||||||
procedure onUpdateItemLayout( item:NSCollectionViewItem ); virtual; abstract;
|
procedure onUpdateItemLayout( cocoItem: TCocoaCollectionItem ); virtual; abstract;
|
||||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); virtual; abstract;
|
procedure onAdjustTextEditorRect( var aFrame: NSRect ); virtual; abstract;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaCollectionItem }
|
|
||||||
TCocoaCollectionItem = objcclass(NSCollectionViewItem)
|
|
||||||
public
|
|
||||||
procedure loadView; override;
|
|
||||||
procedure prepareForReuse; message 'prepareForReuse';
|
|
||||||
procedure dealloc; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCocoaCollectionItemView }
|
{ TCocoaCollectionItemView }
|
||||||
TCocoaCollectionItemView = objcclass(NSView)
|
TCocoaCollectionItemView = objcclass(NSView)
|
||||||
private
|
private
|
||||||
item: TCocoaCollectionItem;
|
item: TCocoaCollectionItem;
|
||||||
|
trackingArea: NSTrackingArea;
|
||||||
public
|
public
|
||||||
|
procedure updateTrackingAreas; override;
|
||||||
|
procedure mouseEntered(theEvent: NSEvent); override;
|
||||||
|
procedure mouseExited(theEvent: NSEvent); override;
|
||||||
procedure drawRect(dirtyRect: NSRect); override;
|
procedure drawRect(dirtyRect: NSRect); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -53,10 +65,15 @@ type
|
|||||||
NSCollectionViewDataSourceProtocol,
|
NSCollectionViewDataSourceProtocol,
|
||||||
NSCollectionViewDelegateProtocol_1011,
|
NSCollectionViewDelegateProtocol_1011,
|
||||||
TCocoaListViewBackendControlProtocol )
|
TCocoaListViewBackendControlProtocol )
|
||||||
|
private
|
||||||
|
_checkBoxes: Boolean;
|
||||||
public
|
public
|
||||||
styleHandler: TCocoaListView_CollectionView_StyleHandler;
|
styleHandler: TCocoaListView_CollectionView_StyleHandler;
|
||||||
iconSize: NSSize;
|
iconSize: NSSize;
|
||||||
itemSize: NSSize;
|
itemSize: NSSize;
|
||||||
|
|
||||||
|
procedure lclSetCheckBoxes( checkBoxes: Boolean); message 'lclSetCheckBoxes:';
|
||||||
|
function lclHasCheckBoxes: Boolean; message 'lclHasCheckBoxes';
|
||||||
public
|
public
|
||||||
callback: TLCLListViewCallback;
|
callback: TLCLListViewCallback;
|
||||||
function lclGetCallback: ICommonCallback; override;
|
function lclGetCallback: ICommonCallback; override;
|
||||||
@ -156,7 +173,6 @@ type
|
|||||||
// Item
|
// Item
|
||||||
procedure ItemDelete( const AIndex: Integer); override;
|
procedure ItemDelete( const AIndex: Integer); override;
|
||||||
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
|
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
|
||||||
function ItemGetChecked( const AIndex: Integer; const {%H-}AItem: TListItem): Boolean; override;
|
|
||||||
function ItemGetPosition( const AIndex: Integer): TPoint; override;
|
function ItemGetPosition( const AIndex: Integer): TPoint; override;
|
||||||
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
|
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
|
||||||
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); override;
|
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); override;
|
||||||
@ -194,28 +210,28 @@ type
|
|||||||
|
|
||||||
{ TCocoaListView_CollectionView_LargeIconHandler }
|
{ TCocoaListView_CollectionView_LargeIconHandler }
|
||||||
TCocoaListView_CollectionView_LargeIconHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
TCocoaListView_CollectionView_LargeIconHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
||||||
procedure onInit; override;
|
procedure resetSize; override;
|
||||||
procedure onUpdateItemValue(indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem); override;
|
procedure onUpdateItemValue( indexPath:NSIndexPath; cocoaItem:TCocoaCollectionItem ); override;
|
||||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||||
procedure onUpdateItemLayout(item: NSCollectionViewItem); override;
|
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaListView_CollectionView_SmallIconHandler }
|
{ TCocoaListView_CollectionView_SmallIconHandler }
|
||||||
TCocoaListView_CollectionView_SmallIconHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
TCocoaListView_CollectionView_SmallIconHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
||||||
procedure onInit; override;
|
procedure resetSize; override;
|
||||||
procedure onUpdateItemValue(indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem); override;
|
procedure onUpdateItemValue( indexPath:NSIndexPath; cocoaItem:TCocoaCollectionItem ); override;
|
||||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||||
procedure onUpdateItemLayout(item: NSCollectionViewItem); override;
|
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaListView_CollectionView_ListHandler }
|
{ TCocoaListView_CollectionView_ListHandler }
|
||||||
TCocoaListView_CollectionView_ListHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
TCocoaListView_CollectionView_ListHandler = class(TCocoaListView_CollectionView_StyleHandler)
|
||||||
procedure onInit; override;
|
procedure resetSize; override;
|
||||||
procedure onUpdateItemValue(indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem); override;
|
procedure onUpdateItemValue( indexPath:NSIndexPath; cocoaItem:TCocoaCollectionItem ); override;
|
||||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||||
procedure onUpdateItemLayout(item: NSCollectionViewItem); override;
|
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -274,9 +290,19 @@ begin
|
|||||||
_collectionView:= collectionView;
|
_collectionView:= collectionView;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaListView_CollectionView_StyleHandler.hasCheckBoxes: Boolean;
|
||||||
|
begin
|
||||||
|
Result:= TCocoaCollectionView(_collectionView).lclHasCheckBoxes;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaListView_CollectionView_StyleHandler.onInit;
|
||||||
|
begin
|
||||||
|
self.resetSize;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaListView_CollectionView_LargeIconHandler }
|
{ TCocoaListView_CollectionView_LargeIconHandler }
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onInit;
|
procedure TCocoaListView_CollectionView_LargeIconHandler.resetSize;
|
||||||
var
|
var
|
||||||
layout: NSCollectionViewFlowLayout;
|
layout: NSCollectionViewFlowLayout;
|
||||||
minSize: NSSize;
|
minSize: NSSize;
|
||||||
@ -284,6 +310,10 @@ begin
|
|||||||
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
||||||
minSize.width:= 64;
|
minSize.width:= 64;
|
||||||
minSize.height:= 68;
|
minSize.height:= 68;
|
||||||
|
|
||||||
|
if self.hasCheckBoxes then
|
||||||
|
minSize.width:= minSize.width + 24;
|
||||||
|
|
||||||
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
||||||
layout.setItemSize( minSize );
|
layout.setItemSize( minSize );
|
||||||
layout.setMinimumInteritemSpacing( 4 );
|
layout.setMinimumInteritemSpacing( 4 );
|
||||||
@ -291,19 +321,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onUpdateItemValue(
|
procedure TCocoaListView_CollectionView_LargeIconHandler.onUpdateItemValue(
|
||||||
indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem);
|
indexPath: NSIndexPath; cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
|
row: NSInteger;
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
cocoaImage: NSImage;
|
cocoaImage: NSImage;
|
||||||
lclImageIndex: Integer;
|
lclImageIndex: Integer;
|
||||||
lclText: String;
|
lclText: String;
|
||||||
begin
|
begin
|
||||||
|
row:= indexPath.item;
|
||||||
cv:= TCocoaCollectionView(_collectionView);
|
cv:= TCocoaCollectionView(_collectionView);
|
||||||
cv.callback.GetItemImageAt( indexPath.item, 0, lclImageIndex );
|
cv.callback.GetItemImageAt( row, 0, lclImageIndex );
|
||||||
cocoaImage:= cv.callback.GetImageFromIndex( lclImageIndex );
|
cocoaImage:= cv.callback.GetImageFromIndex( lclImageIndex );
|
||||||
cocoaItem.imageView.setImage( cocoaImage );
|
cocoaItem.imageView.setImage( cocoaImage );
|
||||||
|
|
||||||
cv.callback.GetItemTextAt( indexPath.item, 0, lclText );
|
cv.callback.GetItemTextAt( row, 0, lclText );
|
||||||
cocoaItem.textField.setStringValue( StrToNSString(lclText) );
|
cocoaItem.textField.setStringValue( StrToNSString(lclText) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -325,26 +357,44 @@ begin
|
|||||||
cv.itemSize.Width:= 64;
|
cv.itemSize.Width:= 64;
|
||||||
if cv.itemSize.Height < 68 then
|
if cv.itemSize.Height < 68 then
|
||||||
cv.itemSize.Height:= 68;
|
cv.itemSize.Height:= 68;
|
||||||
|
|
||||||
|
if self.hasCheckBoxes then
|
||||||
|
cv.itemSize.Width:= cv.itemSize.Width + 24;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onUpdateItemLayout(
|
procedure TCocoaListView_CollectionView_LargeIconHandler.onUpdateItemLayout(
|
||||||
item: NSCollectionViewItem);
|
cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
aFrame: NSRect;
|
aFrame: NSRect;
|
||||||
|
checkBox: NSButton;
|
||||||
begin
|
begin
|
||||||
|
checkBox:= cocoaItem.checkBox;
|
||||||
cv:= TCocoaCollectionView(_collectionView);
|
cv:= TCocoaCollectionView(_collectionView);
|
||||||
|
|
||||||
aFrame.origin.x:= (cv.itemSize.Width - cv.iconSize.Width) / 2;
|
aFrame.origin.x:= (cv.itemSize.Width - cv.iconSize.Width) / 2;
|
||||||
aFrame.origin.y:= cv.itemSize.Height - cv.iconSize.Height - 10;
|
aFrame.origin.y:= cv.itemSize.Height - cv.iconSize.Height - 10;
|
||||||
aFrame.size:= cv.iconSize;
|
aFrame.size:= cv.iconSize;
|
||||||
item.imageView.setFrame( aFrame );
|
if Assigned(checkBox) then
|
||||||
|
aFrame.origin.x:= aFrame.origin.x + 12;
|
||||||
|
cocoaItem.imageView.setFrame( aFrame );
|
||||||
|
|
||||||
aFrame.origin.x:= 0;
|
aFrame.origin.x:= 0;
|
||||||
aFrame.origin.y:= 9;
|
aFrame.origin.y:= 9;
|
||||||
aFrame.size.width:= cv.itemSize.Width;
|
|
||||||
aFrame.size.height:= 15;
|
aFrame.size.height:= 15;
|
||||||
item.textField.setAlignment( NSTextAlignmentCenter );
|
if Assigned(checkBox) then
|
||||||
item.textField.setFrame( aFrame );
|
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||||
|
aFrame.size.width:= cv.itemSize.Width - aFrame.origin.x;
|
||||||
|
cocoaItem.textField.setAlignment( NSTextAlignmentCenter );
|
||||||
|
cocoaItem.textField.setFrame( aFrame );
|
||||||
|
|
||||||
|
if Assigned(checkBox) then begin
|
||||||
|
aFrame.size.width:= 18;
|
||||||
|
aFrame.size.height:= 18;
|
||||||
|
aFrame.origin.x:= 6;
|
||||||
|
aFrame.origin.y:= (cv.itemSize.Height - aFrame.size.height ) / 2 + 5;
|
||||||
|
checkBox.setFrame( aFrame );
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onAdjustTextEditorRect(
|
procedure TCocoaListView_CollectionView_LargeIconHandler.onAdjustTextEditorRect(
|
||||||
@ -356,7 +406,7 @@ end;
|
|||||||
|
|
||||||
{ TCocoaListView_CollectionView_SmallIconHandler }
|
{ TCocoaListView_CollectionView_SmallIconHandler }
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_SmallIconHandler.onInit;
|
procedure TCocoaListView_CollectionView_SmallIconHandler.resetSize;
|
||||||
var
|
var
|
||||||
layout: NSCollectionViewFlowLayout;
|
layout: NSCollectionViewFlowLayout;
|
||||||
minSize: NSSize;
|
minSize: NSSize;
|
||||||
@ -364,6 +414,9 @@ begin
|
|||||||
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
||||||
minSize.width:= 150;
|
minSize.width:= 150;
|
||||||
minSize.height:= 28;
|
minSize.height:= 28;
|
||||||
|
if self.hasCheckBoxes then
|
||||||
|
minSize.width:= minSize.width + 24;
|
||||||
|
|
||||||
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
||||||
layout.setItemSize( minSize );
|
layout.setItemSize( minSize );
|
||||||
layout.setMinimumInteritemSpacing( 10 );
|
layout.setMinimumInteritemSpacing( 10 );
|
||||||
@ -371,19 +424,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_SmallIconHandler.onUpdateItemValue(
|
procedure TCocoaListView_CollectionView_SmallIconHandler.onUpdateItemValue(
|
||||||
indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem);
|
indexPath: NSIndexPath; cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
|
row: NSInteger;
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
cocoaImage: NSImage;
|
cocoaImage: NSImage;
|
||||||
lclImageIndex: Integer;
|
lclImageIndex: Integer;
|
||||||
lclText: String;
|
lclText: String;
|
||||||
begin
|
begin
|
||||||
|
row:= indexPath.item;
|
||||||
cv:= TCocoaCollectionView(_collectionView);
|
cv:= TCocoaCollectionView(_collectionView);
|
||||||
cv.callback.GetItemImageAt( indexPath.item, 0, lclImageIndex );
|
cv.callback.GetItemImageAt( row, 0, lclImageIndex );
|
||||||
cocoaImage:= cv.callback.GetImageFromIndex( lclImageIndex );
|
cocoaImage:= cv.callback.GetImageFromIndex( lclImageIndex );
|
||||||
cocoaItem.imageView.setImage( cocoaImage );
|
cocoaItem.imageView.setImage( cocoaImage );
|
||||||
|
|
||||||
cv.callback.GetItemTextAt( indexPath.item, 0, lclText );
|
cv.callback.GetItemTextAt( row, 0, lclText );
|
||||||
cocoaItem.textField.setStringValue( StrToNSString(lclText) );
|
cocoaItem.textField.setStringValue( StrToNSString(lclText) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -403,25 +458,41 @@ begin
|
|||||||
cv.itemSize.Height:= 4 + baseSize.Height + 4;
|
cv.itemSize.Height:= 4 + baseSize.Height + 4;
|
||||||
if cv.itemSize.Height < 28 then
|
if cv.itemSize.Height < 28 then
|
||||||
cv.itemSize.Height:= 28;
|
cv.itemSize.Height:= 28;
|
||||||
|
|
||||||
|
if self.hasCheckBoxes then
|
||||||
|
cv.itemSize.width:= cv.itemSize.width + 24;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_SmallIconHandler.onUpdateItemLayout(
|
procedure TCocoaListView_CollectionView_SmallIconHandler.onUpdateItemLayout(
|
||||||
item: NSCollectionViewItem);
|
cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
aFrame: NSRect;
|
aFrame: NSRect;
|
||||||
|
checkBox: NSButton;
|
||||||
begin
|
begin
|
||||||
|
checkBox:= cocoaItem.checkBox;
|
||||||
cv:= TCocoaCollectionView(_collectionView);
|
cv:= TCocoaCollectionView(_collectionView);
|
||||||
|
|
||||||
aFrame.origin.x:= 6;
|
aFrame.origin.x:= 6;
|
||||||
aFrame.origin.y:= (cv.itemSize.Height - cv.iconSize.Height) / 2;
|
aFrame.origin.y:= (cv.itemSize.Height - cv.iconSize.Height) / 2;
|
||||||
aFrame.size:= cv.iconSize;
|
aFrame.size:= cv.iconSize;
|
||||||
item.imageView.setFrame( aFrame );
|
if Assigned(checkBox) then
|
||||||
|
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||||
|
cocoaItem.imageView.setFrame( aFrame );
|
||||||
|
|
||||||
aFrame.origin.x:= aFrame.origin.x + aFrame.size.width + 2;
|
aFrame.origin.x:= aFrame.origin.x + aFrame.size.width + 2;
|
||||||
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
||||||
aFrame.size.width:= 120;
|
aFrame.size.width:= 120;
|
||||||
aFrame.size.height:= 15;
|
aFrame.size.height:= 15;
|
||||||
item.textField.setFrame( aFrame );
|
cocoaItem.textField.setFrame( aFrame );
|
||||||
|
|
||||||
|
if Assigned(checkBox) then begin
|
||||||
|
aFrame.size.width:= 18;
|
||||||
|
aFrame.size.height:= 18;
|
||||||
|
aFrame.origin.x:= 6;
|
||||||
|
aFrame.origin.y:= (cv.itemSize.Height - aFrame.size.height ) / 2;
|
||||||
|
checkBox.setFrame( aFrame );
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_SmallIconHandler.onAdjustTextEditorRect(
|
procedure TCocoaListView_CollectionView_SmallIconHandler.onAdjustTextEditorRect(
|
||||||
@ -432,7 +503,7 @@ end;
|
|||||||
|
|
||||||
{ TCocoaListView_CollectionView_ListHandler }
|
{ TCocoaListView_CollectionView_ListHandler }
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_ListHandler.onInit;
|
procedure TCocoaListView_CollectionView_ListHandler.resetSize;
|
||||||
var
|
var
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
layout: NSCollectionViewFlowLayout;
|
layout: NSCollectionViewFlowLayout;
|
||||||
@ -441,6 +512,9 @@ begin
|
|||||||
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
layout:= NSCollectionViewFlowLayout(_collectionView.collectionViewLayout);
|
||||||
minSize.width:= 146;
|
minSize.width:= 146;
|
||||||
minSize.height:= 24;
|
minSize.height:= 24;
|
||||||
|
if self.hasCheckBoxes then
|
||||||
|
minSize.width:= minSize.width + 24;
|
||||||
|
|
||||||
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
TCocoaCollectionView(_collectionView).itemSize:= minSize;
|
||||||
layout.setItemSize( minSize );
|
layout.setItemSize( minSize );
|
||||||
layout.setMinimumInteritemSpacing( 0 );
|
layout.setMinimumInteritemSpacing( 0 );
|
||||||
@ -450,7 +524,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_ListHandler.onUpdateItemValue(
|
procedure TCocoaListView_CollectionView_ListHandler.onUpdateItemValue(
|
||||||
indexPath: NSIndexPath; cocoaItem: NSCollectionViewItem);
|
indexPath: NSIndexPath; cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
cocoaImage: NSImage;
|
cocoaImage: NSImage;
|
||||||
@ -468,17 +542,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_ListHandler.onUpdateItemLayout(
|
procedure TCocoaListView_CollectionView_ListHandler.onUpdateItemLayout(
|
||||||
item: NSCollectionViewItem);
|
cocoaItem: TCocoaCollectionItem);
|
||||||
var
|
var
|
||||||
|
checkBox: NSButton;
|
||||||
cv: TCocoaCollectionView;
|
cv: TCocoaCollectionView;
|
||||||
aFrame: NSRect;
|
aFrame: NSRect;
|
||||||
begin
|
begin
|
||||||
|
checkBox:= cocoaItem.checkBox;
|
||||||
cv:= TCocoaCollectionView(_collectionView);
|
cv:= TCocoaCollectionView(_collectionView);
|
||||||
aFrame.origin.x:= 4;
|
aFrame.origin.x:= 4;
|
||||||
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
||||||
aFrame.size.width:= 138;
|
aFrame.size.width:= 138;
|
||||||
aFrame.size.height:= 15;
|
aFrame.size.height:= 15;
|
||||||
item.textField.setFrame( aFrame );
|
if Assigned(checkBox) then
|
||||||
|
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||||
|
cocoaItem.textField.setFrame( aFrame );
|
||||||
|
|
||||||
|
if Assigned(checkBox) then begin
|
||||||
|
aFrame.size.width:= 18;
|
||||||
|
aFrame.size.height:= 18;
|
||||||
|
aFrame.origin.x:= 6;
|
||||||
|
aFrame.origin.y:= (cv.itemSize.Height - aFrame.size.height ) / 2;
|
||||||
|
checkBox.setFrame( aFrame );
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaListView_CollectionView_ListHandler.onAdjustTextEditorRect(
|
procedure TCocoaListView_CollectionView_ListHandler.onAdjustTextEditorRect(
|
||||||
@ -491,6 +577,33 @@ end;
|
|||||||
|
|
||||||
{ TCocoaCollectionItem }
|
{ TCocoaCollectionItem }
|
||||||
|
|
||||||
|
procedure TCocoaCollectionItem.createCheckBox;
|
||||||
|
begin
|
||||||
|
if NOT Assigned(_checkBox) then begin
|
||||||
|
_checkBox:= NSButton.alloc.init;
|
||||||
|
_checkBox.setHidden( True );
|
||||||
|
_checkBox.setButtonType( NSSwitchButton );
|
||||||
|
_checkBox.setTitle( CocoaConst.NSSTR_EMPTY );
|
||||||
|
_checkBox.setTarget( self );
|
||||||
|
_checkBox.setAction( ObjCSelector('checkboxAction:') );
|
||||||
|
self.View.addSubview( _checkBox );
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaCollectionItem.checkboxAction(sender: NSButton);
|
||||||
|
var
|
||||||
|
row: Integer;
|
||||||
|
cv: TCocoaCollectionView;
|
||||||
|
indexPath: NSIndexPath;
|
||||||
|
begin
|
||||||
|
cv:= TCocoaCollectionView( self.collectionView );
|
||||||
|
indexPath:= cv.indexPathForItem( self );
|
||||||
|
row:= indexPath.item;
|
||||||
|
cv.callback.SetItemCheckedAt( row, 0, sender.state );
|
||||||
|
if sender.state = NSOnState then
|
||||||
|
cv.selectOneItemByIndex( row, True );
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCocoaCollectionItem.loadView;
|
procedure TCocoaCollectionItem.loadView;
|
||||||
var
|
var
|
||||||
itemView: TCocoaCollectionItemView;
|
itemView: TCocoaCollectionItemView;
|
||||||
@ -516,6 +629,11 @@ begin
|
|||||||
self.setView( itemView );
|
self.setView( itemView );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaCollectionItem.checkBox: NSButton;
|
||||||
|
begin
|
||||||
|
Result:= _checkBox;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCocoaCollectionItem.prepareForReuse;
|
procedure TCocoaCollectionItem.prepareForReuse;
|
||||||
begin
|
begin
|
||||||
self.view.removeFromSuperview;
|
self.view.removeFromSuperview;
|
||||||
@ -524,16 +642,61 @@ end;
|
|||||||
procedure TCocoaCollectionItem.dealloc;
|
procedure TCocoaCollectionItem.dealloc;
|
||||||
begin
|
begin
|
||||||
self.imageView.removeFromSuperview;
|
self.imageView.removeFromSuperview;
|
||||||
self.textField.removeFromSuperview;
|
|
||||||
self.view.removeFromSuperview;
|
|
||||||
self.imageView.release;
|
self.imageView.release;
|
||||||
|
|
||||||
|
self.textField.removeFromSuperview;
|
||||||
self.textField.release;
|
self.textField.release;
|
||||||
|
|
||||||
|
if Assigned(_checkBox) then begin
|
||||||
|
_checkBox.removeFromSuperview;
|
||||||
|
_checkBox.release;
|
||||||
|
end;
|
||||||
|
|
||||||
|
self.view.removeFromSuperview;
|
||||||
self.view.release;
|
self.view.release;
|
||||||
inherited dealloc;
|
inherited dealloc;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaCollectionItemView }
|
{ TCocoaCollectionItemView }
|
||||||
|
|
||||||
|
procedure TCocoaCollectionItemView.updateTrackingAreas;
|
||||||
|
const
|
||||||
|
options: NSTrackingAreaOptions = NSTrackingMouseEnteredAndExited
|
||||||
|
or NSTrackingActiveAlways;
|
||||||
|
begin
|
||||||
|
if Assigned(self.trackingArea) then begin
|
||||||
|
removeTrackingArea(self.trackingArea);
|
||||||
|
self.trackingArea.release;
|
||||||
|
end;
|
||||||
|
|
||||||
|
self.trackingArea:= NSTrackingArea.alloc.initWithRect_options_owner_userInfo(
|
||||||
|
self.bounds,
|
||||||
|
options,
|
||||||
|
self,
|
||||||
|
nil );
|
||||||
|
self.addTrackingArea( self.trackingArea );
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaCollectionItemView.mouseEntered(theEvent: NSEvent);
|
||||||
|
begin
|
||||||
|
if Assigned(self.item.checkBox) then
|
||||||
|
self.item.checkBox.setHidden( False );
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaCollectionItemView.mouseExited(theEvent: NSEvent);
|
||||||
|
var
|
||||||
|
checkBox: NSButton;
|
||||||
|
begin
|
||||||
|
checkBox:= self.item.checkBox;
|
||||||
|
if NOT Assigned(checkBox) then
|
||||||
|
Exit;
|
||||||
|
if checkBox.state = NSOnState then
|
||||||
|
Exit;
|
||||||
|
if self.item.isSelected then
|
||||||
|
Exit;
|
||||||
|
checkBox.setHidden( True );
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCocoaCollectionItemView.drawRect(dirtyRect: NSRect);
|
procedure TCocoaCollectionItemView.drawRect(dirtyRect: NSRect);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
@ -545,6 +708,21 @@ end;
|
|||||||
|
|
||||||
{ TCocoaCollectionView }
|
{ TCocoaCollectionView }
|
||||||
|
|
||||||
|
procedure TCocoaCollectionView.lclSetCheckBoxes(checkBoxes: Boolean);
|
||||||
|
begin
|
||||||
|
if _checkBoxes = checkBoxes then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
_checkBoxes:= checkBoxes;
|
||||||
|
self.styleHandler.resetSize;
|
||||||
|
self.reloadData;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCocoaCollectionView.lclHasCheckBoxes: Boolean;
|
||||||
|
begin
|
||||||
|
Result:= _checkBoxes;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCocoaCollectionView.lclGetCallback: ICommonCallback;
|
function TCocoaCollectionView.lclGetCallback: ICommonCallback;
|
||||||
begin
|
begin
|
||||||
Result:= callback;
|
Result:= callback;
|
||||||
@ -601,15 +779,29 @@ end;
|
|||||||
procedure TCocoaCollectionView.updateItemValue(
|
procedure TCocoaCollectionView.updateItemValue(
|
||||||
indexPath:NSIndexPath; cocoaItem: TCocoaCollectionItem );
|
indexPath:NSIndexPath; cocoaItem: TCocoaCollectionItem );
|
||||||
var
|
var
|
||||||
|
row: Integer;
|
||||||
|
checkBox: NSButton;
|
||||||
|
checkedValue: Integer;
|
||||||
isSelected: Boolean;
|
isSelected: Boolean;
|
||||||
begin
|
begin
|
||||||
if NOT Assigned(self.callback) then
|
if NOT Assigned(self.callback) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
if _checkBoxes then
|
||||||
|
cocoaItem.createCheckBox;
|
||||||
|
|
||||||
self.styleHandler.onUpdateItemValue( indexPath, cocoaItem );
|
self.styleHandler.onUpdateItemValue( indexPath, cocoaItem );
|
||||||
|
|
||||||
isSelected:= self.callback.getItemStableSelection(indexPath.item);
|
row:= indexPath.item;
|
||||||
|
isSelected:= self.callback.getItemStableSelection( row );
|
||||||
cocoaItem.setSelected( isSelected );
|
cocoaItem.setSelected( isSelected );
|
||||||
|
|
||||||
|
checkBox:= cocoaItem.checkBox;
|
||||||
|
if Assigned(checkBox) then begin
|
||||||
|
self.callback.GetItemCheckedAt( row, 0, checkedValue );
|
||||||
|
checkBox.setState( checkedValue );
|
||||||
|
checkBox.setHidden( NOT ((checkedValue=NSOnState) or isSelected) );
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaCollectionView.updateItemSize( baseSize: NSSize );
|
procedure TCocoaCollectionView.updateItemSize( baseSize: NSSize );
|
||||||
@ -747,6 +939,8 @@ begin
|
|||||||
if Assigned(item) then begin
|
if Assigned(item) then begin
|
||||||
item.setSelected( True );
|
item.setSelected( True );
|
||||||
item.textField.setToolTip( item.textField.stringValue );
|
item.textField.setToolTip( item.textField.stringValue );
|
||||||
|
if Assigned(item.checkBox) then
|
||||||
|
item.checkBox.setHidden( False );
|
||||||
item.view.setNeedsDisplay_(True);
|
item.view.setNeedsDisplay_(True);
|
||||||
end;
|
end;
|
||||||
if Assigned(self.callback) then
|
if Assigned(self.callback) then
|
||||||
@ -771,6 +965,8 @@ begin
|
|||||||
if Assigned(item) then begin
|
if Assigned(item) then begin
|
||||||
item.setSelected( False );
|
item.setSelected( False );
|
||||||
item.textField.setToolTip( nil );
|
item.textField.setToolTip( nil );
|
||||||
|
if Assigned(item.checkBox) then
|
||||||
|
item.checkBox.setHidden( item.checkBox.state<>NSOnState );
|
||||||
item.view.setNeedsDisplay_(True);
|
item.view.setNeedsDisplay_(True);
|
||||||
end;
|
end;
|
||||||
if Assigned(self.callback) then
|
if Assigned(self.callback) then
|
||||||
@ -929,12 +1125,6 @@ begin
|
|||||||
Result:= NSRectToRect( frame );
|
Result:= NSRectToRect( frame );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaWSListView_CollectionViewHandler.ItemGetChecked(
|
|
||||||
const AIndex: Integer; const AItem: TListItem): Boolean;
|
|
||||||
begin
|
|
||||||
Result:= False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCocoaWSListView_CollectionViewHandler.ItemGetPosition(
|
function TCocoaWSListView_CollectionViewHandler.ItemGetPosition(
|
||||||
const AIndex: Integer): TPoint;
|
const AIndex: Integer): TPoint;
|
||||||
var
|
var
|
||||||
@ -982,6 +1172,7 @@ end;
|
|||||||
procedure TCocoaWSListView_CollectionViewHandler.ItemSetChecked(
|
procedure TCocoaWSListView_CollectionViewHandler.ItemSetChecked(
|
||||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||||
begin
|
begin
|
||||||
|
_collectionView.reloadData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaWSListView_CollectionViewHandler.ItemSetImage(
|
procedure TCocoaWSListView_CollectionViewHandler.ItemSetImage(
|
||||||
@ -1133,6 +1324,8 @@ procedure TCocoaWSListView_CollectionViewHandler.SetProperty(
|
|||||||
const AProp: TListViewProperty; const AIsSet: Boolean);
|
const AProp: TListViewProperty; const AIsSet: Boolean);
|
||||||
begin
|
begin
|
||||||
case AProp of
|
case AProp of
|
||||||
|
{lvpAutoArrange,}
|
||||||
|
lvpCheckboxes: _collectionView.lclSetCheckBoxes(AIsSet);
|
||||||
{lvpHideSelection,
|
{lvpHideSelection,
|
||||||
lvpHotTrack,}
|
lvpHotTrack,}
|
||||||
lvpMultiSelect: _collectionView.setAllowsMultipleSelection(AIsSet);
|
lvpMultiSelect: _collectionView.setAllowsMultipleSelection(AIsSet);
|
||||||
@ -1153,17 +1346,7 @@ end;
|
|||||||
procedure TCocoaWSListView_CollectionViewHandler.SetSort(
|
procedure TCocoaWSListView_CollectionViewHandler.SetSort(
|
||||||
const AType: TSortType; const AColumn: Integer;
|
const AType: TSortType; const AColumn: Integer;
|
||||||
const ASortDirection: TSortDirection);
|
const ASortDirection: TSortDirection);
|
||||||
var
|
|
||||||
lclcb : TLCLListViewCallback;
|
|
||||||
begin
|
begin
|
||||||
lclcb:= getCallback;
|
|
||||||
if NOT Assigned(lclcb) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
if TCocoaListView(lclcb.Owner).initializing then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
lclcb.selectionIndexSet.removeAllIndexes;
|
|
||||||
_collectionView.reloadData();
|
_collectionView.reloadData();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ type
|
|||||||
// Item
|
// Item
|
||||||
procedure ItemDelete( const AIndex: Integer); virtual; abstract;
|
procedure ItemDelete( const AIndex: Integer); virtual; abstract;
|
||||||
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; virtual; abstract;
|
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; virtual; abstract;
|
||||||
function ItemGetChecked( const AIndex: Integer; const {%H-}AItem: TListItem): Boolean; virtual; abstract;
|
|
||||||
function ItemGetPosition( const AIndex: Integer): TPoint; virtual; abstract;
|
function ItemGetPosition( const AIndex: Integer): TPoint; virtual; abstract;
|
||||||
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; virtual; abstract; // returns True if supported
|
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; virtual; abstract; // returns True if supported
|
||||||
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); virtual; abstract;
|
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); virtual; abstract;
|
||||||
|
@ -240,7 +240,6 @@ type
|
|||||||
// Item
|
// Item
|
||||||
procedure ItemDelete( const AIndex: Integer); override;
|
procedure ItemDelete( const AIndex: Integer); override;
|
||||||
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
|
function ItemDisplayRect( const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
|
||||||
function ItemGetChecked( const AIndex: Integer; const {%H-}AItem: TListItem): Boolean; override;
|
|
||||||
function ItemGetPosition( const AIndex: Integer): TPoint; override;
|
function ItemGetPosition( const AIndex: Integer): TPoint; override;
|
||||||
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
|
function ItemGetState( const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
|
||||||
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); override;
|
procedure ItemInsert( const AIndex: Integer; const {%H-}AItem: TListItem); override;
|
||||||
@ -1749,19 +1748,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaWSListView_TableViewHandler.ItemGetChecked(
|
|
||||||
const AIndex: Integer; const AItem: TListItem): Boolean;
|
|
||||||
var
|
|
||||||
lclcb : TLCLListViewCallback;
|
|
||||||
begin
|
|
||||||
Result:= False;
|
|
||||||
lclcb:= getCallback;
|
|
||||||
if NOT Assigned(lclcb) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
Result := lclcb.checkedIdx.containsIndex(AIndex);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCocoaWSListView_TableViewHandler.ItemGetPosition(
|
function TCocoaWSListView_TableViewHandler.ItemGetPosition(
|
||||||
const AIndex: Integer): TPoint;
|
const AIndex: Integer): TPoint;
|
||||||
var
|
var
|
||||||
@ -1806,20 +1792,8 @@ end;
|
|||||||
|
|
||||||
procedure TCocoaWSListView_TableViewHandler.ItemSetChecked(
|
procedure TCocoaWSListView_TableViewHandler.ItemSetChecked(
|
||||||
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
|
||||||
var
|
|
||||||
lclcb: TLCLListViewCallback;
|
|
||||||
begin
|
begin
|
||||||
lclcb:= getCallback;
|
_tableView.reloadDataForRow_column(AIndex, 0);
|
||||||
if NOT Assigned(lclcb) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
if AChecked and not lclcb.checkedIdx.containsIndex(AIndex) then begin
|
|
||||||
lclcb.checkedIdx.addIndex(AIndex);
|
|
||||||
_tableView.reloadDataForRow_column(AIndex, 0);
|
|
||||||
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
|
||||||
lclcb.checkedIdx.removeIndex(AIndex);
|
|
||||||
_tableView.reloadDataForRow_column(AIndex, 0);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaWSListView_TableViewHandler.ItemSetImage(
|
procedure TCocoaWSListView_TableViewHandler.ItemSetImage(
|
||||||
@ -2005,19 +1979,7 @@ end;
|
|||||||
|
|
||||||
procedure TCocoaWSListView_TableViewHandler.SetSort(const AType: TSortType;
|
procedure TCocoaWSListView_TableViewHandler.SetSort(const AType: TSortType;
|
||||||
const AColumn: Integer; const ASortDirection: TSortDirection);
|
const AColumn: Integer; const ASortDirection: TSortDirection);
|
||||||
var
|
|
||||||
lclcb: TLCLListViewCallback;
|
|
||||||
begin
|
begin
|
||||||
lclcb:= getCallback;
|
|
||||||
if NOT Assigned(lclcb) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
if TCocoaListView(lclcb.Owner).initializing then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
if Assigned(lclcb.checkedIdx) then
|
|
||||||
lclcb.checkedIdx.removeAllIndexes;
|
|
||||||
lclcb.selectionIndexSet.removeAllIndexes;
|
|
||||||
_tableView.reloadData();
|
_tableView.reloadData();
|
||||||
{ //todo:
|
{ //todo:
|
||||||
lNSColumn.setSortDescriptorPrototype(
|
lNSColumn.setSortDescriptorPrototype(
|
||||||
|
@ -17,6 +17,8 @@ type
|
|||||||
{ TCocoaWSCustomListView }
|
{ TCocoaWSCustomListView }
|
||||||
|
|
||||||
TCocoaWSCustomListView = class(TWSCustomListView)
|
TCocoaWSCustomListView = class(TWSCustomListView)
|
||||||
|
private
|
||||||
|
class var _settingLCLDirectly: Boolean;
|
||||||
private
|
private
|
||||||
class function getWSHandler( const lclListView: TCustomListView ):
|
class function getWSHandler( const lclListView: TCustomListView ):
|
||||||
TCocoaWSListViewHandler;
|
TCocoaWSListViewHandler;
|
||||||
@ -317,12 +319,14 @@ class function TCocoaWSCustomListView.ItemGetChecked(
|
|||||||
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem
|
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem
|
||||||
): Boolean;
|
): Boolean;
|
||||||
var
|
var
|
||||||
WSHandler: TCocoaWSListViewHandler;
|
lclcb : TLCLListViewCallback;
|
||||||
begin
|
begin
|
||||||
Result:= False;
|
Result:= False;
|
||||||
WSHandler:= getWSHandler( ALV );
|
lclcb:= getCallback( ALV );
|
||||||
if Assigned(WSHandler) then
|
if NOT Assigned(lclcb) then
|
||||||
Result:= WSHandler.ItemGetChecked( AIndex, AItem );
|
Exit;
|
||||||
|
|
||||||
|
Result := lclcb.checkedIdx.containsIndex(AIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TCocoaWSCustomListView.ItemGetPosition(
|
class function TCocoaWSCustomListView.ItemGetPosition(
|
||||||
@ -363,10 +367,34 @@ class procedure TCocoaWSCustomListView.ItemSetChecked(
|
|||||||
const AChecked: Boolean);
|
const AChecked: Boolean);
|
||||||
var
|
var
|
||||||
WSHandler: TCocoaWSListViewHandler;
|
WSHandler: TCocoaWSListViewHandler;
|
||||||
|
lclcb: TLCLListViewCallback;
|
||||||
|
cocoaListView: TCocoaListView;
|
||||||
|
needsUpdate: Boolean = False;
|
||||||
begin
|
begin
|
||||||
WSHandler:= getWSHandler( ALV );
|
if _settingLCLDirectly then
|
||||||
if Assigned(WSHandler) then
|
Exit;
|
||||||
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
|
||||||
|
lclcb:= self.getCallback( ALV );
|
||||||
|
if NOT Assigned(lclcb) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
if AChecked and not lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||||
|
lclcb.checkedIdx.addIndex(AIndex);
|
||||||
|
needsUpdate:= True;
|
||||||
|
end else if not AChecked and lclcb.checkedIdx.containsIndex(AIndex) then begin
|
||||||
|
lclcb.checkedIdx.removeIndex(AIndex);
|
||||||
|
needsUpdate:= True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if needsUpdate then begin
|
||||||
|
WSHandler:= getWSHandler( ALV );
|
||||||
|
if Assigned(WSHandler) then
|
||||||
|
WSHandler.ItemSetChecked( AIndex, AItem, AChecked );
|
||||||
|
end;
|
||||||
|
|
||||||
|
_settingLCLDirectly:= True;
|
||||||
|
AItem.Checked:= AChecked;
|
||||||
|
_settingLCLDirectly:= False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
||||||
@ -553,7 +581,19 @@ class procedure TCocoaWSCustomListView.SetSort(const ALV: TCustomListView;
|
|||||||
const ASortDirection: TSortDirection);
|
const ASortDirection: TSortDirection);
|
||||||
var
|
var
|
||||||
WSHandler: TCocoaWSListViewHandler;
|
WSHandler: TCocoaWSListViewHandler;
|
||||||
|
lclcb: TLCLListViewCallback;
|
||||||
begin
|
begin
|
||||||
|
lclcb:= getCallback( ALV );
|
||||||
|
if NOT Assigned(lclcb) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
if TCocoaListView(lclcb.Owner).initializing then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
if Assigned(lclcb.checkedIdx) then
|
||||||
|
lclcb.checkedIdx.removeAllIndexes;
|
||||||
|
lclcb.selectionIndexSet.removeAllIndexes;
|
||||||
|
|
||||||
WSHandler:= getWSHandler( ALV );
|
WSHandler:= getWSHandler( ALV );
|
||||||
if Assigned(WSHandler) then
|
if Assigned(WSHandler) then
|
||||||
WSHandler.SetSort( AType, AColumn, ASortDirection );
|
WSHandler.SetSort( AType, AColumn, ASortDirection );
|
||||||
|
Loading…
Reference in New Issue
Block a user