1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/filectrlcmn.cpp
3 // Purpose: Implementation for wxFileCtrlBase and other common functions used by
4 // platform-specific wxFileCtrl's
5 // Author: Diaa M. Sami
8 // Copyright: (c) Diaa M. Sami
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/filectrl.h"
23 # include "wx/debug.h"
26 const char wxFileCtrlNameStr
[] = "wxfilectrl";
28 wxDEFINE_EVENT( wxEVT_FILECTRL_SELECTIONCHANGED
, wxFileCtrlEvent
)
29 wxDEFINE_EVENT( wxEVT_FILECTRL_FILEACTIVATED
, wxFileCtrlEvent
)
30 wxDEFINE_EVENT( wxEVT_FILECTRL_FOLDERCHANGED
, wxFileCtrlEvent
)
32 IMPLEMENT_DYNAMIC_CLASS( wxFileCtrlEvent
, wxCommandEvent
)
34 // some helper functions
36 void GenerateFolderChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
38 wxFileCtrlEvent
event( wxEVT_FILECTRL_FOLDERCHANGED
, wnd
, wnd
->GetId() );
40 event
.SetDirectory( fileCtrl
->GetDirectory() );
42 wnd
->GetEventHandler()->ProcessEvent( event
);
45 void GenerateSelectionChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
47 wxFileCtrlEvent
event( wxEVT_FILECTRL_SELECTIONCHANGED
, wnd
, wnd
->GetId() );
48 event
.SetDirectory( fileCtrl
->GetDirectory() );
50 wxArrayString filenames
;
51 fileCtrl
->GetFilenames( filenames
);
52 event
.SetFiles( filenames
);
54 wnd
->GetEventHandler()->ProcessEvent( event
);
57 void GenerateFileActivatedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
, const wxString filename
)
59 wxFileCtrlEvent
event( wxEVT_FILECTRL_FILEACTIVATED
, wnd
, wnd
->GetId() );
60 event
.SetDirectory( fileCtrl
->GetDirectory() );
62 wxArrayString filenames
;
64 if ( filename
.empty() )
66 fileCtrl
->GetFilenames( filenames
);
70 filenames
.Add( filename
);
73 event
.SetFiles( filenames
);
75 wnd
->GetEventHandler()->ProcessEvent( event
);
78 ///////////////////////////////////////////////////////////////////////////////
79 // wxFileCtrlEvent implementation
80 ///////////////////////////////////////////////////////////////////////////////
82 wxString
wxFileCtrlEvent::GetFile() const
84 wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl
)->HasMultipleFileSelection(),
85 wxT( "Please use GetFiles() to get all files instead of this function" ) );
88 if (m_files
.Count() != 0)
93 #endif // wxUSE_FILECTRL