1 Aligned Pasteboard
2 Bitmap Label
3 Cache-image Snip
4 GIF and Animated GFI Writing
5 Graphs
6 Hierarchical List Control
7 Include Bitmap
8 Interactive Value Port
9 Name Message
10 Path Dialog
11 Plot
12 Switchable Button
13 Acknowledgments
Index
On this page:
name-message%
on-choose-directory
on-event
on-paint
set-hidden?
set-message
calc-button-min-sizes
draw-button-label
Version: 4.0.2

 

9 Name Message

 (require mrlib/name-message)

name-message% : class?

  superclass: canvas%

A name-message% control displays a filename that the user can click to show the filename’s path and select one of the enclosing directories. Override the on-choose-directory method to handle the user’s selection.

(new name-message% ...superclass-args...)

  (is-a?/c name-message%)

Passes all arguments to super-init.

(send a-name-message on-choose-directory dir)  void?

  dir : path-string?

Called when one of the popup menu items is chosen. The argument is a represents the selected directory.

(send a-name-message on-event event)  void?

  event : (is-a?/c mouse-event%)

Overrides on-event in canvas<%>.

Handles the click by popping up a menu or message.

(send a-name-message on-paint)  void?

Overrides on-paint in canvas%.

Draws the control’s current message.

(send a-name-message set-hidden? hidden?)  void?

  hidden? : any/c

Calling this method with #f causes the name message to become invisible and to stop responding to mouse movements.

Calling it with a true value restores its visibility and makes it respond to mouse movements again.

(send a-name-message set-message

 

file-name?

 

 

 

 

 

 

msg)

 

 

void?

  file-name? : any/c

  msg : path-string?

Sets the label for the control.

If file-name? is #t, msg is treated like a pathname, and a click on the name-message control creates a popup menu to open a get-file dialog.

If file-name? is #f, msg is treated as a label string. Clicking on the name-message control pops up a dialog saying that there is no file name until the file is saved.

(calc-button-min-sizes dc str)

 

 

real?

 

real?

  dc : (is-a?/c dc<%>)

  str : string?

Calculates the minimum width and height of a button label (when drawn with draw-button-label). Returns two values: the width and height. The dc argument is used for sizing.

(draw-button-label

 

dc

 

 

 

 

 

 

str

 

 

 

 

 

 

dx

 

 

 

 

 

 

dy

 

 

 

 

 

 

width

 

 

 

 

 

 

height

 

 

 

 

 

 

mouse-over?

 

 

 

 

 

 

grabbed?

 

 

 

 

 

 

font

 

 

 

 

 

 

background)

 

 

void?

  dc : (is-a?/c dc<%>)

  str : string?

  dx : real?

  dy : real?

  width : real?

  height : real?

  mouse-over? : boolean?

  grabbed? : boolean?

  font : (is-a?/c font%)

  background : (or/c (is-a?/c color%) string? false/c)

Draws a button label like the one for the (define ...) and filename buttons in the top-left corner of the DrScheme frame. Use this function to draw similar buttons.

The basic idea is to create a canvas object whose on-paint method is overridden to call this function. The dc argument should be canvas’s drawing context, and str should be the string to display on the button. The width and height arguments should be the width and height of the button, and the dx and dy arguments specify an offset into dc for the button. The mouse-over? argument should be true when the mouse is over the button, and the grabbed? argument should be true when the button has been pressed. The font and background arguments supply the font to use in drawing (possibly normal-control-font) and the background color to paint (if any).

See calc-button-min-sizes for help calculating the min sizes of the button.