Cocoa: move config variables from CocoaConst into CocoaConfig

This commit is contained in:
rich2014 2023-12-05 22:05:07 +08:00
parent c30ea41562
commit f5f015df7a
7 changed files with 47 additions and 27 deletions

View File

@ -0,0 +1,33 @@
unit CocoaConfig;
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
interface
uses
CocoaAll;
var
CocoaBasePPI : Integer = 96; // for compatiblity with LCL 1.8 release. The macOS base is 72ppi
// if set to true, then WS would not assign icons via TCocoaWSForm SetIcon
// The icon would have to be changed manually. By default LCL behaviour is used
CocoaIconUse: Boolean = false;
CocoaToggleBezel : NSBezelStyle = NSRoundedBezelStyle;
CocoaToggleType : NSButtonType = NSPushOnPushOffButton;
CocoaHideFocusNoBorder : Boolean = true;
CocoaUseLocalizedFontName : Boolean = false; // some localized named might be too long to be returned properly by APIs
{$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
LoopHiJackEnded : Boolean = false;
{$endif}
implementation
end.

View File

@ -8,25 +8,6 @@ interface
uses
CocoaAll;
const
CocoaBasePPI : Integer = 96; // for compatiblity with LCL 1.8 release. The macOS base is 72ppi
// if set to true, then WS would not assign icons via TCocoaWSForm SetIcon
// The icon would have to be changed manually. By default LCL behaviour is used
CocoaIconUse: Boolean = false;
CocoaToggleBezel : NSBezelStyle = NSRoundedBezelStyle;
CocoaToggleType : NSButtonType = NSPushOnPushOffButton;
CocoaHideFocusNoBorder : Boolean = true;
CocoaUseLocalizedFontName : Boolean = false; // some localized named might be too long to be returned properly by APIs
{$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
LoopHiJackEnded : Boolean = false;
{$endif}
function NSSTR_EMPTY: NSString;
function NSSTR_DARK_NAME: NSString;

View File

@ -33,8 +33,8 @@ uses
// darwin bindings
MacOSAll,
// private
CocoaAll, CocoaConst, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaCursor,
cocoa_extra, CocoaMenus, CocoaWindows, CocoaScrollers,
CocoaAll, CocoaConst, CocoaConfig, CocoaPrivate, CocoaUtils, Cocoa_Extra,
CocoaGDIObjects, CocoaCursor, CocoaMenus, CocoaWindows, CocoaScrollers,
CocoaWSClipboard, CocoaTextEdits,
// LCL
LMessages, LCLProc, LCLIntf, LCLType,

View File

@ -10,7 +10,7 @@ interface
uses
Types, Classes, Controls, SysUtils,
WSControls, LCLType, LCLMessageGlue, LMessages, LCLProc, LCLIntf, Graphics, Forms,
CocoaAll, CocoaInt, CocoaConst, CocoaPrivate, CocoaUtils,
CocoaAll, CocoaInt, CocoaConfig, CocoaPrivate, CocoaUtils,
CocoaGDIObjects, CocoaCursor, CocoaCaret, CocoaScrollers, cocoa_extra;
type

View File

@ -30,7 +30,7 @@ uses
// Widgetset
WSForms, WSLCLClasses, LCLMessageGlue,
// LCL Cocoa
CocoaInt, CocoaConst, CocoaPrivate, CocoaUtils, CocoaWSCommon, CocoaMenus,
CocoaInt, CocoaConfig, CocoaPrivate, CocoaUtils, CocoaWSCommon, CocoaMenus,
CocoaGDIObjects,
CocoaWindows, CocoaScrollers, cocoa_extra;
@ -642,7 +642,7 @@ begin
SetWindowButtonState(NSWindowZoomButton, (biMaximize in ABorderIcons) and (ABorderStyle in [bsSizeable, bsSizeToolWin]), (ABorderStyle in [bsSingle, bsSizeable]) and (biSystemMenu in ABorderIcons));
SetWindowButtonState(NSWindowCloseButton, True, (ABorderStyle <> bsNone) and (biSystemMenu in ABorderIcons));
if not CocoaConst.CocoaIconUse then
if not CocoaConfig.CocoaIconUse then
begin
btn := AWindow.standardWindowButton(NSWindowDocumentIconButton);
url := nil;
@ -1048,7 +1048,7 @@ var
trg : NSImage;
btn : NSButton;
begin
if CocoaConst.CocoaIconUse then Exit;
if CocoaConfig.CocoaIconUse then Exit;
if not AForm.HandleAllocated then Exit;
win := TCocoaWindowContent(AForm.Handle).lclOwnWindow;

View File

@ -33,7 +33,8 @@ uses
// Widgetset
WSStdCtrls, WSLCLClasses,
// LCL Cocoa
CocoaConst, CocoaWSCommon, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaButtons,
CocoaConst, CocoaConfig,
CocoaWSCommon, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaButtons,
CocoaTables, CocoaTextEdits, CocoaScrollers, Cocoa_Extra;
type

View File

@ -131,7 +131,7 @@ end;"/>
<License Value="modified LGPL-2
"/>
<Version Major="3" Build="2"/>
<Files Count="533">
<Files Count="534">
<Item1>
<Filename Value="carbon/agl.pp"/>
<AddToUsesPkgSection Value="False"/>
@ -2633,6 +2633,11 @@ end;"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="CocoaWSDatePicker"/>
</Item533>
<Item534>
<Filename Value="cocoa/cocoaconfig.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="cocoaconfig"/>
</Item534>
</Files>
<CompatibilityMode Value="True"/>
<LazDoc Paths="../../docs/xml/lcl"/>