You've already forked lazarus-ccr
Added: TJDBLabeledEdit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1987 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
JUJIBOUTILS
|
JUJIBOUTILS
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
Note: Lazarus Trunk required
|
||||||
|
|
||||||
Version pre-1.0
|
Version pre-1.0
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
2011-09-23 Added: TJDBLabeledEdit
|
||||||
|
2011-09-22 Added: ftTime support (testing)
|
||||||
2011-09-21 Added: TJDBGridControl and example (testgridctr)
|
2011-09-21 Added: TJDBGridControl and example (testgridctr)
|
||||||
2011-09-20 Added: TJIntegerEdit, TJLabeledIntegerEdit
|
2011-09-20 Added: TJIntegerEdit, TJLabeledIntegerEdit
|
||||||
TJCurrencyEdit, TJLabeledCurrencyEdit
|
TJCurrencyEdit, TJLabeledCurrencyEdit
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Files Count="15">
|
<Files Count="16">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="src/jdbintegeredit.pas"/>
|
<Filename Value="src/jdbintegeredit.pas"/>
|
||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
@@ -92,6 +92,11 @@
|
|||||||
<Filename Value="src/jdbgridutils.pas"/>
|
<Filename Value="src/jdbgridutils.pas"/>
|
||||||
<UnitName Value="jdbgridutils"/>
|
<UnitName Value="jdbgridutils"/>
|
||||||
</Item15>
|
</Item15>
|
||||||
|
<Item16>
|
||||||
|
<Filename Value="src/jdblabelededit.pas"/>
|
||||||
|
<HasRegisterProc Value="True"/>
|
||||||
|
<UnitName Value="JDBLabeledEdit"/>
|
||||||
|
</Item16>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="RunAndDesignTime"/>
|
<Type Value="RunAndDesignTime"/>
|
||||||
<RequiredPkgs Count="2">
|
<RequiredPkgs Count="2">
|
||||||
|
@@ -10,7 +10,8 @@ uses
|
|||||||
jdbintegeredit, jdblabeledintegeredit, jdbcurrencyedit,
|
jdbintegeredit, jdblabeledintegeredit, jdbcurrencyedit,
|
||||||
jdblabeledcurrencyedit, jdbdateedit, jdblabeleddateedit, jcontrolutils,
|
jdblabeledcurrencyedit, jdbdateedit, jdblabeleddateedit, jcontrolutils,
|
||||||
JIntegerEdit, JLabeledIntegerEdit, JCurrencyEdit, JLabeledCurrencyEdit,
|
JIntegerEdit, JLabeledIntegerEdit, JCurrencyEdit, JLabeledCurrencyEdit,
|
||||||
JDateEdit, JLabeledDateEdit, JDBGridControl, jdbgridutils, LazarusPackageIntf;
|
JDateEdit, JLabeledDateEdit, JDBGridControl, jdbgridutils, JDBLabeledEdit,
|
||||||
|
LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ begin
|
|||||||
RegisterUnit('JDateEdit', @JDateEdit.Register);
|
RegisterUnit('JDateEdit', @JDateEdit.Register);
|
||||||
RegisterUnit('JLabeledDateEdit', @JLabeledDateEdit.Register);
|
RegisterUnit('JLabeledDateEdit', @JLabeledDateEdit.Register);
|
||||||
RegisterUnit('JDBGridControl', @JDBGridControl.Register);
|
RegisterUnit('JDBGridControl', @JDBGridControl.Register);
|
||||||
|
RegisterUnit('JDBLabeledEdit', @JDBLabeledEdit.Register);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
288
components/jujiboutils/jujibo-utils/src/jdblabelededit.pas
Normal file
288
components/jujiboutils/jujibo-utils/src/jdblabelededit.pas
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
{ JDBLabeledEdit
|
||||||
|
|
||||||
|
Copyright (C) 2011 Julio Jiménez Borreguero
|
||||||
|
Contact: jujibo at gmail dot com
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or modify it
|
||||||
|
under the same terms as the Lazarus Component Library (LCL)
|
||||||
|
|
||||||
|
See the file license-jujiboutils.txt and COPYING.LGPL, included in this distribution,
|
||||||
|
for details about the license.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unit JDBLabeledEdit;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, LResources, Controls, ExtCtrls, DB, DBCtrls,
|
||||||
|
LMessages, LCLType, SysUtils;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TJDBLabeledEdit }
|
||||||
|
|
||||||
|
TJDBLabeledEdit = class(TCustomLabeledEdit)
|
||||||
|
private
|
||||||
|
{ Private declarations }
|
||||||
|
FDataLink: TFieldDataLink;
|
||||||
|
|
||||||
|
procedure DataChange(Sender: TObject);
|
||||||
|
procedure UpdateData(Sender: TObject);
|
||||||
|
procedure FocusRequest(Sender: TObject);
|
||||||
|
|
||||||
|
function GetDataField: string;
|
||||||
|
function GetDataSource: TDataSource;
|
||||||
|
function GetField: TField;
|
||||||
|
|
||||||
|
function IsReadOnly: boolean;
|
||||||
|
|
||||||
|
procedure SetDataField(const Value: string);
|
||||||
|
procedure SetDataSource(Value: TDataSource);
|
||||||
|
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
|
||||||
|
|
||||||
|
protected
|
||||||
|
{ Protected declarations }
|
||||||
|
procedure Loaded; override;
|
||||||
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
|
procedure ActiveChange(Sender: TObject); virtual;
|
||||||
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
||||||
|
procedure KeyPress(var Key: char); override;
|
||||||
|
procedure DoEnter; override;
|
||||||
|
function GetReadOnly: boolean; override;
|
||||||
|
procedure SetReadOnly(Value: boolean); override;
|
||||||
|
public
|
||||||
|
{ Public declarations }
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure EditingDone; override;
|
||||||
|
property Field: TField read GetField;
|
||||||
|
published
|
||||||
|
{ Published declarations }
|
||||||
|
property DataField: string read GetDataField write SetDataField;
|
||||||
|
property DataSource: TDataSource read GetDataSource write SetDataSource;
|
||||||
|
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
|
||||||
|
|
||||||
|
property Action;
|
||||||
|
property Align;
|
||||||
|
property Alignment;
|
||||||
|
property Anchors;
|
||||||
|
property AutoSelect;
|
||||||
|
property AutoSize;
|
||||||
|
property BidiMode;
|
||||||
|
property BorderSpacing;
|
||||||
|
property BorderStyle;
|
||||||
|
property CharCase;
|
||||||
|
property Color;
|
||||||
|
property Constraints;
|
||||||
|
property DragCursor;
|
||||||
|
property DragMode;
|
||||||
|
property EditLabel;
|
||||||
|
property Enabled;
|
||||||
|
property Font;
|
||||||
|
property LabelPosition;
|
||||||
|
property LabelSpacing;
|
||||||
|
property MaxLength;
|
||||||
|
property ParentColor;
|
||||||
|
property ParentFont;
|
||||||
|
property ParentShowHint;
|
||||||
|
property PopupMenu;
|
||||||
|
property ShowHint;
|
||||||
|
property TabOrder;
|
||||||
|
property TabStop;
|
||||||
|
property Visible;
|
||||||
|
property OnChange;
|
||||||
|
property OnClick;
|
||||||
|
property OnDblClick;
|
||||||
|
property OnDragDrop;
|
||||||
|
property OnDragOver;
|
||||||
|
property OnEditingDone;
|
||||||
|
property OnEndDrag;
|
||||||
|
property OnEnter;
|
||||||
|
property OnExit;
|
||||||
|
property OnKeyDown;
|
||||||
|
property OnKeyPress;
|
||||||
|
property OnKeyUp;
|
||||||
|
property OnMouseDown;
|
||||||
|
property OnMouseMove;
|
||||||
|
property OnMouseUp;
|
||||||
|
property OnStartDrag;
|
||||||
|
property OnUTF8KeyPress;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
{$I jdblabelededit_icon.lrs}
|
||||||
|
RegisterComponents('Data Controls', [TJDBLabeledEdit]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TJDBLabeledEdit }
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.DataChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if FDataLink.Field <> nil then
|
||||||
|
Caption := FDataLink.Field.AsString
|
||||||
|
else
|
||||||
|
Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.UpdateData(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if FDataLink.Field <> nil then
|
||||||
|
FDataLink.Field.Text := Text
|
||||||
|
else
|
||||||
|
Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.FocusRequest(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDBLabeledEdit.GetDataField: string;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.FieldName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDBLabeledEdit.GetDataSource: TDataSource;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.DataSource;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDBLabeledEdit.GetField: TField;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.Field;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDBLabeledEdit.IsReadOnly: boolean;
|
||||||
|
begin
|
||||||
|
if FDatalink.Active then
|
||||||
|
Result := not FDatalink.CanModify
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.SetDataField(const Value: string);
|
||||||
|
begin
|
||||||
|
FDataLink.FieldName := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.SetDataSource(Value: TDataSource);
|
||||||
|
begin
|
||||||
|
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
|
||||||
|
ChangeDataSource(Self, FDataLink, Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.CMGetDataLink(var Message: TLMessage);
|
||||||
|
begin
|
||||||
|
Message.Result := PtrUInt(FDataLink);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.Loaded;
|
||||||
|
begin
|
||||||
|
inherited Loaded;
|
||||||
|
if (csDesigning in ComponentState) then
|
||||||
|
DataChange(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.Notification(AComponent: TComponent; Operation: TOperation);
|
||||||
|
begin
|
||||||
|
inherited Notification(AComponent, Operation);
|
||||||
|
// clean up
|
||||||
|
if (Operation = opRemove) then
|
||||||
|
begin
|
||||||
|
if (FDataLink <> nil) and (AComponent = DataSource) then
|
||||||
|
DataSource := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.ActiveChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if FDatalink.Active then
|
||||||
|
datachange(Sender)
|
||||||
|
else
|
||||||
|
Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.KeyDown(var Key: word; Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
inherited KeyDown(Key, Shift);
|
||||||
|
if Key = VK_ESCAPE then
|
||||||
|
begin
|
||||||
|
FDataLink.Reset;
|
||||||
|
SelectAll;
|
||||||
|
Key := VK_UNKNOWN;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if Key in [VK_DELETE, VK_BACK] then
|
||||||
|
begin
|
||||||
|
if not IsReadOnly then
|
||||||
|
FDatalink.Edit
|
||||||
|
else
|
||||||
|
Key := VK_UNKNOWN;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.KeyPress(var Key: char);
|
||||||
|
begin
|
||||||
|
inherited KeyPress(Key);
|
||||||
|
if not IsReadOnly then
|
||||||
|
FDatalink.Edit;
|
||||||
|
inherited KeyPress(Key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.DoEnter;
|
||||||
|
begin
|
||||||
|
if FDataLink.Field <> nil then
|
||||||
|
Caption := FDataLink.Field.AsString;
|
||||||
|
inherited DoEnter;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDBLabeledEdit.GetReadOnly: boolean;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.ReadOnly;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.SetReadOnly(Value: boolean);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FDataLink.ReadOnly := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TJDBLabeledEdit.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
ControlStyle := ControlStyle + [csReplicatable];
|
||||||
|
FDataLink := TFieldDataLink.Create;
|
||||||
|
FDataLink.Control := Self;
|
||||||
|
FDataLink.OnDataChange := @DataChange;
|
||||||
|
FDataLink.OnUpdateData := @UpdateData;
|
||||||
|
FDataLInk.OnActiveChange := @ActiveChange;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TJDBLabeledEdit.Destroy;
|
||||||
|
begin
|
||||||
|
FDataLink.Free;
|
||||||
|
FDataLink := nil;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDBLabeledEdit.EditingDone;
|
||||||
|
begin
|
||||||
|
inherited EditingDone;
|
||||||
|
UpdateData(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@@ -0,0 +1,33 @@
|
|||||||
|
LazarusResources.Add('tjdblabelededit','PNG',[
|
||||||
|
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||||
|
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
|
||||||
|
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#219#9#23#8
|
||||||
|
+#10':F'#3'+'#155#0#0#2'wIDATH'#199#213#149']HSa'#24#199#127'GDo'#202'9C'#5'C'
|
||||||
|
+#163#129#232#197'2'#226#140'`'#176#4#21#20'"'#232'f72'#162#249#17'D!'#226#141
|
||||||
|
+'0'#132#212#139#16#186#136'd7'#129'H'#203#8'ov#'#216#141#176#4#29#8'q'#14#194
|
||||||
|
+'X'#17#136#226#7#147#152'a'#155#31#224'${'#187#168#247#180#237#204#204'Y'#23
|
||||||
|
+#253'o'#206#243'>'#231#229#249#248#191#255#231'}'#225#31'CI_L'#206'm'#138#177
|
||||||
|
+#233#149#156#27#239#221#178#209#222'X'#165#228#149' ='#240#232#195#171#216'k'
|
||||||
|
+#206#17']'#223'#'#158'H'#17'O'#30#18'O'#164#152#10#199#242'JT'#0'06'#189'BCm'
|
||||||
|
+#25#183']'#23#137'''RF'#240#254#206'6#ICm'#25#182#234#18#142#235'PBUUaJ`'#171
|
||||||
|
+'.!'#178#180#205'T8fT'#220#223#217#6#192#196#176#155#253#131'#\'#214#15','#6
|
||||||
|
+':H'#134'z'#9#6#131'";'#152#170#170'B'#174#211#253#10'@'#183'?"*K'#139#169
|
||||||
|
+#176#20#25'T'#0'$C'#189'XZF'#13#251#198#253'W'#236#29'|e1'#208#129#174#235'J'
|
||||||
|
+'0'#24#20'###'#0#248'|>'#220'n'#183#162#170#170#208'u'#221#160#176#16'`ec'
|
||||||
|
+#135#202#210'r'#0#6'<'#245'47\ '#186#190#135'7'#244#131#243'x"'#197'D'#8#230
|
||||||
|
+#159#223#201#160'C'#6#148#246#177'g`'#171'.'#225#221#251#207#25#213#231#130
|
||||||
|
+#165'e'#148'k'#222#23#200#10'%U'#217#182'IE'#191#163'H'#6'~p'#253#19#146#14#0
|
||||||
|
+']'#215'3'#232#144#182#236'H'#250#21#128#230#254#176'p^)'#167#194'R'#132#253
|
||||||
|
+#210'y'#131#162't'#153#198#147#135#236#31#28#17'Y'#218#230#237#19#151'r'#170
|
||||||
|
+'9'#232#246'G'#196'Zl'#151#163'o'#130#1'O='#171#218#155#191'2'#197']]w'#149
|
||||||
|
+#156#20'y'#234#150#137'F'#230#207#20'|h'#232#17#22'k'#141'R'#8#176#22#219#165
|
||||||
|
+#178#180#216'P'#209#170#182#12#192#211'gcy'''#216'Il'#252'RQ'#231#205#203#127
|
||||||
|
+#164'"'#9'g'#207#172#201#231'p82'#190#25's '#239#150#201#185'M'#241#248#245
|
||||||
|
+'G<u'#167#175'X'#211'4'#28#14#7#154#166#153#231'@'#162#189#177'J'#201'V'#200
|
||||||
|
+#140#190#133#179'g'#22'g'#207',3'#250'VF'#23#217#190'\(<'#169#178'V'#181#156
|
||||||
|
+'V'#181#201#8'*'#237#5#191#217#151'W'#130#25'}'#139#193'@4'#239#195'.8i'#195
|
||||||
|
+'` '#202#130#191#201#168#248#180'8'#177#131'a'#175'='#167'j'#164'o'#216'k7'
|
||||||
|
+#212's'#220'A'#155'0>'#254'R'#244#245'v'#139#179' '#249'e]'#152#222'd'#227
|
||||||
|
+#146#251#249#243#172#176'Xk'#20#254'{|'#7#172#15'p'#145#208'Pic'#0#0#0#0'IEN'
|
||||||
|
+'D'#174'B`'#130
|
||||||
|
]);
|
Reference in New Issue
Block a user