Root/src/browsedialog.h

Source at commit 00d3c3b57008bddf8770c51271db9d766acaf854 created 7 years 5 months ago.
By Maarten ter Huurne, Gave Layer class a protected constructor
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 OffscreenSurface;
33
34class BrowseDialog : protected Dialog {
35protected:
36    BrowseDialog(GMenu2X& gmenu2x,
37            const std::string &title, const std::string &subtitle);
38    virtual ~BrowseDialog();
39
40    void setPath(const std::string &path) {
41        this->path = path;
42        fl.browse(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    bool close, result;
62
63    std::string title;
64    std::string subtitle;
65    std::string path;
66
67    SDL_Rect clipRect;
68
69    unsigned int numRows;
70    unsigned int rowHeight;
71
72    OffscreenSurface *iconGoUp;
73    OffscreenSurface *iconFolder;
74    OffscreenSurface *iconFile;
75
76    ButtonBox buttonBox;
77
78    Action getAction(InputManager::Button button);
79    void handleInput();
80
81    void paint();
82
83    void directoryUp();
84    void directoryEnter();
85    void confirm();
86    void quit();
87
88public:
89    bool exec();
90
91    const std::string &getPath() {
92        return path;
93    }
94    std::string getFile() {
95        return fl[selected];
96    }
97};
98
99#endif // INPUTDIALOG_H
100

Archive Download this file



interactive