mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 18:43:50 +02:00
LCL Carbon: fixed TCustomForm BorderStyle nad BorderIcons handling in design and run time
git-svn-id: trunk@16879 -
This commit is contained in:
parent
bb55537667
commit
ab81515aa9
lcl/interfaces/carbon
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user