## divider.pkg
#
# Draw a horizontal or vertical division between
# other widgets, to visually clarify the user
# interface layout.
# Compiled by:
#
src/lib/x-kit/widget/xkit-widget.sublib### "Barring unforeseen obstacles, an
### on-line interactive computer service,
### provided commercially by an information
### utility, may be as commonplace by 2000 AD
### as telephone service is today."
###
### -- Martin Greenberger, 1964
stipulate
package wg = widget; # widget is from
src/lib/x-kit/widget/old/basic/widget.pkg package wa = widget_attribute_old; # widget_attribute_old is from
src/lib/x-kit/widget/old/lib/widget-attribute-old.pkg package bx = colorbox; # colorbox is from
src/lib/x-kit/widget/old/leaf/colorbox.pkgherein
package divider
: (weak) Divider # Divider is from
src/lib/x-kit/widget/old/leaf/divider.api {
fun make_size_fn (is_horizontal, width)
=
{ if (width < 0)
#
lib_base::failure { module=>"Divider", fn=>"mkSize", msg=>"width < 0"};
fi;
tight_dim = wg::tight_preference width;
loose_dim = wg::INT_PREFERENCE { start_at=>1, step_by=>1, min_steps=>0, best_steps=>0, max_steps=>NULL };
size_preferences
=
is_horizontal ?? { col_preference=>loose_dim, row_preference=>tight_dim }
:: { row_preference=>loose_dim, col_preference=>tight_dim };
\\ () = size_preferences;
};
fun make_divider is_horizontal root { color, width }
=
bx::make_colorbox root (color, make_size_fn (is_horizontal, width));
make_horizontal_divider = make_divider TRUE;
make_vertical_divider = make_divider FALSE;
attributes
=
[ (wa::width, wa::INT, wa::INT_VAL 1) ];
fun divider is_horizontal (root, view, args)
=
{ attribute_def = wg::find_attribute (wg::attributes (view, attributes, args));
#
width = wa::get_int (attribute_def wa::width);
sizefn = make_size_fn (is_horizontal, width);
bx::colorbox (root, view, args) sizefn;
};
horizontal_divider = divider TRUE;
vertical_divider = divider FALSE;
}; # package divider
end;
## COPYRIGHT (c) 1994 by AT&T Bell Laboratories See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.