icon location may contain , so added GetIcon() overload taking MessageParameters
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1fd1788091
commit
11d395f9d7
@ -212,6 +212,8 @@ public:
|
||||
bool GetExtensions(wxArrayString& extensions);
|
||||
// get the icon corresponding to this file type and of the given size
|
||||
bool GetIcon(wxIconLocation *iconloc) const;
|
||||
bool GetIcon(wxIconLocation *iconloc,
|
||||
const MessageParameters& params) const;
|
||||
// get a brief file type description ("*.txt" => "text document")
|
||||
bool GetDescription(wxString *desc) const;
|
||||
|
||||
|
@ -285,6 +285,25 @@ bool wxFileType::GetIcon(wxIconLocation *iconLoc) const
|
||||
return m_impl->GetIcon(iconLoc);
|
||||
}
|
||||
|
||||
bool
|
||||
wxFileType::GetIcon(wxIconLocation *iconloc,
|
||||
const MessageParameters& params) const
|
||||
{
|
||||
if ( !GetIcon(iconloc) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// we may have "%s" in the icon location string, at least under Windows, so
|
||||
// expand this
|
||||
if ( iconloc )
|
||||
{
|
||||
iconloc->SetFileName(ExpandCommand(iconloc->GetFileName(), params));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFileType::GetDescription(wxString *desc) const
|
||||
{
|
||||
wxCHECK_MSG( desc, FALSE, _T("invalid parameter in GetDescription") );
|
||||
|
@ -77,6 +77,33 @@ class WXDLLEXPORT wxIcon;
|
||||
// location, uses it, so it isn't likely to change
|
||||
static const wxChar *MIME_DATABASE_KEY = wxT("MIME\\Database\\Content Type\\");
|
||||
|
||||
// this function replaces Microsoft %1 with Unix-like %s
|
||||
static bool CanonicalizeParams(wxString& command)
|
||||
{
|
||||
// transform it from '%1' to '%s' style format string (now also test for %L
|
||||
// as apparently MS started using it as well for the same purpose)
|
||||
|
||||
// NB: we don't make any attempt to verify that the string is valid, i.e.
|
||||
// doesn't contain %2, or second %1 or .... But we do make sure that we
|
||||
// return a string with _exactly_ one '%s'!
|
||||
bool foundFilename = false;
|
||||
size_t len = command.length();
|
||||
for ( size_t n = 0; (n < len) && !foundFilename; n++ )
|
||||
{
|
||||
if ( command[n] == wxT('%') &&
|
||||
(n + 1 < len) &&
|
||||
(command[n + 1] == wxT('1') || command[n + 1] == wxT('L')) )
|
||||
{
|
||||
// replace it with '%s'
|
||||
command[n + 1] = wxT('s');
|
||||
|
||||
foundFilename = true;
|
||||
}
|
||||
}
|
||||
|
||||
return foundFilename;
|
||||
}
|
||||
|
||||
void wxFileTypeImpl::Init(const wxString& strFileType, const wxString& ext)
|
||||
{
|
||||
// VZ: does it? (FIXME)
|
||||
@ -202,26 +229,7 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const
|
||||
if ( key.Open() ) {
|
||||
// it's the default value of the key
|
||||
if ( key.QueryValue(wxEmptyString, command) ) {
|
||||
// transform it from '%1' to '%s' style format string (now also
|
||||
// test for %L - apparently MS started using it as well for the
|
||||
// same purpose)
|
||||
|
||||
// NB: we don't make any attempt to verify that the string is valid,
|
||||
// i.e. doesn't contain %2, or second %1 or .... But we do make
|
||||
// sure that we return a string with _exactly_ one '%s'!
|
||||
bool foundFilename = FALSE;
|
||||
size_t len = command.Len();
|
||||
for ( size_t n = 0; (n < len) && !foundFilename; n++ ) {
|
||||
if ( command[n] == wxT('%') &&
|
||||
(n + 1 < len) &&
|
||||
(command[n + 1] == wxT('1') ||
|
||||
command[n + 1] == wxT('L')) ) {
|
||||
// replace it with '%s'
|
||||
command[n + 1] = wxT('s');
|
||||
|
||||
foundFilename = TRUE;
|
||||
}
|
||||
}
|
||||
bool foundFilename = CanonicalizeParams(command);
|
||||
|
||||
#if wxUSE_IPC
|
||||
// look whether we must issue some DDE requests to the application
|
||||
@ -251,7 +259,8 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_IPC
|
||||
if ( !foundFilename ) {
|
||||
if ( !foundFilename )
|
||||
{
|
||||
// we didn't find any '%1' - the application doesn't know which
|
||||
// file to open (note that we only do it if there is no DDEExec
|
||||
// subkey)
|
||||
|
Loading…
Reference in New Issue
Block a user