]> git.saurik.com Git - wxWidgets.git/commitdiff
deprecate unneeded wxDIRCTRL_SHOW_FILTERS style, just always show the filters if...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 24 May 2007 00:14:59 +0000 (00:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 24 May 2007 00:14:59 +0000 (00:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46187 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/dirctrl.tex
include/wx/generic/dirctrlg.h
samples/widgets/dirctrl.cpp
src/generic/dirctrlg.cpp
src/xrc/xh_gdctl.cpp

index ff1fcb5b43b333c5dbe494299358bb231773a0f1..44c7cb03d173b491feebdc098734ec235570aee9 100644 (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
 ----------------------------------
index a82963cb2d204d805f621f7e4ff096cee6274ba0..1eafca210d9d4b0f220cf5e62109be14fbb039ca 100644 (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}
 
index f6afb9c3c6d060ed18681d63f1a6876a6122a296..2a6c450824c7d98dc29d6a089172c29372df1453 100644 (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
index 472416f3edbc48150cfda315700c0e2b4b30209e..646d03ae9c99d9c24a583a80caac8c81eb9a6fd9 100644 (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);
 
index 34d7a5054b6b0c84d86fdae75ba73900d5d69331..a41fdba627fec00ab6dd4230b1d55af77308ebaa 100644 (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,
-              const wxPoint& pos,
-              const wxSize& size,
-              long style)
+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);
 }
 
index 5a56eecdd58b9fbe24a00cb444462466533635d2..bbd0a0df59217405a6f6c1215d5a138ecdab2cb6 100644 (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();
 }