/*
**  (C) Copyright 1989, 1990
**  Micro Data Base Systems Inc.
**  Lafayette, Indiana
*/
/* Class Button is the class of all button
   type control windows. */
subclass(Control,
         #Button,
         nil,
         true, true, false);$

/* Answer the window class name string. */
method Button::windowClassNameOf(self)
{
        return WC_BUTTON;
}

/* Simulate a button press. */
method Button::press(self)
{
        sendMessage(self, BM_CLICK, false, 0);
        return nil;
}

/* Simulate a button release. */
method Button::release(self)
{
        sendMessage(self, BM_CLICK, true, 0);
        return nil;
}

/* Answer whether or not a button is selected. */
method Button::isChecked(self)
{
        return sendMessage(self, BM_QUERYCHECK, 0, 0) == 1;
}

/* Answer the 0 based index into a group of radio buttons to the button
   with the check. */
method Button::checkIndexOf(self)
{
	return asInteger(sendMessage(self, BM_QUERYCHECKINDEX, 0, 0));
}

/* Answer 'true' if the button is highlited. */
method Button::isHilited(self)
{
	return sendMessage(self, BM_QUERYHILITE, 0, 0) != 0;
}

/* Place the checkmark next to a button. Answer with the previous
   check state of the button. */
method Button::check(self)
{
        return sendMessage(self, BM_SETCHECK, 1, 0) == 1;
}

/* Remove the checkmark from a button. Answer with the previous
   check state of the button. */
method Button::unCheck(self)
{
        return sendMessage(self, BM_SETCHECK, false, 0) == 1;
}

/* Make the push button a default push putton. */
method Button::setDefault(self)
{
        return sendMessage(self, BM_SETDEFAULT, true, 0) != 0;
}

/* Make the push button a normal push putton. */
method Button::resetDefault(self)
{
        return sendMessage(self, BM_SETDEFAULT, false, 0) != 0;
}

/* Turn on the button hilite. Answer the previous button hilite state. */
method Button::hilite(self)
{
	return sendMessage(self, BM_SETHILITE, true, 0) != 0;
}

/* Turn off the button hilite. */
method Button::unHilite(self)
{
	return sendMessage(self, BM_SETHILITE, false, 0) != 0;
}
 
/* Toggle the checked status of the button.  Answer the prior state. */
method Button::toggle(self)
{
        if(isChecked(self)) 
                return(unCheck(self));
        else
                return(check(self));
}