Cocoa: move config variables from CocoaConst into CocoaConfig

This commit is contained in:
rich2014 2023-12-05 22:05:07 +08:00
parent ddc2c4135b
commit 9c48a2501d
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 uses
CocoaAll; 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_EMPTY: NSString;
function NSSTR_DARK_NAME: NSString; function NSSTR_DARK_NAME: NSString;

View File

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

View File

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

View File

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

View File

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

View File

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