/*	XGToolTipView.cpp
 *
 *		This is the tool tip view
 */

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

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

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

#include <XConfig.h>
#include <XToolTip.h>
#include <XDraw.h>
#include <string.h>

/************************************************************************/
/*																		*/
/*	Globals																*/
/*																		*/
/************************************************************************/

static XGSViewInitRecord MenuInitRecord = {
	'****', 1, 0,
	0, 0, 0, 0,
	true, true, true, true,
	true, true, false
};

/************************************************************************/
/*																		*/
/*	Construction/Destruction											*/
/*																		*/
/************************************************************************/

/*$	XGToolTipView::XGToolTipView
 *
 *		Create me
 */

XGToolTipView::XGToolTipView(char *label) : XGView(NULL,MenuInitRecord)
{
	strcpy(fLabel,label);
}

/*$	XGToolTipView::~XGToolTipView
 *
 *		Go away
 */

XGToolTipView::~XGToolTipView()
{
}

/************************************************************************/
/*																		*/
/*	Size preflight														*/
/*																		*/
/************************************************************************/

/*$	XGToolTipView::GetPopSize
 *
 *		The drawing object I'm handed is already initialized. All I
 *	do is figure out how big my menu should be.
 */

XPoint XGToolTipView::GetPopSize(XGDraw &draw)
{
	XPoint size;
	
	size.v = draw.GetFontHeight() + 2;
	size.h = draw.StringWidth(fLabel) + 6;
	return size;
}

/************************************************************************/
/*																		*/
/*	Event Processing													*/
/*																		*/
/************************************************************************/

/*$	XGToolTipView::DoDrawView
 *
 *		Draw the contents of this view
 */

void XGToolTipView::DoDrawView(XRect)
{
	XRect r;
	XGDraw draw(this);
	draw.SetFont(XGFont::LoadFont(1));

	draw.SetForeColor(KXGColorToolTipText);
	draw.SetBackColor(KXGColorToolTip);

	r = GetContentRect();
	draw.EraseRect(r);
	draw.MoveTo(3,1+draw.GetFontAscent());
	draw.DrawString(fLabel);
	draw.FrameRect(r);
}
