Root/src/browsedialog.h

1/***************************************************************************
2 * Copyright (C) 2006 by Massimiliano Torromeo *
3 * massimiliano.torromeo@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#ifndef BROWSEDIALOG_H
22#define BROWSEDIALOG_H
23
24#include "buttonbox.h"
25#include "dialog.h"
26#include "filelister.h"
27#include "inputmanager.h"
28
29#include <SDL.h>
30#include <string>
31
32class Touchscreen;
33
34class BrowseDialog : protected Dialog {
35protected:
36    BrowseDialog(
37            GMenu2X *gmenu2x, Touchscreen &ts,
38            const std::string &title, const std::string &subtitle);
39    virtual ~BrowseDialog();
40
41    void setPath(const std::string &path) {
42        fl->setPath(path);
43    }
44
45    FileLister *fl;
46    unsigned int selected;
47
48private:
49    enum Action {
50        ACT_NONE,
51        ACT_SELECT,
52        ACT_CLOSE,
53        ACT_UP,
54        ACT_DOWN,
55        ACT_SCROLLUP,
56        ACT_SCROLLDOWN,
57        ACT_GOUP,
58        ACT_CONFIRM,
59    };
60
61    Touchscreen &ts;
62    bool close, result;
63
64    std::string title;
65    std::string subtitle;
66
67    SDL_Rect clipRect;
68    SDL_Rect touchRect;
69
70    unsigned int numRows;
71    unsigned int rowHeight;
72
73    bool ts_pressed;
74
75    Surface *iconGoUp;
76    Surface *iconFolder;
77    Surface *iconFile;
78
79    ButtonBox buttonBox;
80
81    Action getAction(InputManager::Button button);
82    void handleInput();
83
84    void paint();
85
86    void directoryUp();
87    void directoryEnter();
88    void confirm();
89    void quit();
90
91public:
92    bool exec();
93
94    const std::string &getPath() {
95        return fl->getPath();
96    }
97    std::string getFile() {
98        return (*fl)[selected];
99    }
100};
101
102#endif // INPUTDIALOG_H
103

Archive Download this file



interactive