602 ^ xftFontsOnlyHolder |
602 ^ xftFontsOnlyHolder |
603 ! ! |
603 ! ! |
604 |
604 |
605 !FontPanel methodsFor:'initialization'! |
605 !FontPanel methodsFor:'initialization'! |
606 |
606 |
|
607 createFontSelectionBrowserIn:aView |
|
608 |topSelectionBox fontLabelAndSizeSelectionBox |
|
609 l hLabel v1 v2 v3 familyLabel faceLabel sizeLabel fH mm| |
|
610 |
|
611 mm := ViewSpacing. |
|
612 hLabel := 30. |
|
613 |
|
614 l := (0@0 corner:1@1) asFractionalLayout. |
|
615 l bottomInset:hLabel. |
|
616 topSelectionBox := (View in:aView) layout:l. |
|
617 |
|
618 l := (1@0 corner:1@1) asFractionalLayout. |
|
619 l topOffset:hLabel negated. |
|
620 l rightInset:mm. |
|
621 |
|
622 fontLabelAndSizeSelectionBox := (HorizontalPanelView in:aView) layout:l. |
|
623 fontLabelAndSizeSelectionBox horizontalLayout:#rightFit. |
|
624 |
|
625 v1 := View origin:0.0@0.0 corner:0.3@1.0 in:topSelectionBox. |
|
626 |
|
627 familyLabel := Label label:(resources string:'Family') in:v1. |
|
628 familyLabel borderWidth:0. |
|
629 familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
630 fH := familyLabel preferredHeight. |
|
631 |
|
632 familyList := ScrollableView for:SelectionInListView in:v1. |
|
633 familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
634 familyList inset:mm. |
|
635 familyList topInset:fH. |
|
636 |
|
637 familyList := familyList scrolledView. |
|
638 self makeTabable:familyList. |
|
639 |
|
640 v2 := View origin:0.3@0.0 corner:0.8@1.0 in:topSelectionBox. |
|
641 |
|
642 faceLabel := Label label:(resources string:'Typeface') in:v2. |
|
643 faceLabel borderWidth:0. |
|
644 faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
645 |
|
646 faceList := ScrollableView for:SelectionInListView in:v2. |
|
647 faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
648 faceList inset:mm. |
|
649 faceList topInset:fH. |
|
650 faceList := faceList scrolledView. |
|
651 self makeTabable:faceList. |
|
652 |
|
653 v3 := View origin:0.8@0.0 corner:1.0@1.0 in:topSelectionBox. |
|
654 |
|
655 sizeLabelHolder := (resources string:'Size') asValue. |
|
656 sizeLabel := Label in:v3. |
|
657 sizeLabel labelChannel:sizeLabelHolder. |
|
658 sizeLabel borderWidth:0. |
|
659 sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
660 |
|
661 sizeList := ScrollableView for:SelectionInListView in:v3. |
|
662 sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
663 sizeList inset:mm. |
|
664 sizeList topInset:fH. |
|
665 sizeList := sizeList scrolledView. |
|
666 self makeTabable:sizeList. |
|
667 |
|
668 familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
669 faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
670 sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
671 |
|
672 nameLabel := Label label:'' in:fontLabelAndSizeSelectionBox. |
|
673 nameLabel level:0; adjust:#left. |
|
674 |
|
675 pixelPointSwitch := ComboListView in:fontLabelAndSizeSelectionBox. |
|
676 pixelPointSwitch level:-1. |
|
677 pixelPointSwitch contents:'pt'. |
|
678 pixelPointSwitch list:#(#pt #px). |
|
679 pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit]. |
|
680 ! |
|
681 |
607 enabled:aBoolean |
682 enabled:aBoolean |
608 familyList enabled:aBoolean. |
683 familyList enabled:aBoolean. |
609 faceList enabled:aBoolean. |
684 faceList enabled:aBoolean. |
610 sizeList enabled:aBoolean. |
685 sizeList enabled:aBoolean. |
611 encodingFilterField notNil ifTrue:[ |
686 encodingFilterField notNil ifTrue:[ |
627 ! |
702 ! |
628 |
703 |
629 initialize |
704 initialize |
630 "sigh: hand-crafted box creation; TODO: rewrite using UI painter" |
705 "sigh: hand-crafted box creation; TODO: rewrite using UI painter" |
631 |
706 |
632 |familyLabel faceLabel sizeLabel panel panel2 fontBrowserView fp v1 v2 v3 |
707 |everythingExceptOkCancelButtonsPanel fontBrowserView mm l encodingAndXFTOnlyBox box3 box4 xftCheckBox |
633 mm fH l box1 box2 box3 box4 showFontNameLabel xftCheckBox vPanel changeInAllCheckBox |
708 previewAndFontSelectionPanel filterBox changeInAllCheckBox updateHeight |
634 xftFlushFontList decorativeCheckBox nonDecorativeCheckBox monospacedCheckBox nonMonospacedCheckBox| |
709 xftFlushFontList decorativeCheckBox nonDecorativeCheckBox monospacedCheckBox nonMonospacedCheckBox| |
635 |
710 |
636 super initialize. |
711 super initialize. |
637 |
712 |
638 showFontNameLabel := device isWindowsPlatform not. |
713 label := resources string:'Font dialog'. |
639 sizeUnit := #pt. |
714 sizeUnit := #pt. |
640 |
|
641 mm := ViewSpacing. |
715 mm := ViewSpacing. |
642 |
716 |
643 self addAbortAndOkButtons. |
717 self addAbortAndOkButtons. |
644 |
718 |
645 panel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
719 everythingExceptOkCancelButtonsPanel := View origin:0.0@0.0 corner:1.0@1.0 in:self. |
646 panel bottomInset:(buttonPanel preferredHeight |
720 everythingExceptOkCancelButtonsPanel bottomInset:(buttonPanel preferredHeight + (mm)). |
647 + (mm) |
721 |
648 "+ (showFontNameLabel ifTrue:24 ifFalse:0)" ). |
722 previewAndFontSelectionPanel := VariableVerticalPanel in:everythingExceptOkCancelButtonsPanel. |
649 |
723 previewAndFontSelectionPanel layout:(LayoutFrame |
650 vPanel := VariableVerticalPanel in:panel. |
724 leftFraction:0 offset:0 |
651 vPanel origin:0.0@0.0 corner:1.0@1.0. |
725 rightFraction:1 offset:0 |
652 |
726 topFraction:0 offset:0 |
653 previewField := HVScrollableView for:TextView in:vPanel. |
727 bottomFraction:1 offset:-150). |
654 fontBrowserView := View in:vPanel. |
728 |
655 fp := View in:fontBrowserView. |
729 filterBox := VerticalPanelView in:everythingExceptOkCancelButtonsPanel. |
656 fp layout:(0.0@0.0 corner:1.0@1.0) asFractionalLayout. |
730 filterBox layout:(LayoutFrame |
657 fp layout bottomOffset:-150. |
731 leftFraction:0 offset:0 |
658 |
732 rightFraction:1 offset:0 |
659 label := resources string:'Font dialog'. |
733 topFraction:1 offset:-150 |
660 |
734 bottomFraction:1 offset:0). |
661 panel2 := VerticalPanelView in:fontBrowserView. |
735 filterBox horizontalLayout:#fit verticalLayout:#top. |
662 panel2 layout:(0.0@1.0 corner:1.0@1.0) asFractionalLayout. |
736 |
663 panel2 layout topOffset:-150. |
737 previewField := HVScrollableView for:TextView in:previewAndFontSelectionPanel. |
664 |
738 previewField menuHolder:self previewMenu. |
665 panel2 horizontalLayout:#fit. |
739 previewField autoHideScrollBars:true. |
666 panel2 verticalLayout:#top. |
740 previewField := previewField scrolledView. |
667 |
741 "/ previewField inset:mm. |
668 box1 := HorizontalPanelView in:panel2. |
742 "/ self is3D ifTrue:[ |
669 box1 height:25. |
743 "/ previewField level:-1. |
670 box1 horizontalLayout:#rightFit. |
744 "/ ] ifFalse:[ |
671 |
745 "/ previewField borderWidth:1. |
672 showFontNameLabel ifTrue:[ |
746 "/ ]. |
673 nameLabel := Label label:'' in:box1. |
747 |
674 "/ nameLabel origin:0.0@1.0 corner:1.0@1.0. |
748 fontBrowserView := View in:previewAndFontSelectionPanel. |
675 "/ nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)). |
749 self createFontSelectionBrowserIn:fontBrowserView. |
676 "/ nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm. |
750 |
677 nameLabel level:0; adjust:#left. |
751 encodingAndXFTOnlyBox := HorizontalPanelView in:filterBox. |
678 ]. |
752 encodingAndXFTOnlyBox height:32. |
679 |
753 encodingAndXFTOnlyBox horizontalLayout:#leftSpace. |
680 pixelPointSwitch := ComboListView in:box1. |
754 |
681 "/ encodingFilter font:l font. |
755 l := Label label:(resources string:'Encoding:') in:encodingAndXFTOnlyBox. |
682 pixelPointSwitch level:-1. |
756 l borderWidth:0. |
683 pixelPointSwitch contents:'pt'. |
757 l adjust:#left. |
684 pixelPointSwitch list:#(#pt #px). |
758 |
685 pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit]. |
759 encodingFilterField := ComboBoxView in:encodingAndXFTOnlyBox. |
686 "/ box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm. |
760 encodingFilterField level:-1. |
687 "/ encodingFilter editor font:l font. |
761 encodingFilterField contents:'*'. |
688 |
762 encodingFilterField list:(self listOfEncodingsInFilterCombo). |
689 panel2 add:(View new height:8). |
763 encodingFilterField action:[:pattern | self encodingFilterSelected:pattern]. |
690 |
764 encodingFilterField immediateAccept:true. |
691 "/ self showEncodingFilter ifFalse:[ |
|
692 "/ encodingFilter beInvisible |
|
693 "/ ]. |
|
694 |
|
695 box2 := HorizontalPanelView in:panel2. |
|
696 box2 height:25. |
|
697 box2 horizontalLayout:#leftSpace. |
|
698 |
|
699 l := Label label:(resources string:'Encoding:') in:box2. |
|
700 l borderWidth:0. |
|
701 l adjust:#left. |
|
702 |
|
703 encodingFilterField := ComboBoxView in:box2. |
|
704 "/ encodingFilterField font:l font. |
|
705 encodingFilterField level:-1. |
|
706 encodingFilterField contents:'*'. |
|
707 encodingFilterField list:(self listOfEncodingsInFilterCombo). |
|
708 encodingFilterField action:[:pattern | self encodingFilterSelected:pattern]. |
|
709 encodingFilterField immediateAccept:true. |
|
710 "/ encodingFilterField editor font:l font. |
|
711 |
|
712 self showEncodingFilter ifFalse:[ |
|
713 encodingFilterField beInvisible |
|
714 ]. |
|
715 |
|
716 "/ encodingFilterField acceptOnReturn:true. |
765 "/ encodingFilterField acceptOnReturn:true. |
717 "/ encodingFilterField acceptOnTab:true. |
766 "/ encodingFilterField acceptOnTab:true. |
718 "/ encodingFilterField acceptOnLeave:true. |
767 "/ encodingFilterField acceptOnLeave:true. |
719 "/ encodingFilterField acceptOnLostFocus:true. |
768 "/ encodingFilterField acceptOnLostFocus:true. |
720 "/ encodingFilterField acceptOnPointerLeave:true. |
769 "/ encodingFilterField acceptOnPointerLeave:true. |
721 |
770 |
722 encodingLabel := Label label:' ' in:box2. |
771 encodingLabel := Label label:' ' in:encodingAndXFTOnlyBox. |
723 |
772 encodingLabel level:0; adjust:#left. |
724 encodingLabel level:0; adjust:#left. |
773 encodingLabel adjust:#right. |
725 encodingLabel adjust:#right. |
774 |
726 self showEncodingFilter ifFalse:[ |
775 self showEncodingFilter ifFalse:[ |
727 encodingLabel beInvisible |
776 encodingFilterField beInvisible. |
728 ]. |
777 encodingLabel beInvisible |
729 |
778 ]. |
730 device supportsXftFonts ifTrue:[ |
779 |
731 self xftFontsOnlyHolder value: (UserPreferences current useXftFontsOnly). |
780 device supportsXftFonts ifTrue:[ |
732 xftCheckBox := CheckBox label:(resources string:'XFT Fonts Only') in:box2. |
781 self xftFontsOnlyHolder value: (UserPreferences current useXftFontsOnly). |
733 xftCheckBox model:xftFontsOnlyHolder. |
782 xftCheckBox := CheckBox label:(resources string:'XFT Fonts Only') in:encodingAndXFTOnlyBox. |
734 xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ]. |
783 xftCheckBox model:xftFontsOnlyHolder. |
735 |
784 xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ]. |
736 xftFlushFontList := Button label:(resources string:'Flush Cached List of Fonts') in:box2. |
785 |
737 xftFlushFontList action:[ self flushListOfAvailableFonts]. |
786 xftFlushFontList := Button label:(resources string:'Flush Cached List of Fonts') in:encodingAndXFTOnlyBox. |
738 ]. |
787 xftFlushFontList action:[ self flushListOfAvailableFonts]. |
|
788 ]. |
739 |
789 |
740 false ifTrue:[ |
790 false ifTrue:[ |
741 decorativeCheckBox := CheckBox label:(resources string:'Decorative Fonts Only'). |
791 decorativeCheckBox := CheckBox label:(resources string:'Decorative Fonts Only'). |
742 box3 := View new height:(decorativeCheckBox preferredHeight). |
792 box3 := View new height:(decorativeCheckBox preferredHeight). |
743 panel2 add:box3. |
793 filterBox add:box3. |
744 |
794 |
745 decorativeCheckBox origin:0.0@0.0 corner:0.5@1.0. |
795 decorativeCheckBox origin:0.0@0.0 corner:0.5@1.0. |
746 box3 add:decorativeCheckBox. |
796 box3 add:decorativeCheckBox. |
747 decorativeCheckBox model:self decorativeOnlyHolder. |
797 decorativeCheckBox model:self decorativeOnlyHolder. |
748 self decorativeOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
798 self decorativeOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
765 nonMonospacedCheckBox origin:0.5@0.0 corner:1.0@1.0. |
815 nonMonospacedCheckBox origin:0.5@0.0 corner:1.0@1.0. |
766 nonMonospacedCheckBox model:self nonMonospacedOnlyHolder. |
816 nonMonospacedCheckBox model:self nonMonospacedOnlyHolder. |
767 self nonMonospacedOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
817 self nonMonospacedOnlyHolder onChangeEvaluate:[ self filterChanged ]. |
768 ]. |
818 ]. |
769 |
819 |
770 changeInAllCheckBox := CheckBox label:(resources string:'Change all Textviews and Default for New Views') in:panel2. |
820 changeInAllCheckBox := CheckBox label:(resources string:'Change all Textviews and Default for New Views') in:filterBox. |
771 changeInAllCheckBox model:self changeFontInAllViewsHolder. |
821 changeInAllCheckBox model:self changeFontInAllViewsHolder. |
772 changeInAllCheckBox visibilityChannel:self withChangeFontInAllViewsCheckBoxVisibleHolder. |
822 changeInAllCheckBox visibilityChannel:self withChangeFontInAllViewsCheckBoxVisibleHolder. |
773 |
823 |
774 "/ previewField origin:0.0@0.0 corner:1.0@0.4. |
824 updateHeight := |
775 previewField autoHideScrollBars:true. |
825 [ |
776 previewField := previewField scrolledView. |
826 |filterBoxHeight| |
777 previewField inset:mm. |
827 |
778 |
828 filterBoxHeight := filterBox preferredHeight. |
779 self is3D ifTrue:[ |
829 previewAndFontSelectionPanel layout bottomOffset:(filterBoxHeight negated). |
780 previewField level:-1. |
830 filterBox layout topOffset:(filterBoxHeight negated). |
781 ] ifFalse:[ |
831 previewAndFontSelectionPanel layoutChanged. |
782 previewField borderWidth:1. |
832 filterBox layoutChanged. |
783 ]. |
833 ]. |
784 |
834 |
785 v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fp. |
835 updateHeight value. |
|
836 self withChangeFontInAllViewsCheckBoxVisibleHolder onChangeEvaluate:updateHeight. |
786 |
837 |
787 familyLabel := Label label:(resources string:'Family') in:v1. |
|
788 familyLabel borderWidth:0. |
|
789 familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
790 fH := familyLabel preferredHeight. |
|
791 |
|
792 familyList := ScrollableView for:SelectionInListView in:v1. |
|
793 familyList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
794 familyList inset:mm. |
|
795 familyList topInset:fH. |
|
796 |
|
797 familyList := familyList scrolledView. |
|
798 self makeTabable:familyList. |
|
799 |
|
800 v2 := View origin:0.4@0.0 corner:0.8@1.0 in:fp. |
|
801 |
|
802 faceLabel := Label label:(resources string:'Typeface') in:v2. |
|
803 faceLabel borderWidth:0. |
|
804 faceLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil). |
|
805 |
|
806 faceList := ScrollableView for:SelectionInListView in:v2. |
|
807 faceList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
808 faceList inset:mm. |
|
809 faceList topInset:fH. |
|
810 faceList := faceList scrolledView. |
|
811 self makeTabable:faceList. |
|
812 |
|
813 v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fp. |
|
814 |
|
815 sizeLabelHolder := (resources string:'Size') asValue. |
|
816 sizeLabel := Label in:v3. |
|
817 sizeLabel labelChannel:sizeLabelHolder. |
|
818 sizeLabel borderWidth:0. |
|
819 sizeLabel origin:(0.0 @ 0.0)extent:(1.0 @ nil). |
|
820 |
|
821 sizeList := ScrollableView for:SelectionInListView in:v3. |
|
822 sizeList origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
823 sizeList inset:mm. |
|
824 sizeList topInset:fH. |
|
825 sizeList := sizeList scrolledView. |
|
826 self makeTabable:sizeList. |
|
827 |
|
828 familyList action:[:lineNr | self familySelected:(familyList selectionValue)]. |
|
829 faceList action:[:lineNr | self faceSelected:(faceList selectionValue)]. |
|
830 sizeList action:[:lineNr | self sizeSelected:(sizeList selectionValue)]. |
|
831 |
|
832 previewField menuHolder:self previewMenu. |
|
833 |
|
834 " |
838 " |
835 FontPanel new showAtPointer |
839 FontPanel new showAtPointer |
836 FontPanel fontFromUser |
840 FontPanel fontFromUser |
837 " |
841 " |
838 |
842 |