wxFileDialog::SetWildcard() and case sensitivity

Ian Britten britten at caris.com
Wed Sep 5 08:34:53 PDT 2007


Vadim Zeitlin wrote:
> On Tue, 04 Sep 2007 17:11:18 -0300 Ian Britten <britten at caris.com> wrote:
> 
> IB> [ wxGTK, wxMSW v2.8.4 ]
> IB> 
> IB> Is it possible (And portable!) to set some sort of case-insensitive
> IB> behaviour for the wildcard handling of the wxFileDialog?
> 
>  It isn't possible to do it currently but it could be implemented for
> wxGTK. Currently our code uses gtk_file_chooser_add_filter() to construct
> the filter which is used by GTK+ file chooser widget and this is supposed
> to allow for shell-style patterns so using "[jJ][pP][gG]" should work (I
> didn't test it though).

Hey! That seems to work! (I wasn't sure it could, nor the Regex syntax...)

Something like:
     openDialog = new wxFileDialog(
                         this, _T("Open file"), _T(""), _T(""),
                         _T("JPG Image (.jpg)|*.[jJ][pP][gG]"),
                         wxOPEN | wxFILE_MUST_EXIST);
allows me to pick either an upper, lower, or mixed case extension!
[ wxGTK 2.8.4, GTK 2.6.4 ]

Does anyone know what will happen with this on wxMSW?  Will I have to
ifdef the code (Ugh!), or will it work ok (Somehow)?
[ I'll try to find someone to try it here, but there's not many wxMSW
developers, and I'd like to know from an expert, rather than just from
some experimentation... ]



Note that some of the other comments/replies to this drifted into
discussions about MIME types, default WX behaviour, etc.  Although
I appreciate the discussion, I think it drifted off-topic of what I was
looking for.  I'll just give a general reply to those points here:

First, my example using JPG was just an example.  In my real case, it's
custom files, so I really don't know how (or why) I'd look at the MIME
type stuff.  I'm not actually interested in images in this case...
[ Feel free to educate me though, but I'd like to stick with WX code,
not GTK (or MSW) specific stuff... ]

Second, I was not suggesting/requesting that the default behaviour of
WX be changed to handle files/extensions case-insensitively -  I don't
think that would be correct...
What I was looking for (And got, at least on wxGTK) is a hook to allow
me to choose if/when to allow a case-insensitive file extension to be
used, based on the context of what my app is doing.
However, now that I see that it works, I may end up using it in all
my places in my app - It nicely solves this recurring frustration...



Hmmm... after thinking about this more, I do think some sort of
wxINSENSITIVE_EXTENSION option to the wxFileDialog would be a nice
addition:
- On wxMSW, nothing would need to be done (Insensitive by default)
- On wxGTK, inject the [] characters into the given wildcard pattern
- On wxOSX, ... (Dunno... )

Anyways, just a suggestion.  Keep up the great work!
Ian




More information about the wx-users mailing list