PreviousUpNext

15.4.1522  src/lib/x-kit/widget/old/leaf/roundbutton-drawfn-and-sizefn.pkg

## roundbutton-drawfn-and-sizefn.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/old/leaf/roundbutton-look.pkg

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

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

    package roundbutton_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 = [];
        #
        fun drawfn (d, { wide, high }, bwid)
            =
            {
                wid2   = wide / 2;
                ht2    = high / 2;

                pt     = { 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  = { col=>1, row=>1, wide=>diam, high=>diam, angle1, angle2=>  angle2 };
                lower  = { col=>1, row=>1, wide=>diam, high=>diam, angle1, angle2=> -angle2 };

                fun draw (base, top, bottom)                                                    # Mode-dependent colors in which to draw.
                    =
                    {   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 make_button_drawfn_and_sizefn _
            =
            (drawfn, sizefn);
    };

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.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext