You've already forked lazarus-ccr
First commit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3185 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
616
components/poweredby/aboutpoweredbyunit.pas
Normal file
616
components/poweredby/aboutpoweredbyunit.pas
Normal file
@@ -0,0 +1,616 @@
|
||||
{ TAboutPoweredby and TAboutBox Component License
|
||||
|
||||
Copyright (C) 2014 Gordon Bamber minesadorada@charcodelvalle.com
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
}
|
||||
unit AboutPoweredbyunit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Controls, Dialogs, Forms, Graphics, LResources, SysUtils,
|
||||
ExtCtrls, StdCtrls, StrUtils,Buttons,PropEdits;
|
||||
const
|
||||
C_DEFAULTLICENSEFORMWIDTH = 500;
|
||||
C_DEFAULTLICENSEFORMWIDTH_LINUX = C_DEFAULTLICENSEFORMWIDTH + 100;
|
||||
C_DEFAULTLICENSEFORMHEIGHT = 400;
|
||||
C_DEFAULTLICENSEFORMHEIGHT_LINUX = C_DEFAULTLICENSEFORMHEIGHT + 50;
|
||||
|
||||
type
|
||||
TLicenseType = (abNone, abGPL, abLGPL, abMIT, abModifiedGPL, abProprietry);
|
||||
|
||||
TAboutbox = class(TComponent)
|
||||
private
|
||||
{ Private declarations }
|
||||
fDialog: TForm;
|
||||
fBackgroundbitmap: TBitMap;
|
||||
fBackgroundResourceName:String;
|
||||
fDescription: TStrings;
|
||||
fDialogTitle, fVersion, fAuthorname, fAuthorEmail, fOrganisation,
|
||||
fComponentName: string;
|
||||
fDialogHeight, fDialogWidth: integer;
|
||||
fStretchBackground: boolean;
|
||||
fFont: TFont;
|
||||
fColor: TColor;
|
||||
fLicenseType: TLicenseType;
|
||||
procedure SetBackgroundBitmap(const AValue: TBitMap);
|
||||
procedure SetDescriptionStrings(const AValue: TStrings);
|
||||
procedure SetFont(const AValue: TFont);
|
||||
procedure ShowLicense(Sender: TObject);
|
||||
procedure SetDialogTitle(Const AValue:String);
|
||||
protected
|
||||
{ Protected declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
procedure ShowDialog;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
{ Published declarations }
|
||||
// Set these properties in your component Constructor method
|
||||
property BackGround: TBitMap read fBackgroundbitmap write SetBackgroundBitmap;
|
||||
property BackgroundResourceName:String read fBackgroundResourceName write fBackgroundResourceName;
|
||||
property Description: TStrings read fDescription write SetDescriptionStrings;
|
||||
property Title: string read fDialogTitle write SetDialogTitle;
|
||||
property Height: integer read fDialogHeight write fDialogHeight;
|
||||
property Width: integer read fDialogWidth write fDialogWidth;
|
||||
property Font: TFont read fFont write SetFont;
|
||||
property BackGroundColor: TColor read fColor write fColor;
|
||||
property StretchBackground: boolean read fStretchBackground
|
||||
write fStretchBackground default False;
|
||||
property Version: string read fVersion write fVersion;
|
||||
property Authorname: string read fAuthorname write fAuthorname;
|
||||
property Organisation: string read fOrganisation write fOrganisation;
|
||||
property AuthorEmail: string read fAuthorEmail write fAuthorEmail;
|
||||
property ComponentName: string read fComponentName write fComponentName;
|
||||
property LicenseType: TLicenseType read fLicenseType write fLicenseType;
|
||||
end;
|
||||
|
||||
TAboutPoweredBy = class(TComponent)
|
||||
private
|
||||
{ Private declarations }
|
||||
fAboutBox: tAboutBox;
|
||||
procedure SetMyComponentName(Const Avalue:String);
|
||||
procedure SetAboutBoxWidth(Const AValue:Integer);
|
||||
procedure SetAboutBoxHeight(Const AValue:Integer);
|
||||
procedure SetAboutBoxDescription(Const AValue:String);
|
||||
procedure SetAboutBoxFontName(Const AValue:String);
|
||||
procedure SetAboutBoxFontSize(Const AValue:Integer);
|
||||
procedure SetAboutBoxBitmap(Const AValue:TBitmap);
|
||||
procedure SetAboutBoxBackgroundColor(Const AValue:TColor);
|
||||
procedure SetAboutBoxTitle(Const AValue:String);
|
||||
|
||||
procedure SetAboutBoxVersion(Const AValue:String);
|
||||
procedure SetAboutBoxAuthorname(Const AValue:String);
|
||||
procedure SetAboutBoxOrganisation(Const AValue:String);
|
||||
procedure SetAboutBoxAuthorEmail(Const AValue:String);
|
||||
procedure SetAboutBoxBackgroundResourceName(Const AValue:String);
|
||||
procedure SetAboutBoxLicenseType(Const AValue:String);
|
||||
procedure SetAboutBoxStretchBackgroundImage(Const AValue:Boolean);
|
||||
protected
|
||||
{ Protected declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override; // Constructor must be public
|
||||
destructor Destroy; override; // Destructor must be public
|
||||
|
||||
// Set these (hidden) properties in your inherited component's Create procedure
|
||||
property AboutBoxComponentName:String write SetMyComponentName;
|
||||
property AboutBoxWidth:Integer write SetAboutBoxWidth;
|
||||
property AboutBoxHeight:Integer write SetAboutBoxHeight;
|
||||
property AboutBoxDescription:String write SetAboutBoxDescription;
|
||||
property AboutBoxFontName:String write SetAboutBoxFontName;
|
||||
property AboutBoxFontSize:Integer write SetAboutBoxFontSize;
|
||||
property AboutBoxBackgroundColor:TColor write SetAboutBoxBackgroundColor;
|
||||
property AboutBoxTitle:String write SetAboutBoxTitle;
|
||||
|
||||
property AboutBoxVersion:String write SetAboutBoxVersion;
|
||||
property AboutBoxAuthorname:String write SetAboutBoxAuthorname;
|
||||
property AboutBoxOrganisation:String write SetAboutBoxOrganisation;
|
||||
property AboutBoxAuthorEmail:String write SetAboutBoxAuthorEmail;
|
||||
property AboutBoxLicenseType:String write SetAboutBoxLicenseType;
|
||||
property AboutBoxBackgroundResourceName:String write SetAboutBoxBackgroundResourceName;
|
||||
property AboutBoxStretchBackgroundImage:Boolean write SetAboutBoxStretchBackgroundImage;
|
||||
published
|
||||
// The clickable 'About' property will automaticcally appear in any component
|
||||
// descended from TAboutPoweredby
|
||||
|
||||
// About this component...
|
||||
property About: tAboutBox read fAboutBox write fAboutBox;
|
||||
end;
|
||||
|
||||
// Declaration for the 'About' property editor
|
||||
TAboutPropertyEditor = class(TClassPropertyEditor)
|
||||
public
|
||||
procedure Edit; override;
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
{For i8n if required}
|
||||
resourcestring
|
||||
rs_Componentname='Component name';
|
||||
rs_About='About';
|
||||
rs_License='License';
|
||||
rs_By='By';
|
||||
rs_For='For';
|
||||
rs_DatafileMissing='Resource datafile license.lrs is missing';
|
||||
rs_LicenseTextError='There is something wrong with the Licence text';
|
||||
rs_AboutBoxError = 'Subcomponent TAboutBox Error';
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{ TABoutBox}
|
||||
|
||||
constructor TAboutbox.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fBackgroundbitmap := TBitMap.Create;
|
||||
fDescription := TStringList.Create;
|
||||
fFont := TFont.Create;
|
||||
fColor := clDefault;
|
||||
fLicenseType := abNone;
|
||||
fComponentName:=rs_Componentname;
|
||||
fDialogTitle:=rs_About + ' ' + fComponentName;
|
||||
|
||||
fDialogWidth:=320;
|
||||
fDialogHeight:=280;
|
||||
fVersion:='1.0.0.0';
|
||||
fLicenseType:=abNone;
|
||||
end;
|
||||
|
||||
destructor TAboutbox.Destroy;
|
||||
begin
|
||||
FreeAndNil(fFont);
|
||||
FreeAndNil(fDescription);
|
||||
FreeAndNil(fBackgroundbitmap);
|
||||
inherited Destroy;
|
||||
end;
|
||||
procedure TAboutbox.SetDialogTitle(Const AValue:String);
|
||||
begin
|
||||
fDialogTitle:=rs_About + ' ' + Avalue;
|
||||
end;
|
||||
|
||||
procedure TAboutbox.ShowDialog;
|
||||
var
|
||||
OKbutton, LicenseButton: TBitBtn;
|
||||
lbl_Description: TLabel;
|
||||
img_BackGround: TImage;
|
||||
sz: string;
|
||||
iCount: integer;
|
||||
r:TLResource;
|
||||
begin
|
||||
fDialog := TForm.CreateNew(nil);
|
||||
try //.. finally FreeAndNil everything
|
||||
with fDialog do
|
||||
begin
|
||||
// Set Dialog properties
|
||||
position := poScreenCenter;
|
||||
borderstyle := bsToolWindow;
|
||||
Caption := fDialogTitle;
|
||||
formstyle := fsSystemStayOnTop;
|
||||
color := fColor;
|
||||
font := fFont;
|
||||
if (fDialogHeight > 0) then
|
||||
Height := fDialogHeight
|
||||
else
|
||||
Height := 240;
|
||||
if (fDialogWidth > 0) then
|
||||
Width := fDialogWidth
|
||||
else
|
||||
Width := 320;
|
||||
|
||||
// Create a background image
|
||||
img_BackGround := Timage.Create(fDialog);
|
||||
with img_BackGround do
|
||||
// Set img_BackGround properties
|
||||
begin
|
||||
Align := alClient;
|
||||
Stretch := fStretchBackground;
|
||||
// Bitmap assigned?
|
||||
if Assigned(fBackgroundbitmap) then
|
||||
Picture.Assign(fBackgroundbitmap);
|
||||
// Resource file?
|
||||
r := LazarusResources.Find(fBackgroundResourceName);
|
||||
if r <> nil then
|
||||
img_BackGround.Picture.LoadFromLazarusResource(fBackgroundResourceName);
|
||||
SendToBack;
|
||||
parent := fDialog;
|
||||
end;
|
||||
|
||||
// Create a BitBtn button
|
||||
okbutton := TBitBtn.Create(fDialog);
|
||||
// Set BitBtn properties
|
||||
with okButton do
|
||||
begin
|
||||
Kind := bkClose;
|
||||
left := (fDialog.Width div 2) - Width div 2;
|
||||
top := fDialog.Height - Height - 10;
|
||||
ParentFont:=False;
|
||||
parent := fDialog;
|
||||
end;
|
||||
|
||||
// Create a License Button
|
||||
LicenseButton := TBitBtn.Create(fDialog);
|
||||
if (fLicenseType <> abNone) then
|
||||
// Put it on the right
|
||||
begin
|
||||
LicenseButton.Top := OKButton.Top;
|
||||
LicenseButton.Caption := rs_License + '...';
|
||||
LicenseButton.left := Width - LicenseButton.Width - 10;
|
||||
LicenseButton.OnClick := @ShowLicense;
|
||||
LicenseButton.ParentFont:=False;
|
||||
LicenseButton.Parent := fDialog;
|
||||
end;
|
||||
|
||||
|
||||
// Create a label control
|
||||
lbl_Description := Tlabel.Create(fDialog);
|
||||
// Set label properties
|
||||
with lbl_Description do
|
||||
begin
|
||||
left := 8;
|
||||
Top := 30;
|
||||
Width := fDialog.Width - 8;
|
||||
Height := fDialog.Height - 30;
|
||||
Autosize := False;
|
||||
ParentFont := True;
|
||||
Alignment := taCenter;
|
||||
end;
|
||||
|
||||
// Build up Label text
|
||||
sz := '';
|
||||
// Component name
|
||||
if fComponentName <> '' then
|
||||
sz += fComponentName + LineEnding;
|
||||
// Author name (+Email)
|
||||
if fAuthorname <> '' then
|
||||
sz += rs_By + ': ' + fAuthorname + LineEnding;
|
||||
if fAuthorEmail <> '' then
|
||||
sz += ' (' + fAuthorEmail + ')' + LineEnding
|
||||
else
|
||||
sz += LineEnding;
|
||||
|
||||
sz += LineEnding;
|
||||
|
||||
// Version
|
||||
if fVersion <> '' then
|
||||
sz += 'Version: ' + fVersion + LineEnding;
|
||||
// License
|
||||
case fLicenseType of
|
||||
abGPL: sz += rs_License + ': GPL' + LineEnding;
|
||||
abLGPL: sz += rs_License + ': LGPL' + LineEnding;
|
||||
abMIT: sz += rs_License + ': M.I.T.' + LineEnding;
|
||||
abModifiedGPL: sz += rs_License + ': Modified GPL' + LineEnding;
|
||||
abProprietry: sz += rs_License + ': Proprietry' + LineEnding;
|
||||
end;
|
||||
if fOrganisation <> '' then
|
||||
sz += rs_For + ': ' + fOrganisation + LineEnding;
|
||||
if fDescription.Count > 0 then
|
||||
begin
|
||||
sz += LineEnding;
|
||||
for iCount := 1 to fDescription.Count do
|
||||
sz += fDescription[iCount - 1] + LineEnding;
|
||||
end;
|
||||
|
||||
lbl_Description.Caption := sz;
|
||||
lbl_Description.parent := fDialog;
|
||||
// Display the dialog modally
|
||||
ShowModal;
|
||||
end;
|
||||
finally
|
||||
// Free all resources
|
||||
FreeAndNil(img_BackGround);
|
||||
FreeAndNil(lbl_Description);
|
||||
FreeAndNil(LicenseButton);
|
||||
FreeAndNil(okbutton);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAboutbox.ShowLicense(Sender: TObject);
|
||||
// Triggered by License button Click
|
||||
var
|
||||
sLicenseString: string;
|
||||
theList: TStringList;
|
||||
f: integer;
|
||||
LicenceForm: TForm;
|
||||
lblText: TLabel;
|
||||
closebuttton: TBitBtn;
|
||||
r: TLResource;
|
||||
szLicenseFile: string;
|
||||
begin
|
||||
// Quit early?
|
||||
if fLicenseType = abNone then
|
||||
Exit;
|
||||
|
||||
// Set to resource name in license.lrs
|
||||
case fLicenseType of
|
||||
abNone: szLicenseFile := '';
|
||||
abGPL: szLicenseFile := 'gpl.txt';
|
||||
abLGPL: szLicenseFile := 'lgpl.txt';
|
||||
abMIT: szLicenseFile := 'mit.txt';
|
||||
abModifiedgpl: szLicenseFile := 'modifiedgpl.txt';
|
||||
end;
|
||||
|
||||
|
||||
// Use a string list to split the text file into lines
|
||||
theList := TStringList.Create;
|
||||
// Create a window, label and close button on-the-fly
|
||||
LicenceForm := TForm.Create(nil);
|
||||
lblText := TLabel.Create(LicenceForm);
|
||||
closebuttton := TBitBtn.Create(LicenceForm);
|
||||
// Load up the text into variable 'sLicenseString'
|
||||
sLicenseString := LineEnding + LineEnding + fComponentName + LineEnding;
|
||||
try
|
||||
try
|
||||
begin
|
||||
// Load license text from resource string
|
||||
r := LazarusResources.Find(szLicenseFile);
|
||||
if r = nil then
|
||||
raise Exception.Create(rs_DatafileMissing);
|
||||
thelist.Add(r.Value);
|
||||
for f := 0 to TheList.Count - 1 do
|
||||
sLicenseString += TheList[f] + LineEnding;
|
||||
end;
|
||||
except
|
||||
On e: Exception do
|
||||
MessageDlg(rs_AboutBoxError,
|
||||
rs_LicenseTextError, mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
// Replace boilerplate text if possible
|
||||
sLicenseString := AnsiReplaceText(sLicenseString, '<year>',
|
||||
{$I %DATE%}
|
||||
);
|
||||
sLicenseString := AnsiReplaceText(sLicenseString, '<name of author>', fAuthorname);
|
||||
sLicenseString := AnsiReplaceText(sLicenseString, '<contact>',
|
||||
'(' + fAuthorEmail + ')');
|
||||
sLicenseString := AnsiReplaceText(sLicenseString, '<copyright holders>',
|
||||
fOrganisation);
|
||||
|
||||
// Make up the form window and controls
|
||||
with LicenceForm do
|
||||
begin
|
||||
// Form
|
||||
{$IFDEF WINDOWS}
|
||||
// More compact GUI?
|
||||
Width := C_DEFAULTLICENSEFORMWIDTH;
|
||||
Height := C_DEFAULTLICENSEFORMHEIGHT;
|
||||
{$ELSE WINDOWS}
|
||||
Width := C_DEFAULTLICENSEFORMWIDTH_LINUX;
|
||||
Height := C_DEFAULTLICENSEFORMHEIGHT_LINUX;
|
||||
{$ENDIF}
|
||||
// autosize:=true;
|
||||
// If you enable autosize, the button placement goes awry!
|
||||
|
||||
// The Modified GPL has an extra clause
|
||||
if (szLicenseFile = 'modifiedgpl.txt') or
|
||||
(Pos('As a special exception', sLicenseString) > 0) then
|
||||
Height := Height + 100;
|
||||
position := poScreenCenter;
|
||||
borderstyle := bsToolWindow;
|
||||
Caption := fComponentName + ': Licensing';
|
||||
formstyle := fsSystemStayOnTop;
|
||||
|
||||
// Label
|
||||
lblText.Align := alClient;
|
||||
lblText.Alignment := taCenter;
|
||||
lblText.Caption := sLicenseString;
|
||||
lblText.Parent := LicenceForm;
|
||||
|
||||
// Close Button
|
||||
closebuttton.Kind := bkClose;
|
||||
closebuttton.left := (Width div 2) - closebuttton.Width div 2;
|
||||
closebuttton.top := Height - closebuttton.Height - 10;
|
||||
closebuttton.parent := LicenceForm;
|
||||
// Show modally over the existing modal form
|
||||
PopupParent := TForm(Sender);
|
||||
ShowModal;
|
||||
end;
|
||||
finally
|
||||
// Free up all component created resources from memory
|
||||
FreeAndNil(theList);
|
||||
FreeAndNil(lblText);
|
||||
FreeAndNil(closebuttton);
|
||||
FreeAndNil(LicenceForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAboutbox.SetBackgroundBitmap(const AValue: TBitMap);
|
||||
begin
|
||||
if Assigned(AValue) then
|
||||
fBackgroundbitmap.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TAboutbox.SetDescriptionStrings(const AValue: TStrings);
|
||||
begin
|
||||
if Assigned(AValue) then
|
||||
fDescription.Assign(Avalue);
|
||||
end;
|
||||
|
||||
procedure TAboutbox.SetFont(const AValue: TFont);
|
||||
begin
|
||||
if Assigned(AValue) then
|
||||
fFont.Assign(AValue);
|
||||
end;
|
||||
|
||||
{ TAboutPoweredby }
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterPropertyEditor(TypeInfo(TAboutbox),
|
||||
TAboutPoweredby, 'About', TAboutPropertyEditor);
|
||||
end;
|
||||
|
||||
procedure TAboutPropertyEditor.Edit;
|
||||
// Communicate with the component properties
|
||||
Var
|
||||
AAboutBox:TAboutBox;
|
||||
begin
|
||||
AAboutBox:=TAboutBox(GetObjectValue(TAboutBox));
|
||||
AABoutBox.ShowDialog;
|
||||
end;
|
||||
|
||||
function TAboutPropertyEditor.GetAttributes: TPropertyAttributes;
|
||||
// Show the ellipsis
|
||||
begin
|
||||
Result := [paDialog, paReadOnly];
|
||||
end;
|
||||
|
||||
// Sets for AboutBox dialog properties
|
||||
procedure TAboutPoweredby.SetMyComponentName(Const Avalue:String);
|
||||
begin
|
||||
fAboutBox.ComponentName:=AValue;
|
||||
fAboutBox.Title:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxWidth(Const AValue:Integer);
|
||||
begin
|
||||
fAboutBox.Width:=Avalue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxHeight(Const AValue:Integer);
|
||||
begin
|
||||
fAboutBox.Height:=Avalue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxDescription(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Description.Clear;
|
||||
fAboutBox.Description.Add(AValue);
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxFontName(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Font.Name:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxFontSize(Const AValue:Integer);
|
||||
begin
|
||||
if (AValue > 6) then fAboutBox.Font.Size:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxTitle(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Title:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxBitmap(Const AValue:TBitmap);
|
||||
begin
|
||||
If Assigned(Avalue) then fAboutBox.Assign(AValue);
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxBackgroundColor(Const AValue:TColor);
|
||||
begin
|
||||
fAboutBox.BackGroundColor:=AValue;;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxVersion(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Version:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxAuthorname(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Authorname:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxOrganisation(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.Organisation:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxAuthorEmail(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.AuthorEmail:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxBackgroundResourceName(Const AValue:String);
|
||||
begin
|
||||
fAboutBox.BackgroundResourceName:=AValue;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxLicenseType(Const AValue:string);
|
||||
begin
|
||||
Case Upcase(AValue) of
|
||||
'GPL':fAboutBox.LicenseType:=abGPL;
|
||||
'LGPL':fAboutBox.LicenseType:=abLGPL;
|
||||
'MIT':fAboutBox.LicenseType:=abMIT;
|
||||
'MODIFIEDGPL':fAboutBox.LicenseType:=abModifiedGPL;
|
||||
'PROPRIETRY':fAboutBox.LicenseType:=abProprietry;
|
||||
else
|
||||
fAboutBox.LicenseType:=abNone;
|
||||
end;
|
||||
end;
|
||||
procedure TAboutPoweredby.SetAboutBoxStretchBackgroundImage(Const AValue:Boolean);
|
||||
begin
|
||||
fAboutBox.StretchBackground:=AValue;
|
||||
end;
|
||||
|
||||
// End Sets
|
||||
|
||||
constructor TAboutPoweredby.Create(AOwner: TComponent);
|
||||
var
|
||||
TempImage: TPicture;
|
||||
r:TLResource;
|
||||
begin
|
||||
// Inherit default properties
|
||||
inherited Create(AOwner);
|
||||
// Use tAboutBox as a subcomponent
|
||||
fAboutBox := tAboutBox.Create(nil);
|
||||
with fAboutBox do
|
||||
begin
|
||||
SetSubComponent(True); // Tell the IDE to store the modified properties
|
||||
// Default of TAboutPoweredby values override TAbouBox.Create defaults
|
||||
ComponentName := 'TAboutPoweredby';
|
||||
Description.Add('This is to demonstrate'); //TStrings
|
||||
Description.Add('the use of TAboutPoweredby'); //TStrings
|
||||
Description.Add('Set its properties in your Constructor'); //TStrings
|
||||
Width := 320; //Integer
|
||||
Height := 280; //Integer
|
||||
// Set any Font properties or subproperties here
|
||||
// Font.Name := 'Arial';
|
||||
Font.Color := clNavy;
|
||||
Font.Size:=10;
|
||||
// BackGroundColor shows if no BackGround image is set
|
||||
BackGroundColor := clWindow;
|
||||
Version := '1.0.0.0';
|
||||
AuthorName := 'Gordon Bamber';
|
||||
AuthorEmail := 'minesadorada@charcodelvalle.com';
|
||||
Organisation := 'Public Domain';
|
||||
|
||||
//Types available: abNone, abGPL, abLGPL, abMIT, abModifiedGPL, abProprietry
|
||||
LicenseType := abLGPL;
|
||||
|
||||
// BackGround image is optional
|
||||
// It must be in a resouce file in the initialization section
|
||||
|
||||
//== How to set a background image to your About dialog --
|
||||
// The BackGround property is a TBitmap
|
||||
// Use a Temporary TPicture to load a JPG.
|
||||
// NOTE a PNG file will create an error when your component is used in an application!
|
||||
r := LazarusResources.Find(fAboutBox.BackgroundResourceName);
|
||||
if r <> nil then
|
||||
begin
|
||||
TempImage := TPicture.Create;
|
||||
// .lrs file is in the initialization section
|
||||
TempImage.LoadFromLazarusResource(fAboutBox.BackgroundResourceName);
|
||||
BackGround.Assign(TempImage.Bitmap);
|
||||
TempImage.Free;
|
||||
StretchBackground := fAboutBox.StretchBackground; //Boolean
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TAboutPoweredby.Destroy;
|
||||
begin
|
||||
FreeAndNil(fAboutBox);
|
||||
inherited Destroy;
|
||||
end;
|
||||
initialization
|
||||
{$I license.lrs}
|
||||
|
||||
end.
|
1738
components/poweredby/graphics.lrs
Normal file
1738
components/poweredby/graphics.lrs
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
components/poweredby/graphics_resources/powered_by.png
Normal file
BIN
components/poweredby/graphics_resources/powered_by.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
components/poweredby/graphics_resources/powered_by_graphic.png
Normal file
BIN
components/poweredby/graphics_resources/powered_by_graphic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
72
components/poweredby/license.lrs
Normal file
72
components/poweredby/license.lrs
Normal file
@@ -0,0 +1,72 @@
|
||||
LazarusResources.Add('gpl.txt','TXT',[
|
||||
' Copyright (C) <year> <name of author> <contact>'#13#10#13#10' This source'
|
||||
+' is free software; you can redistribute it and/or modify it under'#13#10' '
|
||||
+'the terms of the GNU General Public License as published by the Free'#13#10
|
||||
+' Software Foundation; either version 2 of the License, or (at your option)'
|
||||
+#13#10' any later version.'#13#10#13#10' This code is distributed in the h'
|
||||
+'ope that it will be useful, but WITHOUT ANY'#13#10' WARRANTY; without even'
|
||||
+' the implied warranty of MERCHANTABILITY or FITNESS'#13#10' FOR A PARTICUL'
|
||||
+'AR PURPOSE. See the GNU General Public License for more'#13#10' details.'
|
||||
+#13#10#13#10' A copy of the GNU General Public License is available on the '
|
||||
+'World Wide Web'#13#10' at <http://www.gnu.org/copyleft/gpl.html>. You can '
|
||||
+'also obtain it by writing'#13#10' to the Free Software Foundation, Inc., 5'
|
||||
+'9 Temple Place - Suite 330, Boston,'#13#10' MA 02111-1307, USA.'
|
||||
]);
|
||||
LazarusResources.Add('lgpl.txt','TXT',[
|
||||
' Copyright (C) <year> <name of author> <contact>'#13#10#13#10' This librar'
|
||||
+'y is free software; you can redistribute it and/or modify it'#13#10' under'
|
||||
+' the terms of the GNU Library General Public License as published by'#13#10
|
||||
+' the Free Software Foundation; either version 2 of the License, or (at you'
|
||||
+'r'#13#10' option) any later version.'#13#10#13#10' This program is distri'
|
||||
+'buted in the hope that it will be useful, but WITHOUT'#13#10' ANY WARRANTY'
|
||||
+'; without even the implied warranty of MERCHANTABILITY or'#13#10' FITNESS '
|
||||
+'FOR A PARTICULAR PURPOSE. See the GNU Library General Public License'#13#10
|
||||
+' for more details.'#13#10#13#10' You should have received a copy of the G'
|
||||
+'NU Library General Public License'#13#10' along with this library; if not,'
|
||||
+' write to the Free Software Foundation,'#13#10' Inc., 59 Temple Place - Su'
|
||||
+'ite 330, Boston, MA 02111-1307, USA.'
|
||||
]);
|
||||
LazarusResources.Add('mit.txt','TXT',[
|
||||
' Copyright (c) <year> <copyright holders>'#13#10#13#10' Permission is here'
|
||||
+'by granted, free of charge, to any person obtaining a copy'#13#10' of this'
|
||||
+' software and associated documentation files (the "Software"), to'#13#10' '
|
||||
+'deal in the Software without restriction, including without limitation the'
|
||||
+#13#10' rights to use, copy, modify, merge, publish, distribute, sublicense'
|
||||
+', and/or'#13#10' sell copies of the Software, and to permit persons to who'
|
||||
+'m the Software is'#13#10' furnished to do so, subject to the following con'
|
||||
+'ditions:'#13#10#13#10' The above copyright notice and this permission noti'
|
||||
+'ce shall be included in'#13#10' all copies or substantial portions of the '
|
||||
+'Software.'#13#10#13#10' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY'
|
||||
+' OF ANY KIND, EXPRESS OR'#13#10' IMPLIED, INCLUDING BUT NOT LIMITED TO THE'
|
||||
+' WARRANTIES OF MERCHANTABILITY,'#13#10' FITNESS FOR A PARTICULAR PURPOSE A'
|
||||
+'ND NONINFRINGEMENT. IN NO EVENT SHALL THE'#13#10' AUTHORS OR COPYRIGHT HOL'
|
||||
+'DERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER'#13#10' LIABILITY, WHETHER '
|
||||
+'IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING'#13#10' FROM, OUT OF '
|
||||
+'OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS'#13#10' IN'
|
||||
+' THE SOFTWARE.'
|
||||
]);
|
||||
LazarusResources.Add('modifiedgpl.txt','TXT',[
|
||||
' Copyright (C) <year> <name of author> <contact>'#13#10#13#10' This librar'
|
||||
+'y is free software; you can redistribute it and/or modify it'#13#10' under'
|
||||
+' the terms of the GNU Library General Public License as published by'#13#10
|
||||
+' the Free Software Foundation; either version 2 of the License, or (at you'
|
||||
+'r'#13#10' option) any later version with the following modification:'#13#10
|
||||
+#13#10' As a special exception, the copyright holders of this library give '
|
||||
+'you'#13#10' permission to link this library with independent modules to pr'
|
||||
+'oduce an'#13#10' executable, regardless of the license terms of these inde'
|
||||
+'pendent modules,and'#13#10' to copy and distribute the resulting executabl'
|
||||
+'e under terms of your choice,'#13#10' provided that you also meet, for eac'
|
||||
+'h linked independent module, the terms'#13#10' and conditions of the licen'
|
||||
+'se of that module. An independent module is a'#13#10' module which is not '
|
||||
+'derived from or based on this library. If you modify'#13#10' this library,'
|
||||
+' you may extend this exception to your version of the library,'#13#10' but'
|
||||
+' you are not obligated to do so. If you do not wish to do so, delete this'
|
||||
+#13#10' exception statement from your version.'#13#10#13#10' This program '
|
||||
+'is distributed in the hope that it will be useful, but WITHOUT'#13#10' ANY'
|
||||
+' WARRANTY; without even the implied warranty of MERCHANTABILITY or'#13#10' '
|
||||
+' FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public Licen'
|
||||
+'se'#13#10' for more details.'#13#10#13#10' You should have received a cop'
|
||||
+'y of the GNU Library General Public License'#13#10' along with this librar'
|
||||
+'y; if not, write to the Free Software Foundation,'#13#10' Inc., 59 Temple '
|
||||
+'Place - Suite 330, Boston, MA 02111-1307, USA.'
|
||||
]);
|
68
components/poweredby/poweredby.lpk
Normal file
68
components/poweredby/poweredby.lpk
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="poweredby"/>
|
||||
<AddToProjectUsesSection Value="True"/>
|
||||
<Author Value="minesadorada@charcodelvalle.com"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="Method: ShowPoweredBy
|
||||
Graphic shown will depend on widgetset"/>
|
||||
<License Value="TPoweredby Component
|
||||
|
||||
Copyright (C)2014 Gordon Bamber minesadorada@charcodelvalle.com
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. "/>
|
||||
<Version Major="1" Release="3"/>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="upoweredby.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uPoweredby"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="aboutpoweredbyunit.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="AboutPoweredbyunit"/>
|
||||
</Item2>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item1>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
22
components/poweredby/poweredby.pas
Normal file
22
components/poweredby/poweredby.pas
Normal file
@@ -0,0 +1,22 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit poweredby;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uPoweredby, AboutPoweredbyunit, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('uPoweredby', @uPoweredby.Register);
|
||||
RegisterUnit('AboutPoweredbyunit', @AboutPoweredbyunit.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('poweredby', @Register);
|
||||
end.
|
311
components/poweredby/upoweredby.pas
Normal file
311
components/poweredby/upoweredby.pas
Normal file
@@ -0,0 +1,311 @@
|
||||
{ TPoweredby Component
|
||||
|
||||
Copyright (C)2014 Gordon Bamber minesadorada@charcodelvalle.com
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
}
|
||||
unit uPoweredby;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Controls, Dialogs, Forms, Graphics, LResources, SysUtils,
|
||||
ExtCtrls, InterfaceBase, LCLType,LCLVersion,AboutPoweredbyunit;
|
||||
|
||||
const
|
||||
C_VERSIONSTRING = '1.0.3.0';
|
||||
C_WIDGETSET_GTK = 'GTK widget set';
|
||||
C_WIDGETSET_GTK2 = 'GTK 2 widget set';
|
||||
C_WIDGETSET_GTK3 = 'GTK 3 widget set';
|
||||
C_WIDGETSET_WIN = 'Win32/Win64 widget set';
|
||||
C_WIDGETSET_WINCE = 'WinCE widget set';
|
||||
C_WIDGETSET_CARBON = 'Carbon widget set';
|
||||
C_WIDGETSET_QT = 'QT widget set';
|
||||
C_WIDGETSET_fpGUI = 'fpGUI widget set';
|
||||
C_WIDGETSET_COCOA = 'Cocoa widget set';
|
||||
C_WIDGETSET_CUSTOM = 'Custom drawn widget set';
|
||||
C_WIDGETSET_OTHER = 'Other gui';
|
||||
|
||||
type
|
||||
TPoweredby = class(TAboutPoweredBy)
|
||||
private
|
||||
{ Private declarations }
|
||||
fPoweredByForm: TForm;
|
||||
fVersionString: string;
|
||||
fDelayMilliseconds: integer;
|
||||
fFadeInMilliseconds: integer;
|
||||
fShowOnlyOnce,fAlreadyShown:Boolean;
|
||||
// Used by Timer to close the PoweredBy form
|
||||
procedure ClosePoweredByForm(Sender: TObject);
|
||||
// Windows only!
|
||||
procedure FadeInPoweredBy(Sender: TObject);
|
||||
procedure SetDelayMilliSeconds(AValue: integer);
|
||||
function GetWidgetSetString: string;
|
||||
Function GetFPCTargetInfoString: String;
|
||||
Function GetInfoLCLVersion:String;
|
||||
Function GetInfoFPCVersion:String;
|
||||
protected
|
||||
{ Protected declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
// Call the method 'ShowPoweredByForm' to show the shaped window
|
||||
procedure ShowPoweredByForm;
|
||||
// Called when component is dropped onto a form
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
published
|
||||
{ Published declarations }
|
||||
// Minimum delay=1000msec; Maximum delay=10000msec. Fade-in time is automatically adjusted
|
||||
property DelayMilliSecs: integer read fDelayMilliSeconds write SetDelayMilliSeconds default 1000;
|
||||
// Call the method 'ShowPoweredByForm' to show the shaped window
|
||||
property Version: string read fVersionString;
|
||||
// Reports the current WidgetSet
|
||||
property InfoWidgetSet: string read GetWidgetSetString;
|
||||
// Reports your current Environment
|
||||
property InfoFPCTarget:String read GetFPCTargetInfoString;
|
||||
// Reports your current Environment
|
||||
property InfoFPCVersion:String read GetInfoFPCVersion;
|
||||
// Reports your current Environment
|
||||
property InfoLCLVersion:String read GetInfoLCLVersion;
|
||||
// Useful if you have ShowPoweredByForm in your TForm.Activate() method
|
||||
property ShowOnlyOnce:boolean read fShowOnlyOnce write fShowOnlyOnce default false;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
{$I upoweredby_icon.lrs}
|
||||
RegisterComponents('Additional', [TPoweredby]);
|
||||
end;
|
||||
|
||||
constructor TPoweredby.Create(AOwner: TComponent);
|
||||
// Initialise private vars
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fVersionString := C_VERSIONSTRING;
|
||||
fDelayMilliseconds := 1000;
|
||||
fFadeInMilliseconds := 20;
|
||||
fAlreadyShown:=False;
|
||||
fShowOnlyOnce:=False;
|
||||
// About dialog
|
||||
AboutBoxComponentName:='PoweredBy component';
|
||||
AboutBoxWidth:=400;
|
||||
// AboutBoxHeight (integer)
|
||||
AboutBoxDescription:='Component that shows a Powered By graphic.' + LineEnding +
|
||||
'Use method ShowPoweredByForm in your form.create()' + LineEnding +
|
||||
'to use the component';
|
||||
AboutBoxBackgroundColor:=clWindow;
|
||||
AboutBoxFontName:='Arial';
|
||||
AboutBoxFontSize:=10;
|
||||
AboutBoxVersion:=C_VERSIONSTRING;
|
||||
AboutBoxAuthorname:='Gordon Bamber';
|
||||
AboutBoxOrganisation:='Public Domain';
|
||||
AboutBoxAuthorEmail:='minesadorada@charcodelvalle.com';
|
||||
AboutBoxLicenseType:='LGPL';
|
||||
end;
|
||||
Function TPoweredby.GetInfoLCLVersion:String;
|
||||
begin
|
||||
result:=lcl_version;
|
||||
end;
|
||||
Function TPoweredby.GetInfoFPCVersion:String;
|
||||
begin
|
||||
Result:={$I %FPCVERSION%};
|
||||
end;
|
||||
Function TPoweredby.GetFPCTargetInfoString: String;
|
||||
begin
|
||||
Result := {$I %FPCTARGETCPU%}+' - '+{$I %FPCTARGETOS%};
|
||||
end;
|
||||
|
||||
function priv_GetWidgetSetString: string;
|
||||
// This code cannot be a method of TPoweredBy
|
||||
begin
|
||||
case WidgetSet.LCLPlatform of
|
||||
lpGtk: Result := C_WIDGETSET_GTK;
|
||||
lpGtk2: Result := C_WIDGETSET_GTK2;
|
||||
lpWin32: Result := C_WIDGETSET_WIN;
|
||||
lpWinCE: Result := C_WIDGETSET_WINCE;
|
||||
lpCarbon: Result := C_WIDGETSET_CARBON;
|
||||
lpCocoa: Result := C_WIDGETSET_COCOA;
|
||||
lpQT: Result := C_WIDGETSET_QT;
|
||||
lpfpGUI: Result := C_WIDGETSET_fpGUI;
|
||||
// When were these first included in InterfaceBase?
|
||||
{$IFDEF FPC_FULLVERSION>24200}
|
||||
lpGtk3: Result := C_WIDGETSET_GTK3;
|
||||
lpCustomDrawn: Result := C_WIDGETSET_CUSTOM;
|
||||
{$ENDIF}
|
||||
else
|
||||
Result := C_WIDGETSET_OTHER;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPoweredby.GetWidgetSetString: string;
|
||||
begin
|
||||
Result := priv_GetWidgetSetString;
|
||||
end;
|
||||
|
||||
procedure TPoweredby.SetDelayMilliSeconds(AValue: integer);
|
||||
begin
|
||||
if ((fDelayMilliSeconds <> AValue) and (AValue > 0) and (AValue < 11000)) then
|
||||
begin
|
||||
fDelayMilliseconds := AValue;
|
||||
fFadeInMilliseconds := (AValue div 1000) * 20;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TPoweredby.ClosePoweredByForm(Sender: TObject);
|
||||
// Called by Timer event in ShowPoweredByForm to close Modal window
|
||||
// Also the image OnClick event
|
||||
begin
|
||||
fPoweredByForm.Close;
|
||||
end;
|
||||
|
||||
procedure TPoweredby.FadeInPoweredBy(Sender: TObject);
|
||||
// Use Alphablend property of TForm
|
||||
begin
|
||||
if (fPoweredByForm.AlphaBlendValue < 245) then
|
||||
fPoweredByForm.AlphaBlendValue := fPoweredByForm.AlphaBlendValue + 10;
|
||||
end;
|
||||
|
||||
function CanShowRoundedGraphic: boolean;
|
||||
{
|
||||
Check the current WidgetSet, and add to the list that can show the rounded graphic
|
||||
Choices are:
|
||||
lpGtk,
|
||||
lpGtk2,
|
||||
lpGtk3,
|
||||
lpWin32,
|
||||
lpWinCE,
|
||||
lpCarbon,
|
||||
lpQT,
|
||||
lpfpGUI,
|
||||
lpNoGUI,
|
||||
lpCocoa,
|
||||
lpCustomDrawn
|
||||
}
|
||||
begin
|
||||
case WidgetSet.LCLPlatform of
|
||||
lpWin32, lpQT: Result := True;
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoweredby.ShowPoweredByForm;
|
||||
|
||||
// Graphics are in masks.lrs
|
||||
// 1 ) Constructs a new TForm with an image control
|
||||
// 2 ) Uses the 'SetShape' method of the form canvas to create a transparent mask
|
||||
// 3 ) Paints the Timage over it with a color image
|
||||
// 4 ) Sets a timer to fade it in using the Alphablend property
|
||||
// 5 ) Sets another timer to close the form
|
||||
|
||||
// Note: Windows can fade in a shaped transparent screen
|
||||
// But some widgetsets (GTK,Carbon) cannot
|
||||
var
|
||||
img_Background: TImage;
|
||||
MyBitmap: TBitMap;
|
||||
DelayTimer: TTimer;
|
||||
FadeInTimer: TTImer;
|
||||
begin
|
||||
// Respect the ShowOnlyOnce property setting
|
||||
If ((fShowOnlyOnce=TRUE) AND (fAlreadyShown=TRUE)) then Exit;
|
||||
|
||||
// Try..Finally so we can be sure resources are Freed
|
||||
try
|
||||
try
|
||||
// Create controls
|
||||
fPoweredByForm := TForm.Create(nil);
|
||||
fPoweredByForm.AlphaBlend := True;
|
||||
fPoweredByForm.AlphaBlendValue := 0;
|
||||
img_background := TImage.Create(fPoweredByForm);
|
||||
// Bitmap mask - Load from resource
|
||||
MyBitmap := TBitMap.Create;
|
||||
MyBitmap.LoadFromLazarusResource('powered_by_mask');
|
||||
// Delay Timer
|
||||
Delaytimer := TTimer.Create(fPoweredByForm);
|
||||
delaytimer.Interval := fDelayMilliseconds;
|
||||
delaytimer.OnTimer := @ClosePoweredByForm;
|
||||
|
||||
FadeInTimer := TTimer.Create(fPoweredByForm);
|
||||
FadeInTimer.Interval := fFadeInMilliseconds;
|
||||
FadeInTimer.OnTimer := @FadeInPoweredBy;
|
||||
|
||||
// BackGround image - load from resource
|
||||
with img_background do
|
||||
begin
|
||||
Align := alClient;
|
||||
Stretch := True;
|
||||
Parent := fPoweredByForm;
|
||||
if CanShowRoundedGraphic then
|
||||
Picture.LoadFromLazarusResource('win_powered_by')
|
||||
else
|
||||
Picture.LoadFromLazarusResource('powered_by');
|
||||
OnClick := @ClosePoweredByForm;
|
||||
SendToBack;
|
||||
end;
|
||||
// Set form properties
|
||||
with fPoweredByForm do
|
||||
begin
|
||||
position := poScreenCenter;
|
||||
borderstyle := bsnone;
|
||||
formstyle := fsSystemStayOnTop;
|
||||
OnClick := @ClosePoweredByForm;
|
||||
color := clBlack;
|
||||
Height := MyBitmap.Height;
|
||||
Width := MyBitMap.Width;
|
||||
if CanShowRoundedGraphic then
|
||||
begin
|
||||
MyBitMap.Transparent := True;
|
||||
MyBitMap.TransparentColor := clBlack;
|
||||
Canvas.Draw(0, 0, MyBitMap);
|
||||
// raises Floating Point Error in linux GTK (!??)
|
||||
SetShape(MyBitMap);
|
||||
end
|
||||
else
|
||||
begin
|
||||
// If square graphic, then adjust form size
|
||||
height:=img_background.Picture.Height;
|
||||
width:=img_background.picture.width;
|
||||
end;
|
||||
// Now show the completed form
|
||||
delaytimer.Enabled := True;
|
||||
FadeInTimer.Enabled := True;
|
||||
Application.ProcessMessages;
|
||||
ShowModal; // Closed via the Timer event or a user click
|
||||
fAlreadyShown:=TRUE;
|
||||
end;
|
||||
except
|
||||
On E: Exception do
|
||||
raise Exception.CreateFmt('%s Error: %s', [Name, Exception.ClassName]);
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(img_background);
|
||||
FreeAndNil(MyBitMap);
|
||||
FreeAndNil(delayTimer);
|
||||
FreeAndNil(FadeInTimer);
|
||||
FreeAndNil(fPoweredByForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
// Load graphics as lazarus resources into the component
|
||||
{$I graphics.lrs}
|
||||
|
||||
end.
|
79
components/poweredby/upoweredby_icon.lrs
Normal file
79
components/poweredby/upoweredby_icon.lrs
Normal file
@@ -0,0 +1,79 @@
|
||||
LazarusResources.Add('TPoweredby','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#7'tIME'#7#222#6#6#14#26'+X'#196'S'#18#0#0#0#9'pHYs'#0#0#14#195#0#0#14
|
||||
+#195#1#199'o'#168'd'#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#6#188'IDATx'
|
||||
+#218#133#150'yl'#147#247#25#199'?'#175#253':'#182#227#28#182's`'#147#196#9
|
||||
+#169#147#216#129'pT'#20'oe'#16#160#208#165#131'R'#142#13#168'Z'#173#132'^Tjw'
|
||||
+'t'#237#10'Z'#183'2'#169#211#232'*'#177#178'MU'#203#168'@Z'#171#4#212'3'#208
|
||||
+'R'#10#17#12#1'!'#229'&'#16#147'@'#26#146#204'N'#226'$N'#28'_'#137#175'w?2'
|
||||
+#137'-'#211#202#252#143#237#159#229#231#247'|'#159#231'{'#188#146#162'('#220
|
||||
+#237#229'v'#187#149'}'#251'?'#226#204#217#22#174'v'#7#241#220#10'1'#189'\'
|
||||
+#207#250'U'#213#172']'#243#8#149#149#211#165#187#253'_'#250#182#11#218#219
|
||||
+#219#149#166'3'#231#8'E'#19#24#205#185't'#246#248#169'r'#150#160#146'$'#154
|
||||
+'/'#180#211#214#233'%['#151#196'^dd'#205#170#26#202#203#203#255#231'E'#242
|
||||
+#127#31'D'#163'Q'#165#225#192#231'h'#180#6'l'#165#14'*'#236#197#244#15#12'3'
|
||||
+#224'o'#193'YVL<'#145'`h$'#204#188'{'#29'X'#242#205#156'h'#186'J'#197#131#219
|
||||
+'y{'#203#247#148#218#141#143#162#211#233''']'#164#250#207'/~'#191'_y'#251#221
|
||||
+'='#20#21#219'q'#185#230'!'#203#26#198#198#199'I'#165'R'#228#152'3'#9#134#163
|
||||
+#132'#'#227'$'#18')J'#139'-'#248#6#135'qw'#14'R'#247'V-1'#201#200#203'['#223
|
||||
+'`xxx'#210'H'#238#140#232'v'#231';'#255#178#139#251'\'#243''''#186#150'e5cc1'
|
||||
+#220'7z0fj'#185'x'#197#205#245#27#221#244#13#4'q'#216#11#185#127'^'#149'@2&'
|
||||
+#26#136'3%'#207#136'^'#167#229#211#175'."E'#187#249#195#239'^'#190#131#228
|
||||
+#206#136#234#234'?d4'#158'A,'#158#154'('#222#231#27#198#227#237#227#208#145
|
||||
+#19#140#140'F'#145'd='#22#139#17'Wi'#17''''#207#186'i8v'#25#171'9'#157#23#158
|
||||
+'\C<'#165#136#11#210#24#9'+4'#182#202#204'x'#127'?'#207'<'#245#196#191#17#180
|
||||
+#181#181'){'#235#191'd'#195#15#31'&'#24#12#139#133#250'P'#19#167#238#227#195
|
||||
+'8*'#156#168'd-}C#'#252#226#185'u'#148#148'X'#249#251#201's'#236#216'}'#20
|
||||
+#173'J'#193#235#237'f'#195#195#11#232#240#142#211#220#17#192'U'#150#135#167
|
||||
+#231#27#254#244#218':'#202'+*'#164#137#29'|'#210'p'#152#7#170#231#211't'#174
|
||||
+'U H'#160#164#226#236#250#160#129#154#154'E'#200#218'4'#2#145#16'K'#23#205'!'
|
||||
+'-#'#135'^'#127#138#188')'#5#164#235#20#198#147'2'#25'9'#211'x'#253'o'#199#24
|
||||
+#21#141'm'#127'n'#1'/='#185#136'g'#30#251'>'#31'~z'#228'_,'#186'.x~'#250'R'
|
||||
+#15#146#254#22#203#22#206'$'#22'K'#208'x'#252'$O='#177#154#149#15'-'#227'fW/'
|
||||
+'cq'#5's'#142#133#145#145'Q'#20#146'd'#155#166#240#179'g'#215#242#245'91'#166
|
||||
+'|'#19#215#220'f'#188#221#30'rLY'#140#134#162#19#236'z'#239#202#144#208'P'
|
||||
+#171#162'6'#153#243#182'Y'#11#166#177#192'5'#131#3'G'#206's'#236#212'e'#218
|
||||
+#186'|<'#184#216#133#209#148'K'#155#187#133'X'#160#135'q'#197#128'Z'#163#155
|
||||
+' ^8'#20'`l'#176#157#172'L'#3'K'#22'-'#196'Yn'#227#213#221#135#169#178#229#10
|
||||
+#26'K'#236#254#228#18#218'4'#153#129#158#139#168'O'#156#232#221#246#202'+O'
|
||||
+#147#159#159'Cl<'#198#137#230#22#193#138'<.'#187#187#153'9'#195#142#197#230
|
||||
+'`4'#156'$'#16#138'`'#200#202'!)H'#215#219#219#139'Zg'#194'R<'#157#132#164'a'
|
||||
+'h'#192#203'-'#193#176#230'+^Tj'#29#235'kf'#160'QIl}'#243#3#193#162'B'#27#151
|
||||
+#174'u'#139'u'#171#177#21#230'c1'#233#136#164'dF'#3'q'#134#3#1#178'LV'#210'E'
|
||||
+#225#200#208' A'#161#234#142#254'0'#209#144'4'#161#11'"j'#250#251'n'#176#175
|
||||
+#190#129#164#208#193'='#214'('#139']'#247'`6'#25#144'5'#130#160'q'#241#238
|
||||
+#176#26'h<'#219#205#193'S'#157#232#4#172'd8'#130'.'#195'@Ia&S'#167'XH&'#146
|
||||
+#244'{'#187'0[l\'#19#246'0$'#208#152#132'.'#130#195#3'L'#205#207#163#231#31
|
||||
+#30#188#1#3#6#189#134#155#30#31#175#239'9'#131'9]'#133#189' '#139#169'Ezd'
|
||||
+#189#156'@'#150#4'#'#252#29#168#12#217#132#195'!l6+'#175#254#244'Q'#210#210
|
||||
+'M'#12#14#135#208#164#9'&'#5'#|'#246#238'K('#241'QVl'#222')f'#172#17'lK'#146
|
||||
+'o'#177#160#150#175#139#207')'#18#227#163'h'#148#4#158#190#17#162'c'#14#172
|
||||
+#153'ITkW,`'#208'''X'#164#146#25#236#235#20#208#244#130#9'!'#244#130#158'z-'
|
||||
+#2#186#140#199#23' '#145#150#203#202'M'#191'ey'#237'v'#10'le$'#198#130'B'#144
|
||||
+'*'#177'''''k'#151#217#241#137#17'jEC'#3#158#235#226'\&'#18#232'c'#245'C.'
|
||||
+#228#181#171'W'#208't'#181#14#191'P'#161'ZXC'#154#177#136'o'#186':'#249#227
|
||||
+'_?fZ'#161#153'P'#12'*'#28'Nd'#157#204#180#178'J$!'#29#173':'#142'Ax'#145'Q'
|
||||
+#23'C'#175#150#8#5#252'b/~J'#157'U'#220#236#245#145'o'#200#21#191'%'#184'][v'
|
||||
+'8+'#165#234#185'S'#149#253'g'#18#204#188#215#206#143'W'#206#230'P'#227#215
|
||||
+'|~'#172#21#171#181#152#177'X'#138#202#142'~j7n .'#165'#%#'#156'>v'#144#171
|
||||
+'n'#159'`U'#22#150#28#13'_'#28#189#192#11#143'/'#161#204'^J'#205#252'2'#222
|
||||
+#255#210'M'#245#172'$'#183'kO('#249#145#21#15#136#229#246#241'b'#237'B'#220
|
||||
+'7'#251'h'#239#23#199'j-#'#254'~'#204'Y'#233'by1'#164#216#16'e'#22'5A_'#7'G'
|
||||
+#154'|'#140#196#140't'#251#160#161#177#157#188#156')'#228#228#228'cH'#215'0g'
|
||||
+'F'#17'yi~V._<'#217'M'#223#217#181'W'#209#24#10'p'#139#196':s}'#128'M'#203'+'
|
||||
+#233#233#233'b'#207#193#11#130'vyT'#217#141'8JDQ'#239#16#157#253'2'#254#145#0
|
||||
+#161#209#1'f'#149#217'XU'#227#18#214#29#196#231#143'`'#202#0#131'z'#136'g'
|
||||
,#159#222'(M'#186'`L'#216#245#150#215'v'#224#9'[xqS'#181#144'{6_4'#182#208#229
|
||||
+#245'c5'#193#209#147'nZ=B'#23'b'#23#133#185#6#22#127#167'B'#160#204#160#202
|
||||
+'Q'#196#213#246'^'#238#159'['#202#175'v'#30#193'a'#246#177'c'#251'/'#239#216
|
||||
+#245#164#200#28#22#129#243#230'['#239#225#9#154#249'I'#237'R'#222#169'k'#162
|
||||
+#196#154#201#186#21's'#217'U'#127#154#249'sl"'#217'BB'#217'1'#150#206#175#16
|
||||
+#182#144'd'#199#222'Sl^?'#143#206'[=\'#186#216#204'o'#182'l'#198'd2'#223'I'
|
||||
+#181'I'#137'f2'#155#165'_o}'#158#239':'#213#188#241#231'z'#1'Wf'#195#202'y'
|
||||
+#212#31'8Ow'#127'Hx'#206'T'#238#155'UB'#203#141#1#209#26#19'9a/'#200#160#250
|
||||
+#249']DG{'#248#253#182#159'O*~'#215#208#191#157#17#7#15#29''''#16#150'&'#248
|
||||
+'='#22'W1'#173'(W,2'#141#227#205#29#228'e'#171'9'#127#165#157#165'.+'#203#133
|
||||
+#173#127'['#232'K'#255#239#177#165#165#165'E'#169#219#247#17#159'}u'#129#214
|
||||
+#179#9#129'Yb'#182'K'#195#15#150#204#230#241#199'~'#132#211'y'#247#199#150
|
||||
+#127#2'2'#211#240't'#12'k'#249'c'#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
Reference in New Issue
Block a user