mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 01:19:37 +02:00
ide:
- set parent for frame to show its content - fix frame positioning in the designer git-svn-id: trunk@15057 -
This commit is contained in:
parent
faa5e06bf4
commit
906fc15355
@ -49,7 +49,6 @@ type
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Paint; override;
|
||||
procedure DoLoadBounds; virtual;
|
||||
procedure DoSaveBounds; virtual;
|
||||
public
|
||||
@ -96,7 +95,9 @@ begin
|
||||
FLookupRoot := AValue;
|
||||
if FLookupRoot <> nil then
|
||||
begin
|
||||
Caption:=FLookupRoot.Name;
|
||||
if FLookupRoot is TCustomFrame then
|
||||
TCustomFrame(FLookupRoot).Parent := Self;
|
||||
Caption := FLookupRoot.Name;
|
||||
end;
|
||||
DoLoadBounds;
|
||||
end;
|
||||
@ -120,59 +121,32 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TFrameDesignerForm.Paint;
|
||||
{var
|
||||
ARect: TRect;}
|
||||
begin
|
||||
inherited Paint;
|
||||
{
|
||||
with Canvas do
|
||||
begin
|
||||
Brush.Color:=clWhite;
|
||||
ARect:=Rect(FrameWidth,FrameWidth,
|
||||
Self.ClientWidth-FrameWidth,
|
||||
Self.ClientHeight-FrameWidth);
|
||||
FillRect(ARect);
|
||||
ARect:=Rect(0,0,Self.ClientWidth+1,Self.ClientHeight+1);
|
||||
Pen.Color:=clBlack;
|
||||
Frame3d(ARect, FrameWidth, bvLowered);
|
||||
end;
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TFrameDesignerForm.DoLoadBounds;
|
||||
|
||||
procedure SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight: integer);
|
||||
begin
|
||||
if NewWidth<=0 then NewWidth:=Width;
|
||||
if NewHeight<=0 then NewHeight:=Height;
|
||||
if NewWidth<= 0 then NewWidth := Width;
|
||||
if NewHeight<= 0 then NewHeight := Height;
|
||||
|
||||
NewWidth:=Max(20,Min(NewWidth,Screen.Width-50));
|
||||
NewHeight:=Max(20,Min(NewHeight,Screen.Height-50));
|
||||
NewLeft:=Max(0,Min(NewLeft,Screen.Width-NewWidth-50));
|
||||
NewTop:=Max(0,Min(NewTop,Screen.Height-NewHeight-50));
|
||||
|
||||
//debugln('TFrameDesignerForm.DoLoadBounds (TDataModule) ',dbgsName(LookupRoot),' ',dbgs(NewLeft),',',dbgs(NewTop),',',dbgs(NewWidth),',',dbgs(NewHeight));
|
||||
SetBounds(NewLeft,NewTop,Max(20,NewWidth),Max(NewHeight,20));
|
||||
NewWidth := Max(20, Min(NewWidth, Screen.Width - 50));
|
||||
NewHeight := Max(20, Min(NewHeight, Screen.Height - 50));
|
||||
SetBounds(Left, Top, Max(20, NewWidth), Max(NewHeight, 20));
|
||||
end;
|
||||
|
||||
var
|
||||
CurFrame: TFrame;
|
||||
NewLeft: Integer;
|
||||
NewTop: Integer;
|
||||
CurFrame: TCustomFrame;
|
||||
NewWidth: Integer;
|
||||
NewHeight: Integer;
|
||||
begin
|
||||
if Assigned(OnLoadBounds) then OnLoadBounds(Self);
|
||||
if LookupRoot is TFrame then
|
||||
if Assigned(OnLoadBounds) then
|
||||
OnLoadBounds(Self);
|
||||
if LookupRoot is TCustomFrame then
|
||||
begin
|
||||
CurFrame := TFrame(LookupRoot);
|
||||
NewLeft := CurFrame.Left;
|
||||
NewTop := CurFrame.Top;
|
||||
CurFrame := TCustomFrame(LookupRoot);
|
||||
NewWidth := CurFrame.Width;
|
||||
NewHeight := CurFrame.Height;
|
||||
|
||||
SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
||||
SetNewBounds(Left, Top, NewWidth, NewHeight);
|
||||
end
|
||||
else
|
||||
if LookupRoot <> nil then
|
||||
@ -184,7 +158,7 @@ end;
|
||||
procedure TFrameDesignerForm.DoSaveBounds;
|
||||
begin
|
||||
if LookupRoot is TFrame then
|
||||
TFrame(LookupRoot).SetBounds(Left, Top, Width, Height)
|
||||
TFrame(LookupRoot).SetBounds(0, 0, Width, Height)
|
||||
else
|
||||
if LookupRoot <> nil then
|
||||
;//?
|
||||
|
@ -255,6 +255,7 @@ type
|
||||
class function GetControlClassDefaultSize: TPoint; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
|
||||
end;
|
||||
|
||||
TCustomFrameClass = class of TCustomFrame;
|
||||
|
@ -113,6 +113,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomFrame.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
|
||||
begin
|
||||
if csDesignInstance in ComponentState then
|
||||
begin
|
||||
// dont move frame in the designer
|
||||
aLeft := 0;
|
||||
aTop := 0;
|
||||
end;
|
||||
inherited SetBounds(aLeft, aTop, aWidth, aHeight);
|
||||
end;
|
||||
|
||||
{ TFrame }
|
||||
|
||||
function TFrame.LCLVersionIsStored: boolean;
|
||||
|
@ -2567,7 +2567,7 @@ begin
|
||||
P.x := GET_X_LPARAM(lParam);
|
||||
P.y := GET_Y_LPARAM(lParam);
|
||||
Windows.ScreenToClient(Parent, P);
|
||||
if (Owner is TCustomForm) then
|
||||
if (Owner is TCustomForm) or (Owner is TCustomFrame) then
|
||||
begin
|
||||
// ask form about control under mouse. we need TWinControl
|
||||
Control := Owner.ControlAtPos(P, [capfAllowWinControls]);
|
||||
|
@ -223,9 +223,6 @@ begin
|
||||
if Sender is TControlCanvas then
|
||||
Window := TControlCanvas(Sender).Handle
|
||||
else
|
||||
if Sender is TCustomForm then
|
||||
Window := TCustomForm(Sender).Handle
|
||||
else
|
||||
Window := TWinControl(Sender).Handle;
|
||||
|
||||
if Window = 0 then Exit;
|
||||
|
Loading…
Reference in New Issue
Block a user