2019-01-17 00:04:56 +08:00
|
|
|
<TeXmacs|1.99.8>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2019-01-17 00:04:56 +08:00
|
|
|
<style|<tuple|tmdoc|old-spacing>>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
|
|
|
<\body>
|
2012-09-13 15:40:21 +08:00
|
|
|
<tmdoc-title|Containers, glue, refresh and co.>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<subsection|Attribute widgets>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
In what follows <scm-arg|widget> can be anything defined using
|
|
|
|
<scm|tm-widget>.
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(centered <scm-arg|widget>)><explain-synopsis|centers
|
|
|
|
<scm-arg|widget>>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
This does just that: it centers <scm-arg|widget> with respect to the
|
2012-07-29 18:06:13 +08:00
|
|
|
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 <scm|glue> widgets. This means that in the following example, the
|
|
|
|
first widget is actually expanded to something like the second one.
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\session|scheme|default>
|
|
|
|
<\unfolded-io|Scheme] >
|
|
|
|
(tm-widget (wid1)
|
|
|
|
|
|
|
|
\ \ (centered (text "I'm centered.")))
|
|
|
|
<|unfolded-io>
|
|
|
|
((guile-user) (guile-user))
|
|
|
|
</unfolded-io>
|
|
|
|
|
|
|
|
<\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))
|
|
|
|
</folded-io>
|
|
|
|
|
|
|
|
<\input|Scheme] >
|
|
|
|
(show wid1)
|
|
|
|
</input>
|
|
|
|
|
|
|
|
<\input|Scheme] >
|
|
|
|
(show wid2)
|
|
|
|
</input>
|
|
|
|
</session>
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(resize (<scm-arg|w1> <scm-arg|w2> <scm-arg|w3>) (<scm-arg|h1>
|
|
|
|
<scm-arg|h2> <scm-arg|h3>) <scm-arg|wid>)>
|
2012-07-29 18:06:13 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(resize <scm-arg|w> <scm-arg|h> <scm-arg|widget>)><explain-synopsis|resizes
|
|
|
|
<scm-arg|widget>>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
These two variants resize the argument. The first one specifies a minimum
|
2012-08-11 05:29:34 +08:00
|
|
|
size of <scm-arg|w1><math|\<times\>><scm-arg|h1>, a default size of
|
|
|
|
<scm-arg|w2><math|\<times\>><scm-arg|h2> and a maximum size of
|
|
|
|
<scm-arg|w3><math|\<times\>><scm-arg|h3>. <scm-arg|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.
|
2012-07-29 18:06:13 +08:00
|
|
|
|
|
|
|
Sizes are specified as strings with a unit suffix, like in <scm|"150px">.
|
|
|
|
|
|
|
|
<\session|scheme|default>
|
|
|
|
<\unfolded-io|Scheme] >
|
|
|
|
(tm-widget (wid)
|
|
|
|
|
|
|
|
\ \ (resize "200px" "70px" (text "I'm stuck!")))
|
|
|
|
<|unfolded-io>
|
|
|
|
\;
|
|
|
|
</unfolded-io>
|
|
|
|
|
|
|
|
<\input|Scheme] >
|
|
|
|
(show wid)
|
|
|
|
</input>
|
|
|
|
</session>
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(padded <scm-arg|widget>)><explain-synopsis|surrounds
|
|
|
|
<scm-arg|widget> by padding>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
This sets some fixed padding around <scm-arg|widget>. As in the case of
|
2012-07-29 18:06:13 +08:00
|
|
|
<scm|centered>, 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 <scm|glue> widgets are all fixed (i.e. have all their
|
2019-01-17 00:04:56 +08:00
|
|
|
expansion parameters set to <scm|#f>).
|
2012-07-29 18:06:13 +08:00
|
|
|
</explain>
|
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<subsection|Container or layout widgets>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
Features and fixes (Qt):
Support for widgets: texmacs-output, texmacs-input, resize, popup (for help
balloons), buttons in dialogs, tweaks here and there.
Fixes to layouts and sizing, scroll widgets are dummy for most widgets.
Support for side tools as another (floatable) QToolBar. Would a QDockWidget
be better?
Consistent (albeit partial) support for TeXmacs' widget styles.
Support for some more widgets as menu items (i.e. as QActions for QToolBar).
Fix placement of context menus.
New management of ownership of QWidgets.
Cleanup and maintenance (Qt):
Comments. Many, many comments.
Removed unnecessary files.
Grouped common method definitions.
Shifting around of code for consistency.
Documentation regarding widgets and extension of the UI.
XCode: update project for XCode4, new xcconfig for MOC objects fixes linker
warnings.
To do (Qt):
Fine-tune the presentation of QWidgets: remove unnecessary spacing, provide
default alignment policies, add better support for widgets in QToolBars
(see as_qaction()).
Finish the popup widget (timeout, etc.)
Why are texmacs widgets so often wrapped into vertical widgets? This messes
with scrollable_widget.
Understand why QPainter is not properly initialized for output widgets, then
remove the hack in Texmacs/Window/tm_button.cpp.
2012-05-29 06:17:09 +08:00
|
|
|
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
|
2019-01-17 00:04:56 +08:00
|
|
|
dialogs. Other possibilities are splitters and tabbed widgets. A very
|
|
|
|
useful macro is <scm|dynamic>, which allows you to embed one widget into
|
|
|
|
another.
|
2012-07-29 18:06:13 +08:00
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(aligned <scm-arg|items-list>)><explain-synopsis|arranges items in a
|
|
|
|
two column table>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
\;
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(hlist <scm-arg|widgets>)> <explain-synopsis|arranges items
|
|
|
|
horizontally>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
\;
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(vlist <scm-arg|widgets>)><explain-synopsis|arranges items
|
|
|
|
vertically>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
\;
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(hsplit (item (<scm-arg|widget>)) (item (<scm-arg|widget>))
|
|
|
|
...)><explain-synopsis|arranges two items in a split panel>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
\;
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(tabs (tab (<scm-arg|widget>)) (tab (<scm-arg|widget>))
|
|
|
|
...)><explain-synopsis|a tabbed widget>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
|
|
|
\;
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(dynamic (<scm-arg|widget>))><explain-synopsis|embeds a tm-widget
|
|
|
|
into another one>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
\;
|
2012-07-29 18:06:13 +08:00
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<subsection|Glue widgets>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2019-01-17 00:04:56 +08:00
|
|
|
Besides laying out widgets in containers, you will often want to specify
|
2012-07-29 18:06:13 +08:00
|
|
|
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
|
2012-08-11 05:29:34 +08:00
|
|
|
expand) unless you used <scm|resize> with them or they can have their size
|
|
|
|
set with a parameter. 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.
|
2012-07-29 18:06:13 +08:00
|
|
|
|
|
|
|
<TeXmacs> provides one such basic building block:
|
|
|
|
|
|
|
|
<\explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
<scm|(glue <scm-arg|horiz> <scm-arg|vert> <scm-arg|width>
|
|
|
|
<scm-arg|height>)><explain-synopsis|possibly expanding whitespace>
|
2012-07-29 18:06:13 +08:00
|
|
|
<|explain>
|
2012-08-11 05:29:34 +08:00
|
|
|
The first two parameters, <scm-arg|horiz> and <scm-arg|vert>, are of
|
|
|
|
boolean type and specify whether the <scm|glue> widget will try to expand
|
|
|
|
horizontally or vertically when its surroundings do. The last two
|
|
|
|
parameters, <scm-arg|width> <scm-arg|height>, either fix the size for
|
2012-07-29 18:06:13 +08:00
|
|
|
non-expanding <scm|glue> or set a minimum one.
|
|
|
|
|
|
|
|
<\session|scheme|default>
|
|
|
|
<\unfolded-io|Scheme] >
|
|
|
|
(tm-widget (wid1)
|
|
|
|
|
|
|
|
\ \ (centered (text "I'm centered.")))
|
|
|
|
<|unfolded-io>
|
2012-08-11 05:29:34 +08:00
|
|
|
\;
|
2012-07-29 18:06:13 +08:00
|
|
|
</unfolded-io>
|
|
|
|
|
|
|
|
<\unfolded-io|Scheme] >
|
|
|
|
(tm-widget (wid2)
|
|
|
|
|
|
|
|
\ \ (vlist
|
|
|
|
|
|
|
|
\ \ \ \ ===
|
|
|
|
|
|
|
|
\ \ \ \ (hlist
|
|
|
|
|
|
|
|
\ \ \ \ \ \ (glue #t #f 25 0)
|
|
|
|
|
|
|
|
\ \ \ \ \ \ (text "I'm centered.")
|
|
|
|
|
|
|
|
\ \ \ \ \ \ (glue #t #f 25 0))
|
|
|
|
|
|
|
|
\ \ \ \ (glue #f #f 0 10)))
|
|
|
|
<|unfolded-io>
|
2012-08-11 05:29:34 +08:00
|
|
|
\;
|
2012-07-29 18:06:13 +08:00
|
|
|
</unfolded-io>
|
|
|
|
|
|
|
|
<\input|Scheme] >
|
|
|
|
(show wid1)
|
|
|
|
</input>
|
|
|
|
|
|
|
|
<\input|Scheme] >
|
|
|
|
(show wid2)
|
|
|
|
</input>
|
|
|
|
</session>
|
|
|
|
</explain>
|
|
|
|
|
|
|
|
In addition to the basic <scm|glue> widget, there are several convenience
|
|
|
|
macros.
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|===><explain-synopsis|vertical separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #f #f 0 5)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|======><explain-synopsis|big vertical separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #f #f 0 15)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|//><explain-synopsis|horizontal separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #f #f 5 0)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|///><explain-synopsis|big horizontal separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #f #f 15 0)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|\<gtr\>\<gtr\>><explain-synopsis|expanding horizontal separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #t #f 5 0)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|\<gtr\>\<gtr\>\<gtr\>><explain-synopsis|big expanding horizontal
|
|
|
|
separator>
|
|
|
|
<|explain>
|
|
|
|
Expands to <scm|(glue #t #f 15 0)>.
|
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
For the specific use in menus the following two macros are defined:
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|\|><explain-synopsis|horizontal separator>
|
|
|
|
<|explain>
|
2013-01-07 00:53:09 +08:00
|
|
|
(A vertical bar)
|
2012-07-29 18:06:13 +08:00
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-07-29 18:06:13 +08:00
|
|
|
<\explain>
|
|
|
|
<scm|---><explain-synopsis|vertical separator>
|
|
|
|
<|explain>
|
2013-01-07 00:53:09 +08:00
|
|
|
(Three dashes)
|
2012-07-29 18:06:13 +08:00
|
|
|
</explain>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<subsection|Refresh widgets>
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2013-01-07 00:53:09 +08:00
|
|
|
Refresh widgets redraw their contents every time a command is executed.
|
|
|
|
They achieve this re-evaluating the code for the whole widget, so you can
|
|
|
|
have new values in your variables...
|
2012-04-07 20:02:10 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<tmdoc-copyright|2012|the <TeXmacs> team.>
|
Features and fixes (Qt):
Support for widgets: texmacs-output, texmacs-input, resize, popup (for help
balloons), buttons in dialogs, tweaks here and there.
Fixes to layouts and sizing, scroll widgets are dummy for most widgets.
Support for side tools as another (floatable) QToolBar. Would a QDockWidget
be better?
Consistent (albeit partial) support for TeXmacs' widget styles.
Support for some more widgets as menu items (i.e. as QActions for QToolBar).
Fix placement of context menus.
New management of ownership of QWidgets.
Cleanup and maintenance (Qt):
Comments. Many, many comments.
Removed unnecessary files.
Grouped common method definitions.
Shifting around of code for consistency.
Documentation regarding widgets and extension of the UI.
XCode: update project for XCode4, new xcconfig for MOC objects fixes linker
warnings.
To do (Qt):
Fine-tune the presentation of QWidgets: remove unnecessary spacing, provide
default alignment policies, add better support for widgets in QToolBars
(see as_qaction()).
Finish the popup widget (timeout, etc.)
Why are texmacs widgets so often wrapped into vertical widgets? This messes
with scrollable_widget.
Understand why QPainter is not properly initialized for output widgets, then
remove the hack in Texmacs/Window/tm_button.cpp.
2012-05-29 06:17:09 +08:00
|
|
|
|
2012-08-11 05:29:34 +08:00
|
|
|
<tmdoc-license|Permission is granted to copy, distribute and/or modify
|
|
|
|
this\ndocument under the terms of the GNU Free Documentation License,
|
|
|
|
Version 1.1 or\nany later version published by the Free Software
|
|
|
|
Foundation; with no Invariant\nSections, with no Front-Cover Texts, and
|
|
|
|
with no Back-Cover Texts. A copy of\nthe license is included in the section
|
|
|
|
entitled "GNU Free Documentation License".>
|
2013-01-07 00:53:09 +08:00
|
|
|
</body>
|
|
|
|
|
|
|
|
<initial|<\collection>
|
|
|
|
</collection>>
|