1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#ifndef BROWSER_DIALOG_HXX
19#define BROWSER_DIALOG_HXX
20
21class GuiObject;
22class ButtonWidget;
23class EditTextWidget;
24class FileListWidget;
25class StaticTextWidget;
26class FilesystemNode;
27
28#include "Dialog.hxx"
29#include "Command.hxx"
30#include "bspf.hxx"
31
32class BrowserDialog : public Dialog, public CommandSender
33{
34 public:
35 enum ListMode {
36 FileLoad, // File selector, no input from user
37 FileSave, // File selector, filename changable by user
38 Directories // Directories only, no input from user
39 };
40
41 public:
42 BrowserDialog(GuiObject* boss, const GUI::Font& font, int max_w, int max_h,
43 const string& title = "");
44 virtual ~BrowserDialog() = default;
45
46 /** Place the browser window onscreen, using the given attributes */
47 void show(const string& startpath,
48 BrowserDialog::ListMode mode, int cmd, const string& ext = "");
49
50 /** Get resulting file node (called after receiving kChooseCmd) */
51 const FilesystemNode& getResult() const;
52
53 private:
54 void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
55 void updateUI();
56
57 private:
58 enum {
59 kChooseCmd = 'CHOS',
60 kGoUpCmd = 'GOUP',
61 kBaseDirCmd = 'BADR'
62 };
63
64 int _cmd;
65
66 FileListWidget* _fileList;
67 EditTextWidget* _currentPath;
68 StaticTextWidget* _type;
69 EditTextWidget* _selected;
70 ButtonWidget* _goUpButton;
71 ButtonWidget* _basedirButton;
72
73 BrowserDialog::ListMode _mode;
74
75 private:
76 // Following constructors and assignment operators not supported
77 BrowserDialog() = delete;
78 BrowserDialog(const BrowserDialog&) = delete;
79 BrowserDialog(BrowserDialog&&) = delete;
80 BrowserDialog& operator=(const BrowserDialog&) = delete;
81 BrowserDialog& operator=(BrowserDialog&&) = delete;
82};
83
84#endif
85