Changeset 54 for trunk


Ignore:
Timestamp:
Jun 26, 2012, 7:41:11 AM (12 years ago)
Author:
chronos
Message:
  • Modified: Project instance is now freed in closed state.
  • Added: Toolbar button Open now provide dropdown list of recent opened projects.
Location:
trunk/IDE
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/IDE/Forms/UFormMain.lfm

    r53 r54  
    4343      Top = 2
    4444      Action = AProjectOpen
     45      DropdownMenu = PopupMenu1
     46      Style = tbsDropDown
    4547    end
    4648    object ToolButton3: TToolButton
    47       Left = 47
     49      Left = 59
    4850      Top = 2
    4951      Action = AProjectSave
    5052    end
    5153    object ToolButton4: TToolButton
    52       Left = 70
     54      Left = 82
    5355      Top = 2
    5456      Action = AProjectClose
    5557    end
    5658    object ToolButton5: TToolButton
    57       Left = 93
     59      Left = 105
    5860      Top = 2
    5961      Width = 10
     
    6163    end
    6264    object ToolButton6: TToolButton
    63       Left = 103
     65      Left = 115
    6466      Top = 2
    6567      Action = AViewOptions
    6668    end
    6769    object ToolButton7: TToolButton
    68       Left = 126
     70      Left = 138
    6971      Top = 2
    7072      Action = ABuild
    7173    end
    7274    object ToolButton8: TToolButton
    73       Left = 149
     75      Left = 161
    7476      Top = 2
    7577      Action = ARun
    7678    end
    7779    object ToolButton9: TToolButton
    78       Left = 172
     80      Left = 184
    7981      Top = 2
    8082      Action = APause
    8183    end
    8284    object ToolButton10: TToolButton
    83       Left = 195
     85      Left = 207
    8486      Top = 2
    8587      Action = AStop
     
    869871  end
    870872  object ImageList1: TImageList
    871     left = 344
    872     top = 184
     873    left = 112
     874    top = 272
    873875    Bitmap = {
    874876      4C690E0000001000000010000000000000000000000000000000000000000000
     
    13231325    }
    13241326  end
     1327  object PopupMenu1: TPopupMenu
     1328    left = 196
     1329    top = 54
     1330  end
    13251331end
  • trunk/IDE/Forms/UFormMain.pas

    r53 r54  
    8888    PageControlRight: TPageControl;
    8989    PageControlBottom: TPageControl;
     90    PopupMenu1: TPopupMenu;
    9091    SaveDialog1: TSaveDialog;
    9192    Splitter1: TSplitter;
     
    144145    procedure DockInit;
    145146    procedure UpdateMenu;
    146     procedure UpdateToolbar;
     147    procedure UpdateTitle;
    147148  public
    148149    procedure LoadFromRegistry(Root: HKEY; Key: string);
     
    290291
    291292procedure TFormMain.UpdateInterface;
    292 var
    293   I: Integer;
    294   Title: string;
    295293begin
    296294  with Core do begin
    297   Title := ApplicationInfo.Name;
    298   if Project.FileName <> '' then Title := Project.FileName + ' - ' + Title;
    299   if Project.Modified then Title := Title + ' *';
    300   Caption := Title;
    301   AProjectClose.Enabled := Project.Active;
    302   AProjectSave.Enabled := Project.Active and Project.Modified;
    303   AProjectSaveAs.Enabled := Project.Active;
     295  UpdateTitle;
     296  AProjectClose.Enabled := Assigned(Project);
     297  AProjectSave.Enabled := Assigned(Project) and Project.Modified;
     298  AProjectSaveAs.Enabled := Assigned(Project);
    304299  (*AProgramRun.Enabled := Project.Active and (BrainFuckInterpreter.State = rsStopped);
    305300  AProgramPause.Enabled := Project.Active and (BrainFuckInterpreter.State = rsRunning);
    306301  AProgramStop.Enabled := Project.Active and (BrainFuckInterpreter.State <> rsStopped);*)
    307   ABuild.Enabled := Project.Active and Assigned(Compiler.Target) and
     302  ABuild.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
    308303    Assigned(Compiler.Target.Producer);
    309   APause.Enabled := Project.Active and Assigned(Compiler.Target) and
     304  APause.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
    310305    Assigned(Compiler.Target.Executor) and (Compiler.Target.Executor.State = rsRunning);
    311   ARun.Enabled := Project.Active and Assigned(Compiler.Target) and
     306  ARun.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
    312307    Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsStopped) or
    313308    (Compiler.Target.Executor.State = rsPaused));
    314   AStop.Enabled := Project.Active and Assigned(Compiler.Target) and
     309  AStop.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
    315310    Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or
    316311    (Compiler.Target.Executor.State = rsPaused));
    317   AStepIn.Enabled := Project.Active and Assigned(Compiler.Target) and
     312  AStepIn.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
    318313    Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or
    319314    (Compiler.Target.Executor.State = rsPaused));
     
    324319
    325320  UpdateMenu;
    326   UpdateToolbar;
    327321  FormSourceCode.UpdateInterface;
    328322  FormTargetCode.UpdateInterface;
     
    443437end;
    444438
    445 procedure TFormMain.UpdateToolbar;
    446 var
    447   I: Integer;
    448 begin
    449   for I := 0 to ToolBar1.ButtonCount - 1 do
    450     TToolButton(ToolBar1.Buttons[I]).Hint := TToolButton(ToolBar1.Buttons[I]).Caption;
     439procedure TFormMain.UpdateTitle;
     440var
     441  Title: string;
     442begin
     443  Title := ApplicationInfo.Name;
     444  if Assigned(Core.Project) then begin
     445    if Core.Project.FileName <> '' then Title := Core.Project.FileName + ' - ' + Title;
     446    if Core.Project.Modified then Title := Title + ' *';
     447  end;
     448  Caption := Title;
    451449end;
    452450
     
    503501begin
    504502  //if Project.Modified then ;
    505   Core.Project.Active := False;
     503  FreeAndNil(Core.Project);
    506504  UpdateInterface;
    507505end;
     
    532530begin
    533531  if FormProjectNew.ShowModal = mrOk then begin
    534     if Assigned(FormProjectNew.ListView1.Selected) then
     532    if Assigned(FormProjectNew.ListView1.Selected) then begin
     533      Core.ProjectNew;
    535534      TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Core.Project);
     535    end;
    536536  end;
    537537  UpdateInterface;
     
    540540procedure TFormMain.AProjectSaveAsExecute(Sender: TObject);
    541541begin
     542  if Assigned(Core.Project) then
    542543  if SaveDialog1.Execute then begin
    543     Core.Project.Active := True;
    544544    Core.Project.SaveToFile(SaveDialog1.FileName);
    545545    FormSourceCode.Save;
  • trunk/IDE/Forms/UFormProject.pas

    r53 r54  
    7474    BeginUpdate;
    7575    Clear;
    76     if Project.Active then begin
     76    if Assigned(Project) then begin
    7777      NewNode := AddChild(nil, ExtractFileNameOnly(Project.FileName));
    7878      UpdateProjectFiles(NewNode, Project.Files);
  • trunk/IDE/Forms/UFormSourceCode.pas

    r53 r54  
    4040procedure TFormSourceCode.SynEditSourceChange(Sender: TObject);
    4141begin
    42   if Core.Project.Active then
     42  if Assigned(Core.Project) then
    4343    ProjectFile.Modified := True;
    4444end;
     
    6161procedure TFormSourceCode.UpdateInterface;
    6262begin
    63   SynEditSource.Enabled := Core.Project.Active;
    64   if not Core.Project.Active then SynEditSource.ClearAll;
     63  SynEditSource.Enabled := Assigned(Core.Project);
     64  if not Assigned(Core.Project) then SynEditSource.ClearAll;
    6565end;
    6666
  • trunk/IDE/Forms/UFormTargetCode.pas

    r53 r54  
    4848procedure TFormTargetCode.UpdateInterface;
    4949begin
    50   SynEdit1.Enabled := Core.Project.Active;
    51   if not Core.Project.Active then SynEdit1.ClearAll;
     50  SynEdit1.Enabled := Assigned(Core.Project);
     51  if not Assigned(Core.Project) then SynEdit1.ClearAll;
    5252end;
    5353
  • trunk/IDE/Forms/UFormTargetProject.pas

    r53 r54  
    4141    BeginUpdate;
    4242    Clear;
    43     if Project.Active then begin
     43    if Assigned(Project) then begin
    4444      NewNode := AddChild(nil, ExtractFileNameOnly(TargetProject.FileName));
    4545      UpdateProjectFiles(NewNode, TargetProject.Files);
  • trunk/IDE/UCore.pas

    r53 r54  
    3636    procedure ProjectTemplatesInit;
    3737    procedure ProjectOpen(FileName: string);
     38    procedure ProjectNew;
    3839    procedure CompilerDebugLog(Text: string);
    3940    procedure LoadFromRegistry(Root: HKEY; Key: string);
     
    5556procedure TCore.ProjectOpen(FileName: string);
    5657begin
    57   Project.Active := True;
     58  ProjectNew;
    5859  Project.LoadFromFile(FileName);
    5960  LastOpenedFiles.AddItem(FileName);
    6061  FormMain.UpdateInterface;
     62end;
     63
     64procedure TCore.ProjectNew;
     65begin
     66  if Assigned(Project) then FreeAndNil(Project);
     67  Project := TProject.Create;
     68  Project.FileName := SNewProject;
    6169end;
    6270
     
    97105begin
    98106  LastOpenedFiles.LoadToMenuItem(FormMain.MenuItemOpenRecent,
     107    FormMain.OpenRecentClick);
     108  LastOpenedFiles.LoadToMenuItem(FormMain.PopupMenu1.Items,
    99109    FormMain.OpenRecentClick);
    100110end;
  • trunk/IDE/UProject.pas

    r51 r54  
    7575    FActive: Boolean;
    7676    FModified: Boolean;
    77     function GetActive: Boolean;
    78     procedure SetActive(AValue: Boolean);
     77    FOnChange: TNotifyEvent;
    7978    procedure SetModified(AValue: Boolean);
    8079  public
     
    9190    constructor Create;
    9291    destructor Destroy; override;
    93     property Active: Boolean read GetActive write SetActive;
    9492    property Modified: Boolean read FModified write SetModified;
     93    property OnChange: TNotifyEvent read FOnChange write FOnChange;
    9594  end;
    9695
     
    10099    Name: string;
    101100    Description: TStringList;
    102     procedure InitProject(Project: TProject); virtual;
     101    procedure InitProject(var Project: TProject); virtual;
    103102    constructor Create; virtual;
    104103    destructor Destroy; override;
     
    111110  end;
    112111
    113 
    114 implementation
    115 
    116112resourcestring
    117113  SNewProject = 'New project';
    118114
     115implementation
     116
    119117{ TProjectTemplateList }
    120118
     
    126124{ TProjectTemplate }
    127125
    128 procedure TProjectTemplate.InitProject(Project: TProject);
    129 begin
    130   Project.Active := False;
    131   Project.Active := True;
     126procedure TProjectTemplate.InitProject(var Project: TProject);
     127begin
    132128  Project.FileName := SNewProject;
    133129end;
     
    319315{ TProject }
    320316
    321 function TProject.GetActive: Boolean;
    322 begin
    323   Result := FActive;
    324 end;
    325 
    326 procedure TProject.SetActive(AValue: Boolean);
    327 begin
    328   if FActive = AValue then Exit;
    329   FActive := AValue;
    330   if not FActive then Clear;
    331 end;
    332 
    333317procedure TProject.SetModified(AValue: Boolean);
    334318begin
  • trunk/IDE/UProjectTemplates.pas

    r51 r54  
    1414  TProjectTemplateConsoleApp = class(TProjectTemplate)
    1515    constructor Create; override;
    16     procedure InitProject(Project: TProject); override;
     16    procedure InitProject(var Project: TProject); override;
    1717  end;
    1818
     
    2121  TProjectTemplateGUIApp = class(TProjectTemplate)
    2222    constructor Create; override;
    23     procedure InitProject(Project: TProject); override;
     23    procedure InitProject(var Project: TProject); override;
    2424  end;
    2525
     
    2828  TProjectTemplatePackage = class(TProjectTemplate)
    2929    constructor Create; override;
    30     procedure InitProject(Project: TProject); override;
     30    procedure InitProject(var Project: TProject); override;
    3131  end;
    3232
     
    3535  TProjectTemplateUnit = class(TProjectTemplate)
    3636    constructor Create; override;
    37     procedure InitProject(Project: TProject); override;
     37    procedure InitProject(var Project: TProject); override;
    3838  end;
    3939
     
    4949end;
    5050
    51 procedure TProjectTemplateUnit.InitProject(Project: TProject);
     51procedure TProjectTemplateUnit.InitProject(var Project: TProject);
    5252var
    5353  NewFile: TProjectFile;
     
    7575end;
    7676
    77 procedure TProjectTemplatePackage.InitProject(Project: TProject);
     77procedure TProjectTemplatePackage.InitProject(var Project: TProject);
    7878var
    7979  NewFile: TProjectFile;
     
    100100end;
    101101
    102 procedure TProjectTemplateGUIApp.InitProject(Project: TProject);
     102procedure TProjectTemplateGUIApp.InitProject(var Project: TProject);
    103103var
    104104  NewFile: TProjectFile;
     
    131131end;
    132132
    133 procedure TProjectTemplateConsoleApp.InitProject(Project: TProject);
     133procedure TProjectTemplateConsoleApp.InitProject(var Project: TProject);
    134134var
    135135  NewFile: TProjectFile;
Note: See TracChangeset for help on using the changeset viewer.