Componentes.Terceros.DevExp.../official/x.19/ExpressQuantumGrid 5/Demos/Delphi/MasterDetailMultiDemo/MasterDetailMultiDemoMain.pas
2007-09-09 11:27:22 +00:00

166 lines
5.2 KiB
ObjectPascal

unit MasterDetailMultiDemoMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, cxControls, cxLookupGrid, cxLookupDBGrid, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxGridCustomView, cxGrid,
cxGridCardView, cxGridDBCardView, cxMaskEdit, StdCtrls, ExtCtrls,
cxContainer, cxEdit, cxTextEdit, cxDropDownEdit, cxDBEdit, cxStyles,
Menus, ActnList, ImgList, ComCtrls, cxLookAndFeels, DB,
DBTables, cxCustomData, cxGraphics, cxFilter, cxData, cxDBData, cxClasses,
cxGridBandedTableView, cxGridDBBandedTableView, cxDataStorage,
cxDBLookupComboBox, cxBlobEdit, cxImage, cxMemo, cxHyperLinkEdit;
type
TMasterDetailMultiDemoMainForm = class(TForm)
mmMain: TMainMenu;
miAbout: TMenuItem;
miFile: TMenuItem;
miOptions: TMenuItem;
miExit: TMenuItem;
miGenreTabPosition: TMenuItem;
sbMain: TStatusBar;
lbDescrip: TLabel;
Grid: TcxGrid;
cvPeople: TcxGridDBCardView;
cvPeopleName: TcxGridDBCardViewRow;
cvPeoplePersonLineID: TcxGridDBCardViewRow;
cvPeopleFIRSTNAME: TcxGridDBCardViewRow;
cvPeopleSECONDNAME: TcxGridDBCardViewRow;
cvPeopleNICKNAME: TcxGridDBCardViewRow;
cvPeopleBIRTHNAME: TcxGridDBCardViewRow;
cvPeopleDATEOFBIRTH: TcxGridDBCardViewRow;
cvPeopleLOCATIONOFBIRTH: TcxGridDBCardViewRow;
cvPeopleBIOGRAPHY: TcxGridDBCardViewRow;
cvPeopleHOMEPAGE: TcxGridDBCardViewRow;
cvPeopleID: TcxGridDBCardViewRow;
cvPeopleFilmID: TcxGridDBCardViewRow;
cvPeopleBIRTHCOUNTRY: TcxGridDBCardViewRow;
cvPeopleGender: TcxGridDBCardViewRow;
tvCompanies: TcxGridDBTableView;
tvCompaniesName: TcxGridDBColumn;
tvCompaniesType: TcxGridDBColumn;
tvCompaniesCountry: TcxGridDBColumn;
tvCompaniesWebSite: TcxGridDBColumn;
tvCompaniesID: TcxGridDBColumn;
tvCompaniesFILMID: TcxGridDBColumn;
cvPhotos: TcxGridDBCardView;
cvPhotosID: TcxGridDBCardViewRow;
cvPhotosFILMID: TcxGridDBCardViewRow;
cvPhotosSCREEN: TcxGridDBCardViewRow;
cvPhotosICON: TcxGridDBCardViewRow;
bvFilms: TcxGridDBBandedTableView;
bvFilmsCAPTION: TcxGridDBBandedColumn;
bvFilmsYEAR: TcxGridDBBandedColumn;
bvFilmsPLOTOUTLINE: TcxGridDBBandedColumn;
bvFilmsRUNTIME: TcxGridDBBandedColumn;
bvFilmsPHOTO: TcxGridDBBandedColumn;
bvFilmsWEBSITE: TcxGridDBBandedColumn;
miTabPositionLeft: TMenuItem;
miTabPositionTop: TMenuItem;
miTabPositionNone: TMenuItem;
LookAndFeelController: TcxLookAndFeelController;
procedure miAboutClick(Sender: TObject);
procedure miExitClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GridActiveTabChanged(Sender: TcxCustomGrid;
ALevel: TcxGridLevel);
procedure GridRootLevelStylesGetTabStyle(Sender,
ATabLevel: TcxGridLevel; out AStyle: TcxStyle);
procedure miTabPositionClick(Sender: TObject);
private
procedure CreateLevels;
end;
var
MasterDetailMultiDemoMainForm: TMasterDetailMultiDemoMainForm;
implementation
{$R *.dfm}
uses
MasterDetailMultiDemoData, AboutDemoForm;
procedure TMasterDetailMultiDemoMainForm.miAboutClick(Sender: TObject);
begin
ShowAboutDemoForm;
end;
procedure TMasterDetailMultiDemoMainForm.miExitClick(Sender: TObject);
begin
Close;
end;
procedure TMasterDetailMultiDemoMainForm.FormShow(Sender: TObject);
begin
CreateLevels;
if Grid.Levels.Count > 0 then
GridActiveTabChanged(Grid, Grid.Levels[0]);
end;
procedure TMasterDetailMultiDemoMainForm.CreateLevels;
begin
with MasterDetailMultiDemoMainDM do
begin
if not tblGenres.Active then
tblGenres.Open;
tblGenres.First;
while not tblGenres.Eof do
begin
with Grid.Levels.Add do
begin
Caption := tblGenresName.AsString;
Options.DetailTabsPosition := dtpTop;
Styles.Tab := cxStyle1;
Styles.TabsBackground := cxStyle39;
Add.Caption := 'Companies';
Add.Caption := 'People';
Add.Caption := 'Photos';
Tag := tblGenresID.AsInteger;
end;
tblGenres.Next;
end;
end;
end;
procedure TMasterDetailMultiDemoMainForm.GridActiveTabChanged(
Sender: TcxCustomGrid; ALevel: TcxGridLevel);
begin
if ALevel.IsMaster then
try
Grid.BeginUpdate;
ALevel.GridView := bvFilms;
ALevel.Items[0].GridView := tvCompanies;
ALevel.Items[1].GridView := cvPeople;
ALevel.Items[2].GridView := cvPhotos;
with MasterDetailMultiDemoMainDM do
begin
qryFilms.Params[0].Value := ALevel.Tag;
qryFilms.Close;
qryFilms.Open;
end;
bvFilms.DataController.ClearDetails;
finally
Grid.EndUpdate;
end;
end;
procedure TMasterDetailMultiDemoMainForm.GridRootLevelStylesGetTabStyle(
Sender, ATabLevel: TcxGridLevel; out AStyle: TcxStyle);
begin
if Grid.ActiveLevel = ATabLevel then
AStyle := MasterDetailMultiDemoMainDM.cxStyle9;
end;
procedure TMasterDetailMultiDemoMainForm.miTabPositionClick(Sender: TObject);
begin
(Sender as TMenuItem).Checked := True;
Grid.RootLevelOptions.DetailTabsPosition :=
TcxGridDetailTabsPosition(Byte((Sender as TMenuItem).Tag));
end;
end.