Date:2010-05-02 14:29:09 (13 years 7 months ago)
Author:Lars C.
Commit:40a26e1a9cc74364dc7f7ee51a8c24e903606a95
Message:pass strings by reference where possible

Files: src/asfont.cpp (1 diff)
src/asfont.h (1 diff)
src/dirdialog.cpp (1 diff)
src/dirdialog.h (1 diff)
src/filedialog.cpp (2 diffs)
src/filedialog.h (1 diff)
src/filelister.cpp (1 diff)
src/filelister.h (2 diffs)
src/gmenu2x.cpp (7 diffs)
src/gmenu2x.h (5 diffs)
src/iconbutton.cpp (3 diffs)
src/iconbutton.h (2 diffs)
src/imagedialog.cpp (1 diff)
src/imagedialog.h (1 diff)
src/inputdialog.cpp (1 diff)
src/inputdialog.h (1 diff)
src/inputmanager.cpp (1 diff)
src/inputmanager.h (1 diff)
src/link.cpp (1 diff)
src/link.h (1 diff)
src/linkapp.cpp (10 diffs)
src/linkapp.h (2 diffs)
src/listview.cpp (1 diff)
src/listview.h (1 diff)
src/listviewitem.cpp (1 diff)
src/listviewitem.h (1 diff)
src/menu.cpp (5 diffs)
src/menu.h (1 diff)
src/menusetting.cpp (1 diff)
src/menusetting.h (1 diff)
src/menusettingbool.cpp (2 diffs)
src/menusettingbool.h (1 diff)
src/menusettingdir.cpp (2 diffs)
src/menusettingdir.h (2 diffs)
src/menusettingfile.cpp (2 diffs)
src/menusettingfile.h (2 diffs)
src/menusettingimage.cpp (3 diffs)
src/menusettingimage.h (1 diff)
src/menusettingint.cpp (1 diff)
src/menusettingint.h (1 diff)
src/menusettingmultistring.cpp (1 diff)
src/menusettingmultistring.h (1 diff)
src/menusettingrgba.cpp (1 diff)
src/menusettingrgba.h (1 diff)
src/menusettingstring.cpp (2 diffs)
src/menusettingstring.h (2 diffs)
src/messagebox.cpp (1 diff)
src/messagebox.h (1 diff)
src/selector.cpp (2 diffs)
src/selector.h (1 diff)
src/selectordetector.cpp (2 diffs)
src/selectordetector.h (2 diffs)
src/settingsdialog.cpp (1 diff)
src/settingsdialog.h (1 diff)
src/sfontplus.cpp (5 diffs)
src/sfontplus.h (1 diff)
src/surface.cpp (6 diffs)
src/surface.h (4 diffs)
src/surfacecollection.cpp (7 diffs)
src/surfacecollection.h (1 diff)
src/textdialog.cpp (1 diff)
src/textdialog.h (1 diff)
src/textmanualdialog.cpp (1 diff)
src/textmanualdialog.h (1 diff)
src/translator.cpp (4 diffs)
src/translator.h (1 diff)
src/utilities.cpp (4 diffs)
src/utilities.h (2 diffs)

Change Details

