diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-12-02 20:25:39 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-12-02 20:25:39 +0000 |
commit | be113fdf0215c0b33aa310cfb15499aea6910d19 (patch) | |
tree | cc29299983684f1958dc97dc3f8093d6982e0d60 /extras/tiopf/demos/Demo_04_CreateDatabase | |
parent | 3bd2c57c88fb4b28fbab0aac7e95590b32ab3862 (diff) | |
download | fpGUI-be113fdf0215c0b33aa310cfb15499aea6910d19.tar.xz |
* tiOPF: Created a new Pick Database form for the demos.
* tiOPF: Created a new Demo 04 - CreateDatabase.
Diffstat (limited to 'extras/tiopf/demos/Demo_04_CreateDatabase')
-rw-r--r-- | extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpi | 71 | ||||
-rw-r--r-- | extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpr | 39 | ||||
-rw-r--r-- | extras/tiopf/demos/Demo_04_CreateDatabase/frm_main.pas | 179 |
3 files changed, 289 insertions, 0 deletions
diff --git a/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpi b/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpi new file mode 100644 index 00000000..d2059b58 --- /dev/null +++ b/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpi @@ -0,0 +1,71 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="6"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </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="2"> + <Item1> + <PackageName Value="tiOPFfpGUI"/> + </Item1> + <Item2> + <PackageName Value="fpgui_toolkit"/> + </Item2> + </RequiredPackages> + <Units Count="3"> + <Unit0> + <Filename Value="demo_04.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="demo_04"/> + </Unit0> + <Unit1> + <Filename Value="../Common/frm_pickdatabase.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="frm_pickdatabase"/> + </Unit1> + <Unit2> + <Filename Value="frm_main.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="frm_main"/> + </Unit2> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="8"/> + <SearchPaths> + <OtherUnitFiles Value="../Common/"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <CStyleOperator Value="False"/> + </SyntaxOptions> + </Parsing> + <Other> + <CustomOptions Value="-FUunits +"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpr b/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpr new file mode 100644 index 00000000..d7ff4605 --- /dev/null +++ b/extras/tiopf/demos/Demo_04_CreateDatabase/demo_04.lpr @@ -0,0 +1,39 @@ +program demo_04; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes + ,SysUtils + ,fpg_main + ,tiOPFManager + ,tiConstants + ,frm_main + ; + + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + try + frm.Show; + fpgApplication.Run; + finally + frm.Free; + gTIOPFManager.Terminate; + end; +end; + +begin + MainProc; +end. + + + diff --git a/extras/tiopf/demos/Demo_04_CreateDatabase/frm_main.pas b/extras/tiopf/demos/Demo_04_CreateDatabase/frm_main.pas new file mode 100644 index 00000000..4bd0c9ab --- /dev/null +++ b/extras/tiopf/demos/Demo_04_CreateDatabase/frm_main.pas @@ -0,0 +1,179 @@ +unit frm_main; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_button, fpg_panel; + +type + + TMainForm = class(TfpgForm) + private + {@VFD_HEAD_BEGIN: MainForm} + btnPickDB: TfpgButton; + btnCreateDB: TfpgButton; + btnDBExists: TfpgButton; + pnlDBName: TfpgPanel; + {@VFD_HEAD_END: MainForm} + FPersistenceLayerName: string; + FDatabaseName: string; + FUsername: string; + FPassword: string; + procedure PickDBClicked(Sender: TObject); + procedure DatabaseExistsClicked(Sender: TObject); + procedure CreateDatabaseClicked(Sender: TObject); + public + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +implementation + +uses + frm_pickdatabase + ,fpg_dialogs + ,tiOPFManager + ,tiPersistenceLayers + ,tiDialogs + ; + +{@VFD_NEWFORM_IMPL} + +procedure TMainForm.PickDBClicked(Sender: TObject); +var + frm: TPickDatabaseForm; +begin + frm := TPickDatabaseForm.Create(nil); + try + if frm.ShowModal = mrOK then + begin + FPersistenceLayerName := frm.PersistenceLayerName; + FDatabaseName := frm.DatabaseName; + FUsername := frm.UserName; + FPassword := frm.Password; + pnlDBName.Text := frm.DatabaseName; + end; + finally + frm.Free; + end; +end; + +procedure TMainForm.DatabaseExistsClicked(Sender: TObject); +var + LPerLayer: TtiPersistenceLayer; +begin + LPerLayer:= GTIOPFManager.PersistenceLayers.FindByPersistenceLayerName(FPersistenceLayerName); + Assert(LPerLayer<>nil, '"' + FPersistenceLayerName + '" not registered'); + if LPerLayer.DatabaseExists(FDatabaseName, FUserName, FPassword) + then + tiAppMessage('Database <' + FDatabaseName + '> exists.') + else + tiAppWarning('Database <' + FDatabaseName + '> does not exist.'); +end; + +procedure TMainForm.CreateDatabaseClicked(Sender: TObject); +var + LPerLayer: TtiPersistenceLayer; +begin + LPerLayer:= GTIOPFManager.PersistenceLayers.FindByPersistenceLayerName(FPersistenceLayerName); + Assert(LPerLayer<>nil, '"' + FPersistenceLayerName + '" not registered'); + LPerLayer.CreateDatabase(FDatabaseName, FUserName, FPassword); + tiAppMessage('Database "' + FDatabaseName + '" has been created.'); +end; + +procedure TMainForm.AfterCreate; +begin + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(312, 189, 359, 182); + WindowTitle := 'Demo 04 - Create Database'; + WindowPosition := wpScreenCenter; + + btnPickDB := TfpgButton.Create(self); + with btnPickDB do + begin + Name := 'btnPickDB'; + SetPosition(108, 20, 144, 24); + Text := 'Pick Database'; + AllowAllUp := False; + Embedded := False; + Flat := False; + FontDesc := '#Label1'; + GroupIndex := 0; + Hint := ''; + ImageLayout := ilImageLeft; + ImageMargin := 3; + ImageName := ''; + ImageSpacing := -1; + ModalResult := 0; + ParentShowHint := True; + ShowImage := True; + TabOrder := 0; + OnClick := @PickDBClicked; + end; + + btnCreateDB := TfpgButton.Create(self); + with btnCreateDB do + begin + Name := 'btnCreateDB'; + SetPosition(108, 96, 136, 24); + Text := 'Create Database'; + AllowAllUp := False; + Embedded := False; + Flat := False; + FontDesc := '#Label1'; + GroupIndex := 0; + Hint := ''; + ImageLayout := ilImageLeft; + ImageMargin := 3; + ImageName := ''; + ImageSpacing := -1; + ModalResult := 0; + ParentShowHint := True; + ShowImage := True; + TabOrder := 1; + OnClick := @CreateDatabaseClicked; + end; + + btnDBExists := TfpgButton.Create(self); + with btnDBExists do + begin + Name := 'btnDBExists'; + SetPosition(108, 128, 136, 24); + Text := 'Database Exists'; + AllowAllUp := False; + Embedded := False; + Flat := False; + FontDesc := '#Label1'; + GroupIndex := 0; + Hint := ''; + ImageLayout := ilImageLeft; + ImageMargin := 3; + ImageName := ''; + ImageSpacing := -1; + ModalResult := 0; + ParentShowHint := True; + ShowImage := True; + TabOrder := 2; + OnClick := @DatabaseExistsClicked; + end; + + pnlDBName := TfpgPanel.Create(self); + with pnlDBName do + begin + Name := 'pnlDBName'; + SetPosition(12, 56, 336, 32); + Anchors := [anLeft,anRight,anTop]; + ParentShowHint := True; + Style := bsLowered; + Text := '---'; + end; + + {@VFD_BODY_END: MainForm} +end; + + +end. |