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,2025 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 FXPathBox;
37 class FXButton;
38 class FXMenuButton;
39 class FXIcon;
40 class FXMenuPane;
41 class FXCheckButton;
42 class FXMatrix;
43 class FXIconSource;
44 class FXHorizontalFrame;
45 
46 
48 enum {
49  SELECTFILE_ANY,
50  SELECTFILE_EXISTING,
51  SELECTFILE_MULTIPLE,
52  SELECTFILE_MULTIPLE_ALL,
53  SELECTFILE_DIRECTORY
54  };
55 
56 #define PATHBOX 1
57 
59 class FXAPI FXFileSelector : public FXPacker {
60  FXDECLARE(FXFileSelector)
61 protected:
62  FXFileList *filebox; // File list widget
63  FXTextField *filename; // File name entry field
64  FXComboBox *filefilter; // Combobox for pattern list
65  // FXComboBox *encodinglist; // Combobox for encoding list
66  FXMenuPane *bookmarkmenu; // Menu for bookmarks
67  FXHorizontalFrame *navbuttons; // Navigation buttons
68  FXHorizontalFrame *fileboxframe; // Frame around file list
69  FXMatrix *entryblock; // Entry block
70  FXCheckButton *readonly; // Open file as read only
71 #if defined(PATHBOX)
72  FXPathBox *dirbox; // Directory hierarchy list
73 #else
74  FXDirBox *dirbox; // Directory hierarchy list
75 #endif
76  FXButton *accept; // Accept button
77  FXButton *cancel; // Cancel button
78  FXIcon *updiricon; // Up directory icon
79  FXIcon *listicon; // List mode icon
80  FXIcon *detailicon; // Detail mode icon
81  FXIcon *iconsicon; // Icon mode icon
82  FXIcon *homeicon; // Go home icon
83  FXIcon *workicon; // Go home icon
84  FXIcon *shownicon; // Files shown icon
85  FXIcon *hiddenicon; // Files hidden icon
86  FXIcon *bookmarkicon; // Book mark icon
87  FXIcon *bookaddicon; // Book add icon
88  FXIcon *bookdelicon; // Book delete icon
89  FXIcon *bookclricon; // Book clear icon
90  FXIcon *sortingicon; // Sorting icon
91  FXIcon *newicon; // New directory icon
92  FXIcon *renameicon; // Rename file icon
93  FXIcon *copyicon; // Copy file icon
94  FXIcon *moveicon; // Rename file icon
95  FXIcon *linkicon; // Link file icon
96  FXIcon *deleteicon; // Delete file icon
97  FXRecentFiles bookmarks; // Bookmarked places
98  FXuint selectmode; // Select mode
99  FXbool navigable; // May navigate
100 protected:
101  FXFileSelector(){}
102  static FXint countFilenames(const FXString& string);
103  static FXString decodeFilename(const FXString& string,FXint n=0);
104  static FXString encodeFilename(const FXString& string);
105 private:
107  FXFileSelector &operator=(const FXFileSelector&);
108 public:
109  long onCmdAccept(FXObject*,FXSelector,void*);
110  long onCmdFilter(FXObject*,FXSelector,void*);
111  long onCmdItemDblClicked(FXObject*,FXSelector,void*);
112  long onCmdItemSelected(FXObject*,FXSelector,void*);
113  long onCmdItemDeselected(FXObject*,FXSelector,void*);
114  long onCmdDirectoryUp(FXObject*,FXSelector,void*);
115  long onUpdDirectoryUp(FXObject*,FXSelector,void*);
116  long onCmdDirTree(FXObject*,FXSelector,void*);
117  long onCmdHome(FXObject*,FXSelector,void*);
118  long onCmdWork(FXObject*,FXSelector,void*);
119  long onCmdBookmark(FXObject*,FXSelector,void*);
120  long onCmdUnBookmark(FXObject*,FXSelector,void*);
121  long onCmdVisit(FXObject*,FXSelector,void*);
122  long onCmdNew(FXObject*,FXSelector,void*);
123  long onUpdNew(FXObject*,FXSelector,void*);
124  long onCmdRename(FXObject*,FXSelector,void*);
125  long onCmdCopy(FXObject*,FXSelector,void*);
126  long onCmdMove(FXObject*,FXSelector,void*);
127  long onCmdLink(FXObject*,FXSelector,void*);
128  long onCmdRemove(FXObject*,FXSelector,void*);
129  long onUpdSelected(FXObject*,FXSelector,void*);
130  long onPopupMenu(FXObject*,FXSelector,void*);
131  long onCmdImageSize(FXObject*,FXSelector,void*);
132  long onUpdImageSize(FXObject*,FXSelector,void*);
133  long onUpdNavigable(FXObject*,FXSelector,void*);
134 public:
135  enum {
136  ID_FILEFILTER=FXPacker::ID_LAST,
137  ID_ACCEPT,
138  ID_FILELIST,
139  ID_DIRECTORY_UP,
140  ID_DIRTREE,
141  ID_MINI_SIZE,
142  ID_NORMAL_SIZE,
143  ID_MEDIUM_SIZE,
144  ID_GIANT_SIZE,
145  ID_HOME,
146  ID_WORK,
147  ID_BOOKMARK,
148  ID_UNBOOKMARK,
149  ID_BOOKMENU,
150  ID_VISIT,
151  ID_NEW,
152  ID_RENAME,
153  ID_COPY,
154  ID_MOVE,
155  ID_LINK,
156  ID_REMOVE,
157  ID_LAST
158  };
159 public:
160 
162  FXFileSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
163 
165  virtual void create();
166 
168  FXButton *acceptButton() const { return accept; }
169 
171  FXButton *cancelButton() const { return cancel; }
172 
174  void setFilename(const FXString& path);
175 
177  FXString getFilename() const;
178 
184  FXString* getFilenames() const;
185 
187  void setDirectory(const FXString& path);
188 
190  FXString getDirectory() const;
191 
193  void setSelectMode(FXuint mode);
194 
196  FXuint getSelectMode() const { return selectmode; }
197 
199  void setPattern(const FXString& ptrn);
200 
202  FXString getPattern() const;
203 
205  void setMatchMode(FXuint mode);
206 
208  FXuint getMatchMode() const;
209 
224  void setPatternList(const FXString& patterns);
225 
227  FXString getPatternList() const;
228 
233  void setCurrentPattern(FXint patno);
234 
236  FXint getCurrentPattern() const;
237 
239  void setPatternText(FXint patno,const FXString& text);
240 
242  FXString getPatternText(FXint patno) const;
243 
245  FXint getNumPatterns() const;
246 
248  void allowPatternEntry(FXbool flag);
249 
251  FXbool allowPatternEntry() const;
252 
254  void setItemSpace(FXint s);
255 
257  FXint getItemSpace() const;
258 
260  void setFileBoxStyle(FXuint style);
261 
263  FXuint getFileBoxStyle() const;
264 
266  void setSortOrder(FXuint order);
267 
269  FXuint getSortOrder() const;
270 
272  FXbool showHiddenFiles() const;
273 
275  void showHiddenFiles(FXbool flag);
276 
278  FXbool showImages() const;
279 
281  void showImages(FXbool flag);
282 
284  FXint getImageSize() const;
285 
287  void setImageSize(FXint size);
288 
290  void showReadOnly(FXbool flag);
291 
293  FXbool shownReadOnly() const;
294 
296  void setReadOnly(FXbool flag);
297 
299  FXbool getReadOnly() const;
300 
302  void allowNavigation(FXbool flag);
303 
305  FXbool allowNavigation() const { return navigable; }
306 
308  void setDraggableFiles(FXbool flag);
309 
311  FXbool getDraggableFiles() const;
312 
314  void setTimeFormat(const FXString& fmt);
315 
317  FXString getTimeFormat() const;
318 
320  void setAssociations(FXFileAssociations* assoc,FXbool owned=false);
321 
323  FXFileAssociations* getAssociations() const;
324 
326  void setIconSource(FXIconSource* src);
327 
329  FXIconSource* getIconSource() const;
330 
337  static FXString patternFromText(const FXString& pattern);
338 
344  static FXString extensionFromPattern(const FXString& pattern);
345 
347  virtual void save(FXStream& store) const;
348 
350  virtual void load(FXStream& store);
351 
353  virtual ~FXFileSelector();
354  };
355 
356 }
357 
358 #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:305
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:171
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:196
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
Path selection widget.
Definition: FXPathBox.h:47
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:168
Popup menu pane.
Definition: FXMenuPane.h:32
File selection widget.
Definition: FXFileSelector.h:59
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp