]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/filectrl.h
Fix bug with using uninitialized flags in GetParentForModalDialog().
[wxWidgets.git] / include / wx / gtk / filectrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/filectrl.h
3 // Purpose: wxGtkFileCtrl Header
4 // Author: Diaa M. Sami
5 // Modified by:
6 // Created: Aug-10-2007
7 // RCS-ID: $Id$
8 // Copyright: (c) Diaa M. Sami
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12
13 #ifndef _WX_GTK_FILECTRL_H_
14 #define _WX_GTK_FILECTRL_H_
15
16 #include "wx/control.h"
17 #include "wx/filectrl.h"
18
19 extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[];
20
21 typedef struct _GtkFileChooser GtkFileChooser;
22
23 // [GTK] current problems:
24 // All methods(e.g. SetFilename(), SetPath(), etc) which change the state of
25 // the control result in events fired, such events should be suppressed.
26 // ------
27 // Sometimes a selection event(with 0 files) is fired before
28 // wxEVT_FILECTRL_FOLDERCHANGED, unfortunately this can hardly be detected!
29
30 // A wx wrapper for any Gtk object implementing the interface GtkFileChooser
31
32 class WXDLLIMPEXP_CORE wxGtkFileChooser
33 {
34 public:
35 wxGtkFileChooser() {}
36
37 void SetWidget(GtkFileChooser *w);
38
39 wxString GetPath() const;
40 void GetPaths( wxArrayString& paths ) const;
41 wxString GetDirectory() const;
42 wxString GetFilename() const;
43 void GetFilenames( wxArrayString& files ) const;
44 int GetFilterIndex() const;
45
46 bool SetPath( const wxString& path );
47 bool SetDirectory( const wxString& dir );
48 void SetWildcard( const wxString& wildCard );
49 void SetFilterIndex( int filterIndex );
50
51 wxString GetCurrentWildCard() const
52 { return m_wildcards[GetFilterIndex()]; }
53
54 private:
55 GtkFileChooser *m_widget;
56 // First wildcard in filter, to be used when the user
57 // saves a file without giving an extension.
58 wxArrayString m_wildcards;
59 };
60
61 #if wxUSE_FILECTRL
62
63 class WXDLLIMPEXP_CORE wxGtkFileCtrl: public wxControl,
64 public wxFileCtrlBase
65 {
66 public:
67 wxGtkFileCtrl () { Init(); }
68
69 wxGtkFileCtrl ( wxWindow *parent,
70 wxWindowID id,
71 const wxString& defaultDirectory = wxEmptyString,
72 const wxString& defaultFilename = wxEmptyString,
73 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
74 long style = wxFC_DEFAULT_STYLE,
75 const wxPoint& pos = wxDefaultPosition,
76 const wxSize& size = wxDefaultSize,
77 const wxString& name = wxFileCtrlNameStr )
78 {
79 Init();
80 Create( parent, id, defaultDirectory, defaultFilename, wildCard, style, pos, size, name );
81 }
82
83 virtual ~wxGtkFileCtrl() {};
84
85 void Init();
86 bool Create( wxWindow *parent,
87 wxWindowID id,
88 const wxString& defaultDirectory = wxEmptyString,
89 const wxString& defaultFileName = wxEmptyString,
90 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
91 long style = wxFC_DEFAULT_STYLE,
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 const wxString& name = wxFileCtrlNameStr );
95
96 virtual void SetWildcard( const wxString& wildCard );
97 virtual void SetFilterIndex( int filterIndex );
98 virtual bool SetDirectory( const wxString& dir );
99 virtual bool SetFilename( const wxString& name );
100 virtual bool SetPath( const wxString& path );
101
102 virtual wxString GetFilename() const;
103 virtual wxString GetDirectory() const;
104 virtual wxString GetWildcard() const { return this->m_wildCard; }
105 virtual wxString GetPath() const;
106 virtual void GetPaths( wxArrayString& paths ) const;
107 virtual void GetFilenames( wxArrayString& files ) const;
108 virtual int GetFilterIndex() const { return m_fc.GetFilterIndex(); }
109
110 virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE ); }
111 virtual void ShowHidden(bool show);
112
113 bool m_checkNextSelEvent;
114 bool m_ignoreNextFolderChangeEvent;
115
116 protected:
117 GtkFileChooser *m_fcWidget;
118 wxGtkFileChooser m_fc;
119 wxString m_wildCard;
120
121 DECLARE_DYNAMIC_CLASS( wxGtkFileCtrl )
122 };
123
124 #endif // wxUSE_FILECTRL
125
126 #endif // _WX_GTK_FILECTRL_H_
127