src/asfont.cpp
1818    halfLineHeight = getLineHeight()/2;
1919}
2020
21ASFont::ASFont(string font) {
21ASFont::ASFont(const string &font) {
2222    this->font.initFont(font);
2323    halfHeight = getHeight()/2;
2424    halfLineHeight = getLineHeight()/2;
src/asfont.h
2424public:
2525    ASFont(SDL_Surface* font);
2626    ASFont(Surface* font);
27    ASFont(string font);
27    ASFont(const string &font);
2828    ~ASFont();
2929
3030    bool utf8Code(unsigned char c);
src/dirdialog.cpp
3333using namespace std;
3434using namespace fastdelegate;
3535
36DirDialog::DirDialog(GMenu2X *gmenu2x, string text, string dir) {
36DirDialog::DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir) {
3737    this->gmenu2x = gmenu2x;
3838    this->text = text;
3939    selRow = 0;
src/dirdialog.h
5656
5757public:
5858    string path;
59    DirDialog(GMenu2X *gmenu2x, string text, string dir="");
59    DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir="");
6060
6161    bool exec();
6262};
src/filedialog.cpp
3030
3131using namespace std;
3232
33FileDialog::FileDialog(GMenu2X *gmenu2x, string text, string filter, string file) {
33FileDialog::FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter, const string &file) {
3434    this->gmenu2x = gmenu2x;
3535    this->text = text;
3636    this->filter = filter;
...... 
176176    return result;
177177}
178178
179void FileDialog::setPath(string path) {
179void FileDialog::setPath(const string &path) {
180180    path_v = path;
181181    fl.setPath(path);
182182    selected = 0;
src/filedialog.h
5151
5252public:
5353    string file;
54    FileDialog(GMenu2X *gmenu2x, string text, string filter="", string file="");
54    FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", const string &file="");
5555    virtual ~FileDialog() {};
5656
57    virtual string path() { return path_v; };
58    virtual void setPath(string path);
57    virtual const string &path() { return path_v; };
58    virtual void setPath(const string &path);
5959
6060    inline virtual void beforeFileList();
6161    inline virtual void onChangeDir();
src/filelister.cpp
3030
3131using namespace std;
3232
33FileLister::FileLister(string startPath, bool showDirectories, bool showFiles) {
33FileLister::FileLister(const string &startPath, bool showDirectories, bool showFiles) {
3434    this->showDirectories = showDirectories;
3535    this->showFiles = showFiles;
3636    setPath(startPath,false);
3737}
3838
39string FileLister::getPath() {
39const string &FileLister::getPath() {
4040    return path;
4141}
42void FileLister::setPath(string path, bool doBrowse) {
43    if (path[path.length()-1]!='/') path += "/";
42void FileLister::setPath(const string &path, bool doBrowse) {
4443    this->path = path;
44    if (this->path[path.length()-1]!='/')
45        this->path += "/";
4546    if (doBrowse)
4647        browse();
4748}
4849
49string FileLister::getFilter() {
50const string &FileLister::getFilter() {
5051    return filter;
5152}
52void FileLister::setFilter(string filter) {
53void FileLister::setFilter(const string &filter) {
5354    this->filter = filter;
5455}
5556
src/filelister.h
3333    bool showDirectories, showFiles;
3434
3535public:
36    FileLister(string startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
36    FileLister(const string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
3737    void browse();
3838
3939    vector<string> directories, files, exclude;
...... 
4545    bool isFile(uint);
4646    bool isDirectory(uint);
4747
48    string getPath();
49    void setPath(string path, bool doBrowse=true);
50    string getFilter();
51    void setFilter(string filter);
48    const string &getPath();
49    void setPath(const string &path, bool doBrowse=true);
50    const string &getFilter();
51    void setFilter(const string &filter);
5252};
5353
5454#endif /*FILELISTER_H_*/
src/gmenu2x.cpp
695695    }
696696}
697697
698void GMenu2X::writeTmp(int selelem, string selectordir) {
698void GMenu2X::writeTmp(int selelem, const string &selectordir) {
699699    string conffile = "/tmp/gmenu2x.tmp";
700700    ofstream inf(conffile.c_str());
701701    if (inf.is_open()) {
...... 
11221122#endif
11231123}
11241124
1125void GMenu2X::setSkin(string skin, bool setWallpaper) {
1125void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
11261126    confStr["skin"] = skin;
11271127
11281128    //Clear previous skin settings
...... 
18471847    return currentscalefactor;
18481848}
18491849
1850string GMenu2X::getExePath() {
1850const string &GMenu2X::getExePath() {
18511851    if (path.empty()) {
18521852        char buf[255];
18531853        int l = readlink("/proc/self/exe",buf,255);
...... 
18821882    return x+btn->getRect().w+6;
18831883}
18841884
1885int GMenu2X::drawButton(Surface *s, string btn, string text, int x, int y) {
1885int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x, int y) {
18861886    if (y<0) y = resY+y;
18871887    SDL_Rect re = {x, y-7, 0, 16};
18881888    if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
...... 
18941894    return x+re.w+6;
18951895}
18961896
1897int GMenu2X::drawButtonRight(Surface *s, string btn, string text, int x, int y) {
1897int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text, int x, int y) {
18981898    if (y<0) y = resY+y;
18991899    if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
19001900        x -= 16;
...... 
19231923    s->box(resX-6, by, 3, bs, skinConfColors["selectionBg"]);
19241924}
19251925
1926void GMenu2X::drawTitleIcon(string icon, bool skinRes, Surface *s) {
1926void GMenu2X::drawTitleIcon(const string &icon, bool skinRes, Surface *s) {
19271927    if (s==NULL) s = this->s;
19281928
19291929    Surface *i = NULL;
...... 
19401940    i->blit(s,4,(skinConfInt["topBarHeight"]-32)/2);
19411941}
19421942
1943void GMenu2X::writeTitle(string title, Surface *s) {
1943void GMenu2X::writeTitle(const string &title, Surface *s) {
19441944    if (s==NULL) s = this->s;
19451945    s->write(font,title,40, skinConfInt["topBarHeight"]/4, SFontHAlignLeft, SFontVAlignMiddle);
19461946}
19471947
1948void GMenu2X::writeSubTitle(string subtitle, Surface *s) {
1948void GMenu2X::writeSubTitle(const string &subtitle, Surface *s) {
19491949    if (s==NULL) s = this->s;
19501950    s->write(font,subtitle,40, skinConfInt["topBarHeight"]/4*3, SFontHAlignLeft, SFontVAlignMiddle);
19511951}
src/gmenu2x.h
8585    */
8686    unsigned short getBatteryLevel();
8787    FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle;
88    void browsePath(string path, vector<string>* directories, vector<string>* files);
88    void browsePath(const string &path, vector<string>* directories, vector<string>* files);
8989    /*!
9090    Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections.
9191    */
...... 
146146    @see path
147147    @return String containing the parent directory
148148    */
149    string getExePath();
149    const string &getExePath();
150150
151151    InputManager input;
152152    Touchscreen ts;
...... 
158158
159159    //Configuration settings
160160    bool useSelectionPng;
161    void setSkin(string skin, bool setWallpaper = true);
161    void setSkin(const string &skin, bool setWallpaper = true);
162162    //firmware type and version
163163    string fwType, fwVersion;
164164    //gp2x type
...... 
212212    void writeConfig();
213213    void writeConfigOpen2x();
214214    void writeSkinConfig();
215    void writeTmp(int selelem=-1, string selectordir="");
215    void writeTmp(int selelem=-1, const string &selectordir="");
216216
217217    void ledOn();
218218    void ledOff();
...... 
226226
227227    void initBG();
228228    int drawButton(IconButton *btn, int x=5, int y=-10);
229    int drawButton(Surface *s, string btn, string text, int x=5, int y=-10);
230    int drawButtonRight(Surface *s, string btn, string text, int x=5, int y=-10);
229    int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
230    int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
231231    void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height);
232232
233    void drawTitleIcon(string icon, bool skinRes=true, Surface *s=NULL);
234    void writeTitle(string title, Surface *s=NULL);
235    void writeSubTitle(string subtitle, Surface *s=NULL);
233    void drawTitleIcon(const string &icon, bool skinRes=true, Surface *s=NULL);
234    void writeTitle(const string &title, Surface *s=NULL);
235    void writeSubTitle(const string &subtitle, Surface *s=NULL);
236236    void drawTopBar(Surface *s=NULL);
237237    void drawBottomBar(Surface *s=NULL);
238238
src/iconbutton.cpp
44using namespace std;
55using namespace fastdelegate;
66
7IconButton::IconButton(GMenu2X *gmenu2x, string icon, string label) : Button(gmenu2x) {
7IconButton::IconButton(GMenu2X *gmenu2x, const string &icon, const string &label) : Button(gmenu2x) {
88    this->gmenu2x = gmenu2x;
99    this->icon = icon;
1010    labelPosition = IconButton::DISP_RIGHT;
...... 
9393    setSize(w, h);
9494}
9595
96string IconButton::getLabel() {
96const string &IconButton::getLabel() {
9797    return label;
9898}
9999
100void IconButton::setLabel(string label) {
100void IconButton::setLabel(const string &label) {
101101    this->label = label;
102102}
103103
...... 
107107    recalcSize();
108108}
109109
110string IconButton::getIcon() {
110const string &IconButton::getIcon() {
111111    return icon;
112112}
113113
114void IconButton::setIcon(string icon) {
114void IconButton::setIcon(const string &icon) {
115115    this->icon = icon;
116116    recalcSize();
117117}
src/iconbutton.h
2222    static const int DISP_TOP = 2;
2323    static const int DISP_BOTTOM = 3;
2424
25    IconButton(GMenu2X *gmenu2x, string icon, string label="");
25    IconButton(GMenu2X *gmenu2x, const string &icon, const string &label="");
2626    virtual ~IconButton() {};
2727
2828    virtual void paint();
...... 
3030
3131    void setPosition(int x, int y);
3232
33    string getLabel();
34    void setLabel(string label);
33    const string &getLabel();
34    void setLabel(const string &label);
3535    void setLabelPosition(int pos, int margin);
3636
37    string getIcon();
38    void setIcon(string icon);
37    const string &getIcon();
38    void setIcon(const string &icon);
3939
4040    void setAction(ButtonAction action);
4141};
src/imagedialog.cpp
3131
3232using namespace std;
3333
34ImageDialog::ImageDialog(GMenu2X *gmenu2x, string text, string filter, string file) : FileDialog(gmenu2x, text, filter, file) {
34ImageDialog::ImageDialog(GMenu2X *gmenu2x, const string &text, const string &filter, const string &file) : FileDialog(gmenu2x, text, filter, file) {
3535    this->gmenu2x = gmenu2x;
3636    this->text = text;
3737    this->filter = filter;
38    this->file = "";
3938    setPath("/card");
4039    title = "Image Browser";
4140    if (!file.empty()) {
42        file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/");
43        string::size_type pos = file.rfind("/");
41        this->file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/");
42        string::size_type pos = this->file.rfind("/");
4443        if (pos != string::npos) {
45            setPath( file.substr(0, pos) );
44            setPath( this->file.substr(0, pos) );
4645            cout << "ib: " << path() << endl;
47            this->file = file.substr(pos+1,file.length());
46            this->file = this->file.substr(pos+1,file.length());
4847        }
4948    }
5049    selRow = 0;
src/imagedialog.h
3131protected:
3232    SurfaceCollection previews;
3333public:
34    ImageDialog(GMenu2X *gmenu2x, string text, string filter="", string file="");
34    ImageDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", const string &file="");
3535    virtual ~ImageDialog();
3636    inline virtual void beforeFileList();
3737    inline virtual void onChangeDir();
src/inputdialog.cpp
2626using namespace std;
2727using namespace fastdelegate;
2828
29InputDialog::InputDialog(GMenu2X *gmenu2x, string text, string startvalue, string title, string icon) {
29InputDialog::InputDialog(GMenu2X *gmenu2x, const string &text, const string &startvalue, const string &title, const string &icon) {
3030    this->gmenu2x = gmenu2x;
3131    if (title=="") {
3232        this->title = text;
src/inputdialog.h
6767    void setKeyboard(int);
6868
6969public:
70    InputDialog(GMenu2X *gmenu2x, string text, string startvalue="", string title="", string icon="");
70    InputDialog(GMenu2X *gmenu2x, const string &text, const string &startvalue="", const string &title="", const string &icon="");
7171
7272    string input;
7373    bool exec();
src/inputmanager.cpp
3434            SDL_JoystickClose(joysticks[x]);
3535}
3636
37void InputManager::init(string conffile) {
37void InputManager::init(const string &conffile) {
3838    SDL_JoystickEventState(SDL_IGNORE);
3939
4040    int numJoy = SDL_NumJoysticks();
src/inputmanager.h
7272
7373    InputManager();
7474    ~InputManager();
75    void init(string conffile = "input.conf");
75    void init(const string &conffile = "input.conf");
7676
7777    vector <SDL_Joystick*> joysticks;
7878    vector<bool> actions;
src/link.cpp
5757    iconSurface = gmenu2x->sc[getIconPath()];
5858}
5959
60string Link::getTitle() {
60const string &Link::getTitle() {
6161    return title;
6262}
6363
64void Link::setTitle(string title) {
64void Link::setTitle(const string &title) {
6565    this->title = title;
6666    edited = true;
6767}
6868
69string Link::getDescription() {
69const string &Link::getDescription() {
7070    return description;
7171}
7272
73void Link::setDescription(string description) {
73void Link::setDescription(const string &description) {
7474    this->description = description;
7575    edited = true;
7676}
7777
78string Link::getIcon() {
78const string &Link::getIcon() {
7979    return icon;
8080}
8181
82void Link::setIcon(string icon) {
82void Link::setIcon(const string &icon) {
8383    string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
84
8485    if (icon.substr(0,skinpath.length()) == skinpath) {
8586        string tempIcon = icon.substr(skinpath.length(), icon.length());
8687        string::size_type pos = tempIcon.find("/");
8788        if (pos != string::npos)
88            icon = "skin:"+tempIcon.substr(pos+1,icon.length());
89            this->icon = "skin:"+tempIcon.substr(pos+1,icon.length());
90        else
91            this->icon = icon;
92    } else {
93        this->icon = icon;
8994    }
9095
91    iconPath = strreplace(icon,"skin:",skinpath+"/");
96    iconPath = strreplace(this->icon,"skin:",skinpath+"/");
9297    if (iconPath.empty() || !fileExists(iconPath)) {
93        iconPath = strreplace(icon,"skin:",gmenu2x->getExePath()+"skins/Default/");
98        iconPath = strreplace(this->icon,"skin:",gmenu2x->getExePath()+"skins/Default/");
9499        if (!fileExists(iconPath)) searchIcon();
95100    }
96101
97    this->icon = icon;
98102    edited = true;
99103    updateSurfaces();
100104}
101105
102string Link::searchIcon() {
106const string &Link::searchIcon() {
103107    iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
104108    return iconPath;
105109}
106110
107string Link::getIconPath() {
111const string &Link::getIconPath() {
108112    if (iconPath.empty()) searchIcon();
109113    return iconPath;
110114}
111115
112void Link::setIconPath(string icon) {
116void Link::setIconPath(const string &icon) {
113117    if (fileExists(icon))
114118        iconPath = icon;
115119    else
src/link.h
5959    void setSize(int w, int h);
6060    void setPosition(int x, int y);
6161
62    string getTitle();
63    void setTitle(string title);
64    string getDescription();
65    void setDescription(string description);
66    string getIcon();
67    void setIcon(string icon);
68    virtual string searchIcon();
69    string getIconPath();
70    void setIconPath(string icon);
62    const string &getTitle();
63    void setTitle(const string &title);
64    const string &getDescription();
65    void setDescription(const string &description);
66    const string &getIcon();
67    void setIcon(const string &icon);
68    virtual const string &searchIcon();
69    const string &getIconPath();
70    void setIconPath(const string &icon);
7171
7272    virtual void run();
7373};
src/linkapp.cpp
109109    edited = false;
110110}
111111
112string LinkApp::searchIcon() {
112const string &LinkApp::searchIcon() {
113113    string execicon = exec;
114114    string::size_type pos = exec.rfind(".");
115115    if (pos != string::npos) execicon = exec.substr(0,pos);
...... 
133133    return iclock;
134134}
135135
136string LinkApp::clockStr(int maxClock) {
136const string &LinkApp::clockStr(int maxClock) {
137137    if (iclock>maxClock) setClock(maxClock);
138138    return sclock;
139139}
...... 
152152    return ivolume;
153153}
154154
155string LinkApp::volumeStr() {
155const string &LinkApp::volumeStr() {
156156    return svolume;
157157}
158158
...... 
174174    return ibacklight;
175175}
176176
177string LinkApp::backlightStr()
177const string &LinkApp::backlightStr()
178178{
179179    return sbacklight;
180180}
...... 
194194    return igamma;
195195}
196196
197string LinkApp::gammaStr() {
197const string &LinkApp::gammaStr() {
198198    return sgamma;
199199}
200200
...... 
372372    }
373373}
374374
375void LinkApp::selector(int startSelection, string selectorDir) {
375void LinkApp::selector(int startSelection, const string &selectorDir) {
376376    //Run selector interface
377377    Selector sel(gmenu2x, this, selectorDir);
378378    int selection = sel.exec(startSelection);
...... 
382382    }
383383}
384384
385void LinkApp::launch(string selectedFile, string selectedDir) {
385void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
386386    drawRun();
387387    save();
388388#ifndef TARGET_GP2X
...... 
405405    //selectedFile
406406    if (selectedFile!="") {
407407        string selectedFileExtension;
408        string selectedFileName;
409        string dir;
408410        string::size_type i = selectedFile.rfind(".");
409411        if (i != string::npos) {
410412            selectedFileExtension = selectedFile.substr(i,selectedFile.length());
411            selectedFile = selectedFile.substr(0,i);
413            selectedFileName = selectedFile.substr(0,i);
412414        }
413415
414416        if (selectedDir=="")
415            selectedDir = getSelectorDir();
417            dir = getSelectorDir();
418        else
419            dir = selectedDir;
416420        if (params=="") {
417            params = cmdclean(selectedDir+selectedFile+selectedFileExtension);
421            params = cmdclean(dir+selectedFile);
418422        } else {
419423            string origParams = params;
420            params = strreplace(params,"[selFullPath]",cmdclean(selectedDir+selectedFile+selectedFileExtension));
421            params = strreplace(params,"[selPath]",cmdclean(selectedDir));
422            params = strreplace(params,"[selFile]",cmdclean(selectedFile));
424            params = strreplace(params,"[selFullPath]",cmdclean(dir+selectedFile));
425            params = strreplace(params,"[selPath]",cmdclean(dir));
426            params = strreplace(params,"[selFile]",cmdclean(selectedFileName));
423427            params = strreplace(params,"[selExt]",cmdclean(selectedFileExtension));
424            if (params == origParams) params += " " + cmdclean(selectedDir+selectedFile+selectedFileExtension);
428            if (params == origParams) params += " " + cmdclean(dir+selectedFile);
425429        }
426430    }
427431
...... 
480484    chdir(gmenu2x->getExePath().c_str());
481485}
482486
483string LinkApp::getExec() {
487const string &LinkApp::getExec() {
484488    return exec;
485489}
486490
487void LinkApp::setExec(string exec) {
491void LinkApp::setExec(const string &exec) {
488492    this->exec = exec;
489493    edited = true;
490494}
491495
492string LinkApp::getParams() {
496const string &LinkApp::getParams() {
493497    return params;
494498}
495499
496void LinkApp::setParams(string params) {
500void LinkApp::setParams(const string &params) {
497501    this->params = params;
498502    edited = true;
499503}
500504
501string LinkApp::getWorkdir() {
505const string &LinkApp::getWorkdir() {
502506    return workdir;
503507}
504508
505void LinkApp::setWorkdir(string workdir) {
509void LinkApp::setWorkdir(const string &workdir) {
506510    this->workdir = workdir;
507511    edited = true;
508512}
509513
510string LinkApp::getManual() {
514const string &LinkApp::getManual() {
511515    return manual;
512516}
513517
514void LinkApp::setManual(string manual) {
518void LinkApp::setManual(const string &manual) {
515519    this->manual = manual;
516520    edited = true;
517521}
518522
519string LinkApp::getSelectorDir() {
523const string &LinkApp::getSelectorDir() {
520524    return selectordir;
521525}
522526
523void LinkApp::setSelectorDir(string selectordir) {
524    if (selectordir!="" && selectordir[selectordir.length()-1]!='/') selectordir += "/";
527void LinkApp::setSelectorDir(const string &selectordir) {
525528    this->selectordir = selectordir;
529    if (this->selectordir!="" && this->selectordir[this->selectordir.length()-1]!='/') this->selectordir += "/";
526530    edited = true;
527531}
528532
...... 
544548    edited = true;
545549}
546550
547string LinkApp::getSelectorFilter() {
551const string &LinkApp::getSelectorFilter() {
548552    return selectorfilter;
549553}
550554
551void LinkApp::setSelectorFilter(string selectorfilter) {
555void LinkApp::setSelectorFilter(const string &selectorfilter) {
552556    this->selectorfilter = selectorfilter;
553557    edited = true;
554558}
555559
556string LinkApp::getSelectorScreens() {
560const string &LinkApp::getSelectorScreens() {
557561    return selectorscreens;
558562}
559563
560void LinkApp::setSelectorScreens(string selectorscreens) {
564void LinkApp::setSelectorScreens(const string &selectorscreens) {
561565    this->selectorscreens = selectorscreens;
562566    edited = true;
563567}
564568
565string LinkApp::getAliasFile() {
569const string &LinkApp::getAliasFile() {
566570    return aliasfile;
567571}
568572
569void LinkApp::setAliasFile(string aliasfile) {
573void LinkApp::setAliasFile(const string &aliasfile) {
570574    if (fileExists(aliasfile)) {
571575        this->aliasfile = aliasfile;
572576        edited = true;
src/linkapp.h
5252
5353public:
5454    LinkApp(GMenu2X *gmenu2x, const char* linkfile);
55    virtual string searchIcon();
56
57    string getExec();
58    void setExec(string exec);
59    string getParams();
60    void setParams(string params);
61    string getWorkdir();
62    void setWorkdir(string workdir);
63    string getManual();
64    void setManual(string manual);
65    string getSelectorDir();
66    void setSelectorDir(string selectordir);
55    virtual const string &searchIcon();
56
57    const string &getExec();
58    void setExec(const string &exec);
59    const string &getParams();
60    void setParams(const string &params);
61    const string &getWorkdir();
62    void setWorkdir(const string &workdir);
63    const string &getManual();
64    void setManual(const string &manual);
65    const string &getSelectorDir();
66    void setSelectorDir(const string &selectordir);
6767    bool getSelectorBrowser();
6868    void setSelectorBrowser(bool value);
6969    bool getUseRamTimings();
7070    void setUseRamTimings(bool value);
71    string getSelectorScreens();
72    void setSelectorScreens(string selectorscreens);
73    string getSelectorFilter();
74    void setSelectorFilter(string selectorfilter);
75    string getAliasFile();
76    void setAliasFile(string aliasfile);
71    const string &getSelectorScreens();
72    void setSelectorScreens(const string &selectorscreens);
73    const string &getSelectorFilter();
74    void setSelectorFilter(const string &selectorfilter);
75    const string &getAliasFile();
76    void setAliasFile(const string &aliasfile);
7777
7878    string file;
7979
8080    int clock();
81    string clockStr(int maxClock);
81    const string &clockStr(int maxClock);
8282    void setClock(int mhz);
8383
8484    int volume();
85    string volumeStr();
85    const string &volumeStr();
8686    void setVolume(int vol);
8787
8888//G
8989    int gamma();
90    string gammaStr();
90    const string &gammaStr();
9191    void setGamma(int gamma);
9292
9393    int backlight();
94    string backlightStr();
94    const string &backlightStr();
9595    void setBacklight(int val);
9696// /G
9797
...... 
101101    bool save();
102102    void run();
103103    void showManual();
104    void selector(int startSelection=0, string selectorDir="");
105    void launch(string selectedFile="", string selectedDir="");
104    void selector(int startSelection=0, const string &selectorDir="");
105    void launch(const string &selectedFile="", const string &selectedDir="");
106106    bool targetExists();
107107};
108108
src/listview.cpp
1313    return item;
1414}
1515
16ListViewItem * ListView::add(string text) {
16ListViewItem * ListView::add(const string &text) {
1717    ListViewItem *item = new ListViewItem(this,text);
1818    return add(item);
1919}
src/listview.h
4141    GMenu2X *gmenu2x;
4242
4343    ListViewItem *add(ListViewItem *item);
44    ListViewItem *add(string text);
44    ListViewItem *add(const string &text);
4545    void del(ListViewItem *item);
4646    void del(int itemIndex);
4747    void clear();
src/listviewitem.cpp
11#include "listview.h"
22#include "listviewitem.h"
33
4ListViewItem::ListViewItem(ListView * parent, string text) {
4ListViewItem::ListViewItem(ListView * parent, const string &text) {
55    this->parent = parent;
66    rect.h = 16;
77    rect.w = parent->getWidth();
src/listviewitem.h
3232    SDL_Rect rect;
3333
3434public:
35    ListViewItem(ListView *parent, string text);
35    ListViewItem(ListView *parent, const string &text);
3636    virtual ~ListViewItem();
3737
3838    string text;
src/menu.cpp
133133    return iSection;
134134}
135135
136string Menu::selSection() {
136const string &Menu::selSection() {
137137    return sections[iSection];
138138}
139139
...... 
161161/*====================================
162162   LINKS MANAGEMENT
163163  ====================================*/
164bool Menu::addActionLink(uint section, string title, LinkRunAction action, string description, string icon) {
164bool Menu::addActionLink(uint section, const string &title, const LinkRunAction &action, const string &description, const string &icon) {
165165    if (section>=sections.size()) return false;
166166
167167    LinkAction *linkact = new LinkAction(gmenu2x,action);
...... 
183183        if (!addSection(section))
184184            return false;
185185    }
186    if (path[path.length()-1]!='/') path += "/";
187186
188187    //if the extension is not equal to gpu or dge then enable the wrapepr by default
189188    bool wrapper = false, pxml = false;
...... 
213212    cout << "\033[0;34mGMENU2X:\033[0m Adding link: " << linkpath << endl;
214213#endif
215214
215    if (path[path.length()-1]!='/') path += "/";
216216    //search for a manual
217217    pos = file.rfind(".");
218218    string exename = path+file.substr(0,pos);
...... 
306306    return true;
307307}
308308
309bool Menu::addSection(string sectionName) {
309bool Menu::addSection(const string &sectionName) {
310310    string sectiondir = "sections/"+sectionName;
311311    if (mkdir(sectiondir.c_str(),0777)==0) {
312312        sections.push_back(sectionName);
src/menu.h
5454    linklist *sectionLinks(int i = -1);
5555
5656    int selSectionIndex();
57    string selSection();
57    const string &selSection();
5858    void decSectionIndex();
5959    void incSectionIndex();
6060    void setSectionIndex(int i);
6161    uint firstDispSection();
6262    uint firstDispRow();
6363
64    bool addActionLink(uint section, string title, LinkRunAction action, string description="", string icon="");
64    bool addActionLink(uint section, const string &title, const LinkRunAction &action, const string &description="", const string &icon="");
6565    bool addLink(string path, string file, string section="");
66    bool addSection(string sectionName);
66    bool addSection(const string &sectionName);
6767    void deleteSelectedLink();
6868    void deleteSelectedSection();
6969
src/menusetting.cpp
1919 ***************************************************************************/
2020#include "menusetting.h"
2121
22MenuSetting::MenuSetting(GMenu2X *gmenu2x, string name, string description) {
22MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description) {
2323    this->gmenu2x = gmenu2x;
2424    this->name = name;
2525    this->description = description;
src/menusetting.h
3838    GMenu2X *gmenu2x;
3939
4040public:
41    MenuSetting(GMenu2X *gmenu2x, string name, string description);
41    MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description);
4242    virtual ~MenuSetting() {};
4343
4444    virtual void draw(int y);
src/menusettingbool.cpp
2424using namespace std;
2525using namespace fastdelegate;
2626
27MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string description, int *value)
27MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
2828    : MenuSetting(gmenu2x,name,description) {
2929    this->gmenu2x = gmenu2x;
3030    _ivalue = value;
...... 
3636    btnToggle->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
3737}
3838
39MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string description, bool *value)
39MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
4040    : MenuSetting(gmenu2x,name,description) {
4141    this->gmenu2x = gmenu2x;
4242    _value = value;
src/menusettingbool.h
3838    void toggle();
3939
4040public:
41    MenuSettingBool(GMenu2X *gmenu2x, string name, string description, bool *value);
42    MenuSettingBool(GMenu2X *gmenu2x, string name, string description, int *value);
41    MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
42    MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);
4343    virtual ~MenuSettingBool() {};
4444
4545    virtual void draw(int y);
src/menusettingdir.cpp
2424using namespace std;
2525using namespace fastdelegate;
2626
27MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, string name, string description, string *value)
27MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value)
2828    : MenuSetting(gmenu2x,name,description) {
2929    this->gmenu2x = gmenu2x;
3030    _value = value;
...... 
6161    if (dd.exec()) setValue( dd.path );
6262}
6363
64void MenuSettingDir::setValue(string value) {
64void MenuSettingDir::setValue(const string &value) {
6565    *_value = value;
6666}
6767
68string MenuSettingDir::value() {
68const string &MenuSettingDir::value() {
6969    return *_value;
7070}
7171
src/menusettingdir.h
3636    void clear();
3737
3838public:
39    MenuSettingDir(GMenu2X *gmenu2x, string name, string description, string *value);
39    MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value);
4040    virtual ~MenuSettingDir() {};
4141
4242    virtual void draw(int y);
...... 
4646    virtual void drawSelected(int y);
4747    virtual bool edited();
4848
49    void setValue(string value);
50    string value();
49    void setValue(const string &value);
50    const string &value();
5151};
5252
5353#endif
src/menusettingfile.cpp
2424using namespace std;
2525using namespace fastdelegate;
2626
27MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, string name, string description, string *value, string filter)
27MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
2828    : MenuSetting(gmenu2x,name,description) {
2929    this->gmenu2x = gmenu2x;
3030    this->filter = filter;
...... 
6262    if (fd.exec()) setValue( fd.path()+"/"+fd.file );
6363}
6464
65void MenuSettingFile::setValue(string value) {
65void MenuSettingFile::setValue(const string &value) {
6666    *_value = value;
6767}
6868
69string MenuSettingFile::value() {
69const string &MenuSettingFile::value() {
7070    return *_value;
7171}
7272
src/menusettingfile.h
3737    void clear();
3838
3939public:
40    MenuSettingFile(GMenu2X *gmenu2x, string name, string description, string *value, string filter="");
40    MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
4141    virtual ~MenuSettingFile() {};
4242
4343    virtual void draw(int y);
...... 
4747    virtual void drawSelected(int y);
4848    virtual bool edited();
4949
50    virtual void setValue(string value);
51    string value();
50    virtual void setValue(const string &value);
51    const string &value();
5252};
5353
5454#endif
src/menusettingimage.cpp
2323
2424using namespace std;
2525
26MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, string name, string description, string *value, string filter)
26MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
2727    : MenuSettingFile(gmenu2x,name,description,value,filter) {
2828    this->gmenu2x = gmenu2x;
2929    this->filter = filter;
...... 
3939    }
4040}
4141
42void MenuSettingImage::setValue(string value) {
42void MenuSettingImage::setValue(const string &value) {
4343    string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
4444    bool inSkinDir = value.substr(0,skinpath.length()) == skinpath;
4545    if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
...... 
5050        string tempIcon = value.substr(skinpath.length(), value.length());
5151        string::size_type pos = tempIcon.find("/");
5252        if (pos != string::npos)
53            value = "skin:"+tempIcon.substr(pos+1,value.length());
53            *_value = "skin:"+tempIcon.substr(pos+1,value.length());
54        else
55            *_value = value;
56    } else {
57        *_value = value;
5458    }
55    *_value = value;
5659}
src/menusettingimage.h
2727
2828class MenuSettingImage : public MenuSettingFile {
2929public:
30    MenuSettingImage(GMenu2X *gmenu2x, string name, string description, string *value, string filter="");
30    MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
3131    virtual ~MenuSettingImage() {};
3232
3333    virtual void manageInput();
34    virtual void setValue(string value);
34    virtual void setValue(const string &value);
3535};
3636
3737#endif
src/menusettingint.cpp
2424using namespace std;
2525using namespace fastdelegate;
2626
27MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, string name, string description, int *value, int min, int max)
27MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max)
2828    : MenuSetting(gmenu2x,name,description) {
2929    this->gmenu2x = gmenu2x;
3030    _value = value;
src/menusettingint.h
3939    void dec();
4040
4141public:
42    MenuSettingInt(GMenu2X *gmenu2x, string name, string description, int *value, int min, int max);
42    MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max);
4343    virtual ~MenuSettingInt() {};
4444
4545    virtual void draw(int y);
src/menusettingmultistring.cpp
2323using namespace std;
2424using namespace fastdelegate;
2525
26MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, string name, string description, string *value, vector<string> *choices)
26MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices)
2727    : MenuSetting(gmenu2x,name,description) {
2828    this->gmenu2x = gmenu2x;
2929    this->choices = choices;
src/menusettingmultistring.h
3939    void setSel(int);
4040
4141public:
42    MenuSettingMultiString(GMenu2X *gmenu2x, string name, string description, string *value, vector<string> *choices);
42    MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices);
4343    virtual ~MenuSettingMultiString() {};
4444
4545    virtual void draw(int y);
src/menusettingrgba.cpp
2323using namespace std;
2424using namespace fastdelegate;
2525
26MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, string name, string description, RGBAColor *value)
26MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value)
2727    : MenuSetting(gmenu2x,name,description) {
2828    selPart = 0;
2929    this->gmenu2x = gmenu2x;
src/menusettingrgba.h
4242    void rightComponent();
4343
4444public:
45    MenuSettingRGBA(GMenu2X *gmenu2x, string name, string description, RGBAColor *value);
45    MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value);
4646    virtual ~MenuSettingRGBA() {};
4747
4848    virtual void draw(int y);
src/menusettingstring.cpp
2424using namespace std;
2525using namespace fastdelegate;
2626
27MenuSettingString::MenuSettingString(GMenu2X *gmenu2x, string name, string description, string *value, string diagTitle, string diagIcon)
27MenuSettingString::MenuSettingString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &diagTitle, const string &diagIcon)
2828    : MenuSetting(gmenu2x,name,description) {
2929    this->gmenu2x = gmenu2x;
3030    _value = value;
...... 
5353    if ( gmenu2x->input[ACTION_B] ) edit();
5454}
5555
56void MenuSettingString::setValue(string value) {
56void MenuSettingString::setValue(const string &value) {
5757    *_value = value;
5858}
5959
60string MenuSettingString::value() {
60const string &MenuSettingString::value() {
6161    return *_value;
6262}
6363
src/menusettingstring.h
3636    void clear();
3737
3838public:
39    MenuSettingString(GMenu2X *gmenu2x, string name, string description, string *value, string diagTitle="", string diagIcon="");
39    MenuSettingString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &diagTitle="", const string &diagIcon="");
4040    virtual ~MenuSettingString() {};
4141
4242    virtual void draw(int y);
...... 
4646    virtual void drawSelected(int y);
4747    virtual bool edited();
4848
49    void setValue(string value);
50    string value();
49    void setValue(const string &value);
50    const string &value();
5151};
5252
5353#endif
src/messagebox.cpp
2525
2626using namespace std;
2727
28MessageBox::MessageBox(GMenu2X *gmenu2x, string text, string icon) {
28MessageBox::MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon) {
2929    this->gmenu2x = gmenu2x;
3030    this->text = text;
3131    this->icon = icon;
src/messagebox.h
3838    GMenu2X *gmenu2x;
3939
4040public:
41    MessageBox(GMenu2X *gmenu2x, string text, string icon="");
41    MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon="");
4242    vector<string> buttons;
4343    vector<string> buttonLabels;
4444    vector<SDL_Rect> buttonPositions;
src/selector.cpp
3333
3434using namespace std;
3535
36Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir) {
36Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir) {
3737    this->gmenu2x = gmenu2x;
3838    this->link = link;
3939    loadAliases();
...... 
235235    }
236236}
237237
238string Selector::getAlias(string key) {
238string Selector::getAlias(const string &key) {
239239    hash_map<string, string>::iterator i = aliases.find(key);
240240    if (i == aliases.end())
241241        return "";
src/selector.h
4141
4242    hash_map<string, string> aliases;
4343    void loadAliases();
44    string getAlias(string key);
44    string getAlias(const string &key);
4545    void prepare(FileLister *fl, vector<string> *screens, vector<string> *titles);
4646    void freeScreenshots(vector<string> *screens);
4747
4848public:
4949    string file, dir;
50    Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir="");
50    Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir="");
5151
5252    int exec(int startSelection=0);
5353};
src/selectordetector.cpp
1111    useSelectorBackground = false;
1212}
1313
14SelectorDetector::SelectorDetector(string config) {
14SelectorDetector::SelectorDetector(const string &config) {
1515    useSelectorBackground = false;
1616    readSelectorConfig(config);
1717}
...... 
2020    //dtor
2121}
2222
23bool SelectorDetector::readSelectorConfig(string config) {
23bool SelectorDetector::readSelectorConfig(const string &config) {
2424    if (fileExists(config)) {
2525        ifstream inf(config.c_str(), ios_base::in);
2626        if (inf.is_open()) {
src/selectordetector.h
3737{
3838    public:
3939        SelectorDetector();
40        SelectorDetector(string config);
40        SelectorDetector(const string &config);
4141        ~SelectorDetector();
4242
43        bool readSelectorConfig(string config);
43        bool readSelectorConfig(const string &config);
4444
4545        string getApplication(){return application;}
4646        string getFilePath(){return filePath;}
...... 
5151        string application;
5252        string filePath;
5353        string filters;
54        //bool isSelectorGPE(string gpe);
55        //string getSelectorConfig(string gpe); // Looks in the GPE for the location of the selectorconfig
54        //bool isSelectorGPE(const string &gpe);
55        //string getSelectorConfig(const string &gpe); // Looks in the GPE for the location of the selectorconfig
5656};
5757
5858#endif // SELECTORDETECTOR_H
src/settingsdialog.cpp
2525
2626using namespace std;
2727
28SettingsDialog::SettingsDialog(GMenu2X *gmenu2x, string text, string icon) {
28SettingsDialog::SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon) {
2929    this->gmenu2x = gmenu2x;
3030    this->text = text;
3131
src/settingsdialog.h
4040    GMenu2X *gmenu2x;
4141
4242public:
43    SettingsDialog(GMenu2X *gmenu2x, string text, string icon="skin:sections/settings.png");
43    SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon="skin:sections/settings.png");
4444    ~SettingsDialog();
4545
4646    bool edited();
src/sfontplus.cpp
4646    initFont(font);
4747}
4848
49SFontPlus::SFontPlus(string font) {
49SFontPlus::SFontPlus(const string &font) {
5050    surface = NULL;
5151    initFont(font);
5252}
...... 
6060    //return c>=194;
6161}
6262
63void SFontPlus::initFont(string font, string characters) {
63void SFontPlus::initFont(const string &font, const string &characters) {
6464    SDL_Surface *buf = IMG_Load(font.c_str());
6565    if (buf!=NULL) {
6666        initFont( SDL_DisplayFormatAlpha(buf), characters );
...... 
6868    }
6969}
7070
71void SFontPlus::initFont(SDL_Surface *font, string characters) {
71void SFontPlus::initFont(SDL_Surface *font, const string &characters) {
7272    freeFont();
7373    this->characters = characters;
7474    if (font==NULL) return;
...... 
126126    }
127127}
128128
129void SFontPlus::write(SDL_Surface *s, string text, int x, int y) {
129void SFontPlus::write(SDL_Surface *s, const string &text, int x, int y) {
130130    if (text.empty()) return;
131131
132132    string::size_type pos;
...... 
161161    }
162162}
163163
164uint SFontPlus::getTextWidth(string text) {
164uint SFontPlus::getTextWidth(const string &text) {
165165    string::size_type pos;
166166    int width = 0;
167167
src/sfontplus.h
2424public:
2525    SFontPlus();
2626    SFontPlus(SDL_Surface *font);
27    SFontPlus(string font);
27    SFontPlus(const string &font);
2828    ~SFontPlus();
2929
3030    bool utf8Code(unsigned char c);
3131
32    void initFont(SDL_Surface *font, string characters = SFONTPLUS_CHARSET);
33    void initFont(string font, string characters = SFONTPLUS_CHARSET);
32    void initFont(SDL_Surface *font, const string &characters = SFONTPLUS_CHARSET);
33    void initFont(const string &font, const string &characters = SFONTPLUS_CHARSET);
3434    void freeFont();
3535
36    void write(SDL_Surface *s, string text, int x, int y);
36    void write(SDL_Surface *s, const string &text, int x, int y);
3737
38    uint getTextWidth(string text);
38    uint getTextWidth(const string &text);
3939    uint getHeight();
4040    uint getLineHeight();
4141};
src/surface.cpp
2626#include "surface.h"
2727#include "utilities.h"
2828
29RGBAColor strtorgba(string strColor) {
29RGBAColor strtorgba(const string &strColor) {
3030    RGBAColor c = {0,0,0,255};
3131    c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 );
3232    c.g = constrain( strtol( strColor.substr(2,2).c_str(), NULL, 16 ), 0, 255 );
...... 
4040    dblbuffer = NULL;
4141}
4242
43Surface::Surface(string img, bool alpha, string skin) {
43Surface::Surface(const string &img, bool alpha, const string &skin) {
4444    raw = NULL;
4545    dblbuffer = NULL;
4646    load(img, alpha, skin);
...... 
4848    halfH = raw->h/2;
4949}
5050
51Surface::Surface(string img, string skin, bool alpha) {
51Surface::Surface(const string &img, const string &skin, bool alpha) {
5252    raw = NULL;
5353    dblbuffer = NULL;
5454    load(img, alpha, skin);
...... 
111111        return raw->format;
112112}
113113
114void Surface::load(string img, bool alpha, string skin) {
114void Surface::load(const string &img, bool alpha, const string &skin) {
115115    free();
116116
117117    string skinpath;
...... 
119119        skinpath = "skins/"+skin+"/"+img;
120120        if (!fileExists(skinpath))
121121            skinpath = "skins/Default/"+img;
122        img = skinpath;
122    } else {
123        skinpath = img;
123124    }
124125
125    SDL_Surface *buf = IMG_Load(img.c_str());
126    SDL_Surface *buf = IMG_Load(skinpath.c_str());
126127    if (buf!=NULL) {
127128        if (alpha)
128129            raw = SDL_DisplayFormatAlpha(buf);
...... 
264265*/
265266}
266267
267void Surface::write(ASFont *font, string text, int x, int y, const unsigned short halign, const unsigned short valign) {
268void Surface::write(ASFont *font, const string &text, int x, int y, const unsigned short halign, const unsigned short valign) {
268269    font->write(this,text,x,y,halign,valign);
269270}
270271
src/surface.h
3232    unsigned short r,g,b,a;
3333};
3434
35RGBAColor strtorgba(string strColor);
35RGBAColor strtorgba(const string &strColor);
3636
3737/**
3838    Wrapper around SDL_Surface
...... 
4646
4747public:
4848    Surface();
49    Surface(string img, string skin="", bool alpha=true);
50    Surface(string img, bool alpha, string skin="");
49    Surface(const string &img, const string &skin="", bool alpha=true);
50    Surface(const string &img, bool alpha, const string &skin="");
5151    Surface(SDL_Surface *s, SDL_PixelFormat *fmt = NULL, Uint32 flags = 0);
5252    Surface(Surface *s);
5353    Surface(int w, int h, Uint32 flags = SDL_HWSURFACE|SDL_SRCALPHA);
...... 
5858    SDL_Surface *raw;
5959
6060    void free();
61    void load(string img, bool alpha=true, string skin="");
61    void load(const string &img, bool alpha=true, const string &skin="");
6262    void lock();
6363    void unlock();
6464    void flip();
...... 
8383    bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
8484    bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
8585
86    void write(ASFont *font, string text, int x, int y, const unsigned short halign=0, const unsigned short valign=0);
86    void write(ASFont *font, const string &text, int x, int y, const unsigned short halign=0, const unsigned short valign=0);
8787
8888    int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8);
8989    int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8);
src/surfacecollection.cpp
2222
2323using namespace std;
2424
25SurfaceCollection::SurfaceCollection(bool defaultAlpha, string skin) {
25SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) {
2626    surfaces.set_empty_key(" ");
2727    surfaces.set_deleted_key("");
2828    this->defaultAlpha = defaultAlpha;
...... 
3131
3232SurfaceCollection::~SurfaceCollection() {}
3333
34void SurfaceCollection::setSkin(string skin) {
34void SurfaceCollection::setSkin(const string &skin) {
3535    this->skin = skin;
3636}
3737
38string SurfaceCollection::getSkinFilePath(string file) {
38string SurfaceCollection::getSkinFilePath(const string &file) {
3939    string prefix = "/usr/share/gmenu2x/";
4040    if (fileExists("skins/"+skin+"/"+file))
4141        return "skins/"+skin+"/"+file;
...... 
5454    }
5555}
5656
57bool SurfaceCollection::exists(string path) {
57bool SurfaceCollection::exists(const string &path) {
5858    return surfaces.find(path) != surfaces.end();
5959}
6060
61Surface *SurfaceCollection::add(Surface *s, string path) {
61Surface *SurfaceCollection::add(Surface *s, const string &path) {
6262    if (exists(path)) del(path);
6363    surfaces[path] = s;
6464    return s;
6565}
6666
67Surface *SurfaceCollection::add(string path, bool alpha) {
67Surface *SurfaceCollection::add(const string &path, bool alpha) {
6868#ifdef DEBUG
6969    cout << "Adding surface: " << path << endl;
7070#endif
...... 
8282    return s;
8383}
8484
85Surface *SurfaceCollection::addSkinRes(string path, bool alpha) {
85Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
8686#ifdef DEBUG
8787    cout << "Adding skin surface: " << path << endl;
8888#endif
...... 
9999    return s;
100100}
101101
102void SurfaceCollection::del(string path) {
102void SurfaceCollection::del(const string &path) {
103103    SurfaceHash::iterator i = surfaces.find(path);
104104    if (i != surfaces.end()) {
105105        free(i->second);
...... 
115115    }
116116}
117117
118void SurfaceCollection::move(string from, string to) {
118void SurfaceCollection::move(const string &from, const string &to) {
119119    del(to);
120120    surfaces[to] = surfaces[from];
121121    surfaces.erase(from);
122122}
123123
124Surface *SurfaceCollection::operator[](string key) {
124Surface *SurfaceCollection::operator[](const string &key) {
125125    SurfaceHash::iterator i = surfaces.find(key);
126126    if (i == surfaces.end())
127127        return add(key, defaultAlpha);
...... 
129129        return i->second;
130130}
131131
132Surface *SurfaceCollection::skinRes(string key) {
132Surface *SurfaceCollection::skinRes(const string &key) {
133133    if (key.empty()) return NULL;
134134
135135    SurfaceHash::iterator i = surfaces.find(key);
src/surfacecollection.h
3939    string skin;
4040
4141public:
42    SurfaceCollection(bool defaultAlpha=true, string skin="default");
42    SurfaceCollection(bool defaultAlpha=true, const string &skin="default");
4343    ~SurfaceCollection();
4444
45    void setSkin(string skin);
46    string getSkinFilePath(string file);
45    void setSkin(const string &skin);
46    string getSkinFilePath(const string &file);
4747
4848    bool defaultAlpha;
4949    void debug();
5050
51    Surface *add(Surface *s, string path);
52    Surface *add(string path, bool alpha=true);
53    Surface *addSkinRes(string path, bool alpha=true);
54    void del(string path);
51    Surface *add(Surface *s, const string &path);
52    Surface *add(const string &path, bool alpha=true);
53    Surface *addSkinRes(const string &path, bool alpha=true);
54    void del(const string &path);
5555    void clear();
56    void move(string from, string to);
57    bool exists(string path);
56    void move(const string &from, const string &to);
57    bool exists(const string &path);
5858
59    Surface *operator[](string);
60    Surface *skinRes(string);
59    Surface *operator[](const string &);
60    Surface *skinRes(const string &);
6161};
6262
6363#endif
src/textdialog.cpp
2222
2323using namespace std;
2424
25TextDialog::TextDialog(GMenu2X *gmenu2x, string title, string description, string icon, vector<string> *text) {
25TextDialog::TextDialog(GMenu2X *gmenu2x, const string &title, const string &description, const string &icon, vector<string> *text) {
2626    this->gmenu2x = gmenu2x;
2727    this->text = text;
2828    this->title = title;
src/textdialog.h
3737    void drawText(vector<string> *text, uint firstRow, uint rowsPerPage);
3838
3939public:
40    TextDialog(GMenu2X *gmenu2x, string title, string description, string icon, vector<string> *text);
40    TextDialog(GMenu2X *gmenu2x, const string &title, const string &description, const string &icon, vector<string> *text);
4141    void exec();
4242};
4343
src/textmanualdialog.cpp
2323
2424using namespace std;
2525
26TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, string title, string icon, vector<string> *text)
26TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const string &icon, vector<string> *text)
2727    : TextDialog(gmenu2x,title,"",icon,text) {
2828    this->gmenu2x = gmenu2x;
2929
src/textmanualdialog.h
3838    vector<ManualPage> pages;
3939
4040public:
41    TextManualDialog(GMenu2X *gmenu2x, string title, string icon, vector<string> *text);
41    TextManualDialog(GMenu2X *gmenu2x, const string &title, const string &icon, vector<string> *text);
4242    void exec();
4343};
4444
src/translator.cpp
2626
2727using namespace std;
2828
29Translator::Translator(string lang) {
29Translator::Translator(const string &lang) {
3030    _lang = "";
3131    if (!lang.empty())
3232        setLang(lang);
...... 
3434
3535Translator::~Translator() {}
3636
37bool Translator::exists(string term) {
37bool Translator::exists(const string &term) {
3838    return translations.find(term) != translations.end();
3939}
4040
41void Translator::setLang(string lang) {
41void Translator::setLang(const string &lang) {
4242    translations.clear();
4343
4444    string line;
...... 
5757    }
5858}
5959
60string Translator::translate(string term,const char *replacestr,...) {
60string Translator::translate(const string &term,const char *replacestr,...) {
6161    string result = term;
6262
6363    if (!_lang.empty()) {
...... 
8787    return result;
8888}
8989
90string Translator::operator[](string term) {
90string Translator::operator[](const string &term) {
9191    return translate(term);
9292}
9393
src/translator.h
3333    hash_map<string, string> translations;
3434
3535public:
36    Translator(string lang="");
36    Translator(const string &lang="");
3737    ~Translator();
3838
3939    string lang();
40    void setLang(string lang);
41    bool exists(string term);
42    string translate(string term,const char *replacestr=NULL,...);
43    string operator[](string term);
40    void setLang(const string &lang);
41    bool exists(const string &term);
42    string translate(const string &term,const char *replacestr=NULL,...);
43    string operator[](const string &term);
4444};
4545
4646#endif
src/utilities.cpp
2828
2929using namespace std;
3030
31bool case_less::operator()(string const &left, string const &right) const {
31bool case_less::operator()(const string &left, const string &right) const {
3232    return strcasecmp(left.c_str(), right.c_str()) < 0;
3333}
3434
...... 
4343  return string(s, b, e - b + 1);
4444}
4545
46void string_copy(string s, char **cs) {
46void string_copy(const string &s, char **cs) {
4747    *cs = (char*)malloc(s.length());
4848    strcpy(*cs, s.c_str());
4949}
5050
51char * string_copy(string s) {
51char * string_copy(const string &s) {
5252    char *cs = NULL;
5353    string_copy(s, &cs);
5454    return cs;
5555}
5656
57bool fileExists(string file) {
57bool fileExists(const string &file) {
5858    fstream fin;
5959    fin.open(file.c_str() ,ios::in);
6060    bool exists = fin.is_open();
...... 
115115    return *val;
116116}
117117
118string evalStrConf (string val, string def) {
118const string &evalStrConf (const string &val, const string &def) {
119119    return val.empty() ? def : val;
120120}
121string evalStrConf (string *val, string def) {
121const string &evalStrConf (string *val, const string &def) {
122122    *val = evalStrConf(*val, def);
123123    return *val;
124124}
...... 
158158    return true;
159159}
160160
161string strreplace (string orig, string search, string replace) {
161string strreplace (string orig, const string &search, const string &replace) {
162162    string::size_type pos = orig.find( search, 0 );
163163    while (pos != string::npos) {
164164        orig.replace(pos,search.length(),replace);
src/utilities.h
4949
5050class case_less {
5151public:
52    bool operator()(string const &left, string const &right) const;
52    bool operator()(const string &left, const string &right) const;
5353};
5454
5555string trim(const string& s);
56string strreplace (string orig, string search, string replace);
56string strreplace (string orig, const string &search, const string &replace);
5757string cmdclean (string cmdline);
5858
59char *string_copy(string);
60void string_copy(string, char **);
59char *string_copy(const string &);
60void string_copy(const string &, char **);
6161
62bool fileExists(string file);
62bool fileExists(const string &file);
6363bool rmtree(string path);
6464
6565int max (int a, int b);
...... 
6868
6969int evalIntConf (int val, int def, int imin, int imax);
7070int evalIntConf (int *val, int def, int imin, int imax);
71string evalStrConf (string val, string def);
72string evalStrConf (string *val, string def);
71const string &evalStrConf (const string &val, const string &def);
72const string &evalStrConf (string *val, const string &def);
7373
7474bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true);
7575

Archive Download the corresponding diff file



interactive