First batch examples from components get metadata

This commit is contained in:
David Bannon 2022-03-20 17:31:33 +11:00
parent 19b0ff07bf
commit bc0acfba38
71 changed files with 941 additions and 3 deletions

View File

@ -0,0 +1,5 @@
{ "AggPasPango_example" : {
"Category" : "Techniques",
"Keywords" : ["Pango","AGG","textout", "Anti-Grain Geometry", "2D Vector Graphics"],
"Description" : "Demonstrates using Pango to write text on a bitmap and display it in a Lazarus widget.\n\nAggPas is an Object Pascal port of the Anti-Grain Geometry library - AGG,\n originally written by Maxim Shemanarev in industrially standard C++. \n AGG as well as AggPas is Open Source and free of charge 2D vector graphic\n library.\n\nFor further information, see the readme.txt file in <LazDir>/components/aggpas."}
}

View File

@ -0,0 +1,5 @@
{ "AggPas_LCLDemo1_example" : {
"Category" : "Techniques",
"Keywords" : ["AggPas","2d vector","Graphics","AGG","Textout"],
"Description" : "Draws and writes some text on a AggLCLCanvas.\n\nAggPas is an Object Pascal port of the Anti-Grain Geometry library - AGG, originally written by Maxim Shemanarev in industrially standard C++. \n AGG as well as AggPas is Open Source and free of charge 2D vector graphic\n library.\n\nFor further information, see the readme.txt file in <LazDir>/components/aggpas."}
}

View File

@ -58,7 +58,7 @@ begin
Ellipse(40,65,120,130);
// solid blue text
FontFilename:=SetDirSeparators('../../verdana.ttf');
FontFilename:='FreeSerif.ttf';
DebugLn(['TForm1.FormCreate ',FontFilename,' ',FileExistsUTF8(FontFilename)]);
Font.LoadFromFile(FontFilename);
Font.Size:=18;

View File

@ -0,0 +1,5 @@
{ "AggPas_LCLDemo2_example" : {
"Category" : "Techniques",
"Keywords" : ["AGG","Canvas","shapes", "Anti-Grain Geometry", "2D Vector Graphics"],
"Description" : "Demonstrates writing text and a range of shapes to a canvas using AGG.\n\nAggPas is an Object Pascal port of the Anti-Grain Geometry library - AGG,\n originally written by Maxim Shemanarev in industrially standard C++. \n AGG as well as AggPas is Open Source and free of charge 2D vector graphic\n library.\n\nFor further information, see the readme.txt file in <LazDir>/components/aggpas."}
}

View File

@ -29,6 +29,8 @@ implementation
{ TForm1 }
uses LazFileUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
HasFont: Boolean;
@ -47,7 +49,7 @@ begin
end;
{$IFDEF LCLGtk2}
HasFont:=true;
FontFilename:=SetDirSeparators('../../verdana.ttf');
FontFilename:=SetDirSeparators('FreeSans.ttf');
if not FileExistsUTF8(FontFilename) then begin
ShowMessage('file not found: '+FontFilename+' CurDir='+GetCurrentDirUTF8);
HasFont:=false;

View File

@ -0,0 +1,5 @@
{ "cairocanvas_example" : {
"Category" : "Techniques",
"Keywords" : ["Cairo","PDF","Postscript","svg","png"],
"Description" : "Package for use libcairo in fpc. This example does NOT display a GUI, it writes out a number of files, PDF, PS, SVG and PNG the content of which generated within the example.\n\nThis cairocanvas example require the Cairo Graphics and Pango libraries.\n\nSee the associated readme.txt file.\n\n"}
}

View File

@ -0,0 +1,31 @@
This directory contains a demonstration programs for the
export components. See also stdexports.
The simple directory contains a program which demonstrates how
to work with the export components directly.
Both programs work on a DBase data file. The File|New menu
can be used to create a new data file (it is saved at once,
a filename is asked) or the File|Open can be used to load
(any) Dbase file.
You can configure the components as you wish, at runtime the
design-time settings will be used. (unless the user changes them
with the dialog)
When the 'show config dialog' menu option is set in the program,
exporting will first show the configuration dialog, so the
export can be configured at runtime by the user. This is a generic dialog,
so it may not be the summit of ease-of-use.
The second (stdexports) program demonstrates how the automatic
registration routines (TStandardExportFormats component) work in
conjunction with the TFPDataExporter component. The former controls
which export formats are registered (and hence visible to the end
user), the second shows a selection and configuration dialog.
The set of registered formats can be set at design time, only the
selected formats will be available to the end user.
Note that currently, only data that can be represented in text format
can be exported, i.e., blobs will not work (unless they contain text).

View File

@ -0,0 +1,5 @@
{ "dbexport_demo" : {
"Category" : "DBase",
"Keywords" : ["dbase","database","export","Needs work"],
"Description" : "Demonstrates exporting a small database in a number of formats. Accepts an input file of your choice so may even be a useful utility.\nRequires the dbflaz package.\nSee also stdexports.\nAppears to have some UTF8 issues, char may not be displayed correctly and some Pango errors reported to console."}
}

View File

@ -0,0 +1,31 @@
This directory contains a demonstration program for the dbase
export components.
The dbexport_demo example contains a similar program which demonstrates how
to work with the export components directly.
Both programs work on a DBase data file. The File|New menu
can be used to create a new data file (it is saved at once,
a filename is asked) or the File|Open can be used to load
(any) Dbase file.
You can configure the components as you wish, at runtime the
design-time settings will be used. (unless the user changes them
with the dialog)
When the 'show config dialog' menu option is set in the program,
exporting will first show the configuration dialog, so the
export can be configured at runtime by the user. This is a generic dialog,
so it may not be the summit of ease-of-use.
This (stdexports) program demonstrates how the automatic
registration routines (TStandardExportFormats component) work in
conjunction with the TFPDataExporter component. The former controls
which export formats are registered (and hence visible to the end
user), the second shows a selection and configuration dialog.
The set of registered formats can be set at design time, only the
selected formats will be available to the end user.
Note that currently, only data that can be represented in text format
can be exported, i.e., blobs will not work (unless they contain text).

View File

@ -0,0 +1,187 @@
Unit gendata;
{$mode objfpc}{$H+}
Interface
Uses Classes, SysUtils, DB, dbf;
Const
DefFirstNamesFile = 'firstnames.txt';
DefLastNamesFile = 'lastnames.txt';
DefPersonCount = 10;
DefDayCount = 3;
Type
{ TDatagenerator }
TDatagenerator = Class(TObject)
private
FTID : Integer;
FDayCount: Integer;
FFirstNamesFile: String;
FLastNamesFile: String;
FOnProgress: TNotifyEvent;
FOutputFile: String;
FPersonCount: Integer;
FStartDate: TDateTime;
FDataset : TDataset;
procedure DoTrack(No,ID : Integer; Const FN,LN: String; Const D,Tin,Tout : TDateTime);
procedure DoPerson(ID : Integer; FN,LN : String);
Protected
Function CreateDataset : TDataset; virtual; abstract;
Procedure CloseDataset; virtual;
Property Dataset : TDataset Read FDataset Write FDataset;
Public
Constructor Create;
Procedure GenerateData;
Property FirstNamesFile : String Read FFirstNamesFile Write FFirstNamesFile;
Property LastNamesFile : String Read FLastNamesFile Write FLastNamesFile;
Property OutputFile : String Read FOutputFile Write FOutputFile;
Property StartDate : TDateTime Read FStartDate Write FStartDate;
Property OnProgress : TNotifyEvent Read FOnProgress Write FOnPRogress;
Property PersonCount : Integer Read FPersonCount Write FPersonCount;
Property DayCount : Integer Read FDayCount Write FDayCount;
end;
{ TDBFGenerator }
TDBFGenerator = Class(TDataGenerator)
Protected
Function CreateDataset : TDataset; override;
End;
Implementation
{ TDatagenerator }
constructor TDatagenerator.Create;
begin
FFirstNamesFile:=DefFirstNamesFile;
FLastNamesFile:=DefLastNamesFile;
FPersonCount:=DefPersonCount;
FDayCount:=DefDayCount;
FStartDate:=EncodeDate(2005,9,1);
end;
procedure TDatagenerator.DoTrack(No,ID : Integer; Const FN,LN: String; Const D,Tin,Tout : TDateTime);
begin
With Dataset do
begin
Append;
FieldByName('TrackID').AsInteger:=No;
FieldByName('PersonID').AsInteger:=ID;
FieldByName('FirstName').AsString:=FN;
FieldByName('LastName').AsString:=LN;
FieldByName('DayOfWeek').AsInteger:=DayOfWeek(D);
FieldByName('Date').AsDateTime:=D;
FieldByName('TimeIn').AsDateTime:=TIn;
FieldByName('TimeOut').AsDateTime:=TOut;
Post;
end;
end;
procedure TDatagenerator.DoPerson(ID : Integer; FN,LN : String);
Var
D,TIn,Tout : TDateTime;
I : Integer;
begin
For I:=1 to DayCount do
begin
D:=FStartDate+I;
// Entry
TIn:=EncodeTime(8,30+Random(10)-10,Random(60),0);
// Exit
Tout:=EncodeTime(17,30+Random(10)-10,Random(60),0);
DoTrack((ID-1)*DayCount+I,ID,FN,LN,D,TIn,Tout);
end;
If Assigned(FOnProgress) then
FOnProgress(Self);
end;
procedure TDatagenerator.CloseDataset;
begin
FDataset.Close;
FreeAndNil(FDataset);
end;
procedure TDatagenerator.GenerateData;
Var
FN,LN : TStrings;
PFN,PLN : String;
F : Text;
I : Integer;
begin
FTID:=0;
FDataset:=CreateDataset;
Try
Randomize;
FN:=TStringList.Create;
Try
FN.LoadFromFile(UTF8ToAnsi(FFirstNamesFile));
LN:=TStringList.Create;
Try
LN.LoadFromFile(UTF8ToAnsi(FLastNamesFile));
Assign(F,FOutputFile);
Rewrite(F);
Try
For I:=1 to PersonCount do
begin
PFN:=FN[Random(FN.Count)];
PLN:=LN[Random(LN.Count)];
DoPerson(I,PFN,PLN);
end;
Finally
Close(F);
end;
Finally
LN.Free;
end;
Finally
FN.Free;
end;
Finally
CLoseDataset;
end;
end;
{ TDBFGenerator }
function TDBFGenerator.CreateDataset: TDataset;
Var
DS : TDBF;
begin
DS:=TDBF.Create(Nil);
with DS.FieldDefs do
begin
Clear;
Add('TrackID',ftInteger,0);
Add('PersonID',ftInteger,0);
Add('FirstName',ftString,30);
Add('LastName',ftString,30);
Add('DayOfWeek',ftSmallint,0);
Add('Date',ftDate,0);
Add('TimeIn',ftDateTime,0);
Add('TimeOut',ftDateTime,0);
end;
DS.TableName:=OutputFile;
DS.CreateTable;
DS.Exclusive := true;
DS.Open;
DS.AddIndex('LastName', 'LastName', []);
Result:=DS;
end;
end.

View File

@ -0,0 +1,5 @@
{ "stdexports" : {
"Category" : "DBase",
"Keywords" : ["dbase","database","export","Needs work"],
"Description" : "Demonstrates exporting a small database in a number of formats. Accepts an input file of your choice s may even be a useful utility.\nSee also dbexport_demo.\nPlease see the associated readme.txt file.\nAppears to have some UTF8 issues, char may not be displayed correctly and some Pango errors reported to console."}
}

View File

@ -0,0 +1,5 @@
{ "Google_calendar_demo" : {
"Category" : "Techniques",
"Keywords" : ["google api","calendar","Synapse", "Needs Work"],
"Description" : "Demonstrates access to the Google API, as long as Synapse is installed, compiles and starts up fine but not tested because I don't have a Google API Access Code. Its possible that Google no longer supports the OAuth mode that is used here as testing generates a Google Invalid Client rather than a signing request. And does not behave very well on a 'cancel'. \nRequires Synapse from OPM\nRequires the use of a Google API Access Code"}
}

View File

@ -0,0 +1,5 @@
{ "Google_discovery_demo" : {
"Category" : "Techniques",
"Keywords" : ["Google API", "discovery", "Synapse"],
"Description" : "Finds and displays the Google API Services.\nRequires the synapse package from the OPM."}
}

View File

@ -16,7 +16,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, ActnList, Menus, ListViewFilterEdit, restbase, googleclient,
googlediscovery, frmgenoptions, frmview;
googlediscovery, frmgenoptions, frmview, opensslsockets;
type

View File

@ -0,0 +1,5 @@
{ "google_drive" : {
"Category" : "Techniques",
"Keywords" : ["Google API","Synapse","Google Drive", "Needs Work"],
"Description" : "Demonstrates access to the Google API, as long as Synapse is installed, compiles and starts up fine but not tested because I don't have a Google API Access Code. Its possible that Google no longer supports the OAuth mode that is used here as testing generates a Google Invalid Client rather than a signing request. And does not behave very well on a 'cancel'. \nRequires Synapse from OPM\nRequires the use of a Google API Access Code"}
}

View File

@ -0,0 +1,5 @@
{ "google_gmail" : {
"Category" : "Techniques",
"Keywords" : ["Google API","Synapse","gmail", "Needs Work"],
"Description" : "Demonstrates access to the Google API, as long as Synapse is installed, compiles and starts up fine but not tested because I don't have a Google API Access Code. Its possible that Google no longer supports the OAuth mode that is used here as testing generates a Google Invalid Client rather than a signing request. And does not behave very well on a 'cancel'. \nRequires Synapse from OPM\nRequires the use of a Google API Access Code"}
}

View File

