You've already forked lazarus-ccr
Improves pascocoa and texteditor example
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@584 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
3
bindings/objc/clean.sh
Executable file
3
bindings/objc/clean.sh
Executable file
@ -0,0 +1,3 @@
|
||||
rm *.o
|
||||
rm *.ppu
|
||||
rm *.bak
|
@ -39,6 +39,8 @@ uses ctypes, unix;
|
||||
{$include malloc.inc}
|
||||
{.$include zone.inc}
|
||||
|
||||
{ Extra declarations }
|
||||
|
||||
implementation
|
||||
|
||||
{ Macros from error.h }
|
||||
|
@ -14,13 +14,15 @@
|
||||
{$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.
|
||||
var
|
||||
NSToolbarSeparatorItemIdentifier: CFStringRef; cvar; external;
|
||||
NSToolbarSpaceItemIdentifier: CFStringRef; cvar; external;
|
||||
NSToolbarFlexibleSpaceItemIdentifier: CFStringRef; cvar; external;
|
||||
NSToolbarShowColorsItemIdentifier: CFStringRef; cvar; external; // Shows the color panel.
|
||||
NSToolbarShowFontsItemIdentifier: CFStringRef; cvar; external; // Shows the font panel.
|
||||
NSToolbarCustomizeToolbarItemIdentifier: CFStringRef; cvar; external; // Puts the current toolbar into customize mode.
|
||||
NSToolbarPrintItemIdentifier: CFStringRef; cvar; external; // Sends printDocument: to firstResponder, but you can change this in toolbarWillAddItem: if you need to do so.
|
||||
|
||||
const
|
||||
NSToolbarItemVisibilityPriorityStandard = 0;
|
||||
NSToolbarItemVisibilityPriorityLow = 1000;
|
||||
|
@ -9,7 +9,7 @@
|
||||
unit appkit;
|
||||
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$mode objfpc}
|
||||
{$packrecords c}
|
||||
{$endif}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
controller.pas
|
||||
|
||||
Controller class for the texteditor example.
|
||||
|
||||
This example project is released under public domain
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
@ -24,11 +26,11 @@ type
|
||||
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 doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
class procedure doOpenFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
class procedure doSaveFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
class function applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
|
||||
_cmd: SEL; theApplication: objc.id): cbool; cdecl; //static;
|
||||
_cmd: SEL; theApplication: objc.id): cbool; cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
end;
|
||||
|
||||
const
|
||||
@ -93,13 +95,13 @@ var
|
||||
begin
|
||||
{ Show dialog }
|
||||
|
||||
if SavePanel.runModal = NSFileHandlingPanelOKButton then
|
||||
if OpenPanel.runModal = NSFileHandlingPanelOKButton then
|
||||
begin
|
||||
{ Now move the contents of the file to the edit control }
|
||||
{ Now move the contents of the edit control to the file }
|
||||
|
||||
FileContents := NSString.initWithContentsOfFile(OpenPanel.filename);
|
||||
FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue));
|
||||
|
||||
FileContents.writeToFile_atomically(SavePanel.filename, False);
|
||||
myView.TextField.setStringValue(CFStringRef(FileContents.Handle));
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -110,13 +112,13 @@ var
|
||||
begin
|
||||
{ Show dialog }
|
||||
|
||||
if OpenPanel.runModal = NSFileHandlingPanelOKButton then
|
||||
if SavePanel.runModal = NSFileHandlingPanelOKButton then
|
||||
begin
|
||||
{ Now move the contents of the edit control to the file }
|
||||
{ Now move the contents of the file to the edit control }
|
||||
|
||||
FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue));
|
||||
FileContents := NSString.initWithContentsOfFile(OpenPanel.filename);
|
||||
|
||||
myView.TextField.setStringValue(CFStringRef(FileContents.Handle));
|
||||
FileContents.writeToFile_atomically(SavePanel.filename, False);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
{
|
||||
model.pas
|
||||
|
||||
Model class for the texteditor class. Holds and manages resource files and user data.
|
||||
|
||||
This example project is released under public domain
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
}
|
||||
unit model;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
@ -1,3 +1,12 @@
|
||||
{
|
||||
mytoolbar.pas
|
||||
|
||||
Toolbar controller class. Creates and manages the toolbar.
|
||||
|
||||
This example project is released under public domain
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
}
|
||||
unit mytoolbar;
|
||||
|
||||
{$mode delphi}{$STATIC ON}
|
||||
@ -17,14 +26,15 @@ type
|
||||
{ Extra binding functions }
|
||||
constructor Create; override;
|
||||
procedure AddMethods; override;
|
||||
{ Public routines }
|
||||
procedure AttachEventHandlers;
|
||||
{ Toolbar items }
|
||||
OpenToolbarItem, SaveToolbarItem, CloseToolbarItem: NSToolbarItem;
|
||||
{ Objective-c Methods }
|
||||
class function toolbarAllowedItemIdentifiers(_self: objc.id;
|
||||
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl;// static;
|
||||
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
class function toolbarDefaultItemIdentifiers(_self: objc.id;
|
||||
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl;// static;
|
||||
_cmd: SEL; toolbar: objc.id {NSToolbar}): CFArrayRef; cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||
end;
|
||||
|
||||
const
|
||||
@ -38,7 +48,7 @@ var
|
||||
|
||||
function toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar
|
||||
(_self: objc.id; _cmd: SEL; toolbar: objc.id;
|
||||
itemIdentifier: CFStringRef; flag: OBJC_BOOL): objc.id; cdecl;// static;
|
||||
itemIdentifier: CFStringRef; flag: objc.BOOL): objc.id; cdecl;// static;
|
||||
|
||||
implementation
|
||||
|
||||
@ -62,15 +72,15 @@ begin
|
||||
|
||||
{ Create toolbar items }
|
||||
OpenToolbarItem := NSToolbarItem.initWithItemIdentifier(OpenToolbarItemIdentifier);
|
||||
// [toolbarItem setLabel:@"Save"];
|
||||
// [toolbarItem setPaletteLabel:[toolbarItem label]];
|
||||
// [toolbarItem setToolTip:@"Save Your Passwords"];}
|
||||
OpenToolbarItem.setToolTip(CFStringCreateWithPascalString(nil, 'Open', kCFStringEncodingUTF8));
|
||||
OpenToolbarItem.setImage(myModel.imgOpen.Handle);
|
||||
|
||||
SaveToolbarItem := NSToolbarItem.initWithItemIdentifier(SaveToolbarItemIdentifier);
|
||||
SaveToolbarItem.setToolTip(CFStringCreateWithPascalString(nil, 'Save', kCFStringEncodingUTF8));
|
||||
SaveToolbarItem.setImage(myModel.imgSave.Handle);
|
||||
|
||||
CloseToolbarItem := NSToolbarItem.initWithItemIdentifier(CloseToolbarItemIdentifier);
|
||||
CloseToolbarItem.setToolTip(CFStringCreateWithPascalString(nil, 'Exit', kCFStringEncodingUTF8));
|
||||
CloseToolbarItem.setImage(myModel.imgClose.Handle);
|
||||
end;
|
||||
|
||||
@ -94,15 +104,19 @@ begin
|
||||
CloseToolbarItem.setAction(sel_registerName(PChar('doClose:')));
|
||||
end;
|
||||
|
||||
{@@
|
||||
Lists all of the items in the toolbar by their identifiers.
|
||||
This method is necessary to implement a toolbar.
|
||||
}
|
||||
class function TMyToolbarController.toolbarAllowedItemIdentifiers(_self: objc.id;
|
||||
_cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl;
|
||||
var
|
||||
toolbarItems: array[0..4] of CFStringRef;
|
||||
begin
|
||||
WriteLn('OpenToolbarItemIdentifier: ', IntToHex(Cardinal(OpenToolbarItemIdentifier), 8));
|
||||
{ WriteLn('OpenToolbarItemIdentifier: ', IntToHex(Cardinal(OpenToolbarItemIdentifier), 8));
|
||||
WriteLn('SaveToolbarItemIdentifier: ', IntToHex(Cardinal(SaveToolbarItemIdentifier), 8));
|
||||
WriteLn('NSToolbarSpaceItemIdentifier: ', IntToHex(Cardinal(NSToolbarSpaceItemIdentifier), 8));
|
||||
WriteLn('CloseToolbarItemIdentifier: ', IntToHex(Cardinal(CloseToolbarItemIdentifier), 8));
|
||||
WriteLn('CloseToolbarItemIdentifier: ', IntToHex(Cardinal(CloseToolbarItemIdentifier), 8));}
|
||||
toolbarItems[0] := OpenToolbarItemIdentifier;
|
||||
toolbarItems[1] := SaveToolbarItemIdentifier;
|
||||
toolbarItems[2] := NSToolbarSpaceItemIdentifier;
|
||||
@ -112,17 +126,27 @@ begin
|
||||
Result := CFArrayCreate(nil, @toolbarItems[0], 4, nil);
|
||||
end;
|
||||
|
||||
{@@
|
||||
Returns which items are available by default in the toolbar.
|
||||
Other items exist in the toolbar but are optional.
|
||||
We simply return the same items from toolbarAllowedItemIdentifiers.
|
||||
}
|
||||
class function TMyToolbarController.toolbarDefaultItemIdentifiers(_self: objc.id;
|
||||
_cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl;
|
||||
begin
|
||||
Result := toolbarAllowedItemIdentifiers(_self, _cmd, toolbar);
|
||||
end;
|
||||
|
||||
{@@
|
||||
Returns the NSToolbarItem for each item.
|
||||
Note that we should return an item in our cache instead of creating a new one
|
||||
everytime this routine is called.
|
||||
}
|
||||
function toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(_self: objc.id;
|
||||
_cmd: SEL; toolbar: objc.id {NSToolbar}; itemIdentifier: CFStringRef;
|
||||
flag: OBJC_BOOL): objc.id {NSToolbarItem}; cdecl;
|
||||
flag: objc.BOOL): objc.id {NSToolbarItem}; cdecl;
|
||||
begin
|
||||
WriteLn('toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar: ', IntToHex(Cardinal(itemIdentifier), 8));
|
||||
// WriteLn('toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar: ', IntToHex(Cardinal(itemIdentifier), 8));
|
||||
|
||||
with myToolbarController do
|
||||
begin
|
||||
|
@ -6,7 +6,7 @@
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<ActiveEditorIndexAtStart Value="7"/>
|
||||
<ActiveEditorIndexAtStart Value="1"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
@ -30,211 +30,229 @@
|
||||
<PackageName Value="cocoa_pkg"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="9">
|
||||
<Units Count="12">
|
||||
<Unit0>
|
||||
<Filename Value="texteditor.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="texteditor"/>
|
||||
<CursorPos X="15" Y="44"/>
|
||||
<TopLine Value="31"/>
|
||||
<CursorPos X="9" Y="15"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="37"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="model.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="model"/>
|
||||
<CursorPos X="33" Y="63"/>
|
||||
<TopLine Value="48"/>
|
||||
<CursorPos X="1" Y="4"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="37"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="view.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="view"/>
|
||||
<CursorPos X="28" Y="217"/>
|
||||
<TopLine Value="204"/>
|
||||
<CursorPos X="1" Y="221"/>
|
||||
<TopLine Value="74"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="37"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="controller.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="controller"/>
|
||||
<CursorPos X="25" Y="30"/>
|
||||
<TopLine Value="19"/>
|
||||
<CursorPos X="19" Y="98"/>
|
||||
<TopLine Value="85"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="37"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="mytoolbar"/>
|
||||
<CursorPos X="1" Y="106"/>
|
||||
<TopLine Value="97"/>
|
||||
<CursorPos X="51" Y="126"/>
|
||||
<TopLine Value="115"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="26"/>
|
||||
<UsageCount Value="32"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../../objc/objc.pas"/>
|
||||
<UnitName Value="objc"/>
|
||||
<CursorPos X="14" Y="48"/>
|
||||
<TopLine Value="29"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="12"/>
|
||||
<CursorPos X="50" Y="3"/>
|
||||
<TopLine Value="27"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="15"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="../../foundation/foundation.pas"/>
|
||||
<UnitName Value="foundation"/>
|
||||
<CursorPos X="30" Y="12"/>
|
||||
<CursorPos X="30" Y="8"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="12"/>
|
||||
<Loaded Value="True"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="../../appkit/NSToolbarItem.inc"/>
|
||||
<CursorPos X="49" Y="5"/>
|
||||
<TopLine Value="4"/>
|
||||
<UsageCount Value="10"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="../../appkit/appkit.pas"/>
|
||||
<UnitName Value="appkit"/>
|
||||
<CursorPos X="16" Y="12"/>
|
||||
<CursorPos X="28" Y="9"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="12"/>
|
||||
<Loaded Value="True"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../../objc/objc.inc"/>
|
||||
<CursorPos X="13" Y="60"/>
|
||||
<TopLine Value="46"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="../../appkit/NSApplication.inc"/>
|
||||
<CursorPos X="31" Y="1047"/>
|
||||
<TopLine Value="1041"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="../../appkit/NSAlert.inc"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="28"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit11>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="73" Column="1" TopLine="61"/>
|
||||
<Caret Line="76" Column="1" TopLine="64"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="74" Column="1" TopLine="62"/>
|
||||
<Caret Line="78" Column="1" TopLine="66"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="75" Column="1" TopLine="63"/>
|
||||
<Caret Line="72" Column="1" TopLine="67"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="76" Column="1" TopLine="64"/>
|
||||
<Caret Line="74" Column="92" TopLine="61"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="78" Column="1" TopLine="66"/>
|
||||
<Caret Line="8" Column="12" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="72" Column="1" TopLine="67"/>
|
||||
<Caret Line="126" Column="30" TopLine="115"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="74" Column="92" TopLine="61"/>
|
||||
<Caret Line="21" Column="55" TopLine="2"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="8" Column="12" TopLine="1"/>
|
||||
<Caret Line="101" Column="111" TopLine="92"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="126" Column="30" TopLine="115"/>
|
||||
<Caret Line="75" Column="5" TopLine="52"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="21" Column="55" TopLine="2"/>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="101" Column="20" TopLine="90"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="101" Column="111" TopLine="92"/>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="102" Column="13" TopLine="89"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="75" Column="5" TopLine="52"/>
|
||||
<Caret Line="65" Column="1" TopLine="58"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="101" Column="20" TopLine="90"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="102" Column="13" TopLine="89"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="65" Column="1" TopLine="58"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="20" Column="34" TopLine="8"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="37" Column="22" TopLine="28"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="99" Column="12" TopLine="80"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="108" Column="1" TopLine="85"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="20" Column="22" TopLine="9"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="99" Column="12" TopLine="80"/>
|
||||
<Caret Line="178" Column="5" TopLine="155"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="108" Column="1" TopLine="85"/>
|
||||
<Caret Line="181" Column="5" TopLine="158"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="20" Column="22" TopLine="9"/>
|
||||
<Caret Line="23" Column="27" TopLine="13"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="178" Column="5" TopLine="155"/>
|
||||
<Caret Line="219" Column="1" TopLine="210"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="181" Column="5" TopLine="158"/>
|
||||
<Caret Line="23" Column="8" TopLine="14"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="23" Column="27" TopLine="13"/>
|
||||
<Caret Line="218" Column="1" TopLine="209"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="219" Column="1" TopLine="210"/>
|
||||
<Caret Line="131" Column="1" TopLine="114"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="23" Column="8" TopLine="14"/>
|
||||
<Caret Line="116" Column="44" TopLine="104"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="218" Column="1" TopLine="209"/>
|
||||
<Caret Line="192" Column="35" TopLine="180"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="131" Column="1" TopLine="114"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="116" Column="44" TopLine="104"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="192" Column="35" TopLine="180"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="controller.pas"/>
|
||||
<Caret Line="74" Column="15" TopLine="59"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="../../../objc/objc.pas"/>
|
||||
<Caret Line="27" Column="12" TopLine="19"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="mytoolbar.pas"/>
|
||||
<Caret Line="149" Column="9" TopLine="134"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="view.pas"/>
|
||||
<Caret Line="218" Column="77" TopLine="200"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -49,7 +49,7 @@ begin
|
||||
myController := TMyController.Create();
|
||||
|
||||
myView.AttachEventHandlers();
|
||||
myToolbarController.AttachEventHandlers();
|
||||
myToolbarController.AttachEventHandlers(); // Created in myView.CreateUserInterface
|
||||
|
||||
{ Enters main message loop }
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
{
|
||||
view.pas
|
||||
|
||||
View class of the texteditor example. Creates the user interface.
|
||||
|
||||
This example project is released under public domain
|
||||
|
||||
AUTHORS: Felipe Monteiro de Carvalho
|
||||
}
|
||||
unit view;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
@ -87,6 +96,8 @@ begin
|
||||
CreateMainMenu();
|
||||
end;
|
||||
|
||||
{@@
|
||||
}
|
||||
procedure TMyView.AttachEventHandlers();
|
||||
begin
|
||||
OpenItem.setTarget(myController.Handle);
|
||||
@ -99,6 +110,8 @@ begin
|
||||
ExitItem.setAction(sel_registerName(PChar('doClose:')));
|
||||
end;
|
||||
|
||||
{@@
|
||||
}
|
||||
function TMyView.CreateAppleMenu(): NSMenu;
|
||||
var
|
||||
AppleMenuTitle, ServicesMenuTitle: CFStringRef;
|
||||
@ -114,56 +127,10 @@ begin
|
||||
|
||||
ServicesMenu := NSMenu.initWithTitle(ServicesMenuTitle);
|
||||
NSApp.setServicesMenu(ServicesMenu.Handle);
|
||||
|
||||
{
|
||||
NSMenuItem *menuitem;
|
||||
// Create the application (Apple) menu.
|
||||
NSMenu *menuApp = [[NSMenu alloc] initWithTitle: @""];
|
||||
|
||||
NSMenu *menuServices = [[NSMenu alloc] initWithTitle: @"Services"];
|
||||
[NSApp setServicesMenu:menuServices];
|
||||
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle:@"Preferences..." action:nil keyEquivalent:@","];
|
||||
[menuApp addItem: menuitem];
|
||||
SetPreferencesMenuItem(menuitem);
|
||||
[menuApp addItem: [NSMenuItem separatorItem]];
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle: @"Services"
|
||||
action:nil keyEquivalent:@""];
|
||||
[menuitem setSubmenu:menuServices];
|
||||
[menuApp addItem: menuitem];
|
||||
[menuitem release];
|
||||
|
||||
[menuApp addItem: [NSMenuItem separatorItem]];
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle:@"Hide"
|
||||
action:@selector(hide:) keyEquivalent:@""];
|
||||
[menuitem setTarget: NSApp];
|
||||
[menuApp addItem: menuitem];
|
||||
[menuitem release];
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle:@"Hide Others"
|
||||
action:@selector(hideOtherApplications:) keyEquivalent:@""];
|
||||
[menuitem setTarget: NSApp];
|
||||
[menuApp addItem: menuitem];
|
||||
[menuitem release];
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle:@"Show All"
|
||||
action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||
[menuitem setTarget: NSApp];
|
||||
[menuApp addItem: menuitem];
|
||||
[menuitem release];
|
||||
[menuApp addItem: [NSMenuItem separatorItem]];
|
||||
menuitem = [[NSMenuItem alloc] initWithTitle:@"Quit"
|
||||
action:@selector(terminate:) keyEquivalent:@"q"];
|
||||
[menuitem setTarget: NSApp];
|
||||
[menuApp addItem: menuitem];
|
||||
SetQuitMenuItem(menuitem);
|
||||
[menuitem release];
|
||||
|
||||
[NSApp setAppleMenu:menuApp];
|
||||
AddToMenubar(menuApp);
|
||||
[menuApp release];
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
end;
|
||||
|
||||
{@@
|
||||
}
|
||||
function TMyView.CreateFileMenu(): NSMenu;
|
||||
var
|
||||
MenuTitle: CFStringRef;
|
||||
@ -184,6 +151,8 @@ begin
|
||||
Result.addItem(ExitItem.Handle);
|
||||
end;
|
||||
|
||||
{@@
|
||||
}
|
||||
procedure TMyView.AddToMenubar(menu: NSMenu);
|
||||
var
|
||||
dummyItem: NSMenuItem;
|
||||
@ -234,6 +203,9 @@ begin
|
||||
Result := NSMenuItem.initWithTitle_action_keyEquivalent(ItemText, nil, KeyText);
|
||||
end;
|
||||
|
||||
{@@
|
||||
Creates an autosized NSTextField
|
||||
}
|
||||
function TMyView.CreateTextField(): NSTextField;
|
||||
var
|
||||
ClientRect: NSRect;
|
||||
@ -244,6 +216,7 @@ begin
|
||||
ClientRect.size.height := 500.0;
|
||||
|
||||
Result := NSTextField.initWithFrame(ClientRect);
|
||||
Result.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
|
||||
MainWindowView.addSubview(Result.Handle);
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user