original commit: a579e45d795e6c31eaf70f3962da6d77d79a0118
This commit is contained in:
Mike MacHenry 2004-08-09 18:58:20 +00:00
parent aa5fa1a2c1
commit 379599ca2c
5 changed files with 50 additions and 19 deletions

View File

@ -4,13 +4,15 @@
(lib "list.ss")
(lib "class.ss")
(lib "mred.ss" "mred")
(lib "contract.ss")
"interface.ss"
"snip-lib.ss")
(provide vacuous-max
child-height
child-width)
(provide/contract
(vacuous-max (() (listof number?) . ->* . (number?)))
(child-height ((union (is-a?/c alignment<%>) (is-a?/c snip%)) . -> . number?))
(child-width ((union (is-a?/c alignment<%>) (is-a?/c snip%)) . -> . number?)))
(define (vacuous-max . n)
(if (empty? n)

View File

@ -7,12 +7,32 @@
(define alignment<%>
(interface ()
#;(-> void?)
;; Tells the alignment that its sizes should be calculated
set-min-sizes
#;(nonnegative? nonnegative? nonnegative? nonnegative? . -> . void?)
;; Tells the alignment to align its children on the pasteboard in the given rectangle
align
#;(-> nonnegative?)
;; The minimum width this alignment must be
get-min-width
#;(-> nonnegative?)
;; The minimum height this alignment must be
get-min-height
#;(-> boolean?)
;; True if the alignment can be stretched in the x dimension
stretchable-width?
#;(-> boolean?)
;; True if the alignment can be stretched in the y dimension
stretchable-height?
#;(boolean? . -> . void)
;; Tells the alignment to show or hide its children
show))
#| the interface that must be implemented by a class to be inserted into an

View File

@ -12,12 +12,22 @@
(define (on-show-pasteboard-mixin super%)
(class super%
(field [shown? false])
#|
(rename [super-refresh refresh])
(define/override (refresh x y w h d-c)
(super-refresh x y (max w 0) (max h 0) d-c)
(unless shown?
(set! shown? true)
(on-show)))
|#
#|
(rename [super-get-extent get-extent])
(define/override (get-extent w h)
(super-get-extent w h)
(unless shown?
(set! shown? true)
(on-show)))
|#
(define/public (showing?) shown?)
(define/public (on-show) (void))
(super-new)))
@ -33,9 +43,10 @@
(define c (new editor-canvas% (editor e) (parent f)))
(define pb (new on-show-pasteboard%))
(define es (new editor-snip% (editor pb)))
(not (send pb showing?))
(send e insert es)
(send pb showing?)
(send e remove es)
(not (send pb showing?))
|#
)
)

View File

@ -6,7 +6,8 @@
"../stretchable-editor-snip.ss"
"../verthoriz-alignment.ss"
"../aligned-pasteboard.ss"
"../grid-alignment.ss")
"../grid-alignment.ss"
"../snip-wrapper.ss")
(define f (new frame% (label "f") (height 500) (width 500)))
(send f show true)
@ -14,17 +15,14 @@
(define c (new editor-canvas% (editor a1) (parent f)))
(define a2 (new horizontal-alignment% (parent a1)))
(define a3 (new horizontal-alignment% (parent a1)))
(define a4 (new grid-alignment% (parent a1) (columns 4)))
(send a2 add (make-object string-snip% "One"))
(send a2 add (make-object string-snip% "Two"))
(send a3 add (make-object string-snip% "Three"))
(send a3 add (make-object string-snip% "Four"))
(send a4 add (vector (make-object string-snip% "This is really long")
(new editor-snip% (editor (new text%)))
(make-object string-snip% "short")
(make-object string-snip% "meduim")))
(send a4 add (vector (make-object string-snip% "short")
(make-object string-snip% "This is really long")
(new editor-snip% (editor (new text%)))
(make-object string-snip% "meduim")))
(new snip-wrapper%
(snip (make-object string-snip% "One"))
(parent a2))
(new snip-wrapper%
(snip (make-object string-snip% "Two"))
(parent a2))
(new snip-wrapper%
(snip (make-object string-snip% "Three"))
(parent a3))
(send f show true)

View File

@ -30,7 +30,7 @@
[min-height 0])
;; STATUS: This function (through lock-alignment false) invokes a call
;; to realign of the pasteboard even when this alignement has show? = false
;; to realign of the pasteboard even when this alignment has show? = false
;; so the call is not needed.
(define/public (add child)
(set! children (append children (list child)))