1 /********************************************************************************
2 *                                                                               *
3 *              D i r e c t o r y   S e l e c t i o n   W i d g e t              *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2000,2020 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify          *
9 * it under the terms of the GNU Lesser General Public License as published by   *
10 * the Free Software Foundation; either version 3 of the License, or             *
11 * (at your option) any later version.                                           *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
16 * GNU Lesser General Public License for more details.                           *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public License      *
19 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
20 ********************************************************************************/
21 #ifndef FXDIRSELECTOR_H
22 #define FXDIRSELECTOR_H
23 
24 #ifndef FXPACKER_H
25 #include "FXPacker.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXButton;
32 class FXDirList;
33 class FXTextField;
34 class FXFileAssociations;
35 
36 
37 /**
38 * The Directory Selector widget is the reusable mega-widget component which
39 * is the core of the Directory Dialog.  The function of the directory selector widget
40 * is very similar to the file selector widget, except that the directory selector widget
41 * displays a tree-structured view of the file system, and thereby makes up and down
42 * navigation through the file system significantly easier.
43 */
44 class FXAPI FXDirSelector : public FXPacker {
45   FXDECLARE(FXDirSelector)
46 protected:
47   FXDirList     *dirbox;        // Directory list widget
48   FXTextField   *dirname;       // Directory name entry field
49   FXButton      *accept;        // Accept button
50   FXButton      *cancel;        // Cancel button
51   FXIcon        *updiricon;     // Up directory icon
52   FXIcon        *homeicon;      // Go home icon
53   FXIcon        *workicon;      // Go home icon
54   FXIcon        *bookmarkicon;  // Book mark icon
55   FXIcon        *bookaddicon;   // Book add icon
56   FXIcon        *bookdelicon;   // Book delete icon
57   FXIcon        *bookclricon;   // Book clear icon
58   FXIcon        *sortingicon;   // Sorting icon
59   FXIcon        *newicon;       // New directory icon
60   FXIcon        *deleteicon;    // Delete file icon
61   FXIcon        *moveicon;      // Rename file icon
62   FXIcon        *copyicon;      // Copy file icon
63   FXIcon        *linkicon;      // Link file icon
64   FXRecentFiles  mrufiles;      // Recently visited places
65 protected:
FXDirSelector()66   FXDirSelector(){}
67 private:
68   FXDirSelector(const FXDirSelector&);
69   FXDirSelector &operator=(const FXDirSelector&);
70 public:
71   long onCmdName(FXObject*,FXSelector,void*);
72   long onCmdOpened(FXObject*,FXSelector,void*);
73   long onCmdHome(FXObject*,FXSelector,void*);
74   long onCmdWork(FXObject*,FXSelector,void*);
75   long onCmdDirectoryUp(FXObject*,FXSelector,void*);
76   long onPopupMenu(FXObject*,FXSelector,void*);
77   long onCmdBookmark(FXObject*,FXSelector,void*);
78   long onCmdUnBookmark(FXObject*,FXSelector,void*);
79   long onCmdVisit(FXObject*,FXSelector,void*);
80   long onCmdNew(FXObject*,FXSelector,void*);
81   long onUpdNew(FXObject*,FXSelector,void*);
82   long onCmdMove(FXObject*,FXSelector,void*);
83   long onCmdCopy(FXObject*,FXSelector,void*);
84   long onCmdLink(FXObject*,FXSelector,void*);
85   long onCmdRemove(FXObject*,FXSelector,void*);
86   long onUpdSelected(FXObject*,FXSelector,void*);
87 public:
88   enum {
89     ID_DIRNAME=FXPacker::ID_LAST,
90     ID_DIRLIST,
91     ID_HOME,
92     ID_WORK,
93     ID_DIRECTORY_UP,
94     ID_BOOKMARK,
95     ID_UNBOOKMARK,
96     ID_VISIT,
97     ID_NEW,
98     ID_REMOVE,
99     ID_MOVE,
100     ID_COPY,
101     ID_LINK,
102     ID_LAST
103     };
104 public:
105 
106   /// Constructor
107   FXDirSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
108 
109   /// Return a pointer to the "Accept" button
acceptButton()110   FXButton *acceptButton() const { return accept; }
111 
112   /// Return a pointer to the "Cancel" button
cancelButton()113   FXButton *cancelButton() const { return cancel; }
114 
115   /// Change directory
116   void setDirectory(const FXString& path);
117 
118   /// Return directory
119   FXString getDirectory() const;
120 
121   /// Change wildcard matching pattern
122   void setPattern(const FXString& ptrn);
123 
124   /// Return wildcard pattern
125   FXString getPattern() const;
126 
127   /// Return wildcard matching mode
128   FXuint getMatchMode() const;
129 
130   /// Change wildcard matching mode (see FXPath)
131   void setMatchMode(FXuint mode);
132 
133   /// Return true if showing files as well as directories
134   FXbool showFiles() const;
135 
136   /// Show or hide normal files
137   void showFiles(FXbool showing);
138 
139   /// Return true if showing hidden directories
140   FXbool showHiddenFiles() const;
141 
142   /// Show or hide hidden directories
143   void showHiddenFiles(FXbool showing);
144 
145   /// Change Directory List style
146   void setDirBoxStyle(FXuint style);
147 
148   /// Return Directory List style
149   FXuint getDirBoxStyle() const;
150 
151   /// Change file associations; delete old ones if owned
152   void setAssociations(FXFileAssociations* assoc,FXbool owned=false);
153 
154   /// Return file associations
155   FXFileAssociations* getAssociations() const;
156 
157   /// Save to stream
158   virtual void save(FXStream& store) const;
159 
160   /// Load from stream
161   virtual void load(FXStream& store);
162 
163   /// Destructor
164   virtual ~FXDirSelector();
165   };
166 
167 }
168 
169 #endif
170