add methods to text-field% to control the background color

This commit is contained in:
Matthew Flatt 2010-08-03 12:34:06 -06:00
parent 82f976a4d9
commit c8762ae877
3 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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?]{