1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Header for wxFileCtrlBase and other common functions used by
4 // platform-specific wxFileCtrl's
5 // Author: Diaa M. Sami
7 // Created: Jul-07-2007
9 // Copyright: (c) Diaa M. Sami
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_FILECTRL_H_BASE_
14 #define _WX_FILECTRL_H_BASE_
20 #include "wx/string.h"
27 wxFC_MULTIPLE
= 0x0004,
28 wxFC_NOSHOWHIDDEN
= 0x0008
31 #define wxFC_DEFAULT_STYLE wxFC_OPEN
32 extern WXDLLEXPORT_DATA( const wxChar
) wxFileCtrlNameStr
[];
34 BEGIN_DECLARE_EVENT_TYPES()
35 DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_SELECTIONCHANGED
, 1150 )
36 DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_FILEACTIVATED
, 1151 )
37 DECLARE_EXPORTED_EVENT_TYPE( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_FOLDERCHANGED
, 1152 )
38 END_DECLARE_EVENT_TYPES()
40 class WXDLLIMPEXP_CORE wxFileCtrlBase
43 virtual ~wxFileCtrlBase() {}
45 virtual void SetWildcard( const wxString
& wildCard
) = 0;
46 virtual void SetFilterIndex( int filterindex
) = 0;
47 virtual bool SetDirectory( const wxString
& dir
) = 0;
49 // Selects a certain file.
50 // In case the filename specified isn't found/couldn't be shown with
51 // currently selected filter, false is returned and nothing happens
52 virtual bool SetFilename( const wxString
& name
) = 0;
54 // chdirs to a certain directory and selects a certain file.
55 // In case the filename specified isn't found/couldn't be shown with
56 // currently selected filter, false is returned and if directory exists
58 virtual bool SetPath( const wxString
& path
) = 0;
60 virtual wxString
GetFilename() const = 0;
61 virtual wxString
GetDirectory() const = 0;
62 virtual wxString
GetWildcard() const = 0;
63 virtual wxString
GetPath() const = 0;
64 virtual void GetPaths( wxArrayString
& paths
) const = 0;
65 virtual void GetFilenames( wxArrayString
& files
) const = 0;
66 virtual int GetFilterIndex() const = 0;
68 virtual bool HasMultipleFileSelection() const = 0;
69 virtual void ShowHidden(bool show
) = 0;
72 void GenerateFolderChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
);
73 void GenerateSelectionChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
);
74 void GenerateFileActivatedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
, const wxString filename
= wxEmptyString
);
76 #if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
77 #define wxFileCtrl wxGtkFileCtrl
78 #include "wx/gtk/filectrl.h"
80 #define wxFileCtrl wxGenericFileCtrl
81 #include "wx/generic/filectrlg.h"
85 // On wxEVT_FILECTRL_FOLDERCHANGED, only the value returned by GetDirectory is
86 // valid and it represents the (new) current directory for the wxFileCtrl.
87 // On wxEVT_FILECTRL_FILEACTIVATED, GetDirectory returns the current directory
88 // for the wxFileCtrl and GetFiles returns the names of the file(s) activated.
89 // On wxEVT_FILECTRL_SELECTIONCHANGED, GetDirectory returns the current directory
90 // for the wxFileCtrl and GetFiles returns the names of the currently selected
92 // In wxGTK, after each wxEVT_FILECTRL_FOLDERCHANGED, wxEVT_FILECTRL_SELECTIONCHANGED
93 // is fired automatically once or more with 0 files.
94 class WXDLLIMPEXP_CORE wxFileCtrlEvent
: public wxCommandEvent
98 wxFileCtrlEvent( wxEventType type
, wxObject
*evtObject
, int id
)
99 : wxCommandEvent( type
, id
)
101 SetEventObject( evtObject
);
104 // no need for the copy constructor as the default one will be fine.
105 virtual wxEvent
*Clone() const { return new wxFileCtrlEvent( *this ); }
107 void SetFiles( const wxArrayString
&files
) { m_files
= files
; }
108 void SetDirectory( const wxString
&directory
) { m_directory
= directory
; }
110 wxArrayString
GetFiles() const { return m_files
; }
111 wxString
GetDirectory() const { return m_directory
; }
113 wxString
GetFile() const;
116 wxString m_directory
;
117 wxArrayString m_files
;
119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent
)
122 typedef void ( wxEvtHandler::*wxFileCtrlEventFunction
)( wxFileCtrlEvent
& );
124 #define wxFileCtrlEventHandler(func) \
125 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFileCtrlEventFunction, &func)
127 #define EVT_FILECTRL_FILEACTIVATED(id, fn) \
128 wx__DECLARE_EVT1(wxEVT_FILECTRL_FILEACTIVATED, id, wxFileCtrlEventHandler(fn))
130 #define EVT_FILECTRL_SELECTIONCHANGED(id, fn) \
131 wx__DECLARE_EVT1(wxEVT_FILECTRL_SELECTIONCHANGED, id, wxFileCtrlEventHandler(fn))
133 #define EVT_FILECTRL_FOLDERCHANGED(id, fn) \
134 wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn))
136 #endif // wxUSE_FILECTRL
138 #endif // _WX_FILECTRL_H_BASE_