#! /usr/NeWS/bin/psh
%
% This file is a product of Sun Microsystems, Inc. and is provided for
% unrestricted use provided that this legend is included on all tape
% media and as a part of the software program in whole or part.  Users
% may copy or modify this file without charge, but are not authorized to
% license or distribute it to anyone else except as part of a product
% or program developed by the user.
% 
% THIS FILE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
% WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
% PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
% 
% This file is provided with no support and without any obligation on the
% part of Sun Microsystems, Inc. to assist in its use, correction,
% modification or enhancement.
% 
% SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
% INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS FILE
% OR ANY PART THEREOF.
% 
% In no event will Sun Microsystems, Inc. be liable for any lost revenue
% or profits or other special, indirect and consequential damages, even
% if Sun has been advised of the possibility of such damages.
% 
% Sun Microsystems, Inc.
% 2550 Garcia Avenue
% Mountain View, California  94043
%
%
% languagedemo 9.3 88/01/18
%

%
%  LanguageDemo: Language pot-pourri.
%

FontDirectory /Times-Roman-Latin-1 known not {
     30 dict begin
     /Times-Roman findfont { def } forall
     /FontName /Times-Roman-Latin-1 def
     /Encoding { 
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/space /exclam   /quotedbl   /numbersign   /dollar  /percent  /ampersand
/quoteright /parenleft   /parenright  /asterisk   /plus  /comma  /hyphen
/period /slash  /zero /one  /two /three  /four /five  /six /seven /eight
/nine /colon /semicolon /less /equal /greater /question /at /A  /B /C /D
/E /F /G /H /I /J /K  /L /M  /N /O  /P /Q  /R /S  /T /U  /V /W  /X /Y /Z
/bracketleft /backslash     /bracketright    /asciicircum    /underscore
/quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o  /p /q  /r /s /t
/u /v  /w  /x  /y  /z  /braceleft /bar  /braceright /asciitilde /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef  /.notdef /.notdef /.notdef
/.notdef /exclamdown  /cent  /sterling /currency  /yen /.notdef /section
/.notdef /.notdef /ordfeminine /guillemotleft /.notdef /.notdef /.notdef
/.notdef /.notdef   /.notdef   /.notdef   /.notdef   /.notdef   /.notdef
/paragraph /bullet   /.notdef   /.notdef  /ordmasculine  /guillemotright
/.notdef /.notdef  /.notdef  /questiondown  /Agrave /Aacute /Acircumflex
/Atilde /Adieresis  /Aring  /AE  /Ccedilla  /Egrave /Eacute /Ecircumflex
/Edieresis /Igrave  /Iacute  /Icircumflex  /Idieresis  /.notdef  /Ntilde
/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /.notdef /Oslash /Ugrave
/Uacute /Ucircumflex  /Udieresis  /.notdef  /.notdef /germandbls /agrave
/aacute /acircumflex  /.notdef  /adieresis /aring  /ae /ccedilla /egrave
/eacute /ecircumflex /edieresis /igrave  /iacute /icircumflex /idieresis
/.notdef /ntilde   /ograve   /oacute   /ocircumflex  /otilde  /odieresis
/.notdef /oslash  /ugrave  /uacute  /ucircumflex  /udieresis  /ydieresis
/.notdef /Ydieresis
    } cvlit def
    FontName currentdict definefont pop % pstack pop
    end
} if
/eurofont /Times-Roman-Latin-1 findfont 24 scalefont def
{/kanjifont /Kanji findfont 20 scalefont def} stopped not /hasKanji exch def

hasKanji {
    /makeKstr {             % [ n n ... => string
	counttomark /n exch def n string dup        % [ n n n ... str
	n 1 sub -1 0 {                              % [ n n n ... str str i
	    3 index 128 add put exch pop dup        % [ n n ... str str
	} for
	pop exch pop
    } def

    /Chineseparagraph [
	(\272\307\275\351\315\255\300\273\270\300)
	()
    ] def
    /Chinesemenu [
	[ 49 81 74 56 makeKstr			{toEnglish paintparagraph}
	[ 67 102 74 56 makeKstr			{toChinese paintparagraph}
	[ 75 33  74 56 makeKstr			{toFrench paintparagraph}
	[ 70 65 74 56 makeKstr			{toGerman paintparagraph}
	[ 70 124 74 56 makeKstr			{toJapanese paintparagraph}
	[ 48 85 66 103 77 120 74 56 makeKstr	{toItalian paintparagraph}
	[ 64 62 72 73 38 88 74 56 makeKstr	{toSpanish paintparagraph}
    ] /new DefaultMenu send def
    /toChinese {Chinesemenu kanjifont Chineseparagraph newlanguage} def
    
    /Japaneseparagraph [
	[ 61 105  36 97  36 75  56 64  77 85  36 34  36 106  36 45  makeKstr
%	(\277\300\244\317\244\275\244\316\244\322\244\310\244\352\273\322\244\362\273\362\244\357\244\304\244\277\244\333\244\311\244\313\244\263\244\316\300\244\244\362\260\246\244\267\244\306\262\274\244\265\244\304\244\277)
	()
    ] def
    /Japanesemenu [
	[ 49 81  56 108 makeKstr		    {toEnglish paintparagraph}
	[ 67 102 57 113 56 108 makeKstr		    {toChinese paintparagraph}
	[ 37 85 37 105 37 115 37 57 56 108 makeKstr {toFrench paintparagraph}
	[ 37 73 37 36 37 68 56 108 makeKstr	    {toGerman paintparagraph}
	[ 70 124 75 92 56 108 makeKstr		    {toJapanese paintparagraph}
	[ 37 36 37 63 37 106 37 34 56 108 makeKstr  {toItalian paintparagraph}
	[ 37 57 37 90 37 36 37 115 56 108 makeKstr  {toSpanish paintparagraph}
    ] /new DefaultMenu send def
    /toJapanese {Japanesemenu kanjifont Japaneseparagraph newlanguage} def

} if

/fillcanvaswithtext { % stringarray canvas font textcolor bkgndcolor => -
10 dict begin
    gsave
    4 -1 roll setcanvas fillcanvas setshade setfont
    /para exch def
    /fontht	currentfont fontheight def
    /y		clippath pathbbox 4 1 roll pop pop pop def
    /line	0 def
    {   /y y fontht sub def
        y 0 le {exit} if
        5 y moveto
        para line get show pause
        /line line 1 add para length mod def
    } loop
    grestore
end
} def
/paintparagraph {paragraph can parafont 0 1 fillcanvaswithtext} def
/newlanguage { % menu font paragraph
    /paragraph exch store /parafont exch store /menu exch store
    menu /MenuFont parafont put
} def

/Englishparagraph [
    (In the beginning was the Word)
    ()
] def
/Englishmenu [
    (English)	{toEnglish paintparagraph}
    hasKanji { (Chinese)	{toChinese paintparagraph} } if
    (French)	{toFrench paintparagraph}
    (German)	{toGerman paintparagraph}
    hasKanji { (Japanese)	{toJapanese paintparagraph} } if
    (Italian)	{toItalian paintparagraph}
    (Spanish)	{toSpanish paintparagraph}
] /new DefaultMenu send def
/toEnglish {Englishmenu eurofont Englishparagraph newlanguage} def

/Frenchparagraph [
    (Au d\351but fut la parole)
    ()
] def
/Frenchmenu [
    (Anglais)		{toEnglish paintparagraph}
    hasKanji { (Chinois)		{toChinese paintparagraph} } if
    (Fran\347ais)	{toFrench paintparagraph}
    (Allemand)		{toGerman paintparagraph}
    hasKanji { (Japonais)		{toJapanese paintparagraph} } if
    (Italien)		{toItalian paintparagraph}
    (Espagnol)		{toSpanish paintparagraph}
] /new DefaultMenu send def
/toFrench {Frenchmenu eurofont Frenchparagraph newlanguage} def

/Germanparagraph [
    (Am anfang war das Wort)
    ()
] def
/Germanmenu [
    (Englisch)		{toEnglish paintparagraph}
    hasKanji { (Chinesisch)	{toChinese paintparagraph} } if
    (Franz\366sisch)	{toFrench paintparagraph}
    (Deutsch)		{toGerman paintparagraph}
    hasKanji { (Japanisch)		{toJapanese paintparagraph} } if
    (Italienisch)	{toItalian paintparagraph}
    (Spanisch)		{toSpanish paintparagraph}
] /new DefaultMenu send def
/toGerman {Germanmenu eurofont Germanparagraph newlanguage} def

/Italianparagraph [
    (Al' inizi\363 c'era la parola)
    ()
] def
/Italianmenu [
    (Inglese)		{toEnglish paintparagraph}
    hasKanji { (Cinese)		{toChinese paintparagraph} } if
    (Francese)		{toFrench paintparagraph}
    (Tedesco)		{toGerman paintparagraph}
    hasKanji { (Giapponese)	{toJapanese paintparagraph} } if
    (Italiano)		{toItalian paintparagraph}
    (Spagnolo)		{toSpanish paintparagraph}
] /new DefaultMenu send def
/toItalian {Italianmenu eurofont Italianparagraph newlanguage} def

/Spanishparagraph [
    (Al principio fu\351 la palabra)
    ()
] def
/Spanishmenu [
    (Ingl\351s)		{toEnglish paintparagraph}
    hasKanji { (Chino)		{toChinese paintparagraph} } if
    (Franc\351s)	{toFrench paintparagraph}
    (Alem\341n)		{toGerman paintparagraph}
    hasKanji { (Japon\351s)	{toJapanese paintparagraph} } if
    (Italiano)		{toItalian paintparagraph}
    (Espa\361ol)	{toSpanish paintparagraph}
] /new DefaultMenu send def
/toSpanish {Spanishmenu eurofont Spanishparagraph newlanguage} def

hasKanji {
    toChinese  % makes sure kanji is swapped in!
} {
    toFrench
} ifelse

/win framebuffer /new DefaultWindow send def	% Create a window
{						% Install my stuff.
    /FrameLabel (Languages) def
    /PaintClient {paintparagraph} def
    /IconImage /hello_world def
} win send
/reshapefromuser win send			% Shape it.
/can win /ClientCanvas get def
/map win send  % Map the window. (Damage causes PaintClient to be called)

% Note: we don't use the /ClientMenu field in the window for the client
%	menu because it is changed each time the language changes.
/eventmgr [
    MenuButton {/showat menu send}
    DownTransition can eventmgrinterest
] forkeventmgr def
