blob: ab36fa4a9294d7725f512f03405a43507a15e1e4 [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
Tim Peters182b5ac2004-07-18 06:16:08 +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?",
35 """But Mr F.G. Superman has a secret identity . . .
36when trouble strikes at any time . . .
37at any place . . . he is ready to become . . .
Just van Rossum40f9b7b1999-01-30 22:39:17 +000038Bicycle Repair Man!"""
Tim Peters182b5ac2004-07-18 06:16:08 +000039 ]
Just van Rossum40f9b7b1999-01-30 22:39:17 +000040
Just van Rossumc9246612000-10-20 07:35:33 +000041def skipdoublereturns(text):
Tim Peters182b5ac2004-07-18 06:16:08 +000042 return string.replace(text, '\n\n', '\n')
Just van Rossumc9246612000-10-20 07:35:33 +000043
Just van Rossum40f9b7b1999-01-30 22:39:17 +000044def nl2return(text):
Tim Peters182b5ac2004-07-18 06:16:08 +000045 return string.replace(text, '\n', '\r')
Just van Rossum40f9b7b1999-01-30 22:39:17 +000046
47def UpdateSplash(drawdialog = 0, what = 0):
Tim Peters182b5ac2004-07-18 06:16:08 +000048 if drawdialog:
49 splash.DrawDialog()
50 drawtext(what)
51 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):
Tim Peters182b5ac2004-07-18 06:16:08 +000055 Qd.SetPort(splash)
56 fontID = Fm.GetFNum("Python-Sans")
57 if not fontID:
58 fontID = geneva
59 Qd.TextFont(fontID)
60 Qd.TextSize(9)
61 rect = (10, 115, _about_width - 10, _about_height - 30)
62 if not what:
63 import __main__
64 abouttxt = nl2return(abouttext1 % (
65 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
66 else:
67 import random
68 abouttxt = nl2return(random.choice(flauwekul))
69 TE.TETextBox(abouttxt, rect, teJustCenter)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000070
71UpdateSplash(1)
72
73def wait():
Tim Peters182b5ac2004-07-18 06:16:08 +000074 from Carbon import Evt
75 from Carbon import Events
76 global splash
77 try:
78 splash
79 except NameError:
80 return
81 Qd.InitCursor()
82 time = Evt.TickCount()
83 whattext = 0
84 drawtext(whattext)
85 while _keepsplashscreenopen:
86 ok, event = Evt.EventAvail(Events.highLevelEventMask)
87 if ok:
88 # got apple event, back to mainloop
89 break
90 ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
91 if ok:
92 ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
93 if ok:
94 (what, message, when, where, modifiers) = event
95 if what == Events.updateEvt:
96 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():
Tim Peters182b5ac2004-07-18 06:16:08 +0000108 global splash, splashresfile, _keepsplashscreenopen
109 _keepsplashscreenopen = 1
110 splash = Dlg.GetNewDialog(468, -1)
111 splash.DrawDialog()
112 wait()