]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filectrl.h
Allow using socket from both wxBase and wxCore (adopting to changes from r50831)
[wxWidgets.git] / include / wx / filectrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filectrl.h
3 // Purpose: Header for wxFileCtrlBase and other common functions used by
4 // platform-specific wxFileCtrl's
5 // Author: Diaa M. Sami
6 // Modified by:
7 // Created: Jul-07-2007
8 // RCS-ID: $Id$
9 // Copyright: (c) Diaa M. Sami
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_FILECTRL_H_BASE_
14 #define _WX_FILECTRL_H_BASE_
15
16 #include "wx/defs.h"
17
18 #if wxUSE_FILECTRL
19
20 #include "wx/string.h"
21 #include "wx/event.h"
22
23 enum
24 {
25 wxFC_OPEN = 0x0001,
26 wxFC_SAVE = 0x0002,
27 wxFC_MULTIPLE = 0x0004,
28 wxFC_NOSHOWHIDDEN = 0x0008
29 };
30
31 #define wxFC_DEFAULT_STYLE wxFC_OPEN
32 extern WXDLLEXPORT_DATA( const wxChar ) wxFileCtrlNameStr[];
33
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()
39
40 class WXDLLIMPEXP_CORE wxFileCtrlBase
41 {
42 public:
43 virtual ~wxFileCtrlBase() {}
44
45 virtual void SetWildcard( const wxString& wildCard ) = 0;
46 virtual void SetFilterIndex( int filterindex ) = 0;
47 virtual bool SetDirectory( const wxString& dir ) = 0;
48
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;
53
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
57 // it's chdir'ed to
58 virtual bool SetPath( const wxString& path ) = 0;
59
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;
67
68 virtual bool HasMultipleFileSelection() const = 0;
69 virtual void ShowHidden(bool show) = 0;
70 };
71
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 );
75
76 #if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
77 #define wxFileCtrl wxGtkFileCtrl
78 #include "wx/gtk/filectrl.h"
79 #else
80 #define wxFileCtrl wxGenericFileCtrl
81 #include "wx/generic/filectrlg.h"
82 #endif
83
84 // Some documentation
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
91 // file(s).
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
95 {
96 public:
97 wxFileCtrlEvent() {}
98 wxFileCtrlEvent( wxEventType type, wxObject *evtObject, int id )
99 : wxCommandEvent( type, id )
100 {
101 SetEventObject( evtObject );
102 }
103
104 // no need for the copy constructor as the default one will be fine.
105 virtual wxEvent *Clone() const { return new wxFileCtrlEvent( *this ); }
106
107 void SetFiles( const wxArrayString &files ) { m_files = files; }
108 void SetDirectory( const wxString &directory ) { m_directory = directory; }
109
110 wxArrayString GetFiles() const { return m_files; }
111 wxString GetDirectory() const { return m_directory; }
112
113 wxString GetFile() const;
114
115 protected:
116 wxString m_directory;
117 wxArrayString m_files;
118
119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent )
120 };
121
122 typedef void ( wxEvtHandler::*wxFileCtrlEventFunction )( wxFileCtrlEvent& );
123
124 #define wxFileCtrlEventHandler(func) \
125 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFileCtrlEventFunction, &func)
126
127 #define EVT_FILECTRL_FILEACTIVATED(id, fn) \
128 wx__DECLARE_EVT1(wxEVT_FILECTRL_FILEACTIVATED, id, wxFileCtrlEventHandler(fn))
129
130 #define EVT_FILECTRL_SELECTIONCHANGED(id, fn) \
131 wx__DECLARE_EVT1(wxEVT_FILECTRL_SELECTIONCHANGED, id, wxFileCtrlEventHandler(fn))
132
133 #define EVT_FILECTRL_FOLDERCHANGED(id, fn) \
134 wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn))
135
136 #endif // wxUSE_FILECTRL
137
138 #endif // _WX_FILECTRL_H_BASE_