574 drawX drawY drawPnt displayId screen drawableId error stringLen| |
603 drawX drawY drawPnt displayId screen drawableId error stringLen| |
575 |
604 |
576 "limit the string len, otherwise bad output is generated" |
605 "limit the string len, otherwise bad output is generated" |
577 stringLen := index2Arg - index1 + 1. |
606 stringLen := index2Arg - index1 + 1. |
578 stringLen > 8000 ifTrue:[ |
607 stringLen > 8000 ifTrue:[ |
579 index2 := index1 + 8000 - 1. |
608 index2 := index1 + 8000 - 1. |
580 ] ifFalse:[ |
609 ] ifFalse:[ |
581 stringLen <= 0 ifTrue:[^ self]. |
610 stringLen <= 0 ifTrue:[^ self]. |
582 index2 := index2Arg. |
611 index2 := index2Arg. |
583 ]. |
612 ]. |
584 bytesPerCharacter := aString bitsPerCharacter // 8. |
613 bytesPerCharacter := aString bitsPerCharacter // 8. |
585 transformation := aGC transformation. |
614 transformation := aGC transformation. |
586 |
615 |
587 clipR := aGC clippingBoundsOrNil. |
616 clipR := aGC clippingBoundsOrNil. |
588 clipR notNil ifTrue:[ |
617 clipR notNil ifTrue:[ |
589 clipX := clipR left. |
618 clipX := clipR left. |
590 clipY := clipR top. |
619 clipY := clipR top. |
591 clipW := clipR width. |
620 clipW := clipR width. |
592 clipH := clipR height. |
621 clipH := clipR height. |
593 "/ YES YES YES: this MUST be transformed!! |
622 "/ YES YES YES: this MUST be transformed!! |
594 "/ (see htmlView) fix the notebook, please. |
623 "/ (see htmlView) fix the notebook, please. |
595 transformation notNil ifTrue:[ |
624 transformation notNil ifTrue:[ |
596 clipPnt := transformation transformPoint:(clipX @ clipY). |
625 clipPnt := transformation transformPoint:(clipX @ clipY). |
597 clipX := clipPnt x ceiling. |
626 clipX := clipPnt x ceiling. |
598 clipY := clipPnt y ceiling. |
627 clipY := clipPnt y ceiling. |
599 "/ clipX := (transformation applyToX:clipX) ceiling. |
628 "/ clipX := (transformation applyToX:clipX) ceiling. |
600 "/ clipY := (transformation applyToY:clipY) ceiling. |
629 "/ clipY := (transformation applyToY:clipY) ceiling. |
601 ]. |
630 ]. |
602 ]. |
631 ]. |
603 |
632 |
604 transformation isNil ifTrue:[ |
633 transformation isNil ifTrue:[ |
605 drawX := xArg. |
634 drawX := xArg. |
606 drawY := yArg. |
635 drawY := yArg. |
607 ] ifFalse:[ |
636 ] ifFalse:[ |
608 drawPnt := transformation transformPoint:(xArg @ yArg). |
637 drawPnt := transformation transformPoint:(xArg @ yArg). |
609 drawX := drawPnt x ceiling. |
638 drawX := drawPnt x ceiling. |
610 drawY := drawPnt y ceiling. |
639 drawY := drawPnt y ceiling. |
611 "/ drawX := (transformation applyToX:xArg) ceiling. |
640 "/ drawX := (transformation applyToX:xArg) ceiling. |
612 "/ drawY := (transformation applyToY:yArg) ceiling. |
641 "/ drawY := (transformation applyToY:yArg) ceiling. |
613 ]. |
642 ]. |
614 |
643 |
615 fg := aGC paint. |
644 fg := aGC paint. |
616 fgPixel := fg colorId. |
645 fgPixel := fg colorId. |
617 "/ fgPixel notNil ifTrue:[ |
646 "/ fgPixel notNil ifTrue:[ |
618 fgR := fg scaledRed. |
647 fgR := fg scaledRed. |
619 fgG := fg scaledGreen. |
648 fgG := fg scaledGreen. |
620 fgB := fg scaledBlue. |
649 fgB := fg scaledBlue. |
621 fgA := (fg alpha * 65535) rounded. |
650 fgA := (fg alpha * 65535) rounded. |
622 "/]. |
651 "/]. |
623 fgR isNil ifTrue:[ |
652 fgR isNil ifTrue:[ |
624 "/ when drawing into a pixmap... |
653 "/ when drawing into a pixmap... |
625 fg colorId == 0 ifTrue:[ |
654 fg colorId == 0 ifTrue:[ |
626 fgR := fgG := fgB := 0. |
655 fgR := fgG := fgB := 0. |
627 ] ifFalse:[ |
656 ] ifFalse:[ |
628 fgR := fgG := fgB := 16rFFFF. |
657 fgR := fgG := fgB := 16rFFFF. |
629 ] |
658 ] |
630 ]. |
659 ]. |
631 |
660 |
632 opaque ifTrue:[ |
661 opaque ifTrue:[ |
633 bg := aGC backgroundPaint. |
662 bg := aGC backgroundPaint. |
634 bgPixel := bg colorId. |
663 bgPixel := bg colorId. |
635 "/bgPixel notNil ifTrue:[ |
664 "/bgPixel notNil ifTrue:[ |
636 bgR := bg scaledRed. |
665 bgR := bg scaledRed. |
637 bgG := bg scaledGreen. |
666 bgG := bg scaledGreen. |
638 bgB := bg scaledBlue. |
667 bgB := bg scaledBlue. |
639 bgA := (bg alpha * 65535) rounded. |
668 bgA := (bg alpha * 65535) rounded. |
640 "/]. |
669 "/]. |
641 bgR isNil ifTrue:[ |
670 bgR isNil ifTrue:[ |
642 "/ when drawing into a pixmap... |
671 "/ when drawing into a pixmap... |
643 bg colorId == 0 ifTrue:[ |
672 bg colorId == 0 ifTrue:[ |
644 bgR := bgG := bgB := 0. |
673 bgR := bgG := bgB := 0. |
645 ] ifFalse:[ |
674 ] ifFalse:[ |
646 bgR := bgG := bgB := 16rFFFF. |
675 bgR := bgG := bgB := 16rFFFF. |
647 ] |
676 ] |
648 ]. |
677 ]. |
649 ]. |
678 ]. |
650 displayId := device displayIdOrErrorIfBroken. |
679 displayId := device displayIdOrErrorIfBroken. |
651 displayId isNil ifTrue:[ |
680 displayId isNil ifTrue:[ |
652 ^ self. |
681 ^ self. |
653 ]. |
682 ]. |
654 screen := device screen. |
683 screen := device screen. |
655 drawableId := aGC drawableId. |
684 drawableId := aGC drawableId. |
656 |
685 aGC addDependent:self. "I need to be informed, when the GC is destroyed" |
657 %{ |
686 |
658 #ifdef XFT |
687 %{ |
659 XftFont *font; |
688 #ifdef XFT |
660 XftDraw *draw; |
|
661 XftColor color; |
689 XftColor color; |
662 XGlyphInfo extents; |
690 XGlyphInfo extents; |
663 XRectangle clipRX; |
691 XRectangle clipRX; |
664 char* string; |
692 char *string; |
665 int len; |
693 int len; |
666 int __bytesPerCharacter; |
694 int __bytesPerCharacter; |
|
695 XftDraw *__sharedDrawId; |
|
696 XftFont *__xftFont = XFT_FONT(__INST(fontId)); |
667 |
697 |
668 if (!(__bothSmallInteger(drawX, drawY) |
698 if (!(__bothSmallInteger(drawX, drawY) |
669 && __bothSmallInteger(index1, index2) |
699 && __bothSmallInteger(index1, index2) |
670 && __isSmallInteger(bytesPerCharacter) |
700 && __isSmallInteger(bytesPerCharacter) |
671 && (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA))) |
701 && (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA))) |
672 && (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA))) |
702 && (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA))) |
673 && __isNonNilObject(aString) |
703 && __isNonNilObject(aString) |
674 )) { |
704 )) { |
675 goto err; |
705 goto err; |
676 } |
706 } |
677 |
707 |
678 __bytesPerCharacter = __intVal(bytesPerCharacter); |
708 __bytesPerCharacter = __intVal(bytesPerCharacter); |
679 |
709 |
680 if ( __INST(sharedDrawId) == nil ) { |
710 if (__INST(sharedDrawId) == nil) { |
681 __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) , |
711 __sharedDrawId = XftDrawCreate(DISPLAY(displayId), |
682 DRAWABLE( drawableId ) , |
712 DRAWABLE(drawableId), |
683 DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) , |
713 DefaultVisual(DISPLAY(displayId), SCREEN(screen)), |
684 DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ); |
714 DefaultColormap(DISPLAY(displayId), SCREEN(screen))); |
685 __STORE(self, __INST(sharedDrawId)); |
715 __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW(__sharedDrawId); |
686 } |
716 __STORE(self, __INST(sharedDrawId)); |
687 |
717 } else if (XftDrawDrawable(__sharedDrawId = XFT_DRAW(__INST(sharedDrawId))) != DRAWABLE(drawableId)) { |
688 if ( XftDrawDrawable ( XFT_DRAW ( __INST(sharedDrawId) ) ) != DRAWABLE( drawableId ) ) { |
718 XftDrawChange(__sharedDrawId, DRAWABLE(drawableId)); |
689 XftDrawChange( XFT_DRAW( __INST(sharedDrawId) ) , DRAWABLE( drawableId ) ); |
719 } |
690 } |
720 |
691 |
721 string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter); |
692 string = __stringVal( aString ) + (( __intVal(index1) - 1 ) * __bytesPerCharacter); |
|
693 len = __intVal(index2) - __intVal(index1) + 1; |
722 len = __intVal(index2) - __intVal(index1) + 1; |
694 |
723 |
695 if (clipR != nil) { |
724 if (clipR != nil) { |
696 clipRX.x = __intVal(clipX); |
725 clipRX.x = __intVal(clipX); |
697 clipRX.y = __intVal(clipY); |
726 clipRX.y = __intVal(clipY); |
698 clipRX.width = __intVal(clipW); |
727 clipRX.width = __intVal(clipW); |
699 clipRX.height = __intVal(clipH); |
728 clipRX.height = __intVal(clipH); |
700 XftDrawSetClipRectangles( XFT_DRAW( __INST( sharedDrawId ) ) , 0, 0, &clipRX, 1); |
729 XftDrawSetClipRectangles(__sharedDrawId, 0, 0, &clipRX, 1); |
701 } else { |
730 } else { |
702 XftDrawSetClip( XFT_DRAW( __INST( sharedDrawId ) ) , 0); |
731 XftDrawSetClip(__sharedDrawId, 0); |
703 } |
732 } |
704 |
733 |
705 if (opaque == true) { |
734 if (opaque == true) { |
706 if (bgPixel != nil) { |
735 if (bgPixel != nil) { |
707 color.pixel = (unsigned long)__intVal(bgPixel); |
736 color.pixel = (unsigned long)__intVal(bgPixel); |
708 } |
737 } |
709 // else { |
738 // else { |
710 color.color.red = __intVal(bgR); |
739 color.color.red = __intVal(bgR); |
711 color.color.green = __intVal(bgG); |
740 color.color.green = __intVal(bgG); |
712 color.color.blue = __intVal(bgB); |
741 color.color.blue = __intVal(bgB); |
713 color.color.alpha = __intVal(bgA); |
742 color.color.alpha = __intVal(bgA); |
714 // } |
743 // } |
715 switch (__bytesPerCharacter) { |
744 switch (__bytesPerCharacter) { |
716 case 1: |
745 case 1: |
717 XftTextExtents8( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar8*)string, len, &extents); |
746 XftTextExtents8(DISPLAY(displayId), __xftFont, (FcChar8*)string, len, &extents); |
718 break; |
747 break; |
719 case 2: |
748 case 2: |
720 XftTextExtents16( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar16*)string, len, &extents); |
749 XftTextExtents16(DISPLAY(displayId), __xftFont, (FcChar16*)string, len, &extents); |
721 break; |
750 break; |
722 case 4: |
751 case 4: |
723 XftTextExtents32( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar32*)string, len, &extents); |
752 XftTextExtents32(DISPLAY(displayId), __xftFont, (FcChar32*)string, len, &extents); |
724 break; |
753 break; |
725 } |
754 } |
726 XftDrawRect( XFT_DRAW ( __INST( sharedDrawId ) ), &color, __intVal(drawX) - extents.x, __intVal(drawY) - XFT_FONT( __INST( fontId ) )->ascent, extents.width, XFT_FONT(__INST (fontId ) )->height); |
755 XftDrawRect(__sharedDrawId, &color, __intVal(drawX) - extents.x, __intVal(drawY) - __xftFont->ascent, extents.width, __xftFont->height); |
727 } |
756 } |
728 if (fgPixel != nil) { |
757 if (fgPixel != nil) { |
729 color.pixel = (unsigned long)__intVal(fgPixel); |
758 color.pixel = (unsigned long)__intVal(fgPixel); |
730 } |
759 } |
731 // else { |
760 // else { |
732 color.color.red = __intVal(fgR); |
761 color.color.red = __intVal(fgR); |
733 color.color.green = __intVal(fgG); |
762 color.color.green = __intVal(fgG); |
734 color.color.blue = __intVal(fgB); |
763 color.color.blue = __intVal(fgB); |
735 color.color.alpha = __intVal(fgA); |
764 color.color.alpha = __intVal(fgA); |
736 // } |
765 // } |
737 switch (__bytesPerCharacter) { |
766 switch (__bytesPerCharacter) { |
738 case 1: |
767 case 1: |
739 XftDrawString8( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
768 XftDrawString8(__sharedDrawId, &color,__xftFont, |
740 __intVal(drawX), |
769 __intVal(drawX), |
741 __intVal(drawY), |
770 __intVal(drawY), |
742 (FcChar8*)string, |
771 (FcChar8*)string, |
743 len); |
772 len); |
744 RETURN ( self ); |
773 break; |
745 break; |
774 |
746 case 2: |
775 case 2: |
747 XftDrawString16( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
776 XftDrawString16(__sharedDrawId, &color, __xftFont, |
748 __intVal(drawX), |
777 __intVal(drawX), |
749 __intVal(drawY), |
778 __intVal(drawY), |
750 (FcChar16*)string, |
779 (FcChar16*)string, |
751 len); |
780 len); |
752 RETURN ( self ); |
781 break; |
753 break; |
782 |
754 case 4: |
783 case 4: |
755 XftDrawString32( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
784 XftDrawString32(__sharedDrawId, &color, __xftFont, |
756 __intVal(drawX), |
785 __intVal(drawX), |
757 __intVal(drawY), |
786 __intVal(drawY), |
758 (FcChar32*)string, |
787 (FcChar32*)string, |
759 len); |
788 len); |
760 RETURN ( self ); |
789 break; |
761 break; |
790 |
762 } |
791 default: |
|
792 goto err; |
|
793 } |
|
794 |
|
795 # if 0 // this has been superseeded by receiving change messages on view destroy |
|
796 // Have to disassociate the drawableId - otherwise we get an X11 error 'RenderBadPicture (invalid Picture parameter)' |
|
797 // when the drawable (the window) is destroyed. |
|
798 XftDrawChange(__sharedDrawId, None); |
|
799 # endif |
|
800 RETURN(self); |
|
801 |
763 err:; |
802 err:; |
764 #endif |
803 #endif |
765 %}. |
804 %}. |
766 self primitiveFailed: error. |
805 self primitiveFailed: error. |
767 |
806 |