From 379599ca2cad10ba7f491aa54d3327cf9f582341 Mon Sep 17 00:00:00 2001 From: Mike MacHenry Date: Mon, 9 Aug 2004 18:58:20 +0000 Subject: [PATCH] ... original commit: a579e45d795e6c31eaf70f3962da6d77d79a0118 --- .../embedded-gui/private/alignment-helpers.ss | 8 +++--- collects/embedded-gui/private/interface.ss | 20 ++++++++++++++ .../private/on-show-pasteboard.ss | 13 +++++++++- .../private/tests/alignment-test.ss | 26 +++++++++---------- .../private/verthoriz-alignment.ss | 2 +- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/collects/embedded-gui/private/alignment-helpers.ss b/collects/embedded-gui/private/alignment-helpers.ss index f480dd97..90bfa72f 100644 --- a/collects/embedded-gui/private/alignment-helpers.ss +++ b/collects/embedded-gui/private/alignment-helpers.ss @@ -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) diff --git a/collects/embedded-gui/private/interface.ss b/collects/embedded-gui/private/interface.ss index ba1c7563..d6916d1a 100644 --- a/collects/embedded-gui/private/interface.ss +++ b/collects/embedded-gui/private/interface.ss @@ -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 diff --git a/collects/embedded-gui/private/on-show-pasteboard.ss b/collects/embedded-gui/private/on-show-pasteboard.ss index 29012266..03e23508 100644 --- a/collects/embedded-gui/private/on-show-pasteboard.ss +++ b/collects/embedded-gui/private/on-show-pasteboard.ss @@ -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?)) |# - ) + ) \ No newline at end of file diff --git a/collects/embedded-gui/private/tests/alignment-test.ss b/collects/embedded-gui/private/tests/alignment-test.ss index bfa9a732..6db91d1c 100644 --- a/collects/embedded-gui/private/tests/alignment-test.ss +++ b/collects/embedded-gui/private/tests/alignment-test.ss @@ -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) \ No newline at end of file diff --git a/collects/embedded-gui/private/verthoriz-alignment.ss b/collects/embedded-gui/private/verthoriz-alignment.ss index 1e1742aa..3e6bec76 100644 --- a/collects/embedded-gui/private/verthoriz-alignment.ss +++ b/collects/embedded-gui/private/verthoriz-alignment.ss @@ -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)))