10 Name Message
(require mrlib/name-message) | package: gui-lib |
|
superclass: canvas% |
constructor
(new name-message% ...superclass-args...)
→ (is-a?/c name-message%) Passes all arguments to super-init.
method
(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.
method
event : (is-a?/c mouse-event%) Handles the click by popping up a menu or message.Draws the control’s current message.
method
(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.
method
(send a-name-message set-message file-name? msg) → void? file-name? : any/c msg : (if filename? path-string? 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.
method
(send a-name-message set-short-title short-title?) → void?
short-title? : boolean? Sets the short-title? flag. The flag defaults to #f.If the flag is #t, then the label for the control is simply the string "/". Otherwise, the label is determined by the set-message.
method
(send a-name-message fill-popup menu reset) → any
menu : (is-a?/c popup-menu%) reset : (-> void?) This method is called when the user clicks in the name message. Override it to fill in the menu items for the popup menu menu.
method
(send a-name-message get-background-color)
→ (or/c #f (is-a/c color%) string?) The result of this method is used for the background color when redrawing the name message. If it is #f, the OS’s default panel background is used.
method
(send a-name-message set-allow-shrinking width) → void?
width : (or/c #f number?) When this method receives a number, the name-message will then shrink (the number indicates the minimum width the name message will have).If it receives false, the name message will not shrink and its minimum width will be the size required to display its current label.
By default, the name-message does not allow shrinking.
procedure
(calc-button-min-sizes dc str [font]) →
real? real? dc : (is-a?/c dc<%>) str : string? font : (or/c #f (is-a?/c font%)) = #f
procedure
(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? #f)
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.
procedure
(pad-xywh tx ty tw th) →
number? number? (>=/c 0) (>=/c 0) tx : number? ty : number? tw : (>=/c 0) th : (>=/c 0)