On this page:
start-splash
shutdown-splash
close-splash
add-splash-icon
get-splash-bitmap
set-splash-bitmap
get-splash-canvas
get-splash-eventspace
get-splash-paint-callback
set-splash-paint-callback
set-splash-progress-bar?!
set-splash-char-observer
set-splash-event-callback
get-splash-event-callback
set-refresh-splash-on-gauge-change?!
get-splash-width
get-splash-height
refresh-splash

32 Splash

 (require framework/splash) package: gui-lib

This module helps support applications with splash screens like the one in DrRacket.

When this module is invoked, it sets the current-load parameter to a procedure that counts how many files are loaded (until shutdown-splash is called) and uses that number to control the gauge along the bottom of the splash screen.

procedure

(start-splash draw-spec    
  splash-title    
  width-default    
  [#:allow-funny? allow-funny?    
  #:frame-icon frame-icon])  void?
  draw-spec : 
(or/c path-string?
      (is-a?/c bitmap%)
      (vector/c (or/c (-> (is-a?/c dc<%>) void?)
                      (-> (is-a?/c dc<%>)
                          exact-nonnegative-integer?
                          exact-nonnegative-integer?
                          exact-nonnegative-integer?
                          exact-nonnegative-integer?
                          void?))
                exact-nonnegative-integer?
                exact-nonnegative-integer?))
  splash-title : string?
  width-default : exact-nonnegative-integer?
  allow-funny? : boolean? = #f
  frame-icon : 
(or/c #f
      (is-a?/c bitmap%)
      (cons/c (is-a?/c bitmap%)
              (is-a?/c bitmap%)))
 = #f
Starts a new splash screen. The splash screen is created in its own, new eventspace. The progress gauge at the bottom of the window advances as files are loaded (monitored via the current-load parameter).

The draw-spec determines what the splash window contains. The splash-title is used as the title of the window and the width-default determines how many progress steps the gauge in the splash screen should contain if there is no preference saved for the splash screen width. The splash library uses get-preference and put-preferences to store preferences, using

(string->symbol (format "plt:~a-splash-max-width" splash-title))

as the key for the preference. Each time the app starts up, the maximum width is reset based on the number of files that were loaded that time.

If the draw-spec is a path-string?, then the path is expected to be a file that contains a bitmap that is drawn as the contents of the splash screen. If it is a bitmap, then that bitmap is used directly. If draw-spec is a vector, then the vector’s first element is a procedure that is called to draw the splash screen and the other two integers are the size of the splash screen, width followed by height. If the procedure accepts only one argument, then it is called with a dc<%> object where the drawing should occur. If it accepts 5 arguments, it is called with the dc<%>, as well as (in order) the current value of the gauge, the maximum value of the gauge, and the width and the height of the area to draw.

The allow-funny? argument determines if a special gauge is used on Christmas day.

The frame-icon is used just like the value of the parameter frame:current-icon is used, but for the splash screen.

procedure

(shutdown-splash)  void?

Stops the splash window’s gauge from advancing. Call this after all of the files have been loaded.

procedure

(close-splash)  void?

Closes the splash window. Call shutdown-splash first. You can leave some time between these two if there is more initialization work to be done where you do not want to count loaded files.

procedure

(add-splash-icon bmp x y)  void?

  bmp : (is-a?/c bitmap%)
  x : real?
  y : real?
Adds an icon to the splash screen. (DrRacket uses this function to show the tools as they are loaded.)

procedure

(get-splash-bitmap)  (or/c #f (is-a?/c bitmap%))

Returns the splash bitmap unless one has not been set.

procedure

(set-splash-bitmap bmp)  void?

  bmp : (is-a?/c bitmap%)
Sets the splash bitmap to bmp and triggers a redrawing of the splash screen. Don’t use this to set the initial bitmap, use start-splash instead.

procedure

(get-splash-canvas)  (is-a?/c canvas%)

Returns the canvas where the splash screen bitmap is drawn (if there is a bitmap); see start-splash for how the splash is drawn.
Returns the splash screen’s eventspace.
Returns the callback that is invoked when redrawing the splash screen.
Sets the callback that is invoked when redrawing the splash screen. See start-splash for what the arguments are.

procedure

(set-splash-progress-bar?! b)  void?

  b : boolean?
Calling this procedure with #f removes the progress bar from the splash screen. Useful in conjunction with setting your own paint callback for the splash screen that measures progress in its own way, during drawing. DrRacket uses this on King Kamehameha and Prince Kuhio day.

procedure

(set-splash-char-observer obs)  void?

  obs : (-> (is-a?/c key-event%) any)
Sets a procedure that is called whenever a user types a key with the splash screen as the focus.

procedure

(set-splash-event-callback obj)  void?

  obj : (-> (is-?/c mouse-event%) any)
Sets a procedure that is called whenever a mouse event happens in the splash canvas.

procedure

(get-splash-event-callback)  (-> (is-?/c mouse-event%) any)

Returns the last procedure passed to set-splash-event-callback or void, if set-splash-event-callback has not been called.
Sets a procedure that is called each time the splash gauge changes. If the procedure returns a true value (i.e., not #f), then the splash screen is redrawn. The procedure is called with the current value of the gauge and the maximum value.

The default function is (lambda (curr tot) #f).
Returns the width of the splash drawing area / bitmap. See start-splash for the details of the size and how things are drawn.
Returns the width of the splash drawing area / bitmap. See start-splash for the details of the size and how things are drawn.

procedure

(refresh-splash)  void?

Triggers a refresh of the splash, handling the details of double buffering and doing the drawing on the splash’s eventspace’s main thread.