@ -0,0 +1,5 @@
{ "Google_tasks_demo" : {
"Category" : "Techniques",
"Keywords" : ["Google API","Synapse","Tasks", "Needs Work"],
"Description" : "Demonstrates access to the Google API, as long as Synapse is installed, compiles and starts up fine but not tested because I don't have a Google API Access Code. Its possible that Google no longer supports the OAuth mode that is used here as testing generates a Google Invalid Client rather than a signing request. And does not behave very well on a 'cancel'. \nRequires Synapse from OPM.\nRequires the use of a Google API Access Code"}
}

View File

@ -0,0 +1,5 @@
{ "lrFclPDFExport_demo" : {
"Category" : "Components",
"Keywords" : ["LazReport","PDF","lrPDFExport","lr_pdfexport", "needs work"],
"Description" : "Demonstrates how to generate PDF reports from LazReport.\nRequires the package lr_PDFExport be installed before loading.\nNote that it generates an eror while starting up, clGray is not a valid integer. Its coming from the LRF file, needs fixing."}
}

View File

@ -0,0 +1,5 @@
{ "lr_codereport_sample" : {
"Category" : "Components",
"Keywords" : ["LazReport","CodeReport","PDF"],
"Description" : "Generates a report and can export it as a PDF.\nRequires LazReportPDFExport and lr_CodeReport\n\n "}
}

View File

@ -0,0 +1,5 @@
{ "lrspreadsheetexport_demo" : {
"Category" : "Components",
"Keywords" : ["lazreport","spreadsheet","export"],
"Description" : "Demonstrates creating and exporting a spreadsheet in several formats, ODS, XLS, XLSX\n\nDepends on fpspreadsheet in OPM, install FIRST !\nDepends on lrSpreadSheetExport.\n\n"}
}

View File

@ -0,0 +1,5 @@
{ "mouseandkeyinput_example" : {
"Category" : "Techniques",
"Keywords" : ["mouse", "keyboard", "input", "simulate"],
"Description" : "Shows how to simulate mouse and keyboard input programatically, for example triggered by the press of a button."}
}

View File

