From 7861e07eb0b499f8f6c7016b6fa4f42060e5ea9a Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Thu, 2 Jun 2011 22:44:04 +0200 Subject: [PATCH] Surface: Made "raw" field private. I cheated a bit by declaring ASFont as friend, but all other outside access now happens via methods. I removed the "saveScreenshot" method since the code calling it is commented out and I never heard anyone complain about missing this feature. --- src/gmenu2x.cpp | 22 ++-------------------- src/gmenu2x.h | 1 - src/iconbutton.cpp | 4 ++-- src/linkapp.cpp | 2 +- src/surface.h | 7 ++++++- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 088cc9c..6a9df84 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -1441,24 +1441,6 @@ void GMenu2X::changeWallpaper() { } } -void GMenu2X::saveScreenshot() { - ledOn(); - uint x = 0; - stringstream ss; - string fname; - do { - x++; - fname = ""; - ss.clear(); - ss << x; - ss >> fname; - fname = "screen"+fname+".bmp"; - } while (fileExists(fname)); - SDL_SaveBMP(s->raw,fname.c_str()); - sync(); - ledOff(); -} - void GMenu2X::addLink() { FileDialog fd(this,tr["Select an application"]); if (fd.exec()) { @@ -1994,7 +1976,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x SDL_Rect re = {x, y-7, 0, 16}; 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"]->raw->w+3; + re.w = sc["imgs/buttons/"+btn+".png"]->width() + 3; s->write(font, text, x+re.w, y, ASFont::HAlignLeft, ASFont::VAlignMiddle); re.w += font->getTextWidth(text); } @@ -2046,7 +2028,7 @@ void GMenu2X::drawBottomBar(Surface *s) { Surface *bar = sc.skinRes("imgs/bottombar.png"); if (bar != NULL) - bar->blit(s, 0, resY-bar->raw->h); + bar->blit(s, 0, resY-bar->height()); else s->box(0, resY-20, resX, 20, skinConfColors[COLOR_BOTTOM_BAR_BG]); } diff --git a/src/gmenu2x.h b/src/gmenu2x.h index 278facf..ac8f7c0 100644 --- a/src/gmenu2x.h +++ b/src/gmenu2x.h @@ -210,7 +210,6 @@ public: void viewLog(); void contextMenu(); void changeWallpaper(); - void saveScreenshot(); void applyRamTimings(); void applyDefaultTimings(); diff --git a/src/iconbutton.cpp b/src/iconbutton.cpp index 972ad26..6795b28 100644 --- a/src/iconbutton.cpp +++ b/src/iconbutton.cpp @@ -52,8 +52,8 @@ void IconButton::recalcSize() { margin = 0; if (iconSurface != NULL) { - w += iconSurface->raw->w; - h += iconSurface->raw->h; + w += iconSurface->width(); + h += iconSurface->height(); iconRect.w = w; iconRect.h = h; iconRect.x = rect.x; diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 71695e3..278dc47 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -310,7 +310,7 @@ void LinkApp::showManual() { string pageStatus; bool close = false, repaint = true; - int page=0, pagecount=pngman->raw->w/320; + int page = 0, pagecount = pngman->width() / 320; ss << pagecount; string spagecount; diff --git a/src/surface.h b/src/surface.h index 94c2611..0386429 100644 --- a/src/surface.h +++ b/src/surface.h @@ -45,7 +45,8 @@ public: Surface(Surface *s); ~Surface(); - SDL_Surface *raw; + int width() { return raw->w; } + int height() { return raw->h; } void flip(); @@ -77,8 +78,12 @@ private: bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); + SDL_Surface *raw; bool freeWhenDone; int halfW, halfH; + + // For direct access to "raw". + friend class ASFont; }; #endif