Made Designer control the control movement and such. I am now using ISDesignMsg to move the controls.

Shane

git-svn-id: trunk@100 -
This commit is contained in:
lazarus 2001-01-06 06:28:48 +00:00
parent 0a09a437ad
commit 74f4e66f0f
4 changed files with 376 additions and 42 deletions

View File

@ -168,7 +168,7 @@ endif
# Targets # Targets
override DIROBJECTS+=$(wildcard lcl components) override DIROBJECTS+=$(wildcard lcl components designer)
override EXEOBJECTS+=lazarus override EXEOBJECTS+=lazarus
# Clean # Clean
@ -1362,7 +1362,7 @@ endif
# Dir components # Dir components
ifdef OBJECTDIRCOMPONENTS ifdef OBJECTDIRCOMPONENTS
.PHONY: components_all components_debug components_examples components_test components_smart components_shared components_showinstall components_install components_sourceinstall components_exampleinstall components_zipinstall components_zipsourceinstall components_zipexampleinstall components_clean components_distclean components_cleanall components_require components_info .PHONY: components_all components_debug components_examples components_test components_smart components_shared components_showinstall components_install components_sourceinstall components_exampleinstall components_zipinstall components_zipsourceinstall components_zipexampleinstall components_clean components_distclean components_cleanall components_require components_info designer_clean
components_all: components_all:
$(MAKE) -C components all $(MAKE) -C components all
@ -1417,6 +1417,9 @@ components_require:
components_info: components_info:
$(MAKE) -C components info $(MAKE) -C components info
designer_clean:
$(MAKE) -C designer clean
endif endif
##################################################################### #####################################################################

View File

@ -25,7 +25,7 @@ unit designer;
interface interface
uses uses
classes, Forms, controls, lmessages, graphics, ControlSelection, FormEditor, UnitEditor; classes, Forms, controls, lmessages, graphics, ControlSelection, CustomFormEditor,FormEditor, UnitEditor,Main;
type type
TGridPoint = record TGridPoint = record
@ -38,9 +38,17 @@ type
FCustomForm: TCustomForm; FCustomForm: TCustomForm;
FFormEditor : TFormEditor; FFormEditor : TFormEditor;
FSourceEditor : TSourceEditor; FSourceEditor : TSourceEditor;
FMainIDE : TMainIDE;
function GetIsControl: Boolean; function GetIsControl: Boolean;
procedure SetIsControl(Value: Boolean); procedure SetIsControl(Value: Boolean);
protected protected
MouseDownControl : TObject;
MouseDownPos, MouseUpPos, LastMouseMovePos : TPoint;
Procedure MouseDownOnControl(Sender : TControl; Message : TLMessage);
procedure MouseMoveOnControl(Sender : TControl; var Message : TLMessage);
Procedure MouseUpOnControl(Sender : TControl; Message:TLMessage);
public public
ControlSelection : TControlSelection; ControlSelection : TControlSelection;
constructor Create(customform : TCustomform); constructor Create(customform : TCustomform);
@ -54,21 +62,29 @@ type
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: string); override;
Procedure SelectOnlyThisComponent(AComponent:TComponent);
procedure MouseUpOnForm(Sender : TObject; Button: TMouseButton;
Shift : TShiftState; X, Y: Integer);
procedure MouseDownOnForm(Sender : TObject; Button: TMouseButton;
Shift : TShiftState; X, Y: Integer);
procedure MouseMoveOnForm(Sender : TObject; Shift : TShiftState; X, Y: Integer);
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;
end; end;
implementation implementation
uses uses
Sysutils, Typinfo; Sysutils, Typinfo,Math;
var var
GridPoints : TGridPoint; GridPoints : TGridPoint;
constructor TDesigner.Create(CustomForm : TCustomForm); constructor TDesigner.Create(CustomForm : TCustomForm);
var var
nmUnit : String; nmUnit : String;
@ -96,15 +112,295 @@ begin
end; end;
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
begin
ControlSelection.Clear;
ControlSelection.Add(TControl(AComponent));
FFormEditor.ClearSelected;
// this will automatically inform the object inspector
FFormEditor.AddSelected(AComponent);
end;
procedure TDesigner.MouseDownOnForm(Sender : TObject; Button: TMouseButton;
Shift : TShiftState; X, Y: Integer);
Begin
Writeln('MOUSEDOWNONFORM');
if GetCaptureGrabber<>nil then exit;
MouseDownPos.X := X;
MouseDownPos.Y := Y;
MouseDownControl:=Sender;
LastMouseMovePos:=MouseDownPos;
End;
procedure TDesigner.MouseMoveOnForm(Sender : TObject;
Shift : TShiftState; X, Y: Integer);
var
CurDesigner: TDesigner;
CaptureGrabber:TGrabber;
Begin
CaptureGrabber:=GetCaptureGrabber;
if CaptureGrabber<>nil then begin
CaptureGrabber.CaptureMouseMove(TControl(Sender),Shift,X,Y);
end else begin
if Assigned(MouseDownControl) then begin
LastMouseMovePos:=Point(X,Y);
end;
end;
End;
procedure TDesigner.MouseUpOnForm(Sender : TObject; Button: TMouseButton;
Shift : TShiftState; X, Y: Integer);
var
ParentCI, NewCI : TComponentInterface;
NewLeft, NewTop, NewWidth, NewHeight : Integer;
// CInterface : TComponentInterface;
CaptureGrabber:TGrabber;
Begin
CaptureGrabber:=GetCaptureGrabber;
if CaptureGrabber<>nil then begin
CaptureGrabber.CaptureMouseUp(TControl(Sender),Button,Shift,X,Y);
exit;
end;
MouseUpPos.X := X;
MouseUpPos.Y := Y;
if FMainIDE.SelectedComponent = nil then
Begin //mouse pointer button pressed.
SelectOnlyThisComponent(TComponent(Sender));
end
else
Begin //add a new control
ParentCI:=TComponentInterface(FFormEditor.FindComponent(TComponent(Sender)));
if (TComponent(Sender) is TWinControl)
and (not (csAcceptsControls in TWinControl(Sender).ControlStyle)) then
begin
ParentCI:=TComponentInterface(
FFormEditor.FindComponent(TWinControl(Sender).Parent));
end;
if Assigned(ParentCI) then begin
NewLeft:=Min(MouseDownPos.X,MouseUpPos.X);
NewWidth:=Abs(MouseUpPos.X-MouseDownPos.X);
NewTop:=Min(MouseDownPos.Y,MouseUpPos.Y);
NewHeight:=Abs(MouseUpPos.Y-MouseDownPos.Y);
if Abs(NewWidth+NewHeight)<7 then begin
// this very small component is probably only a wag, take default size
NewWidth:=0;
NewHeight:=0;
end;
NewCI := TComponentInterface(FFormEditor.CreateComponent(ParentCI,FMainIDE.SelectedComponent.ComponentClass
,NewLeft,NewTop,NewWidth,NewHeight));
NewCI.SetPropByName('Visible',True); //Control).Visible := True;
ObjectInspector1.FillComponentComboBox;
AddControlCode(NewCI.Control);
Writeln('2222');
if NewCI.Control is TControl then begin
// set the OnMouseDown and OnMouseUp event so we know when the control
// is selected or a new control is dropped
FMainIDE.SetDesigning(NewCI.Control);
// NewCI.SetPropByName('OnMouseUp',@MouseUpOnControl);
// NewCI.SetPropByName('OnMouseDown',@MouseDownOnControl);
// NewCI.SetPropByName('OnMouseMove',@MouseMoveOnControl);
SelectOnlyThisComponent(TComponent(NewCI.Control));
end;
Writeln('Calling ControlClick with Nil from MouseUponForm');
FMainIDE.ControlClick(FMainIDE.Notebook1); //this resets it to the mouse.
end;
end;
MouseDownControl:=nil;
Writeln('Exiting MouseUPOnForm');
end;
procedure TDesigner.MouseDownOnControl(Sender : TControl; Message : TLMessage);
Begin
if GetCaptureGrabber<>nil then exit;
MouseDownPos.X := TLMMOuse(Message).pos.X;
MouseDownPos.Y := TLMMOuse(Message).pos.Y;
if not (Sender is TCustomForm) then begin
inc(MouseDownPos.X,TControl(Sender).Left);
inc(MouseDownPos.Y,TControl(Sender).Top);
end;
MouseDownControl:=Sender;
LastMouseMovePos:=MouseDownPos;
Writeln(TComponent(Sender).Name+'.OnMouseDown at '+inttostr(MouseDownPos.x)
+','+inttostr(MouseDownPos.Y));
if FMainIDE.SelectedComponent = nil then
Begin //mouse pointer button pressed.
if not (Sender is TCustomForm) then begin
SelectOnlyThisComponent(TComponent(Sender));
end;
end;
End;
procedure TDesigner.MouseUpOnControl(Sender : TControl; Message:TLMessage);
const
mk_lbutton = 1;
mk_rbutton = 2;
mk_shift = 4;
mk_control = 8;
mk_mbutton = $10;
var
ParentCI, NewCI : TComponentInterface;
NewLeft, NewTop, NewWidth, NewHeight : Integer;
// CInterface : TComponentInterface;
CaptureGrabber:TGrabber;
Button : TMouseButton;
Shift : TShiftState;
Begin
Writeln('In UpOnControl');
if (TLMMouse(Message).keys and MK_LButton) = MK_LButton then
Button := mbLEft
else
if (TLMMouse(Message).keys and MK_LButton) = MK_RButton then
Button := mbRight;
Shift := [];
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
shift := [ssShift];
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
shift := shift +[ssCTRL];
CaptureGrabber:=GetCaptureGrabber;
if CaptureGrabber<>nil then begin
CaptureGrabber.CaptureMouseUp(TControl(Sender),Button,Shift,TLMMouse(Message).pos.X,TLMMouse(Message).pos.Y);
exit;
end;
MouseUpPos.X := TLMMouse(Message).pos.X;
MouseUpPos.Y := TLMMouse(Message).pos.Y;
if not (Sender is TCustomForm) then begin
inc(MouseUpPos.X,TControl(Sender).Left);
inc(MouseUpPos.Y,TControl(Sender).Top);
end;
Writeln(TComponent(Sender).Name+'.OnMouseUp at '+inttostr(TLMMouse(Message).pos.x)+','+inttostr(TLMMouse(Message).pos.y));
if FMainIDE.SelectedComponent = nil then
Begin //mouse pointer button pressed.
if Sender is TCustomForm then
SelectOnlyThisComponent(TComponent(Sender));
end
else
Begin //add a new control
ParentCI:=TComponentInterface(FFormEditor.FindComponent(TComponent(Sender)));
if (TComponent(Sender) is TWinControl)
and (not (csAcceptsControls in TWinControl(Sender).ControlStyle)) then
begin
ParentCI:=TComponentInterface(
FFormEditor.FindComponent(TWinControl(Sender).Parent));
end;
if Assigned(ParentCI) then begin
NewLeft:=Min(MouseDownPos.X,MouseUpPos.X);
NewWidth:=Abs(MouseUpPos.X-MouseDownPos.X);
NewTop:=Min(MouseDownPos.Y,MouseUpPos.Y);
NewHeight:=Abs(MouseUpPos.Y-MouseDownPos.Y);
if Abs(NewWidth+NewHeight)<7 then begin
// this very small component is probably only a wag, take default size
NewWidth:=0;
NewHeight:=0;
end;
NewCI := TComponentInterface(FFormEditor.CreateComponent(ParentCI,FMainIDE.SelectedComponent.ComponentClass
,NewLeft,NewTop,NewWidth,NewHeight));
NewCI.SetPropByName('Visible',True); //Control).Visible := True;
ObjectInspector1.FillComponentComboBox;
AddControlCode(NewCI.Control);
if NewCI.Control is TControl then begin
// set the OnMouseDown and OnMouseUp event so we know when the control
// is selected or a new control is dropped
//why cant I do this here??? NewCI.Control.SetDesigning(True);
// NewCI.SetPropByName('OnMouseUp',@MouseUpOnControl);
// NewCI.SetPropByName('OnMouseDown',@MouseDownOnControl);
// NewCI.SetPropByName('OnMouseMove',@MouseMoveOnControl);
SelectOnlyThisComponent(TComponent(NewCI.Control));
end;
Writeln('Calling ControlClick with ni from MouseUpOnControl');
FMainIDE.ControlClick(FMainIDE.Notebook1); //this resets it to the mouse.
end;
end;
MouseDownControl:=nil;
end;
Procedure TDesigner.MouseMoveOnControl(Sender : TControl; var Message : TLMessage);
const
mk_lbutton = 1;
mk_rbutton = 2;
mk_shift = 4;
mk_control = 8;
mk_mbutton = $10;
var
CaptureGrabber : TGrabber;
Button : TMouseButton;
Shift : TShiftState;
X,Y : Integer;
Begin
X :=TLMMouse(Message).Pos.x;
Y := TLMMouse(Message).Pos.Y;
if (TLMMouse(Message).keys and MK_LButton) = MK_LButton then
Button := mbLEft
else
if (TLMMouse(Message).keys and MK_LButton) = MK_RButton then
Button := mbRight;
Shift := [];
if (TLMMouse(Message).keys and MK_Shift) = MK_Shift then
shift := [ssShift];
if (TLMMouse(Message).keys and MK_Control) = MK_Control then
shift := Shift + [ssCTRL];
CaptureGrabber:=GetCaptureGrabber;
if CaptureGrabber<>nil then begin
CaptureGrabber.CaptureMouseMove(TControl(Sender),Shift,X,Y);
end else begin
if Assigned(MouseDownControl) then begin
if FMainIDE.SelectedComponent = nil then begin
// mouse pointer button pressed
if not (Sender is TCustomForm) then begin
// move selection
ControlSelection.MoveSelection(
X-LastMouseMovePos.X, Y-LastMouseMovePos.Y);
LastMouseMovePos:=Point(X,Y);
end;
end;
end;
end;
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;
Writeln('In ISDESIGNMSG'); Writeln('In ISDESIGNMSG');
if ((Message.msg >= LM_MOUSEFIRST) and (Message.msg <= LM_MOUSELAST)) then if ((Message.msg >= LM_MOUSEFIRST) and (Message.msg <= LM_MOUSELAST)) then
Result := true; Result := true;
if (Message.msg=LM_LBUTTONDOWN) then
begin //select the control
ControlSelection.Clear;
ControlSelection.Add(TControl(Sender));
end
else
if Message.msg = LM_MOUSEMOVE then
MouseMoveonCOntrol(Sender, Message);
if Result then Writeln('It IS a design message') if Result then Writeln('It IS a design message')
else else
Writeln('It IS NOT a design message') Writeln('It IS NOT a design message');
end; end;
procedure TDesigner.LoadFile(FileName: string); procedure TDesigner.LoadFile(FileName: string);

View File

@ -133,8 +133,13 @@ end;
Function TComponentInterface.FSetProp(PRI : PPropInfo; Function TComponentInterface.FSetProp(PRI : PPropInfo;
const Value) : Boolean; const Value) : Boolean;
Begin Begin
writeln('Index = '+inttostr(PRI^.index));
case PRI^.PropType^.Kind of case PRI^.PropType^.Kind of
tkBool: SetOrdProp(FControl,PRI,longint(Value)); tkBool: Begin
Writeln('Boolean....');
SetOrdProp(FControl,PRI,longint(Value));
Result := True;
end;
tkSString, tkSString,
tkLString, tkLString,
tkAString, tkAString,
@ -397,6 +402,12 @@ Begin
Begin Begin
Result :=FSetProp(PRI,Value); Result :=FSetProp(PRI,Value);
end; end;
if Result = true then
Writeln('SETPROPBYNAME result = true')
else
Writeln('SETPROPBYNAME result = false');
end; end;
Function TComponentInterface.GetControlCount: Integer; Function TComponentInterface.GetControlCount: Integer;

View File

@ -32,8 +32,8 @@ uses
Classes, LclLinux, compiler, stdctrls, forms, buttons, menus, comctrls, Classes, LclLinux, compiler, stdctrls, forms, buttons, menus, comctrls,
Spin, project,sysutils, global, Spin, project,sysutils, global,
compileroptions, Controls, graphics, extctrls, Dialogs, dlgMEssage, compileroptions, Controls, graphics, extctrls, Dialogs, dlgMEssage,
Designer, process, idecomp, Find_dlg, FormEditor, AbstractFormEditor, process, idecomp, Find_dlg, FormEditor, AbstractFormEditor,
CustomFormEditor, ObjectInspector, ControlSelection, PropEdits, UnitEditor,CompReg; CustomFormEditor,ObjectInspector, ControlSelection, PropEdits, UnitEditor,CompReg;
const const
STANDARDBTNCOUNT = 50; STANDARDBTNCOUNT = 50;
@ -153,19 +153,20 @@ type
Procedure FileOpenedEvent(Sender : TObject; Filename : String); Procedure FileOpenedEvent(Sender : TObject; Filename : String);
Procedure FileSavedEvent(Sender : TObject; Filename : String); Procedure FileSavedEvent(Sender : TObject; Filename : String);
procedure MouseDownOnControl(Sender : TObject; Button: TMouseButton; Shift : TShiftState; X, Y: Integer); // procedure MouseDownOnControl(Sender : TObject; Button: TMouseButton; Shift : TShiftState; X, Y: Integer);
procedure MouseMoveOnControl(Sender : TObject; Shift : TShiftState; X, Y: Integer); // procedure MouseMoveOnControl(Sender : TObject; Shift : TShiftState; X, Y: Integer);
procedure MouseUpOnControl(Sender : TObject; Button: TMouseButton; Shift : TShiftState; X, Y: Integer); // procedure MouseUpOnControl(Sender : TObject; Button: TMouseButton; Shift : TShiftState; X, Y: Integer);
procedure ControlClick(Sender : TObject); Procedure COntrolClick(Sender : TObject);
procedure MessageViewDblClick(Sender : TObject); procedure MessageViewDblClick(Sender : TObject);
function FindDesigner(ChildComponent:TComponent):TDesigner; // function FindDesigner(ChildComponent:TComponent):TDesigner;
procedure SelectOnlyThisComponent(AComponent:TComponent); // procedure SelectOnlyThisComponent(AComponent:TComponent);
procedure OIOnAddAvailableComponent(AComponent:TComponent; var Allowed:boolean); procedure OIOnAddAvailableComponent(AComponent:TComponent; var Allowed:boolean);
procedure OIOnSelectComponent(AComponent:TComponent); procedure OIOnSelectComponent(AComponent:TComponent);
private private
FCodeLastActivated : Boolean; //used for toggling between code and forms FCodeLastActivated : Boolean; //used for toggling between code and forms
FControlLastActivated : TObject; FControlLastActivated : TObject;
FSelectedComponent : TRegisteredComponent;
Function CreateSeperator : TMenuItem; Function CreateSeperator : TMenuItem;
Function ReturnActiveUnitList : TUnitInfo; Function ReturnActiveUnitList : TUnitInfo;
@ -179,18 +180,18 @@ type
// Procedure Paint; override; // Procedure Paint; override;
Function ReturnFormName(Source : TStringList) : String; Function ReturnFormName(Source : TStringList) : String;
SelectedComponent : TRegisteredComponent;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure LoadMainMenu; procedure LoadMainMenu;
Procedure FormKill(Sender : TObject); Procedure FormKill(Sender : TObject);
Procedure SetFlags(SLIst : TUnitInfo); Procedure SetFlags(SLIst : TUnitInfo);
Procedure SetName_Form(SList : TUnitInfo); Procedure SetName_Form(SList : TUnitInfo);
Procedure SetDesigning(Control : TComponent);
procedure FormPaint(Sender : TObject); procedure FormPaint(Sender : TObject);
//these numbers are used to determine where the mouse was when the button was pressed //these numbers are used to determine where the mouse was when the button was pressed
MouseDownPos, MouseUpPos, LastMouseMovePos : TPoint; MouseDownPos, MouseUpPos, LastMouseMovePos : TPoint;
MouseDownControl: TObject; MouseDownControl: TObject;
property SelectedComponent : TRegisteredComponent read FSelectedComponent write FSelectedComponent;
end; end;
@ -216,7 +217,7 @@ var
implementation implementation
uses uses
TestForm, ViewUnit_dlg,ViewForm_dlg, Math,lresources; TestForm, ViewUnit_dlg,ViewForm_dlg, Math,lresources, Designer;
{ TMainIDE } { TMainIDE }
@ -710,8 +711,12 @@ begin
end; end;
procedure TMainIDE.OIOnSelectComponent(AComponent:TComponent); procedure TMainIDE.OIOnSelectComponent(AComponent:TComponent);
var
Form : TCustomForm;
begin begin
SelectOnlyThisComponent(AComponent); Form := GetParentForm(TControl(AComponent));
//not implemented yet
TDesigner(Form.Designer).SelectOnlyThisComponent(AComponent);
end; end;
Procedure TMainIDE.ToolButtonCLick(Sender : TObject); Procedure TMainIDE.ToolButtonCLick(Sender : TObject);
@ -1135,6 +1140,12 @@ FControlLastActivated := Sender;
end; end;
Procedure TMainIDE.SetDesigning(Control : TComponent);
Begin
Control.SetDesigning(True);
end;
{ {
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -1152,8 +1163,13 @@ var
Speedbutton : TSpeedbutton; Speedbutton : TSpeedbutton;
Temp : TControl; Temp : TControl;
begin begin
Writeln('In ControlClick with nil?');
if Sender=nil then Writeln('yep, Sender is nil');
if Sender is TSpeedButton then if Sender is TSpeedButton then
Begin Begin
Writeln('sender is a speedbutton');
Writeln('The name is '+TSpeedbutton(sender).name);
SpeedButton := TSPeedButton(Sender); SpeedButton := TSPeedButton(Sender);
Writeln('Speedbutton s Name is '+SpeedButton.name); Writeln('Speedbutton s Name is '+SpeedButton.name);
//find the IDECOmponent that has this speedbutton //find the IDECOmponent that has this speedbutton
@ -1176,14 +1192,14 @@ begin
else else
Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found'); Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found');
end; end;
if IDECOmp <> nil then if IDECOmp <> nil then
Begin Begin
//draw this button down //draw this button down
SpeedButton.Down := True; SpeedButton.Down := True;
SelectedComponent := IDEComp.RegisteredComponent; SelectedComponent := IDEComp.RegisteredComponent;
end end
else else
begin begin
SelectedComponent := nil; SelectedComponent := nil;
Temp := nil; Temp := nil;
for i := 0 to Notebook1.Page[Notebook1.Pageindex].ControlCount-1 do for i := 0 to Notebook1.Page[Notebook1.Pageindex].ControlCount-1 do
@ -1198,11 +1214,11 @@ begin
TSpeedButton(Temp).down := True TSpeedButton(Temp).down := True
else else
Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found'); Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found');
end; end;
end end
else else
Begin Begin
Writeln('must be nil');
//draw old speedbutton up //draw old speedbutton up
if SelectedComponent <> nil then if SelectedComponent <> nil then
TIDeComponent(IdeCompList.FindCompByRegComponent(SelectedComponent)).SpeedButton.Down := False; TIDeComponent(IdeCompList.FindCompByRegComponent(SelectedComponent)).SpeedButton.Down := False;
@ -1222,11 +1238,12 @@ begin
Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found'); Writeln('*****************ERROR - Control '+'GlobalMouseSpeedButton'+inttostr(Notebook1.Pageindex)+' not found');
end; end;
Writeln('Exiting ControlClick');
end; end;
function TMainIDE.FindDesigner(ChildComponent:TComponent):TDesigner; {function TMainIDE.FindDesigner(ChildComponent:TComponent):TDesigner;
begin begin
if ChildComponent is TForm then if ChildComponent is TForm then
Result:=TDesigner(TForm(ChildComponent).Designer) Result:=TDesigner(TForm(ChildComponent).Designer)
@ -1236,8 +1253,8 @@ begin
else else
Result:=nil; Result:=nil;
end; end;
}
procedure TMainIDE.SelectOnlyThisComponent(AComponent:TComponent); {procedure TMainIDE.SelectOnlyThisComponent(AComponent:TComponent);
var var
CurDesigner:TDesigner; CurDesigner:TDesigner;
begin begin
@ -1251,7 +1268,7 @@ begin
// this will automatically inform the object inspector // this will automatically inform the object inspector
FormEditor1.AddSelected(AComponent); FormEditor1.AddSelected(AComponent);
end; end;
}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1263,7 +1280,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TMainIDE.MouseDownOnControl(Sender : TObject; Button: TMouseButton; {procedure TMainIDE.MouseDownOnControl(Sender : TObject; Button: TMouseButton;
Shift : TShiftState; X, Y: Integer); Shift : TShiftState; X, Y: Integer);
Begin Begin
if GetCaptureGrabber<>nil then exit; if GetCaptureGrabber<>nil then exit;
@ -1366,7 +1383,6 @@ Begin
end; end;
NewCI := TComponentInterface(FormEditor1.CreateComponent(ParentCI,SelectedComponent.ComponentClass NewCI := TComponentInterface(FormEditor1.CreateComponent(ParentCI,SelectedComponent.ComponentClass
,NewLeft,NewTop,NewWidth,NewHeight)); ,NewLeft,NewTop,NewWidth,NewHeight));
NewCI.SetPropByName('Designing',True);
NewCI.SetPropByName('Visible',True); //Control).Visible := True; NewCI.SetPropByName('Visible',True); //Control).Visible := True;
ObjectInspector1.FillComponentComboBox; ObjectInspector1.FillComponentComboBox;
@ -1376,9 +1392,10 @@ Begin
// set the OnMouseDown and OnMouseUp event so we know when the control // set the OnMouseDown and OnMouseUp event so we know when the control
// is selected or a new control is dropped // is selected or a new control is dropped
writeln('NewComponent is TControl'); writeln('NewComponent is TControl');
NewCI.SetPropByName('OnMouseUp',@MouseUpOnControl); NewCI.Control.SetDesigning(True);
NewCI.SetPropByName('OnMouseDown',@MouseDownOnControl); // NewCI.SetPropByName('OnMouseUp',@MouseUpOnControl);
NewCI.SetPropByName('OnMouseMove',@MouseMoveOnControl); // NewCI.SetPropByName('OnMouseDown',@MouseDownOnControl);
// NewCI.SetPropByName('OnMouseMove',@MouseMoveOnControl);
SelectOnlyThisComponent(TComponent(NewCI.Control)); SelectOnlyThisComponent(TComponent(NewCI.Control));
end; end;
end; end;
@ -1387,7 +1404,7 @@ writeln('NewComponent is TControl');
MouseDownControl:=nil; MouseDownControl:=nil;
ControlClick(Notebook1); //this resets it to the mouse. ControlClick(Notebook1); //this resets it to the mouse.
end; end;
}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TMainIDE.mnuNewFormClicked(Sender : TObject); procedure TMainIDE.mnuNewFormClicked(Sender : TObject);
var var
@ -1410,19 +1427,25 @@ begin
ObjectInspector1.Left+ObjectInspector1.Width+5,ObjectInspector1.Top, ObjectInspector1.Left+ObjectInspector1.Width+5,ObjectInspector1.Top,
400,300)); 400,300));
CInterface.SetPropByName('Designing',True);
TempForm:=TForm(CInterface.Control); TempForm:=TForm(CInterface.Control);
//TempForm.SetDesigning(true);
TempForm.Designer := TempForm.Designer :=
TDesigner.Create(TCustomForm(CInterface.Control)); TDesigner.Create(TCustomForm(CInterface.Control));
TDesigner(TempForm.Designer).MainIDE := Self;
TDesigner(TempForm.Designer).FormEditor := FormEditor1; TDesigner(TempForm.Designer).FormEditor := FormEditor1;
TDesigner(tempForm.Designer).SourceEditor := SourceNotebook.CreateUnitFromForm(TempForm); TDesigner(tempForm.Designer).SourceEditor := SourceNotebook.CreateUnitFromForm(TempForm);
TempForm.OnMouseDown := @MouseDownOnControl; TempForm.OnMouseDown := @TDesigner(TempForm.Designer).MouseDownOnForm;
TempForm.OnMouseUp := @MouseUpOnControl; TempForm.OnMouseUp := @TDesigner(TempForm.Designer).MouseUpOnForm;
TempForm.OnMouseMove := @MouseMoveOnControl; TempForm.OnMouseMove := @TDesigner(TempForm.Designer).MouseMoveOnForm;
TempForm.OnActivate := @CodeOrFormActivated; TempForm.OnActivate := @CodeOrFormActivated;
Writeln('display form');
TempForm.Show; TempForm.Show;
Writeln('display form');
PropertyEditorHook1.LookupRoot := TForm(CInterface.Control); PropertyEditorHook1.LookupRoot := TForm(CInterface.Control);
FormEditor1.ClearSelected; FormEditor1.ClearSelected;
@ -1869,8 +1892,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.34 2001/01/05 18:56:23 lazarus Revision 1.35 2001/01/06 06:28:47 lazarus
Minor changes Made Designer control the control movement and such. I am now using ISDesignMsg to move the controls.
Shane
Revision 1.32 2001/01/04 20:33:53 lazarus Revision 1.32 2001/01/04 20:33:53 lazarus
Moved lresources. Moved lresources.