@ -0,0 +1,487 @@
{ MRU (Most Recent Used) menu item manager
Copyright (C) 2011 Michael Van Canneyt (michael@freepascal.org)
Modifications by Werner Pamler
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 with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.
}
unit mrumanager;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, inifiles, menus;
Type
{ TRecentMenuItem }
TRecentMenuItem = Class(TMenuItem)
Private
FFileName : string;
Public
Property FileName : String Read FFileName;
end;
TRecentMenuItemClass = Class of TRecentMenuItem;
{ TMRUMenuManager }
TOnRecentFileEvent = Procedure(Sender : TObject; Const AFileName : String) of object;
TMRUMenuManager = Class(TComponent)
Private
FIniFileName: String;
FIniSection: String;
FOnRecent: TOnRecentFileEvent;
FRecent : TStrings;
FMaxRecent : Integer;
FMenuCaptionMask : string;
FMIRecent : TMenuItem;
FPMRecent : TPopupMenu;
FMaxItemLength : integer;
procedure SetIniFileName(const AValue:string);
procedure SetIniSection(const AValue:string);
procedure SetMaxItemLength(const AValue:integer);
procedure SetMenuCaptionMask(const AValue:string);
procedure SetMIRecent(const AValue: TMenuItem);
procedure SetPMRecent(const AValue: TPopupMenu);
procedure SetRecent(const AValue: TStrings);
protected
// Overrides.
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
// Return default name and section if either is empty.
procedure GetFileNameAndSection(Var AFileName,ASection : String); virtual;
// Override if you want to load additional values.
procedure LoadFromIni(Ini: TCustomIniFile; ASection: String); virtual;
// Override if you want to write additional values.
procedure SaveToIni(Ini: TCustomIniFile; ASection: String); virtual;
// Called when menu item is clicked.
procedure DoOnRecentClick(Sender: TObject); virtual;
// Override this if you want to create a custom class of menu itel.
function CreateMenuItem(AOwner: TComponent): TRecentMenuItem; virtual;
// Create a menu caption. Default is index followed by filename.
// Override if you want to customize.
Function CreateMenuCaption(AIndex : Integer; Const AFileName : String) : String; virtual;
Public
Constructor Create(AOwner : TComponent);override;
Destructor Destroy; override;
// Load files from ini file AFileName in section ASection. Calls ShowRecentFiles
// Need for explicit call only when IniFileName='' and IniSection='' and class created at run-time
procedure LoadRecentFilesFromIni(const AFileName: string=''; const ASection: String='');
// Saves files to ini file AFileName in section ASection.
procedure SaveRecentFilesToIni(const AFileName: string=''; const ASection: String='');
// Add a filename to the list of files.
// If an existing file is added, it is moved first in the list.
// If MaxRecent is attained, the last one is removed.
// Calls ShowRecentFiles.
procedure AddToRecent(AFileName: String);
// Re-populate the menu.
procedure ShowRecentFiles;
Published
// Max. items to be kept in the list.
Property MaxRecent : Integer Read FMaxRecent write FMaxRecent default 10;
// Menu item to create a submenu under. Existing items will be removed.
Property MenuItem : TMenuItem Read FMIRecent Write SetMIRecent;
// Popupmenu attached to a toolbar button. Existing items will be removed.
Property PopupMenu : TPopupMenu Read FPMRecent Write SetPMRecent;
// Default ini filename.
Property IniFileName : String Read FIniFileName Write SetIniFileName;
// Default ini section.
Property IniSection : String Read FIniSection Write SetIniSection;
// Maximum length of recent menu item
Property MaxItemLength : integer Read FMaxItemLength Write SetMaxItemLength default 80;
// Format mask for MenuCaption: first placeholder must be %d, second %s, e.g. '%d - %s'
Property MenuCaptionMask : string read FMenuCaptionMask Write SetMenuCaptionMask;
// Recent items. If adding manually to the list, ShowRecentFiles must be called manually.
Property Recent : TStrings Read FRecent Write SetRecent;
// Called when the user clicks an recent meu item.
Property OnRecentFile : TOnRecentFileEvent Read FOnRecent Write FOnRecent;
end;
EMRUManager = Class(Exception);
Const
DefaultIniFile = 'recent.ini';
DefaultSection = 'Global';
KeyMaxRecent = 'MaxRecent';
KeyCount = 'Count';
KeyFile = 'File%d';
implementation
Resourcestring
SErrFailedToCreateDir = 'Failed to create directory "%s"';
const
DEFAULT_MASK = '%0:d. %1:s';
function MinimizeFileName(const AFileName:string; AMaxLen:integer) : string;
procedure SplitPath(const APath:String; Parts: TStrings);
{ Splits the provided path into constituent folder names }
var
i, j : Integer;
begin
if APath = '' then exit;
if not Assigned(Parts) then exit;
i := Length(APath);
j := i;
while (i >= 1) do begin
if APath[i] = DirectorySeparator then begin
Parts.Insert(0, copy(APath, i+1, j-i));
j := i;
end;
dec(i);
end;
Parts.Insert(0, copy(APath, 1, j));
end;
function AddStringsFromTo(AList:TStrings; FromIndex,ToIndex:integer) : string;
var
i : integer;
begin
result := '';
for i:=FromIndex to ToIndex do
result := result + AList[i];
end;
var
Parts : TStringList;
i : integer;
tmp : string;
begin
result := AFileName;
if Length(AFileName) > AMaxLen then begin
Parts := TStringList.Create;
try
SplitPath(AFileName, Parts);
i := Parts.Count div 2;
while (i < Parts.Count) do begin
tmp := Format('%s...%s%s', [
AddStringsFromTo(Parts, 0, i-1),
DirectorySeparator,
AddStringsFromTo(Parts, i+1, Parts.Count-1)
]);
if Length(tmp) < AMaxLen then begin
result := tmp;
exit;
end else
Parts.Delete(i);
i := Parts.Count div 2;
end;
result := ExtractFileName(AFileName);
finally
Parts.Free;
end;
end;
end;
procedure TMRUMenuManager.AddToRecent(AFileName : String);
Var
I,J : Integer;
B : Boolean;
begin
AFileName:=ExpandFileName(AFileName);
With FRecent do
begin
J:=IndexOf(AFileName);
If (J<>-1) then
begin
if (J>0) then
Exchange(0,J)
end
else
begin
While (Count>=FMaxRecent) do
Delete(Count-1);
Insert(0,AFileName)
end;
end;
ShowRecentFiles;
end;
function TMRUMenuManager.CreateMenuItem(AOwner :TComponent) : TRecentMenuItem;
begin
Result:=TRecentMenuItem.Create(AOwner);
end;
function TMRUMenuManager.CreateMenuCaption(AIndex: Integer;
const AFileName: String): String;
var
fn : string;
mask : string;
begin
if FMaxItemLength > 0 then
fn := MinimizeFileName(AFileName, FMaxItemLength)
else
fn := AFileName;
if FMenuCaptionMask = '' then
mask := DEFAULT_MASK
else
mask := FMenuCaptionMask;
Result:=Format(mask, [AIndex+1,fn]);
end;
procedure TMRUMenuManager.ShowRecentFiles;
Var
I : Integer;
M : TRecentMenuItem;
begin
if Assigned(FMIRecent) then begin
FMIRecent.clear;
For I:=0 to FRecent.Count-1 do
begin
M:=CreateMenuItem(Self.Owner);
M.Caption:=CreateMenuCaption(I,FRecent[i]);
M.FFileName:=FRecent[i];
M.OnClick:=@DoOnRecentClick;
FMIRecent.Add(M);
end;
end;
if Assigned(FPMRecent) then begin
FPMRecent.Items.Clear;
for i:=0 to FRecent.Count-1 do
begin
M := CreateMenuItem(Self.Owner);
M.Caption := CreateMenuCaption(I, Recent[i]);
M.FFileName := FRecent[i];
M.OnClick := @DoOnRecentClick;
FPMRecent.Items.Add(M);
end;
end;
end;
procedure TMRUMenuManager.LoadFromIni(Ini : TCustomIniFile; ASection : String);
Var
I,Count : Integer;
FN : String;
begin
FRecent.Clear;
FMaxRecent:=Ini.ReadInteger(ASection,KeyMaxRecent,10);
Count:=Ini.ReadInteger(ASection,KeyCount,0);
For I:=1 to Count do
begin
FN:=Ini.ReadString(ASection,Format(KeyFile,[i]),'');
If (FN<>'') then
FRecent.Add(FN);
end;
end;
procedure TMRUMenuManager.GetFileNameAndSection(var AFileName, ASection: String);
begin
if (AFileName='') then
begin
AFileName:=GetAppConfigDir(False);
AFileName:=IncludeTrailingPathDelimiter(AFileName)+DefaultIniFile;
end;
if (ASection='') then
ASection:=DefaultSection;
end;
procedure TMRUMenuManager.LoadRecentFilesFromIni(Const AFileName : string = ''; Const ASection : String = '');
Var
DN,FN,Sec : String;
Ini : TIniFile;
begin
FN:=AFileName;
Sec:=ASection;
GetFileNameAndSection(FN,Sec);
DN:=ExtractFilePath(FN);
If ForceDirectories(DN) then
begin
If FileExists(FN) then
begin
Ini:=TIniFile.Create(FN);
try
LoadFromIni(Ini,Sec);
finally
Ini.Free;
end;
end;
end;
ShowRecentFiles;
end;
procedure TMRUMenuManager.SaveToIni(Ini : TCustomIniFile; ASection : String);
Var
I : Integer;
begin
Ini.EraseSection(ASection);
Ini.WriteInteger(ASection,KeyMaxRecent,FMaxRecent);
Ini.WriteInteger(ASection,KeyCount,FRecent.Count);
For I:=0 to FRecent.Count-1 do
Ini.WriteString(ASection,Format(KeyFile,[i+1]),FRecent[i]);
Ini.UpdateFile;
end;
procedure TMRUMenuManager.SaveRecentFilesToIni(Const AFileName : string = ''; Const ASection : String = '');
Var
DN,FN,Sec : String;
Ini : TMemIniFile;
begin
FN:=AFileName;
Sec:=ASection;
GetFileNameAndSection(FN,Sec);
DN:=ExtractFilePath(FN);
If not ForceDirectories(DN) then
Raise EMRUManager.CreateFmt(SErrFailedToCreateDir,[DN]);
Ini:=TMemIniFile.Create(FN);
try
SaveToIni(Ini,Sec);
finally
Ini.Free;
end;
end;
procedure TMRUMenuManager.SetIniFileName(const AValue:string);
begin
if AValue <> FIniFileName then begin
FIniFileName := AValue;
LoadRecentFilesFromIni(FIniFileName, FIniSection);
end;
end;
procedure TMRUMenuManager.SetIniSection(const AValue:string);
begin
if AValue <> FIniSection then begin
FIniSection := AValue;
LoadRecentFilesFromini(FIniFileName, FIniSection);
end;
end;
procedure TMRUMenuManager.SetMaxItemLength(const AValue:integer);
begin
if FMaxItemLength <> AValue then begin
FMaxItemLength := AValue;
ShowRecentFiles;
end;
end;
procedure TMRUMenuManager.SetMenuCaptionMask(const AValue:string);
begin
if FMenuCaptionMask <> AValue then begin
FMenuCaptionMask := AValue;
ShowRecentFiles;
end;
end;
procedure TMRUMenuManager.SetMIRecent(const AValue: TMenuItem);
begin
if FMIRecent=AValue then exit;
If Assigned(FMIRecent) then
FMIRecent.RemoveFreeNotification(Self);
FMIRecent:=AValue;
If Assigned(FMIRecent) then
FMIRecent.FreeNotification(Self);
ShowRecentFiles;
end;
procedure TMRUMenuManager.SetPMRecent(const AValue: TPopupMenu);
begin
if FPMRecent=AValue then exit;
if Assigned(FPMRecent) then
FPMRecent.RemoveFreeNotification(self);
FPMRecent := AValue;
if Assigned(FPMRecent) then
FPMRecent.FreeNotification(self);
ShowRecentFiles;
end;
procedure TMRUMenuManager.SetRecent(const AValue: TStrings);
begin
if FRecent=AValue then exit;
FRecent.Assign(AValue);
ShowRecentFiles;
end;
procedure TMRUMenuManager.loaded;
begin
inherited loaded;
if (FRecent.Count>0) and (assigned(FMIRecent) or assigned(FPMRecent))then
LoadRecentFilesFromIni(FIniFileName, FIniSection);
end;
constructor TMRUMenuManager.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FRecent:=TStringList.Create;
FMaxRecent := 10;
FMaxItemLength := 80;
FMenuCaptionMask := DEFAULT_MASK;
end;
destructor TMRUMenuManager.Destroy;
begin
SaveRecentFilesToIni(FIniFileName, FIniSection);
FreeAndNil(FRecent);
inherited Destroy;
end;
procedure TMRUMenuManager.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) then begin
if AComponent = FMIRecent then FMIRecent := nil;
if AComponent = FPMRecent then FPMRecent := nil;
end;
{ original code - I think this is not correct:
inherited Notification(AComponent, Operation);
if (Operation=opRemove) and ((AComponent=FMIRecent) or (AComponent=FPMRecent)) then
exit;
}
end;
procedure TMRUMenuManager.DoOnRecentClick(Sender: TObject);
Var
FN : String;
begin
With (Sender as TRecentMenuItem) do
FN:=FileName;
if (FN<>'') and (OnRecentFile<>Nil) then
begin
OnRecentFile(Self,FN);
AddToRecent(FN); // Gets moved to the top
end;
end;
end.

