]> git.saurik.com Git - wxWidgets.git/blob - src/common/filectrlcmn.cpp
Don't limit the number of stack frames in GTK assert dialog to 20.
[wxWidgets.git] / src / common / filectrlcmn.cpp
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
6 // Created: 2007-07-07
7 // RCS-ID: $Id$
8 // Copyright: (c) Diaa M. Sami
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_FILECTRL
19
20 #include "wx/filectrl.h"
21
22 #ifndef WX_PRECOMP
23 # include "wx/debug.h"
24 #endif
25
26 const char wxFileCtrlNameStr[] = "wxfilectrl";
27
28 wxDEFINE_EVENT( wxEVT_FILECTRL_SELECTIONCHANGED, wxFileCtrlEvent );
29 wxDEFINE_EVENT( wxEVT_FILECTRL_FILEACTIVATED, wxFileCtrlEvent );
30 wxDEFINE_EVENT( wxEVT_FILECTRL_FOLDERCHANGED, wxFileCtrlEvent );
31
32 IMPLEMENT_DYNAMIC_CLASS( wxFileCtrlEvent, wxCommandEvent )
33
34 // some helper functions
35
36 void GenerateFolderChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd )
37 {
38 wxFileCtrlEvent event( wxEVT_FILECTRL_FOLDERCHANGED, wnd, wnd->GetId() );
39
40 event.SetDirectory( fileCtrl->GetDirectory() );
41
42 wnd->GetEventHandler()->ProcessEvent( event );
43 }
44
45 void GenerateSelectionChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd)
46 {
47 wxFileCtrlEvent event( wxEVT_FILECTRL_SELECTIONCHANGED, wnd, wnd->GetId() );
48 event.SetDirectory( fileCtrl->GetDirectory() );
49
50 wxArrayString filenames;
51 fileCtrl->GetFilenames( filenames );
52 event.SetFiles( filenames );
53
54 wnd->GetEventHandler()->ProcessEvent( event );
55 }
56
57 void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const wxString filename )
58 {
59 wxFileCtrlEvent event( wxEVT_FILECTRL_FILEACTIVATED, wnd, wnd->GetId() );
60 event.SetDirectory( fileCtrl->GetDirectory() );
61
62 wxArrayString filenames;
63
64 if ( filename.empty() )
65 {
66 fileCtrl->GetFilenames( filenames );
67 }
68 else
69 {
70 filenames.Add( filename );
71 }
72
73 event.SetFiles( filenames );
74
75 wnd->GetEventHandler()->ProcessEvent( event );
76 }
77
78 ///////////////////////////////////////////////////////////////////////////////
79 // wxFileCtrlEvent implementation
80 ///////////////////////////////////////////////////////////////////////////////
81
82 wxString wxFileCtrlEvent::GetFile() const
83 {
84 wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl )->HasMultipleFileSelection(),
85 wxT( "Please use GetFiles() to get all files instead of this function" ) );
86
87 wxString string;
88 if (m_files.Count() != 0)
89 string = m_files[0];
90 return string;
91 }
92
93 #endif // wxUSE_FILECTRL