1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 17:52:54 +03:00

More header cleanups.

This time the focus was on removing namespace imports from headers.
This commit is contained in:
Maarten ter Huurne 2011-10-23 16:43:56 +02:00
parent e0e7e87ebc
commit a01d892eb6
22 changed files with 212 additions and 227 deletions

View File

@ -7,6 +7,7 @@
#include <string>
using namespace fastdelegate;
using std::string;
BrowseDialog::BrowseDialog(GMenu2X *gmenu2x, const string &title,
const string &subtitle)

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,17 +18,14 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef BUTTON_H_
#define BUTTON_H_
#ifndef BUTTON_H
#define BUTTON_H
#include <string>
#include <SDL.h>
#include "FastDelegate.h"
using std::string;
using fastdelegate::FastDelegate0;
#include <SDL.h>
typedef FastDelegate0<> ButtonAction;
typedef fastdelegate::FastDelegate0<> ButtonAction;
class Touchscreen;
class Button {
@ -61,4 +58,4 @@ public:
void setAction(ButtonAction action);
};
#endif /*BUTTON_H_*/
#endif // BUTTON_H

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,20 +18,20 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef FILEDIALOG_H_
#define FILEDIALOG_H_
#include <string>
#ifndef FILEDIALOG_H
#define FILEDIALOG_H
#include "browsedialog.h"
#include <string>
class FileDialog : public BrowseDialog {
public:
FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter="",
const string &file="", const string &title = "File Dialog");
FileDialog(GMenu2X *gmenu2x, const std::string &text,
const std::string &filter="", const std::string &file="",
const std::string &title = "File Dialog");
virtual ~FileDialog();
bool exec();
};
#endif /*INPUTDIALOG_H_*/
#endif // FILEDIALOG_H

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,6 +18,11 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "filelister.h"
#include "debug.h"
#include "utilities.h"
//for browsing the filesystem
#include <sys/stat.h>
#include <sys/types.h>
@ -27,10 +32,6 @@
#include <algorithm>
#include <cstring>
#include "filelister.h"
#include "utilities.h"
#include "debug.h"
using namespace std;
FileLister::FileLister(const string &startPath, bool showDirectories,

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,43 +18,40 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef FILELISTER_H_
#define FILELISTER_H_
#ifndef FILELISTER_H
#define FILELISTER_H
#include <string>
#include <vector>
using std::string;
using std::vector;
class FileLister {
private:
string path, filter;
std::string path, filter;
bool showDirectories, showFiles;
vector<string> directories, files, excludes;
std::vector<std::string> directories, files, excludes;
public:
FileLister(const string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
FileLister(const std::string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
void browse(bool clean = true);
unsigned int size();
unsigned int dirCount();
unsigned int fileCount();
string operator[](unsigned int);
string at(unsigned int);
std::string operator[](unsigned int);
std::string at(unsigned int);
bool isFile(unsigned int);
bool isDirectory(unsigned int);
const string &getPath();
void setPath(const string &path, bool doBrowse=true);
const string &getFilter();
void setFilter(const string &filter);
const std::string &getPath();
void setPath(const std::string &path, bool doBrowse=true);
const std::string &getFilter();
void setFilter(const std::string &filter);
const vector<string> &getDirectories() { return directories; }
const vector<string> &getFiles() { return files; }
void insertFile(const string &file);
void addExclude(const string &exclude);
const std::vector<std::string> &getDirectories() { return directories; }
const std::vector<std::string> &getFiles() { return files; }
void insertFile(const std::string &file);
void addExclude(const std::string &exclude);
};
#endif /*FILELISTER_H_*/
#endif // FILELISTER_H

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -86,6 +86,9 @@
//#include <pnd_discovery.h>
#endif
using namespace std;
using namespace fastdelegate;
#ifdef _CARD_ROOT
const char *CARD_ROOT = _CARD_ROOT;
#elif defined(PLATFORM_DINGUX)
@ -98,9 +101,6 @@ const int CARD_ROOT_LEN = strlen(CARD_ROOT)-1;
static GMenu2X *app;
static string gmenu2x_home;
using namespace std;
using namespace fastdelegate;
// Note: Keep this in sync with the enum!
static const char *colorNames[NUM_COLORS] = {
"topBarBg",

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -73,13 +73,9 @@ enum color {
NUM_COLORS,
};
using std::string;
using std::vector;
using fastdelegate::FastDelegate0;
typedef FastDelegate0<> MenuAction;
typedef unordered_map<string, string, hash<string> > ConfStrHash;
typedef unordered_map<string, int, hash<string> > ConfIntHash;
typedef fastdelegate::FastDelegate0<> MenuAction;
typedef std::tr1::unordered_map<std::string, std::string, std::tr1::hash<std::string> > ConfStrHash;
typedef std::tr1::unordered_map<std::string, int, std::tr1::hash<std::string> > ConfIntHash;
typedef struct {
unsigned short batt;
@ -87,7 +83,7 @@ typedef struct {
} MMSP2ADC;
struct MenuOption {
string text;
std::string text;
MenuAction action;
};
@ -95,12 +91,12 @@ class Menu;
class GMenu2X {
private:
string path; //!< Contains the working directory of GMenu2X
std::string path; //!< Contains the working directory of GMenu2X
/*!
Retrieves the free disk space on the sd
@return String containing a human readable representation of the free disk space
*/
string getDiskFree(const char *path);
std::string getDiskFree(const char *path);
unsigned short cpuX; //!< Offset for displaying cpu clock information
unsigned short volumeX; //!< Offset for displaying volume level
unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar
@ -116,7 +112,7 @@ private:
*/
unsigned short getBatteryLevel();
FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle;
void browsePath(const string &path, vector<string>* directories, vector<string>* files);
void browsePath(const std::string &path, std::vector<std::string>* directories, std::vector<std::string>* files);
/*!
Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections.
*/
@ -125,7 +121,7 @@ private:
Performs the actual scan in the given path and populates the files vector with the results. The creation of the links is not performed here.
@see scanner
*/
void scanPath(string path, vector<string> *files);
void scanPath(std::string path, std::vector<std::string> *files);
/*!
Displays a selector and launches the specified executable file
@ -137,10 +133,10 @@ private:
samba,
web;
string ip, defaultgw, lastSelectorDir;
std::string ip, defaultgw, lastSelectorDir;
int lastSelectorElement;
void readConfig();
void readConfig(string path);
void readConfig(std::string path);
void readTmp();
void initServices();
@ -174,7 +170,7 @@ public:
/* Returns the home directory of gmenu2x, usually
* ~/.gmenu2x */
static const string getHome(void);
static const std::string getHome(void);
/*
* Variables needed for elements disposition
@ -188,7 +184,7 @@ public:
@see path
@return String containing the parent directory
*/
const string &getExePath();
const std::string &getExePath();
InputManager input;
Touchscreen ts;
@ -200,17 +196,17 @@ public:
//Configuration settings
bool useSelectionPng;
void setSkin(const string &skin, bool setWallpaper = true);
void setSkin(const std::string &skin, bool setWallpaper = true);
#ifdef PLATFORM_GP2X
//firmware type and version
string fwType, fwVersion;
std::string fwType, fwVersion;
bool isF200() { return ts.initialized(); }
// Open2x settings ---------------------------------------------------------
bool o2x_usb_net_on_boot, o2x_ftp_on_boot, o2x_telnet_on_boot, o2x_gp2xjoy_on_boot, o2x_usb_host_on_boot, o2x_usb_hid_on_boot, o2x_usb_storage_on_boot;
string o2x_usb_net_ip;
std::string o2x_usb_net_ip;
int volumeMode, savedVolumeMode; // just use the const int scale values at top of source
#endif
@ -262,7 +258,7 @@ public:
void writeConfigOpen2x();
#endif
void writeSkinConfig();
void writeTmp(int selelem=-1, const string &selectordir="");
void writeTmp(int selelem=-1, const std::string &selectordir="");
void ledOn();
void ledOff();
@ -276,14 +272,14 @@ public:
void initBG();
int drawButton(Button *btn, int x=5, int y=-10);
int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height);
void drawTopBar(Surface *s=NULL);
void drawBottomBar(Surface *s=NULL);
Menu* menu;
Menu *menu;
};
#endif
#endif // GMENU2X_H

View File

@ -31,7 +31,7 @@ protected:
SurfaceCollection previews;
public:
ImageDialog(GMenu2X *gmenu2x, const std::string &text,
const std::string &filter="", const string &file="");
const std::string &filter="", const std::string &file="");
virtual ~ImageDialog();
virtual void beforeFileList();

View File

@ -24,12 +24,9 @@
#include "button.h"
#include <string>
#include <iostream>
class Surface;
using std::string;
class GMenu2X;
/**
@ -44,7 +41,7 @@ private:
protected:
GMenu2X *gmenu2x;
bool edited;
string title, description, icon, iconPath;
std::string title, description, icon, iconPath;
Surface *iconSurface;
Surface *icon_hover;
@ -62,15 +59,15 @@ public:
void setSize(int w, int h);
void setPosition(int x, int y);
const string &getTitle();
void setTitle(const string &title);
const string &getDescription();
void setDescription(const string &description);
const string &getIcon();
void setIcon(const string &icon);
virtual const string &searchIcon();
const string &getIconPath();
void setIconPath(const string &icon);
const std::string &getTitle();
void setTitle(const std::string &title);
const std::string &getDescription();
void setDescription(const std::string &description);
const std::string &getIcon();
void setIcon(const std::string &icon);
virtual const std::string &searchIcon();
const std::string &getIconPath();
void setIconPath(const std::string &icon);
virtual void run();
};

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,11 +17,8 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <fstream>
#include <sstream>
#include "linkaction.h"
using namespace std;
#include "linkaction.h"
LinkAction::LinkAction(GMenu2X *gmenu2x, LinkRunAction act)
: Link(gmenu2x) {

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,19 +17,14 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LINKACTION_H
#define LINKACTION_H
#include <string>
#include <iostream>
#include "FastDelegate.h"
#include "link.h"
using std::string;
using fastdelegate::FastDelegate0;
typedef FastDelegate0<> LinkRunAction;
typedef fastdelegate::FastDelegate0<> LinkRunAction;
class GMenu2X;
@ -47,4 +42,4 @@ public:
virtual void run();
};
#endif
#endif // LINKACTION_H

View File

@ -24,9 +24,6 @@
#include "link.h"
#include <string>
#include <iostream>
using std::string;
class GMenu2X;
class InputManager;
@ -39,69 +36,70 @@ Parses links files.
class LinkApp : public Link {
private:
InputManager &inputMgr;
string sclock, svolume;
std::string sclock, svolume;
int iclock, ivolume;
//G
string sgamma;
std::string sgamma;
//G
int igamma;
string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens;
std::string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens;
bool selectorbrowser, useRamTimings;
void drawRun();
string aliasfile;
string file;
std::string aliasfile;
std::string file;
bool wrapper;
bool dontleave;
public:
LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr, const char* linkfile);
virtual const string &searchIcon();
virtual const std::string &searchIcon();
const string &getExec();
void setExec(const string &exec);
const string &getParams();
void setParams(const string &params);
const string &getWorkdir();
void setWorkdir(const string &workdir);
const string &getManual();
void setManual(const string &manual);
const string &getSelectorDir();
void setSelectorDir(const string &selectordir);
const std::string &getExec();
void setExec(const std::string &exec);
const std::string &getParams();
void setParams(const std::string &params);
const std::string &getWorkdir();
void setWorkdir(const std::string &workdir);
const std::string &getManual();
void setManual(const std::string &manual);
const std::string &getSelectorDir();
void setSelectorDir(const std::string &selectordir);
bool getSelectorBrowser();
void setSelectorBrowser(bool value);
bool getUseRamTimings();
void setUseRamTimings(bool value);
const string &getSelectorScreens();
void setSelectorScreens(const string &selectorscreens);
const string &getSelectorFilter();
void setSelectorFilter(const string &selectorfilter);
const string &getAliasFile();
void setAliasFile(const string &aliasfile);
const std::string &getSelectorScreens();
void setSelectorScreens(const std::string &selectorscreens);
const std::string &getSelectorFilter();
void setSelectorFilter(const std::string &selectorfilter);
const std::string &getAliasFile();
void setAliasFile(const std::string &aliasfile);
int clock();
const string &clockStr(int maxClock);
const std::string &clockStr(int maxClock);
void setClock(int mhz);
int volume();
const string &volumeStr();
const std::string &volumeStr();
void setVolume(int vol);
//G
int gamma();
const string &gammaStr();
const std::string &gammaStr();
void setGamma(int gamma);
bool save();
void run();
void showManual();
void selector(int startSelection=0, const string &selectorDir="");
void launch(const string &selectedFile="", const string &selectedDir="");
void selector(int startSelection=0, const std::string &selectorDir="");
void launch(const std::string &selectedFile="",
const std::string &selectedDir="");
bool targetExists();
const string &getFile() { return file; }
void renameFile(const string &name);
const std::string &getFile() { return file; }
void renameFile(const std::string &name);
bool &needsWrapperRef() { return wrapper; }
bool &runsInBackgroundRef() { return dontleave; }
};

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -74,7 +74,7 @@ void Menu::readSections(std::string parentDir)
if (statret != -1) {
if (find(sections.begin(), sections.end(), (string)dptr->d_name) == sections.end()) {
sections.push_back((string)dptr->d_name);
linklist ll;
vector<Link*> ll;
links.push_back(ll);
}
}
@ -114,12 +114,12 @@ void Menu::loadIcons() {
SECTION MANAGEMENT
====================================*/
void Menu::freeLinks() {
for (vector<linklist>::iterator section = links.begin(); section<links.end(); section++)
for (linklist::iterator link = section->begin(); link<section->end(); link++)
for (vector< vector<Link*> >::iterator section = links.begin(); section<links.end(); section++)
for (vector<Link*>::iterator link = section->begin(); link<section->end(); link++)
delete *link;
}
linklist *Menu::sectionLinks(int i) {
vector<Link*> *Menu::sectionLinks(int i) {
if (i<0 || i>(int)links.size())
i = selSectionIndex();
@ -305,7 +305,7 @@ bool Menu::addSection(const string &sectionName) {
sectiondir = sectiondir + "/" + sectionName;
if (mkdir(sectiondir.c_str(), 0755) == 0) {
sections.push_back(sectionName);
linklist ll;
vector<Link*> ll;
links.push_back(ll);
return true;
}
@ -324,9 +324,9 @@ void Menu::deleteSelectedLink()
sectionLinks()->erase( sectionLinks()->begin() + selLinkIndex() );
setLinkIndex(selLinkIndex());
for (vector<linklist>::iterator section = links.begin();
for (vector< vector<Link*> >::iterator section = links.begin();
!icon_used && section<links.end(); section++)
for (linklist::iterator link = section->begin();
for (vector<Link*>::iterator link = section->begin();
!icon_used && link<section->end(); link++)
icon_used = !iconpath.compare((*link)->getIconPath());

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,21 +17,18 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef MENU_H
#define MENU_H
#include <string>
#include <vector>
#include "linkaction.h"
using std::string;
using std::vector;
#include <string>
#include <vector>
class LinkApp;
class GMenu2X;
typedef vector<Link*> linklist;
/**
Handles the menu structure
@ -42,8 +39,8 @@ private:
GMenu2X *gmenu2x;
int iSection, iLink;
uint iFirstDispSection, iFirstDispRow;
vector<string> sections;
vector<linklist> links;
std::vector<std::string> sections;
std::vector< std::vector<Link*> > links;
void readLinks();
void freeLinks();
@ -58,19 +55,21 @@ public:
Menu(GMenu2X *gmenu2x);
~Menu();
linklist *sectionLinks(int i = -1);
std::vector<Link*> *sectionLinks(int i = -1);
int selSectionIndex();
const string &selSection();
const std::string &selSection();
void decSectionIndex();
void incSectionIndex();
void setSectionIndex(int i);
uint firstDispSection();
uint firstDispRow();
bool addActionLink(uint section, const string &title, LinkRunAction action, const string &description="", const string &icon="");
bool addLink(string path, string file, string section="");
bool addSection(const string &sectionName);
bool addActionLink(uint section, const std::string &title,
LinkRunAction action, const std::string &description="",
const std::string &icon="");
bool addLink(std::string path, std::string file, std::string section="");
bool addSection(const std::string &sectionName);
void deleteSelectedLink();
void deleteSelectedSection();
@ -86,8 +85,8 @@ public:
void linkDown();
void setLinkIndex(int i);
const vector<string> &getSections() { return sections; }
void renameSection(int index, const string &name);
const std::vector<std::string> &getSections() { return sections; }
void renameSection(int index, const std::string &name);
};
#endif
#endif // MENU_H

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,10 +17,14 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "menusetting.h"
#include "asfont.h"
#include "gmenu2x.h"
using std::string;
MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name,
const string &description)
: gmenu2x(gmenu2x)

View File

@ -35,6 +35,7 @@
#include "debug.h"
using namespace std;
using std::tr1::unordered_map;
#define SELECTOR_ELEMENTS 11

View File

@ -29,9 +29,6 @@
class LinkApp;
class FileLister;
using std::string;
using std::vector;
class Selector : protected Dialog {
private:
int selRow;
@ -40,7 +37,7 @@ private:
std::tr1::unordered_map<std::string, std::string> aliases;
void loadAliases();
string getAlias(const std::string &key);
std::string getAlias(const std::string &key);
void prepare(FileLister *fl, std::vector<std::string> *screens,
std::vector<std::string> *titles);
void freeScreenshots(std::vector<std::string> *screens);

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -19,14 +19,16 @@
***************************************************************************/
#include "surface.h"
#include "imageio.h"
#include "utilities.h"
#include "debug.h"
#include "imageio.h"
#include "surfacecollection.h"
#include "utilities.h"
#include <SDL_gfxPrimitives.h>
#include <iostream>
using namespace std;
RGBAColor strtorgba(const string &strColor) {

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,21 +17,20 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SURFACE_H
#define SURFACE_H
#include <SDL.h>
#include <string>
#include "asfont.h"
using std::string;
#include <SDL.h>
#include <string>
struct RGBAColor {
unsigned short r,g,b,a;
};
RGBAColor strtorgba(const string &strColor);
RGBAColor strtorgba(const std::string &strColor);
/**
Wrapper around SDL_Surface
@ -41,7 +40,8 @@ class Surface {
public:
static Surface *openOutputSurface(int width, int height, int bitsperpixel);
static Surface *emptySurface(int width, int height);
static Surface *loadImage(const string &img, const string &skin="");
static Surface *loadImage(const std::string &img,
const std::string &skin="");
Surface(Surface *s);
~Surface();
@ -66,7 +66,9 @@ public:
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 string &text, int x, int y, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop) {
void write(ASFont *font, const std::string &text, int x, int y,
ASFont::HAlign halign = ASFont::HAlignLeft,
ASFont::VAlign valign = ASFont::VAlignTop) {
font->write(this, text, x, y, halign, valign);
}

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,16 +18,18 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "translator.h"
#include "debug.h"
#include "gmenu2x.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdarg.h>
#include "translator.h"
#include "debug.h"
#include "gmenu2x.h"
using namespace std;
using std::tr1::unordered_map;
Translator::Translator(const string &lang) {
_lang = "";

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* Copyright (C) 2006 by Massimiliano Torromeo *
* massimiliano.torromeo@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,10 +17,12 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef TRANSLATOR_H
#define TRANSLATOR_H
#include "utilities.h"
#include <string>
#include <tr1/unordered_map>
/**
Hash Map of translation strings.
@ -29,18 +31,19 @@ Hash Map of translation strings.
*/
class Translator {
private:
string _lang;
unordered_map<string, string> translations;
std::string _lang;
std::tr1::unordered_map<std::string, std::string> translations;
public:
Translator(const string &lang="");
Translator(const std::string &lang="");
~Translator();
string lang();
void setLang(const string &lang);
bool exists(const string &term);
string translate(const string &term,const char *replacestr=NULL,...);
string operator[](const string &term);
std::string lang();
void setLang(const std::string &lang);
bool exists(const std::string &term);
std::string translate(const std::string &term,
const char *replacestr = NULL, ...);
std::string operator[](const std::string &term);
};
#endif
#endif // TRANSLATOR_H

View File

@ -23,39 +23,35 @@
#include <string>
#include <vector>
#include <tr1/unordered_map>
using std::tr1::unordered_map;
using std::tr1::hash;
using std::string;
using std::vector;
class case_less {
public:
bool operator()(const string &left, const string &right) const;
bool operator()(const std::string &left, const std::string &right) const;
};
string trim(const string& s);
string strreplace (string orig, const string &search, const string &replace);
string cmdclean (string cmdline);
std::string trim(const std::string& s);
std::string strreplace (std::string orig, const std::string &search, const std::string &replace);
std::string cmdclean (std::string cmdline);
char *string_copy(const string &);
void string_copy(const string &, char **);
char *string_copy(const std::string &);
void string_copy(const std::string &, char **);
bool fileExists(const string &file);
bool rmtree(string path);
bool fileExists(const std::string &file);
bool rmtree(std::string path);
int max (int a, int b);
int min (int a, int b);
int constrain (int x, int imin, int imax);
int max(int a, int b);
int min(int a, int b);
int constrain(int x, int imin, int imax);
int evalIntConf (int val, int def, int imin, int imax);
int evalIntConf (int *val, int def, int imin, int imax);
const string &evalStrConf (const string &val, const string &def);
const string &evalStrConf (string *val, const string &def);
int evalIntConf(int val, int def, int imin, int imax);
int evalIntConf(int *val, int def, int imin, int imax);
const std::string &evalStrConf(const std::string &val, const std::string &def);
const std::string &evalStrConf(std::string *val, const std::string &def);
bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true);
bool split(std::vector<std::string> &vec, const std::string &str,
const std::string &delim, bool destructive=true);
int intTransition(int from, int to, long int tickStart, long duration=500, long tickNow=-1);
int intTransition(int from, int to, long int tickStart, long duration=500,
long tickNow=-1);
#endif
#endif // UTILITIES_H