diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-10-14 12:29:19 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-10-14 12:29:19 +0200 |
commit | ff7f64d95ca92b644e0d66e2195a69344895b2ce (patch) | |
tree | d822b50e87cb21b6820e31c4e07a520d3113b89e /extras/tiopf/demos/Demo_07_VisitorBasics | |
parent | ce211febcabb02606c0d5b45b4c8502a76d6ae58 (diff) | |
download | fpGUI-ff7f64d95ca92b644e0d66e2195a69344895b2ce.tar.xz |
Moved tiOPF related units into the tiOPF repository.
It makes more sense to have the tiOPF related units with the
rest of the tiOPF. It's easier to keep changes in sync, and have
atomic commits across the various GUI toolkits supported by tiOPF.
Diffstat (limited to 'extras/tiopf/demos/Demo_07_VisitorBasics')
4 files changed, 0 insertions, 321 deletions
diff --git a/extras/tiopf/demos/Demo_07_VisitorBasics/Client_BOM.pas b/extras/tiopf/demos/Demo_07_VisitorBasics/Client_BOM.pas deleted file mode 100644 index 49195b48..00000000 --- a/extras/tiopf/demos/Demo_07_VisitorBasics/Client_BOM.pas +++ /dev/null @@ -1,81 +0,0 @@ -unit Client_BOM; - -interface -uses - tiObject - ,tiOID - ,tiOIDGUID - ,tiVisitor - ; - -type - - TClient = class; - TClientList = class; - - TClientName = String[200]; - TClientID = String[9]; - - TClientList = class(TtiObjectList); - - - TClient = class(TtiObject) - private - FClientID: TClientID; - FClientName: TClientName; - published - property ClientName: TClientName read FClientName write FClientName; - property ClientID : TClientID read FClientID write FClientID; - end; - - - TClientVisitor = class(TtiVisitor) - protected - function AcceptVisitor: boolean; override; - public - procedure Execute(const AVisited: TtiVisited); override; - end; - - -procedure RegisterMappings; - - -implementation -uses - tiOPFManager - ,tiAutoMap - ,tiConstants - ,tiDialogs - ; - -procedure RegisterMappings; -begin - // Class, Table, Property, Column, Special Info - gTIOPFManager.ClassDBMappingMgr.RegisterMapping(TClient, 'Client', 'OID', 'OID', [pktDB]); - gTIOPFManager.ClassDBMappingMgr.RegisterMapping(TClient, 'Client', 'ClientName', 'Client_Name' ); - gTIOPFManager.ClassDBMappingMgr.RegisterMapping(TClient, 'Client', 'ClientID', 'Client_ID' ); - gTIOPFManager.ClassDBMappingMgr.RegisterCollection(TClientList, TClient); -end; - -{ TClientVisitor } - -function TClientVisitor.AcceptVisitor: boolean; -begin - // Put the code to check if this visitor should act on this object in here. - Result:= Visited is TClient; - // Remove this line and the visitor will touch the TClientList object - // as well as it's owned TClient objects. -end; - -procedure TClientVisitor.Execute(const AVisited: TtiVisited); -begin - inherited; - if not AcceptVisitor then - Exit; - tiShowMessage((Visited as TtiObject).AsDebugString); -end; - -end. - - - diff --git a/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpi b/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpi deleted file mode 100644 index 10179042..00000000 --- a/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpi +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0"?> -<CONFIG> - <ProjectOptions> - <Version Value="7"/> - <General> - <Flags> - <SaveOnlyProjectUnits Value="True"/> - <MainUnitHasCreateFormStatements Value="False"/> - <MainUnitHasTitleStatement Value="False"/> - <LRSInOutputDirectory Value="False"/> - </Flags> - <SessionStorage Value="InProjectDir"/> - <MainUnit Value="0"/> - <TargetFileExt Value=""/> - </General> - <VersionInfo> - <ProjectVersion Value=""/> - </VersionInfo> - <PublishOptions> - <Version Value="2"/> - <IgnoreBinaries Value="False"/> - <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> - <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> - </PublishOptions> - <RunParams> - <local> - <FormatVersion Value="1"/> - <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> - </local> - </RunParams> - <RequiredPackages Count="1"> - <Item1> - <PackageName Value="tiOPFfpGUI"/> - </Item1> - </RequiredPackages> - <Units Count="3"> - <Unit0> - <Filename Value="demo_07.lpr"/> - <IsPartOfProject Value="True"/> - <UnitName Value="demo_07"/> - </Unit0> - <Unit1> - <Filename Value="frm_main.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="frm_main"/> - </Unit1> - <Unit2> - <Filename Value="Client_BOM.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="Client_BOM"/> - </Unit2> - </Units> - </ProjectOptions> - <CompilerOptions> - <Version Value="8"/> - <SearchPaths> - <UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/> - </SearchPaths> - <Parsing> - <SyntaxOptions> - <AllowLabel Value="False"/> - <CPPInline Value="False"/> - </SyntaxOptions> - </Parsing> - <Other> - <CustomOptions Value="-dUseCThreads"/> - <CompilerPath Value="$(CompPath)"/> - </Other> - </CompilerOptions> -</CONFIG> diff --git a/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpr b/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpr deleted file mode 100644 index 125dd248..00000000 --- a/extras/tiopf/demos/Demo_07_VisitorBasics/demo_07.lpr +++ /dev/null @@ -1,39 +0,0 @@ -program demo_07; - -{$mode objfpc}{$H+} - -uses - {$IFDEF UNIX}{$IFDEF UseCThreads} - cthreads, - {$ENDIF}{$ENDIF} - Classes, fpg_main, frm_main, tiOIDGUID, tiOPFManager, Client_BOM; - - -procedure MainProc; -var - frm: TMainForm; -begin - fpgApplication.Initialize; - - // Change the connection string to suite your database location - // ** Remote connection - //gTIOPFManager.ConnectDatabase('192.168.0.54|/home/graemeg/programming/data/tiopf.fdb', 'sysdba', 'masterkey'); - // ** Local connection - //gTIOPFManager.ConnectDatabase('/home/graemeg/programming/data/tiopf.fdb', 'sysdba', 'masterkey'); - - frm := TMainForm.Create(nil); - try - frm.Show; - fpgApplication.Run; - finally - frm.Free; - //gTIOPFManager.DisconnectDatabase; - //gTIOPFManager.Terminate; - end; -end; - -begin - MainProc; -end. - - diff --git a/extras/tiopf/demos/Demo_07_VisitorBasics/frm_main.pas b/extras/tiopf/demos/Demo_07_VisitorBasics/frm_main.pas deleted file mode 100644 index 8a10f2df..00000000 --- a/extras/tiopf/demos/Demo_07_VisitorBasics/frm_main.pas +++ /dev/null @@ -1,131 +0,0 @@ -unit frm_main; - -{$mode objfpc}{$H+} - -interface - -uses - SysUtils, Classes, - fpg_main, fpg_form, fpg_button, - Client_BOM; - -type - - TMainForm = class(TfpgForm) - private - FClientList: TClientList; - procedure btnAddClientClick(Sender: TObject); - procedure btnShowListClick(Sender: TObject); - procedure btnRunClientVisitorClick(Sender: TObject); - public - {@VFD_HEAD_BEGIN: MainForm} - btnAddClient: TfpgButton; - btnShowList: TfpgButton; - btnRunClientVisitor: TfpgButton; - {@VFD_HEAD_END: MainForm} - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure AfterCreate; override; - end; - -{@VFD_NEWFORM_DECL} - -implementation - -uses - tiUtils - ,tiDialogs - ,tiOPFManager - ; - -{@VFD_NEWFORM_IMPL} - -procedure TMainForm.btnAddClientClick(Sender: TObject); -var - lClient: TClient; -begin - lClient := TClient.Create; - lClient.OID.AsString := IntToStr(tiGetTickCount); // Not how you do it in real life! - lClient.ClientName := 'Test ' + DateTimeToStr(Now); - lClient.ClientID := IntToStr(tiGetTickCount); - FClientList.Add(lClient); -end; - -procedure TMainForm.btnShowListClick(Sender: TObject); -begin - tiShowString(FClientList.AsDebugString); -end; - -procedure TMainForm.btnRunClientVisitorClick(Sender: TObject); -var - lVis: TClientVisitor; -begin - lVis := TClientVisitor.Create; - try - FClientList.Iterate(lVis); - finally - lVis.Free; - end; -end; - -constructor TMainForm.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - FClientList := TClientList.Create; -end; - -destructor TMainForm.Destroy; -begin -// FClientList.Save; - FClientList.Free; - inherited Destroy; -end; - -procedure TMainForm.AfterCreate; -begin - {@VFD_BODY_BEGIN: MainForm} - Name := 'MainForm'; - SetPosition(854, 117, 244, 166); - WindowTitle := 'Visitor Basics'; - WindowPosition := wpScreenCenter; - Sizeable := False; - - btnAddClient := TfpgButton.Create(self); - with btnAddClient do - begin - Name := 'btnAddClient'; - SetPosition(68, 24, 107, 24); - Text := 'Add client'; - FontDesc := '#Label1'; - ImageName := ''; - OnClick := @btnAddClientClick; - end; - - btnShowList := TfpgButton.Create(self); - with btnShowList do - begin - Name := 'btnShowList'; - SetPosition(68, 56, 107, 24); - Text := 'Show list'; - FontDesc := '#Label1'; - ImageName := ''; - OnClick := @btnShowListClick; - end; - - btnRunClientVisitor := TfpgButton.Create(self); - with btnRunClientVisitor do - begin - Name := 'btnRunClientVisitor'; - SetPosition(68, 88, 107, 24); - Text := 'Run client visitor'; - FontDesc := '#Label1'; - ImageName := ''; - OnClick := @btnRunClientVisitorClick; - end; - - {@VFD_BODY_END: MainForm} -end; - - -end. - |