Changeset 28


Ignore:
Timestamp:
Dec 22, 2016, 6:01:41 PM (8 years ago)
Author:
chronos
Message:
  • Added: Remember forms dimensions.
  • Added: Remember recent opened files.
Location:
trunk
Files:
102 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r26 r28  
    99  Menu = MainMenu1
    1010  OnActivate = FormActivate
     11  OnClose = FormClose
    1112  OnCreate = FormCreate
    1213  OnDestroy = FormDestroy
     
    114115    top = 206
    115116  end
     117  object LastOpenedList1: TLastOpenedList
     118    MaxCount = 10
     119    OnChange = LastOpenedList1Change
     120    left = 292
     121    top = 112
     122  end
    116123end
  • trunk/Forms/UFormMain.pas

    r27 r28  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ExtCtrls, ComCtrls, types, LCLType;
     9  ExtCtrls, ComCtrls, types, LCLType, ULastOpenedList, URegistry, Registry;
    1010
    1111type
     
    1414
    1515  TFormMain = class(TForm)
     16    LastOpenedList1: TLastOpenedList;
    1617    MainMenu1: TMainMenu;
    1718    MenuItem1: TMenuItem;
     
    4041    Timer1: TTimer;
    4142    procedure FormActivate(Sender: TObject);
     43    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4244    procedure FormCreate(Sender: TObject);
    4345    procedure FormDestroy(Sender: TObject);
    4446    procedure FormShow(Sender: TObject);
     47    procedure LastOpenedList1Change(Sender: TObject);
    4548    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    4649      Shift: TShiftState; X, Y: Integer);
     
    6467    MousePos: TPoint;
    6568    Activated: Boolean;
     69    procedure OpenRecentClick(Sender: TObject);
    6670  public
    6771    procedure EraseBackground(DC: HDC); override;
     
    9498end;
    9599
     100procedure TFormMain.OpenRecentClick(Sender: TObject);
     101begin
     102  Core.ProjectOpen(TMenuItem(Sender).Caption);
     103end;
     104
    96105procedure TFormMain.EraseBackground(DC: HDC);
    97106begin
     
    120129    TempBitmap.SetSize(View.SrcRect.Right - View.SrcRect.Left,
    121130      View.SrcRect.Bottom - View.SrcRect.Top);
    122     //TempBitmap.BeginUpdate(True);
     131    TempBitmap.BeginUpdate(True);
    123132    TempBitmap.Canvas.Brush.Color := clBlack;
    124133    TempBitmap.Canvas.FillRect(0, 0, TempBitmap.Width, TempBitmap.Height);
    125134    View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
    126     //Bitmap.PaintToCanvas(TempBitmap.Canvas, View.SrcRect);
    127     Bitmap.PaintToBitmap(TempBitmap, View.SrcRect);
    128     //TempBitmap.EndUpdate(False);
     135    Bitmap.PaintToCanvas(TempBitmap.Canvas, View.SrcRect);
     136    //Bitmap.PaintToBitmap(TempBitmap, View.SrcRect);
     137    TempBitmap.EndUpdate(False);
    129138    PaintBox1.Canvas.StretchDraw(View.DestRect, TempBitmap);
    130139    //PaintBox1.Canvas.Draw(0, 0, TempBitmap);
     
    147156end;
    148157
     158procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     159begin
     160  Core.PersistentForm1.Save(Self);
     161  LastOpenedList1.SaveToRegistry(RegContext(HKEY(Core.ApplicationInfo1.RegistryRoot),
     162    Core.ApplicationInfo1.RegistryKey + '\RecentFiles'));
     163end;
     164
    149165procedure TFormMain.FormDestroy(Sender: TObject);
    150166begin
     
    154170procedure TFormMain.FormShow(Sender: TObject);
    155171begin
     172  Core.PersistentForm1.Load(Self);
     173  LastOpenedList1.LoadFromRegistry(RegContext(HKEY(Core.ApplicationInfo1.RegistryRoot),
     174    Core.ApplicationInfo1.RegistryKey + '\RecentFiles'));
     175end;
     176
     177procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     178begin
     179  LastOpenedList1.LoadToMenuItem(MenuItemRecentFiles, OpenRecentClick);
    156180end;
    157181
  • trunk/Forms/UFormNew.lfm

    r26 r28  
    77  ClientHeight = 300
    88  ClientWidth = 497
     9  OnClose = FormClose
    910  OnShow = FormShow
    1011  LCLVersion = '1.6.2.0'
  • trunk/Forms/UFormNew.pas

    r26 r28  
    2626    SpinEditWidth: TSpinEdit;
    2727    SpinEditHeight: TSpinEdit;
     28    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2829    procedure FormShow(Sender: TObject);
    2930    procedure SpinEditWidthChange(Sender: TObject);
     
    4041
    4142{$R *.lfm}
     43
     44uses
     45  UCore;
    4246
    4347{ TFormNew }
     
    5761  I: Integer;
    5862begin
     63  Core.PersistentForm1.Load(Self);
     64
    5965  ComboBoxColorFormat.Clear;
    6066  for I := 0 to ColorFormatManager.FormatCount - 1 do begin
     
    7177end;
    7278
     79procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     80begin
     81  Core.PersistentForm1.Save(Self);
     82end;
     83
    7384end.
    7485
  • trunk/LibrePaint.lpi

    r26 r28  
    6666      </local>
    6767    </RunParams>
    68     <RequiredPackages Count="2">
     68    <RequiredPackages Count="4">
    6969      <Item1>
     70        <PackageName Value="Common"/>
     71        <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/>
     72      </Item1>
     73      <Item2>
     74        <PackageName Value="TemplateGenerics"/>
     75        <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/>
     76      </Item2>
     77      <Item3>
    7078        <PackageName Value="FastGraphics"/>
    7179        <DefaultFilename Value="Packages/FastGraphics/FastGraphics.lpk" Prefer="True"/>
    72       </Item1>
    73       <Item2>
     80      </Item3>
     81      <Item4>
    7482        <PackageName Value="LCL"/>
    75       </Item2>
     83      </Item4>
    7684    </RequiredPackages>
    7785    <Units Count="5">
  • trunk/LibrePaint.lpr

    r26 r28  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   SysUtils, Forms, UCore, UProject, UFormNew, UFormMain;
     10  SysUtils, Forms, UCore, UProject, TemplateGenerics, Common, UFormNew,
     11  UFormMain;
    1112
    1213{$R *.res}
  • trunk/Packages/FastGraphics/ColorFormats/UColorRGB8.pas

    r27 r28  
    9292function TPixmapRGB8.RGB8ToColor(Value: TColorRGB8): TColor;
    9393begin
    94   Result := (Value.B shl 16) or (Value.G shl 8) or (Value.R shl 0);
     94  Result := (Value.R shl 16) or (Value.G shl 8) or (Value.B shl 0);
    9595end;
    9696
  • trunk/UCore.lfm

    r15 r28  
    105105    top = 208
    106106  end
     107  object PersistentForm1: TPersistentForm
     108    MinVisiblePart = 50
     109    EntireVisible = False
     110    left = 64
     111    top = 48
     112  end
     113  object ApplicationInfo1: TApplicationInfo
     114    Identification = 1
     115    VersionMajor = 1
     116    VersionMinor = 0
     117    VersionBugFix = 0
     118    VersionSuffix = 'alfa'
     119    CompanyName = 'Chronosoft'
     120    HomePage = 'http://svn.zdechov.net/svn/LibrePaint'
     121    AuthorsName = 'Chronos'
     122    EmailContact = 'robie@centrum.cz'
     123    AppName = 'LibrePaint'
     124    ReleaseDate = 42726
     125    RegistryKey = '\Software\Chronosoft\LibrePaint'
     126    RegistryRoot = rrKeyCurrentUser
     127    License = 'CC0'
     128    left = 62
     129    top = 133
     130  end
    107131end
  • trunk/UCore.pas

    r27 r28  
    66
    77uses
    8   Classes, SysUtils, FileUtil, ActnList, UProject, UFGraphics, Controls, Graphics,
    9   ExtDlgs, ExtCtrls;
     8  Classes, SysUtils, FileUtil, ActnList, UProject, UFGraphics, UPersistentForm,
     9  Controls, Graphics, ExtDlgs, ExtCtrls, UREgistry, UApplicationInfo, Registry;
    1010
    1111const
     
    2929    AFileClose: TAction;
    3030    AFileOpen: TAction;
     31    ApplicationInfo1: TApplicationInfo;
    3132    AZoomNormal: TAction;
    3233    AZoomAll: TAction;
     
    3940    ImageList1: TImageList;
    4041    OpenPictureDialog1: TOpenPictureDialog;
     42    PersistentForm1: TPersistentForm;
    4143    SavePictureDialog1: TSavePictureDialog;
    4244    procedure AExitExecute(Sender: TObject);
     
    5961    procedure DataModuleDestroy(Sender: TObject);
    6062  private
    61     { private declarations }
    6263  public
    6364    Project: TProject;
     65    procedure ProjectOpen(FileName: string);
    6466    procedure Init;
    6567  end;
     
    9496end;
    9597
     98procedure TCore.ProjectOpen(FileName: string);
     99var
     100  Image: TImage;
     101begin
     102  FormMain.LastOpenedList1.AddItem(FileName);
     103  Image := TImage.Create(nil);
     104  Image.Picture.LoadFromFile(FileName);
     105  Image.Picture.Bitmap.BeginUpdate(True);
     106  Project.Bitmap.Size := Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
     107  Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
     108  Image.Picture.Bitmap.EndUpdate;
     109  Image.Free;
     110  AZoomAll.Execute;
     111  FormMain.Redraw;
     112  Project.FileName := FileName;
     113end;
     114
    96115procedure TCore.Init;
    97116begin
     117  PersistentForm1.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),
     118    ApplicationInfo1.RegistryKey);
     119
    98120  // Set default
    99121  Project.Bitmap.ColorFormat := ColorFormatManager.Formats[0];
     
    162184
    163185procedure TCore.AFileOpenExecute(Sender: TObject);
    164 var
    165   Image: TImage;
    166186begin
    167187  if OpenPictureDialog1.Execute then begin
    168     Image := TImage.Create(nil);
    169     Image.Picture.LoadFromFile(OpenPictureDialog1.FileName);
    170     Image.Picture.Bitmap.BeginUpdate(True);
    171     Project.Bitmap.Size := Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
    172     Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
    173     Image.Picture.Bitmap.EndUpdate;
    174     Image.Free;
    175     AZoomAll.Execute;
    176     FormMain.Redraw;
    177     Project.FileName := OpenPictureDialog1.FileName;
     188    ProjectOpen(OpenPictureDialog1.FileName);
    178189  end;
    179190end;
     
    184195  if SavePictureDialog1.Execute then begin
    185196    Project.FileName := SavePictureDialog1.FileName;
     197    FormMain.LastOpenedList1.AddItem(SavePictureDialog1.FileName);
    186198    AFileSave.Execute;
    187199  end;
     
    194206  if Project.FileName = '' then AFileSaveAs.Execute
    195207  else begin
     208    FormMain.LastOpenedList1.AddItem(SavePictureDialog1.FileName);
    196209    Image := TImage.Create(nil);
    197210    Image.Picture.Bitmap.SetSize(Project.Bitmap.Size.X, Project.Bitmap.Size.Y);
Note: See TracChangeset for help on using the changeset viewer.