mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 19:39:28 +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
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Paint; override;
|
|
||||||
procedure DoLoadBounds; virtual;
|
procedure DoLoadBounds; virtual;
|
||||||
procedure DoSaveBounds; virtual;
|
procedure DoSaveBounds; virtual;
|
||||||
public
|
public
|
||||||
@ -96,7 +95,9 @@ begin
|
|||||||
FLookupRoot := AValue;
|
FLookupRoot := AValue;
|
||||||
if FLookupRoot <> nil then
|
if FLookupRoot <> nil then
|
||||||
begin
|
begin
|
||||||
Caption:=FLookupRoot.Name;
|
if FLookupRoot is TCustomFrame then
|
||||||
|
TCustomFrame(FLookupRoot).Parent := Self;
|
||||||
|
Caption := FLookupRoot.Name;
|
||||||
end;
|
end;
|
||||||
DoLoadBounds;
|
DoLoadBounds;
|
||||||
end;
|
end;
|
||||||
@ -120,59 +121,32 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
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 TFrameDesignerForm.DoLoadBounds;
|
||||||
|
|
||||||
procedure SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight: integer);
|
procedure SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight: integer);
|
||||||
begin
|
begin
|
||||||
if NewWidth<=0 then NewWidth:=Width;
|
if NewWidth<= 0 then NewWidth := Width;
|
||||||
if NewHeight<=0 then NewHeight:=Height;
|
if NewHeight<= 0 then NewHeight := Height;
|
||||||
|
|
||||||
NewWidth:=Max(20,Min(NewWidth,Screen.Width-50));
|
NewWidth := Max(20, Min(NewWidth, Screen.Width - 50));
|
||||||
NewHeight:=Max(20,Min(NewHeight,Screen.Height-50));
|
NewHeight := Max(20, Min(NewHeight, Screen.Height - 50));
|
||||||
NewLeft:=Max(0,Min(NewLeft,Screen.Width-NewWidth-50));
|
SetBounds(Left, Top, Max(20, NewWidth), Max(NewHeight, 20));
|
||||||
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));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
CurFrame: TFrame;
|
CurFrame: TCustomFrame;
|
||||||
NewLeft: Integer;
|
|
||||||
NewTop: Integer;
|
|
||||||
NewWidth: Integer;
|
NewWidth: Integer;
|
||||||
NewHeight: Integer;
|
NewHeight: Integer;
|
||||||
begin
|
begin
|
||||||
if Assigned(OnLoadBounds) then OnLoadBounds(Self);
|
if Assigned(OnLoadBounds) then
|
||||||
if LookupRoot is TFrame then
|
OnLoadBounds(Self);
|
||||||
|
if LookupRoot is TCustomFrame then
|
||||||
begin
|
begin
|
||||||
CurFrame := TFrame(LookupRoot);
|
CurFrame := TCustomFrame(LookupRoot);
|
||||||
NewLeft := CurFrame.Left;
|
|
||||||
NewTop := CurFrame.Top;
|
|
||||||
NewWidth := CurFrame.Width;
|
NewWidth := CurFrame.Width;
|
||||||
NewHeight := CurFrame.Height;
|
NewHeight := CurFrame.Height;
|
||||||
|
|
||||||
SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
SetNewBounds(Left, Top, NewWidth, NewHeight);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if LookupRoot <> nil then
|
if LookupRoot <> nil then
|
||||||
@ -184,7 +158,7 @@ end;
|
|||||||
procedure TFrameDesignerForm.DoSaveBounds;
|
procedure TFrameDesignerForm.DoSaveBounds;
|
||||||
begin
|
begin
|
||||||
if LookupRoot is TFrame then
|
if LookupRoot is TFrame then
|
||||||
TFrame(LookupRoot).SetBounds(Left, Top, Width, Height)
|
TFrame(LookupRoot).SetBounds(0, 0, Width, Height)
|
||||||
else
|
else
|
||||||
if LookupRoot <> nil then
|
if LookupRoot <> nil then
|
||||||
;//?
|
;//?
|
||||||
|
@ -255,6 +255,7 @@ type
|
|||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCustomFrameClass = class of TCustomFrame;
|
TCustomFrameClass = class of TCustomFrame;
|
||||||
|
@ -113,6 +113,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
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 }
|
{ TFrame }
|
||||||
|
|
||||||
function TFrame.LCLVersionIsStored: boolean;
|
function TFrame.LCLVersionIsStored: boolean;
|
||||||
|
@ -2567,7 +2567,7 @@ begin
|
|||||||
P.x := GET_X_LPARAM(lParam);
|
P.x := GET_X_LPARAM(lParam);
|
||||||
P.y := GET_Y_LPARAM(lParam);
|
P.y := GET_Y_LPARAM(lParam);
|
||||||
Windows.ScreenToClient(Parent, P);
|
Windows.ScreenToClient(Parent, P);
|
||||||
if (Owner is TCustomForm) then
|
if (Owner is TCustomForm) or (Owner is TCustomFrame) then
|
||||||
begin
|
begin
|
||||||
// ask form about control under mouse. we need TWinControl
|
// ask form about control under mouse. we need TWinControl
|
||||||
Control := Owner.ControlAtPos(P, [capfAllowWinControls]);
|
Control := Owner.ControlAtPos(P, [capfAllowWinControls]);
|
||||||
|
@ -223,9 +223,6 @@ begin
|
|||||||
if Sender is TControlCanvas then
|
if Sender is TControlCanvas then
|
||||||
Window := TControlCanvas(Sender).Handle
|
Window := TControlCanvas(Sender).Handle
|
||||||
else
|
else
|
||||||
if Sender is TCustomForm then
|
|
||||||
Window := TCustomForm(Sender).Handle
|
|
||||||
else
|
|
||||||
Window := TWinControl(Sender).Handle;
|
Window := TWinControl(Sender).Handle;
|
||||||
|
|
||||||
if Window = 0 then Exit;
|
if Window = 0 then Exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user