]>
Commit | Line | Data |
---|---|---|
0cf3e587 VZ |
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 | ||
700d08c1 RR |
12 | |
13 | #ifndef _WX_GTK_FILECTRL_H_ | |
14 | #define _WX_GTK_FILECTRL_H_ | |
0cf3e587 | 15 | |
7d61c83f | 16 | #include "wx/control.h" |
700d08c1 | 17 | #include "wx/filectrl.h" |
7d61c83f | 18 | |
53a2db12 | 19 | extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[]; |
7d61c83f | 20 | |
0cf3e587 VZ |
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: | |
6305f044 | 35 | wxGtkFileChooser() { m_ignoreNextFilterEvent = false; } |
0cf3e587 VZ |
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 | ||
6305f044 VZ |
51 | bool HasFilterChoice() const; |
52 | ||
53 | bool ShouldIgnoreNextFilterEvent() const { return m_ignoreNextFilterEvent; } | |
54 | ||
20380343 RR |
55 | wxString GetCurrentWildCard() const |
56 | { return m_wildcards[GetFilterIndex()]; } | |
57 | ||
0cf3e587 VZ |
58 | private: |
59 | GtkFileChooser *m_widget; | |
20380343 RR |
60 | // First wildcard in filter, to be used when the user |
61 | // saves a file without giving an extension. | |
03647350 | 62 | wxArrayString m_wildcards; |
6305f044 VZ |
63 | |
64 | // If true, ignore the next event because it was generated by us and not | |
65 | // the user. | |
66 | bool m_ignoreNextFilterEvent; | |
0cf3e587 VZ |
67 | }; |
68 | ||
69 | #if wxUSE_FILECTRL | |
70 | ||
71 | class WXDLLIMPEXP_CORE wxGtkFileCtrl: public wxControl, | |
72 | public wxFileCtrlBase | |
73 | { | |
74 | public: | |
75 | wxGtkFileCtrl () { Init(); } | |
76 | ||
77 | wxGtkFileCtrl ( wxWindow *parent, | |
78 | wxWindowID id, | |
79 | const wxString& defaultDirectory = wxEmptyString, | |
80 | const wxString& defaultFilename = wxEmptyString, | |
81 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
82 | long style = wxFC_DEFAULT_STYLE, | |
83 | const wxPoint& pos = wxDefaultPosition, | |
84 | const wxSize& size = wxDefaultSize, | |
85 | const wxString& name = wxFileCtrlNameStr ) | |
86 | { | |
87 | Init(); | |
88 | Create( parent, id, defaultDirectory, defaultFilename, wildCard, style, pos, size, name ); | |
89 | } | |
90 | ||
6dd0883d | 91 | virtual ~wxGtkFileCtrl() {} |
0cf3e587 | 92 | |
0cf3e587 VZ |
93 | bool Create( wxWindow *parent, |
94 | wxWindowID id, | |
95 | const wxString& defaultDirectory = wxEmptyString, | |
96 | const wxString& defaultFileName = wxEmptyString, | |
97 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
98 | long style = wxFC_DEFAULT_STYLE, | |
99 | const wxPoint& pos = wxDefaultPosition, | |
100 | const wxSize& size = wxDefaultSize, | |
101 | const wxString& name = wxFileCtrlNameStr ); | |
102 | ||
103 | virtual void SetWildcard( const wxString& wildCard ); | |
104 | virtual void SetFilterIndex( int filterIndex ); | |
105 | virtual bool SetDirectory( const wxString& dir ); | |
106 | virtual bool SetFilename( const wxString& name ); | |
107 | virtual bool SetPath( const wxString& path ); | |
108 | ||
109 | virtual wxString GetFilename() const; | |
110 | virtual wxString GetDirectory() const; | |
111 | virtual wxString GetWildcard() const { return this->m_wildCard; } | |
112 | virtual wxString GetPath() const; | |
113 | virtual void GetPaths( wxArrayString& paths ) const; | |
114 | virtual void GetFilenames( wxArrayString& files ) const; | |
115 | virtual int GetFilterIndex() const { return m_fc.GetFilterIndex(); } | |
116 | ||
117 | virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE ); } | |
260020e3 | 118 | virtual void ShowHidden(bool show); |
0cf3e587 | 119 | |
6305f044 VZ |
120 | virtual bool HasFilterChoice() const |
121 | { return m_fc.HasFilterChoice(); } | |
122 | ||
123 | ||
124 | // Implementation only from now on. | |
125 | bool GTKShouldIgnoreNextFilterEvent() const | |
126 | { return m_fc.ShouldIgnoreNextFilterEvent(); } | |
127 | ||
0cf3e587 VZ |
128 | bool m_checkNextSelEvent; |
129 | bool m_ignoreNextFolderChangeEvent; | |
130 | ||
131 | protected: | |
132 | GtkFileChooser *m_fcWidget; | |
133 | wxGtkFileChooser m_fc; | |
134 | wxString m_wildCard; | |
135 | ||
95dc31e0 PC |
136 | private: |
137 | void Init(); | |
138 | ||
0cf3e587 VZ |
139 | DECLARE_DYNAMIC_CLASS( wxGtkFileCtrl ) |
140 | }; | |
141 | ||
142 | #endif // wxUSE_FILECTRL | |
143 | ||
700d08c1 | 144 | #endif // _WX_GTK_FILECTRL_H_ |
0cf3e587 | 145 |