## arrowbutton-drawfn-and-sizefn.pkg
#
# View for arrow buttons.
# Compiled by:
#
src/lib/x-kit/widget/xkit-widget.sublib# This package gets used in:
#
#
src/lib/x-kit/widget/old/leaf/arrowbutton-look.pkgstipulate
include package geometry2d; # geometry2d is from
src/lib/std/2d/geometry2d.pkg #
package xc = xclient; # xclient is from
src/lib/x-kit/xclient/xclient.pkg #
package d3 = three_d; # three_d is from
src/lib/x-kit/widget/old/lib/three-d.pkg 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 wt = widget_types; # widget_types is from
src/lib/x-kit/widget/old/basic/widget-types.pkgherein
package arrowbutton_drawfn_and_sizefn
: (weak) Button_Drawfn_And_Sizefn # Button_Drawfn_And_Sizefn is from
src/lib/x-kit/widget/old/leaf/button-drawfn-and-sizefn.api {
attributes = [
(wa::arrow_dir, wa::ARROW_DIR, wa::ARROW_DIR_VAL wt::ARROW_UP)
];
offset = 1;
fun get_vertices (wide, high, wt::ARROW_UP)
=>
[ { col=>wide / 2, row=>offset - 1 },
{ col=>offset - 1, row=>high-offset },
{ col=>wide-offset, row=>high-offset }
];
get_vertices (wide, high, wt::ARROW_DOWN)
=>
[ { col=>wide / 2, row=>high-offset },
{ col=>wide-offset, row=>offset },
{ col=>offset, row=>offset }
];
get_vertices (wide, high, wt::ARROW_LEFT)
=>
[ { col=>offset, row=>high / 2 },
{ col=>wide-offset, row=>high-offset },
{ col=>wide-offset, row=>offset - 1 }
];
get_vertices (wide, high, wt::ARROW_RIGHT)
=>
[ { col=>wide-offset, row=>high / 2 },
{ col=>offset, row=>offset - 1 },
{ col=>offset, row=>high-offset }
];
end;
fun size direction (wide, high)
=
{ length = ((((wide - 2*offset)*173) + 100) / 200) + 2*offset;
#
my (wide, high)
=
case high
#
THE h => (wide, h);
_ => case direction
#
(wt::ARROW_DOWN
| wt::ARROW_UP) => (wide, length);
_ => (length, wide);
esac;
esac;
wg::make_tight_size_preference (wide, high);
};
fun drawfn direction (d, size as { wide, high }, bwid)
=
{ verts = get_vertices (wide, high, direction);
#
\\ (base, top, bottom) # Mode-dependent colors in which to draw.
=
{ xc::fill_polygon d base { verts, shape=>xc::CONVEX_SHAPE };
d3::draw3dpoly d (verts, bwid) { top, bottom };
};
};
fun make_button_drawfn_and_sizefn attributes
=
{ direction = wa::get_arrow_dir (attributes wa::arrow_dir);
#
( drawfn direction,
size direction
);
};
};
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.