changed the way equal<%> and snip% interact. Specifically:
- snip% now implements equal<%> its equal-to? delegates to other-equal-to?. - snip%'s other-equal-to and equal-hash-code and equal-secondary-hash-code all just amount to using eq?. The setup is here just to make snip% be the one that declares that it implements equal<%> so that various snips can adjust other-equal-to? (and the hash code methods) - image-snip% no longer implements equal<%> (but it extends snip% and it overrides other-equal-to? and the hash-code methods to do what they always did)
This commit is contained in:
parent
e5175c5b38
commit
2f009ca529
|
@ -108,7 +108,7 @@
|
|||
|
||||
;; ------------------------------------------------------------
|
||||
|
||||
(defclass snip% object%
|
||||
(defclass* snip% object% (equal<%>)
|
||||
;; For use only by the owning editor:
|
||||
(field [s-prev #f]
|
||||
[s-next #f]
|
||||
|
@ -322,14 +322,19 @@
|
|||
#f))))
|
||||
|
||||
(def/public (set-unmodified)
|
||||
(void)))
|
||||
|
||||
(void))
|
||||
|
||||
(def/public (equal-to? [snip% that] [any? recur])
|
||||
(send that other-equal-to? this recur))
|
||||
(def/public (other-equal-to? [image-snip% that] [any? recur]) (eq? this that))
|
||||
(define/public (equal-hash-code-of recur) (eq-hash-code this))
|
||||
(define/public (equal-secondary-hash-code-of recur) 1))
|
||||
|
||||
(defclass internal-snip% snip%
|
||||
(super-new)
|
||||
(def/override (set-count [exact-integer? c])
|
||||
;; reject change
|
||||
(void)))
|
||||
|
||||
;; ------------------------------------------------------------
|
||||
|
||||
(defclass string-snip-class% snip-class%
|
||||
|
@ -863,7 +868,7 @@
|
|||
(get-output-bytes s))]
|
||||
[else default]))])))
|
||||
|
||||
(defclass* image-snip% internal-snip% (equal<%> png-convertible<%>)
|
||||
(defclass* image-snip% internal-snip% (png-convertible<%>)
|
||||
(inherit-field s-admin
|
||||
s-flags)
|
||||
(inherit set-snipclass)
|
||||
|
@ -1138,10 +1143,7 @@
|
|||
(def/public (get-bitmap-mask)
|
||||
mask)
|
||||
|
||||
(def/public (equal-to? [image-snip% other] [any? recur])
|
||||
(send other other-equal-to? this recur))
|
||||
|
||||
(def/public (other-equal-to? [image-snip% other] [any? recur])
|
||||
(def/override (other-equal-to? [image-snip% other] [any? recur])
|
||||
(let* ([bm (send this get-bitmap)]
|
||||
[bm2 (send other get-bitmap)])
|
||||
(and
|
||||
|
@ -1186,9 +1188,9 @@
|
|||
(hash-code s1)))
|
||||
0))
|
||||
|
||||
(def/public (equal-hash-code-of [any? recur])
|
||||
(def/override (equal-hash-code-of [any? recur])
|
||||
(do-hash-code equal-hash-code))
|
||||
(def/public (equal-secondary-hash-code-of [any? recur])
|
||||
(def/override (equal-secondary-hash-code-of [any? recur])
|
||||
(do-hash-code equal-secondary-hash-code))
|
||||
|
||||
(def/public (set-offset [real? x] [real? y])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#lang scribble/doc
|
||||
@(require "common.ss")
|
||||
|
||||
@defclass/title[image-snip% snip% (equal<%>)]{
|
||||
@defclass/title[image-snip% snip% ()]{
|
||||
|
||||
An @scheme[image-snip%] is a snip that can display bitmap images
|
||||
(usually loaded from a file). When the image file cannot be found, a
|
||||
|
@ -43,19 +43,6 @@ secondary hash code for @this-obj[] (using the same notion of
|
|||
|
||||
See also @scheme[equal<%>].}
|
||||
|
||||
|
||||
@defmethod[(equal-to? [snip (is-a?/c image-snip%)]
|
||||
[equal? (any/c any/c . -> . boolean?)])
|
||||
boolean?]{
|
||||
|
||||
Calls the @method[image-snip% other-equal-to?] method of @scheme[snip]
|
||||
(to simulate multi-method dispatch) in case @scheme[snip] provides a
|
||||
more specific equivalence comparison.
|
||||
|
||||
See also @scheme[equal<%>].}
|
||||
|
||||
|
||||
|
||||
@defmethod[(get-bitmap)
|
||||
(or/c (is-a?/c bitmap%) #f)]{
|
||||
|
||||
|
@ -145,7 +132,7 @@ If @scheme[inline?] is not @scheme[#f], the image data will be saved
|
|||
boolean?]{
|
||||
|
||||
Returns @scheme[#t] if @this-obj[] and @scheme[snip] both have bitmaps
|
||||
and the bitmaps are the same dimensions. If either has a mask bitmap
|
||||
and the bitmaps are the same. If either has a mask bitmap
|
||||
with the same dimensions as the main bitmap, then the masks must be
|
||||
the same (or if only one mask is present, it must correspond to a
|
||||
solid mask).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#lang scribble/doc
|
||||
@(require "common.ss")
|
||||
|
||||
@defclass/title[snip% object% ()]{
|
||||
@defclass/title[snip% object% (equal<%>)]{
|
||||
|
||||
A direct instance of @scheme[snip%] is uninteresting. Useful snips are
|
||||
defined by instantiating derived subclasses, but this class defines
|
||||
|
@ -217,7 +217,35 @@ Draws nothing.
|
|||
|
||||
}}
|
||||
|
||||
@defmethod[(equal-to? [snip (is-a?/c snip%)]
|
||||
[equal? (-> any/c any/c boolean?)])
|
||||
boolean?]{
|
||||
@methspec{See @scheme[equal<%>].}
|
||||
|
||||
@methimpl{Calls the @method[snip% other-equal-to?] method of @scheme[snip]
|
||||
(to simulate multi-method dispatch) in case @scheme[snip] provides a
|
||||
more specific equivalence comparison.}}
|
||||
|
||||
@defmethod[(other-equal-to? [that (is-a?/c snip%)]
|
||||
[equal? (-> any/c any/ boolean?)])
|
||||
boolean?]{
|
||||
@methimpl{Returns @racket[(eq? this that)].}
|
||||
}
|
||||
|
||||
@defmethod[(equal-hash-code [hash-code (any/c . -> . exact-integer?)])
|
||||
exact-integer?]{
|
||||
|
||||
@methspec{See @scheme[equal<%>].}
|
||||
|
||||
@methimpl{Returns @scheme[(eq-hash-code this)].}}
|
||||
|
||||
@defmethod[(equal-secondary-hash-code [hash-code (any/c . -> . exact-integer?)])
|
||||
exact-integer?]{
|
||||
|
||||
@methspec{See @scheme[equal<%>].}
|
||||
|
||||
@methimpl{Returns @scheme[1].}}
|
||||
|
||||
@defmethod[(find-scroll-step [y real?])
|
||||
exact-nonnegative-integer?]{
|
||||
|
||||
|
@ -234,7 +262,6 @@ Returns @scheme[0].
|
|||
|
||||
}}
|
||||
|
||||
|
||||
@defmethod[(get-admin)
|
||||
(or/c (is-a?/c snip-admin%) false/c)]{
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user