cocoa: removed special NSScrollView class for ListView. Using the common TCocoaScrollView instead

git-svn-id: trunk@58674 -
This commit is contained in:
dmitry 2018-08-04 22:13:08 +00:00
parent deb177f78b
commit d8f5f93d77
2 changed files with 15 additions and 30 deletions

View File

@ -224,30 +224,8 @@ type
procedure tableViewSelectionIsChanging(notification: NSNotification); message 'tableViewSelectionIsChanging:';} procedure tableViewSelectionIsChanging(notification: NSNotification); message 'tableViewSelectionIsChanging:';}
end; end;
// todo: this NSScrollView should go away. TCocoaScrollView must be used instead
{ TCocoaListView }
TCocoaListView = objcclass(NSScrollView)
public
callback: ICommonCallback;
// For report style:
TableListView: TCocoaTableListView;
// For the other styles:
// ToDo
function lclGetCallback: ICommonCallback; override;
end;
implementation implementation
{ TCocoaListView }
function TCocoaListView.lclGetCallback: ICommonCallback;
begin
Result := callback;
end;
{ TCocoaListBox } { TCocoaListBox }
function TCocoaListBox.lclIsHandle: Boolean; function TCocoaListBox.lclIsHandle: Boolean;

View File

@ -17,7 +17,8 @@ uses
// WS // WS
WSComCtrls, WSComCtrls,
// Cocoa WS // Cocoa WS
CocoaPrivate, CocoaTabControls, CocoaUtils, CocoaWSCommon, CocoaTables, cocoa_extra; CocoaPrivate, CocoaScrollers, CocoaTabControls, CocoaUtils,
CocoaWSCommon, CocoaTables, cocoa_extra;
type type
@ -92,6 +93,8 @@ type
{ TCocoaWSCustomListView } { TCocoaWSCustomListView }
TCocoaListView = TCocoaScrollView;
TCocoaWSCustomListView = class(TWSCustomListView) TCocoaWSCustomListView = class(TWSCustomListView)
private private
class function CheckParams(out AScroll: TCocoaListView; out ATableControl: TCocoaTableListView; const ALV: TCustomListView): Boolean; class function CheckParams(out AScroll: TCocoaListView; out ATableControl: TCocoaTableListView; const ALV: TCustomListView): Boolean;
@ -654,9 +657,9 @@ begin
AScroll := TCocoaListView(ALV.Handle); AScroll := TCocoaListView(ALV.Handle);
// ToDo: Implement for other styles // ToDo: Implement for other styles
if AScroll.TableListView <> nil then if Assigned(AScroll.documentView) and (AScroll.documentView.isKindOfClass(TCocoaTableListView)) then
begin begin
ATableControl := AScroll.TableListView; ATableControl := TCocoaTableListView(AScroll.documentView);
Result := True; Result := True;
end; end;
end; end;
@ -708,7 +711,7 @@ begin
// 1-> The column header appears only if the NSTableView is inside a NSScrollView // 1-> The column header appears only if the NSTableView is inside a NSScrollView
// 2-> To get proper scrolling use NSScrollView.setDocumentView instead of addSubview // 2-> To get proper scrolling use NSScrollView.setDocumentView instead of addSubview
// Source: http://stackoverflow.com/questions/13872642/nstableview-scrolling-does-not-work // Source: http://stackoverflow.com/questions/13872642/nstableview-scrolling-does-not-work
lCocoaLV.TableListView := lTableLV; //lCocoaLV.TableListView := lTableLV;
lCocoaLV.setDocumentView(lTableLV); lCocoaLV.setDocumentView(lTableLV);
lCocoaLV.setHasVerticalScroller(True); lCocoaLV.setHasVerticalScroller(True);
@ -747,13 +750,15 @@ class function TCocoaWSCustomListView.ColumnGetWidth(
var var
lTableLV: TCocoaTableListView; lTableLV: TCocoaTableListView;
lColumn: NSTableColumn; lColumn: NSTableColumn;
sc: TCocoaListView;
begin begin
{$IFDEF COCOA_DEBUG_LISTVIEW} {$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnGetWidth] AIndex=%d', [AIndex])); WriteLn(Format('[TCocoaWSCustomListView.ColumnGetWidth] AIndex=%d', [AIndex]));
{$ENDIF} {$ENDIF}
Result:=0; Result:=0;
if not Assigned(ALV) or not ALV.HandleAllocated then Exit; if not CheckParams(sc, lTableLV, ALV) then Exit;
lTableLV := TCocoaListView(ALV.Handle).TableListView; //if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
//lTableLV := TCocoaTableListView(TCocoaListView(ALV.Handle).documentView);
if (AIndex < 0) or (AIndex >= lTableLV.tableColumns.count()) then Exit; if (AIndex < 0) or (AIndex >= lTableLV.tableColumns.count()) then Exit;
lColumn := lTableLV.tableColumns.objectAtIndex(AIndex); lColumn := lTableLV.tableColumns.objectAtIndex(AIndex);
@ -766,13 +771,15 @@ var
lTableLV: TCocoaTableListView; lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn; lNSColumn: NSTableColumn;
lTitle: NSString; lTitle: NSString;
sc: TCocoaListView;
begin begin
{$IFDEF COCOA_DEBUG_LISTVIEW} {$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert] ALV=%x AIndex=%d', [PtrInt(ALV), AIndex])); WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert] ALV=%x AIndex=%d', [PtrInt(ALV), AIndex]));
{$ENDIF} {$ENDIF}
ALV.HandleNeeded(); ALV.HandleNeeded();
if not Assigned(ALV) or not ALV.HandleAllocated then Exit; //if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
lTableLV := TCocoaListView(ALV.Handle).TableListView; //lTableLV := TCocoaTableListView(TCocoaListView(ALV.Handle).documentView);
if not CheckParams(sc, lTableLV, ALV) then Exit;
{$IFDEF COCOA_DEBUG_LISTVIEW} {$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert]=> tableColumns.count=%d', [lTableLV.tableColumns.count()])); WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert]=> tableColumns.count=%d', [lTableLV.tableColumns.count()]));
{$ENDIF} {$ENDIF}