mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:39:25 +02:00
cocoa: Implements Application.OnDropFiles
git-svn-id: trunk@49727 -
This commit is contained in:
parent
fdde7f3583
commit
bec0723351
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6960,6 +6960,7 @@ lcl/interfaces/cocoa/Makefile svneol=native#text/plain
|
|||||||
lcl/interfaces/cocoa/Makefile.compiled svneol=native#text/plain
|
lcl/interfaces/cocoa/Makefile.compiled svneol=native#text/plain
|
||||||
lcl/interfaces/cocoa/Makefile.fpc svneol=native#text/plain
|
lcl/interfaces/cocoa/Makefile.fpc svneol=native#text/plain
|
||||||
lcl/interfaces/cocoa/alllclintfunits.pas svneol=native#text/plain
|
lcl/interfaces/cocoa/alllclintfunits.pas svneol=native#text/plain
|
||||||
|
lcl/interfaces/cocoa/cocoa_extra.pas svneol=native#text/plain
|
||||||
lcl/interfaces/cocoa/cocoacaret.pas svneol=native#text/pascal
|
lcl/interfaces/cocoa/cocoacaret.pas svneol=native#text/pascal
|
||||||
lcl/interfaces/cocoa/cocoagdiobjects.pas svneol=native#text/plain
|
lcl/interfaces/cocoa/cocoagdiobjects.pas svneol=native#text/plain
|
||||||
lcl/interfaces/cocoa/cocoaint.pas svneol=native#text/plain
|
lcl/interfaces/cocoa/cocoaint.pas svneol=native#text/plain
|
||||||
|
61
lcl/interfaces/cocoa/cocoa_extra.pas
Normal file
61
lcl/interfaces/cocoa/cocoa_extra.pas
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{ $Id: $}
|
||||||
|
{ --------------------------------------------
|
||||||
|
cocoa_extra.pp - Cocoa headers not available in FPC
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
This unit contains Cocoa headers which are not yet available in the latest FPC release
|
||||||
|
|
||||||
|
*****************************************************************************
|
||||||
|
This file is part of the Lazarus Component Library (LCL)
|
||||||
|
|
||||||
|
See the file COPYING.modifiedLGPL.txt, included in this distribution,
|
||||||
|
for details about the license.
|
||||||
|
*****************************************************************************
|
||||||
|
}
|
||||||
|
unit cocoa_extra;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
{$modeswitch objectivec1}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
// rtl+ftl
|
||||||
|
Types, Classes, SysUtils,
|
||||||
|
CGGeometry,
|
||||||
|
// Libs
|
||||||
|
MacOSAll, CocoaAll;
|
||||||
|
|
||||||
|
type
|
||||||
|
NSViewFix = objccategory external (NSView)
|
||||||
|
function fittingSize: NSSize; message 'fittingSize';
|
||||||
|
end;
|
||||||
|
|
||||||
|
NSButtonSoundExtensionsCategory = objccategory external (NSButton)
|
||||||
|
function intrinsicContentSize(): NSSize; message 'intrinsicContentSize';
|
||||||
|
end;
|
||||||
|
|
||||||
|
// The following dummy categories fix bugs in the Cocoa bindings available in FPC
|
||||||
|
// Remove them when the FPC binding parser is fixed.
|
||||||
|
// More details:
|
||||||
|
// http://wiki.freepascal.org/FPC_PasCocoa/Differences#Sending_messages_to_id
|
||||||
|
// http://wiki.lazarus.freepascal.org/FPC_PasCocoa#Category_declaration
|
||||||
|
NSBitmapImageRepFix = objccategory external(NSBitmapImageRep)
|
||||||
|
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:';
|
||||||
|
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; bitmapFormat_: NSBitmapFormat; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:';
|
||||||
|
end;
|
||||||
|
|
||||||
|
NSGraphicsContextFix = objccategory external(NSGraphicsContext)
|
||||||
|
procedure setImageInterpolation(interpolation: NSImageInterpolation); message 'setImageInterpolation:';
|
||||||
|
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
||||||
|
end;
|
||||||
|
|
||||||
|
{// private since 10.5, doesn't seam to do anything in 10.10
|
||||||
|
NSApplicationSetAppleMenu = objccategory external(NSApplication)
|
||||||
|
procedure setAppleMenu(AMenu: NSMenu); message 'setAppleMenu:';
|
||||||
|
end;}
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@ -11,6 +11,7 @@ uses
|
|||||||
MacOSAll, // for CGContextRef
|
MacOSAll, // for CGContextRef
|
||||||
LCLtype, LCLProc, Graphics, Controls, fpcanvas,
|
LCLtype, LCLProc, Graphics, Controls, fpcanvas,
|
||||||
CocoaAll, CocoaProc, CocoaUtils,
|
CocoaAll, CocoaProc, CocoaUtils,
|
||||||
|
cocoa_extra,
|
||||||
{$ifndef CocoaUseHITheme}
|
{$ifndef CocoaUseHITheme}
|
||||||
customdrawndrawers, customdrawn_mac,
|
customdrawndrawers, customdrawn_mac,
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -513,24 +514,6 @@ begin
|
|||||||
Result:=(p1.x=p2.x) and (p1.y=p2.y);
|
Result:=(p1.x=p2.x) and (p1.y=p2.y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaBitmap }
|
|
||||||
|
|
||||||
type
|
|
||||||
// The following dummy categories fix bugs in the Cocoa bindings available in FPC
|
|
||||||
// Remove them when the FPC binding parser is fixed.
|
|
||||||
// More details:
|
|
||||||
// http://wiki.freepascal.org/FPC_PasCocoa/Differences#Sending_messages_to_id
|
|
||||||
// http://wiki.lazarus.freepascal.org/FPC_PasCocoa#Category_declaration
|
|
||||||
NSBitmapImageRepFix = objccategory external(NSBitmapImageRep)
|
|
||||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:';
|
|
||||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; bitmapFormat_: NSBitmapFormat; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:';
|
|
||||||
end;
|
|
||||||
|
|
||||||
NSGraphicsContextFix = objccategory external(NSGraphicsContext)
|
|
||||||
procedure setImageInterpolation(interpolation: NSImageInterpolation); message 'setImageInterpolation:';
|
|
||||||
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCocoaFont }
|
{ TCocoaFont }
|
||||||
|
|
||||||
constructor TCocoaFont.CreateDefault(AGlobal: Boolean = False);
|
constructor TCocoaFont.CreateDefault(AGlobal: Boolean = False);
|
||||||
|
@ -33,7 +33,7 @@ uses
|
|||||||
InterfaceBase, GraphType,
|
InterfaceBase, GraphType,
|
||||||
// private
|
// private
|
||||||
CocoaAll, CocoaPrivate, CocoaUtils, CocoaGDIObjects,
|
CocoaAll, CocoaPrivate, CocoaUtils, CocoaGDIObjects,
|
||||||
CocoaProc,
|
CocoaProc, cocoa_extra,
|
||||||
// LCL
|
// LCL
|
||||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||||
Controls, Forms, Themes, Menus,
|
Controls, Forms, Themes, Menus,
|
||||||
@ -59,10 +59,9 @@ type
|
|||||||
constructor Create(AMimeType: string; ACocoaFormat: NSString; ADataType: TCocoaClipboardDataType);
|
constructor Create(AMimeType: string; ACocoaFormat: NSString; ADataType: TCocoaClipboardDataType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{// private since 10.5, doesn't seam to do anything in 10.10
|
TAppDelegate = objcclass(NSObject, NSApplicationDelegateProtocol)
|
||||||
NSApplicationSetAppleMenu = objccategory external(NSApplication)
|
procedure application_openFiles(sender: NSApplication; filenames: NSArray);
|
||||||
procedure setAppleMenu(AMenu: NSMenu); message 'setAppleMenu:';
|
end;
|
||||||
end;}
|
|
||||||
|
|
||||||
{ TCocoaWidgetSet }
|
{ TCocoaWidgetSet }
|
||||||
|
|
||||||
@ -70,6 +69,7 @@ type
|
|||||||
private
|
private
|
||||||
FTerminating: Boolean;
|
FTerminating: Boolean;
|
||||||
FNSApp: NSApplication;
|
FNSApp: NSApplication;
|
||||||
|
FNSApp_Delegate: TAppDelegate;
|
||||||
FCurrentCursor: HCursor;
|
FCurrentCursor: HCursor;
|
||||||
FCaptureControl: HWND;
|
FCaptureControl: HWND;
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{ Creates the application NSApp object }
|
{ Creates the application NSApp object }
|
||||||
FNsApp := NSApplication.sharedApplication;
|
FNSApp := NSApplication.sharedApplication;
|
||||||
|
FNSApp_Delegate := TAppDelegate.alloc.init;
|
||||||
|
FNSApp.setDelegate(FNSApp_Delegate);
|
||||||
|
|
||||||
// Sandboxing
|
// Sandboxing
|
||||||
lDict := NSProcessInfo.processInfo.environment;
|
lDict := NSProcessInfo.processInfo.environment;
|
||||||
@ -537,6 +539,21 @@ begin
|
|||||||
DataType := ADataType;
|
DataType := ADataType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAppDelegate.application_openFiles(sender: NSApplication; filenames: NSArray);
|
||||||
|
var
|
||||||
|
lFiles: array of string;
|
||||||
|
lNSStr: NSString;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
SetLength(lFiles, filenames.count);
|
||||||
|
for i := 0 to filenames.count-1 do
|
||||||
|
begin
|
||||||
|
lNSStr := NSString(filenames.objectAtIndex(i));
|
||||||
|
lFiles[i] := NSStringToString(lNSStr);
|
||||||
|
end;
|
||||||
|
Application.IntfDropFiles(lFiles);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCocoaWidgetSet.RawImage_DescriptionFromCocoaBitmap
|
Method: TCocoaWidgetSet.RawImage_DescriptionFromCocoaBitmap
|
||||||
|
|
||||||
|
@ -27,8 +27,9 @@ uses
|
|||||||
Classes, Controls, Buttons, LCLType, LCLProc, Graphics, GraphType,
|
Classes, Controls, Buttons, LCLType, LCLProc, Graphics, GraphType,
|
||||||
// widgetset
|
// widgetset
|
||||||
WSButtons, WSLCLClasses, WSProc,
|
WSButtons, WSLCLClasses, WSProc,
|
||||||
// LCL Carbon
|
// LCL Cocoa
|
||||||
CocoaWSCommon, CocoaWSStdCtrls, CocoaGDIObjects, CocoaPrivate, CocoaUtils;
|
CocoaWSCommon, CocoaWSStdCtrls, CocoaGDIObjects, CocoaPrivate, CocoaUtils,
|
||||||
|
cocoa_extra;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -88,11 +89,6 @@ begin
|
|||||||
Result := TLCLIntfHandle(btn);
|
Result := TLCLIntfHandle(btn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
|
||||||
NSButtonSoundExtensionsCategory = objccategory external (NSButton)
|
|
||||||
function intrinsicContentSize(): NSSize; message 'intrinsicContentSize';
|
|
||||||
end;
|
|
||||||
|
|
||||||
class procedure TCocoaWSBitBtn.GetPreferredSize(const AWinControl: TWinControl;
|
class procedure TCocoaWSBitBtn.GetPreferredSize(const AWinControl: TWinControl;
|
||||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user