Ignore:
Timestamp:
Aug 6, 2012, 2:35:22 PM (12 years ago)
Author:
chronos
Message:
  • Added: Registration of new file templates for modules.
  • Added: Program stores last opened file list in registry.
Location:
trunk/StudioPackage/Forms
Files:
4 added
3 edited

Legend:

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

    r14 r15  
    11object FormMain: TFormMain
    2   Left = 150
     2  Left = 240
    33  Height = 520
    4   Top = 112
     4  Top = 108
    55  Width = 747
    66  Caption = 'LibreDevelop Studio'
     
    2727    Width = 747
    2828    Caption = 'ToolBar1'
     29    Images = DataModule1.ImageListMain
    2930    TabOrder = 1
    3031    object ToolButton1: TToolButton
    3132      Left = 1
    32       Hint = 'New project'
    3333      Top = 2
    34       Caption = 'New...'
    35       ImageIndex = 4
     34      Action = AFileNew
    3635    end
    3736    object ToolButton2: TToolButton
    3837      Left = 24
    39       Hint = 'Open project'
    4038      Top = 2
    41       Caption = 'Open...'
    42       ImageIndex = 8
     39      Action = AFileOpen
     40      DropdownMenu = PopupMenuRecentFiles
     41      Style = tbsDropDown
    4342    end
    4443    object ToolButton3: TToolButton
    45       Left = 47
    46       Hint = 'Save project'
     44      Left = 59
    4745      Top = 2
    48       Caption = 'Save'
    49       ImageIndex = 13
     46      Action = AFileSaveAs
    5047    end
    5148    object ToolButton4: TToolButton
    52       Left = 70
    53       Hint = 'Close project'
     49      Left = 82
    5450      Top = 2
    55       Caption = 'Close'
    56       ImageIndex = 3
     51      Action = AFileClose
    5752    end
    5853  end
     
    117112        Action = AFileOpen
    118113      end
    119       object MenuItem29: TMenuItem
    120         Action = AFileOpenRecent
     114      object MenuItemFileOpenRecent: TMenuItem
     115        Caption = 'Open recent'
     116        ImageIndex = 8
     117        OnClick = MenuItemFileOpenRecentClick
    121118      end
    122119      object MenuItem30: TMenuItem
     
    313310      Caption = 'Open recent'
    314311      ImageIndex = 8
     312      OnExecute = AFileOpenRecentExecute
    315313    end
    316314    object AFileSave: TAction
     
    318316      Caption = 'Save'
    319317      ImageIndex = 13
     318      OnExecute = AFileSaveExecute
    320319      ShortCut = 16467
    321320    end
     
    324323      Caption = 'Save as...'
    325324      ImageIndex = 13
     325      OnExecute = AFileSaveAsExecute
    326326      ShortCut = 24659
    327327    end
     
    387387    top = 272
    388388  end
     389  object LastOpenedList1: TLastOpenedList
     390    MaxCount = 10
     391    OnChange = LastOpenedList1Change
     392    left = 80
     393    top = 160
     394  end
     395  object PopupMenuRecentFiles: TPopupMenu
     396    Images = DataModule1.ImageListMain
     397    left = 259
     398    top = 69
     399  end
    389400end
  • trunk/StudioPackage/Forms/UFormMain.lrt

    r14 r15  
    11TFORMMAIN.CAPTION=LibreDevelop Studio
    22TFORMMAIN.TOOLBAR1.CAPTION=ToolBar1
    3 TFORMMAIN.TOOLBUTTON1.HINT=New project
    4 TFORMMAIN.TOOLBUTTON1.CAPTION=New...
    5 TFORMMAIN.TOOLBUTTON2.HINT=Open project
    6 TFORMMAIN.TOOLBUTTON2.CAPTION=Open...
    7 TFORMMAIN.TOOLBUTTON3.HINT=Save project
    8 TFORMMAIN.TOOLBUTTON3.CAPTION=Save
    9 TFORMMAIN.TOOLBUTTON4.HINT=Close project
    10 TFORMMAIN.TOOLBUTTON4.CAPTION=Close
    113TFORMMAIN.MENUITEM26.CAPTION=File
     4TFORMMAIN.MENUITEMFILEOPENRECENT.CAPTION=Open recent
    125TFORMMAIN.MENUITEM33.CAPTION=-
    136TFORMMAIN.MENUITEM2.CAPTION=Edit
  • trunk/StudioPackage/Forms/UFormMain.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ActnList, ComCtrls, ExtCtrls, UDataModule;
     9  ActnList, ComCtrls, ExtCtrls, ULastOpenedList, UCoolTranslator, UDataModule,
     10  URegistry;
    1011
    1112type
     
    4445    AClipboardCut: TAction;
    4546    ActionListMain: TActionList;
     47    LastOpenedList1: TLastOpenedList;
    4648    MainMenu: TMainMenu;
    4749    MenuItem15: TMenuItem;
     
    6062    MenuItem27: TMenuItem;
    6163    MenuItem28: TMenuItem;
    62     MenuItem29: TMenuItem;
     64    MenuItemFileOpenRecent: TMenuItem;
    6365    MenuItem30: TMenuItem;
    6466    MenuItem31: TMenuItem;
     
    8991    PageControlBottom: TPageControl;
    9092    PageControlCenter: TPageControl;
     93    PopupMenuRecentFiles: TPopupMenu;
    9194    SaveDialogFile: TSaveDialog;
    9295    Splitter1: TSplitter;
     
    102105    procedure AFileNewExecute(Sender: TObject);
    103106    procedure AFileOpenExecute(Sender: TObject);
     107    procedure AFileOpenRecentExecute(Sender: TObject);
     108    procedure AFileSaveAsExecute(Sender: TObject);
     109    procedure AFileSaveExecute(Sender: TObject);
    104110    procedure AViewModulesExecute(Sender: TObject);
    105111    procedure AViewSettingsExecute(Sender: TObject);
     
    108114    procedure FormDestroy(Sender: TObject);
    109115    procedure FormShow(Sender: TObject);
     116    procedure LastOpenedList1Change(Sender: TObject);
     117    procedure MenuItemFileOpenRecentClick(Sender: TObject);
    110118  private
    111119    procedure DockInit;
    112120  public
     121    procedure UpdateInterface;
    113122    procedure OpenedFileChange(Sender: TObject);
     123    procedure LoadFromRegistry(Context: TRegistryContext);
     124    procedure SaveToRegistry(Context: TRegistryContext);
    114125  end;
    115126
     
    117128  FormMain: TFormMain;
    118129
     130
    119131implementation
    120132
     
    122134
    123135uses
    124   UFormSourceCode, UFormSettings, UFormModuleList;
     136  UFormSourceCode, UFormSettings, UFormModuleList, UFormNewFile, USource;
    125137
    126138{ TFormMain }
     
    133145procedure TFormMain.AFileCloseExecute(Sender: TObject);
    134146begin
    135   DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected.FileName);
     147  DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected);
    136148end;
    137149
    138150procedure TFormMain.AFileNewExecute(Sender: TObject);
    139 begin
    140   DataModule1.OpenedFiles.NewFile;
     151var
     152  NewFile: TSource;
     153begin
     154  if FormNewFile.ShowModal = mrOk then
     155    if Assigned(FormNewFile.ListView1.Selected) then begin
     156      NewFile := TFileTemplate(FormNewFile.ListView1.Selected.Data).Execute;
     157      DataModule1.OpenedFiles.OpenFile(NewFile);
     158    end;
    141159end;
    142160
     
    145163  OpenDialogFile.Filter := DataModule1.FileTypes.GetDialogFilter;
    146164  if OpenDialogFile.Execute then begin
    147     DataModule1.OpenedFiles.OpenFile(OpenDialogFile.FileName);
    148   end;
     165    LastOpenedList1.AddItem(OpenDialogFile.FileName);
     166    DataModule1.OpenedFiles.OpenFileName(OpenDialogFile.FileName);
     167  end;
     168end;
     169
     170procedure TFormMain.AFileOpenRecentExecute(Sender: TObject);
     171begin
     172  if Sender is TMenuItem then
     173    DataModule1.OpenedFiles.OpenFileName(TMenuItem(Sender).Caption);
     174end;
     175
     176procedure TFormMain.AFileSaveAsExecute(Sender: TObject);
     177begin
     178  SaveDialogFile.FileName := DataModule1.OpenedFiles.Selected.Name;
     179  if SaveDialogFile.Execute then begin
     180    LastOpenedList1.AddItem(SaveDialogFile.FileName);
     181    DataModule1.OpenedFiles.Selected.Name := SaveDialogFile.FileName;
     182  end;
     183end;
     184
     185procedure TFormMain.AFileSaveExecute(Sender: TObject);
     186begin
     187
    149188end;
    150189
     
    177216begin
    178217  DockInit;
     218  UpdateInterface;
     219end;
     220
     221procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     222begin
     223  LastOpenedList1.LoadToMenuItem(PopupMenuRecentFiles.Items, AFileOpenRecentExecute);
     224  LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, AFileOpenRecentExecute);
     225end;
     226
     227procedure TFormMain.MenuItemFileOpenRecentClick(Sender: TObject);
     228begin
     229
    179230end;
    180231
     
    186237}end;
    187238
     239procedure TFormMain.UpdateInterface;
     240begin
     241  AFileClose.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     242  AFileSave.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     243  AFileSaveAs.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     244end;
     245
    188246procedure TFormMain.OpenedFileChange(Sender: TObject);
    189247var
     
    193251  with DataModule1.OpenedFiles do begin
    194252    for I := 0 to Count - 1 do
    195     with TOpenedFile(Items[I]) do begin
     253    with TSource(Items[I]) do begin
    196254      if not Assigned(Form.Parent) then begin
    197255        NewTabSheet := PageControlCenter.AddTabSheet;
    198         NewTabSheet.Caption := ExtractFileName(FileName);
     256        NewTabSheet.Caption := ExtractFileName(Name);
    199257        //NewTabSheet.PopupMenu := ;
    200258        Form.ManualDock(NewTabSheet, nil, alClient);
     
    206264end;
    207265
     266procedure TFormMain.LoadFromRegistry(Context: TRegistryContext);
     267begin
     268  LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFiles');
     269end;
     270
     271procedure TFormMain.SaveToRegistry(Context: TRegistryContext);
     272begin
     273  LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFiles');
     274end;
     275
    208276end.
    209277
Note: See TracChangeset for help on using the changeset viewer.