]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filectrl.h
Only compile wxStd{Input,Output}Stream if wxUSE_STREAMS==1.
[wxWidgets.git] / include / wx / filectrl.h
CommitLineData
0cf3e587
VZ
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
23enum
24{
25 wxFC_OPEN = 0x0001,
26 wxFC_SAVE = 0x0002,
27 wxFC_MULTIPLE = 0x0004,
b3adca1e 28 wxFC_NOSHOWHIDDEN = 0x0008
0cf3e587
VZ
29};
30
31#define wxFC_DEFAULT_STYLE wxFC_OPEN
23318a53 32extern WXDLLIMPEXP_DATA_CORE(const char) wxFileCtrlNameStr[]; // in filectrlcmn.cpp
0cf3e587 33
0cf3e587
VZ
34class WXDLLIMPEXP_CORE wxFileCtrlBase
35{
36public:
37 virtual ~wxFileCtrlBase() {}
38
39 virtual void SetWildcard( const wxString& wildCard ) = 0;
40 virtual void SetFilterIndex( int filterindex ) = 0;
41 virtual bool SetDirectory( const wxString& dir ) = 0;
42
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;
47
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
51 // it's chdir'ed to
52 virtual bool SetPath( const wxString& path ) = 0;
53
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;
61
62 virtual bool HasMultipleFileSelection() const = 0;
260020e3 63 virtual void ShowHidden(bool show) = 0;
0cf3e587
VZ
64};
65
6305f044 66void GenerateFilterChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
0cf3e587
VZ
67void GenerateFolderChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
68void GenerateSelectionChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
69void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const wxString filename = wxEmptyString );
70
ff654490 71#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
0cf3e587
VZ
72 #define wxFileCtrl wxGtkFileCtrl
73 #include "wx/gtk/filectrl.h"
74#else
75 #define wxFileCtrl wxGenericFileCtrl
76 #include "wx/generic/filectrlg.h"
77#endif
78
79// Some documentation
6305f044
VZ
80// On wxEVT_FILECTRL_FILTERCHANGED, only the value returned by GetFilterIndex is
81// valid and it represents the (new) current filter index for the wxFileCtrl.
0cf3e587
VZ
82// On wxEVT_FILECTRL_FOLDERCHANGED, only the value returned by GetDirectory is
83// valid and it represents the (new) current directory for the wxFileCtrl.
84// On wxEVT_FILECTRL_FILEACTIVATED, GetDirectory returns the current directory
85// for the wxFileCtrl and GetFiles returns the names of the file(s) activated.
86// On wxEVT_FILECTRL_SELECTIONCHANGED, GetDirectory returns the current directory
87// for the wxFileCtrl and GetFiles returns the names of the currently selected
88// file(s).
89// In wxGTK, after each wxEVT_FILECTRL_FOLDERCHANGED, wxEVT_FILECTRL_SELECTIONCHANGED
90// is fired automatically once or more with 0 files.
91class WXDLLIMPEXP_CORE wxFileCtrlEvent : public wxCommandEvent
92{
93public:
94 wxFileCtrlEvent() {}
95 wxFileCtrlEvent( wxEventType type, wxObject *evtObject, int id )
96 : wxCommandEvent( type, id )
97 {
98 SetEventObject( evtObject );
99 }
100
101 // no need for the copy constructor as the default one will be fine.
102 virtual wxEvent *Clone() const { return new wxFileCtrlEvent( *this ); }
103
260020e3
PC
104 void SetFiles( const wxArrayString &files ) { m_files = files; }
105 void SetDirectory( const wxString &directory ) { m_directory = directory; }
6305f044 106 void SetFilterIndex( int filterIndex ) { m_filterIndex = filterIndex; }
0cf3e587 107
260020e3
PC
108 wxArrayString GetFiles() const { return m_files; }
109 wxString GetDirectory() const { return m_directory; }
6305f044 110 int GetFilterIndex() const { return m_filterIndex; }
0cf3e587
VZ
111
112 wxString GetFile() const;
113
114protected:
6305f044 115 int m_filterIndex;
260020e3
PC
116 wxString m_directory;
117 wxArrayString m_files;
0cf3e587
VZ
118
119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent )
120};
121
122typedef void ( wxEvtHandler::*wxFileCtrlEventFunction )( wxFileCtrlEvent& );
123
9b11752c
VZ
124wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_SELECTIONCHANGED, wxFileCtrlEvent );
125wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILEACTIVATED, wxFileCtrlEvent );
126wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FOLDERCHANGED, wxFileCtrlEvent );
6305f044 127wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILTERCHANGED, wxFileCtrlEvent );
3c778901 128
0cf3e587 129#define wxFileCtrlEventHandler(func) \
3c778901 130 wxEVENT_HANDLER_CAST( wxFileCtrlEventFunction, func )
0cf3e587
VZ
131
132#define EVT_FILECTRL_FILEACTIVATED(id, fn) \
133 wx__DECLARE_EVT1(wxEVT_FILECTRL_FILEACTIVATED, id, wxFileCtrlEventHandler(fn))
134
135#define EVT_FILECTRL_SELECTIONCHANGED(id, fn) \
136 wx__DECLARE_EVT1(wxEVT_FILECTRL_SELECTIONCHANGED, id, wxFileCtrlEventHandler(fn))
137
138#define EVT_FILECTRL_FOLDERCHANGED(id, fn) \
139 wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn))
140
6305f044
VZ
141#define EVT_FILECTRL_FILTERCHANGED(id, fn) \
142 wx__DECLARE_EVT1(wxEVT_FILECTRL_FILTERCHANGED, id, wxFileCtrlEventHandler(fn))
143
0cf3e587
VZ
144#endif // wxUSE_FILECTRL
145
146#endif // _WX_FILECTRL_H_BASE_