mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:39:40 +02:00
MG: new designer and controlselection code
git-svn-id: trunk@222 -
This commit is contained in:
parent
5718818c2a
commit
5c2ae1e0e1
@ -17,10 +17,10 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
}
|
}
|
||||||
{$H+}
|
|
||||||
unit AbstractFormEditor;
|
unit AbstractFormEditor;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}{$H-}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -70,7 +70,7 @@ or use TPropertyType
|
|||||||
|
|
||||||
TIFormInterface = class
|
TIFormInterface = class
|
||||||
public
|
public
|
||||||
Function Filename : String; virtual; abstract;
|
Function Filename : AnsiString; virtual; abstract;
|
||||||
Function FormModified : Boolean; virtual; abstract;
|
Function FormModified : Boolean; virtual; abstract;
|
||||||
Function MArkModified : Boolean; virtual; abstract;
|
Function MArkModified : Boolean; virtual; abstract;
|
||||||
Function GetFormComponent : TIComponentInterface; virtual; abstract;
|
Function GetFormComponent : TIComponentInterface; virtual; abstract;
|
||||||
@ -92,7 +92,7 @@ or use TPropertyType
|
|||||||
|
|
||||||
TAbstractFormEditor = class
|
TAbstractFormEditor = class
|
||||||
public
|
public
|
||||||
Function Filename : String; virtual; abstract;
|
Function Filename : AnsiString; virtual; abstract;
|
||||||
Function FormModified : Boolean; virtual; abstract;
|
Function FormModified : Boolean; virtual; abstract;
|
||||||
Function FindComponentByName(const Name : String) : TIComponentInterface; virtual; abstract;
|
Function FindComponentByName(const Name : String) : TIComponentInterface; virtual; abstract;
|
||||||
Function FindComponent(AComponent: TComponent): TIComponentInterface; virtual; abstract;
|
Function FindComponent(AComponent: TComponent): TIComponentInterface; virtual; abstract;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -20,12 +20,13 @@
|
|||||||
}
|
}
|
||||||
unit designer;
|
unit designer;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
classes, Forms, controls, lmessages, graphics, ControlSelection, CustomFormEditor,FormEditor, UnitEditor,Main;
|
Classes, Forms, Controls, LMessages, Graphics, ControlSelection,
|
||||||
|
CustomFormEditor, FormEditor, UnitEditor, CompReg;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGridPoint = record
|
TGridPoint = record
|
||||||
@ -33,21 +34,37 @@ type
|
|||||||
y: integer;
|
y: integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TOnGetSelectedComponentClass = procedure(Sender: TObject;
|
||||||
|
var RegisteredComponent: TRegisteredComponent) of object;
|
||||||
|
TOnSetDesigning = procedure(Sender: TObject; Component: TComponent;
|
||||||
|
Value: boolean) of object;
|
||||||
|
TOnAddComponent = procedure(Sender: TObject; Component: TComponent;
|
||||||
|
ComponentClass: TRegisteredComponent) of object;
|
||||||
|
|
||||||
TDesigner = class(TIDesigner)
|
TDesigner = class(TIDesigner)
|
||||||
private
|
private
|
||||||
FCustomForm: TCustomForm;
|
FCustomForm: TCustomForm;
|
||||||
FFormEditor : TFormEditor;
|
FFormEditor : TFormEditor;
|
||||||
FSourceEditor : TSourceEditor;
|
FSourceEditor : TSourceEditor;
|
||||||
FMainIDE : TMainIDE;
|
FActiveRubberband:boolean;
|
||||||
|
FOnGetSelectedComponentClass: TOnGetSelectedComponentClass;
|
||||||
|
FOnUnselectComponentClass: TNotifyEvent;
|
||||||
|
FOnSetDesigning: TOnSetDesigning;
|
||||||
|
FOnComponentListChanged: TNotifyEvent;
|
||||||
|
FOnPropertiesChanged: TNotifyEvent;
|
||||||
|
FOnAddComponent: TOnAddComponent;
|
||||||
|
|
||||||
function GetIsControl: Boolean;
|
function GetIsControl: Boolean;
|
||||||
procedure SetIsControl(Value: Boolean);
|
procedure SetIsControl(Value: Boolean);
|
||||||
protected
|
protected
|
||||||
MouseDownControl : TObject;
|
MouseDownControl : TObject;
|
||||||
MouseDownPos, MouseUpPos, LastMouseMovePos : TPoint;
|
MouseDownPos, MouseUpPos, LastMouseMovePos : TPoint;
|
||||||
|
|
||||||
Procedure MouseDownOnControl(Sender : TControl; Message : TLMessage);
|
function Paint(Sender: TControl; Message: TLMPaint):boolean;
|
||||||
procedure MouseMoveOnControl(Sender : TControl; var Message : TLMessage);
|
|
||||||
Procedure MouseUpOnControl(Sender : TControl; Message:TLMessage);
|
Procedure MouseDownOnControl(Sender : TControl; Message : TLMMouse);
|
||||||
|
Procedure MouseMoveOnControl(Sender : TControl; var Message : TLMMouse);
|
||||||
|
Procedure MouseUpOnControl(Sender : TControl; Message:TLMMouse);
|
||||||
|
|
||||||
Procedure KeyDown(Sender : TControl; Message:TLMKEY);
|
Procedure KeyDown(Sender : TControl; Message:TLMKEY);
|
||||||
Procedure KeyUP(Sender : TControl; Message:TLMKEY);
|
Procedure KeyUP(Sender : TControl; Message:TLMKEY);
|
||||||
@ -58,9 +75,8 @@ type
|
|||||||
|
|
||||||
public
|
public
|
||||||
ControlSelection : TControlSelection;
|
ControlSelection : TControlSelection;
|
||||||
constructor Create(customform : TCustomform);
|
constructor Create(Customform : TCustomform);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
Procedure AddControlCode(Control : TComponent);
|
|
||||||
|
|
||||||
procedure CreateNew(FileName : string);
|
procedure CreateNew(FileName : string);
|
||||||
procedure LoadFile(FileName: string);
|
procedure LoadFile(FileName: string);
|
||||||
@ -69,21 +85,32 @@ type
|
|||||||
procedure Modified; override;
|
procedure Modified; override;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
procedure PaintGrid; override;
|
procedure PaintGrid; override;
|
||||||
procedure ValidateRename(AComponent: TComponent; const CurName, NewName: string); override;
|
procedure ValidateRename(AComponent: TComponent;
|
||||||
|
const CurName, NewName: shortstring); override;
|
||||||
Procedure SelectOnlyThisComponent(AComponent:TComponent);
|
Procedure SelectOnlyThisComponent(AComponent:TComponent);
|
||||||
|
|
||||||
|
|
||||||
property IsControl: Boolean read GetIsControl write SetIsControl;
|
property IsControl: Boolean read GetIsControl write SetIsControl;
|
||||||
property Form: TCustomForm read FCustomForm write FCustomForm;
|
property Form: TCustomForm read FCustomForm write FCustomForm;
|
||||||
property FormEditor : TFormEditor read FFormEditor write FFormEditor;
|
property FormEditor : TFormEditor read FFormEditor write FFormEditor;
|
||||||
property SourceEditor : TSourceEditor read FSourceEditor write FSourceEditor;
|
property SourceEditor : TSourceEditor read FSourceEditor write FSourceEditor;
|
||||||
property MainIDE : TMainIDE read FMainIDE write FMainIDE;
|
property OnGetSelectedComponentClass: TOnGetSelectedComponentClass
|
||||||
|
read FOnGetSelectedComponentClass write FOnGetSelectedComponentClass;
|
||||||
|
property OnUnselectComponentClass: TNotifyEvent
|
||||||
|
read FOnUnselectComponentClass write FOnUnselectComponentClass;
|
||||||
|
property OnSetDesigning: TOnSetDesigning read FOnSetDesigning write FOnSetDesigning;
|
||||||
|
property OnComponentListChanged: TNotifyEvent
|
||||||
|
read FOnComponentListChanged write FOnComponentListChanged;
|
||||||
|
property OnPropertiesChanged: TNotifyEvent
|
||||||
|
read FOnPropertiesChanged write FOnPropertiesChanged;
|
||||||
|
property OnAddComponent: TOnAddComponent read FOnAddComponent write FOnAddComponent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Sysutils, Typinfo,Math;
|
Sysutils, Typinfo, Math, LCLLinux;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -100,12 +127,8 @@ constructor TDesigner.Create(CustomForm : TCustomForm);
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FCustomForm := CustomForm;
|
FCustomForm := CustomForm;
|
||||||
ControlSelection := TControlSelection.Create(CustomForm);
|
ControlSelection := TControlSelection.Create;
|
||||||
|
FActiveRubberband:=false;
|
||||||
//the source is created when the form is created.
|
|
||||||
//the TDesigner is created in Main.pp and then TDesigner.SourceEditor := SourceNotebook.CreateFormFromUnit(CustomForm);
|
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TDesigner.Destroy;
|
destructor TDesigner.Destroy;
|
||||||
@ -114,7 +137,6 @@ Begin
|
|||||||
Inherited;
|
Inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TDesigner.CreateNew(FileName : string);
|
procedure TDesigner.CreateNew(FileName : string);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
@ -123,30 +145,31 @@ end;
|
|||||||
|
|
||||||
Procedure TDesigner.RemoveControl(Control : TComponent);
|
Procedure TDesigner.RemoveControl(Control : TComponent);
|
||||||
Begin
|
Begin
|
||||||
Writeln('RemoveControl called');
|
Writeln('[TDesigner.RemoveControl] ',Control.Name,':',Control.ClassName);
|
||||||
FSourceEditor.RemoveControlCode(Control);
|
FSourceEditor.RemoveControlCode(Control);
|
||||||
Writeln('1');
|
Writeln('[TDesigner.RemoveControl] 1');
|
||||||
FCustomForm.RemoveControl(TCOntrol(Control)); //this send a message to notification and removes it from the controlselection
|
FCustomForm.RemoveControl(TCOntrol(Control));
|
||||||
Writeln('2');
|
//this send a message to notification and removes it from the controlselection
|
||||||
|
Writeln('[TDesigner.RemoveControl] 2');
|
||||||
FFormEditor.DeleteControl(Control);
|
FFormEditor.DeleteControl(Control);
|
||||||
Writeln('3');
|
Writeln('[TDesigner.RemoveControl] end');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TDesigner.NudgeControl(Value1,Value2 : Integer);
|
Procedure TDesigner.NudgeControl(Value1,Value2 : Integer);
|
||||||
Begin
|
Begin
|
||||||
Writeln('NudgeControl');
|
Writeln('[TDesigner.NudgeControl]');
|
||||||
ControlSelection.MoveSelection(Value1,Value2);
|
ControlSelection.MoveSelection(Value1,Value2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TDesigner.NudgeSize(Value1,Value2 : Integer);
|
Procedure TDesigner.NudgeSize(Value1,Value2 : Integer);
|
||||||
Begin
|
Begin
|
||||||
Writeln('NudgeSize');
|
Writeln('[TDesigner.NudgeSize]');
|
||||||
ControlSelection.SizeSelection(Value1,Value2);
|
ControlSelection.SizeSelection(Value1,Value2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
|
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
|
||||||
begin
|
begin
|
||||||
Writeln('Control Added '+TCOntrol(aComponent).name);
|
Writeln('Control Added ',TControl(aComponent).name);
|
||||||
ControlSelection.Clear;
|
ControlSelection.Clear;
|
||||||
ControlSelection.Add(TControl(AComponent));
|
ControlSelection.Add(TControl(AComponent));
|
||||||
|
|
||||||
@ -155,120 +178,180 @@ Writeln('Control Added '+TCOntrol(aComponent).name);
|
|||||||
FFormEditor.AddSelected(AComponent);
|
FFormEditor.AddSelected(AComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDesigner.Paint(Sender: TControl; Message: TLMPaint):boolean;
|
||||||
|
begin
|
||||||
|
Result:=true;
|
||||||
|
Sender.Dispatch(Message);
|
||||||
|
if (ControlSelection.IsSelected(Sender)) then begin
|
||||||
|
writeln('*** LM_PAINT ',Sender.Name,':',Sender.ClassName,' DC=',Message.DC);
|
||||||
|
ControlSelection.DrawMarker(Sender,Message.DC);
|
||||||
|
ControlSelection.DrawGrabbers;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDesigner.MouseDownOnControl(Sender : TControl; Message : TLMessage);
|
procedure TDesigner.MouseDownOnControl(Sender : TControl; Message : TLMMouse);
|
||||||
|
var i,
|
||||||
|
MouseX,MouseY,
|
||||||
|
CompIndex:integer;
|
||||||
|
FormOrigin,SenderOrigin:TPoint;
|
||||||
|
AControlSelection:TControlSelection;
|
||||||
|
SelectedCompClass: TRegisteredComponent;
|
||||||
Begin
|
Begin
|
||||||
// if assigned(MouseDownControl) and (MOuseDownControl <> Sender) then Exit;
|
if (MouseDownControl<>nil) or (getParentForm(Sender)=nil) then exit;
|
||||||
Writeln('Left is '+Inttostr(TCOntrol(Sender).left));
|
|
||||||
Writeln('Top is '+Inttostr(TCOntrol(Sender).Top));
|
|
||||||
Writeln('***************************');
|
|
||||||
Writeln('TDesigner.MouseDownOnControl');
|
|
||||||
Writeln(Format('X,Y = %d,%d',[TLMMOuse(Message).pos.x,TLMMOuse(Message).pos.Y]));
|
|
||||||
Writeln(Format('Control left and top are %d,%d',[TCOntrol(sender).Left,TCOntrol(sender).Top]));
|
|
||||||
Writeln('***************************');
|
|
||||||
|
|
||||||
|
|
||||||
if GetCaptureGrabber<>nil then exit;
|
|
||||||
|
|
||||||
if not assigned(MouseDownControl) then
|
|
||||||
Begin
|
|
||||||
MouseDownPos.X := TLMMOuse(Message).pos.X;
|
|
||||||
MouseDownPos.Y := TLMMOuse(Message).pos.Y;
|
|
||||||
//adjust X and Y by adding the Control corners.
|
|
||||||
MouseDownControl:=Sender;
|
MouseDownControl:=Sender;
|
||||||
if not (Sender is TCustomForm) then
|
|
||||||
begin
|
|
||||||
inc(MouseDownPos.X,TControl(Sender).Left);
|
|
||||||
inc(MouseDownPos.Y,TControl(Sender).Top);
|
|
||||||
end;
|
|
||||||
LastMouseMovePos:=MouseDownPos;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
FormOrigin:=GetParentForm(Sender).ClientOrigin;
|
||||||
|
SenderOrigin:=Sender.ClientOrigin;
|
||||||
|
MouseX:=Message.Pos.X+SenderOrigin.X-FormOrigin.X;
|
||||||
|
MouseY:=Message.Pos.Y+SenderOrigin.Y-FormOrigin.Y;
|
||||||
|
|
||||||
|
MouseDownPos := Point(MouseX,MouseY);
|
||||||
|
LastMouseMovePos:=MouseDownPos;
|
||||||
|
|
||||||
|
writeln('************************************************************');
|
||||||
|
write('MouseDownOnControl');
|
||||||
|
write(' ',Sender.Name,':',Sender.ClassName,' Sender=',SenderOrigin.X,',',SenderOrigin.Y);
|
||||||
|
write(' Msg=',Message.Pos.X,',',Message.Pos.Y);
|
||||||
|
write(' Mouse=',MouseX,',',MouseY);
|
||||||
|
writeln('');
|
||||||
|
|
||||||
|
ControlSelection.ActiveGrabber:=
|
||||||
|
ControlSelection.GrabberAtPos(MouseDownPos.X,MouseDownPos.Y);
|
||||||
|
|
||||||
|
if (Message.Keys and MK_Shift) = MK_Shift then
|
||||||
Writeln('Shift down')
|
Writeln('Shift down')
|
||||||
else
|
else
|
||||||
Writeln('No Shift down');
|
Writeln('No Shift down');
|
||||||
|
|
||||||
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
|
if (Message.Keys and MK_Control) = MK_Control then
|
||||||
Writeln('CTRL down')
|
Writeln('CTRL down')
|
||||||
else
|
else
|
||||||
Writeln('No CTRL down');
|
Writeln('No CTRL down');
|
||||||
|
|
||||||
|
if Assigned(FOnGetSelectedComponentClass) then
|
||||||
|
FOnGetSelectedComponentClass(Self,SelectedCompClass)
|
||||||
|
|
||||||
Writeln('Sender is '+sender.name);
|
|
||||||
if FMainIDE.SelectedComponent = nil then
|
|
||||||
Begin //mouse pointer button pressed.
|
|
||||||
if not (Sender is TCustomForm) then begin
|
|
||||||
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
|
||||||
ControlSelection.Add(sender)
|
|
||||||
else
|
else
|
||||||
SelectOnlyThisComponent(TComponent(Sender));
|
SelectedCompClass:=nil;
|
||||||
|
|
||||||
|
if SelectedCompClass = nil then begin
|
||||||
|
// selection mode
|
||||||
|
if ControlSelection.ActiveGrabber=nil then begin
|
||||||
|
CompIndex:=ControlSelection.IndexOf(Sender);
|
||||||
|
if (Message.Keys and MK_SHIFT)>0 then begin
|
||||||
|
// shift key
|
||||||
|
if CompIndex<0 then begin
|
||||||
|
// not selected
|
||||||
|
// add component to selection
|
||||||
|
if (ControlSelection.Count=0)
|
||||||
|
or (not (Sender is TCustomForm)) then begin
|
||||||
|
ControlSelection.Add(Sender);
|
||||||
|
Sender.Invalidate;
|
||||||
|
if Sender.Parent<>nil then
|
||||||
|
Sender.Parent.Invalidate;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// remove from multiselection
|
||||||
|
ControlSelection.Delete(CompIndex);
|
||||||
|
Sender.Invalidate;
|
||||||
|
if Sender.Parent<>nil then
|
||||||
|
Sender.Parent.Invalidate;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
if (CompIndex<0) then begin
|
||||||
|
// select only this component
|
||||||
|
AControlSelection:=TControlSelection.Create;
|
||||||
|
AControlSelection.Assign(ControlSelection);
|
||||||
|
ControlSelection.Clear;
|
||||||
|
for i:=0 to AControlSelection.Count-1 do
|
||||||
|
AControlSelection[i].Control.Invalidate;
|
||||||
|
ControlSelection.Add(Sender);
|
||||||
|
Sender.Invalidate;
|
||||||
|
if Sender.Parent<>nil then
|
||||||
|
Sender.Parent.Invalidate;
|
||||||
|
AControlSelection.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
ControlSelection.SaveBounds;
|
||||||
|
end else begin
|
||||||
|
// add component mode -> handled in mousemove and mouseup
|
||||||
|
end;
|
||||||
|
|
||||||
|
writeln('[TDesigner.MouseDownOnControl] END');
|
||||||
End;
|
End;
|
||||||
|
|
||||||
procedure TDesigner.MouseUpOnControl(Sender : TControl; Message:TLMessage);
|
procedure TDesigner.MouseUpOnControl(Sender : TControl; Message:TLMMouse);
|
||||||
var
|
var
|
||||||
ParentCI, NewCI : TComponentInterface;
|
ParentCI, NewCI : TComponentInterface;
|
||||||
NewLeft, NewTop, NewWidth, NewHeight : Integer;
|
NewLeft, NewTop, NewWidth, NewHeight,
|
||||||
// CInterface : TComponentInterface;
|
MouseX, MouseY, I : Integer;
|
||||||
CaptureGrabber:TGrabber;
|
|
||||||
Button : TMouseButton;
|
|
||||||
Shift : TShiftState;
|
Shift : TShiftState;
|
||||||
|
SenderParentForm:TCustomForm;
|
||||||
|
RubberBandWasActive:boolean;
|
||||||
|
FormOrigin,SenderOrigin:TPoint;
|
||||||
|
SelectedCompClass: TRegisteredComponent;
|
||||||
|
AControlSelection: TControlSelection;
|
||||||
Begin
|
Begin
|
||||||
|
SenderParentForm:=GetParentForm(Sender);
|
||||||
|
if (MouseDownControl=nil) or (SenderParentForm=nil) then exit;
|
||||||
|
|
||||||
|
ControlSelection.ActiveGrabber:=nil;
|
||||||
Writeln('***************************');
|
RubberBandWasActive:=FActiveRubberBand;
|
||||||
Writeln('In TDesigner.UpOnControl');
|
if FActiveRubberband then begin
|
||||||
Writeln(Format('X,Y = %d,%d',[TLMMOuse(Message).pos.x,TLMMOuse(Message).pos.Y]));
|
FActiveRubberband:=false;
|
||||||
Writeln('***************************');
|
ControlSelection.DrawRubberBand(false,ControlSelection.RubberBandBounds);
|
||||||
if (TLMMouse(Message).keys and MK_LButton) = MK_LButton then
|
end;
|
||||||
Button := mbLEft
|
|
||||||
else
|
|
||||||
if (TLMMouse(Message).keys and MK_LButton) = MK_RButton then
|
|
||||||
Button := mbRight;
|
|
||||||
|
|
||||||
Shift := [];
|
Shift := [];
|
||||||
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
||||||
shift := [ssShift];
|
Shift := [ssShift];
|
||||||
|
|
||||||
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
|
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
|
||||||
shift := shift +[ssCTRL];
|
Shift := Shift +[ssCTRL];
|
||||||
|
|
||||||
|
|
||||||
CaptureGrabber:=GetCaptureGrabber;
|
FormOrigin:=SenderParentForm.ClientOrigin;
|
||||||
if CaptureGrabber<>nil then begin
|
SenderOrigin:=Sender.ClientOrigin;
|
||||||
CaptureGrabber.CaptureMouseUp(TControl(Sender),Button,Shift,TLMMouse(Message).pos.X,TLMMouse(Message).pos.Y);
|
MouseX:=Message.Pos.X+SenderOrigin.X-FormOrigin.X;
|
||||||
exit;
|
MouseY:=Message.Pos.Y+SenderOrigin.Y-FormOrigin.Y;
|
||||||
end;
|
MouseUpPos := Point(MouseX,MouseY);
|
||||||
|
dec(MouseX,MouseDownPos.X);
|
||||||
|
dec(MouseY,MouseDownPos.Y);
|
||||||
|
|
||||||
MouseUpPos.X := TLMMouse(Message).pos.X;
|
if Assigned(FOnGetSelectedComponentClass) then
|
||||||
MouseUpPos.Y := TLMMouse(Message).pos.Y;
|
FOnGetSelectedComponentClass(Self,SelectedCompClass)
|
||||||
if not (Sender is TCustomForm) then begin
|
|
||||||
inc(MouseUpPos.X,TControl(Sender).Left);
|
|
||||||
inc(MouseUpPos.Y,TControl(Sender).Top);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if FMainIDE.SelectedComponent = nil then
|
|
||||||
Begin //mouse pointer button pressed.
|
|
||||||
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
Begin //add a new control
|
SelectedCompClass:=nil;
|
||||||
|
|
||||||
FMainIDE.SetDesigning(FCustomForm,False);
|
if SelectedCompClass = nil then begin
|
||||||
ParentCI:=TComponentInterface(FFormEditor.FindComponent(TComponent(Sender)));
|
// selection mode
|
||||||
if (TComponent(Sender) is TWinControl)
|
if (ControlSelection.Count=1)
|
||||||
and (not (csAcceptsControls in TWinControl(Sender).ControlStyle)) then
|
and (ControlSelection[0].Control is TCustomForm) then begin
|
||||||
begin
|
// rubberband selection
|
||||||
|
if RubberBandWasActive then begin
|
||||||
|
AControlSelection:=TControlSelection.Create;
|
||||||
|
AControlSelection.Assign(ControlSelection);
|
||||||
|
ControlSelection.Clear;
|
||||||
|
for i:=0 to AControlSelection.Count-1 do
|
||||||
|
AControlSelection[i].Control.Invalidate;
|
||||||
|
AControlSelection.Free;
|
||||||
|
ControlSelection.SelectWithRubberBand(SenderParentForm);
|
||||||
|
for i:=0 to ControlSelection.Count-1 do
|
||||||
|
ControlSelection[i].Control.Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// add a new control
|
||||||
|
|
||||||
|
if Assigned(FOnSetDesigning) then FOnSetDesigning(Self,FCustomForm,False);
|
||||||
|
ParentCI:=TComponentInterface(FFormEditor.FindComponent(Sender));
|
||||||
|
if (Sender is TWinControl)
|
||||||
|
and (not (csAcceptsControls in TWinControl(Sender).ControlStyle)) then begin
|
||||||
ParentCI:=TComponentInterface(
|
ParentCI:=TComponentInterface(
|
||||||
FFormEditor.FindComponent(TWinControl(Sender).Parent));
|
FFormEditor.FindComponent(TWinControl(Sender).Parent));
|
||||||
end;
|
end;
|
||||||
if Assigned(ParentCI) then begin
|
if Assigned(ParentCI) then begin
|
||||||
NewLeft:=Min(MouseDownPos.X,MouseUpPos.X);
|
NewLeft:=Min(MouseDownPos.X,MouseUpPos.X)-(SenderOrigin.X-FormOrigin.X);
|
||||||
NewWidth:=Abs(MouseUpPos.X-MouseDownPos.X);
|
NewWidth:=Abs(MouseUpPos.X-MouseDownPos.X)-(SenderOrigin.Y-FormOrigin.Y);
|
||||||
NewTop:=Min(MouseDownPos.Y,MouseUpPos.Y);
|
NewTop:=Min(MouseDownPos.Y,MouseUpPos.Y);
|
||||||
NewHeight:=Abs(MouseUpPos.Y-MouseDownPos.Y);
|
NewHeight:=Abs(MouseUpPos.Y-MouseDownPos.Y);
|
||||||
if Abs(NewWidth+NewHeight)<7 then begin
|
if Abs(NewWidth+NewHeight)<7 then begin
|
||||||
@ -276,29 +359,33 @@ Begin
|
|||||||
NewWidth:=0;
|
NewWidth:=0;
|
||||||
NewHeight:=0;
|
NewHeight:=0;
|
||||||
end;
|
end;
|
||||||
NewCI := TComponentInterface(FFormEditor.CreateComponent(ParentCI,FMainIDE.SelectedComponent.ComponentClass
|
NewCI := TComponentInterface(FFormEditor.CreateComponent(
|
||||||
|
ParentCI,SelectedCompClass.ComponentClass
|
||||||
,NewLeft,NewTop,NewWidth,NewHeight));
|
,NewLeft,NewTop,NewWidth,NewHeight));
|
||||||
NewCI.SetPropByName('Visible',True);
|
NewCI.SetPropByName('Visible',True);
|
||||||
NewCI.SetPropByName('Designing',True);
|
NewCI.SetPropByName('Designing',True);
|
||||||
FMainIDE.SetDesigning(NewCI.Control,True);
|
if Assigned(FOnSetDesigning) then
|
||||||
|
FOnSetDesigning(Self,NewCI.Control,True);
|
||||||
ObjectInspector1.FillComponentComboBox;
|
if Assigned(FOnComponentListChanged) then
|
||||||
AddControlCode(NewCI.Control);
|
FOnComponentListChanged(Self);
|
||||||
|
if Assigned(FOnAddComponent) then
|
||||||
|
FOnAddComponent(Self,NewCI.Control,SelectedCompClass);
|
||||||
|
|
||||||
SelectOnlyThisComponent(TComponent(NewCI.Control));
|
SelectOnlyThisComponent(TComponent(NewCI.Control));
|
||||||
Writeln('Calling ControlClick with nil from MouseUpOnControl');
|
Writeln('Calling ControlClick with nil from MouseUpOnControl');
|
||||||
FMainIDE.ControlClick(FMainIDE.Notebook1); //this resets it to the mouse.
|
if not (ssCtrl in Shift) then
|
||||||
FMainIDE.SetDesigning(FCustomForm,True);
|
if Assigned(FOnUnselectComponentClass) then
|
||||||
|
// this resets it to the mouse. (= selection tool)
|
||||||
|
FOnUnselectComponentClass(Self);
|
||||||
|
if Assigned(FOnSetDesigning) then FOnSetDesigning(Self,FCustomForm,True);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
MouseDownControl:=nil;
|
MouseDownControl:=nil;
|
||||||
|
writeln('[TDesigner.MouseUpOnControl] END');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TDesigner.MouseMoveOnControl(Sender : TControl; var Message : TLMMouse);
|
||||||
|
|
||||||
Procedure TDesigner.MouseMoveOnControl(Sender : TControl; var Message : TLMessage);
|
|
||||||
const
|
const
|
||||||
mk_lbutton = 1;
|
mk_lbutton = 1;
|
||||||
mk_rbutton = 2;
|
mk_rbutton = 2;
|
||||||
@ -306,55 +393,53 @@ const
|
|||||||
mk_control = 8;
|
mk_control = 8;
|
||||||
mk_mbutton = $10;
|
mk_mbutton = $10;
|
||||||
var
|
var
|
||||||
CaptureGrabber : TGrabber;
|
|
||||||
Shift : TShiftState;
|
Shift : TShiftState;
|
||||||
X,Y : Integer;
|
FormOrigin, SenderOrigin:TPoint;
|
||||||
|
SenderParentForm:TCustomForm;
|
||||||
|
MouseX, MouseY :integer;
|
||||||
Begin
|
Begin
|
||||||
|
if MouseDownControl=nil then exit;
|
||||||
|
|
||||||
// if assigned(MouseDownControl) and (MOuseDownControl <> Sender) then Exit;
|
SenderParentForm:=GetParentForm(Sender);
|
||||||
Writeln('MouseMoveOnControl');
|
if SenderParentForm=nil then exit;
|
||||||
X :=TLMMouse(Message).Pos.x;
|
FormOrigin:=SenderParentForm.ClientOrigin;
|
||||||
Y := TLMMouse(Message).Pos.Y;
|
SenderOrigin:=Sender.ClientOrigin;
|
||||||
Writeln('MousePos');
|
MouseX:=Message.Pos.X+SenderOrigin.X-FormOrigin.X;
|
||||||
Writeln(Format('X,y = %d,%d',[Mouse.CursorPos.X,MOuse.CursorPos.Y]));
|
MouseY:=Message.Pos.Y+SenderOrigin.Y-FormOrigin.Y;
|
||||||
Writeln('X and Y are '+inttostr(x)+','+inttostr(y));
|
|
||||||
If (sender is TControl) then Begin
|
if (Message.keys and MK_LButton) = MK_LButton then begin
|
||||||
Writeln('Sender is '+TControl(sender).Name);
|
Write('TDesigner.MouseMoveOnControl');
|
||||||
Writeln('Left is '+Inttostr(TControl(sender).Left));
|
Write(' Cur=',MouseX,',',MouseY);
|
||||||
Writeln('Width is '+Inttostr(TControl(sender).Width));
|
Write(' Msg=',Message.Pos.x,',',Message.Pos.Y);
|
||||||
Writeln('Top is '+Inttostr(TControl(sender).Top));
|
Write(' ',Sender.Name,':',Sender.ClassName,'=',Sender.Left,',',Sender.Top);
|
||||||
Writeln('Height is '+Inttostr(TControl(sender).Height));
|
writeln();
|
||||||
end;
|
end;
|
||||||
if Assigned(MouseDownControl) then Writeln('MouseDownControl is '+TCOntrol(MouseDownControl).Name);
|
|
||||||
|
|
||||||
Shift := [];
|
Shift := [];
|
||||||
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
|
||||||
shift := [ssShift];
|
Shift := [ssShift];
|
||||||
|
|
||||||
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
|
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
|
||||||
shift := Shift + [ssCTRL];
|
Shift := Shift + [ssCTRL];
|
||||||
|
|
||||||
CaptureGrabber:=GetCaptureGrabber;
|
if ControlSelection.ActiveGrabber<>nil then begin
|
||||||
if CaptureGrabber<>nil then begin
|
if (Message.keys and MK_LButton) = MK_LButton then begin
|
||||||
CaptureGrabber.CaptureMouseMove(TControl(Sender),Shift,X,Y);
|
ControlSelection.SizeSelection(MouseX-MouseDownPos.X, MouseY-LastMouseMovePos.Y);
|
||||||
|
if Assigned(FOnPropertiesChanged) then
|
||||||
|
FOnPropertiesChanged(Self);
|
||||||
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if Assigned(MouseDownControl) then begin
|
if (Message.keys and MK_LButton) = MK_LButton then begin
|
||||||
if FMainIDE.SelectedComponent = nil then begin
|
if (ControlSelection.Count>=1)
|
||||||
// mouse pointer button pressed
|
and not (ControlSelection[0].Control is TCustomForm) then begin
|
||||||
{ if not (Sender is TCustomForm) then} begin
|
|
||||||
// move selection
|
// move selection
|
||||||
Writeln('moving stuff');
|
ControlSelection.MoveSelection(
|
||||||
{ if not(X in ([0 ..(TControl(sender).Width)])) or
|
MouseX-MouseDownPos.X, MouseY-MouseDownPos.Y);
|
||||||
not(Y in ([0 ..(TControl(sender).Height)])) then
|
if Assigned(FOnPropertiesChanged) then
|
||||||
exit; }
|
FOnPropertiesChanged(Self);
|
||||||
ControlSelection.MoveSelection(X-LastMouseMovePos.X, Y-LastMouseMovePos.Y);
|
|
||||||
// ControlSelection.MoveContent(X-LastMouseMovePos.X, Y-LastMouseMovePos.Y);
|
|
||||||
|
|
||||||
LastMouseMovePos:=Point(X,Y);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
LastMouseMovePos:=Point(MouseX,MouseY);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -362,85 +447,62 @@ end;
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
Handles the keydown messages. DEL deletes the selected controls, CTRL-UPARROR/DOWNARROW
|
Handles the keydown messages. DEL deletes the selected controls, CTRL-UPARROR/DOWNARROW
|
||||||
moves the selction up one, etc.
|
moves the selection up one, etc.
|
||||||
}
|
}
|
||||||
Procedure TDesigner.KeyDown(Sender : TControl; Message:TLMKEY);
|
Procedure TDesigner.KeyDown(Sender : TControl; Message:TLMKEY);
|
||||||
var
|
var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
Continue : Boolean;
|
|
||||||
Shift : TShiftState;
|
Shift : TShiftState;
|
||||||
Begin
|
Begin
|
||||||
Writeln('KEYDOWN');
|
Writeln('KEYDOWN');
|
||||||
with MEssage do
|
with MEssage do
|
||||||
Begin
|
Begin
|
||||||
Writeln('CHARCODE = '+inttostr(charcode));
|
Writeln('CHARCODE = '+inttostr(charcode));
|
||||||
Writeln('KEYDATA = '+inttostr(KeyData));
|
Writeln('KEYDATA = '+inttostr(KeyData));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Shift := KeyDataToShiftState(Message.KeyData);
|
Shift := KeyDataToShiftState(Message.KeyData);
|
||||||
|
|
||||||
if Message.CharCode = 46 then //DEL KEY
|
if Message.CharCode = 46 then //DEL KEY
|
||||||
begin
|
begin
|
||||||
Continue := True;
|
for I := ControlSelection.Count-1 downto 0 do Begin
|
||||||
While Continue do
|
|
||||||
Begin
|
|
||||||
Continue := False;
|
|
||||||
for I := 0 to FCustomForm.ComponentCount-1 do
|
|
||||||
Begin
|
|
||||||
Writeln('I = '+inttostr(i));
|
Writeln('I = '+inttostr(i));
|
||||||
if (FCustomForm.Components[i] is TControl) and
|
RemoveControl(ControlSelection.Items[I].Control);
|
||||||
ControlSelection.IsSelected(TControl(FCustomForm.Components[i])) then
|
|
||||||
Begin
|
|
||||||
Continue := True;
|
|
||||||
RemoveControl(TControl(FCustomForm.Components[i]));
|
|
||||||
Break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
End;
|
End;
|
||||||
SelectOnlythisComponent(FCustomForm);
|
SelectOnlythisComponent(FCustomForm);
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Message.CharCode = 38 then //UP ARROW
|
if Message.CharCode = 38 then //UP ARROW
|
||||||
Begin
|
Begin
|
||||||
if (ssCtrl in Shift) then
|
if (ssCtrl in Shift) then
|
||||||
NudgeControl(0,-1)
|
NudgeControl(0,-1)
|
||||||
else
|
else if (ssShift in Shift) then
|
||||||
if (ssShift in Shift) then
|
|
||||||
NudgeSize(0,-1);
|
NudgeSize(0,-1);
|
||||||
end
|
end
|
||||||
else
|
else if Message.CharCode = 40 then //DOWN ARROW
|
||||||
if Message.CharCode = 40 then //DOWN ARROW
|
|
||||||
Begin
|
Begin
|
||||||
if (ssCtrl in Shift) then
|
if (ssCtrl in Shift) then
|
||||||
NudgeControl(0,1)
|
NudgeControl(0,1)
|
||||||
else
|
else if (ssShift in Shift) then
|
||||||
if (ssShift in Shift) then
|
|
||||||
NudgeSize(0,1);
|
NudgeSize(0,1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Message.CharCode = 39 then //RIGHT ARROW
|
if Message.CharCode = 39 then //RIGHT ARROW
|
||||||
Begin
|
Begin
|
||||||
if (ssCtrl in Shift) then
|
if (ssCtrl in Shift) then
|
||||||
NudgeControl(1,0)
|
NudgeControl(1,0)
|
||||||
else
|
else if (ssShift in Shift) then
|
||||||
if (ssShift in Shift) then
|
|
||||||
NudgeSize(1,0);
|
NudgeSize(1,0);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Message.CharCode = 37 then //LEFT ARROW
|
if Message.CharCode = 37 then //LEFT ARROW
|
||||||
Begin
|
Begin
|
||||||
if (ssCtrl in Shift) then
|
if (ssCtrl in Shift) then
|
||||||
NudgeControl(-1,0)
|
NudgeControl(-1,0)
|
||||||
else
|
else if (ssShift in Shift) then
|
||||||
if (ssShift in Shift) then
|
|
||||||
NudgeSize(-1,0);
|
NudgeSize(-1,0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -448,7 +510,7 @@ end;
|
|||||||
Procedure TDesigner.KeyUp(Sender : TControl; Message:TLMKEY);
|
Procedure TDesigner.KeyUp(Sender : TControl; Message:TLMKEY);
|
||||||
Begin
|
Begin
|
||||||
Writeln('KEYUp');
|
Writeln('KEYUp');
|
||||||
with MEssage do
|
with MEssage do
|
||||||
Begin
|
Begin
|
||||||
Writeln('CHARCODE = '+inttostr(charcode));
|
Writeln('CHARCODE = '+inttostr(charcode));
|
||||||
Writeln('KEYDATA = '+inttostr(KeyData));
|
Writeln('KEYDATA = '+inttostr(KeyData));
|
||||||
@ -458,39 +520,24 @@ end;
|
|||||||
|
|
||||||
function TDesigner.IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean;
|
function TDesigner.IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean;
|
||||||
Begin
|
Begin
|
||||||
result := false;
|
result := false;
|
||||||
if ((Message.msg >= LM_MOUSEFIRST) and (Message.msg <= LM_MOUSELAST)) then
|
if csDesigning in Sender.ComponentState then begin
|
||||||
Result := true
|
|
||||||
else
|
if ((Message.msg >= LM_MOUSEFIRST) and (Message.msg <= LM_MOUSELAST)) then
|
||||||
if ((Message.msg >= LM_KeyFIRST) and (Message.msg <= LM_KeyLAST)) then
|
Result := true
|
||||||
Begin
|
|
||||||
Writeln('KEY MESSAGE in IsDesignMsg');
|
|
||||||
if MEssage.MSG = LM_KEYDOWN then KeyDown(Sender,TLMKey(Message))
|
|
||||||
else
|
else
|
||||||
if MEssage.MSG = LM_KEYUP then KeyUP(Sender,TLMKey(Message));
|
if ((Message.msg >= LM_KeyFIRST) and (Message.msg <= LM_KeyLAST)) then
|
||||||
Result := true;
|
Result:=true;
|
||||||
|
|
||||||
|
case Message.MSG of
|
||||||
|
LM_PAINT: Result:=Paint(Sender,TLMPAINT(Message));
|
||||||
|
LM_KEYDOWN: KeyDown(Sender,TLMKey(Message));
|
||||||
|
LM_KEYUP: KeyUP(Sender,TLMKey(Message));
|
||||||
|
LM_LBUTTONDOWN: MouseDownOnControl(sender,TLMMouse(Message));
|
||||||
|
LM_LBUTTONUP: MouseUpOnControl(sender,TLMMouse(Message));
|
||||||
|
LM_MOUSEMOVE: MouseMoveOnControl(Sender, TLMMouse(Message));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if (Message.msg=LM_LBUTTONDOWN) then
|
|
||||||
begin
|
|
||||||
MouseDownonControl(sender,message);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if (Message.msg=LM_LBUTTONUP) then
|
|
||||||
begin
|
|
||||||
MouseUPONControl(sender,message);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if Message.msg = LM_MOUSEMOVE then
|
|
||||||
MouseMoveonCOntrol(Sender, Message)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{if Result then Writeln('It IS a design message')
|
|
||||||
else
|
|
||||||
Writeln('It IS NOT a design message');
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesigner.LoadFile(FileName: string);
|
procedure TDesigner.LoadFile(FileName: string);
|
||||||
@ -503,13 +550,6 @@ Begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TDesigner.AddControlCode(Control : TComponent);
|
|
||||||
Begin
|
|
||||||
FSourceEditor.AddControlCode(Control);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
||||||
Begin
|
Begin
|
||||||
if Operation = opInsert then
|
if Operation = opInsert then
|
||||||
@ -530,17 +570,16 @@ procedure TDesigner.PaintGrid;
|
|||||||
var
|
var
|
||||||
x,y : integer;
|
x,y : integer;
|
||||||
begin
|
begin
|
||||||
with FCustomForm do
|
writeln('PaintGrid DC=',FCustomForm.Canvas.Handle,' ',Cardinal(Pointer(FCustomForm)));
|
||||||
Begin
|
with FCustomForm.Canvas do begin
|
||||||
canvas.Pen.Color := clGray;
|
Pen.Color := clGray;
|
||||||
x := left;
|
x := 0;
|
||||||
while x <= left + width do
|
while x <= FCustomForm.Width do begin
|
||||||
begin
|
y := 0;
|
||||||
y := Top;
|
while y <= FCustomForm.Height do begin
|
||||||
while y <= top+height do
|
//if Controlatpos(Point(x,y),True) = nil then
|
||||||
begin
|
MoveTo(x,y);
|
||||||
//if Controlatpos(TPOINT([x,y]),True) = nil then
|
LineTo(x+1,y);
|
||||||
Canvas.Rectangle(x-left,y-top,x-left+1,y-top);
|
|
||||||
Inc(y, GridPoints.Y);
|
Inc(y, GridPoints.Y);
|
||||||
end;
|
end;
|
||||||
Inc(x, GridPoints.X);
|
Inc(x, GridPoints.X);
|
||||||
@ -548,14 +587,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesigner.ValidateRename(AComponent: TComponent; const CurName, NewName: string);
|
procedure TDesigner.ValidateRename(AComponent: TComponent;
|
||||||
|
const CurName, NewName: shortstring);
|
||||||
Begin
|
Begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDesigner.GetIsControl: Boolean;
|
function TDesigner.GetIsControl: Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesigner.SetIsControl(Value: Boolean);
|
procedure TDesigner.SetIsControl(Value: Boolean);
|
||||||
|
@ -73,6 +73,15 @@ function FindResourceInCode(Source:string; AddCode:string;
|
|||||||
var Position,EndPosition:integer):boolean;
|
var Position,EndPosition:integer):boolean;
|
||||||
function AddResourceCode(var Source:string; AddCode:string):boolean;
|
function AddResourceCode(var Source:string; AddCode:string):boolean;
|
||||||
|
|
||||||
|
// form components
|
||||||
|
function FindFormClassDefinitionInSource(Source:string; FormClassName:string;
|
||||||
|
var FormClassNameStartPos, FormBodyStartPos: integer
|
||||||
|
):boolean;
|
||||||
|
function FindFormComponentInSource(Source: string; FormBodyStartPos: integer;
|
||||||
|
ComponentName, ComponentClassName: string): integer;
|
||||||
|
function AddFormComponentToSource(var Source:string; FormBodyStartPos: integer;
|
||||||
|
ComponentName, ComponentClassName: string): boolean;
|
||||||
|
|
||||||
// code search
|
// code search
|
||||||
function SearchCodeInSource(Source,Find:string; StartPos:integer;
|
function SearchCodeInSource(Source,Find:string; StartPos:integer;
|
||||||
var EndFoundPosition:integer; CaseSensitive:boolean):integer;
|
var EndFoundPosition:integer; CaseSensitive:boolean):integer;
|
||||||
@ -622,6 +631,89 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FindFormClassDefinitionInSource(Source:string; FormClassName:string;
|
||||||
|
var FormClassNameStartPos, FormBodyStartPos: integer
|
||||||
|
):boolean;
|
||||||
|
var AtomEnd,AtomStart: integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if FormClassName='' then exit;
|
||||||
|
repeat
|
||||||
|
FormClassNameStartPos:=SearchCodeInSource(Source,
|
||||||
|
FormClassName+'=class(TForm)',1,FormBodyStartPos,false);
|
||||||
|
if FormClassNameStartPos<1 then exit;
|
||||||
|
AtomEnd:=FormBodyStartPos;
|
||||||
|
until ReadNextPascalAtom(Source,AtomEnd,AtomStart)<>';';
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function FindFormComponentInSource(Source: string; FormBodyStartPos: integer;
|
||||||
|
ComponentName, ComponentClassName: string): integer;
|
||||||
|
var AtomStart, OldPos: integer;
|
||||||
|
Atom: string;
|
||||||
|
begin
|
||||||
|
ComponentName:=lowercase(ComponentName);
|
||||||
|
ComponentClassName:=lowercase(ComponentClassName);
|
||||||
|
Result:=FormBodyStartPos;
|
||||||
|
repeat
|
||||||
|
Atom:=lowercase(ReadNextPascalAtom(Source,Result,AtomStart));
|
||||||
|
if (Atom='public') or (Atom='published') or (Atom='private') or (Atom='end')
|
||||||
|
or (Atom='protected') or (Atom='') then begin
|
||||||
|
Result:=-1;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
OldPos:=Result;
|
||||||
|
if (lowercase(ReadNextPascalAtom(Source,Result,AtomStart))=ComponentName)
|
||||||
|
and (ReadNextPascalAtom(Source,Result,AtomStart)=':')
|
||||||
|
and (lowercase(ReadNextPascalAtom(Source,Result,AtomStart))=ComponentClassName)
|
||||||
|
and (ReadNextPascalAtom(Source,Result,AtomStart)=';') then begin
|
||||||
|
Result:=OldPos;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
until Result>length(Source);
|
||||||
|
Result:=-1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function AddFormComponentToSource(var Source:string; FormBodyStartPos: integer;
|
||||||
|
ComponentName, ComponentClassName: string): boolean;
|
||||||
|
var Position, AtomStart: integer;
|
||||||
|
Atom: string;
|
||||||
|
PriorSpaces, NextSpaces: string;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if FindFormComponentInSource(Source,FormBodyStartPos
|
||||||
|
,ComponentName,ComponentClassName)>0 then begin
|
||||||
|
Result:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
repeat
|
||||||
|
// find a good position to insert the component
|
||||||
|
// in front of next section and in front of procedures/functions
|
||||||
|
Position:=FormBodyStartPos;
|
||||||
|
Atom:=lowercase(ReadNextPascalAtom(Source,Position,AtomStart));
|
||||||
|
if (Atom='procedure') or (Atom='function') or (Atom='end') or (Atom='class')
|
||||||
|
or (Atom='constructor') or (Atom='destructor')
|
||||||
|
or (Atom='public') or (Atom='private') or (Atom='protected')
|
||||||
|
or (Atom='published') or (Atom='class') or (Atom='property') then begin
|
||||||
|
// insert component definition in source
|
||||||
|
if (Atom='public') or (Atom='private') or (Atom='protected')
|
||||||
|
or (Atom='published') then begin
|
||||||
|
PriorSpaces:=' ';
|
||||||
|
NextSpaces:=' ';
|
||||||
|
end else begin
|
||||||
|
PriorSpaces:='';
|
||||||
|
NextSpaces:=' ';
|
||||||
|
end;
|
||||||
|
Source:=copy(Source,1,AtomStart-1)
|
||||||
|
+PriorSpaces+ComponentName+': '+ComponentClassName+';'+EndOfLine
|
||||||
|
+NextSpaces+copy(Source,AtomStart,length(Source)-AtomStart+1);
|
||||||
|
Result:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
until Position>length(Source);
|
||||||
|
Result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
function SearchCodeInSource(Source,Find:string; StartPos:integer;
|
function SearchCodeInSource(Source,Find:string; StartPos:integer;
|
||||||
var EndFoundPosition:integer; CaseSensitive:boolean):integer;
|
var EndFoundPosition:integer; CaseSensitive:boolean):integer;
|
||||||
// search pascal atoms of Find in Source
|
// search pascal atoms of Find in Source
|
||||||
|
@ -31,7 +31,7 @@ type
|
|||||||
property Page:TRegisteredComponentPage read FPage;
|
property Page:TRegisteredComponentPage read FPage;
|
||||||
property ComponentClass:TComponentClass read FComponentClass;
|
property ComponentClass:TComponentClass read FComponentClass;
|
||||||
property IndexInPage:integer read FIndexInPage;
|
property IndexInPage:integer read FIndexInPage;
|
||||||
property UnitName:ShortString;
|
property UnitName:ShortString read FUnitName;
|
||||||
constructor Create(APage:TRegisteredComponentPage; TheIndexInPage:integer;
|
constructor Create(APage:TRegisteredComponentPage; TheIndexInPage:integer;
|
||||||
AUnitName:ShortString; AComponentClass:TComponentClass);
|
AUnitName:ShortString; AComponentClass:TComponentClass);
|
||||||
end;
|
end;
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
}
|
}
|
||||||
{$H+}
|
|
||||||
unit CustomFormEditor;
|
unit CustomFormEditor;
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -47,27 +46,27 @@ each control that's dropped onto the form
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
Function GetPPropInfobyIndex(Index : Integer) : PPropInfo;
|
Function GetPPropInfobyIndex(Index : Integer) : PPropInfo;
|
||||||
Function GetPPropInfobyName(Name : String) : PPropInfo;
|
Function GetPPropInfobyName(Name : ShortString) : PPropInfo;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
Function GetComponentType : String; override;
|
Function GetComponentType : ShortString; override;
|
||||||
Function GetComponentHandle : LongInt; override;
|
Function GetComponentHandle : LongInt; override;
|
||||||
Function GetParent : TIComponentInterface; override;
|
Function GetParent : TIComponentInterface; override;
|
||||||
Function IsTControl : Boolean; override;
|
Function IsTControl : Boolean; override;
|
||||||
Function GetPropCount : Integer; override;
|
Function GetPropCount : Integer; override;
|
||||||
Function GetPropType(Index : Integer) : TTypeKind; override;
|
Function GetPropType(Index : Integer) : TTypeKind; override;
|
||||||
Function GetPropTypeInfo(Index : Integer) : PTypeInfo;
|
Function GetPropTypeInfo(Index : Integer) : PTypeInfo;
|
||||||
Function GetPropName(Index : Integer) : String; override;
|
Function GetPropName(Index : Integer) : ShortString; override;
|
||||||
Function GetPropTypeName(Index : Integer) : String; override;
|
Function GetPropTypeName(Index : Integer) : ShortString; override;
|
||||||
Function GetPropTypebyName(Name : String) : TTypeKind; override;
|
Function GetPropTypebyName(Name : ShortString) : TTypeKind; override;
|
||||||
|
|
||||||
Function GetPropValue(Index : Integer; var Value) : Boolean; override;
|
Function GetPropValue(Index : Integer; var Value) : Boolean; override;
|
||||||
Function GetPropValuebyName(Name: String; var Value) : Boolean; override;
|
Function GetPropValuebyName(Name: ShortString; var Value) : Boolean; override;
|
||||||
Function SetProp(Index : Integer; const Value) : Boolean; override;
|
Function SetProp(Index : Integer; const Value) : Boolean; override;
|
||||||
Function SetPropbyName(Name : String; const Value) : Boolean; override;
|
Function SetPropbyName(Name : ShortString; const Value) : Boolean; override;
|
||||||
|
|
||||||
|
|
||||||
Function GetControlCount: Integer; override;
|
Function GetControlCount: Integer; override;
|
||||||
@ -105,7 +104,7 @@ TCustomFormEditor
|
|||||||
Procedure DeleteControl(Value : TComponent);
|
Procedure DeleteControl(Value : TComponent);
|
||||||
Function Filename : String; override;
|
Function Filename : String; override;
|
||||||
Function FormModified : Boolean; override;
|
Function FormModified : Boolean; override;
|
||||||
Function FindComponentByName(const Name : String) : TIComponentInterface; override;
|
Function FindComponentByName(const Name : ShortString) : TIComponentInterface; override;
|
||||||
Function FindComponent(AComponent: TComponent): TIComponentInterface; override;
|
Function FindComponent(AComponent: TComponent): TIComponentInterface; override;
|
||||||
Function GetFormComponent : TIComponentInterface; override;
|
Function GetFormComponent : TIComponentInterface; override;
|
||||||
// Function CreateComponent(CI : TIComponentInterface; TypeName : String;
|
// Function CreateComponent(CI : TIComponentInterface; TypeName : String;
|
||||||
@ -115,7 +114,8 @@ TCustomFormEditor
|
|||||||
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface; override;
|
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface; override;
|
||||||
Function NewFormFromLFM(_Filename : String): TCustomform;
|
Function NewFormFromLFM(_Filename : String): TCustomform;
|
||||||
Procedure ClearSelected;
|
Procedure ClearSelected;
|
||||||
property SelectedComponents : TComponentSelectionList read FSelectedComponents write FSelectedComponents;
|
property SelectedComponents : TComponentSelectionList
|
||||||
|
read FSelectedComponents write FSelectedComponents;
|
||||||
property Obj_Inspector : TObjectInspector read FObj_Inspector write FObj_Inspector;
|
property Obj_Inspector : TObjectInspector read FObj_Inspector write FObj_Inspector;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -156,7 +156,7 @@ writeln('Index = '+inttostr(PRI^.index));
|
|||||||
tkAString,
|
tkAString,
|
||||||
tkWString : Begin
|
tkWString : Begin
|
||||||
Writeln('String...');
|
Writeln('String...');
|
||||||
SetStrProp(FControl,PRI,String(Value));
|
SetStrProp(FControl,PRI,ShortString(Value));
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
tkInteger,
|
tkInteger,
|
||||||
@ -195,7 +195,7 @@ Result := True;
|
|||||||
tkAString,
|
tkAString,
|
||||||
tkWString : Begin
|
tkWString : Begin
|
||||||
Writeln('Get String...');
|
Writeln('Get String...');
|
||||||
String(Value) := GetStrProp(FControl,PRI);
|
ShortString(Value) := GetStrProp(FControl,PRI);
|
||||||
Writeln('The string returned is '+String(value));
|
Writeln('The string returned is '+String(value));
|
||||||
Writeln('*Get String...');
|
Writeln('*Get String...');
|
||||||
end;
|
end;
|
||||||
@ -243,7 +243,7 @@ Begin
|
|||||||
Freemem(PP);
|
Freemem(PP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetPPropInfoByName(Name:String): PPropInfo;
|
Function TComponentInterface.GetPPropInfoByName(Name:ShortString): PPropInfo;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
PP : PPropList;
|
PP : PPropList;
|
||||||
@ -268,7 +268,7 @@ Begin
|
|||||||
Freemem(PP);
|
Freemem(PP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetComponentType : String;
|
Function TComponentInterface.GetComponentType : ShortString;
|
||||||
Begin
|
Begin
|
||||||
Result:=FControl.ClassName;
|
Result:=FControl.ClassName;
|
||||||
end;
|
end;
|
||||||
@ -340,11 +340,11 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{This returns "Integer" or "Boolean"}
|
{This returns "Integer" or "Boolean"}
|
||||||
Function TComponentInterface.GetPropTypeName(Index : Integer) : String;
|
Function TComponentInterface.GetPropTypeName(Index : Integer) : ShortString;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
PP : PPropList;
|
PP : PPropList;
|
||||||
PI : PTypeInfo;
|
PI : PTypeInfo;
|
||||||
Begin
|
Begin
|
||||||
PI:=FControl.ClassInfo;
|
PI:=FControl.ClassInfo;
|
||||||
PT:=GetTypeData(PI);
|
PT:=GetTypeData(PI);
|
||||||
@ -359,7 +359,7 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{This returns "Left" "Align" "Visible"}
|
{This returns "Left" "Align" "Visible"}
|
||||||
Function TComponentInterface.GetPropName(Index : Integer) : String;
|
Function TComponentInterface.GetPropName(Index : Integer) : ShortString;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
PP : PPropList;
|
PP : PPropList;
|
||||||
@ -377,7 +377,7 @@ Begin
|
|||||||
freemem(PP);
|
freemem(PP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetPropTypebyName(Name : String) : TTypeKind;
|
Function TComponentInterface.GetPropTypebyName(Name : ShortString) : TTypeKind;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
PP : PPropList;
|
PP : PPropList;
|
||||||
@ -411,7 +411,7 @@ PP := GetPPropInfoByIndex(Index);
|
|||||||
Result := FGetProp(PP,Value);
|
Result := FGetProp(PP,Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetPropValuebyName(Name: String; var Value) : Boolean;
|
Function TComponentInterface.GetPropValuebyName(Name: ShortString; var Value) : Boolean;
|
||||||
var
|
var
|
||||||
PRI : PPropInfo;
|
PRI : PPropInfo;
|
||||||
Begin
|
Begin
|
||||||
@ -435,7 +435,7 @@ Begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function TComponentInterface.SetPropbyName(Name : String; const Value) : Boolean;
|
Function TComponentInterface.SetPropbyName(Name : ShortString; const Value) : Boolean;
|
||||||
var
|
var
|
||||||
PRI : PPropInfo;
|
PRI : PPropInfo;
|
||||||
Begin
|
Begin
|
||||||
@ -563,7 +563,8 @@ Begin
|
|||||||
Result := FModified;
|
Result := FModified;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomFormEditor.FindComponentByName(const Name : String) : TIComponentInterface;
|
Function TCustomFormEditor.FindComponentByName(
|
||||||
|
const Name : ShortString) : TIComponentInterface;
|
||||||
Var
|
Var
|
||||||
Num : Integer;
|
Num : Integer;
|
||||||
Begin
|
Begin
|
||||||
@ -593,7 +594,7 @@ Begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomFormEditor.CreateComponent(ParentCI : TIComponentInterface;
|
Function TCustomFormEditor.CreateComponent(ParentCI : TIComponentInterface;
|
||||||
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface;
|
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface;
|
||||||
Var
|
Var
|
||||||
Temp : TComponentInterface;
|
Temp : TComponentInterface;
|
||||||
TempName : String;
|
TempName : String;
|
||||||
@ -638,21 +639,20 @@ Begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ParentCI <> nil then
|
if ParentCI <> nil then Begin
|
||||||
Begin
|
|
||||||
Writeln('ParentCI <> nil');
|
Writeln('ParentCI <> nil');
|
||||||
TempName := Temp.FControl.ClassName;
|
TempName := Temp.FControl.ClassName;
|
||||||
delete(TempName,1,1);
|
delete(TempName,1,1);
|
||||||
writeln('TempName is '''+TempName+'''');
|
writeln('TempName is '''+TempName+'''');
|
||||||
Num := 0;
|
Num := 0;
|
||||||
Found := True;
|
Found := True;
|
||||||
While Found do
|
While Found do Begin
|
||||||
Begin
|
|
||||||
Found := False;
|
Found := False;
|
||||||
inc(num);
|
inc(num);
|
||||||
for I := 0 to FComponentInterfaceList.Count-1 do
|
for I := 0 to FComponentInterfaceList.Count-1 do
|
||||||
begin
|
begin
|
||||||
DummyComponent:=TComponent(TComponentInterface(FComponentInterfaceList.Items[i]).FControl);
|
DummyComponent:=TComponent(TComponentInterface(
|
||||||
|
FComponentInterfaceList.Items[i]).FControl);
|
||||||
if UpCase(DummyComponent.Name)=UpCase(TempName+IntToStr(Num)) then
|
if UpCase(DummyComponent.Name)=UpCase(TempName+IntToStr(Num)) then
|
||||||
begin
|
begin
|
||||||
Found := True;
|
Found := True;
|
||||||
|
182
ide/main.pp
182
ide/main.pp
@ -114,7 +114,7 @@ type
|
|||||||
itmEnvEditorOptions: TMenuItem;
|
itmEnvEditorOptions: TMenuItem;
|
||||||
|
|
||||||
CheckBox1 : TCheckBox;
|
CheckBox1 : TCheckBox;
|
||||||
Notebook1 : TNotebook;
|
ComponentNotebook : TNotebook;
|
||||||
cmdTest: TButton;
|
cmdTest: TButton;
|
||||||
cmdTest2: TButton;
|
cmdTest2: TButton;
|
||||||
Label2 : TLabel;
|
Label2 : TLabel;
|
||||||
@ -205,6 +205,7 @@ type
|
|||||||
function DoViewUnitsAndForms(OnlyForms: boolean): TModalResult;
|
function DoViewUnitsAndForms(OnlyForms: boolean): TModalResult;
|
||||||
|
|
||||||
// project(s)
|
// project(s)
|
||||||
|
property Project: TProject read fProject write fProject;
|
||||||
function DoNewProject(NewProjectType:TProjectType):TModalResult;
|
function DoNewProject(NewProjectType:TProjectType):TModalResult;
|
||||||
function DoSaveProject(SaveAs:boolean):TModalResult;
|
function DoSaveProject(SaveAs:boolean):TModalResult;
|
||||||
function DoCloseProject:TModalResult;
|
function DoCloseProject:TModalResult;
|
||||||
@ -237,9 +238,18 @@ type
|
|||||||
procedure FormPaint(Sender : TObject);
|
procedure FormPaint(Sender : TObject);
|
||||||
procedure LoadFormFromFile(Value : String);
|
procedure LoadFormFromFile(Value : String);
|
||||||
|
|
||||||
|
// form editor and designer
|
||||||
property SelectedComponent : TRegisteredComponent
|
property SelectedComponent : TRegisteredComponent
|
||||||
read FSelectedComponent write FSelectedComponent;
|
read FSelectedComponent write FSelectedComponent;
|
||||||
property Project: TProject read fProject write fProject;
|
procedure OnDesignerGetSelectedComponentClass(Sender: TObject;
|
||||||
|
var RegisteredComponent: TRegisteredComponent);
|
||||||
|
procedure OnDesignerUnselectComponentClass(Sender: TObject);
|
||||||
|
procedure OnDesignerSetDesigning(Sender: TObject; Component: TComponent;
|
||||||
|
Value: boolean);
|
||||||
|
procedure OnDesignerComponentListChanged(Sender: TObject);
|
||||||
|
procedure OnDesignerPropertiesChanged(Sender: TObject);
|
||||||
|
procedure OnDesignerAddComponent(Sender: TObject; Component: TComponent;
|
||||||
|
ComponentClass: TRegisteredComponent);
|
||||||
|
|
||||||
procedure SaveDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
|
procedure SaveDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
|
||||||
procedure LoadDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
|
procedure LoadDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
|
||||||
@ -345,15 +355,16 @@ begin
|
|||||||
Bitmap1 := TBitmap.Create;
|
Bitmap1 := TBitmap.Create;
|
||||||
Bitmap1.Handle := CreatePixmapIndirect(@IMGOK_Check, ColorToRGB(clBtnFace));
|
Bitmap1.Handle := CreatePixmapIndirect(@IMGOK_Check, ColorToRGB(clBtnFace));
|
||||||
|
|
||||||
Notebook1 := TNotebook.Create(Self);
|
ComponentNotebook := TNotebook.Create(Self);
|
||||||
Notebook1.Parent := Self;
|
with ComponentNotebook do begin
|
||||||
Notebook1.Align := alBottom;
|
Parent := Self;
|
||||||
Notebook1.Left := 1;
|
Align := alBottom;
|
||||||
// Notebook1.Top :=50+ mnuBarMain.Top+MnuBarMain.Height + 2;
|
Left := 1;
|
||||||
Notebook1.Top :=50+ 2;
|
// ComponentNotebook.Top :=50+ MnuBarMain.Top+MnuBarMain.Height + 2;
|
||||||
Notebook1.Width := ClientWidth;
|
Top :=50+ 2;
|
||||||
Notebook1.Height := 100; //ClientHeight - Notebook1.Top;
|
Width := Self.ClientWidth;
|
||||||
|
Height := 100; //Self.ClientHeight - ComponentNotebook.Top;
|
||||||
|
end;
|
||||||
|
|
||||||
SelectionPointerPixmap:=LoadSpeedBtnPixMap('tmouse');
|
SelectionPointerPixmap:=LoadSpeedBtnPixMap('tmouse');
|
||||||
PageCount := 0;
|
PageCount := 0;
|
||||||
@ -363,12 +374,12 @@ begin
|
|||||||
if RegCompPage.Name <> '' then
|
if RegCompPage.Name <> '' then
|
||||||
Begin
|
Begin
|
||||||
if (pagecount = 0) then
|
if (pagecount = 0) then
|
||||||
Notebook1.Pages.Strings[pagecount] := RegCompPage.Name
|
ComponentNotebook.Pages.Strings[pagecount] := RegCompPage.Name
|
||||||
else Notebook1.Pages.Add(RegCompPage.Name);
|
else ComponentNotebook.Pages.Add(RegCompPage.Name);
|
||||||
GlobalMouseSpeedButton := TSpeedButton.Create(Self);
|
GlobalMouseSpeedButton := TSpeedButton.Create(Self);
|
||||||
with GlobalMouseSpeedButton do
|
with GlobalMouseSpeedButton do
|
||||||
Begin
|
Begin
|
||||||
Parent := Notebook1.Page[PageCount];
|
Parent := ComponentNotebook.Page[PageCount];
|
||||||
Enabled := True;
|
Enabled := True;
|
||||||
Width := 25;
|
Width := 25;
|
||||||
Height := 25;
|
Height := 25;
|
||||||
@ -386,7 +397,7 @@ begin
|
|||||||
IDEComponent := TIDEComponent.Create;
|
IDEComponent := TIDEComponent.Create;
|
||||||
IdeComponent.RegisteredComponent := RegComp;
|
IdeComponent.RegisteredComponent := RegComp;
|
||||||
Writeln('Name is '+RegComp.ComponentClass.ClassName);
|
Writeln('Name is '+RegComp.ComponentClass.ClassName);
|
||||||
IDEComponent._SpeedButton(Self,Notebook1.Page[PageCount]);
|
IDEComponent._SpeedButton(Self,ComponentNotebook.Page[PageCount]);
|
||||||
IDEComponent.SpeedButton.OnClick := @ControlClick;
|
IDEComponent.SpeedButton.OnClick := @ControlClick;
|
||||||
IDEComponent.SpeedButton.Hint := RegComp.ComponentClass.ClassName;
|
IDEComponent.SpeedButton.Hint := RegComp.ComponentClass.ClassName;
|
||||||
IDEComponent.SpeedButton.Name := IDEComponent.SpeedButton.Hint;
|
IDEComponent.SpeedButton.Name := IDEComponent.SpeedButton.Hint;
|
||||||
@ -395,10 +406,10 @@ begin
|
|||||||
inc(PageCount);
|
inc(PageCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Notebook1.PageIndex := 0; // Set it to the first page
|
ComponentNotebook.PageIndex := 0; // Set it to the first page
|
||||||
Notebook1.Show;
|
ComponentNotebook.Show;
|
||||||
Notebook1.OnPageChanged := @ControlClick;
|
ComponentNotebook.OnPageChanged := @ControlClick;
|
||||||
Notebook1.Name := 'Notebook1';
|
ComponentNotebook.Name := 'ComponentNotebook';
|
||||||
|
|
||||||
ViewUnitsSpeedBtn := TSpeedButton.Create(Self);
|
ViewUnitsSpeedBtn := TSpeedButton.Create(Self);
|
||||||
with ViewUnitsSpeedBtn do
|
with ViewUnitsSpeedBtn do
|
||||||
@ -631,7 +642,7 @@ end;
|
|||||||
procedure TMainIDE.OIOnAddAvailableComponent(AComponent:TComponent;
|
procedure TMainIDE.OIOnAddAvailableComponent(AComponent:TComponent;
|
||||||
var Allowed:boolean);
|
var Allowed:boolean);
|
||||||
begin
|
begin
|
||||||
Allowed:=(not (AComponent is TGrabber));
|
//Allowed:=(not (AComponent is TGrabber));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OIOnSelectComponent(AComponent:TComponent);
|
procedure TMainIDE.OIOnSelectComponent(AComponent:TComponent);
|
||||||
@ -1054,13 +1065,13 @@ begin
|
|||||||
:= False
|
:= False
|
||||||
else begin
|
else begin
|
||||||
Temp := nil;
|
Temp := nil;
|
||||||
for i := 0 to Notebook1.Page[Notebook1.Pageindex].ControlCount-1 do
|
for i := 0 to ComponentNotebook.Page[ComponentNotebook.Pageindex].ControlCount-1 do
|
||||||
begin
|
begin
|
||||||
if CompareText(
|
if CompareText(
|
||||||
TControl(Notebook1.Page[Notebook1.Pageindex].Controls[I]).Name
|
TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[I]).Name
|
||||||
,'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)) = 0 then
|
,'GlobalMouseSpeedButton'+inttostr(ComponentNotebook.Pageindex)) = 0 then
|
||||||
begin
|
begin
|
||||||
temp := TControl(Notebook1.Page[Notebook1.Pageindex].Controls[i]);
|
temp := TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[i]);
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1068,7 +1079,7 @@ begin
|
|||||||
TSpeedButton(Temp).down := False
|
TSpeedButton(Temp).down := False
|
||||||
else
|
else
|
||||||
Writeln('*****************ERROR - Control ',
|
Writeln('*****************ERROR - Control ',
|
||||||
'GlobalMouseSpeedButton',inttostr(Notebook1.Pageindex),' not found');
|
'GlobalMouseSpeedButton',inttostr(ComponentNotebook.Pageindex),' not found');
|
||||||
end;
|
end;
|
||||||
if IDECOmp <> nil then Begin
|
if IDECOmp <> nil then Begin
|
||||||
//draw this button down
|
//draw this button down
|
||||||
@ -1077,13 +1088,13 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
SelectedComponent := nil;
|
SelectedComponent := nil;
|
||||||
Temp := nil;
|
Temp := nil;
|
||||||
for i := 0 to Notebook1.Page[Notebook1.Pageindex].ControlCount-1 do
|
for i := 0 to ComponentNotebook.Page[ComponentNotebook.Pageindex].ControlCount-1 do
|
||||||
begin
|
begin
|
||||||
if CompareText(
|
if CompareText(
|
||||||
TControl(Notebook1.Page[Notebook1.Pageindex].Controls[I]).Name
|
TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[I]).Name
|
||||||
,'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)) = 0 then
|
,'GlobalMouseSpeedButton'+inttostr(ComponentNotebook.Pageindex)) = 0 then
|
||||||
begin
|
begin
|
||||||
temp := TControl(Notebook1.Page[Notebook1.Pageindex].Controls[i]);
|
temp := TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[i]);
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1091,7 +1102,7 @@ begin
|
|||||||
TSpeedButton(Temp).down := True
|
TSpeedButton(Temp).down := True
|
||||||
else
|
else
|
||||||
Writeln('*****************ERROR - Control '
|
Writeln('*****************ERROR - Control '
|
||||||
+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found');
|
+'GlobalMouseSpeedButton'+inttostr(ComponentNotebook.Pageindex)+' not found');
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1104,13 +1115,13 @@ begin
|
|||||||
:= False;
|
:= False;
|
||||||
SelectedComponent := nil;
|
SelectedComponent := nil;
|
||||||
Temp := nil;
|
Temp := nil;
|
||||||
for i := 0 to Notebook1.Page[Notebook1.Pageindex].ControlCount-1 do
|
for i := 0 to ComponentNotebook.Page[ComponentNotebook.Pageindex].ControlCount-1 do
|
||||||
begin
|
begin
|
||||||
if CompareText(
|
if CompareText(
|
||||||
TControl(Notebook1.Page[Notebook1.Pageindex].Controls[I]).Name
|
TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[I]).Name
|
||||||
,'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)) = 0 then
|
,'GlobalMouseSpeedButton'+inttostr(ComponentNotebook.Pageindex)) = 0 then
|
||||||
begin
|
begin
|
||||||
temp := TControl(Notebook1.Page[Notebook1.Pageindex].Controls[i]);
|
temp := TControl(ComponentNotebook.Page[ComponentNotebook.Pageindex].Controls[i]);
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1118,7 +1129,7 @@ begin
|
|||||||
TSpeedButton(Temp).down := True
|
TSpeedButton(Temp).down := True
|
||||||
else
|
else
|
||||||
Writeln('*****************ERROR - Control '
|
Writeln('*****************ERROR - Control '
|
||||||
+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found');
|
+'GlobalMouseSpeedButton'+inttostr(ComponentNotebook.Pageindex)+' not found');
|
||||||
end;
|
end;
|
||||||
Writeln('Exiting ControlClick');
|
Writeln('Exiting ControlClick');
|
||||||
end;
|
end;
|
||||||
@ -1295,8 +1306,15 @@ end;
|
|||||||
Procedure TMainIDE.SetDefaultsforForm(aForm : TCustomForm);
|
Procedure TMainIDE.SetDefaultsforForm(aForm : TCustomForm);
|
||||||
Begin
|
Begin
|
||||||
aForm.Designer := TDesigner.Create(aForm);
|
aForm.Designer := TDesigner.Create(aForm);
|
||||||
TDesigner(aForm.Designer).MainIDE := Self;
|
with TDesigner(aForm.Designer) do begin
|
||||||
TDesigner(aForm.Designer).FormEditor := FormEditor1;
|
FormEditor := FormEditor1;
|
||||||
|
OnGetSelectedComponentClass:=@OnDesignerGetSelectedComponentClass;
|
||||||
|
OnUnselectComponentClass:=@OnDesignerUnselectComponentClass;
|
||||||
|
OnSetDesigning:=@OnDesignerSetDesigning;
|
||||||
|
OnComponentListChanged:=@OnDesignerComponentListChanged;
|
||||||
|
OnPropertiesChanged:=@OnDesignerPropertiesChanged;
|
||||||
|
OnAddComponent:=@OnDesignerAddComponent;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -2683,6 +2701,92 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerGetSelectedComponentClass(Sender: TObject;
|
||||||
|
var RegisteredComponent: TRegisteredComponent);
|
||||||
|
begin
|
||||||
|
RegisteredComponent:=SelectedComponent;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerUnselectComponentClass(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ControlClick(ComponentNoteBook);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerSetDesigning(Sender: TObject;
|
||||||
|
Component: TComponent; Value: boolean);
|
||||||
|
begin
|
||||||
|
SetDesigning(Component,Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerComponentListChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ObjectInspector1.FillComponentComboBox;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerPropertiesChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ObjectInspector1.RefreshPropertyValues;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OnDesignerAddComponent(Sender: TObject;
|
||||||
|
Component: TComponent; ComponentClass: TRegisteredComponent);
|
||||||
|
var i: integer;
|
||||||
|
ActiveForm: TCustomForm;
|
||||||
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
SrcTxt: string;
|
||||||
|
SrcTxtChanged: boolean;
|
||||||
|
ActiveSrcEdit: TSourceEditor;
|
||||||
|
FormClassName: string;
|
||||||
|
FormClassNameStartPos, FormBodyStartPos: integer;
|
||||||
|
begin
|
||||||
|
ActiveForm:=TDesigner(Sender).Form;
|
||||||
|
if ActiveForm=nil then begin
|
||||||
|
writeln('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
||||||
|
halt;
|
||||||
|
end;
|
||||||
|
// find source for form
|
||||||
|
i:=Project.UnitCount-1;
|
||||||
|
while (i>=0) do begin
|
||||||
|
if (Project.Units[i].Loaded)
|
||||||
|
and (Project.Units[i].Form=ActiveForm) then break;
|
||||||
|
dec(i);
|
||||||
|
end;
|
||||||
|
if i<0 then begin
|
||||||
|
writeln('[TMainIDE.OnDesignerAddComponent] Error: form without source');
|
||||||
|
halt;
|
||||||
|
end;
|
||||||
|
ActiveUnitInfo:=Project.Units[i];
|
||||||
|
SrcTxt:=ActiveUnitInfo.Source.Text;
|
||||||
|
SrcTxtChanged:=false;
|
||||||
|
// add needed unit to source
|
||||||
|
SrcTxtChanged:=SrcTxtChanged
|
||||||
|
or AddToInterfaceUsesSection(SrcTxt,ComponentClass.UnitName,'');
|
||||||
|
// add component definition to form source
|
||||||
|
FormClassName:=ActiveForm.ClassName;
|
||||||
|
if FindFormClassDefinitionInSource(SrcTxt,FormClassName,
|
||||||
|
FormClassNameStartPos, FormBodyStartPos) then begin
|
||||||
|
if AddFormComponentToSource(SrcTxt,FormBodyStartPos,
|
||||||
|
Component.Name, Component.ClassName) then begin
|
||||||
|
SrcTxtChanged:=true;
|
||||||
|
end else begin
|
||||||
|
Application.MessageBox('No insert point in source for the new component found.'
|
||||||
|
,'Code tool failure',mb_ok);
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// the form is not mentioned in the source?
|
||||||
|
// ignore silently
|
||||||
|
end;
|
||||||
|
// update source
|
||||||
|
if SrcTxtChanged then begin
|
||||||
|
ActiveUnitInfo.Source.Text:=SrcTxt;
|
||||||
|
ActiveUnitInfo.Modified:=true;
|
||||||
|
ActiveSrcEdit:=SourceNoteBook.FindSourceEditorWithPageIndex(
|
||||||
|
ActiveUnitInfo.EditorIndex);
|
||||||
|
ActiveSrcEdit.EditorComponent.Lines.Text:=SrcTxt;
|
||||||
|
ActiveSrcEdit.EditorComponent.Modified:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$I images/laz_images.lrs}
|
{$I images/laz_images.lrs}
|
||||||
|
|
||||||
@ -2695,8 +2799,8 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.73 2001/03/12 09:34:52 lazarus
|
Revision 1.74 2001/03/12 18:57:31 lazarus
|
||||||
MG: added transfermacros, renamed dlgmessage.pp to msgview.pp
|
MG: new designer and controlselection code
|
||||||
|
|
||||||
Revision 1.68 2001/03/03 11:06:15 lazarus
|
Revision 1.68 2001/03/03 11:06:15 lazarus
|
||||||
added project support, codetools
|
added project support, codetools
|
||||||
|
@ -1536,7 +1536,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
// load active breakpoint image
|
// load active breakpoint image
|
||||||
Pixmap1:=TPixMap.Create;
|
Pixmap1:=TPixMap.Create;
|
||||||
//Pixmap1.TransparentColor:=clBtnFace;
|
Pixmap1.TransparentColor:=clBtnFace;
|
||||||
if not LoadPixmapRes('ActiveBreakPoint',Pixmap1) then
|
if not LoadPixmapRes('ActiveBreakPoint',Pixmap1) then
|
||||||
LoadPixmapRes('default',Pixmap1);
|
LoadPixmapRes('default',Pixmap1);
|
||||||
MarksImgList.Add(Pixmap1,nil);
|
MarksImgList.Add(Pixmap1,nil);
|
||||||
|
Loading…
Reference in New Issue
Block a user