diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 1aab5fb71..0afd72e29 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -112,7 +112,7 @@ type end; TPrintParams = record - Title : String; + JobTitle : String; // print job title to be shown in system printing manager Margins : TRectOffsets; // margins in points SelStart : Integer; SelLength : Integer; @@ -122,6 +122,13 @@ type Pages : Integer; end; + TPrintAction = (paDocStart, paPageStart, paPageEnd, paDocEnd); + + TPrintActionEvent = procedure (Sender: TObject; + APrintAction: TPrintAction; + PrintCanvas: TCanvas; + CurrentPage: Integer; var AbortPrint: Boolean) of object; + type TRichMemoObject = class(TObject); TCustomRichMemo = class; @@ -145,9 +152,10 @@ type TCustomRichMemo = class(TCustomMemo) private - fHideSelection : Boolean; - fOnSelectionChange: TNotifyEvent; - fZoomFactor : Double; + fHideSelection : Boolean; + fOnSelectionChange : TNotifyEvent; + fOnPrintAction : TPrintActionEvent; + fZoomFactor : Double; private procedure InlineInvalidate(handler: TRichMemoInline); @@ -164,6 +172,11 @@ type procedure SetSelText(const SelTextUTF8: string); override; function GetZoomFactor: Double; virtual; procedure SetZoomFactor(AValue: Double); virtual; + + procedure DoPrintAction(PrintJobEvent: TPrintAction; + PrintCanvas: TCanvas; + CurrentPage: Integer; var AbortPrint: Boolean); + public constructor Create(AOwner: TComponent); override; procedure CopyToClipboard; override; @@ -211,6 +224,7 @@ type property HideSelection : Boolean read fHideSelection write SetHideSelection; property OnSelectionChange: TNotifyEvent read fOnSelectionChange write fOnSelectionChange; property ZoomFactor: Double read GetZoomFactor write SetZoomFactor; + property OnPrintAction: TPrintActionEvent read fOnPrintAction write fOnPrintAction; end; { TRichMemo } @@ -262,6 +276,7 @@ type property OnMouseWheelUp; property OnSelectionChange; property OnStartDrag; + property OnPrintAction; property OnUTF8KeyPress; property ParentBidiMode; property ParentColor; @@ -537,6 +552,16 @@ begin TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, AValue); end; +procedure TCustomRichMemo.DoPrintAction(PrintJobEvent: TPrintAction; + PrintCanvas: TCanvas; CurrentPage: Integer; var AbortPrint: Boolean); +begin + if Assigned(OnPrintAction) then + try + OnPrintAction(Self, PrintJobEvent, PrintCanvas, CurrentPAge, AbortPrint); + except + end; +end; + procedure TCustomRichMemo.InlineInvalidate(handler: TRichMemoInline); begin if not Assigned(handler) then Exit; diff --git a/components/richmemo/richmemohelpers.pas b/components/richmemo/richmemohelpers.pas index 72c3afd14..bc88c5edd 100644 --- a/components/richmemo/richmemohelpers.pas +++ b/components/richmemo/richmemohelpers.pas @@ -345,7 +345,7 @@ var prm : TPrintParams; begin InitPrintParams(prm); - prm.Title:=ACaption; + prm.JobTitle:=ACaption; Print(prm); end; diff --git a/components/richmemo/samples/print/mainform.lfm b/components/richmemo/samples/print/mainform.lfm index 052dd69af..c3180dfa1 100644 --- a/components/richmemo/samples/print/mainform.lfm +++ b/components/richmemo/samples/print/mainform.lfm @@ -6,7 +6,8 @@ object Form1: TForm1 Caption = 'Form1' ClientHeight = 240 ClientWidth = 687 - LCLVersion = '1.2.4.0' + OnCreate = FormCreate + LCLVersion = '1.3' object RichMemo1: TRichMemo Left = 8 Height = 178 diff --git a/components/richmemo/samples/print/mainform.pas b/components/richmemo/samples/print/mainform.pas index 18cdbf976..d6d30696a 100644 --- a/components/richmemo/samples/print/mainform.pas +++ b/components/richmemo/samples/print/mainform.pas @@ -26,10 +26,14 @@ type procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); + procedure FormCreate(Sender: TObject); private { private declarations } public { public declarations } + procedure RichMemo1PrintAction(Sender: TObject; + APrintAction: TPrintAction; PrintCanvas: TCanvas; + CurrentPage: Integer; var AbortPrint: Boolean); end; var @@ -75,7 +79,7 @@ begin InitPrintParams(prm); prm.SelStart:=RichMemo1.SelStart; prm.SelLength:=RichMemo1.SelLength; - prm.Title:='Rich Memo Printing'; + prm.JobTitle:='Rich Memo Printing'; PageSetupToMargins(PageSetupDialog1, prm); RichMemo1.Print(prm); @@ -91,5 +95,22 @@ begin PageSetupDialog1.Execute; end; +procedure TForm1.FormCreate(Sender: TObject); +begin + RichMemo1.OnPrintAction:=@RichMemo1PrintAction; +end; + +procedure TForm1.RichMemo1PrintAction(Sender: TObject; + APrintAction: TPrintAction; PrintCanvas: TCanvas; CurrentPage: Integer; + var AbortPrint: Boolean); +begin + if APrintAction=paPageStart then begin + PrintCanvas.Brush.Color:=clBlue; + PrintCanvas.Brush.Style:=bsSolid; + PrintCanvas.Ellipse(100,100,200,200); + end; + writeln('action: ', APrintAction); +end; + end. diff --git a/components/richmemo/samples/print/project1.lpi b/components/richmemo/samples/print/project1.lpi index 5dd94c6e0..130a99fea 100644 --- a/components/richmemo/samples/print/project1.lpi +++ b/components/richmemo/samples/print/project1.lpi @@ -9,7 +9,6 @@