added docs and minor cleanups in mrlib/name-message
original commit: c5b0c73111e7e6e6752616856a8a4c54d3749a95
This commit is contained in:
parent
f39e86aad3
commit
b4ccdd66b5
|
@ -7,7 +7,8 @@
|
|||
|
||||
(provide/contract
|
||||
[get-left-side-padding (-> number?)]
|
||||
[pad-xywh (number? number? (>=/c 0) (>=/c 0) . -> . (values number? number? (>=/c 0) (>=/c 0)))]
|
||||
[pad-xywh (-> number? number? (>=/c 0) (>=/c 0)
|
||||
(values number? number? (>=/c 0) (>=/c 0)))]
|
||||
[draw-button-label
|
||||
(->d ([dc (is-a?/c dc<%>)]
|
||||
[label (or/c false/c string?)]
|
||||
|
@ -23,8 +24,8 @@
|
|||
[result void?])]
|
||||
|
||||
[calc-button-min-sizes
|
||||
(->* ((is-a?/c dc<%>) string? (is-a?/c font%))
|
||||
()
|
||||
(->* ((is-a?/c dc<%>) string?)
|
||||
((is-a?/c font%))
|
||||
(values number? number?))])
|
||||
|
||||
(provide name-message%)
|
||||
|
@ -241,7 +242,7 @@
|
|||
(define mouse-grabbed-color (make-object color% 100 100 100))
|
||||
(define grabbed-fg-color (make-object color% 220 220 220))
|
||||
|
||||
(define (calc-button-min-sizes dc label button-label-font)
|
||||
(define (calc-button-min-sizes dc label [button-label-font (send dc get-font)])
|
||||
(let-values ([(w h a d) (send dc get-text-extent label button-label-font)])
|
||||
(let-values ([(px py pw ph) (pad-xywh 0 0 w h)])
|
||||
(values pw ph))))
|
||||
|
|
|
@ -72,7 +72,7 @@ saying that there is no file name until the file is saved.}
|
|||
the @method[name-message% set-message].
|
||||
}
|
||||
|
||||
@defmethod[(get-background-color) (or/c false/c (is-a/c color%) string?)]{
|
||||
@defmethod[(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 @scheme[#f], the
|
||||
|
@ -80,7 +80,7 @@ OS's default panel background is used.
|
|||
|
||||
}
|
||||
|
||||
@defmethod[(set-allow-shrinking [width (or/c false/c number?)]) void?]{
|
||||
@defmethod[(set-allow-shrinking [width (or/c #f number?)]) void?]{
|
||||
|
||||
When this method receives a number, the name-message will
|
||||
then shrink (the number indicates the minimum width the name
|
||||
|
@ -99,7 +99,8 @@ Defaultly, the name-message does not allow shrinking.
|
|||
|
||||
|
||||
@defproc[(calc-button-min-sizes [dc (is-a?/c dc<%>)]
|
||||
[str string?])
|
||||
[str string?]
|
||||
[font (or/c #f (is-a?/c font%)) #f])
|
||||
(values real? real?)]{
|
||||
|
||||
Calculates the minimum width and height of a button label (when drawn
|
||||
|
@ -116,7 +117,7 @@ and height. The @scheme[dc] argument is used for sizing.}
|
|||
[mouse-over? boolean?]
|
||||
[grabbed? boolean?]
|
||||
[font (is-a?/c font%)]
|
||||
[background (or/c (is-a?/c color%) string? false/c)])
|
||||
[background (or/c (is-a?/c color%) string? #f)])
|
||||
void?]{
|
||||
|
||||
Draws a button label like the one for the @onscreen{(define ...)} and
|
||||
|
@ -139,3 +140,15 @@ color to paint (if any).
|
|||
See @scheme[calc-button-min-sizes] for help calculating the min sizes
|
||||
of the button.}
|
||||
|
||||
@defproc[(pad-xywh [tx number?]
|
||||
[ty number?]
|
||||
[tw (>=/c 0)]
|
||||
[th (>=/c 0)])
|
||||
(values number? number? (>=/c 0) (>=/c 0))]{
|
||||
Returns spacing information describing how
|
||||
@racket[draw-button-label] draws. The inputs are
|
||||
the x and y coordinates where the text should appear
|
||||
and the width and height of the text, and the results
|
||||
are the x and y coordinates where the shape should be
|
||||
drawn and the width and height of the overall shape.
|
||||
}
|
Loading…
Reference in New Issue
Block a user