📄 jvdyncontrolenginedbtools.pas
字号:
{-----------------------------------------------------------------------------
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 Initial Developer of the Original Code is Jens Fudickar [jens dott fudickar att oratool dott de]
All Rights Reserved.
Contributor(s):
Jens Fudickar [jens dott fudickar att oratool dott de]
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvDynControlEngineDBTools.pas,v 1.16 2005/02/17 10:20:27 marquardt Exp $
unit JvDynControlEngineDBTools;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Controls, DB, Classes,
{$IFDEF MSWINDOWS}
ActnList, Forms, Graphics,
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
QActnList, QForms, QGraphics,
{$ENDIF UNIX}
JvPanel, JvDynControlEngineTools, JvDynControlEngine, JvDynControlEngineDB;
type
TJvCreateDataControlsEvent = procedure(ADynControlEngineDB: TJvDynControlEngineDB;
AParentControl: TWinControl; AFieldCreateOptions: TJvCreateDBFieldsOnControlOptions) of object;
TJvDynControlDataSourceEditDialog = class(TObject)
private
FForm: TCustomForm;
FDynControlEngineDB: TJvDynControlEngineDB;
FDataSource: TDataSource;
FDataComponent: TComponent;
FDialogCaption: string;
FPostButtonCaption: string;
FCancelButtonCaption: string;
FCloseButtonCaption: string;
FPostButtonGlyph: TBitmap;
FCancelButtonGlyph: TBitmap;
FCloseButtonGlyph: TBitmap;
FIncludeNavigator: Boolean;
FBorderStyle: TFormBorderStyle;
FPosition: TPosition;
FTop: Integer;
FLeft: Integer;
FWidth: Integer;
FHeight: Integer;
FOnCreateDataControlsEvent: TJvCreateDataControlsEvent;
FArrangeConstraints: TSizeConstraints;
FArrangeSettings: TJvArrangeSettings;
FFieldCreateOptions: TJvCreateDBFieldsOnControlOptions;
FScrollBox: TScrollBox;
FNavigatorPanel: TJvPanel;
FButtonPanel: TWinControl;
FPostAction: TCustomAction;
FCancelAction: TCustomAction;
protected
function GetDynControlEngineDB: TJvDynControlEngineDB;
procedure SetDataComponent(Value: TComponent);
procedure OnPostButtonClick(Sender: TObject);
procedure OnCancelButtonClick(Sender: TObject);
procedure OnCloseButtonClick(Sender: TObject);
function CreateDynControlDialog(var AMainPanel: TWinControl): TCustomForm;
procedure SetArrangeSettings(Value: TJvArrangeSettings);
procedure SetArrangeConstraints(Value: TSizeConstraints);
procedure SetFieldCreateOptions(Value: TJvCreateDBFieldsOnControlOptions);
procedure ArrangePanelChangedWidth(Sender: TObject; ChangedSize: Integer);
procedure ArrangePanelChangedHeight(Sender: TObject; ChangedSize: Integer);
property DataSource: TDataSource read FDataSource;
public
constructor Create;
destructor Destroy; override;
function ShowDialog: TModalResult;
published
property DataComponent: TComponent read FDataComponent write SetDataComponent;
property PostButtonCaption: string read FPostButtonCaption write FPostButtonCaption;
property CancelButtonCaption: string read FCancelButtonCaption write FCancelButtonCaption;
property CloseButtonCaption: string read FCloseButtonCaption write FCloseButtonCaption;
property PostButtonGlyph: TBitmap read FPostButtonGlyph write FPostButtonGlyph;
property CancelButtonGlyph: TBitmap read FCancelButtonGlyph write FCancelButtonGlyph;
property CloseButtonGlyph: TBitmap read FCloseButtonGlyph write FCloseButtonGlyph;
property DialogCaption: string read FDialogCaption write FDialogCaption;
property DynControlEngineDB: TJvDynControlEngineDB read GetDynControlEngineDB write FDynControlEngineDB;
property IncludeNavigator: Boolean read FIncludeNavigator write FIncludeNavigator;
property BorderStyle: TFormBorderStyle read FBorderStyle write FBorderStyle default bsDialog;
property Position: TPosition read FPosition write FPosition default poScreenCenter;
property Top: Integer read FTop write FTop default 0;
property Left: Integer read FLeft write FLeft default 0;
property Width: Integer read FWidth write FWidth default 0;
property Height: Integer read FHeight write FHeight default 0;
property OnCreateDataControlsEvent: TJvCreateDataControlsEvent read FOnCreateDataControlsEvent write
FOnCreateDataControlsEvent;
property ArrangeConstraints: TSizeConstraints read FArrangeConstraints write SetArrangeConstraints;
property ArrangeSettings: TJvArrangeSettings read FArrangeSettings write SetArrangeSettings;
property FieldCreateOptions: TJvCreateDBFieldsOnControlOptions read FFieldCreateOptions write SetFieldCreateOptions;
end;
function ShowDataSourceEditDialog(ADataComponent: TComponent;
const ADialogCaption, APostButtonCaption, ACancelButtonCaption, ACloseButtonCaption: string;
AIncludeNavigator: Boolean;
AFieldCreateOptions: TJvCreateDBFieldsOnControlOptions = nil;
AArrangeConstraints: TSizeConstraints = nil;
AArrangeSettings: TJvArrangeSettings = nil;
ADynControlEngineDB: TJvDynControlEngineDB = nil): TModalResult;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$RCSfile: JvDynControlEngineDBTools.pas,v $';
Revision: '$Revision: 1.16 $';
Date: '$Date: 2005/02/17 10:20:27 $';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
StdCtrls, SysUtils,
JvDBActions, JvDynControlEngineIntf, JvResources;
procedure TJvDynControlDataSourceEditDialog.SetDataComponent(Value: TComponent);
begin
FDataComponent := Value;
FDataSource := DynControlengineDB.GetDataSourceFromDataComponent(Value);
end;
function TJvDynControlDataSourceEditDialog.GetDynControlEngineDB: TJvDynControlEngineDB;
begin
if Assigned(FDynControlEngineDB) then
Result := FDynControlEngineDB
else
Result := DefaultDynControlEngineDB;
end;
procedure TJvDynControlDataSourceEditDialog.OnPostButtonClick(Sender: TObject);
begin
if DataSource.Dataset.State in [dsInsert, dsEdit] then
try
DataSource.Dataset.Post;
FForm.ModalResult := mrOk;
except
FForm.ModalResult := mrNone;
end;
end;
procedure TJvDynControlDataSourceEditDialog.OnCancelButtonClick(Sender: TObject);
begin
if DataSource.Dataset.State in [dsInsert, dsEdit] then
DataSource.Dataset.Cancel;
FForm.ModalResult := mrCancel;
end;
procedure TJvDynControlDataSourceEditDialog.OnCloseButtonClick(Sender: TObject);
begin
FForm.ModalResult := mrAbort;
end;
constructor TJvDynControlDataSourceEditDialog.Create;
begin
inherited Create;
FDialogCaption := '';
FPostButtonCaption := RSSRWPostButtonCaption;
FCancelButtonCaption := RSSRWCancelButtonCaption;
FCloseButtonCaption := RSSRWCloseButtonCaption;
FPostButtonGlyph := nil;
FCancelButtonGlyph := nil;
FCloseButtonGlyph := nil;
FBorderStyle := bsDialog;
FTop := 0;
FLeft := 0;
FWidth := 0;
FHeight := 0;
FPosition := poScreenCenter;
FDynControlEngineDB := nil;
FDataSource := nil;
FArrangeSettings := TJvArrangeSettings.Create(nil);
with FArrangeSettings do
begin
AutoSize := asBoth;
DistanceHorizontal := 3;
DistanceVertical := 3;
BorderLeft := 3;
BorderTop := 3;
WrapControls := True;
end;
FArrangeConstraints := TSizeConstraints.Create(nil);
with FArrangeConstraints do
begin
MaxHeight := 480;
MaxWidth := 640;
end;
FFieldCreateOptions := TJvCreateDBFieldsOnControlOptions.Create;
end;
destructor TJvDynControlDataSourceEditDialog.Destroy;
begin
FFieldCreateOptions.Free;
FArrangeConstraints.Free;
FArrangeSettings.Free;
inherited Destroy;
end;
procedure TJvDynControlDataSourceEditDialog.SetArrangeSettings(Value: TJvArrangeSettings);
begin
FArrangeSettings.Assign(Value);
end;
procedure TJvDynControlDataSourceEditDialog.SetArrangeConstraints(Value: TSizeConstraints);
begin
FArrangeConstraints.Assign(Value);
end;
procedure TJvDynControlDataSourceEditDialog.SetFieldCreateOptions(Value: TJvCreateDBFieldsOnControlOptions);
begin
FFieldCreateOptions.Assign(Value);
end;
procedure TJvDynControlDataSourceEditDialog.ArrangePanelChangedWidth(Sender: TObject; ChangedSize: Integer);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -