Improves Cocoa bindings

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@458 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2008-06-06 01:32:06 +00:00
parent 3747542709
commit 8562b56ece
7 changed files with 1072 additions and 418 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
{%mainunit appkit.pas}
{
(*
NSStatusBar.h
Application Kit
Copyright (c) 1997-2005, Apple Computer, Inc.
All rights reserved.
}
*)
{$ifdef HEADER}
{$ifndef NSSTATUSBAR_PAS_H}
@ -12,73 +12,93 @@
const
NSVariableStatusItemLength = (-1);
NSSquareStatusItemLength = (-2);
{ Class and method name strings }
const
Str_NSStatusBar = 'NSStatusBar';
Str_systemStatusBar = 'systemStatusBar';
Str_statusItemWithLength = 'statusItemWithLength:';
NSSquareStatusItemLength = (-2);
{$endif}
{$endif}
{$ifdef FORWARD}
{$ifndef NSSTATUSBAR_PAS__FORWARD}
{$define NSSTATUSBAR_PAS__FORWARD}
NSStatusBar = class;
{$endif}
{$endif}
{$ifdef CLASSES}
{$ifndef NSSTATUSBAR_PAS_C}
{$define NSSTATUSBAR_PAS_C}
{@class NSColor;
@class NSFont;}
NSStatusItem = class;
{@class NSMutableArray;}
{ NSStatusBar }
NSStatusBar = class(NSObject)
public
{ Extra binding functions }
class function getClass: objc.id; override;
public
constructor systemStatusBar();
function statusItemWithLength(length: cfloat): NSStatusItem;
procedure removeStatusItem(item: NSStatusItem);
{- (BOOL) isVertical;
- (float) thickness;}
constructor systemStatusBar;
function statusItemWithLength(_length: Single): objc.id;{NSStatusItem}
procedure removeStatusItem(_item: objc.id {NSStatusItem});
function isVertical: LongBool;
function thickness: Single;
end;
{$endif}
{$endif}
{$ifdef IMPLEMENTATION}
const
StrNSStatusBar_NSStatusBar = 'NSStatusBar';
StrNSStatusBar_systemStatusBar = 'systemStatusBar';
StrNSStatusBar_statusItemWithLength = 'statusItemWithLength:';
StrNSStatusBar_removeStatusItem = 'removeStatusItem:';
StrNSStatusBar_isVertical = 'isVertical';
StrNSStatusBar_thickness = 'thickness';
{ NSStatusBar }
class function NSStatusBar.getClass: objc.id;
begin
Result := objc_getClass(Str_NSStatusBar);
Result := objc_getClass(StrNSStatusBar_NSStatusBar);
end;
constructor NSStatusBar.systemStatusBar();
begin
ClassId := getClass();
Handle := objc_msgSend(ClassId, sel_registerName(PChar(Str_systemStatusBar)), []);
end;
function NSStatusBar.statusItemWithLength(length: cfloat): NSStatusItem;
constructor NSStatusBar.systemStatusBar;
type
statusItemWithLength_t = function (param1: objc.id; param2: SEL;
param3: cfloat): objc.id; cdecl;
TmsgSendWrapper = function (param1: objc.id; param2: SEL): objc.id; cdecl;
var
vmethod: statusItemWithLength_t;
itemHandle: objc.id;
vmethod: TmsgSendWrapper;
begin
vmethod := statusItemWithLength_t(@objc_msgSend);
itemHandle := vmethod(Handle, sel_registerName(PChar(Str_statusItemWithLength)), length);
Result := NSStatusItem.CreateWithHandle(itemHandle);
ClassID := getClass();
vmethod := TmsgSendWrapper(@objc_msgSend);
Handle := vmethod(ClassID, sel_registerName(PChar(StrNSStatusBar_systemStatusBar)));
end;
procedure NSStatusBar.removeStatusItem(item: NSStatusItem);
function NSStatusBar.statusItemWithLength(_length: Single): objc.id;
type
TmsgSendWrapper = function (param1: objc.id; param2: SEL;_length: Single): objc.id; cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
Result := objc.id(vmethod(Handle, sel_registerName(PChar(StrNSStatusBar_statusItemWithLength)), _length));
end;
procedure NSStatusBar.removeStatusItem(_item: objc.id {NSStatusItem});
type
TmsgSendWrapper = procedure (param1: objc.id; param2: SEL;_item: objc.id {NSStatusItem}); cdecl;
var
vmethod: TmsgSendWrapper;
begin
vmethod := TmsgSendWrapper(@objc_msgSend);
vmethod(Handle, sel_registerName(PChar(StrNSStatusBar_removeStatusItem)), _item);
end;
function NSStatusBar.isVertical: LongBool;
begin
Result := LongBool(objc_msgSend(Handle, sel_registerName(PChar(StrNSStatusBar_isVertical)), []));
end;
function NSStatusBar.thickness: Single;
begin
Result := Single(objc_msgSend(Handle, sel_registerName(PChar(StrNSStatusBar_thickness)), []));
end;
{$endif}

