deprecate unneeded wxDIRCTRL_SHOW_FILTERS style, just always show the filters if they're present (modified patch 1719448)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46187 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-05-24 00:14:59 +00:00
parent b4ff336e1d
commit d0bc78e2bf
6 changed files with 56 additions and 24 deletions

View File

@@ -72,6 +72,9 @@ Deprecated methods and their replacements
- wxCreateGreyedImage() deprecated, use wxImage::ConvertToGreyscale() instead.
- wxString::GetWriteBuf() and UngetWriteBuf() deprecated, using wxStringBuffer
or wxStringBufferLength instead.
- wxDIRCTRL_SHOW_FILTERS style is deprecated, filters are alwsys shown if
specified so this style should simply be removed
Major new features in this release
----------------------------------

View File

@@ -23,7 +23,6 @@ hierarchy, and optionally, a \helpref{wxChoice}{wxchoice} window containing a li
\twocolitem{\indexit{wxDIRCTRL\_DIR\_ONLY}}{Only show directories, and not files.}
\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\_EDIT\_LABELS}}{Allow the folder and file labels to be editable.}
\end{twocollist}

View File

@@ -44,8 +44,10 @@ enum
wxDIRCTRL_DIR_ONLY = 0x0010,
// When setting the default path, select the first file in the directory
wxDIRCTRL_SELECT_FIRST = 0x0020,
// Show the filter list
#if WXWIN_COMPATIBILITY_2_8
// Unused, for compatibility only
wxDIRCTRL_SHOW_FILTERS = 0x0040,
#endif // WXWIN_COMPATIBILITY_2_8
// Use 3D borders on internal controls
wxDIRCTRL_3D_INTERNAL = 0x0080,
// Editable labels

View File

@@ -132,8 +132,9 @@ protected:
wxCheckBox *m_chkDirOnly,
*m_chk3D,
*m_chkFirst,
*m_chkFilters,
*m_chkLabels;
// filters
wxCheckBox *m_fltr[3];
private:
DECLARE_EVENT_TABLE()
@@ -182,10 +183,17 @@ void DirCtrlWidgetsPage::CreateContent()
m_chkDirOnly = CreateCheckBoxAndAddToSizer(sizerUseFlags, _T("wxDIRCTRL_DIR_ONLY"));
m_chk3D = CreateCheckBoxAndAddToSizer(sizerUseFlags, _T("wxDIRCTRL_3D_INTERNAL"));
m_chkFirst = CreateCheckBoxAndAddToSizer(sizerUseFlags, _T("wxDIRCTRL_SELECT_FIRST"));
m_chkFilters = CreateCheckBoxAndAddToSizer(sizerUseFlags, _T("wxDIRCTRL_SHOW_FILTERS"));
m_chkLabels = CreateCheckBoxAndAddToSizer(sizerUseFlags, _T("wxDIRCTRL_EDIT_LABELS"));
sizerLeft->Add(sizerUseFlags, wxSizerFlags().Expand().Border());
wxSizer *sizerFilters =
new wxStaticBoxSizer(wxVERTICAL, this, _T("&Filters"));
m_fltr[0] = CreateCheckBoxAndAddToSizer(sizerFilters, wxString::Format(wxT("all files (%s)|%s"),
wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr));
m_fltr[1] = CreateCheckBoxAndAddToSizer(sizerFilters, wxT("C++ files (*.cpp; *.h)|*.cpp;*.h"));
m_fltr[2] = CreateCheckBoxAndAddToSizer(sizerFilters, wxT("PNG images (*.png)|*.png"));
sizerLeft->Add(sizerFilters, wxSizerFlags().Expand().Border());
wxButton *btn = new wxButton(this, DirCtrlPage_Reset, _T("&Reset"));
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
@@ -236,10 +244,21 @@ void DirCtrlWidgetsPage::CreateDirCtrl()
( m_chkDirOnly->IsChecked() ? wxDIRCTRL_DIR_ONLY : 0 ) |
( m_chk3D->IsChecked() ? wxDIRCTRL_3D_INTERNAL : 0 ) |
( m_chkFirst->IsChecked() ? wxDIRCTRL_SELECT_FIRST : 0 ) |
( m_chkFilters->IsChecked() ? wxDIRCTRL_SHOW_FILTERS : 0 ) |
( m_chkLabels->IsChecked() ? wxDIRCTRL_EDIT_LABELS : 0 )
);
wxString filter;
for (int i = 0; i < 3; ++i)
{
if (m_fltr[i]->IsChecked())
{
if (!filter.IsEmpty())
filter += wxT("|");
filter += m_fltr[i]->GetLabel();
}
}
dirCtrl->SetFilter(filter);
// update sizer's child window
GetSizer()->Replace(m_dirCtrl, dirCtrl, true);

