mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 04:18:25 +02:00
160 lines
4.1 KiB
PHP
160 lines
4.1 KiB
PHP
{%MainUnit ../dbctrls.pas}
|
|
|
|
{******************************************************************************
|
|
TDBListBox
|
|
data aware ListBox, base found in dbctrls.pp
|
|
******************************************************************************
|
|
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
|
* for details about the copyright. *
|
|
* *
|
|
* 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. *
|
|
* *
|
|
*****************************************************************************
|
|
}
|
|
|
|
// included by dbctrls.pas
|
|
|
|
{TCustomDBComboBox}
|
|
|
|
function TCustomDBComboBox.GetDataField: string;
|
|
begin
|
|
Result:=FDataLink.FieldName;
|
|
end;
|
|
|
|
function TCustomDBComboBox.GetDataSource: TDataSource;
|
|
begin
|
|
Result:=FDataLink.DataSource;
|
|
end;
|
|
|
|
function TCustomDBComboBox.GetField: TField;
|
|
begin
|
|
Result:=FDataLink.Field;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.Change;
|
|
begin
|
|
FDataLink.Modified;
|
|
inherited Change;
|
|
end;
|
|
|
|
|
|
function TCustomDBComboBox.GetReadOnly: Boolean;
|
|
begin
|
|
Result:=FDataLink.ReadOnly;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.SetDataField(const AValue: string);
|
|
begin
|
|
FDataLink.FieldName:=AValue;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.SetDataSource(const AValue: TDataSource);
|
|
begin
|
|
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
|
|
ChangeDataSource(Self,FDataLink,AValue);
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.SetReadOnly(const AValue: Boolean);
|
|
begin
|
|
FDataLink.ReadOnly:=AValue;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.CMGetDataLink(var Message: TLMessage);
|
|
begin
|
|
Message.Result := PtrUInt(FDataLink);
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.DataChange(Sender: TObject);
|
|
begin
|
|
if not (Style=csSimple) and DroppedDown then
|
|
Exit;
|
|
UpdateText;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.EditingChange(Sender: TObject);
|
|
begin
|
|
// ToDo
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.KeyDown(var Key: Word; Shift: TShiftState);
|
|
begin
|
|
inherited KeyDown(Key, Shift);
|
|
if Key=VK_ESCAPE then begin
|
|
//cancel out of editing by reset on esc
|
|
FDataLink.Reset;
|
|
SelectAll;
|
|
Key := VK_UNKNOWN;
|
|
end else
|
|
if Key in [VK_DELETE, VK_BACK] then begin
|
|
if not FDataLink.Edit then
|
|
Key := VK_UNKNOWN;
|
|
end;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.KeyPress(var Key: char);
|
|
begin
|
|
inherited KeyPress(Key);
|
|
case Key of
|
|
#8: // special keys
|
|
if not FDatalink.Edit then
|
|
Key:=#0;
|
|
|
|
#32..#255: //standard keys
|
|
if not FieldCanAcceptKey(FDataLink.Field, Key) or not FDatalink.Edit then
|
|
Key:=#0;
|
|
end;//case
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.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 TCustomDBComboBox.UpdateData(Sender: TObject);
|
|
begin
|
|
//
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.EditingDone;
|
|
begin
|
|
FDataLink.UpdateRecord;
|
|
inherited EditingDone;
|
|
end;
|
|
|
|
procedure TCustomDBComboBox.UpdateText;
|
|
begin
|
|
if csDesigning in ComponentState then
|
|
Text := Name
|
|
else
|
|
Text := '';
|
|
end;
|
|
|
|
constructor TCustomDBComboBox.Create(TheOwner: TComponent);
|
|
begin
|
|
inherited Create(TheOwner);
|
|
ControlStyle:=ControlStyle+[csReplicatable];
|
|
FDataLink:=TFieldDataLink.Create;
|
|
FDataLink.Control:=Self;
|
|
FDataLink.OnDataChange:=@DataChange;
|
|
FDataLink.OnUpdateData:=@UpdateData;
|
|
FDataLink.OnEditingChange:=@EditingChange;
|
|
end;
|
|
|
|
destructor TCustomDBComboBox.Destroy;
|
|
begin
|
|
FDataLink.Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
|