"Fossies" - the Fresh Open Source Software Archive

Member "stella-6.0.2/src/gui/FileListWidget.hxx" (11 Oct 2019, 2932 Bytes) of package /linux/privat/stella-6.0.2-src.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "FileListWidget.hxx" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.0.1_vs_6.0.2.

    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 FILE_LIST_WIDGET_HXX
   19 #define FILE_LIST_WIDGET_HXX
   20 
   21 class CommandSender;
   22 
   23 #include "FSNode.hxx"
   24 #include "GameList.hxx"
   25 #include "StringListWidget.hxx"
   26 
   27 /**
   28   Provides an encapsulation of a file listing, allowing to descend into
   29   directories, and send signals based on whether an item is selected or
   30   activated.
   31 
   32   When the signals ItemChanged and ItemActivated are emitted, the caller
   33   can query the selected() and/or currentDir() methods to determine the
   34   current state.
   35 
   36   Note that for the current implementation, the ItemActivated signal is
   37   not sent when activating a directory (instead the code descends into
   38   the directory).  This may be changed in a future revision.
   39 */
   40 class FileListWidget : public StringListWidget
   41 {
   42   public:
   43     enum {
   44       ItemChanged   = 'FLic',  // Entry in the list is changed (single-click, etc)
   45       ItemActivated = 'FLac'   // Entry in the list is activated (double-click, etc)
   46     };
   47 
   48   public:
   49     FileListWidget(GuiObject* boss, const GUI::Font& font,
   50                    int x, int y, int w, int h);
   51     virtual ~FileListWidget() = default;
   52 
   53     /** Determines how to display files/folders */
   54     void setFileListMode(FilesystemNode::ListMode mode) { _fsmode = mode; }
   55     void setFileExtension(const string& ext) { _extension = ext; }
   56 
   57     /** Set current location (file or directory) */
   58     void setLocation(const FilesystemNode& node, string select = "");
   59 
   60     /** Select parent directory (if applicable) */
   61     void selectParent();
   62 
   63     /** Gets current node(s) */
   64     const FilesystemNode& selected() const   { return _selected;  }
   65     const FilesystemNode& currentDir() const { return _node;      }
   66 
   67   protected:
   68     void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
   69 
   70   private:
   71     FilesystemNode::ListMode _fsmode;
   72     FilesystemNode _node, _selected;
   73     string _extension;
   74 
   75     GameList _gameList;
   76 
   77   private:
   78     // Following constructors and assignment operators not supported
   79     FileListWidget() = delete;
   80     FileListWidget(const FileListWidget&) = delete;
   81     FileListWidget(FileListWidget&&) = delete;
   82     FileListWidget& operator=(const FileListWidget&) = delete;
   83     FileListWidget& operator=(FileListWidget&&) = delete;
   84 };
   85 
   86 #endif