mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 14:36:09 +02:00
cocoa: placing a customcontrol manualscrollview into manualscrollhost. The host itself is a scrollview. But it is not used for Scroll, but rather for the feature of drawing the border. bug #34761
git-svn-id: trunk@61694 -
This commit is contained in:
parent
9bdaa98047
commit
1e8719327f
@ -141,6 +141,9 @@ type
|
||||
|
||||
end;
|
||||
|
||||
TCocoaManualScrollHost = objcclass(TCocoaScrollView)
|
||||
end;
|
||||
|
||||
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
||||
|
||||
// These settings are set by a user in "System Preferences"
|
||||
|
@ -1568,6 +1568,9 @@ begin
|
||||
Result := Assigned(obj);
|
||||
if not Result then Exit;
|
||||
|
||||
if obj.isKindOfClass(TCocoaManualScrollHost) then
|
||||
obj := TCocoaManualScrollHost(obj).documentView;
|
||||
|
||||
if obj.isKindOfClass(NSScrollView) then
|
||||
begin
|
||||
sc := NSScrollView(obj);
|
||||
@ -1602,6 +1605,9 @@ begin
|
||||
Result := Assigned(obj);
|
||||
if not Result then Exit;
|
||||
|
||||
if obj.isKindOfClass(TCocoaManualScrollHost) then
|
||||
obj := TCocoaManualScrollHost(obj).documentView;
|
||||
|
||||
if obj.isKindOfClass(TCocoaScrollBar) then
|
||||
Result := CocoaScrollBarGetScrollInfo(TCocoaScrollBar(obj), ScrollInfo)
|
||||
else
|
||||
@ -1792,11 +1798,19 @@ var
|
||||
f : NSSize;
|
||||
sz : NSSize;
|
||||
flg : NSUInteger;
|
||||
hosted: Boolean;
|
||||
begin
|
||||
obj := NSObject(Handle);
|
||||
Result := 0;
|
||||
if not Assigned(obj) then Exit;
|
||||
|
||||
if obj.isKindOfClass(TCocoaManualScrollHost) then
|
||||
begin
|
||||
hosted := true;
|
||||
obj := TCocoaManualScrollHost(obj).documentView;
|
||||
end else
|
||||
hosted := false;
|
||||
|
||||
if obj.isKindOfClass(TCocoaScrollView) then
|
||||
begin
|
||||
sc:=TCocoaScrollView(obj);
|
||||
@ -1848,6 +1862,9 @@ begin
|
||||
else
|
||||
Result := 0;
|
||||
|
||||
if hosted then
|
||||
NSView(obj).lclInvalidate;
|
||||
|
||||
end else if obj.isKindOfClass(TCocoaScrollBar) then
|
||||
begin
|
||||
Result := CocoaScrollBarSetScrollInfo(TCocoaScrollBar(obj), ScrollInfo);
|
||||
@ -1866,6 +1883,9 @@ begin
|
||||
Result := Assigned(obj);
|
||||
if not Result then Exit;
|
||||
|
||||
if obj.isKindOfClass(TCocoaManualScrollHost) then
|
||||
obj := TCocoaManualScrollHost(obj).documentView;
|
||||
|
||||
if obj.isKindOfClass(TCocoaScrollView)
|
||||
then begin
|
||||
Result := true;
|
||||
|
@ -147,12 +147,15 @@ type
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure SetBorderStyle(const AWinControl: TWinControl;
|
||||
const ABorderStyle: TBorderStyle); override;
|
||||
end;
|
||||
|
||||
// Utility WS functions. todo: it makes sense to put them into CocoaScollers
|
||||
|
||||
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean = true): TCocoaScrollView;
|
||||
function EmbedInManualScrollView(AView: NSView): TCocoaManualScrollView;
|
||||
function EmbedInManualScrollHost(AView: TCocoaManualScrollView): TCocoaManualScrollHost;
|
||||
|
||||
function HWNDToTargetObject(AFormHandle: HWND): TObject;
|
||||
|
||||
@ -275,6 +278,38 @@ begin
|
||||
TCocoaCustomControl(AView).auxMouseByParent := true;
|
||||
end;
|
||||
|
||||
function EmbedInManualScrollHost(AView: TCocoaManualScrollView
|
||||
): TCocoaManualScrollHost;
|
||||
var
|
||||
r: TRect;
|
||||
p: NSView;
|
||||
begin
|
||||
if not Assigned(AView) then
|
||||
Exit(nil);
|
||||
r := AView.lclFrame;
|
||||
p := AView.superview;
|
||||
Result := TCocoaManualScrollHost.alloc.initWithFrame(NSNullRect);
|
||||
if Assigned(p) then p.addSubView(Result);
|
||||
Result.lclSetFrame(r);
|
||||
{$ifdef BOOLFIX}
|
||||
Result.setHidden_(Ord(AView.isHidden));
|
||||
{$else}
|
||||
Result.setHidden(AView.isHidden);
|
||||
{$endif}
|
||||
Result.setDocumentView(AView);
|
||||
Result.setDrawsBackground(false); // everything is covered anyway
|
||||
Result.contentView.setAutoresizesSubviews(true);
|
||||
AView.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
|
||||
|
||||
AView.release;
|
||||
{$ifdef BOOLFIX}
|
||||
AView.setHidden_(Ord(false));
|
||||
{$else}
|
||||
AView.setHidden(false);
|
||||
{$endif}
|
||||
SetViewDefaults(Result);
|
||||
end;
|
||||
|
||||
{ TLCLCommonCallback }
|
||||
|
||||
function TLCLCommonCallback.GetHasCaret: Boolean;
|
||||
@ -1783,7 +1818,9 @@ class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl
|
||||
var
|
||||
ctrl : TCocoaCustomControl;
|
||||
sl : TCocoaManualScrollView;
|
||||
hs : TCocoaManualScrollHost;
|
||||
lcl : TLCLCommonCallback;
|
||||
|
||||
begin
|
||||
ctrl := TCocoaCustomControl(TCocoaCustomControl.alloc.lclInitWithCreateParams(AParams));
|
||||
lcl := TLCLCommonCallback.Create(ctrl, AWinControl);
|
||||
@ -1793,9 +1830,21 @@ begin
|
||||
|
||||
sl := EmbedInManualScrollView(ctrl);
|
||||
sl.callback := ctrl.callback;
|
||||
lcl.HandleFrame:=sl;
|
||||
|
||||
Result := TLCLIntfHandle(sl);
|
||||
hs := EmbedInManualScrollHost(sl);
|
||||
hs.callback := ctrl.callback;
|
||||
lcl.HandleFrame:=hs;
|
||||
|
||||
ScrollViewSetBorderStyle(hs, TCustomControl(AWinControl).BorderStyle );
|
||||
|
||||
Result := TLCLIntfHandle(hs);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomControl.SetBorderStyle(
|
||||
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
|
||||
begin
|
||||
if not Assigned(AWinControl) or not (AWinControl.HandleAllocated) then Exit;
|
||||
ScrollViewSetBorderStyle( TCocoaManualScrollHost(AWinControl.Handle), ABorderStyle );
|
||||
end;
|
||||
|
||||
function HWNDToTargetObject(AFormHandle: HWND): TObject;
|
||||
|
Loading…
Reference in New Issue
Block a user