Changeset 15 for trunk/StudioCommon


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/StudioCommon
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioCommon/LDStudioCommon.lpk

    r14 r15  
    2828      </Item2>
    2929    </Files>
     30    <i18n>
     31      <EnableI18N Value="True"/>
     32      <OutDir Value="Languages"/>
     33      <EnableI18NForLFM Value="True"/>
     34    </i18n>
    3035    <Type Value="RunAndDesignTime"/>
    31     <RequiredPkgs Count="4">
     36    <RequiredPkgs Count="5">
    3237      <Item1>
    33         <PackageName Value="TemplateGenerics"/>
     38        <PackageName Value="Common"/>
    3439      </Item1>
    3540      <Item2>
    36         <PackageName Value="LCL"/>
     41        <PackageName Value="TemplateGenerics"/>
    3742      </Item2>
    3843      <Item3>
    39         <PackageName Value="ModularSystem"/>
     44        <PackageName Value="LCL"/>
    4045      </Item3>
    4146      <Item4>
     47        <PackageName Value="ModularSystem"/>
     48      </Item4>
     49      <Item5>
    4250        <PackageName Value="FCL"/>
    43       </Item4>
     51      </Item5>
    4452    </RequiredPkgs>
    4553    <UsageOptions>
  • trunk/StudioCommon/ULDStudioAPI.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, UModularSystem, ActnList, Menus, Forms, USource,
    9   SpecializedList;
     9  SpecializedList, URegistry;
    1010
    1111type
     
    1919  TUnregisterMainMenuItemEvent = procedure (MenuItem: TMenuItem) of object;
    2020  TDockFormEvent = procedure (Form: TForm; Target: TDockTarget) of object;
     21  TGetRegistryContextEvent = function: TRegistryContext of object;
     22  TRegisterFileTemplateEvent = procedure (Template: TFileTemplate) of object;
    2123
    2224  { TLDStudioAPI }
     
    2527  private
    2628    FOnDockForm: TDockFormEvent;
     29    FOnGetRegistryContext: TGetRegistryContextEvent;
    2730    FOnOpenFile: TOpenFileEvent;
    2831    FOnRegisterAction: TRegisterActionEvent;
     32    FOnRegisterFileTemplate: TRegisterFileTemplateEvent;
    2933    FOnRegisterFileType: TRegisterFileTypeEvent;
    3034    FOnRegisterForm: TRegisterFormEvent;
    3135    FOnRegisterMainMenuItem: TRegisterMainMenuItemEvent;
    3236    FOnUnregisterAction: TRegisterActionEvent;
     37    FOnUnregisterFileTemplate: TRegisterFileTemplateEvent;
    3338    FOnUnregisterFileType: TRegisterFileTypeEvent;
    3439    FOnUnregisterForm: TRegisterFormEvent;
     
    4247    procedure RegisterFileType(FileType: TSourceType);
    4348    procedure UnregisterFileType(FileType: TSourceType);
     49    procedure RegisterFileTemplate(Template: TFileTemplate);
     50    procedure UnregisterFileTemplate(Template: TFileTemplate);
    4451    procedure RegisterForm(Form: TForm);
    4552    procedure UnregisterForm(Form: TForm);
     
    5057    procedure UnregisterMainMenuItem(MenuItem: TMenuItem);
    5158    procedure DockForm(Form: TForm; Target: TDockTarget);
    52 
     59    function GetRegistryContext: TRegistryContext;
    5360  published
    5461    // API handling
     
    7178      read FOnUnregisterMainMenuItem write FOnUnregisterMainMenuItem;
    7279    property OnDockForm: TDockFormEvent read FOnDockForm write FOnDockForm;
     80    property OnGetRegistryContext: TGetRegistryContextEvent
     81      read FOnGetRegistryContext write FOnGetRegistryContext;
     82    property OnRegisterFileTemplate: TRegisterFileTemplateEvent
     83      read FOnRegisterFileTemplate write FOnRegisterFileTemplate;
     84    property OnUnregisterFileTemplate: TRegisterFileTemplateEvent
     85      read FOnUnregisterFileTemplate write FOnUnregisterFileTemplate;
    7386  end;
    7487
     
    110123  if Assigned(FOnUnregisterFileType) then
    111124    FOnUnregisterFileType(FileType);
     125end;
     126
     127procedure TLDStudioAPI.RegisterFileTemplate(Template: TFileTemplate);
     128begin
     129  if Assigned(FOnRegisterFileTemplate) then
     130    FOnRegisterFileTemplate(Template);
     131end;
     132
     133procedure TLDStudioAPI.UnregisterFileTemplate(Template: TFileTemplate);
     134begin
     135  if Assigned(FOnUnregisterFileTemplate) then
     136    FOnUnregisterFileTemplate(Template);
    112137end;
    113138
     
    155180end;
    156181
     182function TLDStudioAPI.GetRegistryContext: TRegistryContext;
     183begin
     184  if Assigned(FOnGetRegistryContext) then
     185    Result := FOnGetRegistryContext();
     186end;
     187
    157188end.
    158189
  • trunk/StudioCommon/USource.pas

    r8 r15  
    66
    77uses
    8   Classes, SysUtils, SpecializedList;
     8  Classes, SysUtils, SpecializedList, Forms;
    99
    1010type
     11
     12  { TSourceType }
     13
    1114  TSourceType = class
    1215    Extension: string;
    1316    Title: string;
     17    Form: TForm;
     18    constructor Create; virtual;
    1419  end;
     20
     21  TFileTypeClass = class of TSourceType;
    1522
    1623  { TFileTypes }
     
    2027  end;
    2128
     29  { TSource }
     30
    2231  TSource = class
    23     Name: string;
     32  private
     33    FName: string;
     34    procedure SetName(AValue: string);
     35  public
     36    Modified: Boolean;
     37    Form: TForm;
     38    property Name: string read FName write SetName;
    2439  end;
    2540
     
    2944    Items: TListObject; // TListObject<TSource>
    3045    Main: TSource;
     46  end;
     47
     48  { TFileTemplate }
     49
     50  TFileTemplate = class
     51  public
     52    Name: string;
     53    Description: TStringList;
     54    FileTypeClass: TSourceType;
     55    constructor Create; virtual;
     56    destructor Destroy; override;
     57    function Execute: TSource; virtual;
     58  end;
     59
     60  TFileTemplates = class(TListObject)
    3161  end;
    3262
     
    5484  TConvertorClass = class of TConvertor;
    5585
     86  { TSourceText }
     87
    5688  TSourceText = class(TSource)
    57     Content: string;
    58     InMemory: Boolean;
     89  private
     90  public
     91    Loaded: Boolean;
     92    Content: TStringList;
     93    constructor Create;
     94    destructor Destroy; override;
    5995  end;
     96
    6097
    6198
     
    64101resourcestring
    65102  SAllFiles = 'All files';
     103
     104{ TSourceType }
     105
     106constructor TSourceType.Create;
     107begin
     108  inherited;
     109end;
     110
     111procedure TSource.SetName(AValue: string);
     112begin
     113  if FName = AValue then Exit;
     114  FName := AValue;
     115  if Assigned(Form) then
     116    Form.Caption := ExtractFileName(FName);
     117end;
     118
     119
     120{ TFileTemplate }
     121
     122constructor TFileTemplate.Create;
     123begin
     124  Description := TStringList.Create;
     125end;
     126
     127destructor TFileTemplate.Destroy;
     128begin
     129  Description.Free;
     130  inherited Destroy;
     131end;
     132
     133function TFileTemplate.Execute: TSource;
     134begin
     135
     136end;
     137
    66138
    67139{ TFileTypes }
     
    97169end;
    98170
     171{ TSourceText }
     172
     173constructor TSourceText.Create;
     174begin
     175  Content := TStringList.Create;
     176end;
     177
     178destructor TSourceText.Destroy;
     179begin
     180  Content.Free;
     181  inherited Destroy;
     182end;
     183
    99184end.
    100185
Note: See TracChangeset for help on using the changeset viewer.