2006-05-31 19:57:54 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: src/generic/filepickerg.cpp
|
|
|
|
// Purpose: wxGenericFileDirButton class implementation
|
|
|
|
// Author: Francesco Montorsi
|
|
|
|
// Modified by:
|
|
|
|
// Created: 15/04/2006
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Francesco Montorsi
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2006-06-03 15:20:23 -04:00
|
|
|
#if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
|
2006-05-31 19:57:54 -04:00
|
|
|
|
|
|
|
#include "wx/filepicker.h"
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton, wxButton)
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton, wxButton)
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGenericFileButton
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2009-06-29 18:07:34 -04:00
|
|
|
bool wxGenericFileDirButton::Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& label,
|
|
|
|
const wxString& path,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& wildcard,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long WXUNUSED(style),
|
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name)
|
2006-05-31 19:57:54 -04:00
|
|
|
{
|
|
|
|
// create this button
|
2009-06-29 18:07:34 -04:00
|
|
|
if ( !wxButton::Create(parent, id, label, pos, size, 0, validator, name) )
|
2006-05-31 19:57:54 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// and handle user clicks on it
|
2008-03-26 11:49:31 -04:00
|
|
|
Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
|
2006-05-31 19:57:54 -04:00
|
|
|
wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick),
|
|
|
|
NULL, this);
|
|
|
|
|
|
|
|
// create the dialog associated with this button
|
|
|
|
m_path = path;
|
2006-06-02 08:00:30 -04:00
|
|
|
m_message = message;
|
|
|
|
m_wildcard = wildcard;
|
|
|
|
|
|
|
|
return true;
|
2006-05-31 19:57:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
|
|
|
{
|
2006-06-02 08:00:30 -04:00
|
|
|
wxDialog *p = CreateDialog();
|
|
|
|
if (p->ShowModal() == wxID_OK)
|
2006-05-31 19:57:54 -04:00
|
|
|
{
|
2006-06-02 08:00:30 -04:00
|
|
|
// save updated path in m_path
|
|
|
|
UpdatePathFromDialog(p);
|
2006-05-31 19:57:54 -04:00
|
|
|
|
|
|
|
// fire an event
|
|
|
|
wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
|
|
|
|
GetEventHandler()->ProcessEvent(event);
|
|
|
|
}
|
2006-06-02 08:00:30 -04:00
|
|
|
|
|
|
|
wxDELETE(p);
|
2006-05-31 19:57:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
|