Improves Cocoa bindings

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@574 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2008-09-29 00:47:50 +00:00
parent 6f801dd3f8
commit fa69e42d57
33 changed files with 2722 additions and 240 deletions

View File

@ -15,7 +15,7 @@
{$include NSAlert.inc}
//#import <AppKit/NSAppleScriptExtensions.h>
{$include NSApplication.inc}
//#import <AppKit/NSBox.h>
{$include NSBox.inc}
{$include NSButton.inc}
{$include NSButtonCell.inc}
{$include NSCell.inc}
@ -63,18 +63,18 @@
#import <AppKit/NSSpeechRecognizer.h>
#import <AppKit/NSSpeechSynthesizer.h>
#import <AppKit/NSSpellChecker.h>
#import <AppKit/NSSplitView.h>
#import <AppKit/NSOpenPanel.h>
#import <AppKit/NSPageLayout.h> }
#import <AppKit/NSSplitView.h>}
{$include NSOpenPanel.inc}
{#import <AppKit/NSPageLayout.h> }
{$include NSPanel.inc}
{#import <AppKit/NSPasteboard.h>
#import <AppKit/NSPopUpButton.h>
#import <AppKit/NSPrintInfo.h>
#import <AppKit/NSPrintOperation.h>
#import <AppKit/NSPrintPanel.h>
#import <AppKit/NSResponder.h>
#import <AppKit/NSSavePanel.h>
#import <AppKit/NSScreen.h>
#import <AppKit/NSResponder.h>}
{$include NSSavePanel.inc}
{#import <AppKit/NSScreen.h>
#import <AppKit/NSScrollView.h>
#import <AppKit/NSScroller.h>
#import <AppKit/NSSegmentedControl.h>
@ -112,9 +112,9 @@
#import <AppKit/NSRulerMarker.h>
#import <AppKit/NSRulerView.h>
#import <AppKit/NSSecureTextField.h>
#import <AppKit/NSInterfaceStyle.h>
#import <AppKit/NSNibDeclarations.h>
#import <AppKit/NSProgressIndicator.h>
#import <AppKit/NSInterfaceStyle.h>}
{$include NSNibDeclarations.inc}
{#import <AppKit/NSProgressIndicator.h>
#import <AppKit/NSTabView.h>
#import <AppKit/NSTabViewItem.h>
#import <AppKit/NSMenuView.h>
@ -136,10 +136,10 @@
#import <AppKit/NSOpenGLView.h>
#import <AppKit/NSApplicationScripting.h>
#import <AppKit/NSDocumentScripting.h>
#import <AppKit/NSTextStorageScripting.h>
#import <AppKit/NSToolbar.h>
#import <AppKit/NSToolbarItem.h>
#import <AppKit/NSWindowScripting.h>
#import <AppKit/NSTextStorageScripting.h>}
{$include NSToolbar.inc}
{$include NSToolbarItem.inc}
{#import <AppKit/NSWindowScripting.h>
#import <AppKit/NSStepper.h>
#import <AppKit/NSStepperCell.h>
#import <AppKit/NSGlyphInfo.h>

View File

@ -275,6 +275,7 @@ type
class procedure useRunningCopyOfApplication;
function applicationHandle: Pointer;
function windowWithWindowHandle(_hWnd: Pointer): objc.id;{NSWindow}
procedure setAppleMenu(aMenu: objc.id {NSMenu});
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
@ -373,6 +374,8 @@ const
StrNSApplication_applicationHandle = 'applicationHandle';
StrNSApplication_windowWithWindowHandle = 'windowWithWindowHandle:';
StrNSApplication_setAppleMenu = 'setAppleMenu:';
{ NSApplication }
class function NSApplication.getClass: objc.id;
@ -1048,4 +1051,14 @@ begin
Result := objc.id(vmethod(Handle, sel_registerName(PChar(StrNSApplication_windowWithWindowHandle)), _hWnd));
end;
procedure NSApplication.setAppleMenu(aMenu: objc.id {NSMenu});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;aMenu: objc.id); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSApplication_setAppleMenu)), aMenu);
end;
{$endif}

View File

@ -0,0 +1,258 @@
{%mainunit appkit.pas}
(*
NSBox.h
Application Kit
Copyright (c) 1994-2005, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSBOX_PAS_H}
{$define NSBOX_PAS_H}
{$include NSView.inc}
type
NSTitlePosition = (
NSNoTitle = 0,
NSAboveTop = 1,
NSAtTop = 2,
NSBelowTop = 3,
NSAboveBottom = 4,
NSAtBottom = 5,
NSBelowBottom = 6
);
type
NSBoxType = (
NSBoxPrimary = 0,
NSBoxSecondary = 1,
NSBoxSeparator = 2,
NSBoxOldStyle = 3
);
{$endif}
{$endif}
{$ifdef FORWARD}
NSBox = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSBOX_PAS_C}
{$define NSBOX_PAS_C}
{$include NSView.inc}
{ NSBox }
NSBox = class(NSView)
public
class function getClass: objc.id; override;
// All instance variables are private
function borderType: NSBorderType;
function titlePosition: NSTitlePosition;
procedure setBorderType(_aType: NSBorderType);
procedure setBoxType(_boxType: NSBoxType);
function boxType: NSBoxType;
procedure setTitlePosition(_aPosition: NSTitlePosition);
function title: CFStringRef;
procedure setTitle(_aString: CFStringRef);
function titleFont: objc.id;{NSFont}
procedure setTitleFont(_fontObj: objc.id {NSFont});
function borderRect: NSRect;
function titleRect: NSRect;
function titleCell: objc.id;
procedure sizeToFit;
function contentViewMargins: NSSize;
procedure setContentViewMargins(_offsetSize: NSSize);
procedure setFrameFromContentFrame(_contentFrame: NSRect);
function contentView: objc.id;
procedure setContentView(_aView: objc.id {NSView});
procedure setTitleWithMnemonic(_stringWithAmpersand: CFStringRef);
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSBox_NSBox = 'NSBox';
StrNSBox_borderType = 'borderType';
StrNSBox_titlePosition = 'titlePosition';
StrNSBox_setBorderType = 'setBorderType:';
StrNSBox_setBoxType = 'setBoxType:';
StrNSBox_boxType = 'boxType';
StrNSBox_setTitlePosition = 'setTitlePosition:';
StrNSBox_title = 'title';
StrNSBox_setTitle = 'setTitle:';
StrNSBox_titleFont = 'titleFont';
StrNSBox_setTitleFont = 'setTitleFont:';
StrNSBox_borderRect = 'borderRect';
StrNSBox_titleRect = 'titleRect';
StrNSBox_titleCell = 'titleCell';
StrNSBox_sizeToFit = 'sizeToFit';
StrNSBox_contentViewMargins = 'contentViewMargins';
StrNSBox_setContentViewMargins = 'setContentViewMargins:';
StrNSBox_setFrameFromContentFrame = 'setFrameFromContentFrame:';
StrNSBox_contentView = 'contentView';
StrNSBox_setContentView = 'setContentView:';
StrNSBox_setTitleWithMnemonic = 'setTitleWithMnemonic:';
{ NSBox }
class function NSBox.getClass: objc.id;
begin
Result := objc_getClass(StrNSBox_NSBox);
end;
function NSBox.borderType: NSBorderType;
begin
Result := NSBorderType(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_borderType)), []));
end;
function NSBox.titlePosition: NSTitlePosition;
begin
Result := NSTitlePosition(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_titlePosition)), []));
end;
procedure NSBox.setBorderType(_aType: NSBorderType);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_aType: NSBorderType); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setBorderType)), _aType);
end;
procedure NSBox.setBoxType(_boxType: NSBoxType);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_boxType: NSBoxType); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setBoxType)), _boxType);
end;
function NSBox.boxType: NSBoxType;
begin
Result := NSBoxType(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_boxType)), []));
end;
procedure NSBox.setTitlePosition(_aPosition: NSTitlePosition);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_aPosition: NSTitlePosition); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setTitlePosition)), _aPosition);
end;
function NSBox.title: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_title)), []));
end;
procedure NSBox.setTitle(_aString: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_aString: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setTitle)), _aString);
end;
function NSBox.titleFont: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_titleFont)), []));
end;
procedure NSBox.setTitleFont(_fontObj: objc.id {NSFont});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_fontObj: objc.id {NSFont}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setTitleFont)), _fontObj);
end;
function NSBox.borderRect: NSRect;
begin
objc_msgSend_stret(@Result, Handle, sel_registerName(PChar(StrNSBox_borderRect)), []);
end;
function NSBox.titleRect: NSRect;
begin
objc_msgSend_stret(@Result, Handle, sel_registerName(PChar(StrNSBox_titleRect)), []);
end;
function NSBox.titleCell: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_titleCell)), []));
end;
procedure NSBox.sizeToFit;
begin
objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_sizeToFit)), []);
end;
function NSBox.contentViewMargins: NSSize;
begin
objc_msgSend_stret(@Result, Handle, sel_registerName(PChar(StrNSBox_contentViewMargins)), []);
end;
procedure NSBox.setContentViewMargins(_offsetSize: NSSize);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_offsetSize: NSSize); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setContentViewMargins)), _offsetSize);
end;
procedure NSBox.setFrameFromContentFrame(_contentFrame: NSRect);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_contentFrame: NSRect); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setFrameFromContentFrame)), _contentFrame);
end;
function NSBox.contentView: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_contentView)), []));
end;
procedure NSBox.setContentView(_aView: objc.id {NSView});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_aView: objc.id {NSView}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setContentView)), _aView);
end;
procedure NSBox.setTitleWithMnemonic(_stringWithAmpersand: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_stringWithAmpersand: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSBox_setTitleWithMnemonic)), _stringWithAmpersand);
end;
{$endif}

View File

@ -0,0 +1,31 @@
{%mainunit appkit.pas}
(*
NSNibDeclarations.h
Application Kit
Copyright (c) 1996-2005, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSNIBDECLARATIONS_PAS_H}
{$define NSNIBDECLARATIONS_PAS_H}
{.$endif}
{.$endif}
type
{$define IBOutlet}
IBAction = procedure;
{.$endif}
{.$endif}
{$endif}
{$endif}
{$ifdef CLASSES}
{$ifndef NSNIBDECLARATIONS_PAS_C}
{$define NSNIBDECLARATIONS_PAS_C}
{.$endif}
{.$endif}
{$endif}
{$endif}

View File

