2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* Tantric 2009
|
|
|
|
*
|
|
|
|
* gui_tooltip.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
2011-01-08 13:35:41 +01:00
|
|
|
#include "themes/CTheme.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
/**
|
|
|
|
* Constructor for the GuiTooltip class.
|
|
|
|
*/
|
2011-01-08 13:35:41 +01:00
|
|
|
GuiTooltip::GuiTooltip(const char *t, int Alpha/*=255*/)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2011-01-08 13:35:41 +01:00
|
|
|
tooltipLeft = Resources::GetImageData("tooltip_left.png");
|
|
|
|
tooltipTile = Resources::GetImageData("tooltip_tile.png");
|
|
|
|
tooltipRight = Resources::GetImageData("tooltip_right.png");
|
|
|
|
leftImage = new GuiImage(tooltipLeft);
|
|
|
|
tileImage = new GuiImage(tooltipTile);
|
|
|
|
rightImage = new GuiImage(tooltipRight);
|
2010-09-19 01:16:05 +02:00
|
|
|
text = NULL;
|
2011-01-08 13:35:41 +01:00
|
|
|
height = leftImage->GetHeight();
|
|
|
|
leftImage->SetParent(this);
|
|
|
|
tileImage->SetParent(this);
|
|
|
|
rightImage->SetParent(this);
|
|
|
|
leftImage->SetParentAngle(false);
|
|
|
|
tileImage->SetParentAngle(false);
|
|
|
|
rightImage->SetParentAngle(false);
|
2010-09-24 02:48:03 +02:00
|
|
|
SetText(t);
|
|
|
|
SetAlpha(Alpha);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destructor for the GuiTooltip class.
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiTooltip::~GuiTooltip()
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (text) delete text;
|
2011-01-08 13:35:41 +01:00
|
|
|
|
|
|
|
delete tooltipLeft;
|
|
|
|
delete tooltipTile;
|
|
|
|
delete tooltipRight;
|
|
|
|
delete leftImage;
|
|
|
|
delete tileImage;
|
|
|
|
delete rightImage;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
float GuiTooltip::GetScale()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
float s = scale * scaleDyn;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return s;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* !Sets the text of the GuiTooltip element
|
|
|
|
* !\param t Text
|
|
|
|
*/
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiTooltip::SetText(const char * t)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (text)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
delete text;
|
|
|
|
text = NULL;
|
|
|
|
}
|
|
|
|
int tile_cnt = 0;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (t && (text = new GuiText(t, 22, ( GXColor )
|
|
|
|
{ 0, 0, 0, 255})))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
text->SetParent(this);
|
2011-01-08 13:35:41 +01:00
|
|
|
tile_cnt = (text->GetTextWidth() - 12) / tileImage->GetWidth();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (tile_cnt < 0) tile_cnt = 0;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2011-01-08 13:35:41 +01:00
|
|
|
tileImage->SetPosition(leftImage->GetWidth(), 0);
|
2011-06-14 19:53:19 +02:00
|
|
|
tileImage->SetTileHorizontal(tile_cnt);
|
2011-01-08 13:35:41 +01:00
|
|
|
rightImage->SetPosition(leftImage->GetWidth() + tile_cnt * tileImage->GetWidth(), 0);
|
|
|
|
width = leftImage->GetWidth() + tile_cnt * tileImage->GetWidth() + rightImage->GetWidth();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiTooltip::SetWidescreen(bool )
|
|
|
|
{
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
/*
|
|
|
|
* Draw the Tooltip on screen
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiTooltip::Draw()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!this->IsVisible()) return;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-01-08 13:35:41 +01:00
|
|
|
leftImage->Draw();
|
|
|
|
tileImage->Draw();
|
|
|
|
rightImage->Draw();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (text) text->Draw();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
this->UpdateEffects();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|