From 8ad22a1c8f8045dc19d9b6463f7cbaa07ac970e9 Mon Sep 17 00:00:00 2001 From: lazarus Date: Thu, 30 Nov 2000 21:43:38 +0000 Subject: [PATCH] Changed TDesigner. It's now notified when a control is added to it's CustomForm. It's created in main.pp when New Form is selected. Shane git-svn-id: trunk@53 - --- .gitattributes | 1 - designer/abstractformeditor.pp | 15 ++ designer/designer.pp | 140 +++++++++++++-- ide/customformeditor.pp | 16 +- ide/main.pp | 302 ++------------------------------- lcl/controls.pp | 6 +- lcl/forms.pp | 28 +-- lcl/include/control.inc | 15 +- lcl/include/customform.inc | 32 +++- lcl/include/designer.inc | 19 --- 10 files changed, 227 insertions(+), 347 deletions(-) delete mode 100644 lcl/include/designer.inc diff --git a/.gitattributes b/.gitattributes index af0cb95689..75920413b2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -200,7 +200,6 @@ lcl/include/custommemo.inc svneol=native#text/pascal lcl/include/customnotebook.inc svneol=native#text/pascal lcl/include/customradiogroup.inc svneol=native#text/pascal lcl/include/defaultbitbtnimages.inc svneol=native#text/pascal -lcl/include/designer.inc svneol=native#text/pascal lcl/include/dragobject.inc svneol=native#text/pascal lcl/include/edit.inc svneol=native#text/pascal lcl/include/filectrl.inc svneol=native#text/pascal diff --git a/designer/abstractformeditor.pp b/designer/abstractformeditor.pp index 58a3225017..7bcb29e5e2 100644 --- a/designer/abstractformeditor.pp +++ b/designer/abstractformeditor.pp @@ -66,6 +66,21 @@ or use TPropertyType end; + TIFormInterface = class + public + Function Filename : String; virtual; abstract; + Function FormModified : Boolean; virtual; abstract; + Function MArkModified : Boolean; virtual; abstract; + Function GetFormComponent : TIComponentInterface; virtual; abstract; + Function FindComponent : TIComponentInterface; virtual; abstract; + Function GetComponentfromHandle(ComponentHandle:Pointer): TIComponentInterface; virtual; abstract; + + Function GetSelCount: Integer; virtual; abstract; + Function GetSelComponent(Index : Integer): TIComponentInterface; virtual; abstract; + Function CreateComponent(CI : TIComponentInterface; TypeClass : TComponentClass; + X,Y,W,H : Integer): TIComponentInterface; virtual; abstract; + end; + { Created by Shane Miller This unit defines the layout for the forms editor. The forms editor is responsible diff --git a/designer/designer.pp b/designer/designer.pp index 5f3d8f85df..44d2128dd8 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -25,30 +25,140 @@ unit designer; interface uses - classes; + classes,Forms,controls,lmessages,graphics,ControlSelection; type - TDesigner = class(TObject) - public - constructor Create;override; - procedure CreateNew(FileName : string); - procedure LoadFile(FileName: string); + TGridPoint = record + x: integer; + y: integer; + end; + + TDesigner = class(TIDesigner) + private + FCustomForm: TCustomForm; + FControlSelection : TControlSelection; + function GetIsControl: Boolean; + procedure SetIsControl(Value: Boolean); + protected + ControlSelection : TControlSelection; + + public + constructor Create(customform : TCustomform); + destructor Destroy; override; + procedure CreateNew(FileName : string); + procedure LoadFile(FileName: string); + + function IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean; override; + procedure Modified; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure PaintGrid; override; + procedure ValidateRename(AComponent: TComponent; const CurName, NewName: string); override; + property IsControl: Boolean read GetIsControl write SetIsControl; + property Form: TCustomForm read FCustomForm write FCustomForm; end; implementation - constructor Create;override; - begin - end; +var +GridPoints : TGridPoint; - procedure CreateNew(FileName : string); - begin - end; +constructor TDesigner.Create(CustomForm : TCustomForm); +begin +inherited Create; +FCustomForm := CustomForm; +ControlSelection := TControlSelection.Create(FCustomForm); +end; - procedure LoadFile(FileName: string); - begin - end; +destructor TDesigner.Destroy; +Begin +Inherited; +ControlSelection.free; +end; + +procedure TDesigner.CreateNew(FileName : string); +begin + +end; + +procedure TDesigner.LoadFile(FileName: string); +begin + +end; + + +function TDesigner.IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean; +Begin + +end; + +procedure TDesigner.Modified; +Begin + +end; + +procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation); +Begin + if Operation = opInsert then + begin + //AComponent.SetDesigning(True); + if (AComponent is TCOntrol) then + Begin +// TControl(AComponent).Visible := True; + ControlSelection.Clear; + Controlselection.Add(TCOntrol(AComponent)); + end; + end + else + if Operation = opRemove then + begin + if (AComponent is TControl) then + if ControlSelection.IsSelected(TControl(AComponent)) then + ControlSelection.Remove(TControl(AComponent)); + end; + +end; + +procedure TDesigner.PaintGrid; +var + x,y : integer; +begin + with FCustomForm do + Begin + canvas.Pen.Color := clGray; + X := left; + while X <= left + width do + begin + Y := Top; + while y <= top+height do + begin + Canvas.Rectangle(x-left,y-top,x-left+1,y-top); + Inc(Y, GridPoints.Y); + end; + Inc(x, GridPoints.X); + end; + end; +end; + +procedure TDesigner.ValidateRename(AComponent: TComponent; const CurName, NewName: string); +Begin + +end; + +function TDesigner.GetIsControl: Boolean; +Begin + +end; + + +procedure TDesigner.SetIsControl(Value: Boolean); +Begin + +end; + +initialization + Gridpoints.x := 10; + GridPoints.Y := 10; end. diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index aaf5de1fcb..d8755606f1 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -159,13 +159,16 @@ PP : PPropList; PI : PTypeInfo; I : Longint; Begin - PT:=GetTypeData(FControl.ClassInfo); + Name := Uppercase(name); + PI := FControl.ClassInfo; + PT:=GetTypeData(PI); + if PT <> nil then Writeln('PT is NOT nil') else Writeln('PT is NIL'); GetMem (PP,PT^.PropCount*SizeOf(Pointer)); GetPropInfos(PI,PP); I := -1; repeat inc(i); - until (PP^[i]^.Name = Name) or (i > PT^.PropCount-1); + until (PP^[i]^.Name = Name) or (i = PT^.PropCount-1); if PP^[i]^.Name = Name then Result:=PP^[i] @@ -377,19 +380,26 @@ Function TComponentInterface.SetPropbyName(Name : String; const Value) : Boolean var PRI : PPropInfo; Begin +Writeln('*************'); +Writeln('SetPropByName'); Result := False; - PRI := GetPPropInfoByName(Name); + PRI := GetPPropInfoByName(Uppercase(Name)); + Writeln('Back from GetPPropInfobyName'); if PRI <> nil then with PRI^ do Begin if SetProc <> nil then Begin //call the procedure passing Value + Writeln('Assigning the procedure'); MySetProc := TSetProc(SetProc^); + Writeln('Calling the procedure'); MySetProc(Value); Result := True; end; end; +Writeln('SetPropByName Exiting...'); +Writeln('*************'); end; diff --git a/ide/main.pp b/ide/main.pp index 758a9e6d45..ca973c0869 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -31,7 +31,7 @@ uses classes,LclLinux,compiler, stdctrls,forms,buttons,menus,comctrls, Spin, project,sysutils, global, compileroptions,Controls,graphics,extctrls, Dialogs,dlgMEssage, - designerform,process,idecomp,Find_dlg,FormEditor,CustomFormEditor,Object_Inspector; + Designer,process,idecomp,Find_dlg,FormEditor,CustomFormEditor,Object_Inspector; const STANDARDBTNCOUNT = 50; @@ -145,11 +145,9 @@ type procedure ControlClick(Sender : TObject); procedure MessageViewDblClick(Sender : TObject); - procedure DesignFormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private Function CreateSeperator : TMenuItem; Procedure SetBtnDefaults(Control : Pointer;I,Page : Integer); - function CreateNewForm : TDesignerForm; Function ReturnActiveUnitList : TUnitInfo; Function Create_LFM(SList : TUnitInfo) : Boolean; Function SavebyUnit(SList : TUnitInfo) : Boolean; @@ -194,6 +192,7 @@ var Form1 : TForm1; FormEditor1 : TFormEditor; ObjectInspector1 : TObjectInspector; + Taginc : Integer; implementation uses @@ -1330,81 +1329,6 @@ For I := 0 to Project1.UnitList.Count-1 do End; -procedure TForm1.DesignFormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); -var - NewObj : TControl; - i: Integer; -begin - if (Button = mbLeft) - then begin - - // OK for the sake of showing something I'll use this - // WE NEED SOMETHING ELSE - NewObj := TIdeComponent(ideComplist.items[bpressed-1]).CreateMethod(TDesignerForm(Sender)); - if NewObj <> nil - then begin - TDesignerForm(Sender).AddControl(NewObj, X, Y); - - //this resets it to the mouse. - ControlClick(Notebook1); - - //add line into source for the control. - for i := 0 to Project1.Unitlist.Count-1 do - begin - if TUnitInfo(Project1.Unitlist.items[i]).Formname = TForm(sender).name - then Break; - end; - if I < Project1.Unitlist.Count - then begin - TUnitInfo(Project1.Unitlist.items[i]).AddControlLine(NewObj.name + ': ' + NewObj.ClassName); - end; - end; - end; -end; - - -(* -{ ------------------------------------------------------------------------- ------------------------------------------------------------------------- --------------------ClickOnForm----------------------------------------- ------------------------------------------------------------------------- ------------------------------------------------------------------------- -} -procedure TForm1.ClickonForm(Sender : TObject); -var -MOusePos : TPoint; -NewObj : TControl; -I : Integer; -Begin - -NewObj := TideComponent(ideComplist.items[bpressed-1]).CreateMethod(TDesignerForm(Sender)); - -if (newobj <> nil) then - begin - if (NewOBj is TWinControl) then - TDesignerForm(Sender).AddDesignerWinControl(NewObj) - else - TDesignerForm(Sender).AddDesignerControl(NewObj); - - ControlClick(Notebook1); //this resets it to the mouse. - //add line into source for the control. - for i := 0 to Project1.Unitlist.Count-1 do - begin - if TUnitInfo(Project1.Unitlist.items[i]).Formname = TForm(sender).name then break; - end; - if I < Project1.Unitlist.Count then - Begin - TUnitInfo(Project1.Unitlist.items[i]).AddControlLine(NewObj.name+': '+NewObj.ClassName); - end; - - - end; - - -end; -*) - { @@ -1541,6 +1465,7 @@ Begin //otherwise we drop a control and call the CreateComponent function. if BPressed = 1 then Begin //mouse button pressed. + FormEditor1.ClearSelected; Writeln('Clicked on the control!!!!! Control name is '+TControl(sender).name); FormEditor1.AddSelected(TComponent(Sender)); @@ -1549,7 +1474,7 @@ if BPressed = 1 then Begin //add a new control CInterface := TComponentInterface(FormEditor1.CreateComponent(nil, TComponentClass(TIdeComponent(ideComplist.items[bpressed-1]).ClassType),-1,-1,-1,-1)); - TControl(CInterface.Control).Visible := True; + CInterface.Setpropbyname('Visible',True);//Control).Visible := True; //set the ONCLICK event so we know when the control is selected; TControl(CInterface.Control).OnClick := @ClickOnControl; @@ -1642,15 +1567,15 @@ if (X >= 0) and (X <= TControl(sender).Width) and else CInterface := TComponentInterface(FormEditor1.CreateComponent(nil, TComponentClass(TIdeComponent(ideComplist.items[bpressed-1]).ClassType),Mouse_Down.X,Mouse_Down.Y,-1,-1)); - - - TControl(CInterface.Control).Visible := True; + // CInterface.Setpropbyname('Visible',True);//Control).Visible := True; //set the ONCLICK event so we know when the control is selected; + TControl(CInterface.Control).Visible := True; TControl(CInterface.Control).OnClick := @ClickOnControl; FormEditor1.ClearSelected; FormEditor1.AddSelected(TComponent(Cinterface.Control)); ObjectInspector1.RootComponent := TForm(sender); + ObjectInspector1.FillComponentComboBox; end; //TIdeComponent(ideComplist.items[bpressed-1]). @@ -1680,8 +1605,10 @@ begin if not Assigned(FormEditor1) then FormEditor1 := TFormEditor.Create; FormEditor1.SelectedComponents.Clear; + CInterface := TComponentInterface(FormEditor1.CreateComponent(nil,TForm,50,50,300,400)); TForm(CInterface.Control).Name := 'Form1'; + TForm(CInterface.Control).Designer := TDesigner.Create(TCustomForm(CInterface.Control)); TForm(CInterface.Control).Show; //set the ONCLICK event so we know when a control is dropped onto the form. @@ -1692,46 +1619,6 @@ begin end; -function TForm1.CreateNewForm : TDesignerForm; -var -NewName : String; -I : Integer; -Num : Integer; -Found : Boolean; -Form : TDesignerForm; -Begin -NewName := 'TForm'; -delete(Newname,1,1); -Found := false; -Num := 1; -while not found do - Begin - Found := true; -if ControlCount > 0 then -for i := 0 to ControlCount-1 do - begin - if Controls[i].name = (Newname+inttostr(Num)) then - Begin - inc(num); - Found := False; - break; - end; - end; - end; //while - - Form := TDesignerForm.Create(self); - Form.parent := Self; - Form.Name := NewName+inttostr(num); - Form.Position:= poDesigned; - Form.OnMouseUp := @DesignFormMouseUp; - Form.Show; - Form.Caption := Form.name; - Form.Top := Top+Height; - Form.Left := 150; - //Create lfm file -result := Form; -end; - {------------------------------------------------------------------------------} procedure TForm1.mnuOpenClicked(Sender : TObject); @@ -2072,189 +1959,24 @@ var SList : TUnitInfo; Begin Assert(False, 'Trace:New Project Clicked'); - if Project1.UnitList.Count > 0 then - Begin //project already loaded - //save other project and such - Project1.UnitList.Clear; - end; - -Assert(False, 'Trace:*************************************************************************'); - Project1.Name := 'Project1'; - Caption := 'Lazarus - '+Project1.Name; - SList := TUnitInfo.Create; - SList.Name := 'Project1.lpr'; - SList.FormName := ''; - SList.Flags := pfPRoject; - with SList.Source do - Begin - //Add the default lines - Add('Program Project1;'); - Add(''); - Add('uses'); - Add(' Forms,'); -// Add(' Unit1 in ''Unit1.pp'' {Form1};'); - Add(' Unit1;'); - Add(''); - Add('begin'); - Add(' Application.Initialize;'); - Add(' Application.CreateForm(TForm1, Form1);'); - Add(' Application.Run;'); - Add('end.'); - end; - SList.Filename := ''; - SList.Page := -1; - Project1.AddUnit(SList); - Assert(False, 'Trace:Project1.UnitList.count = '+inttostr(Project1.UnitList.Count)); - - //Create first unit, then display it. - SList := TUnitInfo.Create; - SList.Name := 'Unit1.pp'; - SList.Form := CreateNewForm; - SList.Formname := SList.Form.Name; - SList.Flags := pfForm; - with SList.Source do - Begin - //Add the default lines - Add('unit Unit1;'); - Add(''); - Add('{$mode objfpc}'); - Add(''); - Add('interface'); - Add(''); - Add('uses'); - Add('Classes, Messages, SysUtils, Graphics, Controls, Forms, Dialogs;'); - Add(''); - Add('type'); - Add(' T'+SList.Formname+' = class(TForm)'); - Add(' private'); - Add(' { Private declarations }'); - Add(' public'); - Add(' { Public declarations }'); - Add(' end;'); - Add(''); - Add('var'); - Add(' '+SList.FormName+': TForm1;'); - Add(''); - Add('implementation'); - Add(''); - Add('end.'); - end; - - SList.Filename := ''; - - //display unit1 - - //fill ViewUnits Listbox - ideEditor1.AddPage(SList.Name,SList.Source); - SList.Page := ideEditor1.Notebook1.Pageindex; - Project1.AddUnit(SList); - UpdateViewDialogs; -Assert(False, 'Trace:*************************************************************************'); - ideEditor1.Show; - end; {------------------------------------------------------------} Procedure TForm1.mnuOpenProjectClicked(Sender : TObject); -Var -I : Integer; -pName : String; Begin -OpenDialog1.Filter := '*.lpr'; -OpenDialog1.Title := 'Open Project file:'; -If OpenDialog1.Execute then - Begin - if Project1.UnitList.Count > 0 then - Begin //project already loaded - //save other project and such - Project1.UnitList.Clear; - //Clear all notebook pages - for I := 0 to ideEditor1.Notebook1.Pages.count-1 do - IdeEditor1.DeletePage(0); - - end; - PName := ExtractFilePath(OpenDialog1.Filename)+Copy(ExtractFileName(OpenDialog1.Filename),1,pos('.',ExtractFileName(OpenDialog1.Filename))-1); - if Project1.OpenProject(PName) then - Begin - Project1.Name := Copy(ExtractFileName(OpenDialog1.Filename),1,pos('.',OpenDialog1.Filename)-1); - Caption := 'Lazarus - '+Project1.Name; - UpdateViewDialogs; - end; - End; - end; Procedure TForm1.mnuSaveProjectClicked(Sender : TObject); -Var -I : Integer; -PName : String; Begin -if Project1.UnitList.Count <= 0 then exit; -SaveDialog1.Filter := '*.lpr'; -SaveDialog1.Filename := '*.lpr'; -SaveDialog1.Title := 'Save project as:'; -//Determine if the Savedialog is needed to save the project file -for I := 0 to Project1.UnitList.Count-1 do - Begin - //Save each unit - if (TUnitInfo(Project1.UnitList.Items[I]).Flags = pfProject) and - (TUnitInfo(Project1.UnitList.Items[I]).filename = '') then - Begin - if SaveDialog1.Execute then - Begin - TUnitInfo(Project1.UnitList.Items[I]).FileName := SaveDialog1.Filename; - TUnitInfo(Project1.UnitList.Items[i]).Name := Copy(ExtractFileName(SaveDialog1.Filename),1,pos('.',ExtractFileName(SaveDialog1.Filename))-1); - PName := ExtractFilePath(SaveDialog1.Filename)+Copy(ExtractFileName(SaveDialog1.Filename),1,pos('.',ExtractFileName(SaveDialog1.Filename))-1); - SaveDialog1.Filename := ExtractFilePath(Savedialog1.Filename)+TUnitInfo(Project1.UnitList.Items[i]).Name; - Project1.Name := SaveDialog1.Filename; - end - else - Exit; - break; - end - else - if (TUnitInfo(Project1.UnitList.Items[I]).Flags = pfProject) and - (TUnitInfo(Project1.UnitList.Items[I]).filename <> '') then - pName := ExtractFilePath(TUnitInfo(Project1.UnitList.Items[I]).filename)+Copy(ExtractFileName(TUnitInfo(Project1.UnitList.Items[I]).filename),1,pos('.',ExtractFileName(TUnitInfo(Project1.UnitList.Items[I]).filename))-1); - end; - for I := 0 to Project1.UnitList.Count-1 do - Begin - //Save each unit - if not(SavebyUnit(TUnitInfo(Project1.Unitlist.Items[I]))) then exit; - end; - Assert(False, 'Trace:PNAME = '+pname); - Project1.SaveProject(pname); - UpdateViewDialogs; end; Procedure TForm1.mnuBuildProjectClicked(Sender : TObject); -Const - BufSize = 1024; -Var - TheProgram : String; - Buf : Array[1..BUFSIZE] of char; - I,Count : longint; - Texts : String; - NUm : Integer; - WriteMessage : Boolean; Begin -if not(messagedlg.visible) then -MessageDlg.Show; -Messagedlg.Clear; -if Project1.UnitList.Count = 0 then Exit; //no project loaded -mnuSaveProjectClicked(self); -if TUnitInfo(Project1.UnitList[0]).FileName = '' then Exit; -MEssageDlg.Caption := 'Compiler Messages - Compiling.............'; -Application.ProcessMessages; - -Compiler1.Compile; - -MessageDlg.Caption := 'Compiler Messages'; end; @@ -2471,8 +2193,10 @@ end. { ============================================================================= $Log$ - Revision 1.12 2000/11/29 21:22:35 lazarus - New Object Inspector code + Revision 1.13 2000/11/30 21:43:38 lazarus + Changed TDesigner. It's now notified when a control is added to it's CustomForm. + It's created in main.pp when New Form is selected. + Shane Revision 1.5 2000/08/10 13:22:51 lazarus diff --git a/lcl/controls.pp b/lcl/controls.pp index 13faea1829..481ea6afc8 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -1123,8 +1123,10 @@ end. { ============================================================================= $Log$ - Revision 1.4 2000/11/29 21:22:35 lazarus - New Object Inspector code + Revision 1.5 2000/11/30 21:43:38 lazarus + Changed TDesigner. It's now notified when a control is added to it's CustomForm. + It's created in main.pp when New Form is selected. + Shane Revision 1.3 2000/11/27 18:52:37 lazarus diff --git a/lcl/forms.pp b/lcl/forms.pp index d6e4cf0876..555819f1ea 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -57,7 +57,7 @@ type FAutoScroll : Boolean; end; - TDesigner = class; + TIDesigner = class; TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object; @@ -71,7 +71,7 @@ type FActiveControl : TWinControl; FBorderStyle : TFormBorderStyle; FCanvas : TControlCanvas; - FDesigner : TDesigner; + FDesigner : TIDesigner; FFormStyle : TFormStyle; FKeyPreview: Boolean; FMenu : TMainMenu; @@ -90,7 +90,7 @@ type procedure DoDestroy; Procedure SetActiveControl(Value : TWinControl); Procedure SetBorderStyle(value : TFORMBorderStyle); - Procedure SetDesigner(Value : TDesigner); + Procedure SetDesigner(Value : TIDesigner); Procedure SetMenu(value : TMainMenu); Procedure SetFormStyle(Value : TFormStyle); Procedure SetPosition(value : TPosition); @@ -115,6 +115,7 @@ type Function GetClientRect : TRect ; Override; Procedure Notification(AComponent: TComponent; Operation : TOperation);override; procedure Paint; dynamic; + Procedure PaintWindow(dc : Hdc); override; Procedure RequestAlign; Override; procedure UpdateShowing; override; procedure UpdateWindowState; @@ -146,7 +147,7 @@ type property BorderStyle : TFormBorderStyle read FBorderStyle write SetBorderStyle default bsSizeable; property Canvas: TControlCanvas read GetCanvas; property Caption stored IsForm; - property Designer : TDesigner read FDesigner write SetDesigner; + property Designer : TIDesigner read FDesigner write SetDesigner; property FormState : TFormState read FFormState; property KeyPreview: Boolean read FKeyPreview write FKeyPreview; property Menu : TMainMenu read FMenu write SetMenu; @@ -176,6 +177,11 @@ type // property WindowState; property OnCreate; property OnDestroy; + property OnShow; + property OnHide; + property OnPaint; + property OnClose; + property OnCloseQuery; end; TFormClass = class of TForm; @@ -239,11 +245,7 @@ type property OnIdle: TIdleEvent read FOnIdle write FOnIdle; end; - TDesigner = class(TObject) - private - FCustomForm: TCustomForm; - function GetIsControl: Boolean; - procedure SetIsControl(Value: Boolean); + TIDesigner = class(TObject) public function IsDesignMsg(Sender: TControl; var Message: TLMessage): Boolean; virtual; abstract; @@ -253,9 +255,7 @@ type procedure PaintGrid; virtual; abstract; procedure ValidateRename(AComponent: TComponent; const CurName, NewName: string); virtual; abstract; - property IsControl: Boolean read GetIsControl write SetIsControl; - property Form: TCustomForm read FCustomForm write FCustomForm; - end; + end; @@ -279,7 +279,7 @@ implementation uses - buttons,stdctrls,interfaces; + buttons,stdctrls,interfaces,designer; var FocusMessages : Boolean; //Should set it to TRUE by defualt but fpc does not handle that yet. @@ -321,7 +321,7 @@ end; {$I Customform.inc} {$I screen.inc} {$I application.inc} -{$I designer.inc} + initialization Screen:= TScreen.Create(nil); Application:= TApplication.Create(nil); diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 11dc6639ff..2bf5c2ffa9 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -379,9 +379,11 @@ begin //Assert(False, Format('Trace:[TControl.WndPRoc] %s --> Message = %d',[CLASSNAME, Message.msg])); //Assert(False, 'Trace:-----------IN TCONTROL WNDPROC----------'); - if (csDesigning in ComponentState) - then begin - + if (csDesigning in ComponentState) then + begin + Form := GetParentForm(Self); + if (Form <> nil) and (Form.Designer <> nil) and + Form.Designer.IsDesignMsg(Self,MEssage) then Exit; end else begin @@ -712,6 +714,7 @@ procedure TControl.Notification( AComponent : TComponent; Operation : TOperation begin inherited Notification(AComponent, Operation); if Operation = opRemove then + if AComponent = PopupMenu then PopupMenu := nil; end; @@ -1239,6 +1242,12 @@ end; { ============================================================================= $Log$ + Revision 1.4 2000/11/30 21:43:38 lazarus + Changed TDesigner. It's now notified when a control is added to it's CustomForm. + It's created in main.pp when New Form is selected. + + Shane + Revision 1.3 2000/11/29 21:22:35 lazarus New Object Inspector code Shane diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index da646e51e2..8fc0305be6 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -261,6 +261,30 @@ begin if Assigned (FOnPaint) and not(Isresizing) then FOnPaint(Self); end; +{------------------------------------------------------------------------------ + Method: TCustomForm.PaintWindow + Params: none + Returns: nothing + + Calls user handler + ------------------------------------------------------------------------------} +Procedure TCustomForm.PaintWindow(DC : Hdc); +begin +// FCanvas.Lock; + try + FCanvas.Handle := DC; + try + if FDesigner <> nil then FDesigner.PaintGrid else Paint; + finally + FCanvas.Handle := 0; + end; + + finally +// FCanvas.Unlock; + end; + +end; + {------------------------------------------------------------------------------ Method: TCustomForm.RequestAlign @@ -283,7 +307,7 @@ end; {------------------------------------------------------------------------------} { TCustomForm SetDesigner } {------------------------------------------------------------------------------} -Procedure TCustomForm.SetDesigner(Value : TDesigner); +Procedure TCustomForm.SetDesigner(Value : TIDesigner); Begin FDesigner := Value; end; @@ -782,6 +806,12 @@ end; { ============================================================================= $Log$ + Revision 1.6 2000/11/30 21:43:38 lazarus + Changed TDesigner. It's now notified when a control is added to it's CustomForm. + It's created in main.pp when New Form is selected. + + Shane + Revision 1.5 2000/11/21 17:33:37 lazarus Added TCustomForm.Notification so the TDesigner is notified of actions. diff --git a/lcl/include/designer.inc b/lcl/include/designer.inc deleted file mode 100644 index 779fc4d9d4..0000000000 --- a/lcl/include/designer.inc +++ /dev/null @@ -1,19 +0,0 @@ -{****************************************************************************** - TDesigner - ******************************************************************************} -{ TDesigner } - -function TDesigner.GetIsControl: Boolean; -begin -// commented out because of a compiler error -// Result := (FCustomForm <> nil) and FCustomForm.IsControl; -Result := true; -end; - -procedure TDesigner.SetIsControl(Value: Boolean); -begin -//commented out because of a compiler error -// if (FCustomForm <> nil) then FCustomForm.IsControl := Value; - -end; -