32 while (w->numChildren() != 0) {
33 FXWindow* child = w->childAtIndex(0);
41 const FXString& file) {
42 if (!FXStat::exists(file)) {
46 FXMessageBox::question(parent, MBOX_YES_NO,
"File Exists",
"Overwrite '%s'?", file.text());
47 if (answer == MBOX_CLICKED_NO) {
56 return FXPath::name(filename);
62 if (filename.length() == 0) {
71 const auto extensions =
parseExtensions(openDialog.getPatternText(openDialog.getCurrentPattern()));
72 const auto filename = openDialog.getFilename();
74 for (
const auto& extension : extensions) {
75 if (extension.length() < filename.length()) {
76 bool sameExtension =
true;
77 for (
auto i = 0; i < extension.length(); i++) {
78 if (filename[i + filename.length() - extension.length()] != extension[i]) {
79 sameExtension =
false;
88 if (extensions.size() > 0) {
89 return filename +
"." + extensions.front();
98 std::vector<FXString> extensions;
100 patternText = patternText.after(
'(');
101 patternText = patternText.before(
')');
103 if (patternText !=
"*") {
106 for (
const auto& extensionStr : extensionsStr) {
107 FXString extension = extensionStr.c_str();
108 extensions.push_back(extension.after(
'.'));
117 FXIcon* icon, FXString& currentFolder) {
119 FXFileDialog opendialog(parent, header);
120 opendialog.setIcon(icon);
121 opendialog.setSelectMode(SELECTFILE_ANY);
122 opendialog.setPatternList(extensions);
123 if (currentFolder.length() != 0) {
124 opendialog.setDirectory(currentFolder);
126 if (!opendialog.execute()) {
133 currentFolder = opendialog.getDirectory();
140 return RGBColor(FXREDVAL(col), FXGREENVAL(col), FXBLUEVAL(col), FXALPHAVAL(col));
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
static void deleteChildren(FXWindow *w)
Deletes all children of the given window.
static FXString getDocumentName(const FXString &filename)
Returns the document name.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependence to an optional file name.
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
static FXbool userPermitsOverwritingWhenFileExists(FXWindow *const parent, const FXString &file)
Returns true if either the file given by its name does not exist or the user allows overwriting it.
static std::vector< FXString > parseExtensions(FXString patternText)
parse extensions
static FXString assureExtension(const FXFileDialog &openDialog)
Corrects missing extension.
unsigned char red() const
Returns the red-amount of the color.
unsigned char alpha() const
Returns the alpha-amount of the color.
unsigned char green() const
Returns the green-amount of the color.
unsigned char blue() const
Returns the blue-amount of the color.
std::vector< std::string > getVector()
return vector of strings