/*  GadTools layout toolkit
**
**  Copyright © 1993-1995 by Olaf `Olsen' Barthel
**  Freely distributable.
*/

#include "gtlayout_global.h"

STATIC VOID __regargs
LTP_GetSizeDimensions(LayoutHandle *Handle,ULONG *SizeWidth,ULONG *SizeHeight)
{
	Object	*SizeImage;
	UWORD	 SizeType;

	if(Handle -> Screen -> Flags & SCREENHIRES)
	{
		if(SizeWidth)
			*SizeWidth = 18;

		if(SizeHeight)
			*SizeHeight = 10;

		SizeType = SYSISIZE_MEDRES;
	}
	else
	{
		if(SizeWidth)
			*SizeWidth = 13;

		if(SizeHeight)
			*SizeHeight = 11;

		SizeType = SYSISIZE_LOWRES;
	}

	if(SizeImage = NewObject(NULL,SYSICLASS,
		SYSIA_Size,		SizeType,
		SYSIA_Which,	SIZEIMAGE,
		SYSIA_DrawInfo,	Handle -> DrawInfo,
	TAG_DONE))
	{
		if(SizeWidth)
			GetAttr(IA_Width,SizeImage,SizeWidth);

		if(SizeHeight)
			GetAttr(IA_Height,SizeImage,SizeHeight);

		DisposeObject(SizeImage);
	}
}


/*****************************************************************************/


ULONG __regargs
LTP_GetSizeWidth(struct LayoutHandle *handle)
{
	ULONG SizeWidth;

	LTP_GetSizeDimensions(handle,&SizeWidth,NULL);

	if(SizeWidth < handle -> Screen -> WBorRight)
		return(handle -> Screen -> WBorRight);
	else
		return(SizeWidth);
}


/*****************************************************************************/


ULONG __regargs
LTP_GetSizeHeight(struct LayoutHandle *handle)
{
	ULONG SizeHeight;

	LTP_GetSizeDimensions(handle,NULL,&SizeHeight);

	if(SizeHeight < handle -> Screen -> WBorBottom)
		return(handle -> Screen -> WBorBottom);
	else
		return(SizeHeight);
}
