1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-05 09:43:10 +02:00
gmenu2x/src/dialog.cpp
Maarten ter Huurne aff5f53f7d Don't pass around naked Surface pointers when drawing
Use references instead.
2014-08-10 04:26:59 +02:00

40 lines
929 B
C++

#include <string>
#include "dialog.h"
#include "gmenu2x.h"
#include "font.h"
Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x)
{
}
void Dialog::drawTitleIcon(Surface& s, const std::string &icon, bool skinRes)
{
Surface *i = NULL;
if (!icon.empty()) {
if (skinRes)
i = gmenu2x->sc.skinRes(icon);
else
i = gmenu2x->sc[icon];
}
if (i==NULL)
i = gmenu2x->sc.skinRes("icons/generic.png");
i->blit(s, 4, (gmenu2x->skinConfInt["topBarHeight"] - 32) / 2);
}
void Dialog::writeTitle(Surface& s, const std::string &title)
{
gmenu2x->font->write(s, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
}
void Dialog::writeSubTitle(Surface& s, const std::string &subtitle)
{
std::string wrapped = gmenu2x->font->wordWrap(subtitle, gmenu2x->resX - 48);
gmenu2x->font->write(s, wrapped, 40,
gmenu2x->skinConfInt["topBarHeight"]
- gmenu2x->font->getTextHeight(wrapped),
Font::HAlignLeft, Font::VAlignTop);
}