mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 14:40:25 +02:00
Cocoa: Standardize and Simplify NS constants, Merge branch 'cocoa/const'
This commit is contained in:
parent
57f76d3946
commit
851cd68564
@ -5,7 +5,7 @@ uses
|
|||||||
agl{%H-},
|
agl{%H-},
|
||||||
cocoa_extra{%H-},
|
cocoa_extra{%H-},
|
||||||
cocoacaret{%H-},
|
cocoacaret{%H-},
|
||||||
cocoaconfig{%H-},
|
cocoaconst{%H-},
|
||||||
cocoacursor{%H-},
|
cocoacursor{%H-},
|
||||||
cocoagdiobjects{%H-},
|
cocoagdiobjects{%H-},
|
||||||
cocoaint{%H-},
|
cocoaint{%H-},
|
||||||
|
@ -48,6 +48,20 @@ const // NSImageScaling values
|
|||||||
NSImageScaleNone = 2;
|
NSImageScaleNone = 2;
|
||||||
NSImageScaleProportionallyUpOrDown = 3;
|
NSImageScaleProportionallyUpOrDown = 3;
|
||||||
|
|
||||||
|
type
|
||||||
|
NSPasteboardType = NSString;
|
||||||
|
var
|
||||||
|
NSPasteboardTypeString: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypePNG: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeTIFF: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypePDF: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeHTML: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeRTF: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeColor: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeFont: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeRuler: NSPasteboardType; cvar; external;
|
||||||
|
NSPasteboardTypeSound: NSPasteboardType; cvar; external;
|
||||||
|
|
||||||
type
|
type
|
||||||
NSMenuFix = objccategory external (NSMenu)
|
NSMenuFix = objccategory external (NSMenu)
|
||||||
function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:';
|
function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:';
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
unit CocoaConfig;
|
|
||||||
|
|
||||||
{$mode ObjFPC}{$H+}
|
|
||||||
{$modeswitch objectivec1}
|
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
end.
|
|
||||||
|
|
169
lcl/interfaces/cocoa/cocoaconst.pas
Normal file
169
lcl/interfaces/cocoa/cocoaconst.pas
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
unit CocoaConst;
|
||||||
|
|
||||||
|
{$mode ObjFPC}{$H+}
|
||||||
|
{$modeswitch objectivec1}
|
||||||
|
|
||||||
|
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;
|
||||||
|
function NSSTR_DARK_NAME_VIBRANT: NSString;
|
||||||
|
|
||||||
|
function NSSTR_LINE_FEED: NSString;
|
||||||
|
function NSSTR_CARRIAGE_RETURN: NSString;
|
||||||
|
function NSSTR_LINE_SEPARATOR: NSString;
|
||||||
|
function NSSTR_PARAGRAPH_SEPARATOR: NSString;
|
||||||
|
|
||||||
|
function NSSTR_KEY_ENTER: NSString;
|
||||||
|
function NSSTR_KEY_ESC: NSString;
|
||||||
|
function NSSTR_KEY_EQUALS: NSString;
|
||||||
|
function NSSTR_KEY_PLUS: NSString;
|
||||||
|
|
||||||
|
function NSSTR_TABCONTROL_PREV_ARROW: NSSTRING;
|
||||||
|
function NSSTR_TABCONTROL_NEXT_ARROW: NSSTRING;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
const
|
||||||
|
DarkName = 'NSAppearanceNameDarkAqua'; // used in 10.14
|
||||||
|
DarkNameVibrant = 'NSAppearanceNameVibrantDark'; // used in 10.13
|
||||||
|
|
||||||
|
var
|
||||||
|
_NSSTR_EMPTY: NSString;
|
||||||
|
|
||||||
|
_NSSTR_DARK_NAME: NSString;
|
||||||
|
_NSSTR_DARK_NAME_VIBRANT: NSString;
|
||||||
|
|
||||||
|
_NSSTR_LINE_FEED: NSString;
|
||||||
|
_NSSTR_CARRIAGE_RETURN: NSString;
|
||||||
|
_NSSTR_LINE_SEPARATOR: NSString;
|
||||||
|
_NSSTR_PARAGRAPH_SEPARATOR: NSString;
|
||||||
|
|
||||||
|
_NSSTR_KEY_ENTER: NSString;
|
||||||
|
_NSSTR_KEY_ESC: NSString;
|
||||||
|
_NSSTR_KEY_EQUALS: NSString;
|
||||||
|
_NSSTR_KEY_PLUS: NSString;
|
||||||
|
|
||||||
|
_NSSTR_TABCONTROL_PREV_ARROW: NSSTRING;
|
||||||
|
_NSSTR_TABCONTROL_NEXT_ARROW: NSSTRING;
|
||||||
|
|
||||||
|
function NSSTR_EMPTY: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_EMPTY;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_DARK_NAME: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_DARK_NAME;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_DARK_NAME_VIBRANT: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_DARK_NAME_VIBRANT;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function NSSTR_LINE_FEED: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_LINE_FEED;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_CARRIAGE_RETURN: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_CARRIAGE_RETURN;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_LINE_SEPARATOR: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_LINE_SEPARATOR;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_PARAGRAPH_SEPARATOR: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_PARAGRAPH_SEPARATOR;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function NSSTR_KEY_ENTER: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_KEY_ENTER;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_KEY_ESC: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_KEY_ESC;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_KEY_EQUALS: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_KEY_EQUALS;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_KEY_PLUS: NSString;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_KEY_PLUS;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function NSSTR_TABCONTROL_PREV_ARROW: NSSTRING;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_TABCONTROL_PREV_ARROW;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSTR_TABCONTROL_NEXT_ARROW: NSSTRING;
|
||||||
|
begin
|
||||||
|
Result:= _NSSTR_TABCONTROL_NEXT_ARROW;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
initialization
|
||||||
|
_NSSTR_EMPTY:= NSString.string_;
|
||||||
|
|
||||||
|
_NSSTR_DARK_NAME:= NSSTR(DarkName);
|
||||||
|
_NSSTR_DARK_NAME_VIBRANT:= NSSTR(DarkNameVibrant);
|
||||||
|
|
||||||
|
_NSSTR_LINE_FEED:= NSSTR(#10);
|
||||||
|
_NSSTR_CARRIAGE_RETURN:= NSSTR(#13);
|
||||||
|
_NSSTR_LINE_SEPARATOR:= NSString.alloc.initWithUTF8String(#$E2#$80#$A8);
|
||||||
|
_NSSTR_PARAGRAPH_SEPARATOR:= NSString.alloc.initWithUTF8String(#$E2#$80#$A9);
|
||||||
|
|
||||||
|
_NSSTR_KEY_ENTER:= NSSTR(#13);
|
||||||
|
_NSSTR_KEY_ESC:= NSSTR(#27);
|
||||||
|
_NSSTR_KEY_EQUALS:= NSSTR('=');
|
||||||
|
_NSSTR_KEY_PLUS:= NSSTR('+');
|
||||||
|
|
||||||
|
_NSSTR_TABCONTROL_PREV_ARROW:= NSString.alloc.initWithUTF8String('◀');
|
||||||
|
_NSSTR_TABCONTROL_NEXT_ARROW:= NSString.alloc.initWithUTF8String('▶');
|
||||||
|
|
||||||
|
finalization;
|
||||||
|
_NSSTR_LINE_SEPARATOR.release;
|
||||||
|
_NSSTR_PARAGRAPH_SEPARATOR.release;
|
||||||
|
|
||||||
|
_NSSTR_TABCONTROL_PREV_ARROW.release;
|
||||||
|
_NSSTR_TABCONTROL_NEXT_ARROW.release;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@ -33,7 +33,7 @@ uses
|
|||||||
// darwin bindings
|
// darwin bindings
|
||||||
MacOSAll,
|
MacOSAll,
|
||||||
// private
|
// private
|
||||||
CocoaAll, CocoaConfig, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaCursor,
|
CocoaAll, CocoaConst, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaCursor,
|
||||||
cocoa_extra, CocoaMenus, CocoaWindows, CocoaScrollers,
|
cocoa_extra, CocoaMenus, CocoaWindows, CocoaScrollers,
|
||||||
CocoaWSClipboard, CocoaTextEdits,
|
CocoaWSClipboard, CocoaTextEdits,
|
||||||
// LCL
|
// LCL
|
||||||
|
@ -290,16 +290,16 @@ begin
|
|||||||
aButton.setKeyEquivalentModifierMask(0);
|
aButton.setKeyEquivalentModifierMask(0);
|
||||||
|
|
||||||
if I = DefaultIndex then
|
if I = DefaultIndex then
|
||||||
aButton.setKeyEquivalent(NSSTR(#13))
|
aButton.setKeyEquivalent(NSSTR_KEY_ENTER)
|
||||||
else if I = 0 then
|
else if I = 0 then
|
||||||
// By default, the first button is the default button. If in our
|
// By default, the first button is the default button. If in our
|
||||||
// case this should not be the case, remove the default status
|
// case this should not be the case, remove the default status
|
||||||
// from the first button.
|
// from the first button.
|
||||||
aButton.setKeyEquivalent(NSSTR(''));
|
aButton.setKeyEquivalent(NSSTR_EMPTY);
|
||||||
|
|
||||||
if Buttons[I]=mrCancel then begin
|
if Buttons[I]=mrCancel then begin
|
||||||
needsCancel := False;
|
needsCancel := False;
|
||||||
aButton.setKeyEquivalent(NSSTR(#27));
|
aButton.setKeyEquivalent(NSSTR_KEY_ESC);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
aButton.setTag(Buttons[I]);
|
aButton.setTag(Buttons[I]);
|
||||||
|
@ -12,7 +12,7 @@ uses
|
|||||||
// LCL
|
// LCL
|
||||||
Forms, Menus, LCLType, Classes, LCLStrConsts,
|
Forms, Menus, LCLType, Classes, LCLStrConsts,
|
||||||
// LCL Cocoa
|
// LCL Cocoa
|
||||||
CocoaAll, CocoaPrivate, CocoaUtils;
|
CocoaAll, CocoaPrivate, CocoaUtils, CocoaConst;
|
||||||
|
|
||||||
type
|
type
|
||||||
IMenuItemCallback = interface(ICommonCallBack)
|
IMenuItemCallback = interface(ICommonCallBack)
|
||||||
@ -144,9 +144,9 @@ begin
|
|||||||
// as a key , +/= is a rare case, both + and = are used as primary keys.
|
// as a key , +/= is a rare case, both + and = are used as primary keys.
|
||||||
// ‘Shift+=’ for ‘+’
|
// ‘Shift+=’ for ‘+’
|
||||||
// ‘=’ for ‘='
|
// ‘=’ for ‘='
|
||||||
if key.isEqualToString(NSSTR('+')) then begin
|
if key.isEqualToString(NSSTR_KEY_PLUS) then begin
|
||||||
if (ShiftKeyMask and NSShiftKeyMask)=0 then
|
if (ShiftKeyMask and NSShiftKeyMask)=0 then
|
||||||
key := NSStr('=')
|
key := NSSTR_KEY_EQUALS
|
||||||
else
|
else
|
||||||
ShiftKeyMask := ShiftKeyMask - NSShiftKeyMask;
|
ShiftKeyMask := ShiftKeyMask - NSShiftKeyMask;
|
||||||
end;
|
end;
|
||||||
|
@ -26,7 +26,7 @@ uses
|
|||||||
// rtl+ftl
|
// rtl+ftl
|
||||||
Types, Classes, SysUtils,
|
Types, Classes, SysUtils,
|
||||||
// Libs
|
// Libs
|
||||||
MacOSAll, CocoaAll, CocoaUtils, CocoaPrivate;
|
MacOSAll, CocoaAll, CocoaUtils, CocoaPrivate, CocoaConst;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -189,9 +189,9 @@ begin
|
|||||||
btn.setButtonType(NSMomentaryLightButton);
|
btn.setButtonType(NSMomentaryLightButton);
|
||||||
|
|
||||||
if isPrev then
|
if isPrev then
|
||||||
btn.setTitle( StrToNSString('◀') )
|
btn.setTitle( NSSTR_TABCONTROL_PREV_ARROW )
|
||||||
else
|
else
|
||||||
btn.setTitle( StrToNSString('▶') );
|
btn.setTitle( NSSTR_TABCONTROL_NEXT_ARROW );
|
||||||
|
|
||||||
{$ifdef BOOLFIX}
|
{$ifdef BOOLFIX}
|
||||||
btn.setBordered_(Ord(false));
|
btn.setBordered_(Ord(false));
|
||||||
|
@ -29,7 +29,7 @@ uses
|
|||||||
Types, Classes, SysUtils,
|
Types, Classes, SysUtils,
|
||||||
// Libs
|
// Libs
|
||||||
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
||||||
cocoa_extra, CocoaPrivate,
|
cocoa_extra, CocoaPrivate, CocoaConst,
|
||||||
// LCL
|
// LCL
|
||||||
LCLType;
|
LCLType;
|
||||||
|
|
||||||
@ -924,7 +924,7 @@ begin
|
|||||||
if not isFirstColumnCheckboxes and isImagesInCell then begin
|
if not isFirstColumnCheckboxes and isImagesInCell then begin
|
||||||
img := lclGetItemImageAt(row, col);
|
img := lclGetItemImageAt(row, col);
|
||||||
|
|
||||||
Result := NSImageAndTextCell(NSImageAndTextCell.alloc).initTextCell(NSSTR(''));
|
Result := NSImageAndTextCell(NSImageAndTextCell.alloc).initTextCell(NSSTR_EMPTY);
|
||||||
NSImageAndTextCell(Result).drawImage := img; // if "image" is assigned, text won't be drawn :(
|
NSImageAndTextCell(Result).drawImage := img; // if "image" is assigned, text won't be drawn :(
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
@ -22,7 +22,7 @@ uses
|
|||||||
LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
|
LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
|
||||||
customdrawndrawers,
|
customdrawndrawers,
|
||||||
// widgetset
|
// widgetset
|
||||||
CocoaUtils, CocoaGDIObjects;
|
CocoaUtils, CocoaGDIObjects, CocoaConst;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TCocoaThemeServices }
|
{ TCocoaThemeServices }
|
||||||
@ -266,7 +266,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if (HdrCell=nil) then
|
if (HdrCell=nil) then
|
||||||
begin
|
begin
|
||||||
hdrCell := NSTableHeaderCell.alloc.initTextCell(NSSTR(''));
|
hdrCell := NSTableHeaderCell.alloc.initTextCell(NSSTR_EMPTY);
|
||||||
end;
|
end;
|
||||||
CellDrawStart(DC, R, cur, nsr);
|
CellDrawStart(DC, R, cur, nsr);
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
if cocoaBtn < 0 then Exit; // unsupported button type
|
if cocoaBtn < 0 then Exit; // unsupported button type
|
||||||
|
|
||||||
btn := NSButtonCell(NSButtonCell.alloc).initTextCell(NSSTR(''));
|
btn := NSButtonCell(NSButtonCell.alloc).initTextCell(NSSTR_EMPTY);
|
||||||
btn.setButtonType(NSButtonType(cocoaBtn));
|
btn.setButtonType(NSButtonType(cocoaBtn));
|
||||||
|
|
||||||
SetButtonCellToDetails(btn, Details);
|
SetButtonCellToDetails(btn, Details);
|
||||||
@ -542,7 +542,7 @@ end;
|
|||||||
constructor TCocoaThemeServices.Create;
|
constructor TCocoaThemeServices.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
BtnCell := NSButtonCell.alloc.initTextCell(NSSTR(''));
|
BtnCell := NSButtonCell.alloc.initTextCell(NSSTR_EMPTY);
|
||||||
BezelToolBar := NSSmallSquareBezelStyle; // can be resized at any size
|
BezelToolBar := NSSmallSquareBezelStyle; // can be resized at any size
|
||||||
BezelButton := NSSmallSquareBezelStyle;
|
BezelButton := NSSmallSquareBezelStyle;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
classes,
|
classes,
|
||||||
MacOSAll, CocoaAll, Cocoa_Extra,
|
MacOSAll, CocoaAll, Cocoa_Extra, CocoaConst,
|
||||||
SysUtils, Types, LCLType, LCLProc,
|
SysUtils, Types, LCLType, LCLProc,
|
||||||
Graphics, GraphType;
|
Graphics, GraphType;
|
||||||
|
|
||||||
@ -154,20 +154,8 @@ function NSEventRawKeyChar(ev: NSEvent): System.WideChar;
|
|||||||
function AllocImageRotatedByDegrees(src: NSImage; degrees: double): NSImage;
|
function AllocImageRotatedByDegrees(src: NSImage; degrees: double): NSImage;
|
||||||
function AllocCursorFromCursorByDegrees(src: NSCursor; degrees: double): NSCursor;
|
function AllocCursorFromCursorByDegrees(src: NSCursor; degrees: double): NSCursor;
|
||||||
|
|
||||||
var
|
|
||||||
NSSTR_DARK_NAME: NSString;
|
|
||||||
NSSTR_DARK_NAME_VIBRANT: NSString;
|
|
||||||
NSSTR_LINE_FEED: NSString;
|
|
||||||
NSSTR_CARRIAGE_RETURN: NSString;
|
|
||||||
NSSTR_LINE_SEPARATOR: NSString;
|
|
||||||
NSSTR_PARAGRAPH_SEPARATOR: NSString;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
|
||||||
DarkName = 'NSAppearanceNameDarkAqua'; // used in 10.14
|
|
||||||
DarkNameVibrant = 'NSAppearanceNameVibrantDark'; // used in 10.13
|
|
||||||
|
|
||||||
procedure ApplicationWillShowModal;
|
procedure ApplicationWillShowModal;
|
||||||
begin
|
begin
|
||||||
// Any place that would attempt to use Cocoa-native modality.
|
// Any place that would attempt to use Cocoa-native modality.
|
||||||
@ -1361,18 +1349,5 @@ begin
|
|||||||
img.release;
|
img.release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
NSSTR_DARK_NAME:= NSSTR(DarkName);
|
|
||||||
NSSTR_DARK_NAME_VIBRANT:= NSSTR(DarkNameVibrant);
|
|
||||||
NSSTR_LINE_FEED:= NSStr(#10);
|
|
||||||
NSSTR_CARRIAGE_RETURN:= NSStr(#13);
|
|
||||||
NSSTR_LINE_SEPARATOR:= StrToNSString(#$E2#$80#$A8, false);
|
|
||||||
NSSTR_PARAGRAPH_SEPARATOR:= StrToNSString(#$E2#$80#$A9, false);
|
|
||||||
|
|
||||||
finalization;
|
|
||||||
NSSTR_LINE_SEPARATOR.release;
|
|
||||||
NSSTR_PARAGRAPH_SEPARATOR.release;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ uses
|
|||||||
// fcl-image
|
// fcl-image
|
||||||
,fpreadpng, fpwritepng, fpimage, fpreadbmp, fpwritebmp
|
,fpreadpng, fpwritepng, fpimage, fpreadbmp, fpwritebmp
|
||||||
,LCLType
|
,LCLType
|
||||||
,CocoaUtils;
|
,CocoaUtils, Cocoa_Extra;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCocoaClipboardDataType = (ccdtText,
|
TCocoaClipboardDataType = (ccdtText,
|
||||||
@ -81,22 +81,8 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
const
|
|
||||||
// these constants are available starting MacOSX 10.6
|
|
||||||
// thus for earlier systems must be redeclared
|
|
||||||
_NSPasteboardTypeString : NSString = nil;
|
|
||||||
_NSPasteboardTypePNG : NSString = nil;
|
|
||||||
_NSPasteboardTypeTiff : NSString = nil;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure InitConst;
|
|
||||||
begin
|
|
||||||
_NSPasteboardTypeString := NSSTR('public.utf8-plain-text');
|
|
||||||
_NSPasteboardTypePNG := NSSTR('public.png');
|
|
||||||
_NSPasteboardTypeTiff := NSSTR('public.tiff');
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCocoaWSClipboard }
|
{ TCocoaWSClipboard }
|
||||||
|
|
||||||
constructor TCocoaWSClipboard.Create;
|
constructor TCocoaWSClipboard.Create;
|
||||||
@ -433,20 +419,17 @@ begin
|
|||||||
case AMimeType of
|
case AMimeType of
|
||||||
'text/plain':
|
'text/plain':
|
||||||
begin
|
begin
|
||||||
//hack: the name of constants is a hack
|
lNSStr := NSPasteboardTypeString;
|
||||||
// should be replaced with either weaklinking
|
|
||||||
// or dynamic loading (dlsym)
|
|
||||||
lNSStr := NSSTR('public.utf8-plain-text'); // NSPasteboardTypeString; // commented out for OSX < 10.6 see #33672
|
|
||||||
lDataType := ccdtText;
|
lDataType := ccdtText;
|
||||||
end;
|
end;
|
||||||
'image/png':
|
'image/png':
|
||||||
begin
|
begin
|
||||||
lNSStr := NSSTR('public.png'); // NSPasteboardTypePNG
|
lNSStr := NSPasteboardTypePNG;
|
||||||
lDataType := ccdtCocoaStandard;
|
lDataType := ccdtCocoaStandard;
|
||||||
end;
|
end;
|
||||||
'image/bmp':
|
'image/bmp':
|
||||||
begin
|
begin
|
||||||
lNSStr := NSSTR('public.png'); // NSPasteboardTypePNG
|
lNSStr := NSPasteboardTypePNG;
|
||||||
lDataType := ccdtBitmap;
|
lDataType := ccdtBitmap;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -470,7 +453,7 @@ end;
|
|||||||
function TCocoaWSClipboard.CocoaTypeToMimeType(AType: NSString): string;
|
function TCocoaWSClipboard.CocoaTypeToMimeType(AType: NSString): string;
|
||||||
begin
|
begin
|
||||||
// "default" types must be mapped to a default LCL mime-type
|
// "default" types must be mapped to a default LCL mime-type
|
||||||
if AType.isEqualToString(_NSPasteboardTypeString) then
|
if AType.isEqualToString(NSPasteboardTypeString) then
|
||||||
Result := 'text/plain'
|
Result := 'text/plain'
|
||||||
else
|
else
|
||||||
Result := NSStringToString(AType);
|
Result := NSStringToString(AType);
|
||||||
@ -490,8 +473,4 @@ begin
|
|||||||
CocoaFormat.release;
|
CocoaFormat.release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
|
||||||
InitConst;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -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, CocoaConfig, CocoaPrivate, CocoaUtils,
|
CocoaAll, CocoaInt, CocoaConst, CocoaPrivate, CocoaUtils,
|
||||||
CocoaGDIObjects, CocoaCursor, CocoaCaret, CocoaScrollers, cocoa_extra;
|
CocoaGDIObjects, CocoaCursor, CocoaCaret, CocoaScrollers, cocoa_extra;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -30,7 +30,7 @@ uses
|
|||||||
// Widgetset
|
// Widgetset
|
||||||
WSForms, WSLCLClasses, LCLMessageGlue,
|
WSForms, WSLCLClasses, LCLMessageGlue,
|
||||||
// LCL Cocoa
|
// LCL Cocoa
|
||||||
CocoaInt, CocoaConfig, CocoaPrivate, CocoaUtils, CocoaWSCommon, CocoaMenus,
|
CocoaInt, CocoaConst, 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 CocoaConfig.CocoaIconUse then
|
if not CocoaConst.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 CocoaConfig.CocoaIconUse then Exit;
|
if CocoaConst.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;
|
||||||
|
@ -33,7 +33,7 @@ uses
|
|||||||
// Widgetset
|
// Widgetset
|
||||||
WSStdCtrls, WSLCLClasses,
|
WSStdCtrls, WSLCLClasses,
|
||||||
// LCL Cocoa
|
// LCL Cocoa
|
||||||
CocoaConfig, CocoaWSCommon, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaButtons,
|
CocoaConst, CocoaWSCommon, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaButtons,
|
||||||
CocoaTables, CocoaTextEdits, CocoaScrollers, Cocoa_Extra;
|
CocoaTables, CocoaTextEdits, CocoaScrollers, Cocoa_Extra;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -1432,8 +1432,6 @@ var
|
|||||||
ns : NSString;
|
ns : NSString;
|
||||||
idx : integer;
|
idx : integer;
|
||||||
ro : Boolean;
|
ro : Boolean;
|
||||||
const
|
|
||||||
LFSTR = #10;
|
|
||||||
begin
|
begin
|
||||||
ns:=FTextView.string_;
|
ns:=FTextView.string_;
|
||||||
idx:=0;
|
idx:=0;
|
||||||
@ -1455,7 +1453,7 @@ begin
|
|||||||
FTextView.setSelectedRange(rng);
|
FTextView.setSelectedRange(rng);
|
||||||
|
|
||||||
if (rng.location>=ns.length) and (st=ced) and (ns.length>0) then
|
if (rng.location>=ns.length) and (st=ced) and (ns.length>0) then
|
||||||
FTextView.insertText( NSString.stringWithUTF8String( LFSTR ));
|
FTextView.insertText( NSSTR_LINE_FEED );
|
||||||
|
|
||||||
if S<>'' then
|
if S<>'' then
|
||||||
begin
|
begin
|
||||||
@ -1463,7 +1461,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
dec(FTextView.supressTextChangeEvent);
|
dec(FTextView.supressTextChangeEvent);
|
||||||
FTextView.insertText( NSString.stringWithUTF8String( LFSTR ));
|
FTextView.insertText( NSSTR_LINE_FEED );
|
||||||
|
|
||||||
if not ro then FTextView.setEditable(ro);
|
if not ro then FTextView.setEditable(ro);
|
||||||
|
|
||||||
|
@ -2614,9 +2614,9 @@ end;"/>
|
|||||||
<UnitName Value="AllLCLIntfUnits"/>
|
<UnitName Value="AllLCLIntfUnits"/>
|
||||||
</Item529>
|
</Item529>
|
||||||
<Item530>
|
<Item530>
|
||||||
<Filename Value="cocoa/cocoaconfig.pas"/>
|
<Filename Value="cocoa/cocoaconst.pas"/>
|
||||||
<AddToUsesPkgSection Value="False"/>
|
<AddToUsesPkgSection Value="False"/>
|
||||||
<UnitName Value="CocoaConfig"/>
|
<UnitName Value="CocoaConst"/>
|
||||||
</Item530>
|
</Item530>
|
||||||
<Item531>
|
<Item531>
|
||||||
<Filename Value="cocoa/cocoacursor.pas"/>
|
<Filename Value="cocoa/cocoacursor.pas"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user