Added a wxDD_NEW_DIR_BUTTON style for wxDirDialog (currently,
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
This commit is contained in:
parent
2240c9edce
commit
dabd1377ce
@ -24,7 +24,7 @@ hierarchy, and optionally, a \helpref{wxChoice}{wxchoice} window containing a li
|
||||
\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}.
|
||||
|
@ -12,6 +12,19 @@ This class represents the directory chooser dialog.
|
||||
\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}.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
|
@ -1159,6 +1159,12 @@ enum wxBorder
|
||||
// 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
|
||||
|
@ -41,7 +41,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxDirSelectorPromptStr;
|
||||
WXDLLEXPORT wxString
|
||||
wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
|
||||
const wxString& defaultPath = wxEmptyString,
|
||||
long style = 0,
|
||||
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDD_NEW_DIR_BUTTON,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
wxWindow *parent = NULL);
|
||||
|
||||
|
@ -184,7 +184,7 @@ class WXDLLEXPORT wxPluginLibrary : public wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
|
||||
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();
|
||||
@ -269,10 +269,13 @@ public:
|
||||
return m_entry->GetSymbol( symbol, success );
|
||||
}
|
||||
|
||||
static void CreateManifest() { ms_manifest = new wxDLManifest(wxKEY_STRING); }
|
||||
static void ClearManifest() { delete ms_manifest; ms_manifest = NULL; }
|
||||
|
||||
private:
|
||||
|
||||
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.
|
||||
|
@ -47,7 +47,7 @@ enum
|
||||
// Use 3D borders on internal controls
|
||||
wxDIRCTRL_3D_INTERNAL = 0x0080,
|
||||
// Editable labels
|
||||
wxDIRCTRL_EDITABLE = 0x0100
|
||||
wxDIRCTRL_EDIT_LABELS = 0x0100
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
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"));
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "wx/filename.h" // for SplitPath()
|
||||
|
||||
#include "wx/dynload.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
#if defined(__DARWIN__)
|
||||
/* Porting notes:
|
||||
@ -280,7 +281,22 @@ void *wxDynamicLibrary::GetSymbol(const wxString &name, bool *success) const
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
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)
|
||||
@ -347,8 +363,8 @@ void wxPluginLibrary::UpdateClassInfo()
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,7 +384,7 @@ void wxPluginLibrary::RestoreClassInfo()
|
||||
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 )
|
||||
@ -457,7 +473,7 @@ void wxPluginLibrary::UnregisterModules()
|
||||
// wxPluginLibrary
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxDLManifest wxPluginManager::ms_manifest(wxKEY_STRING);
|
||||
wxDLManifest* wxPluginManager::ms_manifest = NULL;
|
||||
|
||||
// ------------------------
|
||||
// Static accessors
|
||||
@ -470,7 +486,7 @@ wxPluginLibrary *wxPluginManager::LoadLibrary(const wxString &libname, int flags
|
||||
if( !(flags & wxDL_VERBATIM) )
|
||||
realname += wxDynamicLibrary::GetDllExt();
|
||||
|
||||
wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest.Get(realname);
|
||||
wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest->Get(realname);
|
||||
|
||||
if( entry != 0 )
|
||||
{
|
||||
@ -482,7 +498,7 @@ wxPluginLibrary *wxPluginManager::LoadLibrary(const wxString &libname, int flags
|
||||
|
||||
if( entry->IsLoaded() )
|
||||
{
|
||||
ms_manifest.Put(realname, (wxObject*) entry);
|
||||
ms_manifest->Put(realname, (wxObject*) entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -496,10 +512,10 @@ wxPluginLibrary *wxPluginManager::LoadLibrary(const wxString &libname, int flags
|
||||
|
||||
bool wxPluginManager::UnloadLibrary(const wxString &libname)
|
||||
{
|
||||
wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest.Get(libname);
|
||||
wxPluginLibrary *entry = (wxPluginLibrary*) ms_manifest->Get(libname);
|
||||
|
||||
if( !entry )
|
||||
entry = (wxPluginLibrary*) ms_manifest.Get(libname + wxDynamicLibrary::GetDllExt());
|
||||
entry = (wxPluginLibrary*) ms_manifest->Get(libname + wxDynamicLibrary::GetDllExt());
|
||||
|
||||
if( entry )
|
||||
return entry->UnrefLib();
|
||||
@ -512,9 +528,9 @@ bool wxPluginManager::UnloadLibrary(const wxString &libname)
|
||||
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();
|
||||
|
||||
@ -535,11 +551,11 @@ bool wxPluginManager::Load(const wxString &libname, int flags)
|
||||
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.
|
||||
|
||||
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;
|
||||
|
||||
|
@ -504,10 +504,8 @@ bool wxGenericDirCtrl::Create(wxWindow *parent,
|
||||
|
||||
long treeStyle = wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
if (style & wxDIRCTRL_EDITABLE)
|
||||
if (style & wxDIRCTRL_EDIT_LABELS)
|
||||
treeStyle |= wxTR_EDIT_LABELS;
|
||||
#endif
|
||||
|
||||
if ((style & wxDIRCTRL_3D_INTERNAL) == 0)
|
||||
treeStyle |= wxNO_BORDER;
|
||||
|
@ -93,14 +93,19 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
||||
|
||||
// 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"));
|
||||
newButton->SetToolTip(_("Create new directory"));
|
||||
#endif
|
||||
|
||||
topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 );
|
||||
@ -108,10 +113,21 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
||||
// 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),
|
||||
wxDIRCTRL_DIR_ONLY|wxDIRCTRL_EDITABLE|wxSUNKEN_BORDER);
|
||||
dirStyle);
|
||||
|
||||
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user