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 <string>
25#include "filelister.h"
26#include "gmenu2x.h"
27#include "buttonbox.h"
28#include "dialog.h"
29#include "inputmanager.h"
30
31class FileLister;
32
33using std::string;
34
35class BrowseDialog : protected Dialog {
36protected:
37    BrowseDialog(GMenu2X *gmenu2x, const string &title, const string &subtitle);
38    virtual ~BrowseDialog();
39
40    void setPath(const string &path) {
41        fl->setPath(path);
42    }
43
44    FileLister *fl;
45    unsigned int selected;
46
47private:
48    enum Action {
49        ACT_NONE,
50        ACT_SELECT,
51        ACT_CLOSE,
52        ACT_UP,
53        ACT_DOWN,
54        ACT_SCROLLUP,
55        ACT_SCROLLDOWN,
56        ACT_GOUP,
57        ACT_CONFIRM,
58    };
59
60    bool close, result;
61
62    string title;
63    string subtitle;
64
65    SDL_Rect clipRect;
66    SDL_Rect touchRect;
67
68    unsigned int numRows;
69    unsigned int rowHeight;
70
71    bool ts_pressed;
72
73    Surface *iconGoUp;
74    Surface *iconFolder;
75    Surface *iconFile;
76
77    ButtonBox buttonBox;
78
79    Action getAction(bevent_t *event);
80    void handleInput();
81
82    void paint();
83
84    void directoryUp();
85    void directoryEnter();
86    void confirm();
87
88public:
89    bool exec();
90
91    const std::string &getPath()
92    {
93        return fl->getPath();
94    }
95    std::string getFile()
96    {
97        return (*fl)[selected];
98    }
99};
100
101#endif /*INPUTDIALOG_H_*/
102

Archive Download this file



interactive