works for the generic implementation only).
Renamed wxDIRCTRL_EDITABLE to wxDIRCTRL_EDIT_LABELS.
Removed reported memory leaks from dynload.cpp using wxModule --
this may cause problems if other modules want to use wxPluginLibrary.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15074
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
\twocolitem{\indexit{wxDIRCTRL\_3D\_INTERNAL}}{Use 3D borders for internal controls.}
\twocolitem{\indexit{wxDIRCTRL\_SELECT\_FIRST}}{When setting the default path, select the first file in the directory.}
\twocolitem{\indexit{wxDIRCTRL\_SHOW\_FILTERS}}{Show the drop-down filter list.}
\twocolitem{\indexit{wxDIRCTRL\_3D\_INTERNAL}}{Use 3D borders for internal controls.}
\twocolitem{\indexit{wxDIRCTRL\_SELECT\_FIRST}}{When setting the default path, select the first file in the directory.}
\twocolitem{\indexit{wxDIRCTRL\_SHOW\_FILTERS}}{Show the drop-down filter list.}
-\twocolitem{\indexit{wxDIRCTRL\_EDITABLE}}{Allow the folder and file items to be editable.}
+\twocolitem{\indexit{wxDIRCTRL\_EDIT\_LABELS}}{Allow the folder and file labels to be editable.}
\end{twocollist}
See also \helpref{Generic window styles}{windowstyles}.
\end{twocollist}
See also \helpref{Generic window styles}{windowstyles}.
\wxheading{Include files}
<wx/dirdlg.h>
\wxheading{Include files}
<wx/dirdlg.h>
+<wx/generic/dirdlgg.h>
+
+\wxheading{Window styles}
+
+\twocolwidtha{5cm}
+\begin{twocollist}
+\twocolitem{\indexit{wxDD\_NEW\_DIR\_BUTTON}}{Add "Create new directory" button and allow
+directory names to be editable. Available only on platforms that use the generic
+dialog chooser: GTK+, Motif, X11, MGL. For other platforms, use the wxGenericDirDialog
+implementation explicitly if you wish to use this style.}
+\end{twocollist}
+
+See also \helpref{Generic window styles}{windowstyles}.
// be modal. No progress will then be made at all.
#define wxPD_REMAINING_TIME 0x0040
// be modal. No progress will then be made at all.
#define wxPD_REMAINING_TIME 0x0040
+/*
+ * wxDirDialog styles
+ */
+
+#define wxDD_NEW_DIR_BUTTON 0x0080
+
/*
* extended dialog specifiers. these values are stored in a different
* flag and thus do not overlap with other style flags. note that these
/*
* extended dialog specifiers. these values are stored in a different
* flag and thus do not overlap with other style flags. note that these
WXDLLEXPORT wxString
wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString,
WXDLLEXPORT wxString
wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString,
+ long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDD_NEW_DIR_BUTTON,
const wxPoint& pos = wxDefaultPosition,
wxWindow *parent = NULL);
const wxPoint& pos = wxDefaultPosition,
wxWindow *parent = NULL);
- static wxDLImports ms_classes; // Static hash of all imported classes.
+ static wxDLImports* ms_classes; // Static hash of all imported classes.
wxPluginLibrary( const wxString &libname, int flags = wxDL_DEFAULT );
~wxPluginLibrary();
wxPluginLibrary( const wxString &libname, int flags = wxDL_DEFAULT );
~wxPluginLibrary();
return m_entry->GetSymbol( symbol, success );
}
return m_entry->GetSymbol( symbol, success );
}
+ static void CreateManifest() { ms_manifest = new wxDLManifest(wxKEY_STRING); }
+ static void ClearManifest() { delete ms_manifest; ms_manifest = NULL; }
+
- static wxDLManifest ms_manifest; // Static hash of loaded libs.
- wxPluginLibrary *m_entry; // Cache our entry in the manifest.
+ static wxDLManifest* ms_manifest; // Static hash of loaded libs.
+ wxPluginLibrary* m_entry; // Cache our entry in the manifest.
// We could allow this class to be copied if we really
// wanted to, but not without modification.
// We could allow this class to be copied if we really
// wanted to, but not without modification.
// Use 3D borders on internal controls
wxDIRCTRL_3D_INTERNAL = 0x0080,
// Editable labels
// Use 3D borders on internal controls
wxDIRCTRL_3D_INTERNAL = 0x0080,
// Editable labels
- wxDIRCTRL_EDITABLE = 0x0100
+ wxDIRCTRL_EDIT_LABELS = 0x0100
};
//-----------------------------------------------------------------------------
};
//-----------------------------------------------------------------------------
wxGenericDirDialog(): wxDialog() {}
wxGenericDirDialog(wxWindow* parent, const wxString& title,
const wxString& defaultPath = wxEmptyString,
wxGenericDirDialog(): wxDialog() {}
wxGenericDirDialog(wxWindow* parent, const wxString& title,
const wxString& defaultPath = wxEmptyString,
- long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,
+ long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDD_NEW_DIR_BUTTON,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxSize(450, 550),
const wxString& name = _T("dialog"));
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxSize(450, 550),
const wxString& name = _T("dialog"));
#include "wx/filename.h" // for SplitPath()
#include "wx/dynload.h"
#include "wx/filename.h" // for SplitPath()
#include "wx/dynload.h"
#if defined(__DARWIN__)
/* Porting notes:
#if defined(__DARWIN__)
/* Porting notes:
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
-wxDLImports wxPluginLibrary::ms_classes(wxKEY_STRING);
+wxDLImports* wxPluginLibrary::ms_classes = NULL;
+
+class wxPluginLibraryModule : public wxModule
+{
+public:
+ wxPluginLibraryModule() {}
+ bool OnInit() { wxPluginLibrary::ms_classes = new wxDLImports(wxKEY_STRING); return TRUE; }
+ void OnExit() { delete wxPluginLibrary::ms_classes; wxPluginLibrary::ms_classes = NULL;
+ wxPluginManager::ClearManifest(); }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxPluginLibraryModule )
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPluginLibraryModule, wxModule)
+
wxPluginLibrary::wxPluginLibrary(const wxString &libname, int flags)
: m_linkcount(1)
wxPluginLibrary::wxPluginLibrary(const wxString &libname, int flags)
: m_linkcount(1)
// Hash all the class names into a local table too so
// we can quickly find the entry they correspond to.
// Hash all the class names into a local table too so
// we can quickly find the entry they correspond to.
- if( ms_classes.Get(info->m_className) == 0 )
- ms_classes.Put(info->m_className, (wxObject *) this);
+ if( ms_classes->Get(info->m_className) == 0 )
+ ms_classes->Put(info->m_className, (wxObject *) this);
for(info = m_after; info != m_before; info = info->m_next)
{
wxClassInfo::sm_classTable->Delete(info->m_className);
for(info = m_after; info != m_before; info = info->m_next)
{
wxClassInfo::sm_classTable->Delete(info->m_className);
- ms_classes.Delete(info->m_className);
+ ms_classes->Delete(info->m_className);
}
if( wxClassInfo::sm_first == m_after )
}
if( wxClassInfo::sm_first == m_after )
// wxPluginLibrary
// ---------------------------------------------------------------------------
// wxPluginLibrary
// ---------------------------------------------------------------------------
-wxDLManifest wxPluginManager::ms_manifest(wxKEY_STRING);
+wxDLManifest* wxPluginManager::ms_manifest = NULL;
// ------------------------
// Static accessors
// ------------------------
// Static accessors
if( !(flags & wxDL_VERBATIM) )
realname += wxDynamicLibrary::GetDllExt();
if( !(flags & wxDL_VERBATIM) )
realname += wxDynamicLibrary::GetDllExt();
- wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest.Get(realname);
+ wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest->Get(realname);
if( entry->IsLoaded() )
{
if( entry->IsLoaded() )
{
- ms_manifest.Put(realname, (wxObject*) entry);
+ ms_manifest->Put(realname, (wxObject*) entry);
bool wxPluginManager::UnloadLibrary(const wxString &libname)
{
bool wxPluginManager::UnloadLibrary(const wxString &libname)
{
- wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest.Get(libname);
+ wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest->Get(libname);
- entry = (wxPluginLibrary*) ms_manifest.Get(libname + wxDynamicLibrary::GetDllExt());
+ entry = (wxPluginLibrary*) ms_manifest->Get(libname + wxDynamicLibrary::GetDllExt());
if( entry )
return entry->UnrefLib();
if( entry )
return entry->UnrefLib();
wxPluginLibrary *wxPluginManager::GetObjectFromHandle(wxDllType handle)
{
wxNode *node;
wxPluginLibrary *wxPluginManager::GetObjectFromHandle(wxDllType handle)
{
wxNode *node;
- ms_manifest.BeginFind();
+ ms_manifest->BeginFind();
- for(node = ms_manifest.Next(); node; node = ms_manifest.Next())
+ for(node = ms_manifest->Next(); node; node = ms_manifest->Next())
if( ((wxPluginLibrary*)node->GetData())->GetLibHandle() == handle )
return (wxPluginLibrary*)node->GetData();
if( ((wxPluginLibrary*)node->GetData())->GetLibHandle() == handle )
return (wxPluginLibrary*)node->GetData();
void wxPluginManager::Unload()
{
wxNode *node;
void wxPluginManager::Unload()
{
wxNode *node;
- ms_manifest.BeginFind();
+ ms_manifest->BeginFind();
// It's either this or store the name of the lib just to do this.
// It's either this or store the name of the lib just to do this.
- for(node = ms_manifest.Next(); node; node = ms_manifest.Next())
+ for(node = ms_manifest->Next(); node; node = ms_manifest->Next())
if( (wxPluginLibrary*)node->GetData() == m_entry )
break;
if( (wxPluginLibrary*)node->GetData() == m_entry )
break;
long treeStyle = wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT;
long treeStyle = wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT;
-#ifdef __WXMSW__
- if (style & wxDIRCTRL_EDITABLE)
+ if (style & wxDIRCTRL_EDIT_LABELS)
treeStyle |= wxTR_EDIT_LABELS;
treeStyle |= wxTR_EDIT_LABELS;
if ((style & wxDIRCTRL_3D_INTERNAL) == 0)
treeStyle |= wxNO_BORDER;
if ((style & wxDIRCTRL_3D_INTERNAL) == 0)
treeStyle |= wxNO_BORDER;
// I'm not convinced we need a New button, and we tend to get annoying
// accidental-editing with label editing enabled.
// I'm not convinced we need a New button, and we tend to get annoying
// accidental-editing with label editing enabled.
- wxBitmapButton* newButton =
- new wxBitmapButton(this, ID_NEW,
- wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_CMN_DIALOG));
- buttonsizer->Add( newButton, 0, wxRIGHT, 10 );
+ if (style & wxDD_NEW_DIR_BUTTON)
+ {
+ wxBitmapButton* newButton =
+ new wxBitmapButton(this, ID_NEW,
+ wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_CMN_DIALOG));
+ buttonsizer->Add( newButton, 0, wxRIGHT, 10 );
+#if wxUSE_TOOLTIPS
+ newButton->SetToolTip(_("Create new directory"));
+#endif
+ }
#if wxUSE_TOOLTIPS
homeButton->SetToolTip(_("Go to home directory"));
#if wxUSE_TOOLTIPS
homeButton->SetToolTip(_("Go to home directory"));
- newButton->SetToolTip(_("Create new directory"));
#endif
topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 );
#endif
topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 );
// 1) dir ctrl
m_dirCtrl = NULL; // this is neccessary, event handler called from
// wxGenericDirCtrl would crash otherwise!
// 1) dir ctrl
m_dirCtrl = NULL; // this is neccessary, event handler called from
// wxGenericDirCtrl would crash otherwise!
+ long dirStyle = wxDIRCTRL_DIR_ONLY|wxSUNKEN_BORDER;
+
+#ifdef __WXMSW__
+ if (style & wxDD_NEW_DIR_BUTTON)
+ {
+ // Only under Windows do we need the wxTR_EDIT_LABEL tree control style
+ // before we can call EditLabel (required for "New directory")
+ dirStyle |= wxDIRCTRL_EDIT_LABELS;
+ }
+#endif
+
m_dirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL,
m_path, wxPoint(5, 5),
wxSize(300, 200),
m_dirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL,
m_path, wxPoint(5, 5),
wxSize(300, 200),
- wxDIRCTRL_DIR_ONLY|wxDIRCTRL_EDITABLE|wxSUNKEN_BORDER);
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );