mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 20:50:18 +02:00
Changes for loading filesa
Shane git-svn-id: trunk@122 -
This commit is contained in:
parent
001301df01
commit
1476ee9a17
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -112,6 +112,7 @@ ide/compiler.pp svneol=native#text/pascal
|
|||||||
ide/compileroptions.pp svneol=native#text/pascal
|
ide/compileroptions.pp svneol=native#text/pascal
|
||||||
ide/compreg.pp svneol=native#text/pascal
|
ide/compreg.pp svneol=native#text/pascal
|
||||||
ide/customformeditor.pp svneol=native#text/pascal
|
ide/customformeditor.pp svneol=native#text/pascal
|
||||||
|
ide/dlgmessage.lfm svneol=native#text/plain
|
||||||
ide/dlgmessage.lrs svneol=native#text/pascal
|
ide/dlgmessage.lrs svneol=native#text/pascal
|
||||||
ide/dlgmessage.pp svneol=native#text/pascal
|
ide/dlgmessage.pp svneol=native#text/pascal
|
||||||
ide/find_dlg.pp svneol=native#text/pascal
|
ide/find_dlg.pp svneol=native#text/pascal
|
||||||
@ -129,12 +130,11 @@ ide/main.pp svneol=native#text/pascal
|
|||||||
ide/project.pp svneol=native#text/pascal
|
ide/project.pp svneol=native#text/pascal
|
||||||
ide/splash.pp svneol=native#text/pascal
|
ide/splash.pp svneol=native#text/pascal
|
||||||
ide/testform.pp svneol=native#text/pascal
|
ide/testform.pp svneol=native#text/pascal
|
||||||
ide/tmessagedlg.lfm svneol=native#text/plain
|
|
||||||
ide/tviewforms1.lfm svneol=native#text/plain
|
|
||||||
ide/tviewunits1.lfm svneol=native#text/plain
|
|
||||||
ide/uniteditor.pp svneol=native#text/pascal
|
ide/uniteditor.pp svneol=native#text/pascal
|
||||||
|
ide/viewform_dlg.lfm svneol=native#text/plain
|
||||||
ide/viewform_dlg.pp svneol=native#text/pascal
|
ide/viewform_dlg.pp svneol=native#text/pascal
|
||||||
ide/viewforms1.lrs svneol=native#text/pascal
|
ide/viewforms1.lrs svneol=native#text/pascal
|
||||||
|
ide/viewunit_dlg.lfm svneol=native#text/plain
|
||||||
ide/viewunit_dlg.pp svneol=native#text/pascal
|
ide/viewunit_dlg.pp svneol=native#text/pascal
|
||||||
ide/viewunits1.lrs svneol=native#text/pascal
|
ide/viewunits1.lrs svneol=native#text/pascal
|
||||||
images/color.xpm -text svneol=native#image/x-xpixmap
|
images/color.xpm -text svneol=native#image/x-xpixmap
|
||||||
|
@ -106,8 +106,11 @@ TCustomFormEditor
|
|||||||
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;
|
||||||
|
Function CreateControlComponentInterface(Control: TCOmponent) : TIComponentInterface;
|
||||||
|
|
||||||
Function CreateComponent(ParentCI : TIComponentInterface;
|
Function CreateComponent(ParentCI : TIComponentInterface;
|
||||||
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface; override;
|
TypeClass : TComponentClass; X,Y,W,H : Integer): TIComponentInterface; override;
|
||||||
|
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;
|
||||||
@ -470,6 +473,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCustomFormEditor.Destroy;
|
destructor TCustomFormEditor.Destroy;
|
||||||
|
var
|
||||||
|
I : Integer;
|
||||||
begin
|
begin
|
||||||
JITFormList.Destroy;
|
JITFormList.Destroy;
|
||||||
FComponentInterfaceList.Free;
|
FComponentInterfaceList.Free;
|
||||||
@ -496,7 +501,13 @@ Begin
|
|||||||
Writeln('1');
|
Writeln('1');
|
||||||
RemoveFromComponentInterfaceList(Temp);
|
RemoveFromComponentInterfaceList(Temp);
|
||||||
Writeln('2');
|
Writeln('2');
|
||||||
Temp.Delete;
|
if (Value is TCustomForm) then
|
||||||
|
begin
|
||||||
|
JITFormList.DestroyJITFOrm(TForm(Value));
|
||||||
|
Temp.Destroy;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Temp.Delete;
|
||||||
Writeln('3');
|
Writeln('3');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -567,7 +578,7 @@ Begin
|
|||||||
Begin
|
Begin
|
||||||
//this should be a form
|
//this should be a form
|
||||||
NewFormIndex := JITFormList.AddNewJITForm;
|
NewFormIndex := JITFormList.AddNewJITForm;
|
||||||
if NewFormIndex > 0 then
|
if NewFormIndex >= 0 then
|
||||||
Temp.FControl := JITFormList[NewFormIndex];
|
Temp.FControl := JITFormList[NewFormIndex];
|
||||||
// Temp.FControl := TypeClass.Create(nil);
|
// Temp.FControl := TypeClass.Create(nil);
|
||||||
end;
|
end;
|
||||||
@ -592,6 +603,7 @@ Begin
|
|||||||
|
|
||||||
if ParentCI <> nil then
|
if ParentCI <> nil then
|
||||||
Begin
|
Begin
|
||||||
|
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+'''');
|
||||||
@ -603,8 +615,7 @@ Begin
|
|||||||
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(
|
DummyComponent:=TComponent(TComponentInterface(FComponentInterfaceList.Items[i]).FControl);
|
||||||
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;
|
||||||
@ -615,6 +626,7 @@ Begin
|
|||||||
Temp.FControl.Name := TempName+IntToStr(Num);
|
Temp.FControl.Name := TempName+IntToStr(Num);
|
||||||
Writeln('TempName + num = '+TempName+Inttostr(num));
|
Writeln('TempName + num = '+TempName+Inttostr(num));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Temp.FControl is TControl) then
|
if (Temp.FControl is TControl) then
|
||||||
Begin
|
Begin
|
||||||
CompLeft:=X;
|
CompLeft:=X;
|
||||||
@ -653,5 +665,48 @@ Begin
|
|||||||
FSelectedComponents.Clear;
|
FSelectedComponents.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function TCustomFormEditor.NewFormFromLFM(_Filename : String): TCustomForm;
|
||||||
|
var
|
||||||
|
BinStream: TMemoryStream;
|
||||||
|
TxtStream : TFileStream;
|
||||||
|
Index : Integer;
|
||||||
|
Begin
|
||||||
|
Writeln('[NewFormFromLFM]');
|
||||||
|
result := nil;
|
||||||
|
try
|
||||||
|
BinStream := TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
TxtStream:= TFileStream.Create(_Filename,fmOpenRead);
|
||||||
|
try
|
||||||
|
ObjectTexttoBinary(TxtStream,BinStream);
|
||||||
|
finally
|
||||||
|
TxtStream.Free;
|
||||||
|
end;
|
||||||
|
BinStream.Position := 0;
|
||||||
|
Writeln('[NewFormFromLFM] calling AddJITFORMFromStream');
|
||||||
|
Index := JITFormList.AddJITFormFromStream(binStream);
|
||||||
|
Writeln('[NewFormFromLFM] index='+inttostr(index));
|
||||||
|
Result := JITFormList[Index];
|
||||||
|
finally
|
||||||
|
BinStream.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
//some error raised
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TCustomFormEditor.CreateControlComponentInterface(Control: TComponent) :TIComponentInterface;
|
||||||
|
var
|
||||||
|
Temp : TComponentInterface;
|
||||||
|
|
||||||
|
Begin
|
||||||
|
Temp := TComponentInterface.Create;
|
||||||
|
Temp.FControl := Control;
|
||||||
|
FComponentInterfaceList.Add(Temp);
|
||||||
|
Result := Temp;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -268,7 +268,6 @@ begin
|
|||||||
// RegisterStandardComponents
|
// RegisterStandardComponents
|
||||||
|
|
||||||
RegisterComponentsProc:=@RegisterComponents;
|
RegisterComponentsProc:=@RegisterComponents;
|
||||||
RegisterComponents('','ExtCtrls',[TPage]);
|
|
||||||
RegisterComponents('Standard','Menus',[TMenu,TPopupMenu]);
|
RegisterComponents('Standard','Menus',[TMenu,TPopupMenu]);
|
||||||
RegisterComponents('Standard','Buttons',[TButton]);
|
RegisterComponents('Standard','Buttons',[TButton]);
|
||||||
RegisterComponents('Standard','StdCtrls',[TEdit,TLabel,TMemo,TCheckBox
|
RegisterComponents('Standard','StdCtrls',[TEdit,TLabel,TMemo,TCheckBox
|
||||||
@ -277,11 +276,12 @@ begin
|
|||||||
RegisterComponents('Additional','ExtCtrls',[TNoteBook,TPaintBox
|
RegisterComponents('Additional','ExtCtrls',[TNoteBook,TPaintBox
|
||||||
,TBevel,TRadioGroup]);
|
,TBevel,TRadioGroup]);
|
||||||
RegisterComponents('Additional','ComCtrls',[TStatusBar,TListView,TProgressBar
|
RegisterComponents('Additional','ComCtrls',[TStatusBar,TListView,TProgressBar
|
||||||
,TToolBar,TTrackbar]);
|
,TToolBar,TToolbutton,TTrackbar]);
|
||||||
RegisterComponents('','ComCtrls',[TToolbutton]);
|
|
||||||
|
|
||||||
RegisterComponents('Samples','Spin',[TSpinEdit]);
|
RegisterComponents('Samples','Spin',[TSpinEdit]);
|
||||||
RegisterComponents('System','ExtCtrls',[TTimer]);
|
RegisterComponents('System','ExtCtrls',[TTimer]);
|
||||||
|
// RegisterComponents('','ComCtrls',[TToolbutton]);
|
||||||
|
RegisterComponents('','ExtCtrls',[TPage]);
|
||||||
|
|
||||||
RegisterComponentsProc:=nil;
|
RegisterComponentsProc:=nil;
|
||||||
|
|
||||||
|
38
ide/main.pp
38
ide/main.pp
@ -1560,13 +1560,45 @@ end;
|
|||||||
|
|
||||||
Procedure TMainIDE.FileOpenedEvent(Sender : TObject; Filename : String);
|
Procedure TMainIDE.FileOpenedEvent(Sender : TObject; Filename : String);
|
||||||
var
|
var
|
||||||
MenuItem : TMenuItem;
|
MenuItem : TMenuItem;
|
||||||
|
CInterface : TComponentInterface;
|
||||||
|
TempForm : TCustomForm;
|
||||||
|
Texts : String;
|
||||||
|
I : Integer;
|
||||||
Begin
|
Begin
|
||||||
//Add a new menuitem to the popup that displays the filename.
|
//Add a new menuitem to the popup that displays the filename.
|
||||||
MenuItem := TMenuItem.Create(Self);
|
MenuItem := TMenuItem.Create(Self);
|
||||||
MenuItem.Caption := Filename;
|
MenuItem.Caption := Filename;
|
||||||
MenuItem.OnClick := @SourceNotebook.OpenClicked;
|
MenuItem.OnClick := @SourceNotebook.OpenClicked;
|
||||||
OpenFilePopupMenu.Items.Add(MenuItem);
|
OpenFilePopupMenu.Items.Add(MenuItem);
|
||||||
|
|
||||||
|
Texts := Filename;
|
||||||
|
//chop off the extension.
|
||||||
|
delete(Texts,pos('.',Texts),length(texts));
|
||||||
|
Texts := Texts + '.lfm';
|
||||||
|
Writeln('the filename is '+texts);
|
||||||
|
if FileExists(Texts) then
|
||||||
|
begin
|
||||||
|
FormEditor1.SelectedComponents.Clear;
|
||||||
|
TempForm := FormEditor1.NewFormFromLFM(Texts);
|
||||||
|
|
||||||
|
CInterface := TComponentInterface(FormEditor1.CreateControlComponentInterface(tempForm));
|
||||||
|
TempForm.Designer := TDesigner.Create(TempForm);
|
||||||
|
TDesigner(TempForm.Designer).MainIDE := Self;
|
||||||
|
TDesigner(TempForm.Designer).FormEditor := FormEditor1;
|
||||||
|
TDesigner(tempForm.Designer).SourceEditor := TSourceEditor(sender);
|
||||||
|
TSourceEditor(sender).control := TempForm;
|
||||||
|
TempForm.OnActivate := @CodeOrFormActivated;
|
||||||
|
for I := 0 to TempForm.ComponentCount -1 do
|
||||||
|
FormEditor1.CreateControlComponentInterface(TempForm.Components[i]);
|
||||||
|
TempForm.Show;
|
||||||
|
SetDesigning(TempForm,True);
|
||||||
|
PropertyEditorHook1.LookupRoot := TForm(CInterface.Control);
|
||||||
|
FormEditor1.ClearSelected;
|
||||||
|
FormEditor1.AddSelected(TComponent(CInterface.Control));
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
//enable save buttons here
|
//enable save buttons here
|
||||||
SpeedButton5.Enabled := True;
|
SpeedButton5.Enabled := True;
|
||||||
SpeedButton6.Enabled := True;
|
SpeedButton6.Enabled := True;
|
||||||
@ -1901,6 +1933,10 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.45 2001/01/15 20:55:44 lazarus
|
||||||
|
Changes for loading filesa
|
||||||
|
Shane
|
||||||
|
|
||||||
Revision 1.44 2001/01/15 18:25:51 lazarus
|
Revision 1.44 2001/01/15 18:25:51 lazarus
|
||||||
Fixed a stupid error I caused by using a variable as an index in main.pp and this variable sometimes caused an exception because the index was out of range.
|
Fixed a stupid error I caused by using a variable as an index in main.pp and this variable sometimes caused an exception because the index was out of range.
|
||||||
Shane
|
Shane
|
||||||
|
@ -27,7 +27,7 @@ unit UnitEditor;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
classes, Controls, forms,buttons,sysutils,Dialogs,
|
classes, Controls, forms,buttons,sysutils,Dialogs,FormEditor,
|
||||||
{$ifdef NEW_EDITOR_SYNEDIT}
|
{$ifdef NEW_EDITOR_SYNEDIT}
|
||||||
synedit,SysHighlighterpas,
|
synedit,SysHighlighterpas,
|
||||||
{$else}
|
{$else}
|
||||||
@ -123,7 +123,7 @@ type
|
|||||||
Function Save : Boolean;
|
Function Save : Boolean;
|
||||||
Function Open : Boolean;
|
Function Open : Boolean;
|
||||||
|
|
||||||
property Control : TComponent read FControl;
|
property Control : TComponent read FControl write FControl;
|
||||||
property CurrentCursorXLine : Integer read GetCurrentCursorXLine write SetCurrentCursorXLine;
|
property CurrentCursorXLine : Integer read GetCurrentCursorXLine write SetCurrentCursorXLine;
|
||||||
property CurrentCursorYLine : Integer read GetCurrentCursorYLine write SetCurrentCursorYLine;
|
property CurrentCursorYLine : Integer read GetCurrentCursorYLine write SetCurrentCursorYLine;
|
||||||
property Owner : TComponent read FAOwner;
|
property Owner : TComponent read FAOwner;
|
||||||
@ -145,6 +145,7 @@ type
|
|||||||
private
|
private
|
||||||
Notebook1 : TNotebook;
|
Notebook1 : TNotebook;
|
||||||
FEmpty : Boolean;
|
FEmpty : Boolean;
|
||||||
|
FFormEditor : TFormEditor;
|
||||||
FSourceEditorList : TList;
|
FSourceEditorList : TList;
|
||||||
FSaveDialog : TSaveDialog;
|
FSaveDialog : TSaveDialog;
|
||||||
FOpenDialog : TOpenDialog;
|
FOpenDialog : TOpenDialog;
|
||||||
@ -184,6 +185,7 @@ type
|
|||||||
property OnOpenFile : TNotifyFileEvent read FOnOPenFile write FOnOPenFile;
|
property OnOpenFile : TNotifyFileEvent read FOnOPenFile write FOnOPenFile;
|
||||||
property OnSaveFile : TNotifyFileEvent read FOnSaveFile write FOnSaveFile;
|
property OnSaveFile : TNotifyFileEvent read FOnSaveFile write FOnSaveFile;
|
||||||
property Empty : Boolean read GetEmpty;
|
property Empty : Boolean read GetEmpty;
|
||||||
|
property FormEditor : TFormEditor read FFormEditor write FFormEditor;
|
||||||
property MainIDE : TComponent read FMainIDE;
|
property MainIDE : TComponent read FMainIDE;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -851,42 +853,7 @@ end;
|
|||||||
{This method checks to see if the loaded unit is a form unit.
|
{This method checks to see if the loaded unit is a form unit.
|
||||||
If so, it creates the form }
|
If so, it creates the form }
|
||||||
Procedure TSourceEditor.CreateFormFromUnit;
|
Procedure TSourceEditor.CreateFormFromUnit;
|
||||||
Var
|
|
||||||
I,X : Integer;
|
|
||||||
Found : Boolean;
|
|
||||||
Texts : String;
|
|
||||||
Begin
|
Begin
|
||||||
Writeln('CREATEFORMFROMUNIT');
|
|
||||||
for I := 0 to Source.Count -1 do
|
|
||||||
begin
|
|
||||||
Found := (Pos('initialization',lowercase(Source.Strings[i])) <> 0);
|
|
||||||
if Found then break;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if Not Found then exit;
|
|
||||||
|
|
||||||
Writeln('Found Initialization at '+inttostr(i));
|
|
||||||
|
|
||||||
For X := I to Source.Count-1 do
|
|
||||||
Begin
|
|
||||||
Found := (pos('{<LAZARUSFORMDEF>}',Source.Strings[x]) <> 0);
|
|
||||||
if Found then Break;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if Not Found then exit;
|
|
||||||
Writeln('Found the lazarusformdef line');
|
|
||||||
inc(x);
|
|
||||||
Texts := Source.Strings[x];
|
|
||||||
Writeln('texts = '+texts);
|
|
||||||
//grab the file name
|
|
||||||
Texts := Copy(Texts,pos('{$I ',Texts)+4,Length(Texts));
|
|
||||||
Texts := Copy(Texts,1,pos('.',Texts)+3);
|
|
||||||
Writeln('the resource file is '+Texts);
|
|
||||||
Writeln('Calling the function');
|
|
||||||
TMainIDE(TSourceNotebook(FAOwner).MainIDe).LoadResourceFromFile(Texts);
|
|
||||||
Writeln('Called the function');
|
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1227,7 +1194,7 @@ Begin
|
|||||||
TempEditor.Filename := FOpenDialog.Filename;
|
TempEditor.Filename := FOpenDialog.Filename;
|
||||||
if (TempEditor.Open) then
|
if (TempEditor.Open) then
|
||||||
Begin
|
Begin
|
||||||
if assigned(FOnOPenFile) then FOnOpenFile(self,FOpenDialog.Filename);
|
if assigned(FOnOPenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename);
|
||||||
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
|
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1259,8 +1226,13 @@ Begin
|
|||||||
//create a new page
|
//create a new page
|
||||||
TempEditor := NewSE(-1);
|
TempEditor := NewSE(-1);
|
||||||
TempEditor.Filename := Filename;
|
TempEditor.Filename := Filename;
|
||||||
TempEditor.OPen;
|
|
||||||
Notebook1.Pages.Strings[Notebook1.Pageindex] := ExtractFileName(TempEditor.UnitName);
|
if (TempEditor.OPen) then
|
||||||
|
Begin
|
||||||
|
if assigned(FOnOPenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename);
|
||||||
|
Notebook1.Pages.Strings[Notebook1.Pageindex] := ExtractFileName(TempEditor.UnitName);
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user