mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 21:59:07 +02:00
cocoa: formatting, cleanup, correctly initialize controls with initial visible state using WS_VISIBLE flag, implement ShowHide for controls and forms
git-svn-id: trunk@34600 -
This commit is contained in:
parent
74c7b051a3
commit
c403c02f92
@ -70,6 +70,7 @@ type
|
|||||||
function lclIsEnabled: Boolean; message 'lclIsEnabled';
|
function lclIsEnabled: Boolean; message 'lclIsEnabled';
|
||||||
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:';
|
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:';
|
||||||
function lclIsVisible: Boolean; message 'lclIsVisible';
|
function lclIsVisible: Boolean; message 'lclIsVisible';
|
||||||
|
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:';
|
||||||
function lclWindowState: Integer; message 'lclWindowState';
|
function lclWindowState: Integer; message 'lclWindowState';
|
||||||
|
|
||||||
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:';
|
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:';
|
||||||
@ -92,6 +93,7 @@ type
|
|||||||
|
|
||||||
LCLViewExtension = objccategory(NSView)
|
LCLViewExtension = objccategory(NSView)
|
||||||
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
||||||
|
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:'; reintroduce;
|
||||||
function lclIsPainting: Boolean; message 'lclIsPainting';
|
function lclIsPainting: Boolean; message 'lclIsPainting';
|
||||||
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:'; reintroduce;
|
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:'; reintroduce;
|
||||||
procedure lclInvalidate; message 'lclInvalidate'; reintroduce;
|
procedure lclInvalidate; message 'lclInvalidate'; reintroduce;
|
||||||
@ -120,6 +122,7 @@ type
|
|||||||
|
|
||||||
LCLWindowExtension = objccategory(NSWindow)
|
LCLWindowExtension = objccategory(NSWindow)
|
||||||
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
||||||
|
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:'; reintroduce;
|
||||||
function lclIsEnabled: Boolean; message 'lclIsEnabled'; reintroduce;
|
function lclIsEnabled: Boolean; message 'lclIsEnabled'; reintroduce;
|
||||||
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:'; reintroduce;
|
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:'; reintroduce;
|
||||||
|
|
||||||
@ -978,6 +981,10 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LCLObjectExtension.lclSetVisible(AVisible: Boolean);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
function LCLObjectExtension.lclWindowState: Integer;
|
function LCLObjectExtension.lclWindowState: Integer;
|
||||||
begin
|
begin
|
||||||
Result := SIZENORMAL;
|
Result := SIZENORMAL;
|
||||||
@ -1092,11 +1099,16 @@ begin
|
|||||||
SetEnabled(AEnabled);
|
SetEnabled(AEnabled);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LCLViewExtension.lclIsVisible:Boolean;
|
function LCLViewExtension.lclIsVisible: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := not isHidden;
|
Result := not isHidden;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LCLViewExtension.lclSetVisible(AVisible: Boolean);
|
||||||
|
begin
|
||||||
|
setHidden(not AVisible);
|
||||||
|
end;
|
||||||
|
|
||||||
function LCLViewExtension.lclIsPainting: Boolean;
|
function LCLViewExtension.lclIsPainting: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Assigned(lclGetCallback) and Assigned(lclGetCallback.GetContext);
|
Result := Assigned(lclGetCallback) and Assigned(lclGetCallback.GetContext);
|
||||||
@ -1205,11 +1217,19 @@ end;
|
|||||||
|
|
||||||
{ LCLWindowExtension }
|
{ LCLWindowExtension }
|
||||||
|
|
||||||
function LCLWindowExtension.lclIsVisible:Boolean;
|
function LCLWindowExtension.lclIsVisible: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := isVisible;
|
Result := isVisible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LCLWindowExtension.lclSetVisible(AVisible: Boolean);
|
||||||
|
begin
|
||||||
|
if AVisible then
|
||||||
|
orderFrontRegardless
|
||||||
|
else
|
||||||
|
orderOut(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
function LCLWindowExtension.lclIsEnabled: Boolean;
|
function LCLWindowExtension.lclIsEnabled: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := contentView.lclIsEnabled;
|
Result := contentView.lclIsEnabled;
|
||||||
|
@ -82,6 +82,7 @@ type
|
|||||||
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||||
class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCursor); override;
|
class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCursor); override;
|
||||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
|
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -910,9 +911,9 @@ end;
|
|||||||
|
|
||||||
class function TCocoaWSWinControl.GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
class function TCocoaWSWinControl.GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(AWinControl.Handle<>0);
|
Result := AWinControl.HandleAllocated;
|
||||||
if not Result then Exit;
|
if Result then
|
||||||
ARect:=NSObject(AWinControl.Handle).lclClientFrame;
|
ARect := NSObject(AWinControl.Handle).lclClientFrame;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TCocoaWSWinControl.GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
class function TCocoaWSWinControl.GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
||||||
@ -929,7 +930,7 @@ var
|
|||||||
Obj: NSObject;
|
Obj: NSObject;
|
||||||
Size: NSSize;
|
Size: NSSize;
|
||||||
begin
|
begin
|
||||||
if (AWinControl.Handle <> 0) then
|
if AWinControl.HandleAllocated then
|
||||||
begin
|
begin
|
||||||
Obj := NSObject(AWinControl.Handle);
|
Obj := NSObject(AWinControl.Handle);
|
||||||
{
|
{
|
||||||
@ -946,7 +947,7 @@ end;
|
|||||||
class procedure TCocoaWSWinControl.SetBounds(const AWinControl: TWinControl;
|
class procedure TCocoaWSWinControl.SetBounds(const AWinControl: TWinControl;
|
||||||
const ALeft, ATop, AWidth, AHeight: Integer);
|
const ALeft, ATop, AWidth, AHeight: Integer);
|
||||||
begin
|
begin
|
||||||
if (AWinControl.Handle<>0) then
|
if AWinControl.HandleAllocated then
|
||||||
NSObject(AWinControl.Handle).lclSetFrame(Bounds(ALeft, ATop, AWidth, AHeight));
|
NSObject(AWinControl.Handle).lclSetFrame(Bounds(ALeft, ATop, AWidth, AHeight));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1011,6 +1012,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TCocoaWSWinControl.ShowHide(const AWinControl: TWinControl);
|
||||||
|
begin
|
||||||
|
if AWinControl.HandleAllocated then
|
||||||
|
NSObject(AWinControl.Handle).lclSetVisible(AWinControl.HandleObjectShouldBeVisible);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaWSCustomControl }
|
{ TCocoaWSCustomControl }
|
||||||
|
|
||||||
class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
||||||
@ -1025,27 +1032,33 @@ end;
|
|||||||
|
|
||||||
{ LCLWSViewExtension }
|
{ LCLWSViewExtension }
|
||||||
|
|
||||||
function LCLWSViewExtension.lclInitWithCreateParams(const AParams:TCreateParams): id;
|
function LCLWSViewExtension.lclInitWithCreateParams(const AParams: TCreateParams): id;
|
||||||
var
|
var
|
||||||
p: NSView;
|
p: NSView;
|
||||||
ns: NSRect;
|
ns: NSRect;
|
||||||
begin
|
begin
|
||||||
p:=nil;
|
p := nil;
|
||||||
if (AParams.WndParent<>0) then begin
|
setHidden(AParams.Style and WS_VISIBLE = 0);
|
||||||
|
if (AParams.WndParent <> 0) then
|
||||||
|
begin
|
||||||
if (NSObject(AParams.WndParent).isKindOfClass_(NSView)) then
|
if (NSObject(AParams.WndParent).isKindOfClass_(NSView)) then
|
||||||
p:=NSView(AParams.WndParent)
|
p := NSView(AParams.WndParent)
|
||||||
else if (NSObject(AParams.WndParent).isKindOfClass_(NSWindow)) then
|
else
|
||||||
p:=NSWindow(AParams.WndParent).contentView;
|
if (NSObject(AParams.WndParent).isKindOfClass_(NSWindow)) then
|
||||||
|
p := NSWindow(AParams.WndParent).contentView;
|
||||||
end;
|
end;
|
||||||
with AParams do
|
with AParams do
|
||||||
if Assigned(p)
|
if Assigned(p) then
|
||||||
then LCLToNSRect(Types.Bounds(X,Y,Width, Height), p.frame.size.height, ns)
|
LCLToNSRect(Types.Bounds(X,Y,Width, Height), p.frame.size.height, ns)
|
||||||
else LCLToNSRect(Types.Bounds(X,Y,Width, Height), ns);
|
else
|
||||||
|
LCLToNSRect(Types.Bounds(X,Y,Width, Height), ns);
|
||||||
|
|
||||||
Result:=initWithFrame(ns);
|
Result := initWithFrame(ns);
|
||||||
if not Assigned(Result) then Exit;
|
if not Assigned(Result) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if Assigned(p) then p.addSubview(Self);
|
if Assigned(p) then
|
||||||
|
p.addSubview(Self);
|
||||||
SetViewDefaults(Self);
|
SetViewDefaults(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -91,8 +91,6 @@ type
|
|||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
|
|
||||||
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
|
||||||
|
|
||||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override;
|
class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override;
|
||||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
@ -223,16 +221,6 @@ begin
|
|||||||
Result := TLCLIntfHandle(win);
|
Result := TLCLIntfHandle(win);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomForm.ShowHide(const AWinControl: TWinControl);
|
|
||||||
begin
|
|
||||||
if not AWinControl.HandleAllocated then
|
|
||||||
Exit;
|
|
||||||
if AWinControl.HandleObjectShouldBeVisible then
|
|
||||||
NSWindow(AWinControl.Handle).orderFrontRegardless
|
|
||||||
else
|
|
||||||
NSWindow(AWinControl.Handle).orderOut(nil);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TCocoaWSCustomForm.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
class function TCocoaWSCustomForm.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := AWinControl.HandleAllocated;
|
Result := AWinControl.HandleAllocated;
|
||||||
|
@ -158,7 +158,7 @@ type
|
|||||||
|
|
||||||
TCocoaWSButton = class(TWSButton)
|
TCocoaWSButton = class(TWSButton)
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
|
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -221,7 +221,8 @@ begin
|
|||||||
cap := NSStringUTF8(AParams.Caption);
|
cap := NSStringUTF8(AParams.Caption);
|
||||||
Result.setTitle(cap);
|
Result.setTitle(cap);
|
||||||
cap.release;
|
cap.release;
|
||||||
if btnBezel<>0 then Result.setBezelStyle(btnBezel);
|
if btnBezel <> 0 then
|
||||||
|
Result.setBezelStyle(btnBezel);
|
||||||
Result.setButtonType(btnType);
|
Result.setButtonType(btnType);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user