mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 13:00:47 +02:00
Cocoa/ListView: in vsIcon/vsSmallIco/vsList, CaptionEditor adapts the font of Caption
This commit is contained in:
parent
8740a1e3eb
commit
62bdfb501d
@ -42,8 +42,8 @@ type
|
||||
procedure onInit; virtual;
|
||||
function isSupportIcon: Boolean; virtual;
|
||||
procedure onUpdateItemSize( baseSize: NSSize ); virtual; abstract;
|
||||
procedure onUpdateItemLayout( cocoItem: TCocoaCollectionItem ); virtual; abstract;
|
||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); virtual; abstract;
|
||||
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); virtual; abstract;
|
||||
procedure onAdjustTextEditor( lv: TCocoaListView ); virtual;
|
||||
end;
|
||||
|
||||
{ TCocoaCollectionItemView }
|
||||
@ -210,7 +210,7 @@ type
|
||||
procedure resetSize; override;
|
||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||
procedure onAdjustTextEditor( lv: TCocoaListView ); override;
|
||||
end;
|
||||
|
||||
{ TCocoaListView_CollectionView_SmallIconHandler }
|
||||
@ -218,7 +218,6 @@ type
|
||||
procedure resetSize; override;
|
||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||
end;
|
||||
|
||||
{ TCocoaListView_CollectionView_ListHandler }
|
||||
@ -227,7 +226,6 @@ type
|
||||
function isSupportIcon: Boolean; override;
|
||||
procedure onUpdateItemSize( baseSize: NSSize ); override;
|
||||
procedure onUpdateItemLayout( cocoaItem: TCocoaCollectionItem ); override;
|
||||
procedure onAdjustTextEditorRect( var aFrame: NSRect ); override;
|
||||
end;
|
||||
|
||||
function AllocCocoaCollectionView( style: TViewStyle ): TCocoaCollectionView;
|
||||
@ -300,6 +298,12 @@ begin
|
||||
Result:= True;
|
||||
end;
|
||||
|
||||
procedure TCocoaListView_CollectionView_StyleHandler.onAdjustTextEditor(
|
||||
lv: TCocoaListView );
|
||||
begin
|
||||
lv.setCaptionAlignment( NSTextAlignmentLeft );
|
||||
end;
|
||||
|
||||
{ TCocoaListView_CollectionView_LargeIconHandler }
|
||||
|
||||
procedure TCocoaListView_CollectionView_LargeIconHandler.resetSize;
|
||||
@ -360,12 +364,13 @@ begin
|
||||
aFrame.origin.x:= aFrame.origin.x + 12;
|
||||
cocoaItem.imageView.setFrame( aFrame );
|
||||
|
||||
cocoaItem.textField.sizeToFit;
|
||||
aFrame.origin.x:= 0;
|
||||
aFrame.origin.y:= 9;
|
||||
aFrame.size.height:= 15;
|
||||
if Assigned(checkBox) then
|
||||
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||
aFrame.size.width:= cv.itemSize.Width - aFrame.origin.x;
|
||||
aFrame.size.height:= cocoaItem.textField.frame.size.height;
|
||||
cocoaItem.textField.setAlignment( NSTextAlignmentCenter );
|
||||
cocoaItem.textField.setFrame( aFrame );
|
||||
|
||||
@ -378,12 +383,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onAdjustTextEditorRect(
|
||||
var aFrame: NSRect);
|
||||
procedure TCocoaListView_CollectionView_LargeIconHandler.onAdjustTextEditor(
|
||||
lv: TCocoaListView );
|
||||
begin
|
||||
aFrame.origin.y:= aFrame.origin.y - 1;
|
||||
aFrame.origin.x:= aFrame.origin.x + 2;
|
||||
aFrame.size.width:= aFrame.size.width - 4;
|
||||
lv.setCaptionAlignment( NSTextAlignmentCenter );
|
||||
end;
|
||||
|
||||
{ TCocoaListView_CollectionView_SmallIconHandler }
|
||||
@ -447,10 +450,11 @@ begin
|
||||
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||
cocoaItem.imageView.setFrame( aFrame );
|
||||
|
||||
cocoaItem.textField.sizeToFit;
|
||||
aFrame.origin.x:= aFrame.origin.x + aFrame.size.width + 2;
|
||||
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
||||
aFrame.origin.y:= (cv.itemSize.Height - cocoaItem.textField.frame.size.height) / 2;
|
||||
aFrame.size.width:= cv.itemSize.Width - aFrame.origin.x - 4;
|
||||
aFrame.size.height:= 15;
|
||||
aFrame.size.height:= cocoaItem.textField.frame.size.height;
|
||||
cocoaItem.textField.setFrame( aFrame );
|
||||
|
||||
if Assigned(checkBox) then begin
|
||||
@ -462,13 +466,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaListView_CollectionView_SmallIconHandler.onAdjustTextEditorRect(
|
||||
var aFrame: NSRect);
|
||||
begin
|
||||
aFrame.origin.y:= aFrame.origin.y + 2;
|
||||
aFrame.size.width:= aFrame.size.width + 2;
|
||||
end;
|
||||
|
||||
{ TCocoaListView_CollectionView_ListHandler }
|
||||
|
||||
procedure TCocoaListView_CollectionView_ListHandler.resetSize;
|
||||
@ -510,10 +507,12 @@ var
|
||||
begin
|
||||
checkBox:= cocoaItem.checkBox;
|
||||
cv:= TCocoaCollectionView(_collectionView);
|
||||
|
||||
cocoaItem.textField.sizeToFit;
|
||||
aFrame.origin.x:= 4;
|
||||
aFrame.origin.y:= (cv.itemSize.Height - 15) / 2;
|
||||
aFrame.origin.y:= (cv.itemSize.Height - cocoaItem.textField.frame.size.height) / 2;
|
||||
aFrame.size.width:= 138;
|
||||
aFrame.size.height:= 15;
|
||||
aFrame.size.height:= cocoaItem.textField.frame.size.height;
|
||||
if Assigned(checkBox) then
|
||||
aFrame.origin.x:= aFrame.origin.x + 24;
|
||||
cocoaItem.textField.setFrame( aFrame );
|
||||
@ -527,14 +526,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaListView_CollectionView_ListHandler.onAdjustTextEditorRect(
|
||||
var aFrame: NSRect);
|
||||
begin
|
||||
aFrame.origin.y:= aFrame.origin.y + 2;
|
||||
aFrame.origin.x:= aFrame.origin.x - 2;
|
||||
aFrame.size.width:= aFrame.size.width + 4;
|
||||
end;
|
||||
|
||||
{ TCocoaCollectionItem }
|
||||
|
||||
procedure TCocoaCollectionItem.createCheckBox;
|
||||
@ -571,6 +562,7 @@ var
|
||||
itemView: TCocoaCollectionItemView;
|
||||
fieldControl: NSTextField;
|
||||
imageControl: NSImageView;
|
||||
cell: NSTextFieldCell;
|
||||
begin
|
||||
itemView:= TCocoaCollectionItemView.alloc.initWithFrame( NSZeroRect);
|
||||
itemView.item:= self;
|
||||
@ -585,6 +577,10 @@ begin
|
||||
fieldControl.setDrawsBackground( False );
|
||||
fieldControl.setEditable( False );
|
||||
fieldControl.setLineBreakMode( NSLineBreakByTruncatingTail );
|
||||
fieldControl.setBezeled( False );
|
||||
cell := NSTextFieldCell(fieldControl.cell);
|
||||
cell.setWraps(false);
|
||||
cell.setScrollable(false);
|
||||
self.setTextField( fieldControl );
|
||||
itemView.addSubview( fieldControl );
|
||||
|
||||
@ -1088,8 +1084,9 @@ begin
|
||||
case ACode of
|
||||
drLabel:
|
||||
begin
|
||||
_listView.setCaptionFont( item.textField.font );
|
||||
_collectionView.styleHandler.onAdjustTextEditor( _listView );
|
||||
frame:= item.textField.frame;
|
||||
_collectionView.styleHandler.onAdjustTextEditorRect( frame );
|
||||
NSToLCLRect( frame, item.view.frame.size.height, rect );
|
||||
item.view.lclLocalToScreen( rect.left, rect.top );
|
||||
_listView.lclScreenToLocal( rect.left, rect.top );
|
||||
|
@ -182,6 +182,7 @@ type
|
||||
_initializing: Boolean;
|
||||
_captionEditor: NSTextField;
|
||||
_captionFont: NSFont;
|
||||
_captionAlignment: NSTextAlignment;
|
||||
private
|
||||
procedure createControls; message 'createControls';
|
||||
procedure releaseControls; message 'releaseControls';
|
||||
@ -203,6 +204,7 @@ type
|
||||
function initializing: Boolean; message 'isinitializing';
|
||||
procedure setCaptionEditor( captionEditor: NSTextField ); message 'setCaptionEditor:';
|
||||
procedure setCaptionFont( captionFont: NSFont ); message 'setCaptionFont:';
|
||||
procedure setCaptionAlignment( alignment: NSTextAlignment ); message 'setCaptionAlignment:';
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -236,6 +238,7 @@ begin
|
||||
_captionEditor:= captionEditor;
|
||||
if Assigned(_captionFont) then
|
||||
_captionEditor.setFont( _captionFont );
|
||||
_captionEditor.setAlignment( _captionAlignment );
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setCaptionFont(captionFont: NSFont);
|
||||
@ -246,6 +249,12 @@ begin
|
||||
_captionEditor.setFont( _captionFont );
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setCaptionAlignment( alignment: NSTextAlignment );
|
||||
begin
|
||||
_captionAlignment:= alignment;
|
||||
_captionEditor.setAlignment( _captionAlignment );
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setViewStyle(viewStyle: TViewStyle);
|
||||
begin
|
||||
if Assigned(_backendControl) and (_viewStyle=viewStyle) then
|
||||
|
@ -1127,11 +1127,11 @@ begin
|
||||
cell.setWraps(false);
|
||||
cell.setScrollable(true);
|
||||
end;
|
||||
if NOT TCocoaTextField(field).fixedInitSetting then
|
||||
if NOT field.fixedInitSetting then begin
|
||||
TextFieldSetBorderStyle(field, TCustomEdit(AWinControl).BorderStyle);
|
||||
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
|
||||
if NOT field.fixedInitSetting then
|
||||
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
|
||||
UpdateControlFocusRing( field, AWinControl );
|
||||
end;
|
||||
|
||||
Result:=TLCLHandle(field);
|
||||
end;
|
||||
@ -1213,7 +1213,10 @@ var
|
||||
field: TCocoaTextField;
|
||||
begin
|
||||
field := GetTextField(ACustomEdit);
|
||||
if not Assigned(field) then Exit;
|
||||
if not Assigned(field) then
|
||||
Exit;
|
||||
if field.fixedInitSetting then
|
||||
Exit;
|
||||
TextFieldSetAllignment(field, NewAlignment);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user