You've already forked lazarus-ccr
Added: TJDbEnumCombo, like TDbComboBox but, uses itemindex instead of text
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2616 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -5,6 +5,7 @@ Note: Lazarus Trunk required
|
|||||||
|
|
||||||
Version pre-1.1
|
Version pre-1.1
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
2013-01-03 Added: TJDbEnumCombo, like TDbComboBox but, uses itemindex instead of text
|
||||||
2012-09-20 Added: TJLabeledIntegerEdit and TJLabeledFloatEdit property CurrentValue
|
2012-09-20 Added: TJLabeledIntegerEdit and TJLabeledFloatEdit property CurrentValue
|
||||||
2012-06-12 Fixed: TJDbGridTimeCtrl, store time value
|
2012-06-12 Fixed: TJDbGridTimeCtrl, store time value
|
||||||
2012-03-14 Fixed: Prevent double updates (QT widgetset) in edit widgets
|
2012-03-14 Fixed: Prevent double updates (QT widgetset) in edit widgets
|
||||||
|
@ -4,17 +4,11 @@
|
|||||||
<Name Value="jujiboutils"/>
|
<Name Value="jujiboutils"/>
|
||||||
<Author Value="Julio Jiménez Borreguero"/>
|
<Author Value="Julio Jiménez Borreguero"/>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<OtherUnitFiles Value="src"/>
|
<OtherUnitFiles Value="src"/>
|
||||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Linking>
|
|
||||||
<Debugging>
|
|
||||||
<GenerateDebugInfo Value="True"/>
|
|
||||||
<DebugInfoType Value="dsAuto"/>
|
|
||||||
</Debugging>
|
|
||||||
</Linking>
|
|
||||||
<Other>
|
<Other>
|
||||||
<CompilerMessages>
|
<CompilerMessages>
|
||||||
<UseMsgFile Value="True"/>
|
<UseMsgFile Value="True"/>
|
||||||
@ -27,7 +21,7 @@ different kinds of data, floats, dates, etc. while working with
|
|||||||
db and non db controls."/>
|
db and non db controls."/>
|
||||||
<License Value="LGPL with link exception. Read files license-jujiboutils and COPYING.LGPL"/>
|
<License Value="LGPL with link exception. Read files license-jujiboutils and COPYING.LGPL"/>
|
||||||
<Version Major="1"/>
|
<Version Major="1"/>
|
||||||
<Files Count="17">
|
<Files Count="18">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="src/jdbgridcontrol.pas"/>
|
<Filename Value="src/jdbgridcontrol.pas"/>
|
||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
@ -110,6 +104,11 @@ db and non db controls."/>
|
|||||||
<Filename Value="src/jinputconsts.pas"/>
|
<Filename Value="src/jinputconsts.pas"/>
|
||||||
<UnitName Value="jinputconsts"/>
|
<UnitName Value="jinputconsts"/>
|
||||||
</Item17>
|
</Item17>
|
||||||
|
<Item18>
|
||||||
|
<Filename Value="src/jdbenumcombo.pas"/>
|
||||||
|
<HasRegisterProc Value="True"/>
|
||||||
|
<UnitName Value="JDbEnumCombo"/>
|
||||||
|
</Item18>
|
||||||
</Files>
|
</Files>
|
||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N Value="True"/>
|
<EnableI18N Value="True"/>
|
||||||
|
@ -11,7 +11,7 @@ uses
|
|||||||
jdblabeledcurrencyedit, jdblabeleddateedit, jcontrolutils,
|
jdblabeledcurrencyedit, jdblabeleddateedit, jcontrolutils,
|
||||||
JLabeledIntegerEdit, JLabeledFloatEdit, JLabeledCurrencyEdit,
|
JLabeledIntegerEdit, JLabeledFloatEdit, JLabeledCurrencyEdit,
|
||||||
JLabeledDateEdit, jdbgridutils, JLabeledTimeEdit, JDBLabeledTimeEdit,
|
JLabeledDateEdit, jdbgridutils, JLabeledTimeEdit, JDBLabeledTimeEdit,
|
||||||
JLabeledDateTimeEdit, JDBLabeledDateTimeEdit, jinputconsts,
|
JLabeledDateTimeEdit, JDBLabeledDateTimeEdit, jinputconsts, JDbEnumCombo,
|
||||||
LazarusPackageIntf;
|
LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -32,6 +32,7 @@ begin
|
|||||||
RegisterUnit('JDBLabeledTimeEdit', @JDBLabeledTimeEdit.Register);
|
RegisterUnit('JDBLabeledTimeEdit', @JDBLabeledTimeEdit.Register);
|
||||||
RegisterUnit('JLabeledDateTimeEdit', @JLabeledDateTimeEdit.Register);
|
RegisterUnit('JLabeledDateTimeEdit', @JLabeledDateTimeEdit.Register);
|
||||||
RegisterUnit('JDBLabeledDateTimeEdit', @JDBLabeledDateTimeEdit.Register);
|
RegisterUnit('JDBLabeledDateTimeEdit', @JDBLabeledDateTimeEdit.Register);
|
||||||
|
RegisterUnit('JDbEnumCombo', @JDbEnumCombo.Register);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
235
components/jujiboutils/src/jdbenumcombo.pas
Normal file
235
components/jujiboutils/src/jdbenumcombo.pas
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
{ JDbEnumcombo
|
||||||
|
|
||||||
|
Copyright (C) 2013 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 JDbEnumCombo;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics, Dialogs,
|
||||||
|
DBCtrls, DB, LCLType, LMessages;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TJDbEnumCombo }
|
||||||
|
|
||||||
|
TJDbEnumCombo = class(TCustomComboBox)
|
||||||
|
private
|
||||||
|
FDataLink: TFieldDataLink;
|
||||||
|
function GetDataField: string;
|
||||||
|
function GetDataSource: TDataSource;
|
||||||
|
function GetField: TField;
|
||||||
|
function GetReadOnly: boolean;
|
||||||
|
procedure SetDataField(const AValue: string);
|
||||||
|
procedure SetDataSource(const AValue: TDataSource);
|
||||||
|
procedure SetReadOnly(const AValue: boolean);
|
||||||
|
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
|
||||||
|
protected
|
||||||
|
{ Protected declarations }
|
||||||
|
procedure DataChange(Sender: TObject);
|
||||||
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
|
procedure Change; override;
|
||||||
|
procedure DropDown; override;
|
||||||
|
procedure UpdateData(Sender: TObject);
|
||||||
|
public
|
||||||
|
{ Public declarations }
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure EditingDone; override;
|
||||||
|
property Field: TField read GetField;
|
||||||
|
property Text;
|
||||||
|
property ItemIndex;
|
||||||
|
published
|
||||||
|
{ Published declarations }
|
||||||
|
property Anchors;
|
||||||
|
property ArrowKeysTraverseList;
|
||||||
|
property AutoDropDown;
|
||||||
|
property AutoComplete;
|
||||||
|
property AutoSize;
|
||||||
|
property BiDiMode;
|
||||||
|
property BorderSpacing;
|
||||||
|
property BorderStyle;
|
||||||
|
property CharCase;
|
||||||
|
property Color;
|
||||||
|
property DataField: string read GetDataField write SetDataField;
|
||||||
|
property DataSource: TDataSource read GetDataSource write SetDataSource;
|
||||||
|
property DragCursor;
|
||||||
|
property DragMode;
|
||||||
|
property DropDownCount;
|
||||||
|
property Enabled;
|
||||||
|
property Font;
|
||||||
|
property ItemHeight;
|
||||||
|
property Items;
|
||||||
|
property ItemWidth;
|
||||||
|
property MaxLength default -1;
|
||||||
|
property OnChange;
|
||||||
|
property OnChangeBounds;
|
||||||
|
property OnClick;
|
||||||
|
property OnCloseUp;
|
||||||
|
property OnDblClick;
|
||||||
|
property OnDragDrop;
|
||||||
|
property OnDragOver;
|
||||||
|
property OnDrawItem;
|
||||||
|
property OnDropDown;
|
||||||
|
property OnEditingDone;
|
||||||
|
property OnEndDrag;
|
||||||
|
property OnEnter;
|
||||||
|
property OnExit;
|
||||||
|
property OnKeyDown;
|
||||||
|
property OnKeyPress;
|
||||||
|
property OnKeyUp;
|
||||||
|
property OnMouseDown;
|
||||||
|
property OnMouseMove;
|
||||||
|
property OnMouseUp;
|
||||||
|
property OnSelect;
|
||||||
|
property OnStartDrag;
|
||||||
|
property OnUTF8KeyPress;
|
||||||
|
property ParentBiDiMode;
|
||||||
|
property ParentColor;
|
||||||
|
property ParentFont;
|
||||||
|
property ParentShowHint;
|
||||||
|
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
|
||||||
|
property ShowHint;
|
||||||
|
property TabOrder;
|
||||||
|
property TabStop;
|
||||||
|
property Visible;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
{$I jdbenumcombo_icon.lrs}
|
||||||
|
RegisterComponents('Data Controls', [TJDbEnumCombo]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TJDbEnumCombo }
|
||||||
|
|
||||||
|
function TJDbEnumCombo.GetDataField: string;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.FieldName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDbEnumCombo.GetDataSource: TDataSource;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.DataSource;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDbEnumCombo.GetField: TField;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.Field;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJDbEnumCombo.GetReadOnly: boolean;
|
||||||
|
begin
|
||||||
|
Result := FDataLink.ReadOnly;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.SetDataField(const AValue: string);
|
||||||
|
begin
|
||||||
|
FDataLink.FieldName := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.SetDataSource(const AValue: TDataSource);
|
||||||
|
begin
|
||||||
|
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
|
||||||
|
ChangeDataSource(Self, FDataLink, AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.SetReadOnly(const AValue: boolean);
|
||||||
|
begin
|
||||||
|
FDataLink.ReadOnly := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.CMGetDataLink(var Message: TLMessage);
|
||||||
|
begin
|
||||||
|
Message.Result := PtrUInt(FDataLink);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.DataChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
DataLinkField: TField;
|
||||||
|
begin
|
||||||
|
DataLinkField := FDataLink.Field;
|
||||||
|
if Assigned(DataLinkField) then
|
||||||
|
ItemIndex := DataLinkField.AsInteger
|
||||||
|
else
|
||||||
|
ItemIndex:= -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.Notification(AComponent: TComponent; Operation: TOperation);
|
||||||
|
begin
|
||||||
|
inherited Notification(AComponent, Operation);
|
||||||
|
if (Operation = opRemove) then
|
||||||
|
begin
|
||||||
|
if (FDataLink <> nil) and (AComponent = DataSource) then
|
||||||
|
DataSource := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.Change;
|
||||||
|
begin
|
||||||
|
FDataLink.Edit;
|
||||||
|
FDataLink.Modified;
|
||||||
|
FDataLink.UpdateRecord;
|
||||||
|
inherited Change;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.DropDown;
|
||||||
|
begin
|
||||||
|
FDataLink.Edit;
|
||||||
|
inherited DropDown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.UpdateData(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FDataLink.Field.AsInteger := ItemIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TJDbEnumCombo.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
ControlStyle := ControlStyle + [csReplicatable];
|
||||||
|
FDataLink := TFieldDataLink.Create;
|
||||||
|
FDataLink.Control := Self;
|
||||||
|
FDataLink.OnDataChange := @DataChange;
|
||||||
|
FDataLink.OnUpdateData := @UpdateData;
|
||||||
|
Style:= csDropDownList;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TJDbEnumCombo.Destroy;
|
||||||
|
begin
|
||||||
|
FDataLink.Destroy;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJDbEnumCombo.EditingDone;
|
||||||
|
begin
|
||||||
|
FDataLink.UpdateRecord;
|
||||||
|
inherited EditingDone;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TJDbEnumCombo }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
30
components/jujiboutils/src/jdbenumcombo_icon.lrs
Normal file
30
components/jujiboutils/src/jdbenumcombo_icon.lrs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
LazarusResources.Add('TJDbEnumCombo','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#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#220#12#30#20#27#31#227#15'v'#154#0#0#2'XI'
|
||||||
|
+'DATH'#199#181#150'_HSQ'#28#199'?g'#14#165#160'9'#140'6#D'#20#6'>'#148#129'$'
|
||||||
|
+'$3'#138#213#131#244#162'='#8#130'oA'#143#129#15#177'F>'#11'&='#8#246'&'#244
|
||||||
|
+'&'#10#6#17'X'#15#225#159')'#243'Eb'#148'Z'#4#3'e'#193'D'#134#216'd'#5'Mv'
|
||||||
|
+#239#175#7#187#135#221'y'#231#254#128'_'#184#220's'#206'='#231#251#189#191
|
||||||
|
+#239#239'w'#14'G'#137#8#231#9'7'#128'a'#158#136#204#175#239#203#244#194#206
|
||||||
|
+#169'I'#203#19#189#186#157'7LU'#231'R'#0'('#165'DD'#148#245'M)'#165#255'V'
|
||||||
|
+#143#139#8#179'k{'#18#10#199'$'#20#142#201'V2+""['#201#172',}='#144#217#181
|
||||||
|
+'='#1'$'#20#142#233'w'#222'0'#201#27#230#255#229'B'#241'S8'#238#6#152'^'#216
|
||||||
|
+#161'3'#208'D'#155#255#2#233'L'#142'm '#157#201#145'>:&'#157#201#1#208#25'hb'
|
||||||
|
+#25'ho'#241#148#180#163'0'#2#155'E'#237'-'#30'6'#19#135'l&'#192#231'm'#7#208
|
||||||
|
+#228#233#163'c'#0'6'#19#135#21'y^h'#153#22#0#232#185'q'#5'_c=N9('#206#131#187
|
||||||
|
+#206'%y'#195#180'yo'#17'[QX}7@2'#149#197#239'm'#0'`t'#184#131'P'#231'e'#182
|
||||||
|
+#127#254#214#17#244#247#238#146'>:'#230#207'_'#195#22'I'#241#223#22#247#1#148
|
||||||
|
+#136#240#228#245#150'$SY'#12'S'#180'@$2UsiF"'#195#247#188#222#166'U'#155#128
|
||||||
|
+#223#219#128#175#177#158#247#177#20#0#221'*'#206#248#248#211#10#9#167#24#25
|
||||||
|
+'y'#164#251#147#147#239#180'HI'#139'"'#145'8'#0']]'#183#206'$'#143#199'?'#235
|
||||||
|
+#246#208#208'0ss3'#0'DW7'#162#3#253'}'#202#13#208'z'#237#18#27#223#14'0L'#225
|
||||||
|
+'zkGI'#130'r'#176#200#29's'#224'd'#145#5#151#235#23'J'#229'J'#18#155#166#7
|
||||||
|
+#145#139#182#177#219'='#1't'#4#206'UtSW'#209#151#15'o+'#206#135#149#19#219'>'
|
||||||
|
+'x'#252#176#141'7'#31'w'#29'-*D'#185'|8Y'#234#6#24#12'6'#171#193'`3'#243#235
|
||||||
|
+#251'26'#243#131#177'"+'#187'U'#245#249#176#9'X'#167#227#208#157#171'j0'#216
|
||||||
|
+'|j'#210#232#139#184',/.'#213'~\'#23#194#18's'#194#179#240#243#178#132#175'&'
|
||||||
|
+'^'#158'-P'#205#226#154'"('#133#208#131#251#21#147'~Z'#252'^['#4'5WQ'#165#168
|
||||||
|
+#185#138#170#221'<'#213'@Uz'#171#200'd'#14#239#174#172'lD'#245'BW'#249'5'#3
|
||||||
|
+#253'}J'#157#247#181#229#31'~A@C'#28#210#245#9#0#0#0#0'IEND'#174'B`'#130
|
||||||
|
]);
|
Reference in New Issue
Block a user