From: Rod O. <rod...@us...> - 2006-05-06 15:43:53
|
Update of /cvsroot/win32forth/win32forth/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9809/src/lib Modified Files: ScintillaControl.f Log Message: Rod: Added methods for printing - FormatRange: and Print: Index: ScintillaControl.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/src/lib/ScintillaControl.f,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScintillaControl.f 31 Aug 2005 17:03:19 -0000 1.2 --- ScintillaControl.f 6 May 2006 15:43:48 -0000 1.3 *************** *** 10,13 **** --- 10,15 ---- \ See www.scintilla.org for more information about the control. + \ Saturday, May 06 2006 Added methods for printing - Rod + cr .( Loading Scintilla Control...) *************** *** 1914,1917 **** --- 1916,1996 ---- + \ ----------------------------------------------------------------------------- + \ Printing + \ ----------------------------------------------------------------------------- + + Record: RangeToFormat + int hdcPrinter + int hdcTarget + rectangle Pagesize + rectangle rcPage + int cpMin \ CharacterRange + int cpMax + ;Record + + :M FormatRange: ( f -- n ) RangeToFormat swap SCI_FORMATRANGE SendMessage:Self ;M + + \ assume PSD_INTHOUSANDTHSOFINCHES used in PageSetup + : Xpixels ( n -- n ) DPI: ThePrinter drop 1000 */ ; + : Ypixels ( n -- n ) DPI: ThePrinter nip 1000 */ ; + \ if PSD_INHUNDREDTHSOFMILLIMETERS used replace 1000 with 2540 + + : SetFormatRange ( -- ) + GetHandle: ThePrinter dup to hdcPrinter to hdcTarget + rtMargin @ Xpixels rtMargin cell+ @ Ypixels + Width: ThePrinter rtMargin 2 cells+ @ Xpixels - + Height: ThePrinter rtMargin 3 cells+ @ Ypixels - + SetRect: PageSize EraseRect: rcPage + 0 to cpMin GetTextLength: self to cpMax + ; + + :M Print: ( -- ) + hWnd hwndOwner ! + 1 nFromPage w! + + \ Find number of pages needed to print the file using the default printer + hDevMode 2@ \ save selected printer + Auto-print-init PutHandle: ThePrinter + SetFormatRange + SaveDC: ThePrinter + ( PageNo ) 1 + BEGIN + FALSE FormatRange: self to cpMin + dup nMaxPage < cpMin cpMax < and + WHILE 1+ + REPEAT dup nToPage w! nMaxPage w! + RestoreDC: ThePrinter + print-close + hDevMode 2! \ restore selected printer + \ Number of pages is put into nToPage and nMaxPage + + false + PD_HIDEPRINTTOFILE + nToPage w@ print-init2 ?dup + IF + PutHandle: ThePrinter + \ FileName 1+ DocName ! + SetFormatRange + Print-flags PD_SELECTION and + IF GetSelectionStart: self to cpMin GetSelectionEnd: self to cpMax THEN + \ Print-flags PD_CURRENTPAGE and + \ IF GetFirstVisibleLine: self dup PositionFromLine: self to cpMin LinesOnScreen: self + 1- PositionFromLine: self to cpMax THEN + SaveDC: ThePrinter + print-start + ( PageNo ) 1 + BEGIN + dup Get-frompage Get-topage between + IF start-page TRUE FormatRange: self to cpMin end-page + ELSE FALSE FormatRange: self to cpMin + THEN + dup nMaxPage < cpMin cpMax < and + WHILE 1+ + REPEAT drop ( last PageNo ) + print-end + RestoreDC: ThePrinter + print-close + THEN + ;M + ;Class |