📄 rm_class.pas.~2~
字号:
{*****************************************}
{ }
{ Report Machine v2.0 }
{ Report classes }
{ }
{*****************************************}
unit RM_class;
interface
{$I RM.inc}
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Printers,
Forms, StdCtrls, ComCtrls, Dialogs, Menus, Buttons, Commctrl, RM_const,
RM_DBRel, RM_Pars, RM_Intrp, RM_DSet, RM_DBSet, DB, RM_View
, Variants;
const
// object flags
flStretched = $1;
flWordWrap = $2;
flWordBreak = $4;
flAutoSize = $8;
flTextOnly = $10;
flSuppressRepeated = $20;
flHideZeros = $40;
flUnderlines = $80;
flChildView = $100;
flRTLReading = $200;
flPrintFrame = $400;
flPrintVisible = $800;
flMergeRepeated = $1000;
flTotalCalc = $2000;
flCalcNoVisible = $4000;
flDontUndo = $4000;
flWantHook = $8000;
flMemoMangeTag = $1;
flOnePerPage = $2;
flMemoScaleFontSize = $4;
flMemoOutBigNum = $8;
flMemoPrintAtAppendBlank = $10;
flBandNewPageAfter = $2;
flBandPrintifSubsetEmpty = $4;
flBandBreaked = $8;
flBandOnFirstPage = $10;
flBandOnLastPage = $20;
flBandRepeatHeader = $40;
flBandPrintChildIfInvisible = $80;
flBandAutoAppendBlank = $100;
flBandAlignTop = $200;
flBandPrintColFirst = $400;
flBandRepeatHeader1 = $800;
flBandPrintIfEmpty = $1000;
flBandPrintatDesignPos = $2000;
flPictCenter = $2;
flPictRatio = $4;
flPictTransparent = $8;
// object types
gtMemo = 0;
gtPicture = 1;
gtBand = 2;
gtSubReport = 3;
gtLine = 4;
gtCalcMemo = 5;
gtCross = 6;
gtMoneyMemo = 7; //Add by david
gtRegion = 8;
gtAddIn = 10;
// frame types
RMftNone = 0;
RMftRight = 1;
RMftBottom = 2;
RMftLeft = 4;
RMftTop = 8;
RMftDouble = $10;
// text align
// rmtaLeft = 0;
rmtaRight = 1;
rmtaCenter = 2;
rmtaVertical = 4;
rmtaMiddle = 8;
rmtaDown = 16;
// band align
rmbaNone = 0;
rmbaLeft = 1;
rmbaRight = 2;
rmbaCenter = 3;
rmbaWidth = 4;
rmbaBottom = 5;
rmbaTop = 6;
rmbaClient = 7;
rmbaHeight = 8;
rmbaRest = 9;
// restriction flags
rmrfDontEditMemo = 1;
rmrfDontEditScript = 2;
rmrfDontEditContents = 4;
rmrfDontModify = 8;
rmrfDontSize = 16;
rmrfDontMove = 32;
rmrfDontDelete = 64;
psDouble = 7;
null=0;
type
TRMSizeUnits = (rmsuPixels, rmsuMM, rmsuInches);
TRMAlignment = (rmtaLeftJustify, rmtaRightJustify, rmtaCenterJustify, rmtaEuqalJustify);
TRMLayout = (rmtlTop, rmtlCenter, rmtlBottom);
TRMDocMode = (dmDesigning, dmPrinting);
TRMDrawMode = (drAll, drAfterCalcHeight, drPart);
TRMBandType = (btReportTitle, btReportSummary,
btPageHeader, btPageFooter,
btMasterHeader, btMasterData, btMasterFooter,
btDetailHeader, btDetailData, btDetailFooter,
btSubDetailHeader, btSubDetailData, btSubDetailFooter,
btOverlay, btColumnHeader, btColumnFooter,
btGroupHeader, btGroupFooter,
btCrossHeader, btCrossData, btCrossFooter, btChild, btNone);
TRMPageType = (ptReport, ptDialog);
TRMDataSetPosition = (psLocal, psGlobal);
TRMPageMode = (pmNormal, pmBuildList);
TRMBandRecType = (rtShowBand, rtFirst, rtNext);
TRMRgnType = (rtNormal, rtExtended);
TRMReportType = (rtSimple, rtMultiple);
TRMDataType = (RMdtString, RMdtInteger, RMdtFloat, RMdtBoolean,
RMdtColor, RMdtEnum, RMdtHasEditor, RMdtSize, RMdtOneObject, rmdtDate, rmdtTime);
TRMDataTypes = set of TRMDataType;
TRMPrintPages = (RMAll, RMOdd, RMEven);
//WHF Add
TRMDBCalcType = (rmdcSum, rmdcCount, rmdcAvg, rmdcMax, rmdcMin, rmdcUser);
TRMRotationType = (rmrtNone, rmrt90, rmrt180, rmrt270, rmrt360);
TRMScaleFontType = (rmstByWidth, rmstByHeight);
TRMView = class;
TRMBand = class;
TRMPage = class;
TRMReport = class;
TRMExportFilter = class;
TRMEMFPages = class;
TRMClass = class of TRMView;
TRMDetailEvent = procedure(const ParName: string; var ParValue: Variant) of object;
TRMEnterRectEvent = procedure(Memo: TStringList; View: TRMView) of object;
TRMAfterPrintEvent = procedure(const View: TRMView) of object;
TRMBeginDocEvent = procedure of object;
TRMEndDocEvent = procedure of object;
TRMBeginPageEvent = procedure(pgNo: Integer) of object;
TRMEndPageEvent = procedure(pg: Integer) of object;
TRMEndPrintPageEvent = procedure(var pg: Integer) of object;
TRMBeginBandEvent = procedure(Band: TRMBand) of object;
TRMBeforePrintBandEvent = procedure(Band: TRMBand; var PrintBand: Boolean) of object;
TRMEndBandEvent = procedure(Band: TRMBand) of object;
TRMProgressEvent = procedure(n: Integer) of object;
TRMBeginColumnEvent = procedure(Band: TRMBand) of object;
TRMPrintColumnEvent = procedure(ColNo: Integer; var Width: Integer) of object;
TRMManualBuildEvent = procedure(Page: TRMPage) of object;
TRMObjectClickEvent = procedure(EMFPages: TRMEMFPages; aPageNo: Integer; View: TRMView) of object;
TRMMouseOverObjectEvent = procedure(View: TRMView; var Cursor: TCursor) of object;
TRMBeforeExportEvent = procedure(var FileName: string; var bContinue: Boolean) of object;
TRMAfterExportEvent = procedure(const FileName: string) of object;
TRMPrintReportEvent = procedure of object;
TRMLocalizeEvent = procedure(StringID: Integer; var ResultString: string) of object;
TRMLoadSaveReportSetting = procedure(aReport: TRMReport) of object;
{ TRMFrameLine }
TRMFrameLine = packed record
Visible: Boolean;
Style: Byte;
Color: TColor;
Width: Single;
end;
TRMHighlightAttr = packed record
FontStyle: Word;
FontColor, FillColor: TColor;
end;
TRMPrnInfo = record // print info about page size, margins e.t.c
PPgw, PPgh, Pgw, Pgh: Integer; // page width/height (printer/screen)
POfx, POfy, Ofx, Ofy: Integer; // offset x/y
PPw, PPh, Pw, Ph: Integer; // printable width/height
end;
PRMPageInfo = ^TRMPageInfo;
TRMPageInfo = packed record // pages of a preview
R: TRect;
pgSize: Word;
pgWidth, pgHeight: Integer;
pgOr: TPrinterOrientation; //纸:横放,竖放
pgBin: integer;
pgMargins: TRect; //是否使用边界
PrnInfo: TRMPrnInfo;
Visible: Boolean;
Stream: TMemoryStream;
Page: TRMPage;
bkPictureIndex: Integer;
end;
PRMBandRec = ^TRMBandRec;
TRMBandRec = packed record
Band: TRMBand;
Action: TRMBandRecType;
TableEmpty: Boolean;
end;
PRMPropRec = ^TRMPropRec;
TRMPropRec = packed record
PropName: string;
PropType: TRMDataTypes;
Enum: TStringList;
EnumValues: Variant;
PropEditor: TNotifyEvent;
end;
PRMCacheItem = ^TRMCacheItem;
TRMCacheItem = record
DataSet: TDataSet;
DataField: string;
end;
{ TRMObject }
TRMObject = class(TObject)
private
protected
PropList: TList;
procedure ClearPropList;
procedure RemoveProperty(const APropName: string);
procedure AddProperty(const APropName: string; APropType: TRMDataTypes; APropEditor: TNotifyEvent);
procedure AddEnumProperty(const APropName, AEnum: string; const AEnumValues: array of Variant; aGetEnum: TNotifyEvent);
procedure SetPropValue(Index: string; Value: Variant); virtual;
function GetPropValue(Index: string): Variant; virtual;
function GetPropRec(const Index: string): PRMPropRec;
function DoMethod(const MethodName: string; Pars: array of Variant): Variant; virtual;
// helper methods
procedure SetFontProp(Font: TFont; const Prop: string; Value: Variant);
function GetFontProp(Font: TFont; const Prop: string): Variant;
function LinesMethod(Lines: TStrings; const MethodName, LinesName: string;
Par1, Par2, Par3: Variant): Variant;
public
constructor Create;
destructor Destroy; override;
procedure DefineProperties; virtual;
property Prop[Index: string]: Variant read GetPropValue write SetPropValue;
property PropRec[const Index: string]: PRMPropRec read GetPropRec;
end;
{ TRMView }
TRMView = class(TRMObject)
private
FIsStringValue: Boolean;
FOlddy: Integer;
procedure P1Click(Sender: TObject);
function GetStretched: Boolean;
procedure SetStretched(const value: Boolean);
function GetWantHook: Boolean;
procedure SetWantHook(const value: Boolean);
function GetPrintFrame: Boolean;
procedure SetPrintFrame(const value: Boolean);
function GetPrintVisible: Boolean;
procedure SetPrintVisible(const value: Boolean);
function GetChildView: Boolean;
procedure SetChildView(const Value: Boolean);
function GetTextOnly: Boolean;
procedure SetTextOnly(value: Boolean);
function GetOnePerPage: Boolean;
procedure SetOnePerPage(Value: Boolean);
protected
FFlag1: Boolean;
CanGenObject: Boolean;
Parent: TRMBand;
ParentPage: TRMPage;
SaveGX, SaveGY: Integer;
SaveX, SaveY, SaveDX, SaveDY: Integer;
SaveFWLeft, SaveFWTop, SaveFWRight, SaveFWBottom: Single;
SaveFontWidth: Integer;
BaseName: string;
Canvas: TCanvas;
DRect: TRect;
FDataSet: TDataSet;
FField: string;
StreamMode: (smDesigning, smPrinting);
function _CalcVFrameWidth(aTopWidth, aBottomWidth: Double): Integer;
function _CalcHFrameWidth(aLeftWidth, aRightWidth: Double): Integer;
function GetViewCommon: string; virtual;
procedure FreeChildControl; virtual;
procedure GenTmpObjects; virtual;
function AllowInplaceEdit: boolean; virtual;
procedure InplaceEdit(aParent: TWinControl; var InplaceEditor: TWinControl); virtual;
procedure SaveInplaceEdit(aInplaceEditor: TWinControl); virtual;
procedure ShowBackGround; virtual;
procedure ShowFrame; virtual;
procedure BeginDraw(ACanvas: TCanvas);
procedure GetBlob(b: TField); virtual;
procedure OnHook(View: TRMView); virtual;
procedure ExpandVariables(var s: string);
procedure SetPropValue(Index: string; Value: Variant); override;
function GetPropValue(Index: string): Variant; override;
procedure Loaded; virtual;
function DoMethod(const MethodName: string; Pars: array of Variant): Variant; override;
function ParentBand: TRMView;
procedure AddChildView(aStringList: TStrings); virtual;
procedure HideControls; virtual;
procedure Init; virtual;
procedure SetFrameProp(const Prop: string; Value: Variant);
function GetFrameProp(const Prop: string): Variant;
public
Name: string;
Typ: Byte; // One of gtXXX constants
HVersion, LVersion: Byte; // not used now
ID: Integer;
Selected: Boolean; // used in designer
OriginalRect: TRect;
ScaleX, ScaleY: Double; // used for scaling objects in preview
OffsX, OffsY: Integer; //
IsPrinting: Boolean;
x, y, dx, dy: Integer;
Flags: Word;
Flags1: LongInt;
LeftFrame, TopFrame, RightFrame, BottomFrame: TRMFrameLine;
LeftRightFrame: Word;
gapx, gapy: integer;
FillColor: TColor;
BandAlign: Byte;
Format: Integer;
FormatStr: string;
Visible: WordBool;
Restrictions: Word;
Tag: string;
Memo, Script, Script_AfterPrint: TStringList;
Memo1: TStringList;
ParentView: string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -