mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 07:29:59 +02:00
MG: implemented GridSizeX, GridSizeY and DisplayGrid
git-svn-id: trunk@1746 -
This commit is contained in:
parent
1f1c94bd67
commit
1892b7d5aa
@ -35,7 +35,7 @@ interface
|
||||
uses
|
||||
Classes, LCLType, LCLLinux, Forms, Controls, LMessages, Graphics,
|
||||
ControlSelection, CustomFormEditor, FormEditor, UnitEditor, CompReg, Menus,
|
||||
AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg, ExtCtrls;
|
||||
AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg, ExtCtrls, EnvironmentOpts;
|
||||
|
||||
type
|
||||
TDesigner = class;
|
||||
@ -85,7 +85,13 @@ type
|
||||
//hint stuff
|
||||
FHintTimer : TTimer;
|
||||
FHintWIndow : THintWindow;
|
||||
function GetDisplayGrid: boolean;
|
||||
function GetGridSizeX: integer;
|
||||
function GetGridSizeY: integer;
|
||||
function GetIsControl: Boolean;
|
||||
procedure SetDisplayGrid(const AValue: boolean);
|
||||
procedure SetGridSizeX(const AValue: integer);
|
||||
procedure SetGridSizeY(const AValue: integer);
|
||||
procedure SetIsControl(Value: Boolean);
|
||||
procedure InvalidateWithParent(AComponent: TComponent);
|
||||
Procedure HintTimer(sender : TObject);
|
||||
@ -128,11 +134,17 @@ type
|
||||
procedure ValidateRename(AComponent: TComponent;
|
||||
const CurName, NewName: string); override;
|
||||
Procedure SelectOnlyThisComponent(AComponent:TComponent);
|
||||
function NonVisualComponentAtPos(x,y: integer): TComponent;
|
||||
procedure DrawNonVisualComponents(DC: HDC);
|
||||
|
||||
property IsControl: Boolean read GetIsControl write SetIsControl;
|
||||
property DisplayGrid: boolean read GetDisplayGrid write SetDisplayGrid;
|
||||
property Form: TCustomForm read FCustomForm write FCustomForm;
|
||||
property FormEditor : TFormEditor read FFormEditor write FFormEditor;
|
||||
property SourceEditor : TSourceEditor read FSourceEditor write FSourceEditor;
|
||||
property FormEditor: TFormEditor read FFormEditor write FFormEditor;
|
||||
property GridSizeX: integer read GetGridSizeX write SetGridSizeX;
|
||||
property GridSizeY: integer read GetGridSizeY write SetGridSizeY;
|
||||
property IsControl: Boolean read GetIsControl write SetIsControl;
|
||||
property OnActivated: TNotifyEvent
|
||||
read FOnActivated write FOnActivated;
|
||||
property OnAddComponent: TOnAddComponent read FOnAddComponent write FOnAddComponent;
|
||||
property OnComponentListChanged: TNotifyEvent
|
||||
read FOnComponentListChanged write FOnComponentListChanged;
|
||||
@ -143,22 +155,18 @@ type
|
||||
read FOnPropertiesChanged write FOnPropertiesChanged;
|
||||
property OnRemoveComponent: TOnRemoveComponent
|
||||
read FOnRemoveComponent write FOnRemoveComponent;
|
||||
property OnRenameComponent: TOnRenameComponent
|
||||
read FOnRenameComponent write FOnRenameComponent;
|
||||
property OnSetDesigning: TOnSetDesigning read FOnSetDesigning write FOnSetDesigning;
|
||||
property OnUnselectComponentClass: TNotifyEvent
|
||||
read FOnUnselectComponentClass write FOnUnselectComponentClass;
|
||||
property OnActivated: TNotifyEvent
|
||||
read FOnActivated write FOnActivated;
|
||||
property OnRenameComponent: TOnRenameComponent
|
||||
read FOnRenameComponent write FOnRenameComponent;
|
||||
function NonVisualComponentAtPos(x,y: integer): TComponent;
|
||||
procedure DrawNonVisualComponents(DC: HDC);
|
||||
property OnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas
|
||||
read FOnGetNonVisualCompIconCanvas write FOnGetNonVisualCompIconCanvas;
|
||||
property ShowHints: boolean read FShowHints write FShowHints;
|
||||
property SourceEditor : TSourceEditor read FSourceEditor write FSourceEditor;
|
||||
end;
|
||||
|
||||
|
||||
var GridSizeX, GridSizeY: integer;
|
||||
|
||||
|
||||
implementation
|
||||
@ -796,22 +804,23 @@ end;
|
||||
|
||||
procedure TDesigner.PaintGrid;
|
||||
var
|
||||
x,y : integer;
|
||||
x,y, StepX, StepY : integer;
|
||||
begin
|
||||
if not DisplayGrid then exit;
|
||||
StepX:=GridSizeX;
|
||||
StepY:=GridSizeY;
|
||||
with FCustomForm.Canvas do begin
|
||||
Pen.Color := FGridColor;
|
||||
x := 0;
|
||||
while x <= FCustomForm.Width do begin
|
||||
y := 0;
|
||||
while y <= FCustomForm.Height do begin
|
||||
|
||||
MoveTo(x,y);
|
||||
LineTo(x+1,y);
|
||||
// Pixels[X,Y]:=FGridColor;
|
||||
|
||||
Inc(y, GridSizeY);
|
||||
Inc(y, StepY);
|
||||
end;
|
||||
Inc(x, GridSizeX);
|
||||
Inc(x, StepX);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -832,11 +841,47 @@ Begin
|
||||
OnRenameComponent(Self,AComponent,NewName);
|
||||
end;
|
||||
|
||||
function TDesigner.GetDisplayGrid: boolean;
|
||||
begin
|
||||
Result:=EnvironmentOptions.DisplayGrid;
|
||||
end;
|
||||
|
||||
function TDesigner.GetGridSizeX: integer;
|
||||
begin
|
||||
Result:=EnvironmentOptions.GridSizeX;
|
||||
if Result<2 then Result:=2;
|
||||
end;
|
||||
|
||||
function TDesigner.GetGridSizeY: integer;
|
||||
begin
|
||||
Result:=EnvironmentOptions.GridSizeY;
|
||||
if Result<2 then Result:=2;
|
||||
end;
|
||||
|
||||
function TDesigner.GetIsControl: Boolean;
|
||||
Begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TDesigner.SetDisplayGrid(const AValue: boolean);
|
||||
begin
|
||||
if DisplayGrid=AValue then exit;
|
||||
EnvironmentOptions.DisplayGrid:=AValue;
|
||||
Form.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TDesigner.SetGridSizeX(const AValue: integer);
|
||||
begin
|
||||
if GridSizeX=AValue then exit;
|
||||
EnvironmentOptions.GridSizeX:=AValue;
|
||||
end;
|
||||
|
||||
procedure TDesigner.SetGridSizeY(const AValue: integer);
|
||||
begin
|
||||
if GridSizeY=AValue then exit;
|
||||
EnvironmentOptions.GridSizeY:=AValue;
|
||||
end;
|
||||
|
||||
procedure TDesigner.SetIsControl(Value: Boolean);
|
||||
Begin
|
||||
|
||||
@ -935,7 +980,7 @@ begin
|
||||
|
||||
FPopupMenu:=TPopupMenu.Create(nil);
|
||||
|
||||
FAlignMenuItem := TMenuItem.Create(nil);
|
||||
FAlignMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FAlignMenuItem do begin
|
||||
Caption := 'Align';
|
||||
OnClick := @OnAlignPopupMenuClick;
|
||||
@ -943,7 +988,7 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FAlignMenuItem);
|
||||
|
||||
FMirrorHorizontalMenuItem := TMenuItem.Create(nil);
|
||||
FMirrorHorizontalMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FMirrorHorizontalMenuItem do begin
|
||||
Caption := 'Mirror horizontal';
|
||||
OnClick := @OnMirrorHorizontalPopupMenuClick;
|
||||
@ -951,7 +996,7 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FMirrorHorizontalMenuItem);
|
||||
|
||||
FMirrorVerticalMenuItem := TMenuItem.Create(nil);
|
||||
FMirrorVerticalMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FMirrorVerticalMenuItem do begin
|
||||
Caption := 'Mirror vertical';
|
||||
OnClick := @OnMirrorVerticalPopupMenuClick;
|
||||
@ -959,7 +1004,7 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FMirrorVerticalMenuItem);
|
||||
|
||||
FScaleMenuItem := TMenuItem.Create(nil);
|
||||
FScaleMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FScaleMenuItem do begin
|
||||
Caption := 'Scale';
|
||||
OnClick := @OnScalePopupMenuClick;
|
||||
@ -967,7 +1012,7 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FScaleMenuItem);
|
||||
|
||||
FSizeMenuItem := TMenuItem.Create(nil);
|
||||
FSizeMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FSizeMenuItem do begin
|
||||
Caption := 'Size';
|
||||
OnClick := @OnSizePopupMenuClick;
|
||||
@ -975,7 +1020,7 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FSizeMenuItem);
|
||||
|
||||
FBringToFrontMenuItem := TMenuItem.Create(nil);
|
||||
FBringToFrontMenuItem := TMenuItem.Create(FPopupMenu);
|
||||
with FBringToFrontMenuItem do begin
|
||||
Caption:= 'Bring to front';
|
||||
OnClick:= @OnBringToFrontMenuClick;
|
||||
@ -983,14 +1028,13 @@ begin
|
||||
end;
|
||||
FPopupMenu.Items.Add(FBringToFrontMenuItem);
|
||||
|
||||
FSendToBackMenuItem:= TMenuItem.Create(nil);
|
||||
FSendToBackMenuItem:= TMenuItem.Create(FPopupMenu);
|
||||
with FSendToBackMenuItem do begin
|
||||
Caption:= 'Send to back';
|
||||
OnClick:= @OnSendToBackMenuClick;
|
||||
Enabled:= CompsAreSelected;
|
||||
end;
|
||||
FPopupMenu.Items.Add(FSendToBackMenuItem);
|
||||
|
||||
end;
|
||||
|
||||
procedure TDesigner.OnAlignPopupMenuClick(Sender: TObject);
|
||||
@ -1145,9 +1189,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
GridSizex := 10;
|
||||
GridSizeY := 10;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -1713,7 +1713,6 @@ begin
|
||||
Width:=200;
|
||||
Height:=23;
|
||||
Caption:='Display grid';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1726,7 +1725,6 @@ begin
|
||||
Width:=DisplayGridCheckBox.Width;
|
||||
Height:=DisplayGridCheckBox.Height;
|
||||
Caption:='Snap to grid';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1739,7 +1737,6 @@ begin
|
||||
Width:=DisplayGridCheckBox.Width;
|
||||
Height:=DisplayGridCheckBox.Height;
|
||||
Caption:='Show component captions';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1764,7 +1761,6 @@ begin
|
||||
Width:=DisplayGridCheckBox.Width;
|
||||
Height:=DisplayGridCheckBox.Height;
|
||||
Caption:='Auto create forms';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1777,7 +1773,6 @@ begin
|
||||
Width:=80;
|
||||
Height:=20;
|
||||
Caption:='Grid size X';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1797,7 +1792,6 @@ begin
|
||||
Add('10');
|
||||
EndUpdate;
|
||||
end;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1810,7 +1804,6 @@ begin
|
||||
Width:=GridSizeXLabel.Width;
|
||||
Height:=20;
|
||||
Caption:='Grid size Y';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -1830,7 +1823,6 @@ begin
|
||||
Add('10');
|
||||
EndUpdate;
|
||||
end;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
|
26
ide/main.pp
26
ide/main.pp
@ -188,7 +188,7 @@ type
|
||||
procedure OnPropHookShowMethod(const AMethodName:ShortString);
|
||||
procedure OnPropHookRenameMethod(const CurName, NewName:ShortString);
|
||||
|
||||
// designer
|
||||
// designer events
|
||||
procedure OnDesignerGetSelectedComponentClass(Sender: TObject;
|
||||
var RegisteredComponent: TRegisteredComponent);
|
||||
procedure OnDesignerUnselectComponentClass(Sender: TObject);
|
||||
@ -243,6 +243,7 @@ type
|
||||
function CreateSeperator : TMenuItem;
|
||||
procedure SetDefaultsForForm(aForm : TCustomForm);
|
||||
|
||||
procedure InvalidateAllDesignerForms;
|
||||
protected
|
||||
procedure ToolButtonClick(Sender : TObject);
|
||||
procedure OnApplyWindowLayout(ALayout: TIDEWindowLayout);
|
||||
@ -1970,6 +1971,23 @@ Begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure TMainIDE.InvalidateAllDesignerForms
|
||||
Params: none
|
||||
Result: none
|
||||
|
||||
Calls 'Invalidate' in all designer forms.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TMainIDE.InvalidateAllDesignerForms;
|
||||
var i: integer;
|
||||
begin
|
||||
for i:=0 to Project1.UnitCount-1 do begin
|
||||
if (Project1.Units[i].Form<>nil)
|
||||
and (Project1.Units[i].Form is TControl) then
|
||||
TControl(Project1.Units[i].Form).Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
|
||||
@ -2332,6 +2350,9 @@ Begin
|
||||
|
||||
// save to disk
|
||||
EnvironmentOptions.Save(false);
|
||||
|
||||
// update designer
|
||||
InvalidateAllDesignerForms;
|
||||
end;
|
||||
finally
|
||||
EnvironmentOptionsDialog.Free;
|
||||
@ -6412,6 +6433,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.309 2002/06/11 15:40:27 lazarus
|
||||
MG: implemented GridSizeX, GridSizeY and DisplayGrid
|
||||
|
||||
Revision 1.308 2002/06/09 07:08:41 lazarus
|
||||
MG: fixed window jumping
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user