View File

@@ -470,7 +470,6 @@ wxBEGIN_FLAGS( wxGenericDirCtrlStyle )
wxFLAGS_MEMBER(wxDIRCTRL_DIR_ONLY)
wxFLAGS_MEMBER(wxDIRCTRL_3D_INTERNAL)
wxFLAGS_MEMBER(wxDIRCTRL_SELECT_FIRST)
wxFLAGS_MEMBER(wxDIRCTRL_SHOW_FILTERS)
wxEND_FLAGS( wxGenericDirCtrlStyle )
@@ -564,27 +563,17 @@ bool wxGenericDirCtrl::Create(wxWindow *parent,
else
treeStyle |= wxBORDER_SUNKEN;
long filterStyle = 0;
if ((style & wxDIRCTRL_3D_INTERNAL) == 0)
filterStyle |= wxNO_BORDER;
else
filterStyle |= wxBORDER_SUNKEN;
m_treeCtrl = CreateTreeCtrl(this, wxID_TREECTRL,
wxPoint(0,0), GetClientSize(), treeStyle);
if (!filter.empty() && (style & wxDIRCTRL_SHOW_FILTERS))
m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL, wxDefaultPosition, wxDefaultSize, filterStyle);
if (!filter.empty())
m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL);
m_defaultPath = dir;
m_filter = filter;
if (m_filter.empty())
#ifdef __UNIX__
m_filter = wxT("*");
#else
m_filter = wxT("*.*");
#endif
m_filter = wxFileSelectorDefaultWildcardStr;
SetFilterIndex(defaultFilter);
@@ -1182,6 +1171,14 @@ void wxGenericDirCtrl::SetFilter(const wxString& filter)
{
m_filter = filter;
if (!filter.empty() && !m_filterListCtrl)
m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL);
else if (filter.empty() && m_filterListCtrl)
{
m_filterListCtrl->Destroy();
m_filterListCtrl = NULL;
}
wxString f, d;
if (ExtractWildcard(m_filter, m_currentFilter, f, d))
m_currentFilterStr = f;
@@ -1191,6 +1188,10 @@ void wxGenericDirCtrl::SetFilter(const wxString& filter)
#else
m_currentFilterStr = wxT("*.*");
#endif
// current filter index is meaningless after filter change, set it to zero
SetFilterIndex(0);
if (m_filterListCtrl)
m_filterListCtrl->FillFilterList(m_filter, 0);
}
// Extract description and actual filter from overall filter string
@@ -1267,12 +1268,21 @@ BEGIN_EVENT_TABLE(wxDirFilterListCtrl, wxChoice)
EVT_CHOICE(wxID_ANY, wxDirFilterListCtrl::OnSelFilter)
END_EVENT_TABLE()
bool wxDirFilterListCtrl::Create(wxGenericDirCtrl* parent, const wxWindowID id,
bool wxDirFilterListCtrl::Create(wxGenericDirCtrl* parent,
const wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style)
{
m_dirCtrl = parent;
// by default our border style is determined by the style of our parent
if ( !(style & wxBORDER_MASK) )
{
style |= parent->HasFlag(wxDIRCTRL_3D_INTERNAL) ? wxBORDER_SUNKEN
: wxBORDER_NONE;
}
return wxChoice::Create(parent, id, pos, size, 0, NULL, style);
}

View File

@@ -33,7 +33,6 @@ wxGenericDirCtrlXmlHandler::wxGenericDirCtrlXmlHandler()
XRC_ADD_STYLE(wxDIRCTRL_DIR_ONLY);
XRC_ADD_STYLE(wxDIRCTRL_3D_INTERNAL);
XRC_ADD_STYLE(wxDIRCTRL_SELECT_FIRST);
XRC_ADD_STYLE(wxDIRCTRL_SHOW_FILTERS);
XRC_ADD_STYLE(wxDIRCTRL_EDIT_LABELS);
AddWindowStyles();
}