Added wxEVT_COMMAND_DIRCTRL_CHANGED for wxDirCtrl selection changes.
This makes it much simpler to react to the changes in the control, update the sample to show it. Closes #14792. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0d6f66f45c
commit
84605707d1
@ -581,6 +581,7 @@ All (GUI):
|
||||
- Close wxLogWindow automatically if it's the last remaining top level window.
|
||||
- Implement clipping for wxSVGFileDC (Steve Benbow).
|
||||
- Added wxDirCtrl::GetPath() (troelsk).
|
||||
- Added wxEVT_COMMAND_DIRCTRL_CHANGED event (troelsk).
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
void OnCollapseItem(wxTreeEvent &event );
|
||||
void OnBeginEditItem(wxTreeEvent &event );
|
||||
void OnEndEditItem(wxTreeEvent &event );
|
||||
void OnTreeSelChange(wxTreeEvent &event);
|
||||
void OnSize(wxSizeEvent &event );
|
||||
|
||||
// Try to expand as much of the given path as possible.
|
||||
@ -210,6 +211,13 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxGenericDirCtrl);
|
||||
};
|
||||
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_DIRCTRL_CHANGED, wxTreeEvent );
|
||||
|
||||
#define wx__DECLARE_DIRCTRL_EVT(evt, id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COMMAND_DIRCTRL_ ## evt, id, wxTreeEventHandler(fn))
|
||||
|
||||
#define EVT_DIRCTRL_CHANGED(id, fn) wx__DECLARE_DIRCTRL_EVT(CHANGED, id, fn)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDirFilterListCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -47,6 +47,12 @@ enum
|
||||
@library{wxcore}
|
||||
@category{ctrl}
|
||||
@appearance{genericdirctrl.png}
|
||||
@event{EVT_DIRCTRL_CHANGED(id, func)}
|
||||
Selected directory has changed.
|
||||
Processes a @c wxEVT_COMMAND_DIRCTRL_CHANGED event type.
|
||||
Notice that this event is generated even for the changes done by the
|
||||
program itself and not only those done by the user.
|
||||
@since 2.9.5
|
||||
*/
|
||||
class wxGenericDirCtrl : public wxControl
|
||||
{
|
||||
|
@ -112,6 +112,7 @@ protected:
|
||||
void OnStdPath(wxCommandEvent& event);
|
||||
void OnCheckBox(wxCommandEvent& event);
|
||||
void OnRadioBox(wxCommandEvent& event);
|
||||
void OnSelChanged(wxTreeEvent& event);
|
||||
|
||||
// reset the control parameters
|
||||
void Reset();
|
||||
@ -154,6 +155,7 @@ BEGIN_EVENT_TABLE(DirCtrlWidgetsPage, WidgetsPage)
|
||||
EVT_BUTTON(DirCtrlPage_SetPath, DirCtrlWidgetsPage::OnButtonSetPath)
|
||||
EVT_CHECKBOX(wxID_ANY, DirCtrlWidgetsPage::OnCheckBox)
|
||||
EVT_RADIOBOX(wxID_ANY, DirCtrlWidgetsPage::OnRadioBox)
|
||||
EVT_DIRCTRL_CHANGED(DirCtrlPage_Ctrl, DirCtrlWidgetsPage::OnSelChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
@ -168,6 +170,7 @@ DirCtrlWidgetsPage::DirCtrlWidgetsPage(WidgetsBookCtrl *book,
|
||||
wxImageList *imaglist)
|
||||
:WidgetsPage(book, imaglist, dirctrl_xpm)
|
||||
{
|
||||
m_dirCtrl = NULL;
|
||||
}
|
||||
|
||||
void DirCtrlWidgetsPage::CreateContent()
|
||||
@ -360,4 +363,15 @@ void DirCtrlWidgetsPage::OnRadioBox(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void DirCtrlWidgetsPage::OnSelChanged(wxTreeEvent& event)
|
||||
{
|
||||
if ( m_dirCtrl )
|
||||
{
|
||||
wxLogMessage("Selection changed to \"%s\"",
|
||||
m_dirCtrl->GetPath(event.GetItem()));
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#endif // wxUSE_DIRDLG
|
||||
|
@ -102,6 +102,12 @@ extern WXDLLEXPORT_DATA(const char) wxFileSelectorDefaultWildcardStr[];
|
||||
|
||||
bool wxIsDriveAvailable(const wxString& dirName);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDEFINE_EVENT( wxEVT_COMMAND_DIRCTRL_CHANGED, wxTreeEvent );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGetAvailableDrives, for WINDOWS, DOS, OS2, MAC, UNIX (returns "/")
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -441,6 +447,7 @@ BEGIN_EVENT_TABLE(wxGenericDirCtrl, wxControl)
|
||||
EVT_TREE_ITEM_COLLAPSED (wxID_TREECTRL, wxGenericDirCtrl::OnCollapseItem)
|
||||
EVT_TREE_BEGIN_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnBeginEditItem)
|
||||
EVT_TREE_END_LABEL_EDIT (wxID_TREECTRL, wxGenericDirCtrl::OnEndEditItem)
|
||||
EVT_TREE_SEL_CHANGED (wxID_TREECTRL, wxGenericDirCtrl::OnTreeSelChange)
|
||||
EVT_SIZE (wxGenericDirCtrl::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@ -694,6 +701,17 @@ void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
|
||||
}
|
||||
}
|
||||
|
||||
void wxGenericDirCtrl::OnTreeSelChange(wxTreeEvent &event)
|
||||
{
|
||||
wxTreeEvent changedEvent(wxEVT_COMMAND_DIRCTRL_CHANGED, GetId());
|
||||
|
||||
changedEvent.SetItem(event.GetItem());
|
||||
changedEvent.SetClientObject(m_treeCtrl->GetItemData(event.GetItem()));
|
||||
|
||||
GetEventHandler()->SafelyProcessEvent(changedEvent);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event)
|
||||
{
|
||||
wxTreeItemId parentId = event.GetItem();
|
||||
|
Loading…
Reference in New Issue
Block a user