]>
Commit | Line | Data |
---|---|---|
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 | #ifndef FILECTRL_H | |
13 | #define FILECTRL_H | |
14 | ||
15 | #include "wx/control.h" | |
16 | ||
17 | extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[]; | |
18 | ||
19 | typedef struct _GtkFileChooser GtkFileChooser; | |
20 | ||
21 | // [GTK] current problems: | |
22 | // All methods(e.g. SetFilename(), SetPath(), etc) which change the state of | |
23 | // the control result in events fired, such events should be suppressed. | |
24 | // ------ | |
25 | // Sometimes a selection event(with 0 files) is fired before | |
26 | // wxEVT_FILECTRL_FOLDERCHANGED, unfortunately this can hardly be detected! | |
27 | ||
28 | // A wx wrapper for any Gtk object implementing the interface GtkFileChooser | |
29 | ||
30 | class WXDLLIMPEXP_CORE wxGtkFileChooser | |
31 | { | |
32 | public: | |
33 | wxGtkFileChooser() {} | |
34 | ||
35 | void SetWidget(GtkFileChooser *w); | |
36 | ||
37 | wxString GetPath() const; | |
38 | void GetPaths( wxArrayString& paths ) const; | |
39 | wxString GetDirectory() const; | |
40 | wxString GetFilename() const; | |
41 | void GetFilenames( wxArrayString& files ) const; | |
42 | int GetFilterIndex() const; | |
43 | ||
44 | bool SetPath( const wxString& path ); | |
45 | bool SetDirectory( const wxString& dir ); | |
46 | void SetWildcard( const wxString& wildCard ); | |
47 | void SetFilterIndex( int filterIndex ); | |
48 | ||
49 | private: | |
50 | GtkFileChooser *m_widget; | |
51 | }; | |
52 | ||
53 | #if wxUSE_FILECTRL | |
54 | ||
55 | class WXDLLIMPEXP_CORE wxGtkFileCtrl: public wxControl, | |
56 | public wxFileCtrlBase | |
57 | { | |
58 | public: | |
59 | wxGtkFileCtrl () { Init(); } | |
60 | ||
61 | wxGtkFileCtrl ( wxWindow *parent, | |
62 | wxWindowID id, | |
63 | const wxString& defaultDirectory = wxEmptyString, | |
64 | const wxString& defaultFilename = wxEmptyString, | |
65 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
66 | long style = wxFC_DEFAULT_STYLE, | |
67 | const wxPoint& pos = wxDefaultPosition, | |
68 | const wxSize& size = wxDefaultSize, | |
69 | const wxString& name = wxFileCtrlNameStr ) | |
70 | { | |
71 | Init(); | |
72 | Create( parent, id, defaultDirectory, defaultFilename, wildCard, style, pos, size, name ); | |
73 | } | |
74 | ||
75 | virtual ~wxGtkFileCtrl() {}; | |
76 | ||
77 | void Init(); | |
78 | bool Create( wxWindow *parent, | |
79 | wxWindowID id, | |
80 | const wxString& defaultDirectory = wxEmptyString, | |
81 | const wxString& defaultFileName = wxEmptyString, | |
82 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
83 | long style = wxFC_DEFAULT_STYLE, | |
84 | const wxPoint& pos = wxDefaultPosition, | |
85 | const wxSize& size = wxDefaultSize, | |
86 | const wxString& name = wxFileCtrlNameStr ); | |
87 | ||
88 | virtual void SetWildcard( const wxString& wildCard ); | |
89 | virtual void SetFilterIndex( int filterIndex ); | |
90 | virtual bool SetDirectory( const wxString& dir ); | |
91 | virtual bool SetFilename( const wxString& name ); | |
92 | virtual bool SetPath( const wxString& path ); | |
93 | ||
94 | virtual wxString GetFilename() const; | |
95 | virtual wxString GetDirectory() const; | |
96 | virtual wxString GetWildcard() const { return this->m_wildCard; } | |
97 | virtual wxString GetPath() const; | |
98 | virtual void GetPaths( wxArrayString& paths ) const; | |
99 | virtual void GetFilenames( wxArrayString& files ) const; | |
100 | virtual int GetFilterIndex() const { return m_fc.GetFilterIndex(); } | |
101 | ||
102 | virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE ); } | |
103 | virtual void ShowHidden(const bool show); | |
104 | ||
105 | bool m_checkNextSelEvent; | |
106 | bool m_ignoreNextFolderChangeEvent; | |
107 | ||
108 | protected: | |
109 | GtkFileChooser *m_fcWidget; | |
110 | wxGtkFileChooser m_fc; | |
111 | wxString m_wildCard; | |
112 | ||
113 | DECLARE_DYNAMIC_CLASS( wxGtkFileCtrl ) | |
114 | }; | |
115 | ||
116 | #endif // wxUSE_FILECTRL | |
117 | ||
118 | #endif // FILECTRL_H | |
119 |