Implemented BringToFront / SendToBack.

git-svn-id: trunk@267 -
This commit is contained in:
lazarus 2001-05-13 22:07:09 +00:00
parent 34fb4ae355
commit 505bc9fa3d
5 changed files with 104 additions and 12 deletions

View File

@ -64,6 +64,8 @@ type
FMirrorVerticalMenuItem: TMenuItem;
FScaleMenuItem: TMenuItem;
FSizeMenuItem: TMenuItem;
FBringToFrontMenuItem: TMenuItem;
FSendToBackMenuItem: TMenuItem;
function GetIsControl: Boolean;
procedure SetIsControl(Value: Boolean);
@ -92,6 +94,8 @@ type
procedure OnMirrorVerticalPopupMenuClick(Sender: TObject);
procedure OnScalePopupMenuClick(Sender: TObject);
procedure OnSizePopupMenuClick(Sender: TObject);
procedure OnBringToFrontMenuClick(Sender: TObject);
procedure OnSendToBackMenuClick(Sender: TObject);
public
ControlSelection : TControlSelection;
constructor Create(Customform : TCustomform; AControlSelection: TControlSelection);
@ -870,6 +874,23 @@ begin
Enabled := CompsAreSelected and OnlyNonVisualCompsAreSelected;
end;
FPopupMenu.Items.Add(FSizeMenuItem);
FBringToFrontMenuItem := TMenuItem.Create(nil);
with FBringToFrontMenuItem do begin
Caption:= 'Bring to front';
OnClick:= @OnBringToFrontMenuClick;
Enabled:= CompsAreSelected;
end;
FPopupMenu.Items.Add(FBringToFrontMenuItem);
FSendToBackMenuItem:= TMenuItem.Create(nil);
with FSendToBackMenuItem do begin
Caption:= 'Send to back';
OnClick:= @OnSendToBackMenuClick;
Enabled:= CompsAreSelected;
end;
FPopupMenu.Items.Add(FSendToBackMenuItem);
end;
procedure TDesigner.OnAlignPopupMenuClick(Sender: TObject);
@ -952,6 +973,24 @@ begin
ControlSelection.SaveBounds;
end;
procedure TDesigner.OnBringToFrontMenuClick(Sender: TObject);
var AComponent : TComponent;
begin
if ControlSelection.Count = 1 then begin
AComponent:= ControlSelection.Items[0].Component;
if AComponent is TControl then TControl(AComponent).BringToFront;
end;
end;
procedure TDesigner.OnSendToBackMenuClick(Sender: TObject);
var AComponent : TComponent;
begin
if ControlSelection.Count = 1 then begin
AComponent:= ControlSelection.Items[0].Component;
if AComponent is TControl then TControl(AComponent).SendToBack;
end;
end;
initialization
GridSizex := 10;

View File

