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 WXDLLIMPEXP_DATA_CORE(const char) wxFileCtrlNameStr
[]; // in filectrlcmn.cpp
34 class WXDLLIMPEXP_CORE wxFileCtrlBase
37 virtual ~wxFileCtrlBase() {}
39 virtual void SetWildcard( const wxString
& wildCard
) = 0;
40 virtual void SetFilterIndex( int filterindex
) = 0;
41 virtual bool SetDirectory( const wxString
& dir
) = 0;
43 // Selects a certain file.
44 // In case the filename specified isn't found/couldn't be shown with
45 // currently selected filter, false is returned and nothing happens
46 virtual bool SetFilename( const wxString
& name
) = 0;
48 // chdirs to a certain directory and selects a certain file.
49 // In case the filename specified isn't found/couldn't be shown with
50 // currently selected filter, false is returned and if directory exists
52 virtual bool SetPath( const wxString
& path
) = 0;
54 virtual wxString
GetFilename() const = 0;
55 virtual wxString
GetDirectory() const = 0;
56 virtual wxString
GetWildcard() const = 0;
57 virtual wxString
GetPath() const = 0;
58 virtual void GetPaths( wxArrayString
& paths
) const = 0;
59 virtual void GetFilenames( wxArrayString
& files
) const = 0;
60 virtual int GetFilterIndex() const = 0;
62 virtual bool HasMultipleFileSelection() const = 0;
63 virtual void ShowHidden(bool show
) = 0;
66 void GenerateFolderChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
);
67 void GenerateSelectionChangedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
);
68 void GenerateFileActivatedEvent( wxFileCtrlBase
*fileCtrl
, wxWindow
*wnd
, const wxString filename
= wxEmptyString
);
70 #if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
71 #define wxFileCtrl wxGtkFileCtrl
72 #include "wx/gtk/filectrl.h"
74 #define wxFileCtrl wxGenericFileCtrl
75 #include "wx/generic/filectrlg.h"
79 // On wxEVT_FILECTRL_FOLDERCHANGED, only the value returned by GetDirectory is
80 // valid and it represents the (new) current directory for the wxFileCtrl.
81 // On wxEVT_FILECTRL_FILEACTIVATED, GetDirectory returns the current directory
82 // for the wxFileCtrl and GetFiles returns the names of the file(s) activated.
83 // On wxEVT_FILECTRL_SELECTIONCHANGED, GetDirectory returns the current directory
84 // for the wxFileCtrl and GetFiles returns the names of the currently selected
86 // In wxGTK, after each wxEVT_FILECTRL_FOLDERCHANGED, wxEVT_FILECTRL_SELECTIONCHANGED
87 // is fired automatically once or more with 0 files.
88 class WXDLLIMPEXP_CORE wxFileCtrlEvent
: public wxCommandEvent
92 wxFileCtrlEvent( wxEventType type
, wxObject
*evtObject
, int id
)
93 : wxCommandEvent( type
, id
)
95 SetEventObject( evtObject
);
98 // no need for the copy constructor as the default one will be fine.
99 virtual wxEvent
*Clone() const { return new wxFileCtrlEvent( *this ); }
101 void SetFiles( const wxArrayString
&files
) { m_files
= files
; }
102 void SetDirectory( const wxString
&directory
) { m_directory
= directory
; }
104 wxArrayString
GetFiles() const { return m_files
; }
105 wxString
GetDirectory() const { return m_directory
; }
107 wxString
GetFile() const;
110 wxString m_directory
;
111 wxArrayString m_files
;
113 DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent
)
116 typedef void ( wxEvtHandler::*wxFileCtrlEventFunction
)( wxFileCtrlEvent
& );
118 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_SELECTIONCHANGED
, wxFileCtrlEvent
)
119 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_FILEACTIVATED
, wxFileCtrlEvent
)
120 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_FILECTRL_FOLDERCHANGED
, wxFileCtrlEvent
)
122 #define wxFileCtrlEventHandler(func) \
123 wxEVENT_HANDLER_CAST( wxFileCtrlEventFunction, func )
125 #define EVT_FILECTRL_FILEACTIVATED(id, fn) \
126 wx__DECLARE_EVT1(wxEVT_FILECTRL_FILEACTIVATED, id, wxFileCtrlEventHandler(fn))
128 #define EVT_FILECTRL_SELECTIONCHANGED(id, fn) \
129 wx__DECLARE_EVT1(wxEVT_FILECTRL_SELECTIONCHANGED, id, wxFileCtrlEventHandler(fn))
131 #define EVT_FILECTRL_FOLDERCHANGED(id, fn) \
132 wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn))
134 #endif // wxUSE_FILECTRL
136 #endif // _WX_FILECTRL_H_BASE_