PageRenderTime 40ms CodeModel.GetById 12ms app.highlight 23ms RepoModel.GetById 2ms app.codeStats 0ms

/ide/splash.pp

http://github.com/graemeg/lazarus
Pascal | 121 lines | 71 code | 19 blank | 31 comment | 0 complexity | f5cd080cd4f55d22fee7df01e688a355 MD5 | raw file
  1{
  2 /***************************************************************************
  3                               Splash.pp
  4                               ---------
  5
  6 ***************************************************************************/
  7
  8 ***************************************************************************
  9 *                                                                         *
 10 *   This source is free software; you can redistribute it and/or modify   *
 11 *   it under the terms of the GNU General Public License as published by  *
 12 *   the Free Software Foundation; either version 2 of the License, or     *
 13 *   (at your option) any later version.                                   *
 14 *                                                                         *
 15 *   This code is distributed in the hope that it will be useful, but      *
 16 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 17 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 18 *   General Public License for more details.                              *
 19 *                                                                         *
 20 *   A copy of the GNU General Public License is available on the World    *
 21 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 22 *   obtain it by writing to the Free Software Foundation,                 *
 23 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 24 *                                                                         *
 25 ***************************************************************************
 26}
 27unit Splash;
 28
 29{$mode objfpc}{$H+}
 30
 31interface
 32
 33uses
 34  Buttons,
 35  Classes,
 36  Controls,
 37  ExtCtrls,
 38  Forms,
 39  Graphics,
 40  LResources,
 41  SysUtils,
 42  LazConf;
 43
 44type
 45
 46  { TSplashForm }
 47
 48  TSplashForm = class(TForm)
 49    Image: TImage;
 50    procedure ApplicationOnIdle(Sender: TObject; var {%H-}Done: boolean);
 51    procedure ImagePaint(Sender: TObject);
 52  private
 53  protected
 54  public
 55    constructor Create(AOwner: TComponent); override;
 56    destructor Destroy; override;
 57  end;
 58
 59var
 60  SplashForm: TSplashForm;
 61
 62implementation
 63
 64{$R *.lfm}
 65{$R ../images/splash_logo.res}
 66
 67const
 68  VersionPos: TPoint = (X:0; Y:281);
 69  VersionStyle: TTextStyle =
 70    (
 71      Alignment  : taCenter;
 72      Layout     : tlCenter;
 73      SingleLine : True;
 74      Clipping   : True;
 75      ExpandTabs : False;
 76      ShowPrefix : False;
 77      Wordbreak  : False;
 78      Opaque     : False;
 79      SystemFont : False;
 80      RightToLeft: False;
 81      EndEllipsis: False;
 82    );
 83  VersionFontStyle: TFontStyles = [fsBold];
 84  VersionFontColor: TColor = clBlue;
 85
 86constructor TSplashForm.Create(AOwner: TComponent);
 87begin
 88  inherited Create(AOwner);
 89
 90  Image.Picture.LoadFromResourceName(hInstance, 'splash_logo', TPortableNetworkGraphic);
 91
 92  Application.AddOnIdleHandler(@ApplicationOnIdle);
 93end;
 94
 95destructor TSplashForm.Destroy;
 96begin
 97  Application.RemoveOnIdleHandler(@ApplicationOnIdle);
 98
 99  inherited Destroy;
100
101  SplashForm := nil;
102end;
103
104procedure TSplashForm.ApplicationOnIdle(Sender: TObject; var Done: boolean);
105begin
106  Hide;
107end;
108
109procedure TSplashForm.ImagePaint(Sender: TObject);
110var
111  ATextRect: TRect;
112begin
113  // GetLazarusVersionString is too long => use LazarusVersionStr
114  ATextRect.TopLeft := VersionPos;
115  ATextRect.BottomRight := Point(Image.Picture.Width, Image.Picture.Height);
116  Image.Canvas.Font.Style := VersionFontStyle;
117  Image.Canvas.Font.Color := VersionFontColor;
118  Image.Canvas.TextRect(ATextRect, VersionPos.X, VersionPos.Y, LazarusVersionStr, VersionStyle);
119end;
120
121end.