View File

@ -3,10 +3,13 @@ cd parser
DEFAULT_INI="default.ini"
APPKIT_INI="../build/appkit.ini"
FRAMEWORK="/System/Library/Frameworks/AppKit.framework/Headers"
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSButton.h > ../appkit/NSButton.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSWindow.h > ../appkit/NSWindow.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSGraphics.h > ../appkit/NSGraphics.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSImage.h > ../appkit/NSImage.inc
./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/NSImageRep.h > ../appkit/NSImageRep.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSButton.h > ../appkit/NSButton.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSGraphics.h > ../appkit/NSGraphics.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSGraphicsContext.h > ../appkit/NSGraphicsContext.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSImage.h > ../appkit/NSImage.inc
./objcparser -ini=$DEFAULT_INI -ini=$APPKIT_INI $FRAMEWORK/NSImageRep.h > ../appkit/NSImageRep.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/NSWindow.h > ../appkit/NSWindow.inc

View File

@ -110,7 +110,7 @@ class procedure TMyController.doShowStatusitem(_self: objc.id; _cmd: SEL; sender
begin
if myController.item <> nil then Exit;
myController.item := myController.bar.statusItemWithLength(NSSquareStatusItemLength);
myController.item := NSStatusItem.CreateWithHandle(myController.bar.statusItemWithLength(NSSquareStatusItemLength));
myController.item.retain();
myController.item.setImage(myController.image);
end;

View File

@ -7,7 +7,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="5"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -26,15 +26,15 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="65">
<Units Count="66">
<Unit0>
<Filename Value="statusitem.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="statusitem"/>
<CursorPos X="1" Y="29"/>
<TopLine Value="11"/>
<CursorPos X="40" Y="70"/>
<TopLine Value="52"/>
<EditorIndex Value="0"/>
<UsageCount Value="58"/>
<UsageCount Value="62"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -48,20 +48,22 @@
<Filename Value="../../appkit/NSButton.inc"/>
<CursorPos X="3" Y="109"/>
<TopLine Value="96"/>
<UsageCount Value="22"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="../../appkit/NSApplication.inc"/>
<CursorPos X="70" Y="102"/>
<TopLine Value="96"/>
<UsageCount Value="16"/>
<CursorPos X="21" Y="79"/>
<TopLine Value="69"/>
<EditorIndex Value="1"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="../../appkit/NSAlert.inc"/>
<CursorPos X="1" Y="12"/>
<TopLine Value="1"/>
<UsageCount Value="30"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@ -74,8 +76,8 @@
<Filename Value="../../appkit/AppKit.inc"/>
<CursorPos X="20" Y="11"/>
<TopLine Value="1"/>
<EditorIndex Value="6"/>
<UsageCount Value="19"/>
<EditorIndex Value="9"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
@ -221,9 +223,11 @@
</Unit28>
<Unit29>
<Filename Value="../../appkit/NSStatusBar.inc"/>
<CursorPos X="85" Y="41"/>
<TopLine Value="38"/>
<UsageCount Value="21"/>
<CursorPos X="15" Y="73"/>
<TopLine Value="69"/>
<EditorIndex Value="4"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit29>
<Unit30>
<Filename Value="../../foundation/NSAutoreleasePool.inc"/>
@ -247,10 +251,10 @@
<Filename Value="controller.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="controller"/>
<CursorPos X="1" Y="176"/>
<TopLine Value="153"/>
<EditorIndex Value="1"/>
<UsageCount Value="42"/>
<CursorPos X="1" Y="110"/>
<TopLine Value="100"/>
<EditorIndex Value="2"/>
<UsageCount Value="46"/>
<Loaded Value="True"/>
</Unit33>
<Unit34>
@ -301,7 +305,7 @@
<UnitName Value="foundation"/>
<CursorPos X="16" Y="28"/>
<TopLine Value="1"/>
<UsageCount Value="13"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
@ -382,7 +386,7 @@
<Filename Value="../../appkit/NSGraphics.inc"/>
<CursorPos X="16" Y="28"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit52>
<Unit53>
@ -426,10 +430,10 @@
</Unit58>
<Unit59>
<Filename Value="../../../../../lazarus/lcl/interfaces/carbon/carbontrayicon.inc"/>
<CursorPos X="18" Y="43"/>
<TopLine Value="27"/>
<EditorIndex Value="2"/>
<UsageCount Value="10"/>
<CursorPos X="9" Y="75"/>
<TopLine Value="68"/>
<EditorIndex Value="5"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit59>
<Unit60>
@ -437,8 +441,8 @@
<UnitName Value="CarbonInt"/>
<CursorPos X="53" Y="39"/>
<TopLine Value="32"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<EditorIndex Value="6"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit60>
<Unit61>
@ -456,38 +460,50 @@
</Unit62>
<Unit63>
<Filename Value="../../appkit/NSBitmapImageRep.inc"/>
<CursorPos X="1" Y="66"/>
<TopLine Value="66"/>
<EditorIndex Value="5"/>
<UsageCount Value="10"/>
<CursorPos X="13" Y="9"/>
<TopLine Value="1"/>
<EditorIndex Value="8"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit63>
<Unit64>
<Filename Value="../../appkit/NSImageRep.inc"/>
<CursorPos X="3" Y="14"/>
<TopLine Value="2"/>
<EditorIndex Value="4"/>
<UsageCount Value="10"/>
<TopLine Value="417"/>
<EditorIndex Value="7"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit64>
<Unit65>
<Filename Value="../../foundation/NSGeometry.inc"/>
<CursorPos X="1" Y="14"/>
<TopLine Value="12"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit65>
</Units>
<JumpHistory Count="4" HistoryIndex="3">
<JumpHistory Count="5" HistoryIndex="4">
<Position1>
<Filename Value="../../appkit/AppKit.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="controller.pas"/>
<Caret Line="61" Column="22" TopLine="49"/>
</Position1>
<Position2>
<Filename Value="../../appkit/NSImageRep.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="controller.pas"/>
<Caret Line="113" Column="39" TopLine="100"/>
</Position2>
<Position3>
<Filename Value="../../appkit/NSBitmapImageRep.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="controller.pas"/>
<Caret Line="39" Column="16" TopLine="26"/>
</Position3>
<Position4>
<Filename Value="../../appkit/NSBitmapImageRep.inc"/>
<Caret Line="170" Column="3" TopLine="157"/>
<Filename Value="statusitem.pas"/>
<Caret Line="15" Column="16" TopLine="40"/>
</Position4>
<Position5>
<Filename Value="statusitem.pas"/>
<Caret Line="70" Column="33" TopLine="52"/>
</Position5>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -67,7 +67,7 @@ begin
MainWindow.orderFrontRegardless;
NSApp.setDelegate(myController);
NSApp.setDelegate(myController.Handle);
NSApp.run;

View File

@ -9,15 +9,13 @@
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
@ -31,37 +29,13 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="3">
<Units Count="1">
<Unit0>
<Filename Value="objcparser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="objcparser"/>
<CursorPos X="45" Y="11"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="ObjCParserUtils.pas"/>
<UnitName Value="ObjCParserUtils"/>
<CursorPos X="13" Y="1305"/>
<TopLine Value="1293"/>
<EditorIndex Value="1"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="ObjCParserTypes.pas"/>
<UnitName Value="ObjCParserTypes"/>
<CursorPos X="18" Y="1966"/>
<TopLine Value="1950"/>
<EditorIndex Value="2"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit2>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
@ -72,14 +46,4 @@
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="2">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
</Exceptions>
</Debugging>
</CONFIG>