@ -0,0 +1,206 @@
{%mainunit appkit.pas}
(*
NSOpenPanel.h
Application Kit
Copyright (c) 1994-2004, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSOPENPANEL_PAS_H}
{$define NSOPENPANEL_PAS_H}
{$include NSSavePanel.inc}
{$endif}
{$endif}
{$ifdef FORWARD}
NSOpenPanel = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSOPENPANEL_PAS_C}
{$define NSOPENPANEL_PAS_C}
{$include NSSavePanel.inc}
{ NSOpenPanel }
NSOpenPanel = class(NSSavePanel)
public
class function getClass: objc.id; override;
constructor openPanel;
function URLs: CFArrayRef;
function filenames: CFArrayRef;
function resolvesAliases: LongBool;
procedure setResolvesAliases(_flag: LongBool);
function canChooseDirectories: LongBool;
procedure setCanChooseDirectories(_flag: LongBool);
function allowsMultipleSelection: LongBool;
procedure setAllowsMultipleSelection(_flag: LongBool);
function canChooseFiles: LongBool;
procedure setCanChooseFiles(_flag: LongBool);
procedure beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
procedure beginForDirectory_file_types_modelessDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
{.$endif}
function runModalForDirectory_file_types(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef): Integer;
function runModalForTypes(_fileTypes: CFArrayRef): Integer;
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSOpenPanel_NSOpenPanel = 'NSOpenPanel';
StrNSOpenPanel_openPanel = 'openPanel';
StrNSOpenPanel_URLs = 'URLs';
StrNSOpenPanel_filenames = 'filenames';
StrNSOpenPanel_resolvesAliases = 'resolvesAliases';
StrNSOpenPanel_setResolvesAliases = 'setResolvesAliases:';
StrNSOpenPanel_canChooseDirectories = 'canChooseDirectories';
StrNSOpenPanel_setCanChooseDirectories = 'setCanChooseDirectories:';
StrNSOpenPanel_allowsMultipleSelection = 'allowsMultipleSelection';
StrNSOpenPanel_setAllowsMultipleSelection = 'setAllowsMultipleSelection:';
StrNSOpenPanel_canChooseFiles = 'canChooseFiles';
StrNSOpenPanel_setCanChooseFiles = 'setCanChooseFiles:';
StrNSOpenPanel_beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo = 'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:';
StrNSOpenPanel_beginForDirectory_file_types_modelessDelegate_didEndSelector_contextInfo = 'beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:';
StrNSOpenPanel_runModalForDirectory_file_types = 'runModalForDirectory:file:types:';
StrNSOpenPanel_runModalForTypes = 'runModalForTypes:';
{ NSOpenPanel }
class function NSOpenPanel.getClass: objc.id;
begin
Result := objc_getClass(StrNSOpenPanel_NSOpenPanel);
end;
constructor NSOpenPanel.openPanel;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL): objc.id; cdecl;
var
vmethod: TmsgSendWrapper;
begin
ClassID := getClass();
vmethod := TmsgSendWrapper(@objc_msgSend);
Handle := vmethod(ClassID, sel_registerName(PChar(StrNSOpenPanel_openPanel)));
end;
function NSOpenPanel.URLs: CFArrayRef;
begin
Result := CFArrayRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_URLs)), []));
end;
function NSOpenPanel.filenames: CFArrayRef;
begin
Result := CFArrayRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_filenames)), []));
end;
function NSOpenPanel.resolvesAliases: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_resolvesAliases)), []));
end;
procedure NSOpenPanel.setResolvesAliases(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_setResolvesAliases)), _flag);
end;
function NSOpenPanel.canChooseDirectories: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_canChooseDirectories)), []));
end;
procedure NSOpenPanel.setCanChooseDirectories(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_setCanChooseDirectories)), _flag);
end;
function NSOpenPanel.allowsMultipleSelection: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_allowsMultipleSelection)), []));
end;
procedure NSOpenPanel.setAllowsMultipleSelection(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_setAllowsMultipleSelection)), _flag);
end;
function NSOpenPanel.canChooseFiles: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSOpenPanel_canChooseFiles)), []));
end;
procedure NSOpenPanel.setCanChooseFiles(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_setCanChooseFiles)), _flag);
end;
procedure NSOpenPanel.beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo)), _path, _name, _fileTypes, _docWindow, _delegate, _didEndSelector, _contextInfo);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
procedure NSOpenPanel.beginForDirectory_file_types_modelessDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_beginForDirectory_file_types_modelessDelegate_didEndSelector_contextInfo)), _path, _name, _fileTypes, _delegate, _didEndSelector, _contextInfo);
end;
{.$endif}
function NSOpenPanel.runModalForDirectory_file_types(_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef): Integer;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_path: CFStringRef; _name: CFStringRef; _fileTypes: CFArrayRef): Integer; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := Integer(vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_runModalForDirectory_file_types)), _path, _name, _fileTypes));
end;
function NSOpenPanel.runModalForTypes(_fileTypes: CFArrayRef): Integer;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_fileTypes: CFArrayRef): Integer; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := Integer(vmethod(Handle, sel_registerName(PChar(StrNSOpenPanel_runModalForTypes)), _fileTypes));
end;
{$endif}

View File

@ -1,98 +1,148 @@
{%mainunit appkit.pas}
{
(*
NSPanel.h
Application Kit
Copyright (c) 1994-2005, Apple Computer, Inc.
All rights reserved.
}
*)
{$ifdef HEADER}
{$ifndef NSPANEL_PAS_H}
{$define NSPANEL_PAS_H}
//#import <AppKit/NSWindow.h>
{$include NSWindow.inc}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
{.$endif}
{
* In the following two functions, msg may be a printf-like message with
* the arguments tacked onto the end. Thus, to get a '%' in your message,
* you must use '%%'
}
function NSRunAlertPanel(title, msg, defaultButton, alternateButton, otherButton: CFStringRef; others: array of const): cint; cdecl; external;
(*APPKIT_EXTERN int NSRunInformationalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
APPKIT_EXTERN int NSRunCriticalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN int NSRunAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN int NSRunInformationalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN int NSRunCriticalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN int NSRunAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
//APPKIT_EXTERN int NSRunInformationalAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
//APPKIT_EXTERN int NSRunCriticalAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
//APPKIT_EXTERN void NSBeginAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
//APPKIT_EXTERN void NSBeginInformationalAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
//APPKIT_EXTERN void NSBeginCriticalAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
//APPKIT_EXTERN id NSGetAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN id NSGetInformationalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN id NSGetCriticalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
//APPKIT_EXTERN void NSReleaseAlertPanel(id panel);
// * NSRunAlertPanel() return values (also returned by runModalSession: when
// * the modal session is run with a panel returned by NSGetAlertPanel()).
//
const
NSAlertDefaultReturn = 1;
NSAlertAlternateReturn = 0;
NSAlertOtherReturn = 1;
NSAlertErrorReturn = 2;
/*
** The NSRunAlertPanelRelativeToWindow variants are deprecated.
** Please use the corresponding NSBeginAlertSheet() function instead.
*/
APPKIT_EXTERN int NSRunAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
APPKIT_EXTERN int NSRunInformationalAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
APPKIT_EXTERN int NSRunCriticalAlertPanelRelativeToWindow(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, ...);
const
NSOKButton = 1;
NSCancelButton = 0;
/*
** Present a sheet alert on the given window. When the modal session is ended, but before the sheet is dismissed,
** the didEndSelector will be invoked in the modalDelegate. After the sheet
** is dismissed, the didDismissSelector will be invoked. Typically, you will want to implement the didEndSelector but you may
** pass NULL for the didDismissSelector.
** The methods should have the following signatures:
** - (void)sheetDidEnd:(NSWindow * )sheet returnCode:(int)returnCode contextInfo:(void * )contextInfo;
** - (void)sheetDidDismiss:(NSWindow * )sheet returnCode:(int)returnCode contextInfo:(void * )contextInfo;
**
*/
APPKIT_EXTERN void NSBeginAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
APPKIT_EXTERN void NSBeginInformationalAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
APPKIT_EXTERN void NSBeginCriticalAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msg, ...);
// Panel specific styleMask
const
NSUtilityWindowMask = 1 shl 4;
NSDocModalWindowMask = 1 shl 6;
APPKIT_EXTERN id NSGetAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
APPKIT_EXTERN id NSGetInformationalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
APPKIT_EXTERN id NSGetCriticalAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
APPKIT_EXTERN void NSReleaseAlertPanel(id panel);
/*
* NSRunAlertPanel() return values (also returned by runModalSession: when
* the modal session is run with a panel returned by NSGetAlertPanel()).
*/
enum {
NSAlertDefaultReturn = 1,
NSAlertAlternateReturn = 0,
NSAlertOtherReturn = -1,
NSAlertErrorReturn = -2
};
enum {
NSOKButton = 1,
NSCancelButton = 0
};
// Panel specific styleMask
enum {
NSUtilityWindowMask = 1 << 4,
NSDocModalWindowMask = 1 << 6
};
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2
enum {
NSNonactivatingPanelMask = 1 << 7 // specify a panel that does not activate owning application
};
#endif
@interface NSPanel : NSWindow
{
/*All instance variables are private*/
}
- (BOOL)isFloatingPanel;
- (void)setFloatingPanel:(BOOL)flag;
- (BOOL)becomesKeyOnlyIfNeeded;
- (void)setBecomesKeyOnlyIfNeeded:(BOOL)flag;
- (BOOL)worksWhenModal;
- (void)setWorksWhenModal:(BOOL)flag;
@end
*)
const
NSNonactivatingPanelMask = 1 shl 7;
{$endif}
{$endif}
{$ifdef FORWARD}
NSPanel = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSPANEL_PAS_C}
{$define NSPANEL_PAS_C}
{$include NSWindow.inc}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
{.$endif}
{ NSPanel }
NSPanel = class(NSWindow)
public
class function getClass: objc.id; override;
// All instance variables are private
function isFloatingPanel: LongBool;
procedure setFloatingPanel(_flag: LongBool);
function becomesKeyOnlyIfNeeded: LongBool;
procedure setBecomesKeyOnlyIfNeeded(_flag: LongBool);
function worksWhenModal: LongBool;
procedure setWorksWhenModal(_flag: LongBool);
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSPanel_NSPanel = 'NSPanel';
StrNSPanel_isFloatingPanel = 'isFloatingPanel';
StrNSPanel_setFloatingPanel = 'setFloatingPanel:';
StrNSPanel_becomesKeyOnlyIfNeeded = 'becomesKeyOnlyIfNeeded';
StrNSPanel_setBecomesKeyOnlyIfNeeded = 'setBecomesKeyOnlyIfNeeded:';
StrNSPanel_worksWhenModal = 'worksWhenModal';
StrNSPanel_setWorksWhenModal = 'setWorksWhenModal:';
{ NSPanel }
class function NSPanel.getClass: objc.id;
begin
Result := objc_getClass(StrNSPanel_NSPanel);
end;
function NSPanel.isFloatingPanel: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSPanel_isFloatingPanel)), []));
end;
procedure NSPanel.setFloatingPanel(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSPanel_setFloatingPanel)), _flag);
end;
function NSPanel.becomesKeyOnlyIfNeeded: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSPanel_becomesKeyOnlyIfNeeded)), []));
end;
procedure NSPanel.setBecomesKeyOnlyIfNeeded(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSPanel_setBecomesKeyOnlyIfNeeded)), _flag);
end;
function NSPanel.worksWhenModal: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSPanel_worksWhenModal)), []));
end;
procedure NSPanel.setWorksWhenModal(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSPanel_setWorksWhenModal)), _flag);
end;
{$endif}

View File