@ -507,13 +507,14 @@ TCMDialogKey = TLMKEY;
// use overload to simulate default
procedure BeginDrag(Immediate: Boolean; Threshold: Integer); //overload;
procedure BeginDrag(Immediate: Boolean); //overload;
Procedure BringToFront;
procedure BringToFront;
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
procedure Repaint; virtual;
Procedure Invalidate; virtual;
procedure AddControl; virtual;
Procedure DragDrop(Source: TObject; X,Y : Integer); Dynamic;
procedure SendToBack;
procedure SetBounds(aLeft, aTop, aWidth, aHeight : integer); virtual;
function GetTextBuf(Buffer: PChar; BufSize: Integer): Integer;
Procedure SetTextBuf(Buffer : PChar);
@ -1131,6 +1132,9 @@ end.
{ =============================================================================
$Log$
Revision 1.19 2001/05/13 22:07:08 lazarus
Implemented BringToFront / SendToBack.
Revision 1.18 2001/03/27 21:12:53 lazarus
MWE:
+ Turned on longstrings

View File

@ -72,7 +72,7 @@ end;
{------------------------------------------------------------------------------}
Procedure TControl.BringToFront;
begin
SetZOrder(True);
SetZOrder(true);
end;
{------------------------------------------------------------------------------}
@ -1092,12 +1092,34 @@ end;
}
{------------------------------------------------------------------------------}
Procedure TControl.SetZOrder(Topmost : Boolean);
var AParent : TWinControl;
AControl : TControl;
begin
if FParent <> nil then
if Topmost then SetZOrderPosition(FParent.FControls.Count-1)
else
SetZOrderPosition(0);
//if FParent <> nil then
// if Topmost then SetZOrderPosition(FParent.FControls.Count-1)
// else
// SetZOrderPosition(0);
if Parent <> nil then begin
AParent:= Parent;
{ Just reinsert the control on top. Don't if it already is }
if Topmost then begin
if (AParent.Controls[AParent.ControlCount - 1] <> Self) then begin
AParent.RemoveControl(Self);
AParent.InsertControl(Self);
end;
end else begin
{ Move all other controls over this one }
if (AParent.Controls[0] <> Self) then begin
AParent.RemoveControl(Self);
AParent.InsertControl(Self);
while AParent.Controls[0] <> Self do begin
AControl:= AParent.Controls[0];
AParent.RemoveControl(AControl);
AParent.InsertControl(AControl);
end;
end;
end;
end;
end;
{------------------------------------------------------------------------------}
@ -1304,6 +1326,18 @@ begin
Result := Parent.GetDeviceContext(WindowHandle);
end;
{------------------------------------------------------------------------------
Method: TControl.SendToBack
Params: None
Returns: Nothing
Puts a control back in Z-order behind all other controls
------------------------------------------------------------------------------}
procedure TControl.SendToBack;
begin
SetZOrder(false);
end;
{$IFDEF ASSERT_IS_ON}
{$UNDEF ASSERT_IS_ON}
{$C-}
@ -1311,6 +1345,9 @@ end;
{ =============================================================================
$Log$
Revision 1.20 2001/05/13 22:07:08 lazarus
Implemented BringToFront / SendToBack.
Revision 1.19 2001/04/02 14:45:26 lazarus
MG: bugfixes for TBevel

View File

@ -368,10 +368,11 @@ var i: integer;
begin
if FParent <> nil then
begin
if TopMost then i := FParent.FWinControls.Count - 1
else i := 0;
if FParent.FControls <> nil then inc(i, FParent.FControls.Count);
SetZOrderPosition(i);
// if TopMost then i := FParent.FWinControls.Count - 1
// else i := 0;
// if FParent.FControls <> nil then inc(i, FParent.FControls.Count);
// SetZOrderPosition(i);
inherited SetZOrder(TopMost);
end
else if FHandle <> 0 then begin
InterfaceObject.SetWindowPos(FHandle, WindowPos[TopMost], 0, 0, 0, 0,
@ -1965,6 +1966,9 @@ end;
{ =============================================================================
$Log$
Revision 1.29 2001/05/13 22:07:08 lazarus
Implemented BringToFront / SendToBack.
Revision 1.28 2001/04/02 14:45:26 lazarus
MG: bugfixes for TBevel

View File

@ -394,7 +394,12 @@ begin
begin
Assert(False, 'Trace:TODO:bringtofront');
//For now just hide and show again.
if (Sender is TControl) then begin
TControl(Sender).Parent.RemoveControl(TControl(Sender));
writeln('Removed control ', TControl(Sender).Name);
TControl(Sender).Parent.InsertControl(TControl(Sender));
writeln('Inserted control ', TControl(Sender).Name);
end;
end;
LM_BTNDEFAULT_CHANGED :
@ -2841,6 +2846,9 @@ end;
{ =============================================================================
$Log$
Revision 1.45 2001/05/13 22:07:09 lazarus
Implemented BringToFront / SendToBack.
Revision 1.44 2001/04/13 17:56:17 lazarus
MWE:
* Moved menubar outside clientarea