1998-12-17 15:56:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dirdlgg.h
|
|
|
|
// Purpose: wxDirDialog
|
|
|
|
// Author: Harm van der Heijden and Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// Created: 12/12/98
|
|
|
|
// Copyright: (c) Harm van der Heijden and Robert Roebling
|
1999-08-17 11:55:25 -04:00
|
|
|
// RCS-ID: $Id$
|
1998-12-17 15:56:27 -05:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
//
|
2000-01-05 10:35:04 -05:00
|
|
|
// Notes: wxDirDialog class written by Harm van der Heijden,
|
1998-12-17 15:56:27 -05:00
|
|
|
// uses wxDirCtrl class written by Robert Roebling for the
|
|
|
|
// wxFile application, modified by Harm van der Heijden
|
|
|
|
//
|
|
|
|
// Description: This generic dirdialog implementation defines three classes:
|
|
|
|
// 1) wxDirItemData(public wxTreeItemData) stores pathname and
|
|
|
|
// displayed name for each item in the directory tree
|
2000-01-05 10:35:04 -05:00
|
|
|
// 2) wxDirCtrl(public wxTreeCtrl) is a tree widget that
|
1998-12-17 15:56:27 -05:00
|
|
|
// displays a directory tree. It is possible to define sections
|
2000-01-05 10:35:04 -05:00
|
|
|
// for fast access to parts of the file system (such as the
|
1998-12-17 15:56:27 -05:00
|
|
|
// user's homedir, /usr/local, /tmp ...etc), similar to
|
|
|
|
// Win95 Explorer's shortcuts to 'My Computer', 'Desktop', etc.
|
|
|
|
// 3) wxDirDialog is the dialog box itself. The user can choose
|
|
|
|
// a directory by navigating the tree, or by typing a dir
|
|
|
|
// in an inputbox. The inputbox displays paths selected in the
|
|
|
|
// tree. It is possible to create new directories. The user
|
2000-01-05 10:35:04 -05:00
|
|
|
// will automatically be prompted for dir creation if he
|
1998-12-17 15:56:27 -05:00
|
|
|
// enters a non-existing dir.
|
|
|
|
//
|
|
|
|
// TODO/BUGS: - standard sections only have reasonable defaults for Unix
|
|
|
|
// (but others are easily added in wxDirCtrl::SetupSections)
|
|
|
|
// - No direct support for "show hidden" toggle. Partly due
|
2000-01-05 10:35:04 -05:00
|
|
|
// to laziness on my part and partly because
|
1998-12-17 15:56:27 -05:00
|
|
|
// wxFindFirst/NextFile never seems to find hidden dirs
|
|
|
|
// anyway.
|
|
|
|
// - No automatic update of the tree (branch) after directory
|
|
|
|
// creation.
|
|
|
|
// - I call wxBeginBusyCursor while expanding items (creating
|
|
|
|
// a new branch might take a few seconds, especially if a
|
|
|
|
// CDROM drive or something is involved) but that doesn't
|
|
|
|
// seem to do anything. Need to look into that.
|
|
|
|
// - Am still looking for an efficient way to delete wxTreeCtrl
|
2000-01-05 10:35:04 -05:00
|
|
|
// branches. DeleteChildren has disappeared and
|
1998-12-17 15:56:27 -05:00
|
|
|
// CollapseAndReset( parent ) deletes the parent as well.
|
|
|
|
// - The dialog window layout is done using wxConstraints. It
|
2000-01-05 10:35:04 -05:00
|
|
|
// works, but it's not as simple as I'd like it to be (see
|
1998-12-17 15:56:27 -05:00
|
|
|
// comments in wxDirDialog::doSize)
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DIRDLGG_H_
|
|
|
|
#define _WX_DIRDLGG_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "dirdlgg.h"
|
|
|
|
#endif
|
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_DIRDLG
|
|
|
|
|
1998-12-17 15:56:27 -05:00
|
|
|
#include "wx/dialog.h"
|
1999-06-15 16:21:59 -04:00
|
|
|
#include "wx/checkbox.h"
|
1998-12-17 15:56:27 -05:00
|
|
|
#include "wx/treectrl.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
1998-12-18 05:19:07 -05:00
|
|
|
// data
|
1998-12-17 15:56:27 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1999-04-12 18:20:19 -04:00
|
|
|
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
|
1999-09-06 08:15:33 -04:00
|
|
|
WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
|
1998-12-17 15:56:27 -05:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
1998-12-18 05:19:07 -05:00
|
|
|
// classes
|
1998-12-17 15:56:27 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-12-18 05:19:07 -05:00
|
|
|
class wxDirItemData;
|
|
|
|
class wxDirCtrl;
|
|
|
|
class wxDirDialog;
|
1998-12-17 15:56:27 -05:00
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxDirItemData
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDirItemData : public wxTreeItemData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDirItemData(wxString& path, wxString& name);
|
|
|
|
~wxDirItemData();
|
|
|
|
bool HasSubDirs();
|
|
|
|
void SetNewDirName( wxString path );
|
|
|
|
wxString m_path, m_name;
|
|
|
|
bool m_isHidden;
|
|
|
|
bool m_hasSubDirs;
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxDirCtrl
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDirCtrl: public wxTreeCtrl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool m_showHidden;
|
|
|
|
wxTreeItemId m_rootId;
|
2000-01-05 10:35:04 -05:00
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
wxDirCtrl();
|
2000-01-05 10:35:04 -05:00
|
|
|
wxDirCtrl(wxWindow *parent, const wxWindowID id = -1,
|
1999-09-05 11:14:50 -04:00
|
|
|
const wxString &dir = wxDirDialogDefaultFolderStr,
|
1999-08-15 11:18:54 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
const long style = wxTR_HAS_BUTTONS,
|
1999-09-05 11:14:50 -04:00
|
|
|
const wxString& name = wxTreeCtrlNameStr );
|
1999-08-15 11:18:54 -04:00
|
|
|
void ShowHidden( const bool yesno );
|
|
|
|
void OnExpandItem(wxTreeEvent &event );
|
|
|
|
void OnCollapseItem(wxTreeEvent &event );
|
|
|
|
void OnBeginEditItem(wxTreeEvent &event );
|
|
|
|
void OnEndEditItem(wxTreeEvent &event );
|
2000-01-05 10:35:04 -05:00
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
protected:
|
|
|
|
void CreateItems(const wxTreeItemId &parent);
|
|
|
|
void SetupSections();
|
|
|
|
wxArrayString m_paths, m_names;
|
2000-01-05 10:35:04 -05:00
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDirCtrl)
|
|
|
|
};
|
|
|
|
|
1998-12-17 15:56:27 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxDirDialog
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDirDialog: public wxDialog
|
|
|
|
{
|
1999-08-15 11:18:54 -04:00
|
|
|
public:
|
1999-12-14 18:53:32 -05:00
|
|
|
wxDirDialog() {}
|
2000-01-05 10:35:04 -05:00
|
|
|
wxDirDialog(wxWindow *parent,
|
1998-12-17 15:56:27 -05:00
|
|
|
const wxString& message = wxFileSelectorPromptStr,
|
1998-12-28 07:35:49 -05:00
|
|
|
const wxString& defaultPath = wxEmptyString,
|
1998-12-17 15:56:27 -05:00
|
|
|
long style = 0, const wxPoint& pos = wxDefaultPosition);
|
|
|
|
inline void SetMessage(const wxString& message) { m_message = message; }
|
|
|
|
inline void SetPath(const wxString& path) { m_path = path; }
|
|
|
|
inline void SetStyle(long style) { m_dialogStyle = style; }
|
|
|
|
|
|
|
|
inline wxString GetMessage() const { return m_message; }
|
|
|
|
inline wxString GetPath() const { return m_path; }
|
|
|
|
inline long GetStyle() const { return m_dialogStyle; }
|
|
|
|
|
|
|
|
int ShowModal();
|
|
|
|
|
|
|
|
void OnTreeSelected( wxTreeEvent &event );
|
1998-12-20 18:49:21 -05:00
|
|
|
void OnTreeKeyDown( wxTreeEvent &event );
|
1998-12-17 15:56:27 -05:00
|
|
|
void OnOK(wxCommandEvent& event);
|
2000-01-05 10:35:04 -05:00
|
|
|
void OnCancel(wxCommandEvent& event);
|
1998-12-17 15:56:27 -05:00
|
|
|
void OnNew(wxCommandEvent& event);
|
|
|
|
// void OnCheck(wxCommandEvent& event);
|
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
protected:
|
1998-12-17 15:56:27 -05:00
|
|
|
// implementation
|
1999-08-15 11:18:54 -04:00
|
|
|
wxString m_message;
|
|
|
|
long m_dialogStyle;
|
|
|
|
wxString m_path;
|
|
|
|
wxDirCtrl *m_dir;
|
|
|
|
wxTextCtrl *m_input;
|
|
|
|
wxCheckBox *m_check; // not yet used
|
|
|
|
wxButton *m_ok, *m_cancel, *m_new;
|
2000-01-05 10:35:04 -05:00
|
|
|
|
1999-08-15 11:18:54 -04:00
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDirDialog)
|
1998-12-17 15:56:27 -05:00
|
|
|
};
|
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
#endif
|
|
|
|
|
1998-12-17 15:56:27 -05:00
|
|
|
#endif
|
|
|
|
// _WX_DIRDLGG_H_
|
|
|
|
|