X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10eb1f1eac4f334f4acaae8199178131eeba5f74..1f0acb435592470b421b80df854fbbb08cd2853f:/include/wx/generic/dirdlgg.h?ds=inline diff --git a/include/wx/generic/dirdlgg.h b/include/wx/generic/dirdlgg.h index 3922c472b6..79c15b278d 100644 --- a/include/wx/generic/dirdlgg.h +++ b/include/wx/generic/dirdlgg.h @@ -1,183 +1,89 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dirdlgg.h -// Purpose: wxDirDialog -// Author: Harm van der Heijden and Robert Roebling +// Name: wx/generic/dirdlgg.h +// Purpose: wxGenericDirCtrl class +// Builds on wxDirCtrl class written by Robert Roebling for the +// wxFile application, modified by Harm van der Heijden. +// Further modified for Windows. +// Author: Robert Roebling, Harm van der Heijden, Julian Smart et al // Modified by: -// Created: 12/12/98 -// Copyright: (c) Harm van der Heijden and Robert Roebling +// Created: 21/3/2000 // RCS-ID: $Id$ -// Licence: wxWindows licence -// -// Notes: wxDirDialog class written by Harm van der Heijden, -// 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 -// 2) wxDirCtrl(public wxTreeCtrl) is a tree widget that -// displays a directory tree. It is possible to define sections -// for fast access to parts of the file system (such as the -// 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 -// will automatically be prompted for dir creation if he -// 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 -// to laziness on my part and partly because -// 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 -// branches. DeleteChildren has disappeared and -// CollapseAndReset( parent ) deletes the parent as well. -// - The dialog window layout is done using wxConstraints. It -// works, but it's not as simple as I'd like it to be (see -// comments in wxDirDialog::doSize) -// +// Copyright: (c) Robert Roebling, Harm van der Heijden, Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DIRDLGG_H_ #define _WX_DIRDLGG_H_ -#ifdef __GNUG__ -#pragma interface "dirdlgg.h" -#endif +class WXDLLIMPEXP_FWD_CORE wxGenericDirCtrl; +class WXDLLIMPEXP_FWD_CORE wxTextCtrl; +class WXDLLIMPEXP_FWD_CORE wxTreeEvent; -#include "wx/defs.h" +// we may be included directly as well as from wx/dirdlg.h (FIXME) +extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[]; +extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; -#if wxUSE_DIRDLG +#ifndef wxDD_DEFAULT_STYLE +#ifdef __WXWINCE__ + #define wxDD_DEFAULT_STYLE wxDEFAULT_DIALOG_STYLE +#else + #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) +#endif +#endif #include "wx/dialog.h" -#include "wx/treectrl.h" - -class WXDLLEXPORT wxButton; -class WXDLLEXPORT wxCheckBox; -class WXDLLEXPORT wxTextCtrl; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr; - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxDirItemData; -class wxDirCtrl; -class wxDirDialog; - -//----------------------------------------------------------------------------- -// 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 +// wxGenericDirDialog //----------------------------------------------------------------------------- -class WXDLLEXPORT wxDirCtrl: public wxTreeCtrl +class WXDLLIMPEXP_CORE wxGenericDirDialog : public wxDirDialogBase { public: - bool m_showHidden; - wxTreeItemId m_rootId; - - wxDirCtrl(); - wxDirCtrl(wxWindow *parent, const wxWindowID id = -1, - const wxString &dir = wxDirDialogDefaultFolderStr, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - const long style = wxTR_HAS_BUTTONS, - const wxString& name = wxTreeCtrlNameStr ); - void ShowHidden( const bool yesno ); - void OnExpandItem(wxTreeEvent &event ); - void OnCollapseItem(wxTreeEvent &event ); - void OnBeginEditItem(wxTreeEvent &event ); - void OnEndEditItem(wxTreeEvent &event ); - -protected: - friend class wxDirDialog; - - void CreateItems(const wxTreeItemId &parent); - void SetupSections(); - wxArrayString m_paths, m_names; - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxDirCtrl) -}; - -//----------------------------------------------------------------------------- -// wxDirDialog -//----------------------------------------------------------------------------- - -class WXDLLEXPORT wxDirDialog: public wxDialog -{ -public: - wxDirDialog() {} - wxDirDialog(wxWindow *parent, - const wxString& message = wxFileSelectorPromptStr, + wxGenericDirDialog() : wxDirDialogBase() { } + + wxGenericDirDialog(wxWindow* parent, + const wxString& title = wxDirSelectorPromptStr, + const wxString& defaultPath = wxEmptyString, + long style = wxDD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize,//Size(450, 550), + const wxString& name = wxDirDialogNameStr); + + bool Create(wxWindow* parent, + const wxString& title = wxDirSelectorPromptStr, const wxString& defaultPath = wxEmptyString, - 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; } + long style = wxDD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize,//Size(450, 550), + const wxString& name = wxDirDialogNameStr); + + //// Accessors + void SetPath(const wxString& path); + wxString GetPath() const; - inline wxString GetMessage() const { return m_message; } - inline wxString GetPath() const { return m_path; } - inline long GetStyle() const { return m_dialogStyle; } + //// Overrides + virtual int ShowModal(); + virtual void EndModal(int retCode); - int ShowModal(); + // this one is specific to wxGenericDirDialog + wxTextCtrl* GetInputCtrl() const { return m_input; } - void OnTreeSelected( wxTreeEvent &event ); - void OnTreeKeyDown( wxTreeEvent &event ); +protected: + //// Event handlers + void OnCloseWindow(wxCloseEvent& event); void OnOK(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); + void OnTreeSelected(wxTreeEvent &event); + void OnTreeKeyDown(wxTreeEvent &event); void OnNew(wxCommandEvent& event); - // void OnCheck(wxCommandEvent& event); + void OnGoHome(wxCommandEvent& event); + void OnShowHidden(wxCommandEvent& event); + + wxGenericDirCtrl* m_dirCtrl; + wxTextCtrl* m_input; -protected: - // implementation - 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; - -private: DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxDirDialog) + DECLARE_DYNAMIC_CLASS(wxGenericDirDialog) }; -#endif - -#endif - // _WX_DIRDLGG_H_ - +#endif // _WX_DIRDLGG_H_