From ab81515aa9a8879a227b8dadc213fe959a289309 Mon Sep 17 00:00:00 2001 From: tombo Date: Sun, 5 Oct 2008 09:22:38 +0000 Subject: [PATCH] LCL Carbon: fixed TCustomForm BorderStyle nad BorderIcons handling in design and run time git-svn-id: trunk@16879 - --- lcl/interfaces/carbon/carbonprivatewindow.inc | 71 ++++++++++--------- lcl/interfaces/carbon/carbonproc.pp | 32 +++++++-- 2 files changed, 64 insertions(+), 39 deletions(-) diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index 18ae9d89de..6f7cdae13c 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -1105,19 +1105,29 @@ var begin // apply appropriate form style and form border style - case (LCLObject as TCustomForm).FormStyle of - fsStayOnTop, fsSplash: - begin - NewWindowClass := kFloatingWindowClass; - Attributes := 0; - end; - else + if csDesigning in LCLObject.ComponentState then + begin NewWindowClass := kDocumentWindowClass; - Attributes := kWindowInWindowMenuAttribute; + Attributes := kWindowInWindowMenuAttribute or + GetBorderWindowAttrs(bsSizeable, [biMaximize, biMinimize, biSystemMenu]); + end + else + begin + case (LCLObject as TCustomForm).FormStyle of + fsStayOnTop, fsSplash: + begin + NewWindowClass := kFloatingWindowClass; + Attributes := 0; + end; + else + NewWindowClass := kDocumentWindowClass; + Attributes := kWindowInWindowMenuAttribute; + end; + + Attributes := Attributes or + GetBorderWindowAttrs((LCLObject as TCustomForm).BorderStyle, + (LCLObject as TCustomForm).BorderIcons); end; - - Attributes := Attributes or - FormBorderToWindowAttrs((LCLObject as TCustomForm).BorderStyle); //DebugLn('TCarbonWindow.CreateWidget ' + DbgS(ParamsToCarbonRect(AParams))); @@ -1660,28 +1670,23 @@ end; ------------------------------------------------------------------------------} procedure TCarbonWindow.SetBorderIcons(ABorderIcons: TBorderIcons); var - AttrsSet, AttrsClear: WindowAttributes; + AttrsSet, AttrsRemove: WindowAttributes; begin - AttrsSet := 0; - AttrsClear := 0; + if csDesigning in LCLObject.ComponentState then Exit; + BeginUpdate(WindowRef(Widget)); + try + AttrsSet := GetBorderWindowAttrs((LCLObject as TCustomForm).BorderStyle, + ABorderIcons); + AttrsRemove := (kWindowNoTitleBarAttribute or kWindowCloseBoxAttribute or + kWindowCollapseBoxAttribute or kWindowFullZoomAttribute or + kWindowResizableAttribute) and (not AttrsSet); - if (biMinimize in ABorderIcons) and (biSystemMenu in ABorderIcons) then - AttrsSet := AttrsSet or kWindowCollapseBoxAttribute - else - AttrsClear := AttrsClear or kWindowCollapseBoxAttribute; - - if (biMaximize in ABorderIcons) and (biSystemMenu in ABorderIcons) then - AttrsSet := AttrsSet or kWindowFullZoomAttribute - else - AttrsClear := AttrsClear or kWindowFullZoomAttribute; - - if biSystemMenu in ABorderIcons then - AttrsSet := AttrsSet or kWindowCloseBoxAttribute - else - AttrsClear := AttrsClear or kWindowCloseBoxAttribute; - - OSError(ChangeWindowAttributes(WindowRef(Widget), AttrsSet, AttrsClear), - Self, 'SetBorderIcons', SChangeWindowAttrs); + if OSError( + ChangeWindowAttributes(WindowRef(Widget), AttrsSet, AttrsRemove), Self, + 'SetBorderIcons', SChangeWindowAttrs) then Exit; + finally + EndUpdate(WindowRef(Widget)); + end; end; {------------------------------------------------------------------------------ @@ -1694,9 +1699,11 @@ procedure TCarbonWindow.SetFormBorderStyle(AFormBorderStyle: TFormBorderStyle); var AttrsSet, AttrsRemove: WindowAttributes; begin + if csDesigning in LCLObject.ComponentState then Exit; BeginUpdate(WindowRef(Widget)); try - AttrsSet := FormBorderToWindowAttrs(AFormBorderStyle); + AttrsSet := GetBorderWindowAttrs(AFormBorderStyle, + (LCLObject as TCustomForm).BorderIcons); AttrsRemove := (kWindowNoTitleBarAttribute or kWindowCloseBoxAttribute or kWindowCollapseBoxAttribute or kWindowFullZoomAttribute or kWindowResizableAttribute) and (not AttrsSet); diff --git a/lcl/interfaces/carbon/carbonproc.pp b/lcl/interfaces/carbon/carbonproc.pp index 6c89c763f9..a2c11e19e9 100644 --- a/lcl/interfaces/carbon/carbonproc.pp +++ b/lcl/interfaces/carbon/carbonproc.pp @@ -35,8 +35,8 @@ interface uses MacOSAll, - Classes, Types, LCLType, LCLProc, LCLClasses, LMessages, - Controls, SysUtils, Graphics, Math, GraphType; + Classes, SysUtils, Types, LCLType, LCLProc, LCLClasses, LMessages, + Controls, Forms, Graphics, Math, GraphType; function OSError(AResult: OSStatus; const AMethodName, ACallName: String; const AText: String = ''): Boolean; @@ -61,7 +61,8 @@ var function VirtualKeyCodeToMac(AKey: Word): Word; -function FormBorderToWindowAttrs(const AFormBorder: TFormBorderStyle): WindowAttributes; +function GetBorderWindowAttrs(const ABorderStyle: TFormBorderStyle; + const ABorderIcons: TBorderIcons): WindowAttributes; function GetCarbonMouseButton(AEvent: EventRef): Integer; function GetCarbonMsgKeyState: PtrInt; @@ -317,12 +318,13 @@ begin end; {------------------------------------------------------------------------------ - Name: FormBorderToWindowAttrs - Returns: Converts the form border style to Carbon window attributes + Name: GetBorderWindowAttrs + Returns: Converts the form border style and icons to Carbon window attributes ------------------------------------------------------------------------------} -function FormBorderToWindowAttrs(const AFormBorder: TFormBorderStyle): WindowAttributes; +function GetBorderWindowAttrs(const ABorderStyle: TFormBorderStyle; + const ABorderIcons: TBorderIcons): WindowAttributes; begin - case AFormBorder of + case ABorderStyle of bsNone: Result := kWindowNoTitleBarAttribute; bsToolWindow, bsSingle: @@ -338,6 +340,22 @@ begin else Result := kWindowNoAttributes; end; + + if biSystemMenu in ABorderIcons then + begin + Result := Result or kWindowCloseBoxAttribute; + if biMinimize in ABorderIcons then + Result := Result or kWindowCollapseBoxAttribute + else + Result := Result and not kWindowCollapseBoxAttribute; + if biMaximize in ABorderIcons then + Result := Result or kWindowFullZoomAttribute + else + Result := Result and not kWindowFullZoomAttribute; + end + else + Result := Result and not (kWindowCloseBoxAttribute or + kWindowCollapseBoxAttribute or kWindowFullZoomAttribute); end; {------------------------------------------------------------------------------