Added wxGenericDirCtrl, wxGenericDirDialog and associated icons.
Altered dialog sample to show generic dir dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7811 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@ -65,6 +65,7 @@ caret.cpp G U
|
||||
choicdgg.cpp G
|
||||
colrdlgg.cpp G G
|
||||
dcpsg.cpp G U
|
||||
dirctrlg.cpp G
|
||||
dirdlgg.cpp G 16,P
|
||||
dragimgg.cpp G P
|
||||
fontdlgg.cpp G G,R,P
|
||||
@ -1084,6 +1085,7 @@ caret.h N
|
||||
choicdgg.h N
|
||||
colrdlgg.h N
|
||||
dcpsg.h N
|
||||
dirctrlg.h N
|
||||
dirdlgg.h N 16
|
||||
dragimgg.h N 16
|
||||
fontdlgg.h N
|
||||
|
7
include/wx/dirctrl.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef _WX_DIRCTRL_H_BASE_
|
||||
#define _WX_DIRCTRL_H_BASE_
|
||||
|
||||
#include "wx/generic/dirctrlg.h"
|
||||
|
||||
#endif
|
||||
// _WX_DIRCTRL_H_BASE_
|
245
include/wx/generic/dirctrlg.h
Normal file
@ -0,0 +1,245 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dirctrlg.h
|
||||
// Purpose: wxGenericDirCtrl class
|
||||
// Builds on wxDirCtrl class written by Robert Roebling for the
|
||||
// wxFile application, modified by Harm van der Heijden.
|
||||
// Further modified for Windows.
|
||||
// Author: Julian Smart et al
|
||||
// Modified by:
|
||||
// Created: 21/3/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DIRCTRL_H_
|
||||
#define _WX_DIRCTRL_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dirctrlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/treectrl.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// classes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxDirItemData;
|
||||
class wxDirCtrl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Extra styles for wxGenericDirCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Only allow directory viewing/selection, no files
|
||||
#define wxDIRCTRL_DIR_ONLY 0x0010
|
||||
// When setting the default path, select the first file in the directory
|
||||
#define wxDIRCTRL_SELECT_FIRST 0x0020
|
||||
// Show the filter list
|
||||
#define wxDIRCTRL_SHOW_FILTERS 0x0040
|
||||
// Use 3D borders on internal controls
|
||||
#define wxDIRCTRL_3D_INTERNAL 0x0080
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDirItemData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDirItemDataEx : public wxTreeItemData
|
||||
{
|
||||
public:
|
||||
wxDirItemDataEx(const wxString& path, const wxString& name, bool isDir);
|
||||
~wxDirItemDataEx();
|
||||
bool HasSubDirs();
|
||||
void SetNewDirName( wxString path );
|
||||
wxString m_path, m_name;
|
||||
bool m_isHidden;
|
||||
bool m_hasSubDirs;
|
||||
bool m_isExpanded;
|
||||
bool m_isDir;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDirCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDirFilterListCtrl;
|
||||
|
||||
class WXDLLEXPORT wxGenericDirCtrl: public wxControl
|
||||
{
|
||||
public:
|
||||
wxGenericDirCtrl();
|
||||
wxGenericDirCtrl(wxWindow *parent, const wxWindowID id = -1,
|
||||
const wxString &dir = wxDirDialogDefaultFolderStr,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDIRCTRL_3D_INTERNAL,
|
||||
const wxString& filter = wxEmptyString,
|
||||
int defaultFilter = 0,
|
||||
const wxString& name = wxTreeCtrlNameStr )
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, dir, pos, size, style, filter, defaultFilter, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, const wxWindowID id = -1,
|
||||
const wxString &dir = wxDirDialogDefaultFolderStr,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDIRCTRL_3D_INTERNAL,
|
||||
const wxString& filter = wxEmptyString,
|
||||
int defaultFilter = 0,
|
||||
const wxString& name = wxTreeCtrlNameStr );
|
||||
|
||||
void Init();
|
||||
|
||||
~wxGenericDirCtrl();
|
||||
|
||||
void OnExpandItem(wxTreeEvent &event );
|
||||
void OnCollapseItem(wxTreeEvent &event );
|
||||
void OnBeginEditItem(wxTreeEvent &event );
|
||||
void OnEndEditItem(wxTreeEvent &event );
|
||||
void OnSize(wxSizeEvent &event );
|
||||
|
||||
// Try to expand as much of the given path as possible.
|
||||
bool ExpandPath(const wxString& path);
|
||||
|
||||
// Accessors
|
||||
|
||||
inline wxString GetDefaultPath() const { return m_defaultPath; }
|
||||
void SetDefaultPath(const wxString& path) { m_defaultPath = path; }
|
||||
|
||||
//inline long GetStyleEx() const { return m_styleEx; }
|
||||
//void SetStyleEx(long styleEx) { m_styleEx = styleEx; }
|
||||
|
||||
// Get dir or filename
|
||||
wxString GetPath() const ;
|
||||
// Get selected filename path only (else empty string).
|
||||
// I.e. don't count a directory as a selection
|
||||
wxString GetFilePath() const ;
|
||||
void SetPath(const wxString& path) ;
|
||||
|
||||
wxString GetFilter() const { return m_filter; }
|
||||
void SetFilter(const wxString& filter);
|
||||
|
||||
int GetFilterIndex() const { return m_currentFilter; }
|
||||
void SetFilterIndex(int n) ;
|
||||
|
||||
wxTreeItemId GetRootId() { return m_rootId; }
|
||||
|
||||
wxTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; }
|
||||
wxDirFilterListCtrl* GetFilterListCtrl() const { return m_filterListCtrl; }
|
||||
|
||||
//// Helpers
|
||||
void SetupSections();
|
||||
// Parse the filter into an array of filters and an array of descriptions
|
||||
int ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions);
|
||||
// Find the child that matches the first part of 'path'.
|
||||
// E.g. if a child path is "/usr" and 'path' is "/usr/include"
|
||||
// then the child for /usr is returned.
|
||||
// If the path string has been used (we're at the leaf), done is set to TRUE
|
||||
wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done);
|
||||
|
||||
// Resize the components of the control
|
||||
void DoResize();
|
||||
protected:
|
||||
void ExpandDir(wxTreeItemId parentId);
|
||||
void AddSection(const wxString& path, const wxString& name, int imageId = 0);
|
||||
//void FindChildFiles(wxTreeItemId id, int dirFlags, wxArrayString& filenames);
|
||||
|
||||
// Extract description and actual filter from overall filter string
|
||||
bool ExtractWildcard(const wxString& filterStr, int n, wxString& filter, wxString& description);
|
||||
|
||||
private:
|
||||
bool m_showHidden;
|
||||
wxTreeItemId m_rootId;
|
||||
wxImageList* m_imageList;
|
||||
wxString m_defaultPath; // Starting path
|
||||
long m_styleEx; // Extended style
|
||||
wxString m_filter; // Wildcards in same format as per wxFileDialog
|
||||
int m_currentFilter; // The current filter index
|
||||
wxString m_currentFilterStr; // Current filter string
|
||||
wxTreeCtrl* m_treeCtrl;
|
||||
wxDirFilterListCtrl* m_filterListCtrl;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxGenericDirCtrl)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDirFilterListCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDirFilterListCtrl: public wxChoice
|
||||
{
|
||||
public:
|
||||
wxDirFilterListCtrl() { Init(); }
|
||||
wxDirFilterListCtrl(wxGenericDirCtrl* parent, const wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0)
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, pos, size, style);
|
||||
}
|
||||
|
||||
bool Create(wxGenericDirCtrl* parent, const wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0);
|
||||
|
||||
void Init();
|
||||
|
||||
~wxDirFilterListCtrl() {};
|
||||
|
||||
//// Operations
|
||||
void FillFilterList(const wxString& filter, int defaultFilter);
|
||||
|
||||
//// Events
|
||||
void OnSelFilter(wxCommandEvent& event);
|
||||
|
||||
protected:
|
||||
wxGenericDirCtrl* m_dirCtrl;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxDirFilterListCtrl)
|
||||
};
|
||||
|
||||
#define wxID_TREECTRL 7000
|
||||
#define wxID_FILTERLISTCTRL 7001
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxGenericDirDialog
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxGenericDirDialog: public wxDialog
|
||||
{
|
||||
DECLARE_EVENT_TABLE()
|
||||
public:
|
||||
wxGenericDirDialog(): wxDialog() {}
|
||||
wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
||||
const wxString& defaultPath = wxEmptyString, long style = wxDEFAULT_DIALOG_STYLE, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxSize(450, 550), const wxString& name = "dialog");
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
inline void SetMessage(const wxString& message) { m_message = message; }
|
||||
void SetPath(const wxString& path) ;
|
||||
inline void SetStyle(long style) { m_dialogStyle = style; }
|
||||
|
||||
inline wxString GetMessage(void) const { return m_message; }
|
||||
wxString GetPath(void) const ;
|
||||
inline long GetStyle(void) const { return m_dialogStyle; }
|
||||
|
||||
protected:
|
||||
wxString m_message;
|
||||
long m_dialogStyle;
|
||||
wxString m_path;
|
||||
wxGenericDirCtrl* m_dirCtrl;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_DIRCTRLG_H_
|
BIN
include/wx/msw/cdrom.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/msw/computer.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/msw/drive.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/msw/file1.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
include/wx/msw/floppy.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/msw/folder1.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
include/wx/msw/folder2.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/msw/removble.ico
Normal file
After Width: | Height: | Size: 318 B |
@ -115,12 +115,22 @@ WXCURSOR_BLANK CURSOR DISCARDABLE "wx/msw/blank.cur"
|
||||
//wxDEFAULT_MDIPARENTFRAME ICON "wx/msw/mdi.ico"
|
||||
//wxDEFAULT_MDICHILDFRAME ICON "wx/msw/child.ico"
|
||||
|
||||
// Standard icons
|
||||
wxICON_QUESTION ICON "wx/msw/question.ico"
|
||||
wxICON_WARNING ICON "wx/msw/warning.ico"
|
||||
wxICON_ERROR ICON "wx/msw/error.ico"
|
||||
wxICON_INFO ICON "wx/msw/info.ico"
|
||||
wxICON_TIP ICON "wx/msw/tip.ico"
|
||||
// Standard large icons
|
||||
wxICON_QUESTION ICON "wx/msw/question.ico"
|
||||
wxICON_WARNING ICON "wx/msw/warning.ico"
|
||||
wxICON_ERROR ICON "wx/msw/error.ico"
|
||||
wxICON_INFO ICON "wx/msw/info.ico"
|
||||
wxICON_TIP ICON "wx/msw/tip.ico"
|
||||
|
||||
// Standard small icons
|
||||
wxICON_SMALL_CLOSED_FOLDER ICON "wx/msw/folder1.ico"
|
||||
wxICON_SMALL_OPEN_FOLDER ICON "wx/msw/folder2.ico"
|
||||
wxICON_SMALL_FILE ICON "wx/msw/file1.ico"
|
||||
wxICON_SMALL_COMPUTER ICON "wx/msw/computer.ico"
|
||||
wxICON_SMALL_DRIVE ICON "wx/msw/drive.ico"
|
||||
wxICON_SMALL_CDROM ICON "wx/msw/cdrom.ico"
|
||||
wxICON_SMALL_FLOPPY ICON "wx/msw/floppy.ico"
|
||||
wxICON_SMALL_REMOVEABLE ICON "wx/msw/removble.ico"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "wx/tipdlg.h"
|
||||
#include "wx/progdlg.h"
|
||||
|
||||
// New wxGenericDirCtrl
|
||||
#include "wx/dirctrl.h"
|
||||
|
||||
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
|
||||
|
||||
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
|
||||
@ -61,6 +64,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
|
||||
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
|
||||
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
|
||||
EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose)
|
||||
EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg)
|
||||
EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg)
|
||||
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
|
||||
@ -129,6 +133,7 @@ bool MyApp::OnInit()
|
||||
file_menu->Append(DIALOGS_FILES_OPEN, "Open &files\tCtrl-Q");
|
||||
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S");
|
||||
file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
|
||||
file_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, "&Choose a directory (generic implementation)");
|
||||
#if wxUSE_PROGRESSDLG
|
||||
file_menu->Append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G");
|
||||
#endif // wxUSE_PROGRESSDLG
|
||||
@ -418,6 +423,21 @@ void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
// pass some initial dir to wxDirDialog
|
||||
wxString dirHome;
|
||||
wxGetHomeDir(&dirHome);
|
||||
|
||||
wxGenericDirDialog dialog(this, "Testing generic directory picker", dirHome);
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path");
|
||||
dialog2.ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
MyModalDialog dlg(this);
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
void FilesOpen(wxCommandEvent& event);
|
||||
void FileSave(wxCommandEvent& event);
|
||||
void DirChoose(wxCommandEvent& event);
|
||||
void GenericDirChoose(wxCommandEvent& event);
|
||||
void ShowTip(wxCommandEvent& event);
|
||||
void ModalDlg(wxCommandEvent& event);
|
||||
void ModelessDlg(wxCommandEvent& event);
|
||||
@ -114,6 +115,7 @@ enum
|
||||
DIALOGS_FILES_OPEN,
|
||||
DIALOGS_FILE_SAVE,
|
||||
DIALOGS_DIR_CHOOSE,
|
||||
DIALOGS_GENERIC_DIR_CHOOSE,
|
||||
DIALOGS_TIP,
|
||||
DIALOGS_NUM_ENTRY,
|
||||
DIALOGS_LOG_DIALOG,
|
||||
|
1204
src/generic/dirctrlg.cpp
Normal file
@ -86,6 +86,7 @@ $(CPPFLAGS) /Fo$@ /c /Tp $<
|
||||
GENERICOBJS= ..\generic\$D\busyinfo.obj \
|
||||
..\generic\$D\calctrl.obj \
|
||||
..\generic\$D\choicdgg.obj \
|
||||
..\generic\$D\dirctrlg.obj \
|
||||
..\generic\$D\dragimgg.obj \
|
||||
..\generic\$D\grid.obj \
|
||||
..\generic\$D\gridsel.obj \
|
||||
|
@ -512,6 +512,10 @@ SOURCE=.\generic\choicdgg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\dirctrlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\dragimgg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|