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,2024 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=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
157 
159  virtual void create();
160 
162  FXButton *acceptButton() const { return accept; }
163 
165  FXButton *cancelButton() const { return cancel; }
166 
168  void setFilename(const FXString& path);
169 
171  FXString getFilename() const;
172 
178  FXString* getFilenames() const;
179 
181  void setDirectory(const FXString& path);
182 
184  FXString getDirectory() const;
185 
187  void setSelectMode(FXuint mode);
188 
190  FXuint getSelectMode() const { return selectmode; }
191 
193  void setPattern(const FXString& ptrn);
194 
196  FXString getPattern() const;
197 
199  void setMatchMode(FXuint mode);
200 
202  FXuint getMatchMode() const;
203 
218  void setPatternList(const FXString& patterns);
219 
221  FXString getPatternList() const;
222 
227  void setCurrentPattern(FXint patno);
228 
230  FXint getCurrentPattern() const;
231 
233  void setPatternText(FXint patno,const FXString& text);
234 
236  FXString getPatternText(FXint patno) const;
237 
239  FXint getNumPatterns() const;
240 
242  void allowPatternEntry(FXbool flag);
243 
245  FXbool allowPatternEntry() const;
246 
248  void setItemSpace(FXint s);
249 
251  FXint getItemSpace() const;
252 
254  void setFileBoxStyle(FXuint style);
255 
257  FXuint getFileBoxStyle() const;
258 
260  FXbool showHiddenFiles() const;
261 
263  void showHiddenFiles(FXbool flag);
264 
266  FXbool showImages() const;
267 
269  void showImages(FXbool flag);
270 
272  FXint getImageSize() const;
273 
275  void setImageSize(FXint size);
276 
278  void showReadOnly(FXbool flag);
279 
281  FXbool shownReadOnly() const;
282 
284  void setReadOnly(FXbool flag);
285 
287  FXbool getReadOnly() const;
288 
290  void allowNavigation(FXbool flag);
291 
293  FXbool allowNavigation() const { return navigable; }
294 
296  void setDraggableFiles(FXbool flag);
297 
299  FXbool getDraggableFiles() const;
300 
302  void setTimeFormat(const FXString& fmt);
303 
305  FXString getTimeFormat() const;
306 
308  void setAssociations(FXFileAssociations* assoc,FXbool owned=false);
309 
311  FXFileAssociations* getAssociations() const;
312 
314  void setIconSource(FXIconSource* src);
315 
317  FXIconSource* getIconSource() const;
318 
325  static FXString patternFromText(const FXString& pattern);
326 
332  static FXString extensionFromPattern(const FXString& pattern);
333 
335  virtual void save(FXStream& store) const;
336 
338  virtual void load(FXStream& store);
339 
341  virtual ~FXFileSelector();
342  };
343 
344 }
345 
346 #endif
The Matrix layout manager automatically arranges its child windows in rows and columns.
Definition: FXMatrix.h:56
A File List widget provides an icon rich view of the file system.
Definition: FXFileList.h:131
FXbool allowNavigation() const
Is navigation allowed?
Definition: FXFileSelector.h:293
An icon source is a class that loads an icon of any type.
Definition: FXIconSource.h:47
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:70
Base composite.
Definition: FXComposite.h:32
Horizontal frame layout manager widget is used to automatically place child-windows horizontally from...
Definition: FXHorizontalFrame.h:36
A Check Button is a tri-state button.
Definition: FXCheckButton.h:54
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
Definition: FX4Splitter.h:28
FXButton * cancelButton() const
Return a pointer to the "Cancel" button.
Definition: FXFileSelector.h:165
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
FXuint getSelectMode() const
Return file selection mode.
Definition: FXFileSelector.h:190
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:48
A text field is a single-line text entry widget.
Definition: FXTextField.h:63
The FileAssociations object manages file associations between a file extension and a FileAssoc record...
Definition: FXFileAssociations.h:101
A Directory Box widget allows the user to select parts of a file path.
Definition: FXDirBox.h:49
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
The Recent Files group manages a most recently used (MRU) file list by means of the standard system r...
Definition: FXRecentFiles.h:49
A Combo Box provides a way to select a string from a list of strings.
Definition: FXComboBox.h:65
FXButton * acceptButton() const
Return a pointer to the "Accept" button.
Definition: FXFileSelector.h:162
Popup menu pane.
Definition: FXMenuPane.h:32
File selection widget.
Definition: FXFileSelector.h:57
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp