blob: 86009d2a814a8a587281fed269405706e9664e0e [file] [log] [blame]
Jack Jansen5a6fdcd2001-08-25 12:15:04 +00001from Carbon import Dlg
2from Carbon import Res
Just van Rossum40f9b7b1999-01-30 22:39:17 +00003
4splash = Dlg.GetNewDialog(468, -1)
5splash.DrawDialog()
6
Jack Jansen5a6fdcd2001-08-25 12:15:04 +00007from Carbon import Qd, TE, Fm
Just van Rossum40f9b7b1999-01-30 22:39:17 +00008
Jack Jansen5a6fdcd2001-08-25 12:15:04 +00009from Carbon import Win
10from Carbon.Fonts import *
11from Carbon.QuickDraw import *
Just van Rossum2d564fd2001-11-02 19:30:21 +000012from Carbon.TextEdit import teJustCenter
Just van Rossum40f9b7b1999-01-30 22:39:17 +000013import string
14import sys
15
Just van Rossum2d564fd2001-11-02 19:30:21 +000016_about_width = 440
17_about_height = 340
18
Just van Rossum40f9b7b1999-01-30 22:39:17 +000019_keepsplashscreenopen = 0
20
Just van Rossumdc3c6172001-06-19 21:37:33 +000021abouttext1 = """The Python Integrated Development Environment for the Macintosh\xaa
Just van Rossum40f9b7b1999-01-30 22:39:17 +000022Version: %s
Just van Rossumdc3c6172001-06-19 21:37:33 +000023Copyright 1997-2001 Just van Rossum, Letterror. <just@letterror.com>
Just van Rossum40f9b7b1999-01-30 22:39:17 +000024Python %s
25%s
Just van Rossum40f9b7b1999-01-30 22:39:17 +000026See: <http://www.python.org/> for information and documentation."""
27
Just van Rossumdc3c6172001-06-19 21:37:33 +000028flauwekul = [ "Goodday, Bruce.",
29 "What's new?",
30 "Nudge, nudge, say no more!",
31 "No, no sir, it's not dead. It's resting.",
32 "Albatros!",
33 "It's . . .",
34 "Is your name not Bruce, then?",
Just van Rossum40f9b7b1999-01-30 22:39:17 +000035 """But Mr F.G. Superman has a secret identity . . .
36when trouble strikes at any time . . .
37at any place . . . he is ready to become . . .
38Bicycle Repair Man!"""
39 ]
40
Just van Rossumc9246612000-10-20 07:35:33 +000041def skipdoublereturns(text):
42 return string.replace(text, '\n\n', '\n')
43
Just van Rossum40f9b7b1999-01-30 22:39:17 +000044def nl2return(text):
Just van Rossumc9246612000-10-20 07:35:33 +000045 return string.replace(text, '\n', '\r')
Just van Rossum40f9b7b1999-01-30 22:39:17 +000046
47def UpdateSplash(drawdialog = 0, what = 0):
48 if drawdialog:
49 splash.DrawDialog()
50 drawtext(what)
Jack Jansen362c7cd02002-11-30 00:01:29 +000051 splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().GetPortBounds())
52 splash.GetDialogWindow().GetWindowPort().QDFlushPortBuffer(None)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000053
54def drawtext(what = 0):
55 Qd.SetPort(splash)
56 fontID = Fm.GetFNum("Python-Sans")
57 if not fontID:
58 fontID = geneva
59 Qd.TextFont(fontID)
60 Qd.TextSize(9)
Just van Rossumdc3c6172001-06-19 21:37:33 +000061 rect = (10, 115, _about_width - 10, _about_height - 30)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000062 if not what:
63 import __main__
Just van Rossumc9246612000-10-20 07:35:33 +000064 abouttxt = nl2return(abouttext1 % (
65 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
Just van Rossum40f9b7b1999-01-30 22:39:17 +000066 else:
67 import random
68 abouttxt = nl2return(random.choice(flauwekul))
69 TE.TETextBox(abouttxt, rect, teJustCenter)
70
71UpdateSplash(1)
72
73def wait():
Jack Jansen5a6fdcd2001-08-25 12:15:04 +000074 from Carbon import Evt
75 from Carbon import Events
Just van Rossum40f9b7b1999-01-30 22:39:17 +000076 global splash
77 try:
78 splash
79 except NameError:
80 return
81 Qd.InitCursor()
82 time = Evt.TickCount()
83 whattext = 0
Just van Rossumdc3c6172001-06-19 21:37:33 +000084 drawtext(whattext)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000085 while _keepsplashscreenopen:
Jack Jansendef0d8d2001-02-09 15:56:19 +000086 ok, event = Evt.EventAvail(Events.highLevelEventMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000087 if ok:
88 # got apple event, back to mainloop
89 break
Jack Jansendef0d8d2001-02-09 15:56:19 +000090 ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000091 if ok:
Jack Jansendef0d8d2001-02-09 15:56:19 +000092 ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000093 if ok:
94 (what, message, when, where, modifiers) = event
Jack Jansendef0d8d2001-02-09 15:56:19 +000095 if what == Events.updateEvt:
Just van Rossum40f9b7b1999-01-30 22:39:17 +000096 if Win.WhichWindow(message) == splash:
97 UpdateSplash(1, whattext)
98 else:
99 break
100 if Evt.TickCount() - time > 360:
101 whattext = not whattext
102 drawtext(whattext)
103 time = Evt.TickCount()
104 del splash
Just van Rossumdc3c6172001-06-19 21:37:33 +0000105
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000106
107def about():
108 global splash, splashresfile, _keepsplashscreenopen
109 _keepsplashscreenopen = 1
110 splash = Dlg.GetNewDialog(468, -1)
111 splash.DrawDialog()
112 wait()