@ -0,0 +1,462 @@
{%mainunit appkit.pas}
(*
NSSavePanel.h
Application Kit
Copyright (c) 1994-2004, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSSAVEPANEL_PAS_H}
{$define NSSAVEPANEL_PAS_H}
{$include NSNibDeclarations.inc}
{$include NSPanel.inc}
const
NSFileHandlingPanelCancelButton = NSCancelButton;
NSFileHandlingPanelOKButton = NSOKButton;
type
__SPFlags = packed record
_bitflags1 : LongWord;
end;
_SPFlags = __SPFlags;
{$endif}
{$endif}
{$ifdef FORWARD}
NSSavePanel = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSSAVEPANEL_PAS_C}
{$define NSSAVEPANEL_PAS_C}
{$include NSNibDeclarations.inc}
{$include NSPanel.inc}
{ NSSavePanel }
NSSavePanel = class(NSPanel)
public
class function getClass: objc.id; override;
constructor savePanel;
function URL: CFURLRef;
function filename: CFStringRef;
function directory: CFStringRef;
procedure setDirectory(_path: CFStringRef);
function requiredFileType: CFStringRef;
procedure setRequiredFileType(__type: CFStringRef);
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function allowedFileTypes: CFArrayRef;
procedure setAllowedFileTypes(_types: CFArrayRef);
function allowsOtherFileTypes: LongBool;
procedure setAllowsOtherFileTypes(_flag: LongBool);
{.$endif}
function accessoryView: objc.id;{NSView}
procedure setAccessoryView(_view: objc.id {NSView});
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function delegate: objc.id;
{.$endif}
procedure setDelegate(_delegate: objc.id);
function isExpanded: LongBool;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function canCreateDirectories: LongBool;
procedure setCanCreateDirectories(_flag: LongBool);
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function canSelectHiddenExtension: LongBool;
{.$endif}
procedure setCanSelectHiddenExtension(_flag: LongBool);
function isExtensionHidden: LongBool;
procedure setExtensionHidden(_flag: LongBool);
function treatsFilePackagesAsDirectories: LongBool;
procedure setTreatsFilePackagesAsDirectories(_flag: LongBool);
function prompt: CFStringRef;
procedure setPrompt(_prompt: CFStringRef);
function title: CFStringRef;
procedure setTitle(_title: CFStringRef);
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function nameFieldLabel: CFStringRef;
procedure setNameFieldLabel(__label: CFStringRef);
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function message: CFStringRef;
procedure setMessage(_message: CFStringRef);
{.$endif}
procedure validateVisibleColumns;
// A method that was deprecated in Mac OS 10.3. -[NSSavePanel selectText:] does nothing.
function selectText(_sender: objc.id): IBAction;
function ok(_sender: objc.id): IBAction;
function cancel(_sender: objc.id): IBAction;
procedure beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
function runModalForDirectory_file(_path: CFStringRef; _name: CFStringRef): Integer;
function runModal: Integer;
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSSavePanel_NSSavePanel = 'NSSavePanel';
StrNSSavePanel_savePanel = 'savePanel';
StrNSSavePanel_URL = 'URL';
StrNSSavePanel_filename = 'filename';
StrNSSavePanel_directory = 'directory';
StrNSSavePanel_setDirectory = 'setDirectory:';
StrNSSavePanel_requiredFileType = 'requiredFileType';
StrNSSavePanel_setRequiredFileType = 'setRequiredFileType:';
StrNSSavePanel_allowedFileTypes = 'allowedFileTypes';
StrNSSavePanel_setAllowedFileTypes = 'setAllowedFileTypes:';
StrNSSavePanel_allowsOtherFileTypes = 'allowsOtherFileTypes';
StrNSSavePanel_setAllowsOtherFileTypes = 'setAllowsOtherFileTypes:';
StrNSSavePanel_accessoryView = 'accessoryView';
StrNSSavePanel_setAccessoryView = 'setAccessoryView:';
StrNSSavePanel_delegate = 'delegate';
StrNSSavePanel_setDelegate = 'setDelegate:';
StrNSSavePanel_isExpanded = 'isExpanded';
StrNSSavePanel_canCreateDirectories = 'canCreateDirectories';
StrNSSavePanel_setCanCreateDirectories = 'setCanCreateDirectories:';
StrNSSavePanel_canSelectHiddenExtension = 'canSelectHiddenExtension';
StrNSSavePanel_setCanSelectHiddenExtension = 'setCanSelectHiddenExtension:';
StrNSSavePanel_isExtensionHidden = 'isExtensionHidden';
StrNSSavePanel_setExtensionHidden = 'setExtensionHidden:';
StrNSSavePanel_treatsFilePackagesAsDirectories = 'treatsFilePackagesAsDirectories';
StrNSSavePanel_setTreatsFilePackagesAsDirectories = 'setTreatsFilePackagesAsDirectories:';
StrNSSavePanel_prompt = 'prompt';
StrNSSavePanel_setPrompt = 'setPrompt:';
StrNSSavePanel_title = 'title';
StrNSSavePanel_setTitle = 'setTitle:';
StrNSSavePanel_nameFieldLabel = 'nameFieldLabel';
StrNSSavePanel_setNameFieldLabel = 'setNameFieldLabel:';
StrNSSavePanel_message = 'message';
StrNSSavePanel_setMessage = 'setMessage:';
StrNSSavePanel_validateVisibleColumns = 'validateVisibleColumns';
StrNSSavePanel_selectText = 'selectText:';
StrNSSavePanel_ok = 'ok:';
StrNSSavePanel_cancel = 'cancel:';
StrNSSavePanel_beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo = 'beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:';
StrNSSavePanel_runModalForDirectory_file = 'runModalForDirectory:file:';
StrNSSavePanel_runModal = 'runModal';
{ NSSavePanel }
class function NSSavePanel.getClass: objc.id;
begin
Result := objc_getClass(StrNSSavePanel_NSSavePanel);
end;
constructor NSSavePanel.savePanel;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL): objc.id; cdecl;
var
vmethod: TmsgSendWrapper;
begin
ClassID := getClass();
vmethod := TmsgSendWrapper(@objc_msgSend);
Handle := vmethod(ClassID, sel_registerName(PChar(StrNSSavePanel_savePanel)));
end;
function NSSavePanel.URL: CFURLRef;
begin
Result := CFURLRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_URL)), []));
end;
function NSSavePanel.filename: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_filename)), []));
end;
function NSSavePanel.directory: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_directory)), []));
end;
procedure NSSavePanel.setDirectory(_path: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_path: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setDirectory)), _path);
end;
function NSSavePanel.requiredFileType: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_requiredFileType)), []));
end;
procedure NSSavePanel.setRequiredFileType(__type: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;__type: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setRequiredFileType)), __type);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.allowedFileTypes: CFArrayRef;
begin
Result := CFArrayRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_allowedFileTypes)), []));
end;
procedure NSSavePanel.setAllowedFileTypes(_types: CFArrayRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_types: CFArrayRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setAllowedFileTypes)), _types);
end;
function NSSavePanel.allowsOtherFileTypes: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_allowsOtherFileTypes)), []));
end;
procedure NSSavePanel.setAllowsOtherFileTypes(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setAllowsOtherFileTypes)), _flag);
end;
{.$endif}
function NSSavePanel.accessoryView: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_accessoryView)), []));
end;
procedure NSSavePanel.setAccessoryView(_view: objc.id {NSView});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_view: objc.id {NSView}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setAccessoryView)), _view);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.delegate: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_delegate)), []));
end;
{.$endif}
procedure NSSavePanel.setDelegate(_delegate: objc.id);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_delegate: objc.id); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setDelegate)), _delegate);
end;
function NSSavePanel.isExpanded: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_isExpanded)), []));
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.canCreateDirectories: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_canCreateDirectories)), []));
end;
procedure NSSavePanel.setCanCreateDirectories(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setCanCreateDirectories)), _flag);
end;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.canSelectHiddenExtension: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_canSelectHiddenExtension)), []));
end;
{.$endif}
procedure NSSavePanel.setCanSelectHiddenExtension(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setCanSelectHiddenExtension)), _flag);
end;
function NSSavePanel.isExtensionHidden: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_isExtensionHidden)), []));
end;
procedure NSSavePanel.setExtensionHidden(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setExtensionHidden)), _flag);
end;
function NSSavePanel.treatsFilePackagesAsDirectories: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_treatsFilePackagesAsDirectories)), []));
end;
procedure NSSavePanel.setTreatsFilePackagesAsDirectories(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setTreatsFilePackagesAsDirectories)), _flag);
end;
function NSSavePanel.prompt: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_prompt)), []));
end;
procedure NSSavePanel.setPrompt(_prompt: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_prompt: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setPrompt)), _prompt);
end;
function NSSavePanel.title: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_title)), []));
end;
procedure NSSavePanel.setTitle(_title: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_title: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setTitle)), _title);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.nameFieldLabel: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_nameFieldLabel)), []));
end;
procedure NSSavePanel.setNameFieldLabel(__label: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;__label: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setNameFieldLabel)), __label);
end;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
function NSSavePanel.message: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_message)), []));
end;
procedure NSSavePanel.setMessage(_message: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_message: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_setMessage)), _message);
end;
{.$endif}
procedure NSSavePanel.validateVisibleColumns;
begin
objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_validateVisibleColumns)), []);
end;
function NSSavePanel.selectText(_sender: objc.id): IBAction;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_sender: objc.id): IBAction; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := IBAction(vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_selectText)), _sender));
end;
function NSSavePanel.ok(_sender: objc.id): IBAction;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_sender: objc.id): IBAction; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := IBAction(vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_ok)), _sender));
end;
function NSSavePanel.cancel(_sender: objc.id): IBAction;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_sender: objc.id): IBAction; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := IBAction(vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_cancel)), _sender));
end;
procedure NSSavePanel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo(_path: CFStringRef; _name: CFStringRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_path: CFStringRef; _name: CFStringRef; _docWindow: objc.id {NSWindow}; _delegate: objc.id; _didEndSelector: SEL; _contextInfo: Pointer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo)), _path, _name, _docWindow, _delegate, _didEndSelector, _contextInfo);
end;
function NSSavePanel.runModalForDirectory_file(_path: CFStringRef; _name: CFStringRef): Integer;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_path: CFStringRef; _name: CFStringRef): Integer; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := Integer(vmethod(Handle, sel_registerName(PChar(StrNSSavePanel_runModalForDirectory_file)), _path, _name));
end;
function NSSavePanel.runModal: Integer;
begin
Result := Integer(objc_msgSend(Handle, sel_registerName(PChar(StrNSSavePanel_runModal)), []));
end;
{$endif}

View File

