From 69347e3724faa883142af22a9f6f7e32bbad5c4b Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 6 Jan 2012 16:03:18 +0000 Subject: [PATCH] cocoa: implement ShowModal and CloseModal for TCustomForm git-svn-id: trunk@34624 - --- lcl/interfaces/cocoa/cocoawsforms.pp | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoawsforms.pp b/lcl/interfaces/cocoa/cocoawsforms.pp index f136bc51bd..62efa8af91 100644 --- a/lcl/interfaces/cocoa/cocoawsforms.pp +++ b/lcl/interfaces/cocoa/cocoawsforms.pp @@ -97,8 +97,8 @@ type class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; -// class procedure CloseModal(const ACustomForm: TCustomForm); override; -// class procedure ShowModal(const ACustomForm: TCustomForm); override; + class procedure CloseModal(const ACustomForm: TCustomForm); override; + class procedure ShowModal(const ACustomForm: TCustomForm); override; class procedure SetAlphaBlend(const ACustomForm: TCustomForm; const AlphaBlend: Boolean; const Alpha: Byte); override; class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override; @@ -146,6 +146,9 @@ type implementation +uses + CocoaInt; + { TLCLWindowCallback } procedure TLCLWindowCallback.Activate; @@ -182,15 +185,6 @@ end; { TCocoaWSCustomForm } -{------------------------------------------------------------------------------ - Method: TCocoaWSCustomForm.CreateHandle - Params: AWinControl - LCL control - AParams - Creation parameters - Returns: Handle to the window in Cocoa interface - - Creates new window in Cocoa interface with the specified parameters - ------------------------------------------------------------------------------} - class procedure TCocoaWSCustomForm.SetStyleMaskFor(AWindow: NSWindow; ABorderStyle: TFormBorderStyle; ABorderIcons: TBorderIcons; ADesigning: Boolean); @@ -291,6 +285,19 @@ begin ns.release; end; +class procedure TCocoaWSCustomForm.CloseModal(const ACustomForm: TCustomForm); +begin + if ACustomForm.HandleAllocated then + if CocoaWidgetSet.NSApp.modalWindow = NSWindow(ACustomForm.Handle) then + CocoaWidgetSet.NSApp.stopModal; +end; + +class procedure TCocoaWSCustomForm.ShowModal(const ACustomForm: TCustomForm); +begin + if ACustomForm.HandleAllocated then + CocoaWidgetSet.NSApp.runModalForWindow(NSWindow(ACustomForm.Handle)); +end; + class procedure TCocoaWSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm; const AlphaBlend: Boolean; const Alpha: Byte); begin if ACustomForm.HandleAllocated then