From 3e64e5f4fbaf636ce2e8468129b1780ee4e9406c Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 28 Jul 2009 20:40:54 +0000 Subject: [PATCH] added a close icon to the yellow warning message svn: r15611 original commit: 3c4bdf86feeda27ad9de986bf357d1a65fda79c0 --- collects/mrlib/close-icon.ss | 8 +++++++- collects/mrlib/scribblings/close-icon.scrbl | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) 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. } }