Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXFileSelector.h
1 /********************************************************************************
2 * *
3 * F i l e S e l e c t i o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2017 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 FXFILESELECTOR_H
22 #define FXFILESELECTOR_H
23 
24 #ifndef FXPACKER_H
25 #include "FXPacker.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXFileAssociations;
32 class FXFileList;
33 class FXTextField;
34 class FXComboBox;
35 class FXDirBox;
36 class FXButton;
37 class FXMenuButton;
38 class FXIcon;
39 class FXMenuPane;
40 class FXCheckButton;
41 class FXMatrix;
42 class FXIconSource;
43 class FXHorizontalFrame;
44 
45 
47 enum {
48  SELECTFILE_ANY,
49  SELECTFILE_EXISTING,
50  SELECTFILE_MULTIPLE,
51  SELECTFILE_MULTIPLE_ALL,
52  SELECTFILE_DIRECTORY
53  };
54 
55 
57 class FXAPI FXFileSelector : public FXPacker {
58  FXDECLARE(FXFileSelector)
59 protected:
60  FXFileList *filebox; // File list widget
61  FXTextField *filename; // File name entry field
62  FXComboBox *filefilter; // Combobox for pattern list
63  FXMenuPane *bookmarkmenu; // Menu for bookmarks
64  FXHorizontalFrame *navbuttons; // Navigation buttons
65  FXHorizontalFrame *fileboxframe; // Frame around file list
66  FXMatrix *entryblock; // Entry block
67  FXCheckButton *readonly; // Open file as read only
68  FXDirBox *dirbox; // Directory hierarchy list
69  FXButton *accept; // Accept button
70  FXButton *cancel; // Cancel button
71  FXIcon *updiricon; // Up directory icon
72  FXIcon *listicon; // List mode icon
73  FXIcon *detailicon; // Detail mode icon
74  FXIcon *iconsicon; // Icon mode icon
75  FXIcon *homeicon; // Go home icon
76  FXIcon *workicon; // Go home icon
77  FXIcon *shownicon; // Files shown icon
78  FXIcon *hiddenicon; // Files hidden icon
79  FXIcon *bookmarkicon; // Book mark icon
80  FXIcon *bookaddicon; // Book add icon
81  FXIcon *bookdelicon; // Book delete icon
82  FXIcon *bookclricon; // Book clear icon
83  FXIcon *sortingicon; // Sorting icon
84  FXIcon *newicon; // New directory icon
85  FXIcon *renameicon; // Rename file icon
86  FXIcon *copyicon; // Copy file icon
87  FXIcon *moveicon; // Rename file icon
88  FXIcon *linkicon; // Link file icon
89  FXIcon *deleteicon; // Delete file icon
90  FXRecentFiles bookmarks; // Bookmarked places
91  FXuint selectmode; // Select mode
92  FXbool navigable; // May navigate
93 protected:
94  FXFileSelector(){}
95  static FXint countFilenames(const FXString& string);
96  static FXString decodeFilename(const FXString& string,FXint n=0);
97  static FXString encodeFilename(const FXString& string);
98 private:
100  FXFileSelector &operator=(const FXFileSelector&);
101 public:
102  long onCmdAccept(FXObject*,FXSelector,void*);
103  long onCmdFilter(FXObject*,FXSelector,void*);
104  long onCmdItemDblClicked(FXObject*,FXSelector,void*);
105  long onCmdItemSelected(FXObject*,FXSelector,void*);
106  long onCmdItemDeselected(FXObject*,FXSelector,void*);
107  long onCmdDirectoryUp(FXObject*,FXSelector,void*);
108  long onUpdDirectoryUp(FXObject*,FXSelector,void*);
109  long onUpdDirTree(FXObject*,FXSelector,void*);
110  long onCmdDirTree(FXObject*,FXSelector,void*);
111  long onCmdHome(FXObject*,FXSelector,void*);
112  long onCmdWork(FXObject*,FXSelector,void*);
113  long onCmdBookmark(FXObject*,FXSelector,void*);
114  long onCmdUnBookmark(FXObject*,FXSelector,void*);
115  long onCmdVisit(FXObject*,FXSelector,void*);
116  long onCmdNew(FXObject*,FXSelector,void*);
117  long onUpdNew(FXObject*,FXSelector,void*);
118  long onCmdRename(FXObject*,FXSelector,void*);
119  long onCmdCopy(FXObject*,FXSelector,void*);
120  long onCmdMove(FXObject*,FXSelector,void*);
121  long onCmdLink(FXObject*,FXSelector,void*);
122  long onCmdRemove(FXObject*,FXSelector,void*);
123  long onUpdSelected(FXObject*,FXSelector,void*);
124  long onPopupMenu(FXObject*,FXSelector,void*);
125  long onCmdImageSize(FXObject*,FXSelector,void*);
126  long onUpdImageSize(FXObject*,FXSelector,void*);
127  long onUpdNavigable(FXObject*,FXSelector,void*);
128 public:
129  enum {
130  ID_FILEFILTER=FXPacker::ID_LAST,
131  ID_ACCEPT,
132  ID_FILELIST,
133  ID_DIRECTORY_UP,
134  ID_DIRTREE,
135  ID_MINI_SIZE,
136  ID_NORMAL_SIZE,
137  ID_MEDIUM_SIZE,
138  ID_GIANT_SIZE,
139  ID_HOME,
140  ID_WORK,
141  ID_BOOKMARK,
142  ID_UNBOOKMARK,
143  ID_BOOKMENU,
144  ID_VISIT,
145  ID_NEW,
146  ID_RENAME,
147  ID_COPY,
148  ID_MOVE,
149  ID_LINK,
150  ID_REMOVE,
151  ID_LAST
152  };
153 public:
154 
156  FXFileSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
157 
159  FXButton *acceptButton() const { return accept; }
160 
162  FXButton *cancelButton() const { return cancel; }
163 
165  void setFilename(const FXString& path);
166 
168  FXString getFilename() const;
169 
175  FXString* getFilenames() const;
176 
178  void setDirectory(const FXString& path);
179 
181  FXString getDirectory() const;
182 
184  void setSelectMode(FXuint mode);
185 
187  FXuint getSelectMode() const { return selectmode; }
188 
190  void setPattern(const FXString& ptrn);
191 
193  FXString getPattern() const;
194 
196  void setMatchMode(FXuint mode);
197 
199  FXuint getMatchMode() const;
200 
215  void setPatternList(const FXString& patterns);
216 
218  FXString getPatternList() const;
219 
224  void setCurrentPattern(FXint patno);
225 
227  FXint getCurrentPattern() const;
228 
230  void setPatternText(FXint patno,const FXString& text);
231 
233  FXString getPatternText(FXint patno) const;
234 
236  FXint getNumPatterns() const;
237 
239  void allowPatternEntry(FXbool flag);
240 
242  FXbool allowPatternEntry() const;
243 
245  void setItemSpace(FXint s);
246 
248  FXint getItemSpace() const;
249 
251  void setFileBoxStyle(FXuint style);
252 
254  FXuint getFileBoxStyle() const;
255 
257  FXbool showHiddenFiles() const;
258 
260  void showHiddenFiles(FXbool flag);
261 
263  FXbool showImages() const;
264 
266  void showImages(FXbool flag);
267 
269  FXint getImageSize() const;
270 
272  void setImageSize(FXint size);
273 
275  void showReadOnly(FXbool flag);
276 
278  FXbool shownReadOnly() const;
279 
281  void setReadOnly(FXbool flag);
282 
284  FXbool getReadOnly() const;
285 
287  void allowNavigation(FXbool flag){ navigable=flag; }
288 
290  FXbool allowNavigation() const { return navigable; }
291 
293  void setDraggableFiles(FXbool flag);
294 
296  FXbool getDraggableFiles() const;
297 
299  void setTimeFormat(const FXString& fmt);
300 
302  FXString getTimeFormat() const;
303 
305  void setAssociations(FXFileAssociations* assoc,FXbool owned=false);
306 
308  FXFileAssociations* getAssociations() const;
309 
311  void setIconSource(FXIconSource* src);
312 
314  FXIconSource* getIconSource() const;
315 
322  static FXString patternFromText(const FXString& pattern);
323 
329  static FXString extensionFromPattern(const FXString& pattern);
330 
332  virtual void save(FXStream& store) const;
333 
335  virtual void load(FXStream& store);
336 
338  virtual ~FXFileSelector();
339  };
340 
341 }
342 
343 #endif

Copyright © 1997-2016 Jeroen van der Zijp