@ -0,0 +1,371 @@
{%mainunit appkit.pas}
(*
NSToolbar.h
Application Kit
Copyright (c) 2000-2004, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSTOOLBAR_PAS_H}
{$define NSTOOLBAR_PAS_H}
{$include AppKitDefines.inc}
type
NSToolbarDisplayMode = (
NSToolbarDisplayModeDefault,
NSToolbarDisplayModeIconAndLabel,
NSToolbarDisplayModeIconOnly,
NSToolbarDisplayModeLabelOnly
);
type
NSToolbarSizeMode = (
NSToolbarSizeModeDefault,
NSToolbarSizeModeRegular,
NSToolbarSizeModeSmall
);
//APPKIT_EXTERN NSString *NSToolbarWillAddItemNotification;
//APPKIT_EXTERN NSString *NSToolbarDidRemoveItemNotification;
{$endif}
{$endif}
{$ifdef FORWARD}
NSToolbar = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSTOOLBAR_PAS_C}
{$define NSTOOLBAR_PAS_C}
{$include AppKitDefines.inc}
{ NSToolbar }
NSToolbar = class(NSObject)
public
class function getClass: objc.id; override;
constructor initWithIdentifier(_identifier: CFStringRef);
// The identifier is used to form the toolbar's autosave name. Also, toolbars with
// the same identifier are implicitly synchronized so that they maintain the same state.
procedure insertItemWithItemIdentifier_atIndex(_itemIdentifier: CFStringRef; __index: Integer);
procedure removeItemAtIndex(__index: Integer);
// Primitives for explicitly adding and removing items. Any change made will be propogated
// immediately to all other toolbars with the same identifier.
procedure setDelegate(_delegate: objc.id);
function delegate: objc.id;
// Customizable toolbars must have a delegate, and must implement the required NSToolbarDelegate
// methods.
procedure setVisible(_shown: LongBool);
function isVisible: LongBool;
// toggles the visibliity of the toolbar.
procedure runCustomizationPalette(_sender: objc.id);
function customizationPaletteIsRunning: LongBool;
// Customizable toolbars (those with delegates) can show a palette which allows users
// to populate the toolbar with individual items or to reset the toolbar to some default
// set of items. The items and item sets in the palette are specified by the delegate
// (-toolbarAllowedItemIdentifiers: and -toolbarDefaultItemIdentifiers:). When the
// user is done configuring, they will dismiss the palette.
// ----- Toolbar Attributes -----
procedure setDisplayMode(_displayMode: NSToolbarDisplayMode);
function displayMode: NSToolbarDisplayMode;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
procedure setSelectedItemIdentifier(_itemIdentifier: CFStringRef);
function selectedItemIdentifier: CFStringRef;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
procedure setSizeMode(_sizeMode: NSToolbarSizeMode);
function sizeMode: NSToolbarSizeMode;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
// Use this API to hide the baseline NSToolbar draws between itself and the main window
// contents. The default is YES. This method should only be used before the toolbar
// is attached to its window (-[NSWindow setToolbar:]).
procedure setShowsBaselineSeparator(_flag: LongBool);
function showsBaselineSeparator: LongBool;
{.$endif}
procedure setAllowsUserCustomization(_allowCustomization: LongBool);
function allowsUserCustomization: LongBool;
// This flag controls whether or not users can configure the toolbar by dragging items
// around, and whether or not the customization palette can be used. The default value
// is NO, but can be changed at any time. For instance, a developer may not want users
// to be able to edit the toolbar while some event is being processed.
// ----- Accessing toolbar info -----
function identifier: CFStringRef;
// All toolbars with the same name will share the same display attributes, and item
// order. Also, if a toolbar autosaves its configuration, the item identifier will
// be used as the autosave name.
function items: CFArrayRef;
// Allows you to access all current items in the toolbar.
function visibleItems: CFArrayRef;
// Allows you to access the current visible items (non clipped).
// ----- Autosaving The Configuration -----
procedure setAutosavesConfiguration(_flag: LongBool);
function autosavesConfiguration: LongBool;
// If autosavesConfiguration is YES, the toolbar will automatically write changes the
// user makes to user defaults. Customizable toolbars will want to set this flag to
// YES. Setting this to NO means changes in configuration are not written automatically,
// however you can use the configurationDictionary method to do it yourself. Default
// is NO.
procedure setConfigurationFromDictionary(_configDict: CFDictionaryRef);
function configurationDictionary: CFDictionaryRef;
// Set and get the current toolbar configuration using a dictionary representation.
// ----- Validation of the items -----
procedure validateVisibleItems;
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSToolbar_NSToolbar = 'NSToolbar';
StrNSToolbar_initWithIdentifier = 'initWithIdentifier:';
StrNSToolbar_insertItemWithItemIdentifier_atIndex = 'insertItemWithItemIdentifier:atIndex:';
StrNSToolbar_removeItemAtIndex = 'removeItemAtIndex:';
StrNSToolbar_setDelegate = 'setDelegate:';
StrNSToolbar_delegate = 'delegate';
StrNSToolbar_setVisible = 'setVisible:';
StrNSToolbar_isVisible = 'isVisible';
StrNSToolbar_runCustomizationPalette = 'runCustomizationPalette:';
StrNSToolbar_customizationPaletteIsRunning = 'customizationPaletteIsRunning';
StrNSToolbar_setDisplayMode = 'setDisplayMode:';
StrNSToolbar_displayMode = 'displayMode';
StrNSToolbar_setSelectedItemIdentifier = 'setSelectedItemIdentifier:';
StrNSToolbar_selectedItemIdentifier = 'selectedItemIdentifier';
StrNSToolbar_setSizeMode = 'setSizeMode:';
StrNSToolbar_sizeMode = 'sizeMode';
StrNSToolbar_setShowsBaselineSeparator = 'setShowsBaselineSeparator:';
StrNSToolbar_showsBaselineSeparator = 'showsBaselineSeparator';
StrNSToolbar_setAllowsUserCustomization = 'setAllowsUserCustomization:';
StrNSToolbar_allowsUserCustomization = 'allowsUserCustomization';
StrNSToolbar_identifier = 'identifier';
StrNSToolbar_items = 'items';
StrNSToolbar_visibleItems = 'visibleItems';
StrNSToolbar_setAutosavesConfiguration = 'setAutosavesConfiguration:';
StrNSToolbar_autosavesConfiguration = 'autosavesConfiguration';
StrNSToolbar_setConfigurationFromDictionary = 'setConfigurationFromDictionary:';
StrNSToolbar_configurationDictionary = 'configurationDictionary';
StrNSToolbar_validateVisibleItems = 'validateVisibleItems';
{ NSToolbar }
class function NSToolbar.getClass: objc.id;
begin
Result := objc_getClass(StrNSToolbar_NSToolbar);
end;
constructor NSToolbar.initWithIdentifier(_identifier: CFStringRef);
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_identifier: CFStringRef): objc.id; cdecl;
var
vmethod: TmsgSendWrapper;
begin
ClassID := getClass();
allocbuf := objc_msgSend(ClassID, sel_registerName(PChar(Str_alloc)), []);
vmethod := TmsgSendWrapper(@objc_msgSend);
Handle := vmethod(allocbuf, sel_registerName(PChar(StrNSToolbar_initWithIdentifier)), _identifier);
end;
procedure NSToolbar.insertItemWithItemIdentifier_atIndex(_itemIdentifier: CFStringRef; __index: Integer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_itemIdentifier: CFStringRef; __index: Integer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_insertItemWithItemIdentifier_atIndex)), _itemIdentifier, __index);
end;
procedure NSToolbar.removeItemAtIndex(__index: Integer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;__index: Integer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_removeItemAtIndex)), __index);
end;
procedure NSToolbar.setDelegate(_delegate: objc.id);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_delegate: objc.id); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setDelegate)), _delegate);
end;
function NSToolbar.delegate: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_delegate)), []));
end;
procedure NSToolbar.setVisible(_shown: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_shown: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setVisible)), _shown);
end;
function NSToolbar.isVisible: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_isVisible)), []));
end;
procedure NSToolbar.runCustomizationPalette(_sender: objc.id);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_sender: objc.id); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_runCustomizationPalette)), _sender);
end;
function NSToolbar.customizationPaletteIsRunning: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_customizationPaletteIsRunning)), []));
end;
procedure NSToolbar.setDisplayMode(_displayMode: NSToolbarDisplayMode);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_displayMode: NSToolbarDisplayMode); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setDisplayMode)), _displayMode);
end;
function NSToolbar.displayMode: NSToolbarDisplayMode;
begin
Result := NSToolbarDisplayMode(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_displayMode)), []));
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
procedure NSToolbar.setSelectedItemIdentifier(_itemIdentifier: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_itemIdentifier: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setSelectedItemIdentifier)), _itemIdentifier);
end;
function NSToolbar.selectedItemIdentifier: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_selectedItemIdentifier)), []));
end;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
procedure NSToolbar.setSizeMode(_sizeMode: NSToolbarSizeMode);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_sizeMode: NSToolbarSizeMode); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setSizeMode)), _sizeMode);
end;
function NSToolbar.sizeMode: NSToolbarSizeMode;
begin
Result := NSToolbarSizeMode(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_sizeMode)), []));
end;
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
procedure NSToolbar.setShowsBaselineSeparator(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setShowsBaselineSeparator)), _flag);
end;
function NSToolbar.showsBaselineSeparator: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_showsBaselineSeparator)), []));
end;
{.$endif}
procedure NSToolbar.setAllowsUserCustomization(_allowCustomization: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_allowCustomization: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setAllowsUserCustomization)), _allowCustomization);
end;
function NSToolbar.allowsUserCustomization: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_allowsUserCustomization)), []));
end;
function NSToolbar.identifier: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_identifier)), []));
end;
function NSToolbar.items: CFArrayRef;
begin
Result := CFArrayRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_items)), []));
end;
function NSToolbar.visibleItems: CFArrayRef;
begin
Result := CFArrayRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_visibleItems)), []));
end;
procedure NSToolbar.setAutosavesConfiguration(_flag: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_flag: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setAutosavesConfiguration)), _flag);
end;
function NSToolbar.autosavesConfiguration: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_autosavesConfiguration)), []));
end;
procedure NSToolbar.setConfigurationFromDictionary(_configDict: CFDictionaryRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_configDict: CFDictionaryRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbar_setConfigurationFromDictionary)), _configDict);
end;
function NSToolbar.configurationDictionary: CFDictionaryRef;
begin
Result := CFDictionaryRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_configurationDictionary)), []));
end;
procedure NSToolbar.validateVisibleItems;
begin
objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbar_validateVisibleItems)), []);
end;
{$endif}

View File

@ -0,0 +1,422 @@
{%mainunit appkit.pas}
(*
NSToolbarItem.h
Application Kit
Copyright (c) 2000-2004, Apple Computer, Inc.
All rights reserved.
*)
{$ifdef HEADER}
{$ifndef NSTOOLBARITEM_PAS_H}
{$define NSTOOLBARITEM_PAS_H}
{$include NSUserInterfaceValidation.inc}
{$include NSText.inc}
{$include NSToolbar.inc}
//APPKIT_EXTERN NSString *NSToolbarSeparatorItemIdentifier;
//APPKIT_EXTERN NSString *NSToolbarSpaceItemIdentifier;
//APPKIT_EXTERN NSString *NSToolbarFlexibleSpaceItemIdentifier;
//APPKIT_EXTERN NSString *NSToolbarShowColorsItemIdentifier; // Shows the color panel.
//APPKIT_EXTERN NSString *NSToolbarShowFontsItemIdentifier; // Shows the font panel.
//APPKIT_EXTERN NSString *NSToolbarCustomizeToolbarItemIdentifier; // Puts the current toolbar into customize mode.
//APPKIT_EXTERN NSString *NSToolbarPrintItemIdentifier; // Sends printDocument: to firstResponder, but you can change this in toolbarWillAddItem: if you need to do so.
const
NSToolbarItemVisibilityPriorityStandard = 0;
NSToolbarItemVisibilityPriorityLow = 1000;
NSToolbarItemVisibilityPriorityHigh = 1000;
NSToolbarItemVisibilityPriorityUser = 2000;
{$endif}
{$endif}
{$ifdef FORWARD}
NSToolbarItem = class;
{$endif}
{$ifdef CLASSES}
{$ifndef NSTOOLBARITEM_PAS_C}
{$define NSTOOLBARITEM_PAS_C}
{$include NSUserInterfaceValidation.inc}
{$include NSText.inc}
{$include NSToolbar.inc}
{ NSToolbarItem }
NSToolbarItem = class(NSObject)
public
class function getClass: objc.id; override;
constructor initWithItemIdentifier(_itemIdentifier: CFStringRef);
// Initialize the toolbar item with an identifier which is a development language string
// used by the toolbar and its delegate for identification purposes.
function itemIdentifier: CFStringRef;
function toolbar: objc.id;{NSToolbar}
// Use this to determine the toolbar in which an item is currently displayed.
// ----- Setters and Getters -----
procedure setLabel(__label: CFStringRef);
function label_: CFStringRef;
// Use this to set the item's label that appears in the toolbar. The implication here
// is that the toolbar will draw the label for the item, and a redraw is triggered by
// this method. The toolbar is in charge of the label area. It is fine for an item
// to have no toolbar label. Also, developers should make sure the length of the label
// is appropriate and not too long.
procedure setPaletteLabel(_paletteLabel: CFStringRef);
function paletteLabel: CFStringRef;
// Use this to set the item's label that appears when the item is in the customization
// palette. All Items must have a palette label, and for most things it is reasonable
// to set them to the same string as the label used in the toolbar.
procedure setToolTip(_toolTip: CFStringRef);
function toolTip: CFStringRef;
// Use this to set a tooltip to be used when the item is displayed in the toolbar.
// (forwards to -view if it responds)
procedure setMenuFormRepresentation(_menuItem: objc.id {NSMenuItem});
function menuFormRepresentation: objc.id;{NSMenuItem}
// The menu form of a toolbar item's purpose is twofold. First, when the window is
// too small to display an item, it will be clipped but remain accessible from a "clipped
// items" menu containing the menu item returned here. Second, in text only mode, the
// menu returned will be used to create the displayed items. Singleton menu items will
// be clickable, while submenu items will be represented as a pull down. For instance,
// say you want a button that allows you to switch between modes A, B, and C. You could
// represent this as a menu by : a menu item "mode" with three submenu items "A", "B",
// and "C". By default, this method returns a singleton menu item with item label
// as the title. For standard items, the target, action is set.
procedure setTag(_tag: Integer);
function tag: Integer;
// Tag for your own custom purpose. (forwards to -view if it responds)
procedure setTarget(_target: objc.id);
function target: objc.id;
// Set and get the action of an item. (forwards to -view if it responds)
procedure setAction(_action: SEL);
function action: SEL;
// Set and get the action of an item. For custom views, this method will call setAction:/action
// on the view if it responds. (forwards to -view if it responds)
procedure setEnabled(_enabled: LongBool);
function isEnabled: LongBool;
// Set and get the enabled flag of an item. For custom views, this method will call
// setEnabled:/isEnabled on the view if it responds. (forwards to -view if it responds)
procedure setImage(_image: objc.id {NSImage});
function image: objc.id;{NSImage}
// Set and get the image of an item. For custom views, this method will call setImage:/image
// on the view if it responds. (forwards to -view if it responds)
procedure setView(_view: objc.id {NSView});
function view: objc.id;{NSView}
// Use setView: if you want your toolbar item to use something other than the standard.
// Note that, by default, many of the set/get methods will be implemented by calls
// forwarded to the view you set, if it responds to it. Also, your view must be archivable
// (in order for the toolbar to make copies of your item to hand off to the config palette).
procedure setMinSize(_size: NSSize);
function minSize: NSSize;
// Unless you have already set your own custom view, you should not call this method.
// The min size should be small enough to look nice in all display modes.
procedure setMaxSize(_size: NSSize);
function maxSize: NSSize;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
procedure setVisibilityPriority(_visibilityPriority: Integer);
function visibilityPriority: Integer;
{.$endif}
// ----- Validation of the items -----
procedure validate;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
procedure setAutovalidates(_resistance: LongBool);
function autovalidates: LongBool;
{.$endif}
// ----- Controlling Duplicates In The Toolbar -----
function allowsDuplicatesInToolbar: LongBool;
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSToolbarItem_NSToolbarItem = 'NSToolbarItem';
StrNSToolbarItem_initWithItemIdentifier = 'initWithItemIdentifier:';
StrNSToolbarItem_itemIdentifier = 'itemIdentifier';
StrNSToolbarItem_toolbar = 'toolbar';
StrNSToolbarItem_setLabel = 'setLabel:';
StrNSToolbarItem_label = 'label';
StrNSToolbarItem_setPaletteLabel = 'setPaletteLabel:';
StrNSToolbarItem_paletteLabel = 'paletteLabel';
StrNSToolbarItem_setToolTip = 'setToolTip:';
StrNSToolbarItem_toolTip = 'toolTip';
StrNSToolbarItem_setMenuFormRepresentation = 'setMenuFormRepresentation:';
StrNSToolbarItem_menuFormRepresentation = 'menuFormRepresentation';
StrNSToolbarItem_setTag = 'setTag:';
StrNSToolbarItem_tag = 'tag';
StrNSToolbarItem_setTarget = 'setTarget:';
StrNSToolbarItem_target = 'target';
StrNSToolbarItem_setAction = 'setAction:';
StrNSToolbarItem_action = 'action';
StrNSToolbarItem_setEnabled = 'setEnabled:';
StrNSToolbarItem_isEnabled = 'isEnabled';
StrNSToolbarItem_setImage = 'setImage:';
StrNSToolbarItem_image = 'image';
StrNSToolbarItem_setView = 'setView:';
StrNSToolbarItem_view = 'view';
StrNSToolbarItem_setMinSize = 'setMinSize:';
StrNSToolbarItem_minSize = 'minSize';
StrNSToolbarItem_setMaxSize = 'setMaxSize:';
StrNSToolbarItem_maxSize = 'maxSize';
StrNSToolbarItem_setVisibilityPriority = 'setVisibilityPriority:';
StrNSToolbarItem_visibilityPriority = 'visibilityPriority';
StrNSToolbarItem_validate = 'validate';
StrNSToolbarItem_setAutovalidates = 'setAutovalidates:';
StrNSToolbarItem_autovalidates = 'autovalidates';
StrNSToolbarItem_allowsDuplicatesInToolbar = 'allowsDuplicatesInToolbar';
{ NSToolbarItem }
class function NSToolbarItem.getClass: objc.id;
begin
Result := objc_getClass(StrNSToolbarItem_NSToolbarItem);
end;
constructor NSToolbarItem.initWithItemIdentifier(_itemIdentifier: CFStringRef);
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_itemIdentifier: CFStringRef): objc.id; cdecl;
var
vmethod: TmsgSendWrapper;
begin
ClassID := getClass();
allocbuf := objc_msgSend(ClassID, sel_registerName(PChar(Str_alloc)), []);
vmethod := TmsgSendWrapper(@objc_msgSend);
Handle := vmethod(allocbuf, sel_registerName(PChar(StrNSToolbarItem_initWithItemIdentifier)), _itemIdentifier);
end;
function NSToolbarItem.itemIdentifier: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_itemIdentifier)), []));
end;
function NSToolbarItem.toolbar: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_toolbar)), []));
end;
procedure NSToolbarItem.setLabel(__label: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;__label: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setLabel)), __label);
end;
function NSToolbarItem.label_: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_label)), []));
end;
procedure NSToolbarItem.setPaletteLabel(_paletteLabel: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_paletteLabel: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setPaletteLabel)), _paletteLabel);
end;
function NSToolbarItem.paletteLabel: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_paletteLabel)), []));
end;
procedure NSToolbarItem.setToolTip(_toolTip: CFStringRef);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_toolTip: CFStringRef); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setToolTip)), _toolTip);
end;
function NSToolbarItem.toolTip: CFStringRef;
begin
Result := CFStringRef(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_toolTip)), []));
end;
procedure NSToolbarItem.setMenuFormRepresentation(_menuItem: objc.id {NSMenuItem});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_menuItem: objc.id {NSMenuItem}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setMenuFormRepresentation)), _menuItem);
end;
function NSToolbarItem.menuFormRepresentation: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_menuFormRepresentation)), []));
end;
procedure NSToolbarItem.setTag(_tag: Integer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_tag: Integer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setTag)), _tag);
end;
function NSToolbarItem.tag: Integer;
begin
Result := Integer(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_tag)), []));
end;
procedure NSToolbarItem.setTarget(_target: objc.id);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_target: objc.id); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setTarget)), _target);
end;
function NSToolbarItem.target: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_target)), []));
end;
procedure NSToolbarItem.setAction(_action: SEL);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_action: SEL); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setAction)), _action);
end;
function NSToolbarItem.action: SEL;
begin
Result := SEL(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_action)), []));
end;
procedure NSToolbarItem.setEnabled(_enabled: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_enabled: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setEnabled)), _enabled);
end;
function NSToolbarItem.isEnabled: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_isEnabled)), []));
end;
procedure NSToolbarItem.setImage(_image: objc.id {NSImage});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_image: objc.id {NSImage}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setImage)), _image);
end;
function NSToolbarItem.image: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_image)), []));
end;
procedure NSToolbarItem.setView(_view: objc.id {NSView});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_view: objc.id {NSView}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setView)), _view);
end;
function NSToolbarItem.view: objc.id;
begin
Result := objc.id(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_view)), []));
end;
procedure NSToolbarItem.setMinSize(_size: NSSize);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_size: NSSize); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setMinSize)), _size);
end;
function NSToolbarItem.minSize: NSSize;
begin
objc_msgSend_stret(@Result, Handle, sel_registerName(PChar(StrNSToolbarItem_minSize)), []);
end;
procedure NSToolbarItem.setMaxSize(_size: NSSize);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_size: NSSize); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setMaxSize)), _size);
end;
function NSToolbarItem.maxSize: NSSize;
begin
objc_msgSend_stret(@Result, Handle, sel_registerName(PChar(StrNSToolbarItem_maxSize)), []);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
procedure NSToolbarItem.setVisibilityPriority(_visibilityPriority: Integer);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_visibilityPriority: Integer); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setVisibilityPriority)), _visibilityPriority);
end;
function NSToolbarItem.visibilityPriority: Integer;
begin
Result := Integer(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_visibilityPriority)), []));
end;
{.$endif}
procedure NSToolbarItem.validate;
begin
objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_validate)), []);
end;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}
procedure NSToolbarItem.setAutovalidates(_resistance: LongBool);
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_resistance: LongBool); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSToolbarItem_setAutovalidates)), _resistance);
end;
function NSToolbarItem.autovalidates: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_autovalidates)), []));
end;
{.$endif}
function NSToolbarItem.allowsDuplicatesInToolbar: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSToolbarItem_allowsDuplicatesInToolbar)), []));
end;
{$endif}

View File

@ -23,16 +23,16 @@
{.$endif}
const
NSAppKitVersionNumberWithCustomSheetPosition = 686.0;
NSNormalWindowLevel = kCGNormalWindowLevel;
NSFloatingWindowLevel = kCGFloatingWindowLevel;
NSSubmenuWindowLevel = kCGTornOffMenuWindowLevel;
NSTornOffMenuWindowLevel = kCGTornOffMenuWindowLevel;
NSMainMenuWindowLevel = kCGMainMenuWindowLevel;
NSStatusWindowLevel = kCGStatusWindowLevel;
NSDockWindowLevel = kCGDockWindowLevel;
NSModalPanelWindowLevel = kCGModalPanelWindowLevel;
NSPopUpMenuWindowLevel = kCGPopUpMenuWindowLevel;
NSScreenSaverWindowLevel = kCGScreenSaverWindowLevel;
NSNormalWindowLevel = kCGNormalWindowLevelKey;
NSFloatingWindowLevel = kCGFloatingWindowLevelKey;
NSSubmenuWindowLevel = kCGTornOffMenuWindowLevelKey;
NSTornOffMenuWindowLevel = kCGTornOffMenuWindowLevelKey;
NSMainMenuWindowLevel = kCGMainMenuWindowLevelKey;
NSStatusWindowLevel = kCGStatusWindowLevelKey;
NSDockWindowLevel = kCGDockWindowLevelKey;
NSModalPanelWindowLevel = kCGModalPanelWindowLevelKey;
NSPopUpMenuWindowLevel = kCGPopUpMenuWindowLevelKey;
NSScreenSaverWindowLevel = kCGScreenSaverWindowLevelKey;
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2}
{.$endif}
{.$ifdef MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4}

View File

@ -15,7 +15,7 @@ unit appkit;
interface
uses ctypes, FPCMacOSAll, objc, foundation, cocoacoregraphics;
uses ctypes, MacOSAll, objc, foundation;
{$define HEADER}
{$include AppKit.inc}

View File

@ -5,6 +5,7 @@ APPKIT_INI="../build/appkit.ini"
FRAMEWORK="/System/Library/Frameworks/AppKit.framework/Headers"
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSApplication.h > ../appkit/NSApplication.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSBitmapImageRep.h > ../appkit/NSBitmapImageRep.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSBox.h > ../appkit/NSBox.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSButton.h > ../appkit/NSButton.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSControl.h > ../appkit/NSControl.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSGraphics.h > ../appkit/NSGraphics.inc
@ -13,12 +14,18 @@ FRAMEWORK="/System/Library/Frameworks/AppKit.framework/Headers"
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSImageRep.h > ../appkit/NSImageRep.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSMenu.h > ../appkit/NSMenu.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSMenuItem.h > ../appkit/NSMenuItem.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSNibDeclarations.h > ../appkit/NSNibDeclarations.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSOpenPanel.h > ../appkit/NSOpenPanel.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSPanel.h > ../appkit/NSPanel.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSSavePanel.h > ../appkit/NSSavePanel.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSSpellProtocol.h > ../appkit/NSSpellProtocol.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSStatusBar.h > ../appkit/NSStatusBar.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSStatusItem.h > ../appkit/NSStatusItem.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSText.h > ../appkit/NSText.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSTextField.h > ../appkit/NSTextField.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSTextFieldCell.h > ../appkit/NSTextFieldCell.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSTextFieldCell.h > ../appkit/NSTextFieldCell.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSToolbar.h > ../appkit/NSToolbar.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSToolbarItem.h > ../appkit/NSToolbarItem.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSUserInterfaceValidation.h > ../appkit/NSUserInterfaceValidation.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSView.h > ../appkit/NSView.inc
#./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSWindow.h > ../appkit/NSWindow.inc

