本文整理汇总了C++中wxFileName::HasExt方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFileName::HasExt方法的具体用法?C++ wxFileName::HasExt怎么用?C++ wxFileName::HasExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFileName
的用法示例。
在下文中一共展示了wxFileName::HasExt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
const wxString& defaultDir,
const wxString& defaultFileName,
const wxString& wildCard,
long style, const wxPoint& pos,
const wxSize& sz,
const wxString& name)
{
parent = GetParentForModalDialog(parent, style);
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, sz, name))
{
return false;
}
if (!PreCreation(parent, pos, wxDefaultSize) ||
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
wxDefaultValidator, wxT("filedialog")))
{
wxFAIL_MSG( wxT("wxFileDialog creation failed") );
return false;
}
GtkFileChooserAction gtk_action;
GtkWindow* gtk_parent = NULL;
if (parent)
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
const gchar* ok_btn_stock;
if ( style & wxFD_SAVE )
{
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
ok_btn_stock = GTK_STOCK_SAVE;
}
else
{
gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN;
ok_btn_stock = GTK_STOCK_OPEN;
}
m_widget = gtk_file_chooser_dialog_new(
wxGTK_CONV(m_message),
gtk_parent,
gtk_action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
ok_btn_stock, GTK_RESPONSE_ACCEPT,
NULL);
g_object_ref(m_widget);
GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget);
m_fc.SetWidget(file_chooser);
gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
if ( style & wxFD_MULTIPLE )
gtk_file_chooser_set_select_multiple(file_chooser, true);
// gtk_widget_hide_on_delete is used here to avoid that Gtk automatically
// destroys the dialog when the user press ESC on the dialog: in that case
// a second call to ShowModal() would result in a bunch of Gtk-CRITICAL
// errors...
g_signal_connect(m_widget,
"delete_event",
G_CALLBACK (gtk_widget_hide_on_delete),
this);
// local-only property could be set to false to allow non-local files to be
// loaded. In that case get/set_uri(s) should be used instead of
// get/set_filename(s) everywhere and the GtkFileChooserDialog should
// probably also be created with a backend, e.g. "gnome-vfs", "default", ...
// (gtk_file_chooser_dialog_new_with_backend). Currently local-only is kept
// as the default - true:
// gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);
g_signal_connect (m_widget, "response",
G_CALLBACK (gtk_filedialog_response_callback), this);
g_signal_connect (m_widget, "selection-changed",
G_CALLBACK (gtk_filedialog_selchanged_callback), this);
// deal with extensions/filters
SetWildcard(wildCard);
wxString defaultFileNameWithExt = defaultFileName;
if ( !wildCard.empty() && !defaultFileName.empty() &&
!wxFileName(defaultFileName).HasExt() )
{
// append the default extension, if any, to the initial file name: GTK
// won't do it for us by default (unlike e.g. MSW)
const wxFileName fnWC(m_fc.GetCurrentWildCard());
if ( fnWC.HasExt() )
{
// Notice that we shouldn't append the extension if it's a wildcard
// because this is not useful: the user would need to change it to use
// some fixed extension anyhow.
const wxString& ext = fnWC.GetExt();
if ( ext.find_first_of("?*") == wxString::npos )
defaultFileNameWithExt << "." << ext;
}
//.........这里部分代码省略.........