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 000000000..d86fcf4fa
Binary files /dev/null and b/components/jvcllaz/design/JvDB/images/tjvdbsearchcombobox.bmp differ
diff --git a/components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp b/components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp
new file mode 100644
index 000000000..c6bfee07e
Binary files /dev/null and b/components/jvcllaz/design/JvDB/images/tjvdbsearchedit.bmp differ
diff --git a/components/jvcllaz/design/JvDB/images/tjvdbtreeview.bmp b/components/jvcllaz/design/JvDB/images/tjvdbtreeview.bmp
new file mode 100644
index 000000000..983c56170
Binary files /dev/null and b/components/jvcllaz/design/JvDB/images/tjvdbtreeview.bmp differ
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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 @@
-
+
-
+
-
+
-
+
+
+
+
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 "/>
-
+
+
+
+
+
+
+
+
+
diff --git a/components/jvcllaz/resource/jvdbreg.res b/components/jvcllaz/resource/jvdbreg.res
index 112eae933..6c52bef04 100644
Binary files a/components/jvcllaz/resource/jvdbreg.res and b/components/jvcllaz/resource/jvdbreg.res differ
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;