forked from ennorehling/csmapfx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FXFileDialogEx.h
156 lines (122 loc) · 4.43 KB
/
FXFileDialogEx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/***********************************-*- mode: c++; tab-width: 2 -*-*\
*
* NAME:
* FXFileDialogEx - File dialog using native dialog
*
* AUTHOR:
* Daniel Gehriger (gehriger@linkcad.com)
*
* Copyright (c) 1999 by Daniel Gehriger. All Rights Reserved.
*
* PUPROSE:
* File dialog using native Common Controls dialog
*
* NOTE
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: FXFileDialogEx.h 101 2006-07-23 02:57:31Z phygon $
*
* HISTORY:
* dgehrige - Dec, 10 1999: Created.
*
\*******************************************************************/
#ifndef FXFILEDIALOGEX_H
#define FXFILEDIALOGEX_H
// use commctl32 dialog on Win32, or normal FXFileDialog for other platforms
#if !defined(WIN32)
#include <fx.h>
#define FXFileDialogEx FXFileDialog
#define DLGEX_SAVE 0
#else
#include <FXObject.h>
using namespace FX;
namespace FXEX {}
using namespace FXEX;
#ifndef _INC_COMMDLG
struct OPENFILENAMEW;
#endif
namespace FXEX {
#define FXFileDialog FXFileDialogEx
/// File dialog options
#define DLGEX_SAVE 0x00100000 // "Save" dialog box
#define DLGEX_CREATEPROMPT 0x00400000 // -> OFN_CREATEPROMPT
#define DLGEX_READONLY 0x00800000 // -> OFN_READONLY
#define DLGEX_PATHMUSTEXIST 0x01000000 // -> OFN_PATHMUSTEXIST
#define DLGEX_FILEMUSTEXIST 0x02000000 // -> OFN_FILEMUSTEXIST
#define DLGEX_HIDEREADONLY 0x04000000 // -> OFN_HIDEREADONLY
#define DLGEX_OVERWRITEPROMPT 0x08000000 // -> OFN_OVERWRITEPROMPT
/**
* Use comctl32 dialog under WIN32 for file dialog cases
*/
class FXAPI FXFileDialogEx : public FXObject {
FXDECLARE(FXFileDialogEx)
protected:
OPENFILENAMEW *m_ofn; // low-level access to OPENFILENAMEW
FXuint m_opts;
FXchar **m_pszFoxPats;
FXchar *m_pszFoxCustomPat;
FXint m_nFoxPats;
FXString *m_filenames;
FXWindow *m_owner;
private:
FXFileDialogEx(const FXFileDialogEx&);
FXFileDialogEx& operator=(const FXFileDialogEx&);
// get FOX patterns into Win32 patterns
void getWinPattern(FXchar*& pszWinPat, const FXchar* pszFoxPat) const;
protected:
FXFileDialogEx();
public:
// ctor
FXFileDialogEx(FXWindow* owner,const FXString& title,FXuint opts=0,FXint x=0,FXint y=0,FXint w=500,FXint h=300);
/// Run modal invocation of the dialog
FXuint execute(FXuint placement = PLACEMENT_CURSOR); // parameter is for compatibility
/// set the initial file name/path
void setFilename(const FXString& path);
/// set the initial directory
void setDirectory(const FXString& path);
/// set the inital pattern
void setPattern(const FXString& ptrn);
/// set the pattern list
void setPatternList(const FXString& ptrns);
/// select the inital pattern from the list (zero based)
void setCurrentPattern(FXint n);
/// modify pattern list
void setPatternText(FXint patno,const FXString& text);
/// get the selected file path
FXString getFilename() const;
/// get the selected file extension
FXString getPattern() const;
/// get the selected directory
FXString getDirectory() const;
/// get index of selected pattern in the list (zero based)
FXint getCurrentPattern() const;
/// get a pattern by index
FXString getPatternText(FXint patno) const;
/// get multiple files
FXString* getFilenames();
/// set the title of the dialog
void setTitle(const FXString& name);
/// get the title of the dialog
FXString getTitle() const;
/// set icon of dialog (no-op)
void setIcon(FXIcon* icon);
/// set select mode
void setSelectMode(int mode);
// dtor
virtual ~FXFileDialogEx();
};
} // namespace FXEX
#endif /* use commctl32 dialog */
#endif /* FXFILEDIALOGEX_H */