mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 04:49:43 +02:00
Merged revision(s) 62528-62533 #4ac51dd8f4-#4ac51dd8f4, 62537 #276621a391 from trunk:
cocoa: updating font dialog to return the selected font size. bug #33990 ........ cocoa: updating font dialog initialization. bug #33990 ........ Cocoa fonts: comments ........ cocoa: hiding focus ring, if borderstyle is none. bug #34828 ........ cocoa: not allowing a column of TListView to be selected automatically. ........ Cocoa: font dialog: * Make font size dependent on the dialog's Font.PixelsPerInch and not the global CocoaBasePPI because the user can change it. * Avoid rounding errors by using the real Font.Size value. Bug #34828 ........ cocoa: updating patrons list ........ git-svn-id: branches/fixes_2_0@62538 -
This commit is contained in:
parent
199a2ed24a
commit
7577b0e9e9
@ -646,7 +646,7 @@ begin
|
||||
if ALogFont.lfHeight = 0 then
|
||||
FSize := Round(NSFont.systemFontSize)
|
||||
else
|
||||
FSize := Abs(ALogFont.lfHeight);
|
||||
FSize := Abs(ALogFont.lfHeight); // To-Do: emulate WinAPI difference between negative and absolute height values
|
||||
|
||||
// create font attributes
|
||||
Win32Weight := ALogFont.lfWeight;
|
||||
|
@ -245,6 +245,8 @@ var
|
||||
CocoaToggleBezel : NSBezelStyle = NSRoundedBezelStyle;
|
||||
CocoaToggleType : NSButtonType = NSPushOnPushOffButton;
|
||||
|
||||
CocoaHideFocusNoBorder : Boolean = true;
|
||||
|
||||
{$ifdef COCOALOOPHIJACK}
|
||||
// The flag is set to true once hi-jacked loop is finished (at the end of app)
|
||||
// The flag is checked in Menus to avoid "double" Cmd+Q menu
|
||||
|
@ -1300,7 +1300,7 @@ begin
|
||||
Result := SizeOf(TLogFont);
|
||||
FillChar(ALogFont^, SizeOf(ALogFont^), 0);
|
||||
ALogFont^.lfFaceName := AFont.Name;
|
||||
ALogFont^.lfHeight := AFont.Size;
|
||||
ALogFont^.lfHeight := -AFont.Size; // Cocoa supports only full height (with leading) that corresponds with a negative value in WinAPI
|
||||
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
||||
if (Traits and NSFontBoldTrait) <> 0 then
|
||||
ALogFont^.lfWeight := FW_BOLD
|
||||
|
@ -244,6 +244,7 @@ begin
|
||||
scroll.setAutohidesScrollers(true);
|
||||
|
||||
ScrollViewSetBorderStyle(scroll, TCustomCheckListBox(AWinControl).BorderStyle);
|
||||
UpdateFocusRing(list, TCustomCheckListBox(AWinControl).BorderStyle);
|
||||
|
||||
Result := TLCLIntfHandle(scroll);
|
||||
end;
|
||||
|
@ -1024,9 +1024,11 @@ begin
|
||||
lTableLV.setDataSource(lTableLV);
|
||||
lTableLV.setDelegate(lTableLV);
|
||||
lTableLV.setAllowsColumnReordering(False);
|
||||
lTableLV.setAllowsColumnSelection(False);
|
||||
lCocoaLV.callback := lclcb;
|
||||
|
||||
ScrollViewSetBorderStyle(lCocoaLV, TCustomListView(AWinControl).BorderStyle);
|
||||
UpdateFocusRing(lTableLV, TCustomListView(AWinControl).BorderStyle);
|
||||
|
||||
{$IFDEF COCOA_DEBUG_LISTVIEW}
|
||||
WriteLn(Format('[TCocoaWSCustomListView.CreateHandle] headerView=%d', [PtrInt(lTableLV.headerView)]));
|
||||
@ -1039,6 +1041,7 @@ class procedure TCocoaWSCustomListView.SetBorderStyle(
|
||||
begin
|
||||
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
|
||||
ScrollViewSetBorderStyle(NSScrollView(AWinControl.Handle), ABorderStyle);
|
||||
UpdateFocusRing(NSView(NSScrollView(AWinControl.Handle).documentView), ABorderStyle);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomListView.ColumnDelete(const ALV: TCustomListView;
|
||||
@ -1563,7 +1566,7 @@ begin
|
||||
case AProp of
|
||||
{lvpAutoArrange,}
|
||||
lvpCheckboxes: lTableLV.lclSetFirstColumCheckboxes(AIsSet);
|
||||
lvpColumnClick: lTableLV.setAllowsColumnSelection(AIsSet);
|
||||
// lvpColumnClick: lTableLV.setAllowsColumnSelection(AIsSet);
|
||||
{ lvpFlatScrollBars,
|
||||
lvpFullDrag,}
|
||||
lvpGridLines: lTableLV.setGridStyleMask(GridStyle[AIsSet]);
|
||||
|
@ -160,6 +160,7 @@ function EmbedInManualScrollHost(AView: TCocoaManualScrollView): TCocoaManualScr
|
||||
function HWNDToTargetObject(AFormHandle: HWND): TObject;
|
||||
|
||||
procedure ScrollViewSetBorderStyle(sv: NSScrollView; astyle: TBorderStyle);
|
||||
procedure UpdateFocusRing(v: NSView; astyle: TBorderStyle);
|
||||
|
||||
function ButtonStateToShiftState(BtnState: PtrUInt): TShiftState;
|
||||
function CocoaModifiersToKeyState(AModifiers: NSUInteger): PtrInt;
|
||||
@ -218,6 +219,17 @@ begin
|
||||
sv.setBorderType( NSBorderStyle[astyle] );
|
||||
end;
|
||||
|
||||
procedure UpdateFocusRing(v: NSView; astyle: TBorderStyle);
|
||||
const
|
||||
NSFocusRing : array [TBorderStyle] of NSBorderType = (
|
||||
NSFocusRingTypeNone, // bsNone
|
||||
NSFocusRingTypeDefault // bsSingle s
|
||||
);
|
||||
begin
|
||||
if Assigned(v) and CocoaHideFocusNoBorder then
|
||||
v.setFocusRingType( NSFocusRing[astyle] );
|
||||
end;
|
||||
|
||||
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean): TCocoaScrollView;
|
||||
var
|
||||
r: TRect;
|
||||
|
@ -137,6 +137,9 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
CocoaInt;
|
||||
|
||||
// API irony.
|
||||
// In LCL the base dialog is TOpenDialog (savedialog inherits from it)
|
||||
// In Cocoa the base dialog is SaveDialog (opendialog inherites from it)
|
||||
@ -545,6 +548,7 @@ var
|
||||
accessoryView: NSView;
|
||||
lRect: NSRect;
|
||||
okButton, cancelButton: NSButton;
|
||||
fn : NSFont;
|
||||
begin
|
||||
{$IFDEF VerboseWSClass}
|
||||
DebugLn('TCocoaWSFontDialog.ShowModal for ' + ACommonDialog.Name);
|
||||
@ -554,7 +558,15 @@ begin
|
||||
|
||||
fontPanel := NSFontPanel.sharedFontPanel();
|
||||
inFont := TCocoaFont(FontDialog.Font.Handle);
|
||||
fontPanel.setPanelFont_isMultiple(inFont.Font, False);
|
||||
fn := inFont.Font;
|
||||
if (FontDialog.Font.PixelsPerInch<>72) and (FontDialog.Font.PixelsPerInch<>0) then
|
||||
begin
|
||||
if (FontDialog.Font.Size<>0) then // assign font size directly to avoid rounding errors
|
||||
fn := NSFont.fontWithDescriptor_size(fn.fontDescriptor, Abs(FontDialog.Font.Size)) // ToDo: emulate negative Size values from WinAPI
|
||||
else // fallback for default font size: round the result because currently the LCL doesn't support floating-point sizes, so there is no reason to show them to the user
|
||||
fn := NSFont.fontWithDescriptor_size(fn.fontDescriptor, Round(fn.pointSize * 72 / FontDialog.Font.PixelsPerInch));
|
||||
end;
|
||||
fontPanel.setPanelFont_isMultiple(fn, False);
|
||||
|
||||
FontDelegate := TFontPanelDelegate.alloc.init();
|
||||
FontDelegate.FontPanel := FontPanel;
|
||||
@ -654,6 +666,8 @@ begin
|
||||
oldFont := oldHandle.Font;
|
||||
//oldFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
|
||||
newFont := FontPanel.panelConvertFont(oldFont);
|
||||
if (FontDialog.Font.PixelsPerInch<>72) and (FontDialog.Font.PixelsPerInch<>0) then
|
||||
newFont := NSFont.fontWithDescriptor_size(newFont.fontDescriptor, newFont.pointSize * FontDialog.Font.PixelsPerInch / 72);
|
||||
newHandle := TCocoaFont.Create(newFont);
|
||||
FontDialog.Font.Handle := HFONT(newHandle);
|
||||
end;
|
||||
|
@ -943,6 +943,7 @@ begin
|
||||
end;
|
||||
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
|
||||
TextFieldSetBorderStyle(field, TCustomEdit(AWinControl).BorderStyle);
|
||||
UpdateFocusRing(field, TCustomEdit(AWinControl).BorderStyle);
|
||||
|
||||
Result:=TLCLIntfHandle(field);
|
||||
end;
|
||||
@ -969,6 +970,7 @@ begin
|
||||
if not Assigned(field) then Exit;
|
||||
field.setBordered_( ObjCBool(ABorderStyle <> bsNone) );
|
||||
field.setBezeled_( ObjCBool(ABorderStyle <> bsNone) );
|
||||
UpdateFocusRing(field, ABorderStyle);
|
||||
end;
|
||||
|
||||
class function TCocoaWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
|
||||
@ -1440,6 +1442,7 @@ begin
|
||||
scr.setDrawsBackground(false);
|
||||
|
||||
ScrollViewSetBorderStyle(scr, TCustomMemo(AWinControl).BorderStyle);
|
||||
UpdateFocusRing(txt, TCustomMemo(AWinControl).BorderStyle);
|
||||
|
||||
nr:=scr.documentVisibleRect;
|
||||
txt.setFrame(nr);
|
||||
@ -1531,6 +1534,7 @@ begin
|
||||
if not Assigned(sv) then Exit;
|
||||
|
||||
ScrollViewSetBorderStyle(sv, ABorderStyle);
|
||||
UpdateFocusRing(NSView(sv.documentView), ABorderStyle);
|
||||
end;
|
||||
|
||||
class function TCocoaWSCustomMemo.GetCaretPos(const ACustomEdit: TCustomEdit): TPoint;
|
||||
@ -2086,6 +2090,7 @@ begin
|
||||
scroll.setHasVerticalScroller(true);
|
||||
scroll.setAutohidesScrollers(true);
|
||||
ScrollViewSetBorderStyle(scroll, lclListBox.BorderStyle);
|
||||
UpdateFocusRing(list, lclListBox.BorderStyle);
|
||||
|
||||
Result := TLCLIntfHandle(scroll);
|
||||
end;
|
||||
@ -2198,6 +2203,7 @@ begin
|
||||
if not Assigned(list) then Exit;
|
||||
|
||||
ScrollViewSetBorderStyle(list.enclosingScrollView, ABorderStyle);
|
||||
UpdateFocusRing(list, ABorderStyle);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
|
||||
|
@ -2,7 +2,6 @@ The following people have been providing a financial support for Cocoa developme
|
||||
|
||||
Active (in alphabetical order):
|
||||
Alexey Torgashin
|
||||
Andrew Fox
|
||||
Christopher Rorden
|
||||
Dan Star
|
||||
Daniele Ponteggia
|
||||
@ -12,9 +11,14 @@ Active (in alphabetical order):
|
||||
Jonas Maebe
|
||||
Marc Hanisch
|
||||
Marcus Fernstrom
|
||||
Max Terentiev
|
||||
Siegfried Rohdewald
|
||||
Sergey
|
||||
Siegfried Rohdewald
|
||||
Tobias Giesen
|
||||
Trevor Roydhouse
|
||||
|
||||
Former:
|
||||
Andrea Mauri
|
||||
Mike Margerum
|
||||
Mike Margerum
|
||||
Andrew Fox
|
||||
|
Loading…
Reference in New Issue
Block a user