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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.