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
7 // Copyright: (c) Diaa M. Sami
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
19 #include "wx/filectrl.h"
22 # include "wx/debug.h"
25 const char wxFileCtrlNameStr
[] = "wxfilectrl";
27 wxDEFINE_EVENT( wxEVT_FILECTRL_SELECTIONCHANGED
, wxFileCtrlEvent
);
28 wxDEFINE_EVENT( wxEVT_FILECTRL_FILEACTIVATED
, wxFileCtrlEvent
);
29 wxDEFINE_EVENT( wxEVT_FILECTRL_FOLDERCHANGED
, wxFileCtrlEvent
);
30 wxDEFINE_EVENT( wxEVT_FILECTRL_FILTERCHANGED
, wxFileCtrlEvent
);
32 IMPLEMENT_DYNAMIC_CLASS( wxFileCtrlEvent
, wxCommandEvent
)
34 // some helper functions
36 void GenerateFilterChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
38 wxFileCtrlEvent
event( wxEVT_FILECTRL_FILTERCHANGED
, wnd
, wnd
->GetId() );
40 event
.SetFilterIndex( fileCtrl
->GetFilterIndex() );
42 wnd
->GetEventHandler()->ProcessEvent( event
);
45 void GenerateFolderChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
47 wxFileCtrlEvent
event( wxEVT_FILECTRL_FOLDERCHANGED
, wnd
, wnd
->GetId() );
49 event
.SetDirectory( fileCtrl
->GetDirectory() );
51 wnd
->GetEventHandler()->ProcessEvent( event
);
54 void GenerateSelectionChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
)
56 wxFileCtrlEvent
event( wxEVT_FILECTRL_SELECTIONCHANGED
, wnd
, wnd
->GetId() );
57 event
.SetDirectory( fileCtrl
->GetDirectory() );
59 wxArrayString filenames
;
60 fileCtrl
->GetFilenames( filenames
);
61 event
.SetFiles( filenames
);
63 wnd
->GetEventHandler()->ProcessEvent( event
);
66 void GenerateFileActivatedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
, const wxString filename
)
68 wxFileCtrlEvent
event( wxEVT_FILECTRL_FILEACTIVATED
, wnd
, wnd
->GetId() );
69 event
.SetDirectory( fileCtrl
->GetDirectory() );
71 wxArrayString filenames
;
73 if ( filename
.empty() )
75 fileCtrl
->GetFilenames( filenames
);
79 filenames
.Add( filename
);
82 event
.SetFiles( filenames
);
84 wnd
->GetEventHandler()->ProcessEvent( event
);
87 ///////////////////////////////////////////////////////////////////////////////
88 // wxFileCtrlEvent implementation
89 ///////////////////////////////////////////////////////////////////////////////
91 wxString
wxFileCtrlEvent::GetFile() const
93 wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl
)->HasMultipleFileSelection(),
94 wxT( "Please use GetFiles() to get all files instead of this function" ) );
97 if (m_files
.Count() != 0)
102 #endif // wxUSE_FILECTRL