📄 frmdrawgridcellsetupunt.pas
字号:
unit frmDrawGridCellSetupUnt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FormDlgEscUnt, ExtCtrls, StdCtrls, ComCtrls, EAEdit, Spin,
ExtDlgs, ActnList, ImgList, Buttons, EAPanel, EAReportDrawGrid_Comp, jpeg;
type
TDrawGridCellSetupParam = record
Cells: TEAInnerReportDrawGridCellList;
Grid: TEAReportDrawGrid;
end;
TfrmDrawGridCellSetup = class(TFormDlgEsc)
pcMain: TPageControl;
tsTypeSet: TTabSheet;
tsFormatSet: TTabSheet;
tsAlignSet: TTabSheet;
cboCellType: TComboBox;
Label1: TLabel;
pcTypeMgr: TPageControl;
tsTypeText: TTabSheet;
tsTypeImage: TTabSheet;
tsTypeButton: TTabSheet;
tsTypeCombox: TTabSheet;
tsTypeStatic: TTabSheet;
Bevel1: TBevel;
Label2: TLabel;
Bevel2: TBevel;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
edtTextValue: TEAButtonEdit;
edtTextPostfix: TEdit;
edtTextPrefix: TEdit;
Label7: TLabel;
Bevel3: TBevel;
cboDateFmt: TComboBox;
Label5: TLabel;
Label8: TLabel;
Label9: TLabel;
dtpDateMax: TDateTimePicker;
dtpDateMin: TDateTimePicker;
Label10: TLabel;
Bevel4: TBevel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
edtDecimalLen: TSpinEdit;
edtNumMax: TEAEdit;
edtNumMin: TEAEdit;
chkNumFree: TCheckBox;
chkWordwrap: TCheckBox;
Label14: TLabel;
Bevel5: TBevel;
Label15: TLabel;
Label16: TLabel;
cboHAlign: TComboBox;
cboVAlign: TComboBox;
Bevel6: TBevel;
Bevel7: TBevel;
ActList: TActionList;
ImgList: TImageList;
ActFont: TAction;
dlgOpenPicture: TOpenPictureDialog;
dlgFont: TFontDialog;
btnOk: TButton;
btnCancel: TButton;
ActOk: TAction;
ActCancel: TAction;
Label19: TLabel;
cboImageAlign: TComboBox;
btnImageOpen: TSpeedButton;
ActOpenPic: TAction;
edtButtonValue: TEAButtonEdit;
Label18: TLabel;
cboComboValue: TComboBox;
btnComboAdjust: TSpeedButton;
ActAdjustCombo: TAction;
Label21: TLabel;
lbStaticList: TListBox;
btnStaticSet: TSpeedButton;
ActTitleSet: TAction;
tsFrameSet: TTabSheet;
btnFrame_AllNull: TSpeedButton;
btnFrame_Bottom: TSpeedButton;
btnFrame_Cross: TSpeedButton;
btnFrame_VertCenter: TSpeedButton;
btnFrame_Left: TSpeedButton;
btnFrame_Top: TSpeedButton;
btnFrame_ToLeftTop: TSpeedButton;
btnFrame_Right: TSpeedButton;
btnFrame_Outer: TSpeedButton;
btnFrame_HorzCenter: TSpeedButton;
Label22: TLabel;
Bevel8: TBevel;
cbBackColor: TColorBox;
Label23: TLabel;
Bevel9: TBevel;
btnButtonPic: TSpeedButton;
dfpFrame: TEADrawFramePanel;
dpImagePic: TEADrawPanel;
dpButtonPic: TEADrawPanel;
tsTypeCheck: TTabSheet;
Label27: TLabel;
btnFrame_ToRightTop: TSpeedButton;
imgImagePic: TImage;
imgButtonPic: TImage;
ActClearPic: TAction;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
cboCheckValue: TComboBox;
Label17: TLabel;
Bevel10: TBevel;
chkReadOnly: TCheckBox;
chkVisible: TCheckBox;
procedure cboCellTypeChange(Sender: TObject);
procedure ActTitleSetExecute(Sender: TObject);
procedure ActCancelExecute(Sender: TObject);
procedure ActOkExecute(Sender: TObject);
procedure cbBackColorChange(Sender: TObject);
procedure dfpFrameMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btnFrame_HorzCenterClick(Sender: TObject);
procedure btnFrame_BottomClick(Sender: TObject);
procedure btnFrame_LeftClick(Sender: TObject);
procedure btnFrame_VertCenterClick(Sender: TObject);
procedure btnFrame_RightClick(Sender: TObject);
procedure btnFrame_ToLeftTopClick(Sender: TObject);
procedure btnFrame_ToRightTopClick(Sender: TObject);
procedure btnFrame_AllNullClick(Sender: TObject);
procedure btnFrame_CrossClick(Sender: TObject);
procedure btnFrame_OuterClick(Sender: TObject);
procedure btnFrame_TopClick(Sender: TObject);
procedure dtpDateMaxChange(Sender: TObject);
procedure dtpDateMinChange(Sender: TObject);
procedure btnImageOpenClick(Sender: TObject);
procedure cboImageAlignChange(Sender: TObject);
procedure imgImagePicDblClick(Sender: TObject);
procedure btnButtonPicClick(Sender: TObject);
procedure imgButtonPicDblClick(Sender: TObject);
procedure dpButtonPicDblClick(Sender: TObject);
procedure dpImagePicDblClick(Sender: TObject);
procedure chkNumFreeClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure btnComboAdjustClick(Sender: TObject);
procedure edtTextValueButtonClick(Sender: TObject;
ClickObject: TEAButtonClickObject);
procedure edtButtonValueButtonClick(Sender: TObject;
ClickObject: TEAButtonClickObject);
procedure lbStaticListDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure edtTextValueChange(Sender: TObject);
procedure edtTextPrefixChange(Sender: TObject);
procedure edtTextPostfixChange(Sender: TObject);
procedure edtButtonValueChange(Sender: TObject);
procedure cboComboValueChange(Sender: TObject);
procedure chkCheckValueClick(Sender: TObject);
procedure cboDateFmtChange(Sender: TObject);
procedure edtDecimalLenChange(Sender: TObject);
procedure edtNumMaxChange(Sender: TObject);
procedure edtNumMinChange(Sender: TObject);
procedure cboHAlignChange(Sender: TObject);
procedure cboVAlignChange(Sender: TObject);
procedure chkWordwrapClick(Sender: TObject);
procedure cboCheckValueChange(Sender: TObject);
procedure chkReadOnlyClick(Sender: TObject);
procedure chkVisibleClick(Sender: TObject);
private
FParam: TDrawGridCellSetupParam;
procedure InitData;
procedure ClearData;
procedure SetData(AParam: TDrawGridCellSetupParam);
procedure UpdateFrameButtonDown;
procedure UpdateDecimalButtonEnable;
procedure UpdateImagePic;
procedure UpdateButtonPic;
public
{ Public declarations }
end;
function ShowDrawGridCellSetupDlg(AParam: TDrawGridCellSetupParam): Boolean;
var
frmDrawGridCellSetup: TfrmDrawGridCellSetup;
implementation
uses
EASysUtils, EAGraphicFun_Lib, EAReportPmmDefining_Lib,
frmEAPubMemoEditUnt, frmDrawGridStaticGridSetupUnt;
{$R *.dfm}
function ShowDrawGridCellSetupDlg(AParam: TDrawGridCellSetupParam): Boolean;
begin
Result := False;
if (AParam.Cells.Count = 0) then
Exit;
frmDrawGridCellSetup := TfrmDrawGridCellSetup.Create(Application);
with frmDrawGridCellSetup do
try
SetData(AParam);
InitData;
if ShowModal = IDOK then
Result := True;
finally
ClearData;
Free;
end;
frmDrawGridCellSetup := nil;
end;
const
cSImageWidth = 181;
cSImageHeight = 109;
cSTitleImg = 17;
procedure TfrmDrawGridCellSetup.cboCellTypeChange(Sender: TObject);
begin
case cboCellType.ItemIndex of
0..2: pcTypeMgr.ActivePage := tsTypeText;
3: pcTypeMgr.ActivePage := tsTypeImage;
4: pcTypeMgr.ActivePage := tsTypeButton;
5: pcTypeMgr.ActivePage := tsTypeCheck;
6: pcTypeMgr.ActivePage := tsTypeCombox;
7: pcTypeMgr.ActivePage := tsTypeStatic;
else
pcTypeMgr.ActivePage := nil;
end;
cboCellType.Tag := 1;
end;
procedure TfrmDrawGridCellSetup.ClearData;
begin
end;
procedure TfrmDrawGridCellSetup.InitData;
var
vCell: TEAReportDrawGridCell;
I, vInt: Integer;
begin
pcMain.ActivePageIndex := 0;
pcTypeMgr.ActivePageIndex := 0;
vCell := FParam.Cells[0];
cboCellType.ItemIndex := Integer(vCell.CellType);
cboCellTypeChange(cboCellType);
cboCellType.Tag := 0;
case cboCellType.ItemIndex of
0..2: begin
edtTextValue.Text := vCell.InnerText;
edtTextPrefix.Text := vCell.PrefixStr;
edtTextPostfix.Text := vCell.PostfixStr;
end;
3: begin
if not vCell.Picture.Empty then
begin
dpImagePic.Tag := 1;
dpImagePic.Invalidate;
imgImagePic.Picture.Graphic := vCell.Picture;
end;
cboImageAlign.ItemIndex := Integer(vCell.ImageAlign);
if not vCell.Picture.Empty then
begin
UpdateImagePic;
end;
end;
4: begin
edtButtonValue.Text := vCell.InnerText;
if not vCell.Picture.Empty then
begin
dpButtonPic.Tag := 1;
dpButtonPic.Invalidate;
end;
end;
5: begin
if vCell.Text = '1' then
cboCheckValue.ItemIndex := 1
else if vCell.Text = '2' then
cboCheckValue.ItemIndex := 2
else
cboCheckValue.ItemIndex := 0;
end;
6: begin
cboComboValue.Items.Assign(vCell.ComboList);
if not TryStrToInt(vCell.Text, vInt) then
vInt := -1;
cboComboValue.ItemIndex := vInt;
end;
7: begin
for I := 0 to vCell.StaticGrid.TitleCount - 1 do
lbStaticList.Items.Add(vCell.StaticGrid.Titles[I].Text);
end;
end;
edtTextValue.Tag := 0;
edtTextPrefix.Tag := 0;
edtTextPostfix.Tag := 0;
cboDateFmt.Text := vCell.CellFormat;
dtpDateMax.DateTime := vCell.MaxDate;
dtpDateMin.DateTime := vCell.MinDate;
edtDecimalLen.Value := vCell.DecimalLen;
edtNumMax.Text := FloatToStr(vCell.MaxNumber);
edtNumMin.Text := FloatToStr(vCell.MinNumber);
chkNumFree.Checked := vCell.FreeNumber;
cboHAlign.ItemIndex := Integer(vCell.HorzPos);
cboVAlign.ItemIndex := Integer(vCell.VertPos);
chkWordwrap.Checked := vCell.WordWrap;
chkReadOnly.Checked := vCell.ReadOnly;
chkVisible.Checked := vCell.Visible;
cbBackColor.Selected := vCell.Color;
dfpFrame.TopFrame := vCell.TFrame;
dfpFrame.LeftFrame := vCell.LFrame;
dfpFrame.BottomFrame := vCell.BFrame;
dfpFrame.RightFrame := vCell.RFrame;
dfpFrame.LeftDiagonal := vCell.LeftDiagonal;
dfpFrame.RightDiagonal := vCell.RightDiagonal;
dfpFrame.HCenter := vCell.TFrame and vCell.BFrame;
dfpFrame.VCenter := vCell.LFrame and vCell.RFrame;
UpdateFrameButtonDown;
end;
procedure TfrmDrawGridCellSetup.SetData(AParam: TDrawGridCellSetupParam);
begin
FParam := AParam;
end;
procedure TfrmDrawGridCellSetup.UpdateFrameButtonDown;
begin
btnFrame_Top.Down := dfpFrame.TopFrame;
btnFrame_HorzCenter.Down := dfpFrame.HCenter;
btnFrame_Bottom.Down := dfpFrame.BottomFrame;
btnFrame_Left.Down := dfpFrame.LeftFrame;
btnFrame_VertCenter.Down := dfpFrame.VCenter;
btnFrame_Right.Down := dfpFrame.RightFrame;
btnFrame_ToRightTop.Down := dfpFrame.RightDiagonal;
btnFrame_ToLeftTop.Down := dfpFrame.LeftDiagonal;
end;
procedure TfrmDrawGridCellSetup.ActTitleSetExecute(Sender: TObject);
var
P: TDrawGridStaticGridSetupParam;
I: Integer;
begin
P.StaticGrid := TEAReportStaticGrid.Create(nil);
try
P.StaticGrid.Assign(FParam.Cells[0].StaticGrid);
if ShowDrawGridStaticGridSetupDlg(P) then
begin
for I := 0 to FParam.Cells.Count - 1 do
FParam.Cells[I].StaticGrid.Assign(P.StaticGrid);
lbStaticList.Items.BeginUpdate;
lbStaticList.Clear;
for I := 0 to P.StaticGrid.TitleCount - 1 do
lbStaticList.Items.Add(P.StaticGrid.Titles[I].Text);
lbStaticList.Tag := 1;
lbStaticList.Items.EndUpdate;
end;
finally
P.StaticGrid.Free;
end;
end;
procedure TfrmDrawGridCellSetup.ActCancelExecute(Sender: TObject);
begin
Close;
end;
procedure TfrmDrawGridCellSetup.ActOkExecute(Sender: TObject);
var
I: Integer;
vFrames: TEAGridFrames;
B: Boolean;
vJpg: TJPEGImage;
begin
B := False;
for I := 0 to FParam.Cells.Count - 1 do
begin
{ type }
if cboCellType.Tag = 1 then
begin
B := True;
FParam.Cells[I].CellType := TEAGridCellType(cboCellType.ItemIndex);
end;
case FParam.Cells[I].CellType of
egctString, egctNumber, egctDate: begin
if edtTextValue.Tag = 1 then
begin
B := True;
FParam.Cells[I].InnerText := edtTextValue.Text;
end;
if edtTextPrefix.Tag = 1 then
begin
B := True;
FParam.Cells[I].PrefixStr := edtTextPrefix.Text;
end;
if edtTextPostfix.Tag = 1 then
begin
B := True;
FParam.Cells[I].PostfixStr := edtTextPostfix.Text;
end;
end;
egctImage: begin
if imgImagePic.Tag = 1 then
begin
B := True;
vJpg := TJPEGImage.Create;
try
ea.Graphics.PictureToJpeg(imgImagePic.Picture, vJpg);
FParam.Cells[I].Picture := vJpg;
finally
vJpg.Free;
end;
FParam.Cells[I].ImageAlign := TEAImageAlign(cboImageAlign.ItemIndex);
end;
end;
egctButton: begin
if edtButtonValue.Tag = 1 then
begin
B := True;
FParam.Cells[I].InnerText := edtButtonValue.Text;
end;
if imgButtonPic.Tag = 1 then
begin
B := True;
vJpg := TJPEGImage.Create;
try
ea.Graphics.PictureToJpeg(imgButtonPic.Picture, vJpg);
FParam.Cells[I].Picture := vJpg;
finally
vJpg.Free;
end;
end;
end;
egctCheckBox: begin
if cboCheckValue.Tag = 1 then
begin
B := True;
FParam.Cells[I].Text := IntToStr(cboCheckValue.ItemIndex);
end;
end;
egctComboList: begin
if cboComboValue.Tag = 1 then
begin
B := True;
FParam.Cells[I].InnerText := IntToStr(cboComboValue.ItemIndex);
FParam.Cells[I].ComboList.Assign(cboComboValue.Items);
end;
end;
egctStaticGrid: begin
if lbStaticList.Tag = 1 then
B := True;
end;
end;
{ format }
if cboDateFmt.Tag = 1 then
begin
B := True;
FParam.Cells[I].CellFormat := cboDateFmt.Text;
end;
if dtpDateMax.Tag = 1 then
begin
B := True;
FParam.Cells[I].MaxDate := dtpDateMax.DateTime;
end;
if dtpDateMin.Tag = 1 then
begin
B := True;
FParam.Cells[I].MinDate := dtpDateMin.DateTime;
end;
if edtDecimalLen.Tag = 1 then
begin
B := True;
FParam.Cells[I].DecimalLen := edtDecimalLen.Value;
end;
if edtNumMax.Tag = 1 then
begin
B := True;
FParam.Cells[I].MaxNumber := edtNumMax.AsFloat;
end;
if edtNumMin.Tag = 1 then
begin
B := True;
FParam.Cells[I].MinNumber := edtNumMin.AsFloat;
end;
if chkNumFree.Tag = 1 then
begin
B := True;
FParam.Cells[I].FreeNumber := chkNumFree.Checked;
end;
{ align }
if cboHAlign.Tag = 1 then
begin
B := True;
FParam.Cells[I].HorzPos := TEAHorzPos(cboHAlign.ItemIndex);
end;
if cboVAlign.Tag = 1 then
begin
B := True;
FParam.Cells[I].VertPos := TEAVertPos(cboVAlign.ItemIndex);
end;
if chkWordwrap.Tag = 1 then
begin
B := True;
FParam.Cells[I].WordWrap := chkWordwrap.Checked;
end;
if chkReadOnly.Tag = 1 then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -