432 "Created: / 02-08-2006 / 17:47:20 / fm" |
369 "Created: / 02-08-2006 / 17:47:20 / fm" |
433 "Modified: / 03-08-2006 / 10:09:01 / fm" |
370 "Modified: / 03-08-2006 / 10:09:01 / fm" |
434 "Modified: / 10-10-2006 / 18:15:17 / cg" |
371 "Modified: / 10-10-2006 / 18:15:17 / cg" |
435 ! |
372 ! |
436 |
373 |
437 horizontalPixelsPerMeter |
|
438 "Answer horizontal pixels per meter |
|
439 on the screen." |
|
440 ^self pixelsPerInchOfScreenWidth * 39.3700787 |
|
441 ! |
|
442 |
|
443 name |
|
444 "Answer the receiver's name from the current printerInfo." |
|
445 |
|
446 ^ self printerInfo printerName |
|
447 |
|
448 "Modified: / 02-08-2006 / 16:55:03 / fm" |
|
449 "Modified: / 10-10-2006 / 18:15:33 / cg" |
|
450 ! |
|
451 |
|
452 name:aName |
|
453 "Set the receiver's printer name to aName." |
|
454 |
|
455 self printerInfo:(self class getPrinterInformation:aName) |
|
456 |
|
457 "Modified: / 10-10-2006 / 18:15:36 / cg" |
|
458 ! |
|
459 |
|
460 numberOfColorBitsPerPixel |
374 numberOfColorBitsPerPixel |
461 ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel" |
375 ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel" |
462 |
376 |
463 "Created: / 03-08-2006 / 09:58:18 / fm" |
377 "Created: / 03-08-2006 / 09:58:18 / fm" |
464 "Modified: / 10-10-2006 / 18:15:40 / cg" |
378 "Modified: / 10-10-2006 / 18:15:40 / cg" |
465 ! |
379 ! |
466 |
380 |
467 physicalOffsetX |
381 physicalOffsetX |
468 |
|
469 "Papierhöhe in Pixels" |
|
470 "Changed by K3/EEZ3-Mg, 02.03.99" |
|
471 |
|
472 ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX" |
382 ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX" |
473 |
383 |
474 "Created: / 01-08-2006 / 16:28:34 / fm" |
384 "Created: / 01-08-2006 / 16:28:34 / fm" |
|
385 "Modified: / 16-04-2007 / 12:52:06 / cg" |
475 ! |
386 ! |
476 |
387 |
477 physicalOffsetY |
388 physicalOffsetY |
478 |
|
479 "Papierhöhe in Pixels" |
|
480 "Changed by K3/EEZ3-Mg, 02.03.99" |
|
481 |
|
482 ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY" |
389 ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY" |
483 |
390 |
484 "Created: / 01-08-2006 / 16:28:34 / fm" |
391 "Created: / 01-08-2006 / 16:28:34 / fm" |
|
392 "Modified: / 16-04-2007 / 12:52:01 / cg" |
485 ! |
393 ! |
486 |
394 |
487 pixelsPerInchOfScreenHeight |
395 pixelsPerInchOfScreenHeight |
488 ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy" |
396 ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy" |
489 |
397 |
619 aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew. |
457 aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew. |
620 aCopy setDevice:device id:nil gcId:gcId. |
458 aCopy setDevice:device id:nil gcId:gcId. |
621 ^ aCopy |
459 ^ aCopy |
622 |
460 |
623 "Created: / 16-04-2007 / 12:39:02 / cg" |
461 "Created: / 16-04-2007 / 12:39:02 / cg" |
624 ! |
|
625 |
|
626 initExtent |
|
627 "Private - init the width and height of GraphicsTool for the receiver." |
|
628 |
|
629 width := self printerWidthArea. |
|
630 height := self printerHeightArea. |
|
631 device |
|
632 width:width; |
|
633 height:height. |
|
634 |
|
635 |
|
636 "Modified: / 01-08-2006 / 16:14:49 / fm" |
|
637 ! ! |
|
638 |
|
639 !WinPrinterContext methodsFor:'printing'! |
|
640 |
|
641 print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
|
642 "Answer the receiver. Output the receiver string to |
|
643 the printer using aFont. A Print abort dialog box will be opened |
|
644 with aTitle. If collateBoolean is true, collate output, otherwise |
|
645 do not. Print copiesInteger copies of the specified string. If |
|
646 wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
647 Left, top, right & bottom margins are specified in inches in |
|
648 aMarginsRect." |
|
649 |
|
650 |lines linesPerPage totalPage marginsRect firstPage abortDialog| |
|
651 |
|
652 jobid isNil ifTrue:[ |
|
653 self startPrintJob:aTitle |
|
654 ]. |
|
655 abortDialog := PrintAbortDialog new open:aTitle printer:self. |
|
656 self font:aFont. |
|
657 marginsRect := self marginsRectangleFor:aMarginsRect. |
|
658 lines := self |
|
659 asArrayOfStringLines:aString |
|
660 in:marginsRect |
|
661 wordWrap:wordWrapBoolean. |
|
662 linesPerPage := self linesPerPageFor: marginsRect. |
|
663 totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
|
664 firstPage := true. |
|
665 |
|
666 "/ collateBoolean |
|
667 "/ ifTrue: [ |
|
668 "/ copiesInteger timesRepeat: [ |
|
669 |
|
670 1 to:totalPage do:[:page | |
|
671 abort ifTrue:[ ^ self ]. |
|
672 firstPage ifFalse:[ |
|
673 self formFeed |
|
674 ]. |
|
675 abortDialog |
|
676 updatePrintingPageInfo:(self class classResources |
|
677 string:'Page %1/%2' |
|
678 with:page printString |
|
679 with:totalPage printString). |
|
680 |
|
681 "/ self device font: printerFont. |
|
682 |
|
683 self font:aFont. |
|
684 self |
|
685 printPage:page |
|
686 in:marginsRect |
|
687 lines:lines |
|
688 linesPerPage:linesPerPage. |
|
689 firstPage := false |
|
690 ]. |
|
691 |
|
692 "/ ] |
|
693 "/ ] ifFalse: [ |
|
694 "/ 1 to: totalPage do: [ :page | |
|
695 "/ copiesInteger timesRepeat: [ |
|
696 "/ abort ifTrue: [ ^self endPrintJob ]. |
|
697 "/ firstPage ifFalse: [ self formFeed ]. |
|
698 "/ self device font: printerFont. |
|
699 "/ self printPage: page in: marginsRect lines: lines linesPerPage: linesPerPage. |
|
700 "/ firstPage := false |
|
701 "/ ] |
|
702 "/ ] |
|
703 "/ ]. |
|
704 |
|
705 jobid notNil ifTrue:[ |
|
706 self endPrintJob. |
|
707 abortDialog close. |
|
708 ]. |
|
709 |
|
710 "/ abort ifFalse: [ abortDialog close ] |
|
711 |
|
712 "Created: / 03-08-2006 / 16:13:33 / fm" |
|
713 "Modified: / 04-08-2006 / 13:40:02 / fm" |
|
714 "Modified: / 10-10-2006 / 18:16:54 / cg" |
|
715 "Modified: / 12-10-2006 / 11:50:37 / User" |
|
716 ! |
|
717 |
|
718 print: aString |
|
719 pageHeader: aString2 |
|
720 font: aFont |
|
721 title: aTitle |
|
722 collate: collateBoolean |
|
723 copies: copiesInteger |
|
724 wordWrap: wordWrapBoolean |
|
725 marginsRect: aMarginsRect |
|
726 |
|
727 "Private - Answer the receiver. Output the receiver string to |
|
728 the printer using aFont. A Print abort dialog box will be opened |
|
729 with aTitle. If collateBoolean is true, collate output, otherwise |
|
730 do not. Print copiesInteger copies of the specified string. If |
|
731 wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
732 Left, top, right & bottom margins are specified in inches in |
|
733 aMarginsRect. |
|
734 Mg: Erweitert um pageHeader" |
|
735 "Changed by K3/EES5-Mg, 08.01.96" |
|
736 |
|
737 | lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
|
738 |
|
739 printerFont := self setPrinterFont: aFont. |
|
740 charHeight := self "pen" getCharHeight. |
|
741 marginsRect := self marginsRectangleFor: aMarginsRect. |
|
742 lines := self "pen" asArrayOfStringLines: aString in: marginsRect wordWrap: wordWrapBoolean. |
|
743 headerLines := self "pen" asArrayOfStringLines: aString2 in: marginsRect wordWrap: wordWrapBoolean. |
|
744 linesPerPage := marginsRect bottom - marginsRect top // charHeight. |
|
745 |
|
746 linesPerPage > headerLines size |
|
747 ifFalse: |
|
748 [Dialog information: 'Der Dokumentenkopf ist zu groß; wird ignoriert!!'. |
|
749 headerLines := #(). |
|
750 ] |
|
751 ifTrue: [linesPerPage := linesPerPage - headerLines size]. |
|
752 totalPage := lines size + linesPerPage - 1 // linesPerPage. |
|
753 firstPage := true. |
|
754 |
|
755 "/ collateBoolean |
|
756 "/ ifTrue: [ |
|
757 "/ copiesInteger timesRepeat: [ |
|
758 |
|
759 1 to: totalPage do: [ :page | |
|
760 abort ifTrue: [ ^self endPrintJob ]. |
|
761 firstPage ifFalse: [ self formFeed ]. |
|
762 self "pen" font: aFont "printerFont". |
|
763 self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
764 firstPage := false ] |
|
765 |
|
766 "/ ] |
|
767 "/ ] |
|
768 "/ ifFalse: [ |
|
769 "/ 1 to: totalPage do: [ :page | |
|
770 "/ copiesInteger timesRepeat: [ |
|
771 "/ abort ifTrue: [ ^self endPrintJob ]. |
|
772 "/ firstPage ifFalse: [ self formFeed ]. |
|
773 "/ self "pen" font: printerFont. |
|
774 "/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
775 "/ firstPage := false ] ] ]. |
|
776 |
|
777 "Created: / 30-11-2006 / 13:19:06 / User" |
|
778 ! |
|
779 |
|
780 print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
|
781 "Private - Answer the receiver. Output the receiver string to |
|
782 the printer using aFont. A Print abort dialog box will be opened |
|
783 with aTitle. If collateBoolean is true, collate output, otherwise |
|
784 do not. Print copiesInteger copies of the specified string. If |
|
785 wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
786 Left, top, right & bottom margins are specified in inches in |
|
787 aMarginsRect." |
|
788 |
|
789 |lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
|
790 |
|
791 self font:aFont. |
|
792 charHeight := self getCharHeight. |
|
793 marginsRect := self marginsRectangleFor:aMarginsRect. |
|
794 lines := self |
|
795 asArrayOfStringLines:aString |
|
796 in:marginsRect |
|
797 wordWrap:wordWrapBoolean. |
|
798 headerLines := self |
|
799 asArrayOfStringLines:aString2 |
|
800 in:marginsRect |
|
801 wordWrap:wordWrapBoolean. |
|
802 linesPerPage := (marginsRect bottom - marginsRect top) // charHeight. |
|
803 linesPerPage > headerLines size ifFalse:[ |
|
804 Dialog information:(self class classResources |
|
805 string:'The header is too large - ignored!!'). |
|
806 headerLines := #(). |
|
807 ] ifTrue:[ |
|
808 linesPerPage := linesPerPage - headerLines size |
|
809 ]. |
|
810 totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
|
811 firstPage := true. |
|
812 |
|
813 "/ collateBoolean |
|
814 "/ ifTrue: [ |
|
815 "/ copiesInteger timesRepeat: [ |
|
816 |
|
817 1 to:totalPage do:[:page | |
|
818 abort ifTrue:[ ^ self ]. |
|
819 firstPage ifFalse:[ |
|
820 self formFeed |
|
821 ]. |
|
822 self font:printerFont. |
|
823 self |
|
824 printPage:page |
|
825 in:marginsRect |
|
826 lines:lines |
|
827 headerLines:headerLines |
|
828 linesPerPage:linesPerPage. |
|
829 firstPage := false |
|
830 ] |
|
831 |
|
832 "/ ] |
|
833 "/ ] ifFalse: [ |
|
834 "/ 1 to: totalPage do: [ :page | |
|
835 "/ copiesInteger timesRepeat: [ |
|
836 "/ abort ifTrue: [ ^self endPrintJob ]. |
|
837 "/ firstPage ifFalse: [ self formFeed ]. |
|
838 "/ self device font: printerFont. |
|
839 "/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
840 "/ firstPage := false |
|
841 "/ ] |
|
842 "/ ] |
|
843 "/ ]. |
|
844 |
|
845 "Created: / 03-08-2006 / 16:14:10 / fm" |
|
846 "Modified: / 10-10-2006 / 18:18:03 / cg" |
|
847 ! ! |
462 ! ! |
848 |
463 |
849 !WinPrinterContext methodsFor:'printing process'! |
464 !WinPrinterContext methodsFor:'printing process'! |
850 |
465 |
851 endPage |
466 endPage |
876 "Created: / 27-07-2006 / 18:21:04 / fm" |
491 "Created: / 27-07-2006 / 18:21:04 / fm" |
877 "Modified: / 01-08-2006 / 16:01:38 / fm" |
492 "Modified: / 01-08-2006 / 16:01:38 / fm" |
878 "Modified: / 10-10-2006 / 18:50:43 / cg" |
493 "Modified: / 10-10-2006 / 18:50:43 / cg" |
879 ! |
494 ! |
880 |
495 |
881 formFeed |
|
882 "Send a form feed to the printer." |
|
883 |
|
884 self |
|
885 endPage; |
|
886 startPage |
|
887 |
|
888 "Created: / 27-07-2006 / 18:25:40 / fm" |
|
889 "Modified: / 10-10-2006 / 18:15:07 / cg" |
|
890 ! |
|
891 |
|
892 startPage |
496 startPage |
893 "Starts a page." |
497 "Starts a page." |
894 |
498 |
895 (OperatingSystem startPage:gcId) > 0 ifFalse:[ |
499 (OperatingSystem startPage:gcId) > 0 ifFalse:[ |
896 ^ self error |
500 ^ self error |
897 ]. |
501 ]. |
898 |
502 |
899 "Created: / 27-07-2006 / 18:25:55 / fm" |
503 "Created: / 27-07-2006 / 18:25:55 / fm" |
900 "Modified: / 28-07-2006 / 18:19:04 / fm" |
504 "Modified: / 28-07-2006 / 18:19:04 / fm" |
901 "Modified: / 10-10-2006 / 18:19:02 / cg" |
505 "Modified: / 10-10-2006 / 18:19:02 / cg" |
902 ! |
|
903 |
|
904 startPrintJob |
|
905 "Start a print job. Everything drawn between startPrintJob |
|
906 and endPrintJob will become one entry in the print queue." |
|
907 |
|
908 self startPrintJob:nil |
|
909 |
|
910 "Created: / 27-07-2006 / 18:18:52 / fm" |
|
911 "Modified: / 10-10-2006 / 18:19:05 / cg" |
|
912 ! |
|
913 |
|
914 startPrintJob:aString |
|
915 "Start a print job, using aString as the job title; everything |
|
916 drawn between startPrintJob and endPrintJob will become |
|
917 one entry in the print queue." |
|
918 |
|
919 ^ self startPrintJob:aString fileName:nil |
|
920 |
|
921 "Created: / 27-07-2006 / 18:19:09 / fm" |
|
922 "Modified: / 10-10-2006 / 18:19:12 / cg" |
|
923 ! |
506 ! |
924 |
507 |
925 startPrintJob:aString fileName:aFileName |
508 startPrintJob:aString fileName:aFileName |
926 "Start a print job, using aString as the job title; everything |
509 "Start a print job, using aString as the job title; everything |
927 drawn between startPrintJob and endPrintJob will become |
510 drawn between startPrintJob and endPrintJob will become |
985 "Modified: / 04-08-2006 / 13:20:40 / fm" |
568 "Modified: / 04-08-2006 / 13:20:40 / fm" |
986 "Modified: / 10-10-2006 / 18:21:07 / cg" |
569 "Modified: / 10-10-2006 / 18:21:07 / cg" |
987 ! |
570 ! |
988 |
571 |
989 supportsGraphics |
572 supportsGraphics |
990 ^(OperatingSystem getDeviceCaps: gcId "asParameter" index: 2 "Technology") ~= 4 |
573 ^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4 |
991 |
574 |
992 "Created: / 03-08-2006 / 10:07:43 / fm" |
575 "Created: / 03-08-2006 / 10:07:43 / fm" |
993 "Modified: / 10-10-2006 / 18:21:14 / cg" |
576 "Modified: / 16-04-2007 / 12:44:03 / cg" |
994 ! ! |
577 ! ! |
995 |
578 |
996 !WinPrinterContext methodsFor:'text printing'! |
579 !WinPrinterContext methodsFor:'text printing'! |
997 |
|
998 asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean |
|
999 "Private - convert aString into an array of lines; if wordWrapBoolean |
|
1000 is true, also perform word wrapping on the lines, within aRectangle." |
|
1001 |
|
1002 |line lines stream x0 x1 partialLine leftMargin rightMargin partialLineWidth index| |
|
1003 |
|
1004 stream := ReadStream on:aString. |
|
1005 lines := OrderedCollection new. |
|
1006 wordWrapBoolean ifTrue:[ |
|
1007 leftMargin := aRectangle left. |
|
1008 rightMargin := aRectangle right |
|
1009 ]. |
|
1010 [ stream atEnd ] whileFalse:[ |
|
1011 line := stream nextLine. |
|
1012 wordWrapBoolean ifFalse:[ |
|
1013 lines add:line |
|
1014 ] ifTrue:[ |
|
1015 x0 := x1 := 1. |
|
1016 1 to:line size do:[:i | |
|
1017 ((line at:i) = Character space "32" |
|
1018 and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) |
|
1019 ifTrue:[ |
|
1020 partialLineWidth := self stringWidthOf:partialLine. |
|
1021 (leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
|
1022 partialLine := line copyFrom:x0 to:x1. |
|
1023 lines add:partialLine. |
|
1024 x0 := x1 + 1 |
|
1025 ] ifFalse:[ x1 := i ] |
|
1026 ]. |
|
1027 index := i |
|
1028 ]. |
|
1029 line isEmpty ifTrue:[ |
|
1030 lines add:line |
|
1031 ] ifFalse:[ |
|
1032 partialLine := line copyFrom:x0 to:index. |
|
1033 partialLineWidth := self stringWidthOf:partialLine. |
|
1034 (leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
|
1035 partialLine := line copyFrom:x0 to:x1. |
|
1036 lines add:partialLine. |
|
1037 partialLine := line copyFrom:x1 + 1 to:index |
|
1038 ]. |
|
1039 lines add:partialLine |
|
1040 ] |
|
1041 ] |
|
1042 ]. |
|
1043 ^ lines asArray |
|
1044 |
|
1045 "Created: / 02-08-2006 / 17:56:51 / fm" |
|
1046 "Modified: / 04-08-2006 / 13:39:50 / fm" |
|
1047 "Modified: / 10-10-2006 / 18:14:00 / cg" |
|
1048 ! |
|
1049 |
|
1050 displayString:aString at:aPoint in:aRect options:ignoredForNow adx:unknownForNow |
|
1051 |x y| |
|
1052 x := aPoint x. |
|
1053 y := aPoint y. |
|
1054 (textAlign isNil or:[textAlign == 0 ]) ifTrue:[ |
|
1055 self displayString:aString at:aPoint. |
|
1056 ^ self |
|
1057 ]. |
|
1058 (textAlign == 8 "TaBottom") ifTrue:[ |
|
1059 y := aPoint y - (self container font ascent) "container font ascent". |
|
1060 ] ifFalse:[ (textAlign == 6 "TaCenter") ifTrue:[ |
|
1061 #TODO. |
|
1062 "/ x := aRect left + ((aRect width-(container font widthOf:aString))//2). |
|
1063 ] ifFalse:[ (textAlign == 2 "TaRight") ifTrue:[ |
|
1064 x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
|
1065 y := self "container font ascent" getCharHeight + aPoint y . |
|
1066 ] ifFalse:[ (textAlign == 14 "TaCenterBottom") ifTrue:[ |
|
1067 y := aRect bottom - self getCharHeight "container font ascent". |
|
1068 x := aRect left + ((aRect width-(self "container font widthOf:" stringWidthOf:aString))//2). |
|
1069 ] ifFalse:[ (textAlign == 10) ifTrue:[ |
|
1070 x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
|
1071 y := aRect bottom "aPoint y - (self container font ascent)" - self getCharHeight. |
|
1072 ]]]]]. |
|
1073 "/ Transcript showCR: 'Original Pos: ', aPoint x printString, '@', aPoint y printString, |
|
1074 "/ ' Pos: ', x printString, '@', y printString, |
|
1075 "/ ' Text: ', aString. |
|
1076 self displayString:aString at:(x@y). |
|
1077 |
|
1078 "Modified: / 14-12-2006 / 12:29:13 / User" |
|
1079 ! |
|
1080 |
|
1081 displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle |
|
1082 "Private - display Strings in anIndexedCollection starting at startIndex and |
|
1083 ending at endIndex, clipped within the bounds of aRectangle." |
|
1084 |
|
1085 |charHeight ta region ascent| |
|
1086 |
|
1087 charHeight := self getCharHeight. |
|
1088 ascent := self font ascentOn:self device. |
|
1089 startIndex to:endIndex do:[:i | |
|
1090 |lineToPrint| |
|
1091 |
|
1092 lineToPrint := (anIndexedCollection at:i). |
|
1093 self device |
|
1094 displayString:lineToPrint |
|
1095 from:1 |
|
1096 to:lineToPrint size |
|
1097 x:aRectangle left |
|
1098 y:(aRectangle top + ((i - startIndex) * charHeight)) |
|
1099 in:nil |
|
1100 with:gcId |
|
1101 opaque:false |
|
1102 fontAscent:ascent. |
|
1103 ]. |
|
1104 |
|
1105 "/ region := self setClipRect: aRectangle. |
|
1106 "/ ta := self getTextAlign. |
|
1107 "/ self setTextAlign: TaTop. |
|
1108 "/ startIndex to: endIndex do: [ :i | |
|
1109 "/ self |
|
1110 "/ displayText: ( anIndexedCollection at: i ) |
|
1111 "/ at: aRectangle left @ ( aRectangle top + ( i - startIndex * charHeight ) ) ]. |
|
1112 "/ self setTextAlign: ta. |
|
1113 "/ self destroyRegion: region |
|
1114 |
|
1115 "Created: / 03-08-2006 / 11:37:52 / fm" |
|
1116 "Modified: / 03-08-2006 / 12:38:43 / fm" |
|
1117 "Modified: / 10-10-2006 / 18:14:36 / cg" |
|
1118 ! |
|
1119 |
|
1120 displayStringLines:anIndexedCollection in:aRectangle |
|
1121 "Private - display anIndexedCollection of Strings clipped within |
|
1122 the bounds of aRectangle." |
|
1123 |
|
1124 self |
|
1125 displayStringLines:anIndexedCollection |
|
1126 from:1 |
|
1127 to:anIndexedCollection size |
|
1128 in:aRectangle |
|
1129 |
|
1130 "Created: / 03-08-2006 / 16:03:07 / fm" |
|
1131 "Modified: / 10-10-2006 / 18:14:40 / cg" |
|
1132 ! |
|
1133 |
|
1134 displayText: aString at: aPoint |
|
1135 |
|
1136 self displayString:aString x:aPoint x y:aPoint y |
|
1137 ! |
|
1138 |
|
1139 linesPerPageFor: aRectangle |
|
1140 |
|
1141 |marginsRect charHeight| |
|
1142 |
|
1143 marginsRect := aRectangle isNil |
|
1144 ifTrue:[self marginsRectangleFor: nil] |
|
1145 ifFalse:[aRectangle]. |
|
1146 |
|
1147 charHeight := self getCharHeight. |
|
1148 ^(marginsRect bottom - marginsRect top) // charHeight |
|
1149 |
|
1150 "Created: / 12-10-2006 / 11:52:57 / User" |
|
1151 ! |
|
1152 |
|
1153 marginsRectangleFor:aRectangle |
|
1154 "Private - Answer a Rectangle defining margins based on aRectangle. |
|
1155 Units for aRectangle are in inches, returned margins rectangle is |
|
1156 in device units (pixels)." |
|
1157 |
|
1158 |left top right bottom pixelsPerInchX pixelsPerInchY horzRes vertRes inset rectangle| |
|
1159 |
|
1160 pixelsPerInchX := self pixelsPerInchOfScreenWidth. |
|
1161 pixelsPerInchX == 0 ifTrue:[self halt]. |
|
1162 pixelsPerInchY := self pixelsPerInchOfScreenHeight. |
|
1163 aRectangle isNil ifTrue:[ |
|
1164 horzRes := self printerWidthArea. |
|
1165 vertRes := self printerHeightArea. |
|
1166 inset := self class defaultMargins. |
|
1167 left := (inset x * pixelsPerInchX) asInteger. |
|
1168 top := (inset y * pixelsPerInchY) asInteger. |
|
1169 right := horzRes - (inset x * pixelsPerInchX) asInteger. |
|
1170 bottom := vertRes - (inset y * pixelsPerInchY) asInteger |
|
1171 ] ifFalse:[ |
|
1172 left := (aRectangle left * pixelsPerInchX) asInteger. |
|
1173 top := (aRectangle top * pixelsPerInchY) asInteger. |
|
1174 right := (aRectangle right * pixelsPerInchX) asInteger. |
|
1175 bottom := (aRectangle bottom * pixelsPerInchY) asInteger |
|
1176 ]. |
|
1177 rectangle := left @ top corner:right @ bottom. |
|
1178 ^ rectangle |
|
1179 |
|
1180 "Created: / 27-07-2006 / 18:22:57 / fm" |
|
1181 "Modified: / 04-08-2006 / 13:39:45 / fm" |
|
1182 "Modified: / 16-04-2007 / 11:57:21 / cg" |
|
1183 ! |
|
1184 |
|
1185 printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage |
|
1186 "Private - print page # pageIndex from lines, assuming |
|
1187 the given number of linesPerPage." |
|
1188 |
|
1189 |firstLine lastLine l indexString p cHeight rect hLines| |
|
1190 |
|
1191 firstLine := (pageIndex - 1) * linesPerPage + 1. |
|
1192 lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
1193 rect := aRectangle deepCopy. |
|
1194 hLines := headerLines deepCopy. |
|
1195 headerLines size > 0 ifTrue:[ |
|
1196 l := hLines first. |
|
1197 p := l indexOfSubCollection: "indexOfString:"'#P'. |
|
1198 p = 0 ifFalse:[ |
|
1199 indexString := pageIndex printString , ' '. |
|
1200 l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size). |
|
1201 hLines at:1 put:l. |
|
1202 ]. |
|
1203 cHeight := self getCharHeight. |
|
1204 rect top:rect top + (hLines size * cHeight). |
|
1205 ]. |
|
1206 self displayStringLines:hLines in:aRectangle. |
|
1207 self |
|
1208 displayStringLines:lines |
|
1209 from:firstLine |
|
1210 to:lastLine |
|
1211 in:rect. |
|
1212 |
|
1213 "Created: / 27-07-2006 / 18:28:00 / fm" |
|
1214 "Modified: / 03-08-2006 / 16:03:15 / fm" |
|
1215 "Modified: / 10-10-2006 / 18:18:15 / cg" |
|
1216 "Modified: / 30-11-2006 / 13:34:44 / User" |
|
1217 ! |
|
1218 |
|
1219 printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage |
|
1220 "Private - print page # pageIndex from lines, assuming |
|
1221 the given number of linesPerPage." |
|
1222 |
|
1223 |firstLine lastLine| |
|
1224 |
|
1225 firstLine := (pageIndex - 1) * linesPerPage + 1. |
|
1226 lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
1227 self |
|
1228 displayStringLines:lines |
|
1229 from:firstLine |
|
1230 to:lastLine |
|
1231 in:aRectangle |
|
1232 |
|
1233 "Created: / 27-07-2006 / 18:24:59 / fm" |
|
1234 "Modified: / 03-08-2006 / 12:47:24 / fm" |
|
1235 "Modified: / 10-10-2006 / 18:18:22 / cg" |
|
1236 ! |
|
1237 |
|
1238 stringWidthOf:aString |
|
1239 "Return the width of aString |
|
1240 when written using the current font." |
|
1241 |
|
1242 ^ self stringWidthOf:aString at:aString size. |
|
1243 |
|
1244 "Modified: / 03-08-2006 / 10:18:23 / fm" |
|
1245 "Modified: / 10-10-2006 / 18:20:08 / cg" |
|
1246 ! |
|
1247 |
580 |
1248 stringWidthOf:aString at:index |
581 stringWidthOf:aString at:index |
1249 "Return the width of aString up to index |
582 "Return the width of aString up to index |
1250 when written using the current font; expand tabs out |
583 when written using the current font; expand tabs out |
1251 to 4 spaces for calculations" |
584 to 4 spaces for calculations" |