]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dirdlgg.h
use XPMs in wxMGL
[wxWidgets.git] / include / wx / generic / dirdlgg.h
CommitLineData
d7a15103
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: dirdlgg.h
3// Purpose: wxDirDialog
4// Author: Harm van der Heijden and Robert Roebling
5// Modified by:
6// Created: 12/12/98
7// Copyright: (c) Harm van der Heijden and Robert Roebling
8b17ba72 8// RCS-ID: $Id$
f6bcfd97 9// Licence: wxWindows licence
d7a15103 10//
479cd5de 11// Notes: wxDirDialog class written by Harm van der Heijden,
d7a15103
JS
12// uses wxDirCtrl class written by Robert Roebling for the
13// wxFile application, modified by Harm van der Heijden
14//
15// Description: This generic dirdialog implementation defines three classes:
16// 1) wxDirItemData(public wxTreeItemData) stores pathname and
17// displayed name for each item in the directory tree
479cd5de 18// 2) wxDirCtrl(public wxTreeCtrl) is a tree widget that
d7a15103 19// displays a directory tree. It is possible to define sections
479cd5de 20// for fast access to parts of the file system (such as the
d7a15103
JS
21// user's homedir, /usr/local, /tmp ...etc), similar to
22// Win95 Explorer's shortcuts to 'My Computer', 'Desktop', etc.
23// 3) wxDirDialog is the dialog box itself. The user can choose
24// a directory by navigating the tree, or by typing a dir
25// in an inputbox. The inputbox displays paths selected in the
26// tree. It is possible to create new directories. The user
479cd5de 27// will automatically be prompted for dir creation if he
d7a15103
JS
28// enters a non-existing dir.
29//
30// TODO/BUGS: - standard sections only have reasonable defaults for Unix
31// (but others are easily added in wxDirCtrl::SetupSections)
32// - No direct support for "show hidden" toggle. Partly due
479cd5de 33// to laziness on my part and partly because
d7a15103
JS
34// wxFindFirst/NextFile never seems to find hidden dirs
35// anyway.
36// - No automatic update of the tree (branch) after directory
37// creation.
38// - I call wxBeginBusyCursor while expanding items (creating
39// a new branch might take a few seconds, especially if a
40// CDROM drive or something is involved) but that doesn't
41// seem to do anything. Need to look into that.
42// - Am still looking for an efficient way to delete wxTreeCtrl
479cd5de 43// branches. DeleteChildren has disappeared and
d7a15103
JS
44// CollapseAndReset( parent ) deletes the parent as well.
45// - The dialog window layout is done using wxConstraints. It
479cd5de 46// works, but it's not as simple as I'd like it to be (see
d7a15103
JS
47// comments in wxDirDialog::doSize)
48//
49/////////////////////////////////////////////////////////////////////////////
50
51#ifndef _WX_DIRDLGG_H_
52#define _WX_DIRDLGG_H_
53
54#ifdef __GNUG__
55#pragma interface "dirdlgg.h"
56#endif
57
ce4169a4
RR
58#include "wx/defs.h"
59
60#if wxUSE_DIRDLG
61
d7a15103 62#include "wx/dialog.h"
d7a15103
JS
63#include "wx/treectrl.h"
64
10eb1f1e
VZ
65class WXDLLEXPORT wxButton;
66class WXDLLEXPORT wxCheckBox;
67class WXDLLEXPORT wxTextCtrl;
68
d7a15103 69//-----------------------------------------------------------------------------
0659e7ee 70// data
d7a15103
JS
71//-----------------------------------------------------------------------------
72
9d2f3c71 73WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
2f435842 74WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
d7a15103
JS
75
76//-----------------------------------------------------------------------------
0659e7ee 77// classes
d7a15103
JS
78//-----------------------------------------------------------------------------
79
0659e7ee
RR
80class wxDirItemData;
81class wxDirCtrl;
82class wxDirDialog;
d7a15103 83
dc6c62a9
RR
84//-----------------------------------------------------------------------------
85// wxDirItemData
86//-----------------------------------------------------------------------------
87
88class WXDLLEXPORT wxDirItemData : public wxTreeItemData
89{
90public:
91 wxDirItemData(wxString& path, wxString& name);
92 ~wxDirItemData();
93 bool HasSubDirs();
94 void SetNewDirName( wxString path );
95 wxString m_path, m_name;
96 bool m_isHidden;
97 bool m_hasSubDirs;
98};
99
100//-----------------------------------------------------------------------------
101// wxDirCtrl
102//-----------------------------------------------------------------------------
103
104class WXDLLEXPORT wxDirCtrl: public wxTreeCtrl
105{
106public:
107 bool m_showHidden;
108 wxTreeItemId m_rootId;
479cd5de 109
dc6c62a9 110 wxDirCtrl();
479cd5de 111 wxDirCtrl(wxWindow *parent, const wxWindowID id = -1,
f6bcfd97
BP
112 const wxString &dir = wxDirDialogDefaultFolderStr,
113 const wxPoint& pos = wxDefaultPosition,
114 const wxSize& size = wxDefaultSize,
115 const long style = wxTR_HAS_BUTTONS,
116 const wxString& name = wxTreeCtrlNameStr );
dc6c62a9
RR
117 void ShowHidden( const bool yesno );
118 void OnExpandItem(wxTreeEvent &event );
119 void OnCollapseItem(wxTreeEvent &event );
120 void OnBeginEditItem(wxTreeEvent &event );
121 void OnEndEditItem(wxTreeEvent &event );
479cd5de 122
dc6c62a9 123protected:
f6bcfd97
BP
124 friend class wxDirDialog;
125
dc6c62a9
RR
126 void CreateItems(const wxTreeItemId &parent);
127 void SetupSections();
128 wxArrayString m_paths, m_names;
479cd5de 129
dc6c62a9
RR
130private:
131 DECLARE_EVENT_TABLE()
132 DECLARE_DYNAMIC_CLASS(wxDirCtrl)
133};
134
d7a15103
JS
135//-----------------------------------------------------------------------------
136// wxDirDialog
137//-----------------------------------------------------------------------------
138
139class WXDLLEXPORT wxDirDialog: public wxDialog
140{
dc6c62a9 141public:
fed628b6 142 wxDirDialog() {}
479cd5de 143 wxDirDialog(wxWindow *parent,
f6bcfd97
BP
144 const wxString& message = wxFileSelectorPromptStr,
145 const wxString& defaultPath = wxEmptyString,
146 long style = 0, const wxPoint& pos = wxDefaultPosition);
d7a15103
JS
147 inline void SetMessage(const wxString& message) { m_message = message; }
148 inline void SetPath(const wxString& path) { m_path = path; }
149 inline void SetStyle(long style) { m_dialogStyle = style; }
150
151 inline wxString GetMessage() const { return m_message; }
152 inline wxString GetPath() const { return m_path; }
153 inline long GetStyle() const { return m_dialogStyle; }
154
155 int ShowModal();
156
157 void OnTreeSelected( wxTreeEvent &event );
1e6d9499 158 void OnTreeKeyDown( wxTreeEvent &event );
d7a15103 159 void OnOK(wxCommandEvent& event);
479cd5de 160 void OnCancel(wxCommandEvent& event);
d7a15103
JS
161 void OnNew(wxCommandEvent& event);
162 // void OnCheck(wxCommandEvent& event);
d7a15103 163
dc6c62a9 164protected:
d7a15103 165 // implementation
dc6c62a9
RR
166 wxString m_message;
167 long m_dialogStyle;
168 wxString m_path;
169 wxDirCtrl *m_dir;
170 wxTextCtrl *m_input;
171 wxCheckBox *m_check; // not yet used
172 wxButton *m_ok, *m_cancel, *m_new;
479cd5de 173
dc6c62a9
RR
174private:
175 DECLARE_EVENT_TABLE()
176 DECLARE_DYNAMIC_CLASS(wxDirDialog)
d7a15103
JS
177};
178
ce4169a4
RR
179#endif
180
d7a15103
JS
181#endif
182 // _WX_DIRDLGG_H_
183