1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
{ $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}
{$include cocoadefines.inc}
interface
uses
// rtl+ftl
Types, Classes, SysUtils,
CGGeometry,
// Libs
MacOSAll, CocoaAll;
type
NSImageScaling = NSUInteger;
const // NSImageScaling values
NSImageScaleProportionallyDown = 0;
NSImageScaleAxesIndependently = 1;
NSImageScaleNone = 2;
NSImageScaleProportionallyUpOrDown = 3;
type
NSMenuFix = objccategory external (NSMenu)
function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:';
end;
{$ifdef BOOLFIX}
ObjCBool = ShortInt; // Matches BOOL declaration in ObjC "signed char"
NSMenuItemFix = objccategory external (NSMenuItem)
procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
procedure setHidden_(ahidden: ObjCBool); message 'setHidden:';
end;
NSControlFix = objccategory external (NSControl)
procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
end;
NSStatusItemFix = objccategory external (NSStatusItem)
procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
end;
NSApplicationFix = objccategory external (NSApplication)
procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
function nextEventMatchingMask_untilDate_inMode_dequeue_(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: ObjCBool): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
procedure postEvent_atStart_(event: NSEvent; flag: ObjCBool); message 'postEvent:atStart:';
end;
NSButtonFix = objccategory external(NSButton)
procedure setBordered_(flag: ObjCBool); message 'setBordered:';
procedure setAllowsMixedState_(flag: ObjCBool); message 'setAllowsMixedState:';
end;
NSTextFieldFix = objccategory external(NSTextField)
procedure setDrawsBackground_(flag: ObjCBool); message 'setDrawsBackground:';
procedure setBordered_(flag: ObjCBool); message 'setBordered:';
procedure setBezeled_(flag: ObjCBool); message 'setBezeled:';
procedure setEditable_(flag: ObjCBool); message 'setEditable:';
procedure setSelectable_(flag: ObjCBool); message 'setSelectable:';
end;
{$endif}
NSEdgeInsets = packed record
top : CGFloat;
left : CGFloat;
bottom : CGFloat;
right : CGFloat;
end;
NSViewFix = objccategory external (NSView)
// 10.7+
function fittingSize: NSSize; message 'fittingSize';
function alignmentRectInsets: NSEdgeInsets; message 'alignmentRectInsets';
function alignmentRectForFrame(ns: NSRect): NSRect; message 'alignmentRectForFrame:';
function frameForAlignmentRect(ns: NSRect): NSRect; message 'frameForAlignmentRect:';
{$ifdef BOOLFIX}
procedure setHidden_(flag: ObjCBool); message 'setHidden:';
procedure setAutoresizesSubviews_(flag: ObjCBool); message 'setAutoresizesSubviews:';
procedure setNeedsDisplay__(flag: ObjCBool); message 'setNeedsDisplay:';
{$endif}
end;
NSLayoutConstraint = objcclass external (NSObject)
function isActive: Boolean; message 'isActive';
procedure setActive(Active: Boolean); message 'setActive:';
end;
NSButtonSoundExtensionsCategory = objccategory external (NSButton)
function intrinsicContentSize(): NSSize; message 'intrinsicContentSize';
procedure setImageScaling(aScaling: NSImageScaling); message 'setImageScaling:';
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:';
// 10.10
function CGContext: CGContextRef; message 'CGContext';
end;
NSEventFix = objccategory external (NSEvent)
class function modifierFlags_: NSUInteger; message 'modifierFlags';
end;
NSWindowTabbingMode = NSInteger;
NSWindowFix = objccategory external (NSWindow)
// 10.4-10.7
// userSpaceScaleFactor is declare in the latest CocoaAll
//function userSpaceScaleFactor: CGFloat; message 'userSpaceScaleFactor'; //deprecated
// 10.7+
procedure toggleFullScreen(sender: id); message 'toggleFullScreen:';
function backingScaleFactor: CGFloat; message 'backingScaleFactor';
// 10.12
procedure setTabbingMode(amode: NSWindowTabbingMode); message 'setTabbingMode:';
function tabbingMode: NSWindowTabbingMode; message 'tabbingMode';
class procedure setAllowsAutomaticWindowTabbing(aflag: Boolean); message 'setAllowsAutomaticWindowTabbing:';
class function allowsAutomaticWindowTabbing: Boolean; message 'allowsAutomaticWindowTabbing';
{$ifdef BOOLFIX}
function initWithContentRect_styleMask_backing_defer_(contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: ObjCBool): id; message 'initWithContentRect:styleMask:backing:defer:';
procedure setFrame_display_(frameRect: NSRect; flag: ObjCBool); message 'setFrame:display:';
function fieldEditor_forObject_(createFlag: ObjCBool; anObject: id): NSText; message 'fieldEditor:forObject:';
procedure setReleasedWhenClosed_(flag: ObjCBool); message 'setReleasedWhenClosed:';
procedure setAcceptsMouseMovedEvents_(flag: ObjCBool); message 'setAcceptsMouseMovedEvents:';
procedure setHidesOnDeactivate_(flag: ObjCBool); message 'setHidesOnDeactivate:';
procedure setHasShadow_(hasShadow_: ObjCBool); message 'setHasShadow:';
procedure setIgnoresMouseEvents_(flag: ObjCBool); message 'setIgnoresMouseEvents:';
{$endif}
end;
NSTableColumnFix = objccategory external (NSTableColumn)
procedure setTitle(atitle: NSString); message 'setTitle:';
function title: NSString; message 'title';
{$ifdef BOOLFIX}
procedure setHidden_(flag: ObjCBool); message 'setHidden:';
{$endif}
end;
NSUserInterfaceItemIdentifier = NSString;
NSTableViewAnimationOptions = NSUInteger;
NSTableViewFix = objccategory external (NSTableView)
// 10.7
function rowForView(AView: NSView): NSInteger; message 'rowForView:';
function columnForView(AView: NSView): NSInteger; message 'columnForView:';
function makeViewWithIdentifier_owner(identifier_: NSUserInterfaceItemIdentifier; owner: id): NSView ; message 'makeViewWithIdentifier:owner:';
function viewAtColumn_row_makeIfNecessary(column, row: NSInteger; makeifNecessary: Boolean): NSview; message 'viewAtColumn:row:makeIfNecessary:';
procedure insertRowsAtIndexes_withAnimation(indexes: NSIndexSet; withAnimation: NSTableViewAnimationOptions);
message 'insertRowsAtIndexes:withAnimation:';
procedure removeRowsAtIndexes_withAnimation(indexes: NSIndexSet; withAnimation: NSTableViewAnimationOptions);
message 'removeRowsAtIndexes:withAnimation:';
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;}
NSOperatingSystemVersion = record
majorVersion: NSInteger;
minorVersion: NSInteger;
patchVersion: NSInteger;
end;
const
// defined in NSApplication.h
NSAppKitVersionNumber10_5 = 949;
NSAppKitVersionNumber10_6 = 1038;
NSAppKitVersionNumber10_7 = 1138;
NSAppKitVersionNumber10_8 = 1187;
NSAppKitVersionNumber10_9 = 1265;
NSAppKitVersionNumber10_10 = 1343;
NSAppKitVersionNumber10_11 = 1404;
NSAppKitVersionNumber10_12 = 1504;
const
//kCGBaseWindowLevelKey = 0;
//kCGMinimumWindowLevelKey = 1;
//kCGDesktopWindowLevelKey = 2;
//kCGBackstopMenuLevelKey = 3;
NSNormalWindowLevel = 4;
NSFloatingWindowLevel = 5;
NSSubmenuWindowLevel = 6;
NSTornOffMenuWindowLevel = 6;
//kCGDockWindowLevelKey = 7; deprecated
NSMainMenuWindowLevel = 8;
NSStatusWindowLevel = 9;
NSModalPanelWindowLevel = 10;
NSPopUpMenuWindowLevel = 11;
NSScreenSaverWindowLevel = 12;
//kCGScreenSaverWindowLevelKey = 13;
//kCGMaximumWindowLevelKey = 14;
//kCGOverlayWindowLevelKey = 15;
//kCGHelpWindowLevelKey = 16;
//kCGUtilityWindowLevelKey = 17;
//kCGDesktopIconWindowLevelKey = 18;
//kCGCursorWindowLevelKey = 19;
//kCGAssistiveTechHighWindowLevelKey = 20;
//kCGNumberOfWindowLevelKeys = 21; { Must be last. }
const
NSWindowCollectionBehaviorFullScreenPrimary = 1 shl 7; // 10.7
NSWindowCollectionBehaviorFullScreenAuxiliary = 1 shl 8; // 10.7
NSWindowCollectionBehaviorFullScreenAllowsTiling = 1 shl 11; // 10.11
NSWindowCollectionBehaviorFullScreenDisallowsTiling = 1 shl 12; // 10.11
NSWindowTabbingModeAutomatic = 0; // The system automatically prefers to tab this window when appropriate
NSWindowTabbingModePreferred = 1; // The window explicitly should prefer to tab when shown
NSWindowTabbingModeDisallowed = 2; // The window explicitly should not prefer to tab when shown
const
NSKeyCodeTab = 48;
{ NSTableView Animation Options }
const
{ Use to not apply any animation effect (the default).
Specifying any animation from the effect groups below
negates this effect. }
NSTableViewAnimationEffectNone = $0;
{ Row animation Effect (optional). The effect can be combined
with other any NSTableViewRowAnimationSlide* option.
}
NSTableViewAnimationEffectFade = $1; // Fades in new rows.
NSTableViewAnimationEffectGap = $2; // Creates a gap for newly inserted rows. This is useful for drag and drop animations that animate to a newly opened gap and should be used in -tableView:acceptDrop:row:dropOperation:.
{Row Animation Sliding (optional). Currently only one option from this group may be specified at a time.
}
NSTableViewAnimationSlideUp = $10; // Animates a row in or out by sliding upward.
NSTableViewAnimationSlideDown = $20; // Animates a row in or out by sliding downward.
NSTableViewAnimationSlideLeft = $30; // Animates a row in by sliding from the left. Animates a row out by sliding towards the left.
NSTableViewAnimationSlideRight = $40; // Animates a row in by sliding from the right. Animates a row out by sliding towards the right.
implementation
end.
|