PreviousUpNext

15.4.1402  src/lib/x-kit/widget/leaf/roundbutton-shape.pkg

## roundbutton-shape.pkg

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib






###               "Where a calculator on the ENIAC is
###                equipped with 18,000 vacuum tubes
###                and weighs 30 tons, computers in the
###                future may have only 1,000 vacuum tubes
###                and perhaps weigh 1.5 tons."
###                          -- Popular Mechanics, 1949


# This package gets used in:
#
#     src/lib/x-kit/widget/leaf/roundbutton-look.pkg

stipulate
#    include xgeometry;                                                 # xgeometry             is from   src/lib/std/2d/xgeometry.pkg

    package wg =  widget;                                               # widget                is from   src/lib/x-kit/widget/basic/widget.pkg
    #
    package xc =  xclient;                                              # xclient               is from   src/lib/x-kit/xclient/xclient.pkg
    package xg =  xgeometry;                                            # xgeometry             is from   src/lib/std/2d/xgeometry.pkg
herein

    package roundbutton_shape: (weak)  Button_Shape {                   # Button_Shape          is from   src/lib/x-kit/widget/leaf/button-shape.api

        attributes = [];

        fun drawfn (d, xg::SIZE { wide, high }, bwid)
            =
            {
                wid2   = wide / 2;
                ht2    = high / 2;

                pt     = xg::POINT { col=>wid2, row=>ht2 };     #  Center point 

                radius = int::min (wid2, ht2) - 1;
                diam   = 2*radius;
                circle = { center=>pt, rad=>radius-bwid };

                angle1 =  45 * 64;   #  45 degrees 
                angle2 = 180 * 64;   # 180 degrees 

                upper  = xg::ARC { col=>1, row=>1, wide=>diam, high=>diam, angle1, angle2=>  angle2 };
                lower  = xg::ARC { col=>1, row=>1, wide=>diam, high=>diam, angle1, angle2=> -angle2 };

                fun draw (base, top, bottom)
                    =
                    {   xc::fill_arc    d top    upper;
                        xc::fill_arc    d bottom lower;
                        xc::fill_circle d base   circle;
                    };

                draw;
            };

        fun sizefn (wide, _)
            =
            wg::make_tight_size_preference (wide, wide);

        fun config _
            =
            (sizefn, drawfn);

    };

end;


## COPYRIGHT (c) 1994 by AT&T Bell Laboratories  See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2013,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext