From a123ccb4f7399bf0a4598bc1111f9ae5dd8e528b Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 15 Mar 2018 21:27:45 +0000 Subject: [PATCH] jvcllaz: Add JvDBSearchEdit (incl demo) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6247 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jvcllaz/design/JvDB/JvDBReg.pas | 32 +- .../jvcllaz/design/JvDB/images/images.txt | 3 + .../JvDB/images/tjvdbsearchcombobox.bmp | Bin 0 -> 1782 bytes .../design/JvDB/images/tjvdbsearchedit.bmp | Bin 0 -> 1654 bytes .../design/JvDB/images/tjvdbtreeview.bmp | Bin 0 -> 1654 bytes .../JvDBSearchEdit/JvSearchEditDemo.lpi | 69 ++++ .../JvDBSearchEdit/JvSearchEditDemo.lpr | 21 ++ .../jvcllaz/examples/JvDBSearchEdit/main.lfm | 112 +++++++ .../jvcllaz/examples/JvDBSearchEdit/main.pas | 110 +++++++ components/jvcllaz/packages/JvDBLazD.lpk | 11 +- components/jvcllaz/packages/JvDBLazR.lpk | 10 +- components/jvcllaz/resource/jvdbreg.res | Bin 1728 -> 6960 bytes .../jvcllaz/run/JvDB/JvDBSearchEdit.pas | 306 ++++++++++++++++++ .../jvcllaz/run/JvJans/JvYearGridEditForm.pas | 3 + 14 files changed, 668 insertions(+), 9 deletions(-) create mode 100644 components/jvcllaz/design/JvDB/images/tjvdbsearchcombobox.bmp create mode 100644 components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp create mode 100644 components/jvcllaz/design/JvDB/images/tjvdbtreeview.bmp create mode 100644 components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpi create mode 100644 components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpr create mode 100644 components/jvcllaz/examples/JvDBSearchEdit/main.lfm create mode 100644 components/jvcllaz/examples/JvDBSearchEdit/main.pas create mode 100644 components/jvcllaz/run/JvDB/JvDBSearchEdit.pas diff --git a/components/jvcllaz/design/JvDB/JvDBReg.pas b/components/jvcllaz/design/JvDB/JvDBReg.pas index 3a81cb7bc..cd1c036b7 100644 --- a/components/jvcllaz/design/JvDB/JvDBReg.pas +++ b/components/jvcllaz/design/JvDB/JvDBReg.pas @@ -5,7 +5,7 @@ unit JvDBReg; interface uses - SysUtils; + SysUtils, PropEdits, DBPropEdits; procedure Register; @@ -14,14 +14,38 @@ implementation {$R ../../resource/jvdbreg.res} uses - Classes, JvDsgnConsts, JvDBHTLabel; + Classes, JvDsgnConsts, JvDBSearchEdit, JvDBHTLabel; //, JvDBTreeView; procedure Register; +const +// cDataField = 'DataField'; +// cKeyField = 'KeyField'; +// cListField = 'ListField'; +// cDisplayField = 'DisplayField'; +// cListKeyField = 'ListKeyField'; + cMasterField = 'MasterField'; + cDetailField = 'DetailField'; + cIconField = 'IconField'; + cItemField = 'ItemField'; +// cLookupField = 'LookupField'; +// cSectionField = 'SectionField'; +// cValueField = 'ValueField'; +// cEditControls = 'EditControls'; +// cSortedField = 'SortedField'; +// cSortMarker = 'SortMarker'; + begin - RegisterComponents(RsPaletteJvclDB, [ + RegisterComponents(RsPaletteJvclDB, [ // was: TsPaletteDBVisual + TJvDBSearchEdit, TJvDBHtLabel + // TJvDBTreeView ]); - //RegisterComponents(RsPaletteDBVisual, [TJvDBHTLabel]); + (* + RegisterPropertyEditor(TypeInfo(string), TJvDBTreeView, cItemField, TFieldProperty); //TJvDataFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TJvDBTreeView, cMasterField, TFieldProperty); //TJvDataFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TJvDBTreeView, cDetailField, TFieldProperty); //TJvDataFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TJvDBTreeView, cIconField, TFieldProperty); //TJvDataFieldProperty); + *) end; end. diff --git a/components/jvcllaz/design/JvDB/images/images.txt b/components/jvcllaz/design/JvDB/images/images.txt index 1259da72d..d41b912a5 100644 --- a/components/jvcllaz/design/JvDB/images/images.txt +++ b/components/jvcllaz/design/JvDB/images/images.txt @@ -1 +1,4 @@ tjvdbhtlabel.bmp +tjvdbsearchcombobox.bmp +tjvdbsearchedit.bmp +tjvdbtreeview.bmp diff --git a/components/jvcllaz/design/JvDB/images/tjvdbsearchcombobox.bmp b/components/jvcllaz/design/JvDB/images/tjvdbsearchcombobox.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d86fcf4fac56c9152e5a2b1656b3763cc34362c6 GIT binary patch literal 1782 zcmb`H!EwYO3`Lbo3dkuXq=FQXd%8&hl(MBz3RUFlJoK^H1rpmcVPr-a@%RGSAD`dP z=Ix#SjpwyJPwtsz=D%L_cpzQ2VukL|ZdR&onR>=r&Fy@2GM&Rwr1Xy*a{JrZYt|!G^h{mV18-#; zoRf`B$L7UZOVqEs&(<=K=n;>v# zDh3>8!k;UIB?D)GIIPm7Cx&ujICF-8h{Ta3oJ)ELjwPbOk)x^brFNNDKoqS0ydE6_ zJshEe!%KX<9HtnK=i^r!zx4bAWF_Xz literal 0 HcmV?d00001 diff --git a/components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp b/components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c6bfee07e32d63ed23561177aba1073332e8eac5 GIT binary patch literal 1654 zcmZ|NF>V|&3_wvjh_k6vrDT~C#MSN)>2n7jB1p}nuvp|A>;mKrDR>0;2E6%_2Jza4 zHS>mAN~@7H`u6?j2btyTdyy~HKJRYiw!3QdLraOYZ;t z5>bPL22B)N!~_Z|<_IJTE#d-&fgc`76ncNJ5)F<(qR=8#B^3roAW>*0DNq<3fkdH2 zxTO^aM<7vXF=3jb7?&fEDD+yID$(EwBnrKjZAvsa0*OMeEpa6p9Dzik*LH;x4URyf z&}%DGi3Ud?QRubJr9^`xkSO&01lCG4I0A`6OR)YB#aOvxT!}(Us6b(G1QLZ_pUsqL za0C*CUZ2#JXmA7)g0i`JRTo!S2>-|G(Q#c4-Yhvm%~+g zyd}%Mk*D_3M&qF*+X(XIf`vjlVI$nSL=JW;$p7Z2osFV0;4>v4$A`Je*H=t6{rZ>!_07 L8|MG^2V3^k|P ztm2g&$KSsH_$ae|J&Anb?(@w%`84zPeui~n0M<7vX3En?MG2YxUjzpm)RG=_80*OMe&t^(AI0A`6 zuTSbqG&ll@La)!wAQ1*fAW`VG6;g=?M<7w?wM|Ni21g)K=(&ZWm1uAT5`~uH{Yw-E zM<6kdURz6*XmA7)g9j-gxZx z+FO3qUQM=blgt17>dz89Hu2kNszh*!4qyN)&-$r)K=+;=&nSabu=Q#fL zpT%yMS)V%e-?oE;>#@)E~)CGvpk1 X+sLm6=g00NKOdaW=ecwb7wY^4kzH3( literal 0 HcmV?d00001 diff --git a/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpi b/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpi new file mode 100644 index 000000000..4288de503 --- /dev/null +++ b/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpi @@ -0,0 +1,69 @@ + + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <DestinationDirectory Value=""/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="1"> + <Mode0 Name="default"/> + </Modes> + </RunParams> + <RequiredPackages Count="3"> + <Item1> + <PackageName Value="JvDBLazR"/> + </Item1> + <Item2> + <PackageName Value="FCL"/> + </Item2> + <Item3> + <PackageName Value="LCL"/> + </Item3> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="JvSearchEditDemo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="main.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="..\..\bin\JvSearchEditDemo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> +</CONFIG> diff --git a/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpr b/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpr new file mode 100644 index 000000000..c6550195f --- /dev/null +++ b/components/jvcllaz/examples/JvDBSearchEdit/JvSearchEditDemo.lpr @@ -0,0 +1,21 @@ +program JvSearchEditDemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, main + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/jvcllaz/examples/JvDBSearchEdit/main.lfm b/components/jvcllaz/examples/JvDBSearchEdit/main.lfm new file mode 100644 index 000000000..66d9e6bd7 --- /dev/null +++ b/components/jvcllaz/examples/JvDBSearchEdit/main.lfm @@ -0,0 +1,112 @@ +object Form1: TForm1 + Left = 680 + Height = 340 + Top = 320 + Width = 408 + Caption = 'DBSearchEdit demo' + ClientHeight = 340 + ClientWidth = 408 + OnCreate = FormCreate + LCLVersion = '1.9.0.0' + object Panel1: TPanel + Left = 0 + Height = 39 + Top = 0 + Width = 408 + Align = alTop + AutoSize = True + BevelOuter = bvNone + ClientHeight = 39 + ClientWidth = 408 + TabOrder = 0 + object JvDBSearchEdit1: TJvDBSearchEdit + AnchorSideLeft.Control = Label1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Panel1 + AnchorSideRight.Control = CheckBox1 + Left = 76 + Height = 23 + Top = 8 + Width = 184 + DataSource = DataSource1 + DataResult = 'OK' + DataField = 'Name' + ClearOnEnter = False + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 7 + BorderSpacing.Top = 8 + BorderSpacing.Right = 16 + BorderSpacing.Bottom = 8 + TabOrder = 0 + Text = 'JvDBSearchEdit1' + end + object Label1: TLabel + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = JvDBSearchEdit1 + AnchorSideTop.Side = asrCenter + Left = 16 + Height = 15 + Top = 12 + Width = 53 + BorderSpacing.Left = 16 + Caption = 'Search for' + ParentColor = False + end + object CheckBox1: TCheckBox + AnchorSideTop.Control = JvDBSearchEdit1 + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + Left = 276 + Height = 19 + Top = 10 + Width = 116 + Anchors = [akTop, akRight] + BorderSpacing.Right = 16 + Caption = 'Clear on get focus' + OnChange = CheckBox1Change + TabOrder = 1 + end + end + object DBGrid1: TDBGrid + Left = 0 + Height = 301 + Top = 39 + Width = 408 + Align = alClient + Color = clWindow + Columns = <> + DataSource = DataSource1 + Options = [dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgDisableInsert] + ReadOnly = True + TabOrder = 1 + end + object BufDataset1: TBufDataset + FieldDefs = <> + left = 104 + top = 96 + object BufDataset1Name: TStringField + FieldKind = fkData + FieldName = 'Name' + Index = 0 + LookupCache = False + ProviderFlags = [pfInUpdate, pfInWhere] + ReadOnly = False + Required = False + end + object BufDataset1Birthdate: TDateField + FieldKind = fkData + FieldName = 'Birthdate' + Index = 1 + LookupCache = False + ProviderFlags = [pfInUpdate, pfInWhere] + ReadOnly = False + Required = False + end + end + object DataSource1: TDataSource + DataSet = BufDataset1 + left = 104 + top = 184 + end +end diff --git a/components/jvcllaz/examples/JvDBSearchEdit/main.pas b/components/jvcllaz/examples/JvDBSearchEdit/main.pas new file mode 100644 index 000000000..2da3077f0 --- /dev/null +++ b/components/jvcllaz/examples/JvDBSearchEdit/main.pas @@ -0,0 +1,110 @@ +unit main; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, BufDataset, db, FileUtil, Forms, Controls, Graphics, + Dialogs, ExtCtrls, StdCtrls, DBGrids, Buttons, JvDBSearchEdit; + +type + + { TForm1 } + + TForm1 = class(TForm) + BufDataset1: TBufDataset; + BufDataset1Birthdate: TDateField; + BufDataset1Name: TStringField; + CheckBox1: TCheckBox; + DataSource1: TDataSource; + DBGrid1: TDBGrid; + JvDBSearchEdit1: TJvDBSearchEdit; + Label1: TLabel; + Panel1: TPanel; + procedure CheckBox1Change(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + + public + + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +function RandomBirthDate: TDate; +begin + Result := Date() - Random(20*365) - 10; +end; + +{ TForm1 } + +procedure TForm1.CheckBox1Change(Sender: TObject); +begin + JvDBSearchEdit1.ClearOnEnter := Checkbox1.Checked; +end; + +procedure TForm1.FormCreate(Sender: TObject); +begin + with BufDataset1 do + begin + CreateDataset; + + // Add records + Append; + BufDataset1Name.AsString := 'Johnny'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Tom'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Dick'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'John'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Jack'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Michael'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Robert'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Harry'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + Append; + BufDataset1Name.AsString := 'Henry'; + BufDataset1BirthDate.AsDateTime := RandomBirthdate; + Post; + + // Index + IndexFieldNames := 'Name'; + end; +end; + +end. + diff --git a/components/jvcllaz/packages/JvDBLazD.lpk b/components/jvcllaz/packages/JvDBLazD.lpk index 05241fd02..fc8cd21e2 100644 --- a/components/jvcllaz/packages/JvDBLazD.lpk +++ b/components/jvcllaz/packages/JvDBLazD.lpk @@ -24,16 +24,19 @@ <UnitName Value="JvDBReg"/> </Item1> </Files> - <RequiredPkgs Count="3"> + <RequiredPkgs Count="4"> <Item1> - <PackageName Value="JvCoreLazD"/> + <PackageName Value="IDEIntf"/> </Item1> <Item2> - <PackageName Value="JvDBLazR"/> + <PackageName Value="JvCoreLazD"/> </Item2> <Item3> - <PackageName Value="FCL"/> + <PackageName Value="JvDBLazR"/> </Item3> + <Item4> + <PackageName Value="FCL"/> + </Item4> </RequiredPkgs> <UsageOptions> <UnitPath Value="$(PkgOutDir)"/> diff --git a/components/jvcllaz/packages/JvDBLazR.lpk b/components/jvcllaz/packages/JvDBLazR.lpk index bee7953ae..08e20eb31 100644 --- a/components/jvcllaz/packages/JvDBLazR.lpk +++ b/components/jvcllaz/packages/JvDBLazR.lpk @@ -16,11 +16,19 @@ - Hypertext components "/> <License Value="The JVCL is released in accordance with the MPL 1.1 license. To get your own copy or read it, go to http://www.mozilla.org/MPL/MPL-1.1.html. "/> <Version Major="1" Release="4"/> - <Files Count="1"> + <Files Count="3"> <Item1> <Filename Value="..\run\JvDB\JvDBHTLabel.pas"/> <UnitName Value="JvDBHTLabel"/> </Item1> + <Item2> + <Filename Value="..\run\JvDB\JvDBTreeView.pas"/> + <UnitName Value="JvDBTreeView"/> + </Item2> + <Item3> + <Filename Value="..\run\JvDB\JvDBSearchEdit.pas"/> + <UnitName Value="JvDBSearchEdit"/> + </Item3> </Files> <RequiredPkgs Count="3"> <Item1> diff --git a/components/jvcllaz/resource/jvdbreg.res b/components/jvcllaz/resource/jvdbreg.res index 112eae93338080e0f6bde5bac25450528bea7d68..6c52bef04ef04066f1fbe77f75a79d848d905d7d 100644 GIT binary patch literal 6960 zcmeI$ziuPR5y0Wv!}@5z$-$Asf+N3y99UA_9|5-Eg8}<+cG#gGzz<N5QUT%TsLX($ z!9j%%FBMie`q$m$%#fmXwZMkg<i~E+G;4Z>!)Y}|L==a^MDwit<8zVU5;+_`lken@ z^1XZ`U&-%j|4F{2^+0_pUwm<DiTsA<ua4fx&&LM)Oyt+UnB)ziZWI^cDekl4m8N8- z<bP9s_|Lx>q@jTg8c39g2^2J}!4XK5NE0Xw{LvhNL>>35)P@E}AW<STB@~7RM<7uQ zQlKz2I0A_h;VGpsG&ll@5)+0givDPD1QIn5O_kcv;0PpY9=0j9p}`SI)I23ksSOQ| zK%(a9a-}vjI0A{9r!th<(BKFpYM$m)YD0q~kf`wySShuk!4XK5ILGgz=tthrAAv-P zt3Y9Ba0C)HKQ>cpLxUrbsQHmLr8YD;0*RU*H#>1RG&ll@nwLT-wV}ZgNYuPcQmG9M zjzFTuCFG^lh6YC<QIZ^gio(#~2=qtIOG}m7(BKFpYF>7x)P@E}AW`#@Y)Wlta0C)H zFIQJ;LxUrbsCg-eQX3i^fke&AJeAte;0XEQ-9h&BbMkTb7|(u_p#>h}eshq2-)+k6 z?d^|0n`INFIpXi$vFSX1M}ML`?=Lni@rw;3fA4>PzF`wT+pvvqH=M>vo~NfBJKsG$ z-Q7Jt{&+0J_fLD?!E2B2c8@y_<CZu*N8w$MkJE_vL_HhHPVu|me<T`d*7#kI@7Te9 z?EILYclLNs^z_sZkT|>TWyDFsTiDR^&obhDMC|(h{vu8y(p-s;;CMO9vxb+myA93u ze8<fT8*X0MaPz{3|9vj<O~0nj=BK~PgM2A}k*}GlzLr1BxAGOQ-QVfk%gb|BpS47i zy#M^=Gy**))o<G$en!8;S8$CxUw~)NHA5fwYsxWC|JEE1OTy=QT<H1YbB<@pur}&+ zTpu%@_3fu2F`vz^`{{&zpuRXiYr>J|HRpvs?Bm5eoC^0(nCCs`c5b>lp7rzk`0;RP z*PaKC>y_ooXD}|#eu<8cd+pFKgZa$$()z&F9^+E4%T#Mp`IuB=@0(F^jLD2L%1k-i z?|B`&8+kaEQRqyPS?0w+n=MQG`4z%jF7jL?S+dQMEPu|%^5^qB7af+KH0F?KeAIa8 zyu4**BhPHiO-q|UpO0rA*OFv*p0BST&pZjdl4qt`^1LTMJ=uD8p2tTvvn?5D^ll&Z zdCkjseBEZY`AU-QpI6&`JbAi)W}frg8t=L|#*06X1D<)FrJ6U%tGm7$JdTGv*HWFn zu$KcqkLNha+1GNv8z*wRmfOyi56q>1U~M<c%X8$qo?GU~H^(=P$~n<A_}E6pD^20V z{Is4^Vcn)MG&ll@5;K9q(BKFpN(ez=XmA7)C3J_v(BKFpN=OBTp}`SI6l*qt!qDId zB#JegKw)Tb1QI3e9tuN4e*_Z6noXcEG&ll@V$CK{7#bXbM6qTQC=3mbK%&NV=Iq2t z<aBm-1QNxXO`tF|I0A_hx<O%Ra0C*?noXcEG&lkYzNEr+E($|~BhVkknoXcEG&ll@ zV$CK{7#bXbM6qTQC=3mbK%yjFpfEHz0*PYHCQuj}9Dzjf9Tg}H4USK-p4)SqTnp=` z<9co{yG>cvZFl=VLCd`D?+#1+e#HB~MU)<=jP>00xV+F`<TC$UclP+UoYr%!W}g?< zb7MivTIRG4nl<aWv7u)=+roOTZ`kkl>}Hd&ug`jTx8tBVHmY9sBR;}x+0!`mb9Ic5 zW)I1;{ynhUab|n}H4owbrt|&`qj%oz_G}%Eng5;vj_}2J80i@K+4$$Ot)IL7Owr%D z+uxm*ZJT55P2$%Vde?t%{EoHU1CQ^SogU<G#}DW=^V6~G{H^iL=`R=I$qivvywc=4 z&!6Te73Lv@p}`SI6myV3VQ6p!62%-OP#78<fkZI}2^59~M<7u`DkuyMjzFTAg9Hjg zgCmeA<{*K>(BKFpO4vOVhKBwKB#JpmpfEHz0*PV{5-1D}jzFTAg9HjggCmfrah*9k zaS}P5-5r5MF$W10h6YC<QOrRCg`vR_NECCBKw)Tb1QI2@9STE(BhVkk93)T}8XSQ{ zF$W10h6YC<QOrRCg`vR_NECCBKw)Tb1QNv@Bv2R{9Dzjf9Tg}H4USJSKXISl%Tm_) zsmJHt`0d-b>pawN>pjlR?CoI_?=!)O9}ctsX@2Uz1@`_k*E(-8cZ_)Neb~%r%m_11 z_G6q><7cz|*z4@S{@&R8_jepipH^l3emLVZKU3;ie2%`qWgPnL{kT#0JZJsy?wPWP zZu65#h@VHtuN5QS`)|w0Kl}G-sm~I9Vmg+QpHVCm-x4SPsehmNmN@x0{ZA9{9RIrC f)69I+$ImY31h*T%g7#E5YuC~0=Xb<kn4kU+`Zt@0 delta 7 OcmdmBc7S)o0X6^)r2{Ge diff --git a/components/jvcllaz/run/JvDB/JvDBSearchEdit.pas b/components/jvcllaz/run/JvDB/JvDBSearchEdit.pas new file mode 100644 index 000000000..daf1dda84 --- /dev/null +++ b/components/jvcllaz/run/JvDB/JvDBSearchEdit.pas @@ -0,0 +1,306 @@ +{----------------------------------------------------------------------------- +The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/MPL-1.1.html + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for +the specific language governing rights and limitations under the License. + +The Original Code is: JvDBSearchEdit.pas, released on 2004-02-28. + +The Initial Developer of the Original Code is Lionel Reynaud +Portions created by Sébastien Buysse are Copyright (C) 2004 Lionel Reynaud. +All Rights Reserved. + +Contributor(s): + +You may retrieve the latest version of this file at the Project JEDI's JVCL home page, +located at http://jvcl.delphi-jedi.org + +Known Issues: + +Description: +// DB Component to find record with Edit +// Free modified and corrected component TDBSearchEdit from Alexander Burlakov +-----------------------------------------------------------------------------} +// $Id$ + +unit JvDBSearchEdit; + + +interface + +uses +// Windows, +// Messages, + LCLType, LCLIntf, LMessages, + Classes, Controls, StdCtrls, DB, DBCtrls; +// JvEdit; + +type + TJvDBCustomSearchEdit = class(TCustomEdit) //JvCustomEdit) + private + FDataLink: TFieldDataLink; + FSearchOptions: TLocateOptions; + FClearOnEnter: Boolean; + FDataResult: string; + FRaiseLocateException: Boolean; + procedure DataChange(Sender: TObject); + function GetDataSource: TDataSource; + function GetDataField: string; + procedure SetDataSource(Value: TDataSource); + procedure SetDataField(const Value: string); + procedure SetSearchOptions(const Value: TLocateOptions); + procedure CMChanged(var Msg: TLMessage); message CM_CHANGED; + protected + procedure DoEnter; override; + procedure DoExit; override; + procedure KeyPress(var Key: Char); override; + procedure Notification(Component: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetResult: Variant; + property SearchOptions: TLocateOptions read FSearchOptions + write SetSearchOptions default [loCaseInsensitive, loPartialKey]; + published + property DataSource: TDataSource read GetDataSource write SetDataSource; + property DataResult: string read FDataResult write FDataResult; + property DataField: string read GetDataField write SetDataField; + property TabStop default True; + property ClearOnEnter: Boolean read FClearOnEnter write FClearOnEnter default True; + //1 Property to raise/hide any exception inside the Dataset.Locate call + property RaiseLocateException: Boolean read FRaiseLocateException write FRaiseLocateException default true; + end; + + {$IFDEF RTL230_UP} + [ComponentPlatformsAttribute(pidWin32 or pidWin64)] + {$ENDIF RTL230_UP} + TJvDBSearchEdit = class(TJvDBCustomSearchEdit) + published + property SearchOptions default [loCaseInsensitive, loPartialKey]; + property Align; + property Alignment; + property Anchors; + property AutoSelect; + property AutoSize; +// property BevelEdges; +// property BevelInner; +// property BevelKind default bkNone; +// property BevelOuter; + property BiDiMode; + property BorderSpacing; + property BorderStyle; + property CharCase; + property Color; + property Constraints; + property Cursor; +// property Flat; + property DragCursor; + property DragKind; +// property ImeMode; +// property ImeName; +// property OEMConvert; +// property ParentFlat; + property DragMode; + property Enabled; + property Font; + property Height; + property HelpContext; + property HelpKeyword; + property HelpType; + property HideSelection; + property Hint; + property MaxLength; + property NumbersOnly; + property ParentBiDiMode; + property ParentColor; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ReadOnly; + property ShowHint; + property TabOrder; + property TabStop; + property Text; + property TextHint; + property Top; + property Visible; + property Width; + property OnChange; + property OnChangeBounds; + property OnClick; + property OnContextPopup; + property OnDblClick; + property OnDragDrop; + property OnDragOver; + property OnEditingDone; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseEnter; + property OnMouseLeave; + property OnMouseMove; + property OnMouseUp; + property OnMouseWheel; + property OnMouseWheelDown; + property OnMouseWheelUp; + property OnResize; + property OnStartDrag; + property OnUTF8KeyPress; + end; + + +implementation + +uses + Variants, Forms, + JvConsts; + +//=== { TJvDBCustomSearchEdit } ============================================== + +constructor TJvDBCustomSearchEdit.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FDataLink := TFieldDataLink.Create; + FDataLink.Control := Self; + FDataLink.OnDataChange := @DataChange; + FSearchOptions := [loCaseInsensitive, loPartialKey]; + FClearOnEnter := True; + Text := ''; + FRaiseLocateException := True; +end; + +destructor TJvDBCustomSearchEdit.Destroy; +begin + FDataLink.Free; + FDataLink := nil; + inherited Destroy; +end; + +procedure TJvDBCustomSearchEdit.Notification(Component: TComponent; Operation: TOperation); +begin + inherited Notification(Component, Operation); + if (FDataLink <> nil) and (Component = DataSource) and (Operation = opRemove) then + DataSource := nil; +end; + +procedure TJvDBCustomSearchEdit.DataChange(Sender: TObject); +begin + if FDataLink.Field <> nil then + begin + if Screen.ActiveControl <> Self then + begin + if FDataLink.CanModify then + Text := FDataLink.Field.Text + else + Text := FDataLink.Field.DisplayText; + SelectAll; + end; + end + else + begin + if csDesigning in ComponentState then + Text := Name + else + Text := ''; + end; +end; + +procedure TJvDBCustomSearchEdit.CMChanged(var Msg: TLMessage); +var + LText: string; +begin + if (not ((csDesigning in ComponentState) and + (csLoading in ComponentState))) and + Assigned(FDataLink.DataSet) then + if (Screen.ActiveControl = Self) and FDataLink.Active then + try + if FDataLink.DataSet.Locate(FDataLink.FieldName, Text, FSearchOptions) then + begin + LText := Text; + Text := FDataLink.DataSet.FieldByName(DataField).AsString; + SelStart := Length(LText); + SelLength := Length(Text) - SelStart; + end; + except + if RaiseLocateException then + raise; + end; +end; + +procedure TJvDBCustomSearchEdit.KeyPress(var Key: Char); +var + LLength: Integer; +begin + if Key = Backspace then + begin + LLength := SelLength; + SelStart := SelStart - 1; + SelLength := LLength + 1; + end; + inherited KeyPress(Key); +end; + +function TJvDBCustomSearchEdit.GetDataSource: TDataSource; +begin + Result := FDataLink.DataSource; +end; + +procedure TJvDBCustomSearchEdit.SetDataSource(Value: TDataSource); +begin + FDataLink.DataSource := Value; +end; + +function TJvDBCustomSearchEdit.GetDataField: string; +begin + Result := FDataLink.FieldName; +end; + +procedure TJvDBCustomSearchEdit.SetDataField(const Value: string); +begin + FDataLink.FieldName := Value; +end; + +procedure TJvDBCustomSearchEdit.SetSearchOptions(const Value: TLocateOptions); +begin + FSearchOptions := Value; +end; + +function TJvDBCustomSearchEdit.GetResult: Variant; +begin + Result := Null; + if Assigned(FDataLink.DataSet) and FDataLink.DataSet.Active and (DataResult <> '') then + Result := FDataLink.DataSet.Lookup(DataField, Text, DataResult); +end; + +procedure TJvDBCustomSearchEdit.DoEnter; +begin + if FClearOnEnter then + Text := ''; + inherited DoEnter; +end; + +procedure TJvDBCustomSearchEdit.DoExit; +begin + inherited DoExit; + // On replace le texte sur l'enregistrement en cours + if Assigned(FDataLink.DataSet) and FDataLink.DataSet.Active then + Text := FDataLink.DataSet.FieldByName(DataField).AsString; +end; + +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} + +end. diff --git a/components/jvcllaz/run/JvJans/JvYearGridEditForm.pas b/components/jvcllaz/run/JvJans/JvYearGridEditForm.pas index c51672f28..8505a5a70 100644 --- a/components/jvcllaz/run/JvJans/JvYearGridEditForm.pas +++ b/components/jvcllaz/run/JvJans/JvYearGridEditForm.pas @@ -35,6 +35,9 @@ uses JvComponent; type + + { TYearGridEditForm } + TYearGridEditForm = class(TForm) //JvForm) Panel1: TPanel; BtnOK: TBitBtn;