#include "xspinbtn.h"


/*@ XSpinButton :: XSpinButton(const XWindow * owner, const XRect * rec, const USHORT id, const ULONG style, const char *string, const char *font)
@group constructors/destructors
@remarks Constructs a XSpinButton
@parameters <t 'ø' c=2>
				øXWindow * owner      øthe owner of the XSlider
            øXRect * rect         øthe rectangle
            øUSHORT id            øid of the window
            øULONG style          østyle, valid values are:
											<t 'ø' c=1>
												øSP_LEFT
												øSP_RIGHT
												øSP_CENTER
												øSP_NOBORDER
												øSP_FAST
												øSP_MASTER
												øSP_SERVANT
												øSP_READONLY
												øSP_NUMERIC
												øSP_CHAR
												øSP_FILLZERO
											</t>
                                (can be or-ed)
				øchar * font				øfont to use, e.g. "8.Helv"
				</t>
*/
XSpinButton :: XSpinButton(const XWindow * owner, const XRect * rec, const USHORT id, const ULONG style, const char *string, const char *font):XControl(rec, style, owner, string, WC_SPINBUTTON, id, font)
{
}


/*@ XSpinButton::SpinDown(const LONG units)
@group misc
@remarks Spin down window-content
@parameters LONG units     units to spin down
*/
void XSpinButton::SpinDown(const LONG units) const
{
	WinSendMsg(winhandle, SPBM_SPINDOWN, (MPARAM) units, 0);
}


/*@ XSpinButton::SpinUp(const LONG units)
@group misc
@remarks Spin up window-content
@parameters LONG units     units to spin up
*/
void XSpinButton::SpinUp(const LONG units) const
{
	WinSendMsg(winhandle, SPBM_SPINUP, (MPARAM) units, 0);
}


/*@ XSpinButton::SetTextLimit(const SHORT limit)
@group misc
@remarks Set maximum textlength
@parameters SHORT limit    maximum length
*/
void XSpinButton::SetTextLimit(const SHORT limit) const
{
	WinSendMsg(winhandle, SPBM_SPINDOWN, MPFROMSHORT(limit), 0);
}


/*@ XSpinButton::SetMaster(const XWindow * master)
@group misc
@remarks
@parameters XWindow* master
@returns BOOL result
*/
BOOL XSpinButton::SetMaster(const XWindow * master) const
{
	return (BOOL) WinSendMsg(winhandle, SPBM_SETMASTER, (MPARAM) master->GetHandle(), 0);
}


/*@ XSpinButton::GetValue(void)
@group set/query values
@remarks Returns the current value of the spinbutton
*/
LONG XSpinButton::GetValue(void)
{
	LONG l;

	WinSendMsg(winhandle, SPBM_QUERYVALUE, MPFROMP((VOID *) & l), 0);
	return l;
}


/*@ XSpinButton::SetLimits(const LONG lowerLimit, const LONG upperLimit)
@group limits
@remarks Set limits of the spinbutton
@parameters LONG lowerLimit   the lower limit<BR>
            LONG upperLimit   the upper limit
*/
void XSpinButton::SetLimits(const LONG lowerLimit, const LONG upperLimit) const
{
	WinSendMsg(winhandle, SPBM_SETLIMITS, (MPARAM) upperLimit, (MPARAM) lowerLimit);
}


/*@ XSpinButton::SetValue(const LONG val)
@group set/query values
@remarks Set the value of the spinbutton
@parameters LONG value     the new value
*/
void XSpinButton::SetValue(const LONG val) const
{
	WinSendMsg(winhandle, SPBM_SETCURRENTVALUE, (MPARAM) val, 0);
}
