diff --git a/collects/mrlib/close-icon.ss b/collects/mrlib/close-icon.ss index 24e05a0c..cde9e95f 100644 --- a/collects/mrlib/close-icon.ss +++ b/collects/mrlib/close-icon.ss @@ -55,7 +55,8 @@ (class canvas% (inherit get-dc min-width min-height stretchable-width stretchable-height get-client-size refresh) - (init-field [callback void]) + (init-field [callback void] + [bg-color #f]) (init [horizontal-pad 4] [vertical-pad 4]) (init-masks) @@ -92,6 +93,11 @@ (define/override (on-paint) (let ([dc (get-dc)]) (let-values ([(cw ch) (get-client-size)]) + (when bg-color + (send dc set-brush bg-color 'solid) + (send dc set-pen bg-color 1 'transparent) + (let-values ([(w h) (get-client-size)]) + (send dc draw-rectangle 0 0 w h))) (send dc draw-bitmap icon (- (/ cw 2) (/ (send icon get-width) 2)) (- (/ ch 2) (/ (send icon get-height) 2)) diff --git a/collects/mrlib/scribblings/close-icon.scrbl b/collects/mrlib/scribblings/close-icon.scrbl index 2a62dd24..0d5e3616 100644 --- a/collects/mrlib/scribblings/close-icon.scrbl +++ b/collects/mrlib/scribblings/close-icon.scrbl @@ -13,8 +13,11 @@ provides a clickable close button icon.} @defclass[close-icon% canvas% ()]{ @defconstructor[([parent (is-a? area-container<%>)] [callback (-> any) void] + [bg-color (or/c #f string (is-a?/c color%))] [horizontal-pad positive-integer? 4] [vertical-pad positive-integer? 4])]{ The @scheme[callback] is called when the close icon is clicked. + + If @scheme[bg-color] is specified, it is used as the background color of the icon. } }