]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/dirctrl.cpp
miscellaneous small enhancements
[wxWidgets.git] / samples / widgets / dirctrl.cpp
index 6995b79e510a405591a711f3b21fa440ad6dae24..654e256197b5c2560ce5228104919f1f85b23285 100644 (file)
 
 // for all others, include the necessary headers
 #ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/log.h"
     #include "wx/sizer.h"
     #include "wx/statbox.h"
     #include "wx/radiobox.h"
     #include "wx/checkbox.h"
     #include "wx/button.h"
-    #include "wx/app.h"
+    #include "wx/filedlg.h"
 #endif
 
 #include "wx/generic/dirctrlg.h"
 
 #include "wx/wupdlock.h"
 #include "wx/stdpaths.h"
-#include "wx/msgdlg.h"
 
 #include "widgets.h"
 
@@ -132,8 +133,9 @@ protected:
     wxCheckBox *m_chkDirOnly,
                *m_chk3D,
                *m_chkFirst,
-               *m_chkFilters,
                *m_chkLabels;
+    // filters
+    wxCheckBox *m_fltr[3];
 
 private:
     DECLARE_EVENT_TABLE()
@@ -182,10 +184,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);
 
@@ -216,8 +225,6 @@ void DirCtrlWidgetsPage::CreateContent()
     Reset();
 
     SetSizer(sizerTop);
-
-    sizerTop->Fit(this);
 }
 
 void DirCtrlWidgetsPage::Reset()
@@ -238,10 +245,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);