View File

@ -0,0 +1,5 @@
{ "mrumenu_demo" : {
"Category" : "Techniques",
"Keywords" : ["MRU", "most recently used", "open"],
"Description" : "Appears to demonstrate a most recently used file open behaviour. Perhaps for Operating Systems that don't have that available in their normal file manager interface ? "}
}

Binary file not shown.

View File

@ -0,0 +1,5 @@
{ "rotate_example" : {
"Category" : "Techniques",
"Keywords" : ["opengl", "graphics", "rotating cube"],
"Description" : "Demo, using OpenGL of the classic rotating colored cube. "}
}

Binary file not shown.

View File

@ -0,0 +1,5 @@
{ "usergui_example" : {
"Category" : "Techniques",
"Keywords" : ["opengl", "OpenGlContext", "Controls"],
"Description" : "Includes a unit, OpenGLContext that has a number of controls build using OpenGL and demonstrates a basic (and quite retro looking) user interface, buttons, sliders etc."}
}

View File

@ -0,0 +1,5 @@
{ "paradox_demo" : {
"Category" : "DBase",
"Keywords" : ["paradox","dbase","db","Needs Work"],
"Description" : "Appears to demonstrate basic use of Paradox Database.\nRequires the lazparadox package (in Laz SRC Tree) to be installed.\nRequires Paradox library on your system, eg on Debian pxlib1.\nGenerates a message \"unable to find TDatasource...\" despite it being in the use db unit and compiling and running fine.\n\n"}
}

View File

@ -0,0 +1,5 @@
{ "plotevent_demo" : {
"Category" : "Components",
"Keywords" : ["plotpanel","event driven","plotting data"],
"Description" : "Demonstrates plotting data obtained from a procedure. That procedure could be a Lazarus Event (but is not in the example).\n"}
}

View File

@ -0,0 +1,5 @@
{ "plotfunction_expression" : {
"Category" : "Components",
"Keywords" : ["fpexprpars", "plot", "expression"],
"Description" : "Plots a square function with adjustable values."}
}

View File

@ -0,0 +1,5 @@
{ "bufclient" : {
"Category" : "DBase",
"Keywords" : ["sqldbrest","REST","TFPhttpclient","TBufDataSet"],
"Description" : "One part of a set of demos (search for sqldbrest) demonstrating using REST to access a database. Compiles but not tested because it requires a server to connect to, possibly also provided in this set under RESTBridge ?\n\nRequires the package weblaz be installed before loading.\n\nBetter documentation would be great !"}
}

View File

@ -0,0 +1,5 @@
{ "csvclient" : {
"Category" : "DBase",
"Keywords" : ["sqldbrest","REST","TFPhttpclient","TBufDataSet","CVS"],
"Description" : "One part of a set of demos (search for sqldbrest) demonstrating using REST to access a database. Compiles but not tested because it requires a server to connect to, possibly also provided in this set under RESTBridge ?\n\nRequires the package weblaz be installed before loading.\n\nBetter documentation would be great !"}
}

View File

@ -0,0 +1,5 @@
{ "jsonclient" : {
"Category" : "DBase",
"Keywords" : ["sqldbrest","REST","TFPhttpclient","TBufDataSet","json"],
"Description" : "One part of a set of demos (search for sqldbrest) demonstrating using REST to access a database. Compiles but not tested because it requires a server to connect to, possibly also provided in this set under RESTBridge ?\n\nRequires the package weblaz be installed before loading.\n\nBetter documentation would be great !"}
}

View File

@ -0,0 +1,5 @@
{ "restbridge" : {
"Category" : "DBase",
"Keywords" : ["sqldbrest", "REST", "TFPhttpclient", "TBufDataSet", "Work Required"],
"Description" : "One part of a set of demos (search for sqldbrest) demonstrating using REST to access a database. Compiles and runs (without any GUI). Might be associated with the other sqldbrest demos but listens on 8080 and they talk 3000. Needs clarification.\n\nBetter documentation would be great !"}
}

View File

@ -0,0 +1,5 @@
{ "restmodule" : {
"Category" : "DBase",
"Keywords" : ["sqldbrest", "REST"],
"Description" : "One part of a set of demos (search for sqldbrest) demonstrating using REST to access a database. Compiles but not tested because it requires a server to connect to, possibly also provided in this set under RESTBridge ?\n\nNo GUI, just registers 'REST'.\n\nBetter documentation would be great !"}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_animate" : {
"Category" : "Components",
"Keywords" : ["TAChart", "Animated"],
"Description" : "Animate a TAChart in three different modes."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_area" : {
"Category" : "Components",
"Keywords" : ["TAChart", "Area"],
"Description" : "Demonstrates a number of different modes of Area graphs."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_axisalign" : {
"Category" : "Components",
"Keywords" : ["TAChart", "align axis"],
"Description" : "How to align the Axises of graphs in the same chart. "}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_chartsource" : {
"Category" : "Components",
"Keywords" : ["TAChart"],
"Description" : "Demonstrates TAChart with different sources."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_clone" : {
"Category" : "Components",
"Keywords" : ["TAChart", "clone", "duplicate"],
"Description" : "How to clone or duplicate the plot of a dataset. "}
}

View File

@ -0,0 +1,5 @@
{ "TaChart_db-pieseries" : {
"Category" : "Components",
"Keywords" : ["TAChart", "Pie Chart", "dbgrid"],
"Description" : "Draws a Pie Chart using data from a dbgrid."}
}

View File

@ -0,0 +1,5 @@
{ "fpvectorial" : {
"Category" : "Components",
"Keywords" : ["TaChart", "TvVectorialFormat","TFPVectorialDrawer"],
"Description" : "Uses Vectorial to display (and export) some line and block charts.\n\nNote, generates a message that it has failed to open a particular TrueTypeFont that is definitly available but works anyway. "}
}

View File

@ -0,0 +1,5 @@
{ "tachart_imagelist" : {
"Category" : "Components",
"Keywords" : ["TAchart","TAChartImagelist"],
"Description" : "Shows how to display images in a TAChart Image List in a TAChart."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_lazreport" : {
"Category" : "Components",
"Keywords" : ["TAChart","LazReport"],
"Description" : "Load a LazReport into a TAChart.\n\nRequires the package LazReport\n\n"}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_multi" : {
"Category" : "Components",
"Keywords" : ["TAChart", "Multi"],
"Description" : "Displays some Multi charts"}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_panes" : {
"Category" : "Components",
"Keywords" : ["TAChart", "Panes"],
"Description" : "Demonstrates using several panes in a TAChart."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_chartstyles" : {
"Category" : "Components",
"Keywords" : ["TAChart","Stacked Bar","runtime"],
"Description" : "This project shows how to add and delete levels to a stacked bar series at runtime. For every new level, a new chart style is created, and for every deleted level, the corresponding chart style is deleted as well.\n\nSee the associated readme.txt for more information.\n\n\n\n"}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_dualaxes" : {
"Category" : "Components",
"Keywords" : ["TAChart","Dual Axes","runtime"],
"Description" : "How to use dual axes (ie left and right) in a TAChart."}
}

View File

@ -0,0 +1,5 @@
{ "TAChart_plotunit" : {
"Category" : "Components",
"Keywords" : ["TAChart","plotunit", "runtime"],
"Description" : "The demo \"plotunit\" show how to generate a series and insert it into a chart at runtime. The main series types of TAChart are supported.\n\nSee the associated readme.txt"}
}