From c8762ae87724b8a52056929bad6554d08f79dd0f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 3 Aug 2010 12:34:06 -0600 Subject: [PATCH] add methods to text-field% to control the background color --- collects/mred/private/mrtextfield.rkt | 7 ++++++- collects/mred/private/wxtextfield.rkt | 7 ++++++- collects/scribblings/gui/text-field-class.scrbl | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/collects/mred/private/mrtextfield.rkt b/collects/mred/private/mrtextfield.rkt index 179b9b460b..e76c938ca1 100644 --- a/collects/mred/private/mrtextfield.rkt +++ b/collects/mred/private/mrtextfield.rkt @@ -57,11 +57,16 @@ (private-field [wx #f]) (public + [set-field-background (lambda (c) + (check-instance '(method text-field% set-field-color) + wx:color% 'color% #f c) + (send wx set-field-background c))] + [get-field-background (lambda () (send wx get-field-background))] [get-editor (entry-point (lambda () (send wx get-editor)))] [get-value (lambda () (send wx get-value))] ; note: wx method doesn't expect as-entry [set-value (entry-point (lambda (v) - (check-string '(method text-control<%> set-value) v) + (check-string '(method text-field% set-value) v) (send wx set-value v)))]) (sequence ;; Technically a bad way to change margin defaults, since it's diff --git a/collects/mred/private/wxtextfield.rkt b/collects/mred/private/wxtextfield.rkt index f17688bb11..55a0b2f30d 100644 --- a/collects/mred/private/wxtextfield.rkt +++ b/collects/mred/private/wxtextfield.rkt @@ -113,7 +113,12 @@ [get-canvas-width (lambda () (let ([tw (box 0)]) (send c get-size tw (box 0)) - (unbox tw)))]) + (unbox tw)))] + + [set-field-background (lambda (col) + (send c set-canvas-background col))] + [get-field-background (lambda () + (send c get-canvas-background))]) (override ;; These might be called before we are fully initialized diff --git a/collects/scribblings/gui/text-field-class.scrbl b/collects/scribblings/gui/text-field-class.scrbl index 3519d102c2..3032ca10d1 100644 --- a/collects/scribblings/gui/text-field-class.scrbl +++ b/collects/scribblings/gui/text-field-class.scrbl @@ -116,6 +116,11 @@ For a text field, the most useful methods of a @scheme[text%] object } +@defmethod[(get-field-background) (is-a?/c color%)]{ + +Gets the background color of the field's editable area.} + + @defmethod[(get-value) string?]{ @@ -124,6 +129,12 @@ Returns the text currently in the text field. } +@defmethod[(set-field-background [color (is-a?/c color%)]) + void?]{ + +Sets the background color of the field's editable area.} + + @defmethod[(set-value [val string?]) void?]{