diff --git a/src/Makefile.am b/src/Makefile.am index 61fc20c..46c6bd0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS = gmenu2x -gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ +gmenu2x_SOURCES = font.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp \ inputmanager.cpp linkapp.cpp link.cpp \ menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp \ @@ -14,7 +14,7 @@ gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ browsedialog.cpp buttonbox.cpp dialog.cpp \ imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp -noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h \ +noinst_HEADERS = font.h button.h cpu.h dirdialog.h \ filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \ inputdialog.h inputmanager.h linkapp.h link.h \ menu.h menusettingbool.h menusettingdir.h \ diff --git a/src/browsedialog.cpp b/src/browsedialog.cpp index 0e51318..829dec3 100644 --- a/src/browsedialog.cpp +++ b/src/browsedialog.cpp @@ -3,6 +3,7 @@ #include "filelister.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" using std::string; @@ -269,7 +270,7 @@ void BrowseDialog::paint() } icon->blit(gmenu2x->s, 5, offsetY); gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, - ASFont::HAlignLeft, ASFont::VAlignMiddle); + Font::HAlignLeft, Font::VAlignMiddle); if (ts.available() && ts.pressed() && ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) { diff --git a/src/dialog.cpp b/src/dialog.cpp index 5749532..3eed2df 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -2,7 +2,7 @@ #include "dialog.h" #include "gmenu2x.h" -#include "asfont.h" +#include "font.h" Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x) { @@ -31,14 +31,14 @@ void Dialog::writeTitle(const std::string &title, Surface *s) { if (s==NULL) s = gmenu2x->s; - s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"]/4, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"] / 4, Font::HAlignLeft, Font::VAlignMiddle); } void Dialog::writeSubTitle(const std::string &subtitle, Surface *s) { if (s==NULL) s = gmenu2x->s; - s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"]/4*3, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"] / 4 * 3, Font::HAlignLeft, Font::VAlignMiddle); } diff --git a/src/asfont.cpp b/src/font.cpp similarity index 90% rename from src/asfont.cpp rename to src/font.cpp index 2274b34..31eca49 100644 --- a/src/asfont.cpp +++ b/src/font.cpp @@ -1,4 +1,5 @@ -#include "asfont.h" +#include "font.h" + #include "debug.h" #include "surface.h" #include "utilities.h" @@ -13,7 +14,7 @@ using namespace std; -ASFont::ASFont(const string &path) +Font::Font(const string &path) { if (!TTF_WasInit() && TTF_Init() < 0) { ERROR("Unable to init SDL_ttf library\n"); @@ -29,20 +30,20 @@ ASFont::ASFont(const string &path) fontheight = TTF_FontHeight(font); } -ASFont::~ASFont() +Font::~Font() { TTF_CloseFont(font); TTF_Quit(); } -int ASFont::getTextWidth(const char *text) +int Font::getTextWidth(const char *text) { int w, h; TTF_SizeUTF8(font, text, &w, &h); return w; } -void ASFont::write(Surface *surface, const string &text, +void Font::write(Surface *surface, const string &text, int x, int y, HAlign halign, VAlign valign) { if (text.find("\n", 0) == string::npos) { @@ -59,7 +60,7 @@ void ASFont::write(Surface *surface, const string &text, } } -void ASFont::writeLine(Surface *surface, const char *text, +void Font::writeLine(Surface *surface, const char *text, int x, int y, HAlign halign, VAlign valign) { switch (halign) { diff --git a/src/asfont.h b/src/font.h similarity index 70% rename from src/asfont.h rename to src/font.h index 3329b12..31b9dc0 100644 --- a/src/asfont.h +++ b/src/font.h @@ -1,24 +1,21 @@ -// Based on SFont by Karl Bartel. -// Adapted to C++ by Massimiliano Torromeo. -// Refactored by Maarten ter Huurne and several others (see git log). +// Original font class was replaced by an SDL_ttf based one by Paul Cercueil. // License: GPL version 2 or later. -#ifndef ASFONT_H -#define ASFONT_H +#ifndef FONT_H +#define FONT_H #include #include -#include class Surface; -class ASFont { +class Font { public: enum HAlign { HAlignLeft, HAlignRight, HAlignCenter }; enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle }; - ASFont(const std::string &font); - ~ASFont(); + Font(const std::string &font); + ~Font(); int getTextWidth(const char *text); @@ -44,4 +41,4 @@ private: unsigned int fontheight; }; -#endif /* ASFONT_H */ +#endif /* FONT_H */ diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 497222e..ed72a5e 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -20,12 +20,12 @@ #include "gp2x.h" -#include "asfont.h" #include "clock.h" #include "cpu.h" #include "debug.h" #include "filedialog.h" #include "filelister.h" +#include "font.h" #include "gmenu2x.h" #include "iconbutton.h" #include "inputdialog.h" @@ -314,7 +314,7 @@ void GMenu2X::initBG() { #else string df = getDiskFree(CARD_ROOT); #endif - bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle); + bgmain->write(font, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle); delete sd; cpuX = font->getTextWidth(df)+32; @@ -367,7 +367,7 @@ void GMenu2X::initFont() { quit(); exit(-1); } - font = new ASFont(fontFile); + font = new Font(fontFile); } void GMenu2X::initMenu() { @@ -655,7 +655,7 @@ void GMenu2X::main() { sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32); else sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding); - s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, ASFont::HAlignCenter, ASFont::VAlignBottom ); + s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, Font::HAlignCenter, Font::VAlignBottom ); } //Links @@ -675,10 +675,10 @@ void GMenu2X::main() { drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81); if (menu->selLink()!=NULL) { - s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom ); + s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, Font::HAlignCenter, Font::VAlignBottom ); if (menu->selLinkApp()!=NULL) { #ifdef ENABLE_CPUFREQ - s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle ); + s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle ); #endif //Manual indicator if (!menu->selLinkApp()->getManual().empty()) @@ -708,7 +708,7 @@ void GMenu2X::main() { s->write(font, Clock::getInstance()->getTime(), halfX, bottomBarTextY, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); if (helpDisplayed) { s->box(10,50,300,helpBoxHeight+4, skinConfColors[COLOR_MESSAGE_BOX_BG]); @@ -738,7 +738,7 @@ void GMenu2X::main() { tickFPS = tickNow; drawn_frames = 0; } - s->write( font, fps+" FPS", resX-1,1 ,ASFont::HAlignRight ); + s->write(font, fps + " FPS", resX - 1, 1, Font::HAlignRight); #endif s->flip(); @@ -1098,7 +1098,7 @@ void GMenu2X::contextMenu() { //draw selection rect s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] ); for (i=0; iwrite( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignTop ); + s->write( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, Font::HAlignLeft, Font::VAlignTop ); s->flip(); //touchscreen @@ -1353,7 +1353,7 @@ void GMenu2X::scanner() { Surface scanbg(bg); drawButton(&scanbg, "cancel", tr["Exit"], drawButton(&scanbg, "accept", "", 5)-10); - scanbg.write(font,tr["Link Scanner"],halfX,7,ASFont::HAlignCenter,ASFont::VAlignMiddle); + scanbg.write(font,tr["Link Scanner"],halfX,7,Font::HAlignCenter,Font::VAlignMiddle); scanbg.convertToDisplayFormat(); uint lineY = 42; @@ -1532,7 +1532,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); re.w = sc["imgs/buttons/"+btn+".png"]->width() + 3; - s->write(font, text, x+re.w, y, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(font, text, x+re.w, y, Font::HAlignLeft, Font::VAlignMiddle); re.w += font->getTextWidth(text); } return x+re.w+6; @@ -1544,7 +1544,7 @@ int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text, x -= 16; sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); x -= 3; - s->write(font, text, x, y, ASFont::HAlignRight, ASFont::VAlignMiddle); + s->write(font, text, x, y, Font::HAlignRight, Font::VAlignMiddle); return x-6-font->getTextWidth(text); } return x-6; diff --git a/src/gmenu2x.h b/src/gmenu2x.h index 65ebec9..0bd1875 100644 --- a/src/gmenu2x.h +++ b/src/gmenu2x.h @@ -32,8 +32,8 @@ #include #include -class ASFont; class Button; +class Font; class MediaMonitor; class Menu; class Surface; @@ -151,7 +151,7 @@ public: SurfaceCollection sc; Translator tr; Surface *s, *bg; - ASFont *font; + Font *font; //Status functions void main(); diff --git a/src/iconbutton.cpp b/src/iconbutton.cpp index 986c926..2552198 100644 --- a/src/iconbutton.cpp +++ b/src/iconbutton.cpp @@ -1,6 +1,6 @@ #include "iconbutton.h" -#include "asfont.h" +#include "font.h" #include "gmenu2x.h" #include "surface.h" @@ -35,7 +35,7 @@ void IconButton::paint() { } if (label != "") { gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y, - ASFont::HAlignLeft, ASFont::VAlignMiddle); + Font::HAlignLeft, Font::VAlignMiddle); } } diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index b6c1f09..6d54ecc 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -24,6 +24,7 @@ #include "delegate.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include @@ -168,7 +169,7 @@ bool InputDialog::exec() { gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->write(gmenu2x->font, input, box.x + 5, box.y + box.h - 2, - ASFont::HAlignLeft, ASFont::VAlignBottom); + Font::HAlignLeft, Font::VAlignBottom); curTick = SDL_GetTicks(); if (curTick - caretTick >= 600) { @@ -310,7 +311,7 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, charX, kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1, KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); xc++; } } @@ -330,7 +331,7 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], (int)(160 - kbLength * KEY_WIDTH / 4), KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1; gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); @@ -341,5 +342,5 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160 + kbLength * KEY_WIDTH / 4), KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); } diff --git a/src/link.cpp b/src/link.cpp index e17817b..c35fe70 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -23,6 +23,7 @@ #include "gmenu2x.h" #include "menu.h" #include "selector.h" +#include "surface.h" #include "utilities.h" #include @@ -47,12 +48,12 @@ void Link::paint() { if (iconSurface) { iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32); } - gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, ASFont::HAlignCenter, ASFont::VAlignBottom ); + gmenu2x->s->write(gmenu2x->font, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom); } bool Link::paintHover() { if (gmenu2x->useSelectionPng) - gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s,rect,ASFont::HAlignCenter,ASFont::VAlignMiddle); + gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s, rect, Font::HAlignCenter, Font::VAlignMiddle); else gmenu2x->s->box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); return true; diff --git a/src/linkapp.cpp b/src/linkapp.cpp index c31e549..2655de8 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -25,6 +25,7 @@ #include "gmenu2x.h" #include "menu.h" #include "selector.h" +#include "surface.h" #include "textmanualdialog.h" #include "utilities.h" @@ -379,7 +380,7 @@ void LinkApp::drawRun() { else gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/ iconSurface->blit(gmenu2x->s,x,gmenu2x->halfY-16); - gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, ASFont::HAlignLeft, ASFont::VAlignMiddle ); + gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, Font::HAlignLeft, Font::VAlignMiddle ); gmenu2x->s->flip(); } @@ -491,7 +492,7 @@ void LinkApp::showManual() { ss << page+1; ss >> pageStatus; pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount; - gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle); + gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle); gmenu2x->s->flip(); repaint = false; diff --git a/src/menusetting.cpp b/src/menusetting.cpp index 44f3160..c749d2c 100644 --- a/src/menusetting.cpp +++ b/src/menusetting.cpp @@ -20,8 +20,9 @@ #include "menusetting.h" -#include "asfont.h" +#include "font.h" #include "gmenu2x.h" +#include "surface.h" using std::string; @@ -40,7 +41,7 @@ MenuSetting::~MenuSetting() void MenuSetting::draw(int y) { - gmenu2x->s->write( gmenu2x->font, name, 5, y, ASFont::HAlignLeft, ASFont::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, name, 5, y, Font::HAlignLeft, Font::VAlignTop ); } void MenuSetting::handleTS() diff --git a/src/menusettingbool.cpp b/src/menusettingbool.cpp index 6d9f14e..1e3258b 100644 --- a/src/menusettingbool.cpp +++ b/src/menusettingbool.cpp @@ -23,6 +23,7 @@ #include "delegate.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include @@ -67,7 +68,7 @@ void MenuSettingBool::initButton() void MenuSettingBool::draw(int y) { MenuSetting::draw(y); - gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, Font::HAlignLeft, Font::VAlignTop ); } bool MenuSettingBool::handleButtonPress(InputManager::Button button) diff --git a/src/menusettingint.cpp b/src/menusettingint.cpp index 683ed72..7ddbb22 100644 --- a/src/menusettingint.cpp +++ b/src/menusettingint.cpp @@ -23,6 +23,7 @@ #include "delegate.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include @@ -69,7 +70,7 @@ MenuSettingInt::MenuSettingInt( void MenuSettingInt::draw(int y) { MenuSetting::draw(y); - gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop ); + gmenu2x->s->write(gmenu2x->font, strvalue, 155, y, Font::HAlignLeft, Font::VAlignTop); } bool MenuSettingInt::handleButtonPress(InputManager::Button button) diff --git a/src/menusettingrgba.cpp b/src/menusettingrgba.cpp index 1ab4e74..0993efb 100644 --- a/src/menusettingrgba.cpp +++ b/src/menusettingrgba.cpp @@ -22,6 +22,7 @@ #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include @@ -53,10 +54,10 @@ void MenuSettingRGBA::draw(int y) { MenuSetting::draw(y); gmenu2x->s->rectangle( 153, y+1, 11, 11, 0,0,0,255 ); gmenu2x->s->box( 154, y+2, 9, 9, value() ); - gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, ASFont::HAlignLeft, ASFont::VAlignTop ); - gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, ASFont::HAlignLeft, ASFont::VAlignTop ); - gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, ASFont::HAlignLeft, ASFont::VAlignTop ); - gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, ASFont::HAlignLeft, ASFont::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, Font::HAlignLeft, Font::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, Font::HAlignLeft, Font::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, Font::HAlignLeft, Font::VAlignTop ); + gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, Font::HAlignLeft, Font::VAlignTop ); } void MenuSettingRGBA::handleTS() { diff --git a/src/menusettingstringbase.cpp b/src/menusettingstringbase.cpp index d488114..16ae01c 100644 --- a/src/menusettingstringbase.cpp +++ b/src/menusettingstringbase.cpp @@ -17,8 +17,10 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + #include "menusettingstringbase.h" #include "gmenu2x.h" +#include "surface.h" using std::string; @@ -39,7 +41,7 @@ void MenuSettingStringBase::draw(int y) { MenuSetting::draw(y); gmenu2x->s->write(gmenu2x->font, value(), 155, y, - ASFont::HAlignLeft, ASFont::VAlignTop); + Font::HAlignLeft, Font::VAlignTop); } bool MenuSettingStringBase::handleButtonPress(InputManager::Button button) diff --git a/src/messagebox.cpp b/src/messagebox.cpp index a06bfbb..3dd6314 100644 --- a/src/messagebox.cpp +++ b/src/messagebox.cpp @@ -20,6 +20,7 @@ #include "messagebox.h" #include "gmenu2x.h" +#include "surface.h" #include @@ -77,7 +78,7 @@ int MessageBox::exec() { //icon+text if (gmenu2x->sc[icon] != NULL) gmenu2x->sc[icon]->blitCenter( &bg, box.x+25, box.y+gmenu2x->font->getHeight()+3 ); - bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, ASFont::HAlignLeft, ASFont::VAlignMiddle ); + bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, Font::HAlignLeft, Font::VAlignMiddle ); int btnX = gmenu2x->halfX+box.w/2-6; for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) { diff --git a/src/selector.cpp b/src/selector.cpp index cde60da..5aac770 100644 --- a/src/selector.cpp +++ b/src/selector.cpp @@ -25,6 +25,7 @@ #include "gmenu2x.h" #include "linkapp.h" #include "menu.h" +#include "surface.h" #include "utilities.h" #include @@ -117,9 +118,9 @@ int Selector::exec(int startSelection) { iY = i-firstElement; if (fl.isDirectory(i)) { gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, 42+(iY*16)); - gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle); + gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), Font::HAlignLeft, Font::VAlignMiddle); } else - gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle); + gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), Font::HAlignLeft, Font::VAlignMiddle); } gmenu2x->s->clearClipRect(); diff --git a/src/surface.cpp b/src/surface.cpp index a4cdac8..6f0b3ad 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -192,25 +192,25 @@ void Surface::setClipRect(SDL_Rect rect) { SDL_SetClipRect(raw,&rect); } -bool Surface::blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign, ASFont::VAlign valign) { +bool Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) { switch (halign) { - case ASFont::HAlignLeft: + case Font::HAlignLeft: break; - case ASFont::HAlignCenter: + case Font::HAlignCenter: container.x += container.w/2-halfW; break; - case ASFont::HAlignRight: + case Font::HAlignRight: container.x += container.w-raw->w; break; } switch (valign) { - case ASFont::VAlignTop: + case Font::VAlignTop: break; - case ASFont::VAlignMiddle: + case Font::VAlignMiddle: container.y += container.h/2-halfH; break; - case ASFont::VAlignBottom: + case Font::VAlignBottom: container.y += container.h-raw->h; break; } diff --git a/src/surface.h b/src/surface.h index c9bd04c..73a7b01 100644 --- a/src/surface.h +++ b/src/surface.h @@ -21,7 +21,7 @@ #ifndef SURFACE_H #define SURFACE_H -#include "asfont.h" +#include "font.h" #include #include @@ -62,13 +62,13 @@ public: void setClipRect(SDL_Rect rect); bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); - bool blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop); + bool blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop); bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); - void write(ASFont *font, const std::string &text, int x, int y, - ASFont::HAlign halign = ASFont::HAlignLeft, - ASFont::VAlign valign = ASFont::VAlignTop) { + void write(Font *font, const std::string &text, int x, int y, + Font::HAlign halign = Font::HAlignLeft, + Font::VAlign valign = Font::VAlignTop) { font->write(this, text, x, y, halign, valign); } @@ -92,7 +92,7 @@ private: int halfW, halfH; // For direct access to "raw". - friend class ASFont; + friend class Font; }; #endif diff --git a/src/textmanualdialog.cpp b/src/textmanualdialog.cpp index 30de855..539e975 100644 --- a/src/textmanualdialog.cpp +++ b/src/textmanualdialog.cpp @@ -21,6 +21,7 @@ #include "textmanualdialog.h" #include "gmenu2x.h" +#include "surface.h" #include "utilities.h" #include @@ -104,7 +105,7 @@ void TextManualDialog::exec() { ss << page+1; ss >> pageStatus; pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount; - gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle); + gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle); gmenu2x->s->flip(); diff --git a/src/wallpaperdialog.cpp b/src/wallpaperdialog.cpp index 62db38e..e2c2d66 100644 --- a/src/wallpaperdialog.cpp +++ b/src/wallpaperdialog.cpp @@ -25,6 +25,7 @@ #include "filelister.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include @@ -105,7 +106,7 @@ bool WallpaperDialog::exec() gmenu2x->s->setClipRect(0,41,311,179); for (i=firstElement; is->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), ASFont::HAlignLeft, ASFont::VAlignMiddle); + gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), Font::HAlignLeft, Font::VAlignMiddle); } gmenu2x->s->clearClipRect();