mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 16:09:17 +02:00
Cocoa/ListView: in vsReport, CaptionEditor adapts the font of Caption
This commit is contained in:
parent
e751c618b6
commit
8740a1e3eb
@ -180,6 +180,8 @@ type
|
||||
_WSHandler: TCocoaWSListViewHandler;
|
||||
_needsCallLclInit: Boolean;
|
||||
_initializing: Boolean;
|
||||
_captionEditor: NSTextField;
|
||||
_captionFont: NSFont;
|
||||
private
|
||||
procedure createControls; message 'createControls';
|
||||
procedure releaseControls; message 'releaseControls';
|
||||
@ -199,6 +201,8 @@ type
|
||||
function scrollView: TCocoaScrollView; message 'scrollView';
|
||||
function WSHandler: TCocoaWSListViewHandler; message 'WSHandler';
|
||||
function initializing: Boolean; message 'isinitializing';
|
||||
procedure setCaptionEditor( captionEditor: NSTextField ); message 'setCaptionEditor:';
|
||||
procedure setCaptionFont( captionFont: NSFont ); message 'setCaptionFont:';
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -227,6 +231,21 @@ begin
|
||||
Result:= _initializing;
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setCaptionEditor(captionEditor: NSTextField);
|
||||
begin
|
||||
_captionEditor:= captionEditor;
|
||||
if Assigned(_captionFont) then
|
||||
_captionEditor.setFont( _captionFont );
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setCaptionFont(captionFont: NSFont);
|
||||
begin
|
||||
if Assigned(_captionFont) then
|
||||
_captionFont.release;
|
||||
_captionFont:= captionFont.retain;
|
||||
_captionEditor.setFont( _captionFont );
|
||||
end;
|
||||
|
||||
procedure TCocoaListView.setViewStyle(viewStyle: TViewStyle);
|
||||
begin
|
||||
if Assigned(_backendControl) and (_viewStyle=viewStyle) then
|
||||
@ -315,6 +334,7 @@ end;
|
||||
procedure TCocoaListView.dealloc;
|
||||
begin
|
||||
self.releaseControls;
|
||||
_captionFont.release;
|
||||
inherited dealloc;
|
||||
end;
|
||||
|
||||
@ -566,8 +586,9 @@ begin
|
||||
field:= TCocoaTextField( aView );
|
||||
field.setBezeled( False );
|
||||
field.setFocusRingType( NSFocusRingTypeExterior );
|
||||
field.fixedBorderStyle:= True;
|
||||
NSView(self.Owner).addSubview( field ); // add to TCococListView
|
||||
field.fixedInitSetting:= True;
|
||||
TCocoaListView(self.Owner).addSubview( field ); // add to TCocoaListView
|
||||
TCocoaListView(self.Owner).setCaptionEditor( field ); // add to TCocoaListView
|
||||
Result:= True;
|
||||
end;
|
||||
|
||||
|
@ -332,18 +332,21 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure updateNSTextFieldWithTFont( cocoaField: NSTextField; lclFont: TFont );
|
||||
function updateNSTextFieldWithTFont( cocoaField: NSTextField; lclFont: TFont ):
|
||||
Boolean;
|
||||
var
|
||||
saveFontColor: TColor;
|
||||
cocoaFont: NSFont;
|
||||
cocoaColor: NSColor;
|
||||
begin
|
||||
Result:= False;
|
||||
saveFontColor:= lclFont.Color;
|
||||
|
||||
lclFont.Color:= clDefault;
|
||||
if NOT lclFont.isDefault then begin
|
||||
cocoaFont:= TCocoaFont(lclFont.Reference.Handle).Font;
|
||||
cocoaField.setFont( cocoaFont );
|
||||
Result:= True;
|
||||
end;
|
||||
|
||||
lclFont.Color:= saveFontColor;
|
||||
@ -351,7 +354,6 @@ begin
|
||||
cocoaColor:= ColorToNSColor(ColorToRGB(lclFont.Color));
|
||||
cocoaField.setTextColor( cocoaColor );
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure drawNSViewBackground( view: NSView; lclBrush: TBrush );
|
||||
@ -1145,7 +1147,8 @@ begin
|
||||
// in Perferences-Component Palette.
|
||||
hideAllSubviews( self );
|
||||
end else begin
|
||||
updateNSTextFieldWithTFont( self.textField, cocoaTLV.lclGetCanvas.Font );
|
||||
if updateNSTextFieldWithTFont(self.textField, cocoaTLV.lclGetCanvas.Font) then
|
||||
updateItemLayout( row, col );
|
||||
inherited drawRect(dirtyRect);
|
||||
end;
|
||||
end;
|
||||
@ -1264,11 +1267,10 @@ begin
|
||||
rowHeight:= tv.tableView_heightOfRow( tv, row );
|
||||
|
||||
if Assigned(_checkBox) then begin
|
||||
aFrame.size.width:= 18;
|
||||
aFrame.size.height:= 18;
|
||||
aFrame.origin.x:= 0;
|
||||
_checkBox.sizeToFit;
|
||||
aFrame.size:= _checkBox.frame.size;
|
||||
aFrame.origin.y:= (rowHeight - aFrame.size.height ) / 2;
|
||||
_checkBox.setFrame( aFrame );
|
||||
_checkBox.setFrameOrigin( aFrame.origin );
|
||||
|
||||
aFrame.origin.x:= 4;
|
||||
end;
|
||||
@ -1283,13 +1285,13 @@ begin
|
||||
end;
|
||||
|
||||
if Assigned(self.textField) then begin
|
||||
aFrame.size.height:= self.textField.frame.size.height;
|
||||
self.textField.sizeToFit;
|
||||
aFrame.origin.x:= aFrame.origin.x + aFrame.size.width;
|
||||
aFrame.origin.y:= (rowHeight - 15) / 2;
|
||||
aFrame.origin.y:= (rowHeight - self.textField.frame.size.height) / 2;
|
||||
aFrame.size.width:= _column.width - aFrame.origin.x;
|
||||
aFrame.size.height:= self.textField.frame.size.height;
|
||||
if aFrame.size.width < 16 then
|
||||
aFrame.size.width:= 16;
|
||||
aFrame.size.height:= 15;
|
||||
self.textField.setFrame( aFrame );
|
||||
end;
|
||||
end;
|
||||
@ -1680,8 +1682,10 @@ begin
|
||||
case ACode of
|
||||
drLabel:
|
||||
begin
|
||||
_listView.setCaptionFont( item.textField.font );
|
||||
// to do: completely restore TFont
|
||||
_tableView.lclGetCanvas.Font.Height:= Round(item.textField.font.pointSize);
|
||||
frame:= item.textField.frame;
|
||||
frame.origin.y:= frame.origin.y + 2;
|
||||
NSToLCLRect( frame, item.frame.size.height, rect );
|
||||
item.lclLocalToScreen( rect.left, rect.top );
|
||||
_listView.lclScreenToLocal( rect.left, rect.top );
|
||||
|
@ -60,7 +60,7 @@ type
|
||||
TCocoaTextField = objcclass(NSTextField, NSTextField_LCLExt)
|
||||
callback: ICommonCallback;
|
||||
maxLength: Integer;
|
||||
fixedBorderStyle: Boolean;
|
||||
fixedInitSetting: Boolean;
|
||||
|
||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||
function lclGetCallback: ICommonCallback; override;
|
||||
|
@ -445,7 +445,8 @@ begin
|
||||
Result := TCocoaTextField.alloc.lclInitWithCreateParams(AParams);
|
||||
if Assigned(Result) then
|
||||
begin
|
||||
Result.setFont(NSFont.systemFontOfSize(NSFont.systemFontSize));
|
||||
if NOT Result.fixedInitSetting then
|
||||
Result.setFont(NSFont.systemFontOfSize(NSFont.systemFontSize));
|
||||
Result.callback := TLCLCommonCallback.Create(Result, ATarget);
|
||||
SetNSControlValue(Result, AParams.Caption);
|
||||
end;
|
||||
@ -1126,10 +1127,10 @@ begin
|
||||
cell.setWraps(false);
|
||||
cell.setScrollable(true);
|
||||
end;
|
||||
if NOT TCocoaTextField(field).fixedBorderStyle then
|
||||
if NOT TCocoaTextField(field).fixedInitSetting then
|
||||
TextFieldSetBorderStyle(field, TCustomEdit(AWinControl).BorderStyle);
|
||||
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
|
||||
if NOT field.fixedBorderStyle then
|
||||
if NOT field.fixedInitSetting then
|
||||
UpdateControlFocusRing( field, AWinControl );
|
||||
|
||||
Result:=TLCLHandle(field);
|
||||
|
Loading…
Reference in New Issue
Block a user