diff --git a/devel/scheme/gui/scheme-gui-advanced.en.tm b/devel/scheme/gui/scheme-gui-advanced.en.tm index 41851c1..618ad4a 100644 --- a/devel/scheme/gui/scheme-gui-advanced.en.tm +++ b/devel/scheme/gui/scheme-gui-advanced.en.tm @@ -8,49 +8,267 @@ Setting attributes of widgets is achieved by enclosing them in the - following special widgets: + following special widgets. - , , , ...\ + <\explain> + > + <|explain> + This does just that: it centers the widget with respect to the + enclosing widget. Although we are calling this an attribute, the effect + is achieved by using a vertical list and a horizontal one together with + four widgets. This means that in the following example, the + first widget is actually expanded to something like the second one. - + <\session|scheme|default> + <\unfolded-io|Scheme] > + (tm-widget (wid1) + + \ \ (centered (text "I'm centered."))) + <|unfolded-io> + ((guile-user) (guile-user)) + + + <\folded-io|Scheme] > + (tm-widget (wid2) + + \ \ (vlist + + \ \ \ \ (glue #f #f 0 10) + + \ \ \ \ (hlist + + \ \ \ \ \ \ (glue #t #f 25 0) + + \ \ \ \ \ \ (text "I'm centered.") + + \ \ \ \ \ \ (glue #t #f 25 0)) + + \ \ \ \ (glue #f #f 0 10))) + <|folded-io> + ((guile-user) (guile-user)) + + + <\input|Scheme] > + (show wid1) + + + <\input|Scheme] > + (show wid2) + + + + + <\explain> + + + > + <|explain> + These two variants resize the argument. The first one specifies a minimum + size of , a default size of and a maximum size + of . The widget will be set to the default size + and will be allowed to resize but not beyond the bounds specified. The + second alternative sets a fixed width and height. + + Sizes are specified as strings with a unit suffix, like in . + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (tm-widget (wid) + + \ \ (resize "200px" "70px" (text "I'm stuck!"))) + <|unfolded-io> + \; + + + <\input|Scheme] > + (show wid) + + + + + <\explain> + by + padding> + <|explain> + This sets some fixed padding around . As in the case of + , the effect is achieved by means of several widgets into + which this macro expands. These are actually the same as in the example + there, but the widgets are all fixed (i.e. have all their + expansion paramenters set to ). + + + You can arrange widgets horizontally or vertically, or in two column mode as in forms. When running the QT version the latter will default to the OS standard for arranging labels and their associated input widgets in - dialogs. + dialogs. Other possibilites are splitters and tabbed widgets. A very useful + macro is , which allows you to embed one widget into another. - , , , , ... + <\explain> + + <|explain> + \; + + + <\explain> + + <|explain> + \; + + + <\explain> + + <|explain> + \; + + + <\explain> + + <|explain> + \; + + + <\explain> + + <|explain> + \; + + + <\explain> + + <|explain> + can be any widget defined using . + - Shifting of widgets... From the definitions: + Besides laying out widgets in containers, you will often want to specifiy + how they eat up space around them when the user resizes the window. By + default (most?) widgets take up as much space as they can (i.e. they always + expand) unless you used with them. If you don't want this to + happen you can place invisible spacers around them which will (if you tell + them to) gobble up as much as they can, either vertically or horizontally + or in both directions. - <\verbatim> - ((== x '---) '$---) + provides one such basic building block: - ((== x '===) (gui-make '(glue #f #f 0 5))) + <\explain> + + <|explain> + The first two parameters are of type and specify whether the + widget will try to expand horizontally or vertically when its + surroundings do. The last two parameters either fix the size for + non-expanding or set a minimum one. - ((== x '======) (gui-make '(glue #f #f 0 15))) + <\session|scheme|default> + <\unfolded-io|Scheme] > + (tm-widget (wid1) - ((== x '/) '$/) + \ \ (centered (text "I'm centered."))) + <|unfolded-io> + ((guile-user) (guile-user)) + - ((== x '//) (gui-make '(glue #f #f 5 0))) + <\unfolded-io|Scheme] > + (tm-widget (wid2) - ((== x '///) (gui-make '(glue #f #f 15 0))) + \ \ (vlist - ((== x '\\) (gui-make '(glue #t #f 5 0))) + \ \ \ \ === - ((== x '\\\) (gui-make '(glue #t #f 15 0))) + \ \ \ \ (hlist - ((== x (string-\symbol "\|")) '$/) - + \ \ \ \ \ \ (glue #t #f 25 0) + + \ \ \ \ \ \ (text "I'm centered.") + + \ \ \ \ \ \ (glue #t #f 25 0)) + + \ \ \ \ (glue #f #f 0 10))) + <|unfolded-io> + ((guile-user) (guile-user) (guile-user) (guile-user)) + + + <\input|Scheme] > + (show wid1) + + + <\input|Scheme] > + (show wid2) + + + <\input|Scheme] > + \; + + + + + In addition to the basic widget, there are several convenience + macros. + + <\explain> + + <|explain> + Expands to . + + + <\explain> + + <|explain> + Expands to . + + + <\explain> + + <|explain> + Expands to . + + + <\explain> + + <|explain> + Expands to . + + + <\explain> + \> + <|explain> + Expands to . + + + <\explain> + \\> + <|explain> + Expands to . + + + For the specific use in menus the following two macros are defined: + + <\explain> + + <|explain> + (That's a vertical bar: ) + + + <\explain> + + <|explain> + (That's dashes. If you see only two, that's + a bug which hasn't yet been fixed) + Refresh widgets reevaluate their contents every time a command is executed... - + \; diff --git a/devel/scheme/gui/scheme-gui-intro.en.tm b/devel/scheme/gui/scheme-gui-intro.en.tm index 406bc25..00ee868 100644 --- a/devel/scheme/gui/scheme-gui-intro.en.tm +++ b/devel/scheme/gui/scheme-gui-intro.en.tm @@ -118,7 +118,7 @@ The special symbol \\> is just one of the - predefined .\ + predefined . @@ -127,7 +127,13 @@ - + + + In order to create more complex layouts you'll need a few containers. Among + these are and . A very useful macro is + : it allows you to embed one widget into another. + + Let's see how you create a dialog. To get started here is one little example taken from : @@ -250,11 +256,35 @@ - That special at the bottom \> inserts as before - whitespace, but it stretches and aligns the to the - right (). This is just another example of a - , of which there are more described - . + That special \> at the end of the widget inserts as + before whitespace, but it stretches and aligns the to + the right. This is just another example of a . + + + + Note that our second dialog, is just a copy of + with an extra line at the end. We could have spared us the + keytrokes in this way: + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (tm-widget (widget1-buttons-smarter cmd) + + \ \ (dynamic (widget1)) + + \ \ (bottom-buttons \\ ("Ok" (cmd "Ok")))) + <|unfolded-io> + \; + + + <\input|Scheme] > + (dialogue-window widget1-buttons-smarter (lambda (arg) (display* arg + "\\n")) "Two toggles") + + + \; + As you can see, the approach we've shown has a shortcoming: there's no way to access all the values of the different widgets in your dialog at the @@ -278,7 +308,7 @@ : <\session|scheme|default> - <\folded-io|Scheme] > + <\unfolded-io|Scheme] > (tm-widget (form3 cmd) \ \ (resize "500px" "500px" @@ -329,9 +359,9 @@ (form-values) "\\n") \ \ \ \ \ \ \ \ \ \ \ (cmd "ok"))))))) - <|folded-io> - ((guile-user) (guile-user)) - + <|unfolded-io> + \; + <\input|Scheme] > (dialogue-window form3 (lambda (x) (display* x "\\n")) "Test of form3")