summaryrefslogtreecommitdiff
path: root/gfx/carbon
diff options
context:
space:
mode:
authorsekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-05-31 14:54:39 +0000
committersekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-05-31 14:54:39 +0000
commit5c84b5c66c967254400370c991170a61533a8014 (patch)
tree02b3da868e266eadfe275e2cc6b7fbb591e4a56f /gfx/carbon
parent59ae98e700b4774a123e62435b54c1141380fcaa (diff)
downloadfpGUI-5c84b5c66c967254400370c991170a61533a8014.tar.xz
Moved the handle internal field to platform specific area. Added GetHandle function. Improved carbon interface
Diffstat (limited to 'gfx/carbon')
-rw-r--r--gfx/carbon/gfx_carbon.pas67
1 files changed, 63 insertions, 4 deletions
diff --git a/gfx/carbon/gfx_carbon.pas b/gfx/carbon/gfx_carbon.pas
index c1236e4c..8ca3a083 100644
--- a/gfx/carbon/gfx_carbon.pas
+++ b/gfx/carbon/gfx_carbon.pas
@@ -16,7 +16,7 @@
unit gfx_carbon;
{$ifdef fpc}
- {$mode objfpc}{$H+}
+ {$mode delphi}{$H+}
{$endif}
interface
@@ -129,10 +129,14 @@ type
{ TCarbonWindow }
TCarbonWindow = class(TFCustomWindow)
+ private
+ FHandle: WindowRef;
+ contentView: HIViewRef;
protected
function GetTitle: String; override;
procedure SetTitle(const ATitle: String); override;
procedure DoSetCursor; override;
+ function GetHandle: PtrUInt; override;
public
constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); override;
destructor Destroy; override;
@@ -373,7 +377,7 @@ end;
procedure TCarbonApplication.Run;
begin
-
+ RunApplicationEventLoop();
end;
procedure TCarbonApplication.Quit;
@@ -383,6 +387,23 @@ end;
{ TCarbonWindow }
+function WindowCommandHandler(nextHandler: EventHandlerCallRef; theEvent: EventRef; userDataPtr: UnivPtr): OSStatus;
+var
+ status: OSStatus;
+ ignoreResult: OSStatus;
+ aCommand: HICommand;
+ theAssociatedControl: ControlRef;
+begin
+ status := eventNotHandledErr;
+
+ ignoreResult := GetEventParameter(theEvent, kEventParamDirectObject, typeHICommand, NIL, sizeof(aCommand), NIL, @aCommand);
+
+// if aCommand.commandID = UInt32(FourCharCode(kButtonHello)) then status := ButtonHelloPressed()
+// else if aCommand.commandID = UInt32(FourCharCode(kButtonMessage)) then status := ButtonMessagePressed();
+
+ Result := status;
+end;
+
function TCarbonWindow.GetTitle: String;
begin
@@ -398,9 +419,47 @@ begin
end;
-constructor TCarbonWindow.Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions);
+function TCarbonWindow.GetHandle: PtrUInt;
begin
+ Result := PtrUInt(FHandle);
+end;
+
+constructor TCarbonWindow.Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions);
+var
+ status, ignoreResult: OSStatus;
+ cmdEvent: EventTypeSpec;
+ eventHandler: EventHandlerUPP;
+ CarbonRect: FPCMacOSAll.Rect;
+begin
+ CarbonRect.left := 50;
+ CarbonRect.Top := 50;
+ CarbonRect.right := 300;
+ CarbonRect.bottom := 300;
+
+ status := CreateNewWindow(kDocumentWindowClass,
+ (kWindowStandardDocumentAttributes or kWindowStandardHandlerAttribute
+ or kWindowCompositingAttribute),
+ CarbonRect, FHandle);
+
+ if (status <> noErr) or (FHandle = nil) then
+ begin
+// DoShowMessage('Error', 'CreateNewWindow failed');
+ end;
+
+ ignoreResult := SetWindowTitleWithCFString(FHandle, CFSTRP('Carbon FPC Hello World'));
+ ignoreResult := HIViewFindByID(HIViewGetRoot(FHandle), kHIViewWindowContentID, contentView);
+
+ { Add events }
+
+ cmdEvent.eventClass := kEventClassCommand;
+ cmdEvent.eventKind := kEventCommandProcess;
+ eventHandler := NewEventHandlerUPP(@WindowCommandHandler);
+ ignoreResult := InstallEventHandler(GetWindowEventTarget(FHandle),
+ eventHandler, 1, @cmdEvent, nil, nil);
+
+ { Creates a canvas }
+ FCanvas := TCarbonCanvas.Create;
end;
destructor TCarbonWindow.Destroy;
@@ -440,7 +499,7 @@ end;
procedure TCarbonWindow.Show;
begin
-
+ ShowWindow(FHandle);
end;
procedure TCarbonWindow.Invalidate(const ARect: TRect);