1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/filectrl.h
3 // Purpose: wxGtkFileCtrl Header
4 // Author: Diaa M. Sami
6 // Created: Aug-10-2007
7 // Copyright: (c) Diaa M. Sami
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTK_FILECTRL_H_
13 #define _WX_GTK_FILECTRL_H_
15 #include "wx/control.h"
16 #include "wx/filectrl.h"
18 extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr
[];
20 typedef struct _GtkFileChooser GtkFileChooser
;
22 // [GTK] current problems:
23 // All methods(e.g. SetFilename(), SetPath(), etc) which change the state of
24 // the control result in events fired, such events should be suppressed.
26 // Sometimes a selection event(with 0 files) is fired before
27 // wxEVT_FILECTRL_FOLDERCHANGED, unfortunately this can hardly be detected!
29 // A wx wrapper for any Gtk object implementing the interface GtkFileChooser
31 class WXDLLIMPEXP_CORE wxGtkFileChooser
34 wxGtkFileChooser() { m_ignoreNextFilterEvent
= false; }
36 void SetWidget(GtkFileChooser
*w
);
38 wxString
GetPath() const;
39 void GetPaths( wxArrayString
& paths
) const;
40 wxString
GetDirectory() const;
41 wxString
GetFilename() const;
42 void GetFilenames( wxArrayString
& files
) const;
43 int GetFilterIndex() const;
45 bool SetPath( const wxString
& path
);
46 bool SetDirectory( const wxString
& dir
);
47 void SetWildcard( const wxString
& wildCard
);
48 void SetFilterIndex( int filterIndex
);
50 bool HasFilterChoice() const;
52 bool ShouldIgnoreNextFilterEvent() const { return m_ignoreNextFilterEvent
; }
54 wxString
GetCurrentWildCard() const
55 { return m_wildcards
[GetFilterIndex()]; }
58 GtkFileChooser
*m_widget
;
59 // First wildcard in filter, to be used when the user
60 // saves a file without giving an extension.
61 wxArrayString m_wildcards
;
63 // If true, ignore the next event because it was generated by us and not
65 bool m_ignoreNextFilterEvent
;
70 class WXDLLIMPEXP_CORE wxGtkFileCtrl
: public wxControl
,
74 wxGtkFileCtrl () { Init(); }
76 wxGtkFileCtrl ( wxWindow
*parent
,
78 const wxString
& defaultDirectory
= wxEmptyString
,
79 const wxString
& defaultFilename
= wxEmptyString
,
80 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
81 long style
= wxFC_DEFAULT_STYLE
,
82 const wxPoint
& pos
= wxDefaultPosition
,
83 const wxSize
& size
= wxDefaultSize
,
84 const wxString
& name
= wxFileCtrlNameStr
)
87 Create( parent
, id
, defaultDirectory
, defaultFilename
, wildCard
, style
, pos
, size
, name
);
90 virtual ~wxGtkFileCtrl();
92 bool Create( wxWindow
*parent
,
94 const wxString
& defaultDirectory
= wxEmptyString
,
95 const wxString
& defaultFileName
= wxEmptyString
,
96 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
97 long style
= wxFC_DEFAULT_STYLE
,
98 const wxPoint
& pos
= wxDefaultPosition
,
99 const wxSize
& size
= wxDefaultSize
,
100 const wxString
& name
= wxFileCtrlNameStr
);
102 virtual void SetWildcard( const wxString
& wildCard
);
103 virtual void SetFilterIndex( int filterIndex
);
104 virtual bool SetDirectory( const wxString
& dir
);
105 virtual bool SetFilename( const wxString
& name
);
106 virtual bool SetPath( const wxString
& path
);
108 virtual wxString
GetFilename() const;
109 virtual wxString
GetDirectory() const;
110 virtual wxString
GetWildcard() const { return this->m_wildCard
; }
111 virtual wxString
GetPath() const;
112 virtual void GetPaths( wxArrayString
& paths
) const;
113 virtual void GetFilenames( wxArrayString
& files
) const;
114 virtual int GetFilterIndex() const { return m_fc
.GetFilterIndex(); }
116 virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE
); }
117 virtual void ShowHidden(bool show
);
119 virtual bool HasFilterChoice() const
120 { return m_fc
.HasFilterChoice(); }
123 // Implementation only from now on.
124 bool GTKShouldIgnoreNextFilterEvent() const
125 { return m_fc
.ShouldIgnoreNextFilterEvent(); }
127 bool m_checkNextSelEvent
;
128 bool m_ignoreNextFolderChangeEvent
;
131 GtkFileChooser
*m_fcWidget
;
132 wxGtkFileChooser m_fc
;
138 DECLARE_DYNAMIC_CLASS( wxGtkFileCtrl
)
141 #endif // wxUSE_FILECTRL
143 #endif // _WX_GTK_FILECTRL_H_