View File

@ -4,6 +4,7 @@ DEFAULT_INI="default.ini"
LOCAL_INI="../build/foundation.ini"
FRAMEWORK="/System/Library/Frameworks/Foundation.framework/Headers"
#./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSObjCRuntime.h > ../foundation/NSObjCRuntime.inc
./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSArray.h > ../foundation/NSArray.inc
#./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSDate.h > ../foundation/NSDate.inc
./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSRange.h > ../foundation/NSRange.inc
./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSValue.h > ../foundation/NSValue.inc
#./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSRange.h > ../foundation/NSRange.inc
#./objcparser -ini=$DEFAULT_INI -ini=$LOCAL_INI $FRAMEWORK/NSValue.h > ../foundation/NSValue.inc

View File

@ -1,5 +1,5 @@
{ This file was automatically created by Lazarus. do not edit!
This source is only used to compile and install the package.
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit cocoa_pkg;
@ -7,7 +7,7 @@ unit cocoa_pkg;
interface
uses
appkit, foundation, objc, LazarusPackageIntf;
appkit, foundation, objc, LazarusPackageIntf;
implementation

View File

@ -11,7 +11,7 @@
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="simplewindow"/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="4"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -28,13 +28,18 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="55">
<RequiredPackages Count="1">
<Item1>
<PackageName Value="cocoa_pkg"/>
</Item1>
</RequiredPackages>
<Units Count="62">
<Unit0>
<Filename Value="simplewindow.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="simplewindow"/>
<CursorPos X="34" Y="64"/>
<TopLine Value="43"/>
<CursorPos X="14" Y="35"/>
<TopLine Value="28"/>
<EditorIndex Value="0"/>
<UsageCount Value="110"/>
<Loaded Value="True"/>
@ -42,11 +47,9 @@
<Unit1>
<Filename Value="../../appkit/appkit.pas"/>
<UnitName Value="appkit"/>
<CursorPos X="16" Y="26"/>
<CursorPos X="77" Y="22"/>
<TopLine Value="14"/>
<EditorIndex Value="3"/>
<UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../appkit/NSPanel.inc"/>
@ -62,11 +65,9 @@
</Unit3>
<Unit4>
<Filename Value="../../appkit/AppKit.inc"/>
<CursorPos X="7" Y="85"/>
<CursorPos X="88" Y="76"/>
<TopLine Value="70"/>
<EditorIndex Value="5"/>
<UsageCount Value="41"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../../../fpc/packages/extra/univint/FPCMacOSAll.pas"/>
@ -128,11 +129,9 @@
<Unit14>
<Filename Value="../../foundation/foundation.pas"/>
<UnitName Value="foundation"/>
<CursorPos X="15" Y="15"/>
<CursorPos X="60" Y="13"/>
<TopLine Value="5"/>
<EditorIndex Value="1"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSObject.h"/>
@ -143,11 +142,9 @@
</Unit15>
<Unit16>
<Filename Value="../../foundation/NSObject.inc"/>
<CursorPos X="1" Y="53"/>
<CursorPos X="65" Y="61"/>
<TopLine Value="53"/>
<EditorIndex Value="2"/>
<UsageCount Value="50"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="../../foundation/NSObject_impl.inc"/>
@ -157,9 +154,8 @@
</Unit17>
<Unit18>
<Filename Value="../../appkit/NSApplication.inc"/>
<CursorPos X="11" Y="152"/>
<TopLine Value="144"/>
<EditorIndex Value="10"/>
<CursorPos X="9" Y="1692"/>
<TopLine Value="1687"/>
<UsageCount Value="48"/>
<Loaded Value="True"/>
</Unit18>
@ -172,9 +168,8 @@
</Unit19>
<Unit20>
<Filename Value="../../appkit/NSWindow.inc"/>
<CursorPos X="31" Y="113"/>
<TopLine Value="107"/>
<EditorIndex Value="9"/>
<CursorPos X="9" Y="1692"/>
<TopLine Value="1687"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit20>
@ -288,11 +283,9 @@
</Unit37>
<Unit38>
<Filename Value="../../appkit/NSStatusBar.inc"/>
<CursorPos X="4" Y="10"/>
<CursorPos X="96" Y="30"/>
<TopLine Value="22"/>
<EditorIndex Value="4"/>
<UsageCount Value="52"/>
<Loaded Value="True"/>
</Unit38>
<Unit39>
<Filename Value="../../appkit/NSStatusItem.inc"/>
@ -323,19 +316,15 @@
</Unit42>
<Unit43>
<Filename Value="../../appkit/NSTextField.inc"/>
<CursorPos X="99" Y="5"/>
<CursorPos X="85" Y="5"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="50"/>
<Loaded Value="True"/>
</Unit43>
<Unit44>
<Filename Value="../../appkit/NSControl.inc"/>
<CursorPos X="51" Y="62"/>
<CursorPos X="82" Y="62"/>
<TopLine Value="57"/>
<EditorIndex Value="6"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit44>
<Unit45>
<Filename Value="/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSView.h"/>
@ -346,11 +335,9 @@
</Unit45>
<Unit46>
<Filename Value="../../appkit/NSView.inc"/>
<CursorPos X="9" Y="1692"/>
<CursorPos X="89" Y="1692"/>
<TopLine Value="1687"/>
<EditorIndex Value="11"/>
<UsageCount Value="39"/>
<Loaded Value="True"/>
</Unit46>
<Unit47>
<Filename Value="../../appkit/NSResponder.inc"/>
@ -396,14 +383,66 @@
</Unit53>
<Unit54>
<Filename Value="../../appkit/NSTextFieldCell.inc"/>
<CursorPos X="20" Y="44"/>
<CursorPos X="95" Y="39"/>
<TopLine Value="33"/>
<EditorIndex Value="8"/>
<UsageCount Value="10"/>
</Unit54>
<Unit55>
<Filename Value="../../../../../lazarus/lcl/interfaces/carbon/carboncanvas.pp"/>
<UnitName Value="CarbonCanvas"/>
<CursorPos X="58" Y="29"/>
<TopLine Value="23"/>
<UsageCount Value="10"/>
</Unit55>
<Unit56>
<Filename Value="../../../../../lazarus/lcl/lclproc.pas"/>
<UnitName Value="LCLProc"/>
<CursorPos X="8" Y="3188"/>
<TopLine Value="3174"/>
<EditorIndex Value="1"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit54>
</Unit56>
<Unit57>
<Filename Value="../../../../../lazarus/lcl/interfaces/wince/wincelistsl.inc"/>
<CursorPos X="86" Y="183"/>
<TopLine Value="180"/>
<UsageCount Value="10"/>
</Unit57>
<Unit58>
<Filename Value="../../../../../lazarus/lcl/interfaces/wince/winceint.pp"/>
<UnitName Value="WinCEInt"/>
<CursorPos X="81" Y="47"/>
<TopLine Value="44"/>
<UsageCount Value="10"/>
</Unit58>
<Unit59>
<Filename Value="../../../../../lazarus/lcl/stdactns.pas"/>
<UnitName Value="StdActns"/>
<CursorPos X="25" Y="979"/>
<TopLine Value="967"/>
<EditorIndex Value="2"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit59>
<Unit60>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/wstringh.inc"/>
<CursorPos X="16" Y="81"/>
<TopLine Value="69"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit60>
<Unit61>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/wstrings.inc"/>
<CursorPos X="19" Y="1508"/>
<TopLine Value="1510"/>
<EditorIndex Value="4"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit61>
</Units>
<JumpHistory Count="25" HistoryIndex="24">
<JumpHistory Count="12" HistoryIndex="11">
<Position1>
<Filename Value="simplewindow.pas"/>
<Caret Line="67" Column="13" TopLine="45"/>
@ -417,104 +456,49 @@
<Caret Line="6" Column="63" TopLine="1"/>
</Position3>
<Position4>
<Filename Value="../../foundation/foundation.pas"/>
<Caret Line="15" Column="15" TopLine="5"/>
<Filename Value="simplewindow.pas"/>
<Caret Line="22" Column="29" TopLine="9"/>
</Position4>
<Position5>
<Filename Value="../../foundation/NSObject.inc"/>
<Caret Line="64" Column="16" TopLine="49"/>
<Filename Value="simplewindow.pas"/>
<Caret Line="66" Column="39" TopLine="46"/>
</Position5>
<Position6>
<Filename Value="../../foundation/NSObject.inc"/>
<Caret Line="67" Column="21" TopLine="59"/>
<Filename Value="simplewindow.pas"/>
<Caret Line="65" Column="23" TopLine="53"/>
</Position6>
<Position7>
<Filename Value="../../foundation/NSObject.inc"/>
<Filename Value="../../../../../lazarus/lcl/lclproc.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="../../foundation/NSObject.inc"/>
<Caret Line="306" Column="1" TopLine="281"/>
<Filename Value="../../../../../lazarus/lcl/stdactns.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="../../foundation/NSObject.inc"/>
<Caret Line="55" Column="1" TopLine="53"/>
<Filename Value="../../../../../lazarus/lcl/stdactns.pas"/>
<Caret Line="979" Column="25" TopLine="967"/>
</Position9>
<Position10>
<Filename Value="../../foundation/NSObject.inc"/>
<Caret Line="306" Column="1" TopLine="281"/>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/wstrings.inc"/>
<Caret Line="1625" Column="14" TopLine="1612"/>
</Position10>
<Position11>
<Filename Value="../../appkit/appkit.pas"/>
<Caret Line="26" Column="16" TopLine="14"/>
<Filename Value="../../../../../lazarus/lcl/lclproc.pas"/>
<Caret Line="3216" Column="16" TopLine="3200"/>
</Position11>
<Position12>
<Filename Value="../../appkit/AppKit.inc"/>
<Caret Line="91" Column="13" TopLine="68"/>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/wstrings.inc"/>
<Caret Line="1625" Column="13" TopLine="1612"/>
</Position12>
<Position13>
<Filename Value="../../appkit/NSView.inc"/>
<Caret Line="85" Column="24" TopLine="66"/>
</Position13>
<Position14>
<Filename Value="../../appkit/NSView.inc"/>
<Caret Line="78" Column="18" TopLine="65"/>
</Position14>
<Position15>
<Filename Value="../../appkit/NSView.inc"/>
<Caret Line="285" Column="38" TopLine="272"/>
</Position15>
<Position16>
<Filename Value="../../appkit/NSView.inc"/>
<Caret Line="456" Column="23" TopLine="443"/>
</Position16>
<Position17>
<Filename Value="../../appkit/NSView.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position17>
<Position18>
<Filename Value="../../appkit/NSWindow.inc"/>
<Caret Line="112" Column="21" TopLine="106"/>
</Position18>
<Position19>
<Filename Value="../../appkit/AppKit.inc"/>
<Caret Line="86" Column="15" TopLine="62"/>
</Position19>
<Position20>
<Filename Value="../../appkit/AppKit.inc"/>
<Caret Line="17" Column="19" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="simplewindow.pas"/>
<Caret Line="22" Column="29" TopLine="9"/>
</Position21>
<Position22>
<Filename Value="simplewindow.pas"/>
<Caret Line="66" Column="39" TopLine="46"/>
</Position22>
<Position23>
<Filename Value="simplewindow.pas"/>
<Caret Line="65" Column="23" TopLine="53"/>
</Position23>
<Position24>
<Filename Value="../../appkit/NSTextField.inc"/>
<Caret Line="71" Column="28" TopLine="63"/>
</Position24>
<Position25>
<Filename Value="../../appkit/NSTextFieldCell.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position25>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<Version Value="8"/>
<SearchPaths>
<OtherUnitFiles Value="../../appkit/;../../../objc/;../../foundation/;../../applicationservices/coregraphics/"/>
<SrcPath Value="../../appkit/;../../../objc/;../../foundation/;../../applicationservices/coregraphics/"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking>
<Options>
<PassLinkerOptions Value="True"/>

View File

@ -18,7 +18,12 @@ program simplewindow;
{$ifdef fpc}{$mode delphi}{$endif}
uses
objc, ctypes, FPCMacOSAll, AppKit, Foundation;
{$ifdef ver2_2_0}
FPCMacOSAll,
{$else}
MacOSAll,
{$endif}
objc, ctypes, AppKit, Foundation, cocoa_pkg;
const
Str_Window_Title = 'Pascal Cocoa Example';

View File

@ -12,7 +12,7 @@ unit controller;
interface
uses
Classes, SysUtils, foundation, objc, appkit, FPCMacOSAll;
Classes, SysUtils, foundation, objc, appkit, MacOSAll;
type
@ -24,8 +24,8 @@ type
constructor Create; override;
procedure AddMethods; override;
{ Objective-c Methods }
class procedure doShowStatusitem(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; static;
class procedure doHideStatusitem(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; static;
class procedure doShowStatusitem(_self: objc.id; _cmd: objc.SEL; sender: objc.id); cdecl; static;
class procedure doHideStatusitem(_self: objc.id; _cmd: objc.SEL; sender: objc.id); cdecl; static;
class procedure doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; static;
class function applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
_cmd: SEL; theApplication: objc.id): cbool; cdecl; static;
@ -100,7 +100,7 @@ end;
{ Objective-c Methods }
class procedure TMyController.doShowStatusitem(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl;
class procedure TMyController.doShowStatusitem(_self: objc.id; _cmd: objc.SEL; sender: objc.id); cdecl;
begin
if myController.item <> nil then Exit;
@ -111,7 +111,7 @@ begin
myController.item.setMenu(myController.myMenu.Handle);
end;
class procedure TMyController.doHideStatusitem(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl;
class procedure TMyController.doHideStatusitem(_self: objc.id; _cmd: objc.SEL; sender: objc.id); cdecl;
begin
if myController.item = nil then Exit;
@ -120,7 +120,7 @@ begin
myController.item := nil;
end;
class procedure TMyController.doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl;
class procedure TMyController.doClose(_self: objc.id; _cmd: objc.SEL; sender: objc.id); cdecl;
begin
MainWindow.close;
end;

View File

@ -43,10 +43,7 @@
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Version Value="8"/>
<Linking>
<Options>
<PassLinkerOptions Value="True"/>

View File

@ -19,7 +19,7 @@ program statusitem;
{$linklib objc}
uses
objc, ctypes, FPCMacOSAll, AppKit, Foundation, controller, cocoa_pkg;
objc, ctypes, MacOSAll, AppKit, Foundation, controller, cocoa_pkg;
const
Str_Window_Title = 'StatusItem example project';

View File

@ -0,0 +1,4 @@
rm *.o
rm *.ppu
rm *.bak
rm *.compiled

View File

@ -0,0 +1,115 @@
{
controller.pas
This example project is released under public domain
AUTHORS: Felipe Monteiro de Carvalho
}
unit controller;
{$mode delphi}{$STATIC ON}
interface
uses
Classes, SysUtils, foundation, objc, appkit, MacOSAll;
type
{ TMyController }
TMyController = class(NSObject)
public
{ Extra binding functions }
constructor Create; override;
procedure AddMethods; override;
{ Objective-c Methods }
class procedure doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; //static;
class procedure doOpenFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; //static;
class procedure doSaveFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; //static;
class procedure doSaveFileAs(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; //static;
class function applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
_cmd: SEL; theApplication: objc.id): cbool; cdecl; //static;
end;
const
Str_doClose = 'doClose:';
Str_doOpenFile = 'doOpenFile:';
Str_doSaveFile = 'doSaveFile:';
Str_doSaveFileAs = 'doSaveFileAs:';
Str_applicationShouldTerminateAfterLastWindowClosed = 'applicationShouldTerminateAfterLastWindowClosed:';
var
myController: TMyController;
implementation
uses view;
{ TMyController }
{@@
Adds methods to the class
Details of the parameters string:
The first parameter is the result (v = void),
followed by self and _cmd (@ = id and : = SEL),
and on the end "sender" (@ = id)
}
procedure TMyController.AddMethods;
begin
AddMethod(Str_doClose, 'v@:@', Pointer(doClose));
AddMethod(Str_doOpenFile, 'v@:@', Pointer(doOpenFile));
AddMethod(Str_doSaveFile, 'v@:@', Pointer(doSaveFile));
AddMethod(Str_doSaveFileAs, 'v@:@', Pointer(doSaveFileAs));
AddMethod(Str_applicationShouldTerminateAfterLastWindowClosed, 'b@:@',
Pointer(applicationShouldTerminateAfterLastWindowClosed));
end;
constructor TMyController.Create;
begin
{ The class is registered on the Objective-C runtime before the NSObject constructor is called }
if not CreateClassDefinition(ClassName(), Str_NSObject) then WriteLn('Failed to create objc class ' + ClassName());
inherited Create;
end;
{ Objective-c Methods }
class procedure TMyController.doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl;
begin
myView.MainWindow.close;
end;
class procedure TMyController.doOpenFile(_self: objc.id; _cmd: SEL;
sender: objc.id); cdecl;
begin
{ Show dialog }
{ Now move the contents of the file to the edit control }
end;
class procedure TMyController.doSaveFile(_self: objc.id; _cmd: SEL;
sender: objc.id); cdecl;
begin
end;
class procedure TMyController.doSaveFileAs(_self: objc.id; _cmd: SEL;
sender: objc.id); cdecl;
begin
end;
class function TMyController.applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
_cmd: SEL; theApplication: objc.id): cbool; cdecl;
begin
Result := objc.YES;
end;
end.

View File

@ -0,0 +1,57 @@
#!/bin/sh
# Force Bourne shell in case tcsh is default.
#
appname=texteditor
appfolder=$appname.app
macosfolder=$appfolder/Contents/MacOS
plistfile=$appfolder/Contents/Info.plist
appfile=texteditor
#
if ! [ -e $appfile ]
then
echo "$appfile does not exist"
elif [ -e $appfolder ]
then
echo "$appfolder already exists"
else
echo "Creating $appfolder..."
mkdir $appfolder
mkdir $appfolder/Contents
mkdir $appfolder/Contents/MacOS
mkdir $appfolder/Contents/Resources
#
# Instead of copying executable into .app folder after each compile,
# simply create a symbolic link to executable.
ln -s ../../../$appname $macosfolder/$appname
# Copy resource files
cp imgOpen.png $appfolder/Contents/Resources/
cp imgSave.png $appfolder/Contents/Resources/
cp imgClose.png $appfolder/Contents/Resources/
#
# Create PkgInfo file.
echo "APPLMAG#" >$appfolder/Contents/PkgInfo
#
# Create information property list file (Info.plist).
echo '<?xml version="1.0" encoding="UTF-8"?>' >$plistfile
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >>$plistfile
echo '<plist version="1.0">' >>$plistfile
echo '<dict>' >>$plistfile
echo ' <key>CFBundleDevelopmentRegion</key>' >>$plistfile
echo ' <string>English</string>' >>$plistfile
echo ' <key>CFBundleExecutable</key>' >>$plistfile
echo ' <string>'$appname'</string>' >>$plistfile
echo ' <key>CFBundleIconFile</key>' >>$plistfile
echo ' <string></string>' >>$plistfile
echo ' <key>CFBundleIdentifier</key>' >>$plistfile
echo ' <string>org.magnifier.magnifier</string>' >>$plistfile
echo ' <key>CFBundleInfoDictionaryVersion</key>' >>$plistfile
echo ' <string>6.0</string>' >>$plistfile
echo ' <key>CFBundlePackageType</key>' >>$plistfile
echo ' <string>APPL</string>' >>$plistfile
echo ' <key>CFBundleSignature</key>' >>$plistfile
echo ' <string>MAG#</string>' >>$plistfile
echo ' <key>CFBundleVersion</key>' >>$plistfile
echo ' <string>1.0</string>' >>$plistfile
echo '</dict>' >>$plistfile
echo '</plist>' >>$plistfile
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

View File

@ -0,0 +1,71 @@
unit model;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
MacOSAll, objc, appkit, foundation;
type
{ TMyModel }
TMyModel = class
private
procedure LoadImages;
function GetResourcesDir: string;
public
{ Routines and variables for program resources }
imgOpen, imgSave, imgClose: NSImage;
ResourcesDir: string;
constructor Create;
end;
var
myModel: TMyModel;
implementation
procedure TMyModel.LoadImages;
var
ImagePath: CFStringRef;
begin
ImagePath := CFStringCreateWithPascalString(nil, ResourcesDir + 'imgOpen.png', kCFStringEncodingUTF8);
imgOpen := NSImage.initWithContentsOfFile(ImagePath);
ImagePath := CFStringCreateWithPascalString(nil, ResourcesDir + 'imgSave.png', kCFStringEncodingUTF8);
imgSave := NSImage.initWithContentsOfFile(ImagePath);
ImagePath := CFStringCreateWithPascalString(nil, ResourcesDir + 'imgClose.png', kCFStringEncodingUTF8);
imgClose := NSImage.initWithContentsOfFile(ImagePath);
end;
function TMyModel.GetResourcesDir: string;
const
BundleResourcesDirectory = '/Contents/Resources/';
var
pathRef: CFURLRef;
pathCFStr: CFStringRef;
pathStr: shortstring;
begin
// Under Mac OS X we need to get the location of the bundle
pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
CFRelease(pathRef);
CFRelease(pathCFStr);
Result := pathStr + BundleResourcesDirectory;
end;
constructor TMyModel.Create;
begin
LoadImages;
ResourcesDir := GetResourcesDir;
end;
end.

View File

@ -0,0 +1,133 @@
unit mytoolbar;
{$mode delphi}{$STATIC ON}
interface
uses
MacOSAll, objc, appkit, foundation;
type
{ TMyToolbarController }
TMyToolbarController = class(NSObject)
public
{ Extra binding functions }
constructor Create; override;
procedure AddMethods; override;
{ Objective-c Methods }
// class procedure doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; //static;
class function toolbarAllowedItemIdentifiers(_self: objc.id;
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl;// static;
class function toolbarDefaultItemIdentifiers(_self: objc.id;
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl;// static;
class function toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar
(_self: objc.id; _cmd: SEL; toolbar: objc.id;
itemIdentifier: CFStringRef; flag: CBOOL): objc.id; cdecl;// static;
end;
const
Str_toolbarAllowedItemIdentifiers = 'toolbarAllowedItemIdentifiers:';
Str_toolbarDefaultItemIdentifiers = 'toolbarDefaultItemIdentifiers:';
Str_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar = 'toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:';
var
OpenToolbarItemIdentifier, SaveToolbarItemIdentifier, CloseToolbarItemIdentifier: CFStringRef;
implementation
uses
model, controller;
{ TMyToolbar }
constructor TMyToolbarController.Create;
begin
{ The class is registered on the Objective-C runtime before the NSObject constructor is called }
if not CreateClassDefinition(ClassName(), Str_NSObject) then WriteLn('Failed to create objc class ' + ClassName());
inherited Create;
{ Prepare CFStringRefs for the constants }
OpenToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'OpenID', kCFStringEncodingUTF8);
SaveToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'SaveID', kCFStringEncodingUTF8);
CloseToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'CloseID', kCFStringEncodingUTF8);
end;
procedure TMyToolbarController.AddMethods;
begin
AddMethod(Str_toolbarAllowedItemIdentifiers, '@@:@', Pointer(toolbarAllowedItemIdentifiers));
AddMethod(Str_toolbarDefaultItemIdentifiers, '@@:@', Pointer(toolbarDefaultItemIdentifiers));
// AddMethod(Str_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar,
// '@@:@@L', Pointer(toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar));
end;
class function TMyToolbarController.toolbarAllowedItemIdentifiers(_self: objc.id;
_cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl;
var
toolbarItems: array[0..4] of CFStringRef;
begin
toolbarItems[0] := OpenToolbarItemIdentifier;
toolbarItems[1] := SaveToolbarItemIdentifier;
// toolbarItems[2] := NSToolbarSpaceItemIdentifier;
toolbarItems[2] := CloseToolbarItemIdentifier;
toolbarItems[3] := nil;
toolbarItems[4] := nil;
Result := CFArrayCreate(nil, @toolbarItems[0], 4, nil);
end;
class function TMyToolbarController.toolbarDefaultItemIdentifiers(_self: objc.id;
_cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl;
begin
Result := toolbarAllowedItemIdentifiers(_self, _cmd, toolbar);
end;
class function TMyToolbarController.toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(_self: objc.id;
_cmd: SEL; toolbar: objc.id {NSToolbar}; itemIdentifier: CFStringRef;
flag: CBOOL): objc.id {NSToolbarItem}; cdecl;
var
toolbarItem: NSToolbarItem;
begin
if CFStringCompare(itemIdentifier, OpenToolbarItemIdentifier, kCFCompareCaseInsensitive) = kCFCompareEqualTo then
begin
toolbarItem := NSToolbarItem.initWithItemIdentifier(itemIdentifier);
// [toolbarItem setLabel:@"Save"];
// [toolbarItem setPaletteLabel:[toolbarItem label]];
// [toolbarItem setToolTip:@"Save Your Passwords"];}
toolbarItem.setImage(myModel.imgOpen.Handle);
toolbarItem.setTarget(myController.Handle);
toolbarItem.setAction(sel_registerName(PChar('doOpenFile:')));
end
else if CFStringCompare(itemIdentifier, SaveToolbarItemIdentifier, kCFCompareCaseInsensitive) = kCFCompareEqualTo then
begin
toolbarItem := NSToolbarItem.initWithItemIdentifier(itemIdentifier);
toolbarItem.setImage(myModel.imgSave.Handle);
toolbarItem.setTarget(myController.Handle);
toolbarItem.setAction(sel_registerName(PChar('doSaveFile:')));
end
else if CFStringCompare(itemIdentifier, CloseToolbarItemIdentifier, kCFCompareCaseInsensitive) = kCFCompareEqualTo then
begin
toolbarItem := NSToolbarItem.initWithItemIdentifier(itemIdentifier);
toolbarItem.setImage(myModel.imgClose.Handle);
toolbarItem.setTarget(myController.Handle);
toolbarItem.setAction(sel_registerName(PChar('doCloseFile:')));
end
else
begin
Result := nil;
Exit
end;
Result := ToolbarItem.autorelease;
{ ToolbarItem.Handle := 0;
ToolbarItem.Free;}
// Result := Result. [toolbarItem autorelease];
end;
end.

View File

@ -0,0 +1,66 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<Version Value="6"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="cocoa_pkg"/>
</Item1>
</RequiredPackages>
<Units Count="5">
<Unit0>
<Filename Value="texteditor.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="texteditor"/>
</Unit0>
<Unit1>
<Filename Value="model.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="model"/>
</Unit1>
<Unit2>
<Filename Value="view.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="view"/>
</Unit2>
<Unit3>
<Filename Value="controller.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="controller"/>
</Unit3>
<Unit4>
<Filename Value="mytoolbar.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mytoolbar"/>
</Unit4>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,63 @@
{
texteditor.pas
This example shows how to create a simple text editor with PasCocoa
This example project is released under public domain
AUTHORS: Felipe Monteiro de Carvalho
}
program texteditor;
{$mode delphi}
{$linkframework Cocoa}
{$linklib objc}
uses
Math,
objc, ctypes, MacOSAll, AppKit, Foundation,
controller, model, view,
cocoa_pkg, mytoolbar;
var
pool: NSAutoreleasePool;
begin
{ Avoids arithmetic exceptions in Objective-C code }
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
{ Creates the AutoreleasePool }
pool := NSAutoreleasePool.Create;
{ Creates the application NSApp object }
NSApp := NSApplication.sharedApplication;
{ Initializes the controller, view and model objects }
myController := TMyController.Create();
myModel := TMyModel.Create();
myView := TMyView.Create();
{ Creates the user interface }
myView.CreateUserInterface();
myView.MainWindow.orderFrontRegardless;
{ Enters main message loop }
NSApp.setDelegate(myController.Handle);
NSApp.run;
{ Releases all objects }
myController.Free;
myModel.Free;
myView.Free;
{ Releases the AutoreleasePool }
pool.Free;
end.

View File

@ -0,0 +1,160 @@
unit view;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
MacOSAll, appkit, foundation, objc,
mytoolbar;
type
{ TMyView }
TMyView = class
private
{ Other helper functions }
function CreateToolbar(AOwnerView: NSView; AX, AY, AWidth, AHeight: Double): NSToolbar;
function CreateMainMenu(): NSMenu;
function CreateMenuItem(ATitle: shortstring;
ACallbackName: string; ACallbackClass: NSObject): NSMenuItem;
function CreateTextField(): NSTextField;
public
{ classes }
MainWindow: NSWindow;
MainWindowView: NSView;
Toolbar: NSToolbar;
ToolbarController: TMyToolbarController;
MainMenu: NSMenu;
TextField: NSTextField;
FileMenuItem, OpenItem, SaveItem, SaveAsItem, ExitItem: NSMenuItem;
FileMenu: NSMenu;
{ strings and sizes}
CFWindowTitle, CFEmptyString: CFStringRef;
MainWindowRect: NSRect;
MenuTitle: CFStringRef;
{ methods }
procedure CreateUserInterface();
end;
var
myView: TMyView;
const
Str_Window_Title = 'Text Editor';
implementation
uses controller, model;
{@@
}
procedure TMyView.CreateUserInterface();
begin
CFEmptyString := CFStringCreateWithPascalString(nil, '', kCFStringEncodingUTF8);
{ Creates the main window }
MainWindowRect.origin.x := 300.0;
MainWindowRect.origin.y := 300.0;
MainWindowRect.size.width := 300.0;
MainWindowRect.size.height := 500.0;
MainWindow := NSWindow.initWithContentRect_styleMask_backing_defer(MainWindowRect,
NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask or NSResizableWindowMask,
NSBackingStoreBuffered, LongBool(NO));
MainWindowView := NSView.CreateWithHandle(MainWindow.contentView);
CFWindowTitle := CFStringCreateWithPascalString(nil, Str_Window_Title, kCFStringEncodingUTF8);
MainWindow.setTitle(CFWindowTitle);
{ Adds the toolbar and it's buttons }
Toolbar := CreateToolbar(MainWindowView, 0, MainWindowRect.size.height - 50, MainWindowRect.size.width, 50);
MainWindow.setToolbar(Toolbar.Handle);
{ Add the text area }
TextField := CreateTextField();
{ Add the main menu }
MainMenu := CreateMainMenu();
NSApp.setAppleMenu(MainMenu.Handle);
NSApp.setMainMenu(MainMenu.Handle);
end;
{@@
}
function TMyView.CreateToolbar(AOwnerView: NSView; AX, AY, AWidth,
AHeight: Double): NSToolbar;
begin
Result := NSToolbar.initWithIdentifier(CFEmptyString);
ToolbarController := TMyToolbarController.Create;
Result.setDelegate(ToolbarController.Handle);
end;
{@@
}
function TMyView.CreateMainMenu(): NSMenu;
begin
MenuTitle := CFStringCreateWithPascalString(nil, 'Title', kCFStringEncodingUTF8);
WriteLn('CreateMenu');
Result := NSMenu.initWithTitle(CFEmptyString);
WriteLn('Menu Created');
{ Creates the file menu }
FileMenu := NSMenu.initWithTitle(MenuTitle);
FileMenuItem := NSMenuItem.initWithTitle_action_keyEquivalent(CFEmptyString, nil, CFEmptyString);
FileMenuItem.setSubmenu(FileMenu.Handle);
Result.addItem(FileMenuItem.Handle);
{ Adds items to it }
OpenItem := CreateMenuItem('Open', 'doOpenFile:', myController);
FileMenu.addItem(OpenItem.Handle);
OpenItem := CreateMenuItem('Save', 'doSaveFile:', myController);
FileMenu.addItem(OpenItem.Handle);
OpenItem := CreateMenuItem('Save As', 'doSaveFileAs:', myController);
FileMenu.addItem(OpenItem.Handle);
OpenItem := CreateMenuItem('Exit', 'doClose:', myController);
FileMenu.addItem(OpenItem.Handle);
end;
{@@
}
function TMyView.CreateMenuItem(ATitle: shortstring;
ACallbackName: string; ACallbackClass: NSObject): NSMenuItem;
var
ItemText: CFStringRef;
KeyText: CFStringRef;
begin
KeyText := CFStringCreateWithPascalString(nil, '', kCFStringEncodingUTF8);
ItemText := CFStringCreateWithPascalString(nil, ATitle, kCFStringEncodingUTF8);
WriteLn(' ItemText: ', IntToHex(Int64(ItemText), 8), ' ATitle: ', ATitle);
Result := NSMenuItem.initWithTitle_action_keyEquivalent(ItemText, nil, KeyText);
Result.setTarget(ACallbackClass.Handle);
Result.setAction(sel_registerName(PChar(ACallbackName)));
end;
function TMyView.CreateTextField(): NSTextField;
var
ClientRect: NSRect;
begin
ClientRect.origin.x := 0.0;
ClientRect.origin.y := 0.0;
ClientRect.size.width := 300.0;
ClientRect.size.height := 500.0;
Result := NSTextField.initWithFrame(ClientRect);
MainWindowView.addSubview(Result.Handle);
end;
end.

View File

@ -11,9 +11,9 @@
{$include NSObjCRuntime.inc}
{#import <Foundation/NSAffineTransform.h>
#import <Foundation/NSArchiver.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAttributedString.h> }
#import <Foundation/NSArchiver.h>}
{.$include NSArray.inc} // Use CFArrayRef
{#import <Foundation/NSAttributedString.h> }
{$include NSAutoreleasePool.inc}
{#import <Foundation/NSBundle.h>
#import <Foundation/NSByteOrder.h>

View File

@ -23,6 +23,7 @@ const
Str_retain = 'retain';
Str_release = 'release';
Str_autorelease = 'autorelease';
{*********** Object Allocation / Deallocation *******}
@ -139,8 +140,8 @@ FOUNDATION_EXPORT unsigned NSExtraRefCount(id object);}
function retain: objc.id;
procedure release;
{- (id)autorelease;
- (unsigned)retainCount;
function autorelease: objc.id;
{- (unsigned)retainCount;
- (NSString *)description;
@ -302,5 +303,10 @@ begin
objc_msgSend(Handle, sel_registerName(PChar(Str_release)), []);
end;
function NSObject.autorelease: objc.id;
begin
Result := objc_msgSend(Handle, sel_registerName(PChar(Str_autorelease)), []);
end;
{$endif}

View File

@ -9,7 +9,7 @@ unit foundation;
interface
uses SysUtils, ctypes, objc, FPCMacOSAll;
uses SysUtils, ctypes, objc, MacOSAll;
{$define HEADER}
{$include Foundation.inc}