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
);
31 wxDEFINE_EVENT( wxEVT_FILECTRL_FILTERCHANGED
, wxFileCtrlEvent
);
33 IMPLEMENT_DYNAMIC_CLASS( wxFileCtrlEvent
, wxCommandEvent
)
35 // some helper functions
37 void GenerateFilterChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
39 wxFileCtrlEvent
event( wxEVT_FILECTRL_FILTERCHANGED
, wnd
, wnd
->GetId() );
41 event
.SetFilterIndex( fileCtrl
->GetFilterIndex() );
43 wnd
->GetEventHandler()->ProcessEvent( event
);
46 void GenerateFolderChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
48 wxFileCtrlEvent
event( wxEVT_FILECTRL_FOLDERCHANGED
, wnd
, wnd
->GetId() );
50 event
.SetDirectory( fileCtrl
->GetDirectory() );
52 wnd
->GetEventHandler()->ProcessEvent( event
);
55 void GenerateSelectionChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
57 wxFileCtrlEvent
event( wxEVT_FILECTRL_SELECTIONCHANGED
, wnd
, wnd
->GetId() );
58 event
.SetDirectory( fileCtrl
->GetDirectory() );
60 wxArrayString filenames
;
61 fileCtrl
->GetFilenames( filenames
);
62 event
.SetFiles( filenames
);
64 wnd
->GetEventHandler()->ProcessEvent( event
);
67 void GenerateFileActivatedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
, const wxString filename
)
69 wxFileCtrlEvent
event( wxEVT_FILECTRL_FILEACTIVATED
, wnd
, wnd
->GetId() );
70 event
.SetDirectory( fileCtrl
->GetDirectory() );
72 wxArrayString filenames
;
74 if ( filename
.empty() )
76 fileCtrl
->GetFilenames( filenames
);
80 filenames
.Add( filename
);
83 event
.SetFiles( filenames
);
85 wnd
->GetEventHandler()->ProcessEvent( event
);
88 ///////////////////////////////////////////////////////////////////////////////
89 // wxFileCtrlEvent implementation
90 ///////////////////////////////////////////////////////////////////////////////
92 wxString
wxFileCtrlEvent::GetFile() const
94 wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl
)->HasMultipleFileSelection(),
95 wxT( "Please use GetFiles() to get all files instead of this function" ) );
98 if (m_files
.Count() != 0)
103 #endif // wxUSE_FILECTRL