]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dirdlgg.h
Checking for wxUSE_SOCKETS and __GSOCKET_STANDALONE__ should be right, now
[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$
d7a15103
JS
9// Licence: wxWindows licence
10//
11// Notes: wxDirDialog class written by Harm van der Heijden,
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
18// 2) wxDirCtrl(public wxTreeCtrl) is a tree widget that
19// displays a directory tree. It is possible to define sections
20// for fast access to parts of the file system (such as the
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
27// will automatically be prompted for dir creation if he
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
33// to laziness on my part and partly because
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
43// branches. DeleteChildren has disappeared and
44// CollapseAndReset( parent ) deletes the parent as well.
45// - The dialog window layout is done using wxConstraints. It
46// works, but it's not as simple as I'd like it to be (see
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"
ce4169a4 63#include "wx/checkbox.h"
d7a15103
JS
64#include "wx/treectrl.h"
65
d7a15103 66//-----------------------------------------------------------------------------
0659e7ee 67// data
d7a15103
JS
68//-----------------------------------------------------------------------------
69
9d2f3c71 70WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
2f435842 71WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
d7a15103
JS
72
73//-----------------------------------------------------------------------------
0659e7ee 74// classes
d7a15103
JS
75//-----------------------------------------------------------------------------
76
0659e7ee
RR
77class wxDirItemData;
78class wxDirCtrl;
79class wxDirDialog;
d7a15103 80
dc6c62a9
RR
81//-----------------------------------------------------------------------------
82// wxDirItemData
83//-----------------------------------------------------------------------------
84
85class WXDLLEXPORT wxDirItemData : public wxTreeItemData
86{
87public:
88 wxDirItemData(wxString& path, wxString& name);
89 ~wxDirItemData();
90 bool HasSubDirs();
91 void SetNewDirName( wxString path );
92 wxString m_path, m_name;
93 bool m_isHidden;
94 bool m_hasSubDirs;
95};
96
97//-----------------------------------------------------------------------------
98// wxDirCtrl
99//-----------------------------------------------------------------------------
100
101class WXDLLEXPORT wxDirCtrl: public wxTreeCtrl
102{
103public:
104 bool m_showHidden;
105 wxTreeItemId m_rootId;
106
107 wxDirCtrl();
108 wxDirCtrl(wxWindow *parent, const wxWindowID id = -1,
1044a386 109 const wxString &dir = wxDirDialogDefaultFolderStr,
dc6c62a9
RR
110 const wxPoint& pos = wxDefaultPosition,
111 const wxSize& size = wxDefaultSize,
112 const long style = wxTR_HAS_BUTTONS,
1044a386 113 const wxString& name = wxTreeCtrlNameStr );
dc6c62a9
RR
114 void ShowHidden( const bool yesno );
115 void OnExpandItem(wxTreeEvent &event );
116 void OnCollapseItem(wxTreeEvent &event );
117 void OnBeginEditItem(wxTreeEvent &event );
118 void OnEndEditItem(wxTreeEvent &event );
119
120protected:
121 void CreateItems(const wxTreeItemId &parent);
122 void SetupSections();
123 wxArrayString m_paths, m_names;
124
125private:
126 DECLARE_EVENT_TABLE()
127 DECLARE_DYNAMIC_CLASS(wxDirCtrl)
128};
129
d7a15103
JS
130//-----------------------------------------------------------------------------
131// wxDirDialog
132//-----------------------------------------------------------------------------
133
134class WXDLLEXPORT wxDirDialog: public wxDialog
135{
dc6c62a9 136public:
d7a15103
JS
137 wxDirDialog(wxWindow *parent,
138 const wxString& message = wxFileSelectorPromptStr,
62448488 139 const wxString& defaultPath = wxEmptyString,
d7a15103
JS
140 long style = 0, const wxPoint& pos = wxDefaultPosition);
141 inline void SetMessage(const wxString& message) { m_message = message; }
142 inline void SetPath(const wxString& path) { m_path = path; }
143 inline void SetStyle(long style) { m_dialogStyle = style; }
144
145 inline wxString GetMessage() const { return m_message; }
146 inline wxString GetPath() const { return m_path; }
147 inline long GetStyle() const { return m_dialogStyle; }
148
149 int ShowModal();
150
151 void OnTreeSelected( wxTreeEvent &event );
1e6d9499 152 void OnTreeKeyDown( wxTreeEvent &event );
d7a15103
JS
153 void OnOK(wxCommandEvent& event);
154 void OnCancel(wxCommandEvent& event);
155 void OnNew(wxCommandEvent& event);
156 // void OnCheck(wxCommandEvent& event);
d7a15103 157
dc6c62a9 158protected:
d7a15103 159 // implementation
dc6c62a9
RR
160 wxString m_message;
161 long m_dialogStyle;
162 wxString m_path;
163 wxDirCtrl *m_dir;
164 wxTextCtrl *m_input;
165 wxCheckBox *m_check; // not yet used
166 wxButton *m_ok, *m_cancel, *m_new;
167
168private:
169 DECLARE_EVENT_TABLE()
170 DECLARE_DYNAMIC_CLASS(wxDirDialog)
d7a15103
JS
171};
172
ce4169a4
RR
173#endif
174
d7a15103
JS
175#endif
176 // _WX_DIRDLGG_H_
177