#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_FILEDLG
#error wxGenericFileDialog currently only supports Unix, win32 and DOS
#endif
-#include "wx/checkbox.h"
-#include "wx/textctrl.h"
-#include "wx/choice.h"
-#include "wx/checkbox.h"
-#include "wx/stattext.h"
-#include "wx/debug.h"
-#include "wx/log.h"
+#ifndef WX_PRECOMP
+ #include "wx/hash.h"
+ #include "wx/intl.h"
+ #include "wx/settings.h"
+ #include "wx/log.h"
+ #include "wx/msgdlg.h"
+ #include "wx/bmpbuttn.h"
+ #include "wx/checkbox.h"
+ #include "wx/choice.h"
+ #include "wx/stattext.h"
+ #include "wx/textctrl.h"
+ #include "wx/sizer.h"
+ #include "wx/filedlg.h" // wxFD_OPEN, wxFD_SAVE...
+#endif
+
#include "wx/longlong.h"
-#include "wx/intl.h"
-#include "wx/msgdlg.h"
-#include "wx/sizer.h"
-#include "wx/bmpbuttn.h"
#include "wx/tokenzr.h"
#include "wx/config.h"
#include "wx/imaglist.h"
#include "wx/dir.h"
#include "wx/artprov.h"
-#include "wx/settings.h"
#include "wx/filefn.h"
#include "wx/file.h" // for wxS_IXXX constants only
-#include "wx/filedlg.h" // wxOPEN, wxSAVE...
#include "wx/generic/filedlgg.h"
#include "wx/generic/dirctrlg.h" // for wxFileIconsTable
#endif
#ifndef __WXWINCE__
-#include <sys/types.h>
-#include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
#endif
#ifdef __UNIX__
NULL);
if (fileHandle != INVALID_HANDLE_VALUE)
- {
+ {
m_size = GetFileSize(fileHandle, 0);
CloseHandle(fileHandle);
}
m_dateTime = buff.st_mtime;
#endif
// __WXWINCE__
-
+
#if defined(__UNIX__)
m_permissions.Printf(_T("%c%c%c%c%c%c%c%c%c"),
buff.st_mode & wxS_IRUSR ? _T('r') : _T('-'),
buff.st_mode & wxS_IWOTH ? _T('w') : _T('-'),
buff.st_mode & wxS_IXOTH ? _T('x') : _T('-'));
#elif defined(__WIN32__)
- DWORD attribs = GetFileAttributes(m_filePath.fn_str());
+ DWORD attribs = ::GetFileAttributes(m_filePath.c_str());
if (attribs != (DWORD)-1)
{
m_permissions.Printf(_T("%c%c%c%c"),
{
if (!IsTopMostDir(m_dirName))
{
- size_t len = m_dirName.Len();
+ size_t len = m_dirName.length();
if (wxEndsWithPathSeparator(m_dirName))
m_dirName.Remove( len-1, 1 );
wxString fname( wxFileNameFromPath(m_dirName) );
const wxString& wildCard,
long style,
const wxPoint& pos,
+ const wxSize& sz,
+ const wxString& name,
bool bypassGenericImpl ) : wxFileDialogBase()
{
Init();
- Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, bypassGenericImpl );
+ Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name, bypassGenericImpl );
}
bool wxGenericFileDialog::Create( wxWindow *parent,
const wxString& wildCard,
long style,
const wxPoint& pos,
+ const wxSize& sz,
+ const wxString& name,
bool bypassGenericImpl )
{
m_bypassGenericImpl = bypassGenericImpl;
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile,
- wildCard, style, pos))
+ wildCard, style, pos, sz, name))
{
return false;
}
if (m_bypassGenericImpl)
return true;
- if (!wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ))
+ if (!wxDialog::Create( parent, wxID_ANY, message, pos, sz,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, name
+ ))
{
return false;
}
&ms_lastShowHidden);
}
- if (m_dialogStyle == 0)
- m_dialogStyle = wxOPEN;
- if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
- m_dialogStyle |= wxOPEN;
-
if ((m_dir.empty()) || (m_dir == wxT(".")))
{
m_dir = wxGetCwd();
m_dir = wxFILE_SEP_PATH;
}
- size_t len = m_dir.Len();
+ size_t len = m_dir.length();
if ((len > 1) && (wxEndsWithPathSeparator(m_dir)))
m_dir.Remove( len-1, 1 );
mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
long style2 = ms_lastViewStyle;
- if ( !(m_dialogStyle & wxMULTIPLE) )
+ if ( !HasFlag(wxFD_MULTIPLE) )
style2 |= wxLC_SINGLE_SEL;
#ifdef __WXWINCE__
mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 );
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
- m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxPROCESS_ENTER );
+ m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
textsizer->Add( m_text, 1, wxCENTER | wxALL, 5 );
mainsizer->Add( textsizer, 0, wxEXPAND );
m_choice = new wxChoice( this, ID_CHOICE );
textsizer->Add( m_choice, 1, wxCENTER|wxALL, 5 );
- buttonsizer = new wxBoxSizer( wxHORIZONTAL );
- buttonsizer->Add( new wxButton( this, wxID_OK ), 0, wxCENTER | wxALL, 5 );
- buttonsizer->Add( new wxButton( this, wxID_CANCEL ), 0, wxCENTER | wxALL, 5 );
- mainsizer->Add( buttonsizer, 0, wxALIGN_RIGHT );
+ wxSizer *bsizer = CreateButtonSizer( wxOK|wxCANCEL , false, 5 );
+ if(bsizer->GetChildren().GetCount() > 0 )
+ {
+ mainsizer->Add( bsizer, 0, wxEXPAND | wxALL, 5 );
+ }
+ else
+ {
+ delete bsizer;
+ }
}
else
{
mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
- m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxPROCESS_ENTER );
+ m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
textsizer->Add( m_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
textsizer->Add( new wxButton( this, wxID_OK ), 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
mainsizer->Add( textsizer, 0, wxEXPAND );
Centre( wxBOTH );
}
-
+
m_text->SetFocus();
-
+
ignoreChanges = false;
return true;
void wxGenericFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
{
- wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
- cevent.SetEventObject( this );
- GetEventHandler()->ProcessEvent( cevent );
+ HandleAction( m_text->GetValue() );
}
void wxGenericFileDialog::OnTextChange( wxCommandEvent &WXUNUSED(event) )
// No double-click on most WinCE devices, so do action immediately.
HandleAction( filename );
#else
- if (filename == wxT("..")) return;
+ if (filename == wxT(".."))
+ {
+ inSelected = false;
+ return;
+ }
wxString dir = m_list->GetDir();
if (!IsTopMostDir(dir))
dir += wxFILE_SEP_PATH;
dir += filename;
- if (wxDirExists(dir)) return;
+ if (wxDirExists(dir))
+ {
+ inSelected = false;
+ return;
+ }
ignoreChanges = true;
m_text->SetValue( filename );
return;
wxString filename( fn );
- wxString dir = m_list->GetDir();
- if (filename.empty()) return;
+ if (filename.empty())
+ {
+#ifdef __WXWINCE__
+ EndModal(wxID_CANCEL);
+#endif
+ return;
+ }
if (filename == wxT(".")) return;
+ wxString dir = m_list->GetDir();
+
// "some/place/" means they want to chdir not try to load "place"
bool want_dir = filename.Last() == wxFILE_SEP_PATH;
if (want_dir)
}
#endif // __UNIX__
- if (!(m_dialogStyle & wxSAVE))
+ if (!HasFlag(wxFD_SAVE))
{
if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
(filename.Find(wxT('?')) != wxNOT_FOUND))
// VZ: the logic of testing for !wxFileExists() only for the open file
// dialog is not entirely clear to me, why don't we allow saving to a
// file without extension as well?
- if ( !(m_dialogStyle & wxOPEN) || !wxFileExists(filename) )
+ if ( !HasFlag(wxFD_OPEN) || !wxFileExists(filename) )
{
filename = AppendExtension(filename, m_filterExtension);
}
// check that the file [doesn't] exist if necessary
- if ( (m_dialogStyle & wxSAVE) &&
- (m_dialogStyle & wxOVERWRITE_PROMPT) &&
+ if ( HasFlag(wxFD_SAVE) && HasFlag(wxFD_OVERWRITE_PROMPT) &&
wxFileExists( filename ) )
{
wxString msg;
if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
return;
}
- else if ( (m_dialogStyle & wxOPEN) &&
- (m_dialogStyle & wxFILE_MUST_EXIST) &&
+ else if ( HasFlag(wxFD_OPEN) && HasFlag(wxFD_FILE_MUST_EXIST) &&
!wxFileExists(filename) )
{
wxMessageBox(_("Please choose an existing file."), _("Error"),
SetPath( filename );
// change to the directory where the user went if asked
- if ( m_dialogStyle & wxCHANGE_DIR )
+ if ( HasFlag(wxFD_CHANGE_DIR) )
{
wxString cwd;
wxSplitPath(filename, &cwd, NULL, NULL);
}
}
- wxCommandEvent event;
- wxDialog::OnOK(event);
+ EndModal(wxID_OK);
}
void wxGenericFileDialog::OnListOk( wxCommandEvent &WXUNUSED(event) )
#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
}
-#ifdef USE_GENERIC_FILEDIALOG
+#ifdef wxUSE_GENERIC_FILEDIALOG
IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog)
-#endif // USE_GENERIC_FILEDIALOG
+#endif // wxUSE_GENERIC_FILEDIALOG
#endif // wxUSE_FILEDLG