home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
zkuste
/
delphi
/
nastroje
/
d3456
/
KBMWABD.ZIP
/
WABD_DBNavigator.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2001-07-15
|
9KB
|
301 lines
unit WABD_DBNavigator;
{$I kbmWABD.inc}
interface
uses SysUtils, Classes, WABD_Objects,Dialogs,DB,Graphics;
type
TWABD_DBNavigator = class;
// Derive from TWABD_FormSection_Base insead of just TWABD_FormSection
// so that the user can NOT edit the child controls in the WABD Form
// designer
{
TWABD_OnResizeTable = procedure(Sender:TObject) of object;
TWABD_OnRenderTable = procedure(Sender:TObject) of object;
TWABD_OnRenderTableCell = procedure(Sender:TObject; Cell:TWABD_SectionObject; Col,Row:integer) of object;
TWABD_OnRenderTableHeaderCell = procedure(Sender:TObject; HeaderCell:TWABD_Label; Col:integer) of object;
}
TWABD_DBNavigator_DataLink = class(TDataLink)
private
FOnActiveChanged:TNotifyEvent;
FOnDatasetChanged:TNotifyEvent;
FNavigator:TWABD_DBNavigator;
protected
procedure DatasetChanged; override;
procedure ActiveChanged; override;
published
property OnActiveChanged:TNotifyEvent read FOnActiveChanged write FOnActiveChanged;
property OnDatasetChanged:TNotifyEvent read FOnDatasetChanged write FOnDatasetChanged;
end;
TWABD_DBNavigator = class(TWABD_Object)
protected
FDataLink : TWABD_DBNavigator_DataLink;
FImgPrevPage: TWABD_Base_Image;
FImgPrev : TWABD_Base_Image;
FImgNext : TWABD_Base_Image;
FImgFirst : TWABD_Base_Image;
FImgLast : TWABD_Base_Image;
FImgNextPage: TWABD_Base_Image;
FImgEdit : TWABD_Base_Image;
FImgDelete : TWABD_Base_Image;
FImgAdd : TWABD_Base_Image;
FImgRefresh : TWABD_Base_Image;
FImgPost : TWABD_Base_Image;
FImgCancel : TWABD_Base_Image;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
function IsLinked:boolean;
function GetDataSource: TDataSource;
procedure SetDataSource(NewDataSource: TDataSource);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Object_To_HTML:string; override;
published
property DataSource: TDataSource read GetDataSource write SetDataSource;
property ImgPrevPage:TWABD_Base_Image read FImgPrevPage write FImgPrevPage;
property ImgPrev:TWABD_Base_Image read FImgPrev write FImgPrev;
property ImgNextPage:TWABD_Base_Image read FImgNextPage write FImgNextPage;
property ImgNext:TWABD_Base_Image read FImgNext write FImgNext;
property ImgFirst:TWABD_Base_Image read FImgFirst write FImgFirst;
property ImgLast:TWABD_Base_Image read FImgLast write FImgLast;
property ImgEdit:TWABD_Base_Image read FImgEdit write FImgEdit;
property ImgDelete:TWABD_Base_Image read FImgDelete write FImgDelete;
property ImgAdd:TWABD_Base_Image read FImgAdd write FImgAdd;
property ImgRefresh:TWABD_Base_Image read FImgRefresh write FImgRefresh;
property ImgPost:TWABD_Base_Image read FImgPost write FImgPost;
property ImgCancel:TWABD_Base_Image read FImgCancel write FImgCancel;
end;
implementation
// TWABD_DBNavigator_DataLink
procedure TWABD_DBNavigator_DataLink.ActiveChanged;
begin
if assigned(FOnActiveChanged) then FOnActiveChanged(self);
end;
procedure TWABD_DBNavigator_DataLink.DatasetChanged;
begin
if assigned(FOnDatasetChanged) then FOnDatasetChanged(self);
end;
// TWABD_DBNavigator.
constructor TWABD_DBNavigator.Create(AOwner: TComponent);
begin
inherited;
// GridX := 30;
// GridY := 30;
// CellBorder := 0;
FImgPrev:=nil;
FImgNext:=nil;
FImgPrevPage:=nil;
FImgNextPage:=nil;
FImgFirst:=nil;
FImgLast:=nil;
FImgEdit:=nil;
FImgDelete:=nil;
FImgAdd:=nil;
FImgRefresh:=nil;
FImgPost:=nil;
FImgCancel:=nil;
FDataLink:=TWABD_DBNavigator_DataLink.Create;
FDataLink.FNavigator:=self;
FDataLink.DataSource:=nil;
end;
destructor TWABD_DBNavigator.Destroy;
begin
FDataLink.free;
inherited;
end;
procedure TWABD_DBNavigator.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (Operation = opRemove) then
begin
if AComponent = FDataLink.DataSource then FDataLink.DataSource := nil
else if AComponent = FImgPrev then FImgPrev:=nil
else if AComponent = FImgNext then FImgNext:=nil
else if AComponent = FImgPrevPage then FImgPrevPage:=nil
else if AComponent = FImgNextPage then FImgNextPage:=nil
else if AComponent = FImgFirst then FImgFirst:=nil
else if AComponent = FImgLast then FImgLast:=nil
else if AComponent = FImgEdit then FImgEdit:=nil
else if AComponent = FImgDelete then FImgDelete:=nil
else if AComponent = FImgAdd then FImgAdd:=nil
else if AComponent = FImgRefresh then FImgRefresh:=nil
else if AComponent = FImgPost then FImgPost:=nil
else if AComponent = FImgCancel then FImgCancel:=nil;
end;
end;
function TWABD_DBNavigator.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
procedure TWABD_DBNavigator.SetDataSource(NewDataSource: TDataSource);
begin
FDataLink.DataSource := NewDataSource;
if NewDataSource<>nil then NewDataSource.FreeNotification(self);
end;
function TWABD_DBNavigator.IsLinked:boolean;
begin
Result:=(FDataLink<>nil) and (FDataLink.DataSource<>nil) and (FDataLink.DataSource.DataSet<>nil) and
(FDataLink.DataSource.DataSet.Active);
end;
function TWABD_DBNavigator.Object_To_HTML:string;
begin
// Output images.
Result:='<p>'+CR;
if FImgFirst<>nil then Result:=Result+FImgFirst.Object_To_HTML+CR;
if FImgPrevPage<>nil then Result:=Result+FImgPrevPage.Object_To_HTML+CR;
if FImgPrev<>nil then Result:=Result+FImgPrev.Object_To_HTML+CR;
if FImgNext<>nil then Result:=Result+FImgNext.Object_To_HTML+CR;
if FImgNextPage<>nil then Result:=Result+FImgNextPage.Object_To_HTML+CR;
if FImgLast<>nil then Result:=Result+FImgLast.Object_To_HTML+CR;
Result:=Result+'<br>'+CR;
if FImgAdd<>nil then Result:=Result+FImgAdd.Object_To_HTML+CR;
if FImgDelete<>nil then Result:=Result+FImgDelete.Object_To_HTML+CR;
if FImgEdit<>nil then Result:=Result+FImgEdit.Object_To_HTML+CR;
if FImgRefresh<>nil then Result:=Result+FImgRefresh.Object_To_HTML+CR;
if FImgPost<>nil then Result:=Result+FImgPost.Object_To_HTML+CR;
if FImgCancel<>nil then Result:=Result+FImgCancel.Object_To_HTML+CR;
Result:=Result+'</p>'+CR;
end;
(*
with FImgFirst do
begin
AltText:='First';
LeftPos:=0;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgPrevPage<>nil then
with FImgPrevPage do
begin
AltText:='Prev. Page';
LeftPos:=31;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgPrev<>nil then
with FImgPrev do
begin
AltText:='Prev';
LeftPos:=61;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgNext<>nil then
with FImgNext do
begin
AltText:='Next';
LeftPos:=91;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgNextPage<>nil then
with FImgNextPage do
begin
AltText:='Next Page';
LeftPos:=121;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgLast<>nil then
with FImgLast do
begin
AltText:='Last';
LeftPos:=151;
TopPos:=0;
Width:=30;
Height:=30;
end;
if FImgAdd<>nil then
with FImgAdd do
begin
AltText:='Add';
LeftPos:=0;
TopPos:=31;
Width:=30;
Height:=30;
end;
if FImgDelete<>nil then
with FImgDelete do
begin
AltText:='Delete';
LeftPos:=31;
TopPos:=31;
Width:=30;
Height:=30;
end;
if FImgEdit<>nil then
with FImgEdit do
begin
AltText:='Edit';
LeftPos:=61;
TopPos:=31;
Width:=30;
Height:=30;
end;
if FImgRefresh<>nil then
with FImgRefresh do
begin
AltText:='Refresh';
LeftPos:=91;
TopPos:=31;
Width:=30;
Height:=30;
end;
if FImgPost<>nil then
with FImgPost do
begin
AltText:='Post';
LeftPos:=121;
TopPos:=31;
Width:=30;
Height:=30;
end;
if FImgCancel<>nil then
with FImgCancel do
begin
AltText:='Cancel';
LeftPos:=151;
TopPos:=31;
Width:=30;
Height:=30;
end;
*)
end.