/////////////////////////////////////////////////////////////////////////////
// Name:        refeditdlg.h
// Purpose:     wxPackageReferenceEditDlg definition
// Author:      Francesco Montorsi
// Modified by:
// Created:     Thu 10 Aug 2006 18:49:40 CEST
// RCS-ID:      $Id: refeditdlg.h,v 1.2 2007/01/01 20:06:20 frm Exp $
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWidgets license
/////////////////////////////////////////////////////////////////////////////

#ifndef _REFEDITDLG_H_
#define _REFEDITDLG_H_


/*!
 * Includes
 */

#include <wx/textctrl.h>
#include "wxp/packageutils.h"


/*!
 * Control identifiers
 */

////@begin control identifiers
#define SYMBOL_WXPACKAGEREFERENCEEDITDLG_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WXPACKAGEREFERENCEEDITDLG_TITLE _("Reference")
#define SYMBOL_WXPACKAGEREFERENCEEDITDLG_IDNAME wxID_ANY
#define SYMBOL_WXPACKAGEREFERENCEEDITDLG_SIZE wxSize(400, 300)
#define SYMBOL_WXPACKAGEREFERENCEEDITDLG_POSITION wxDefaultPosition
#define ID_REFEDIT_LOCAL 10000
#define ID_REFEDIT_LOCALBROWSE 10017
#define ID_REFEDIT_REMOTE 10001
////@end control identifiers

#define wxPACKAGEREF_DEFAULT_HREF       wxT("http://")
#define wxPACKAGEREF_DEFAULT_LOCALREF   wxT("file:///")


// ----------------------------------------------------------------------------
// wxPackageReferenceEditDlg
// ----------------------------------------------------------------------------

class wxPackageReferenceEditDlg: public wxDialog
{
    DECLARE_DYNAMIC_CLASS( wxPackageReferenceEditDlg )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    wxPackageReferenceEditDlg( );
    wxPackageReferenceEditDlg( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGEREFERENCEEDITDLG_IDNAME, const wxString& caption = SYMBOL_WXPACKAGEREFERENCEEDITDLG_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGEREFERENCEEDITDLG_POSITION, const wxSize& size = SYMBOL_WXPACKAGEREFERENCEEDITDLG_SIZE, long style = SYMBOL_WXPACKAGEREFERENCEEDITDLG_STYLE );

    /// Creation
    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGEREFERENCEEDITDLG_IDNAME, const wxString& caption = SYMBOL_WXPACKAGEREFERENCEEDITDLG_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGEREFERENCEEDITDLG_POSITION, const wxSize& size = SYMBOL_WXPACKAGEREFERENCEEDITDLG_SIZE, long style = SYMBOL_WXPACKAGEREFERENCEEDITDLG_STYLE );

    /// Creates the controls and sizers
    void CreateControls();

    /// Should we show tooltips?
    static bool ShowToolTips();

public:     // event handlers

    void OnOK(wxCommandEvent &ev);
    void OnLocalBrowse(wxCommandEvent &ev);

public:     // public API

    //! This dialog will force the user if he selects as local reference a
    //! path which is NOT under the given root.
    //! If the root is empty (default) no errors will be displayed.
    void SetLocalRoot(const wxString &root)
        { m_strRoot=root; }

    //! This dialog will allow the user to select only files matching the
    //! given wildcard.
    void SetWildcard(const wxString &wild)
        { m_strWildcard=wild; }

    void SetRef(const wxPackageDataWithRef &ref)
    {
        m_pLocal->SetValue(ref.GetLocalRef().IsEmpty() ? wxPACKAGEREF_DEFAULT_LOCALREF : ref.GetLocalRef());
        m_pRemote->SetValue(ref.GetHref().IsEmpty() ? wxPACKAGEREF_DEFAULT_HREF : ref.GetHref());

        // save this so that we can restore a wxPackageDataWithRef later
        m_strData = ref.GetData();
    }

    wxPackageDataWithRef GetRef() const
    {
        wxString r(m_pRemote->GetValue()), l(m_pLocal->GetValue());

        return wxPackageDataWithRef(m_strData,
                                    r == wxPACKAGEREF_DEFAULT_HREF ? wxT("") : r,
                                    l == wxPACKAGEREF_DEFAULT_LOCALREF ? wxT("") : l);
    }

protected:      // controls

////@begin wxPackageReferenceEditDlg member variables
    wxTextCtrl* m_pLocal;
    wxTextCtrl* m_pRemote;
////@end wxPackageReferenceEditDlg member variables

protected:

    wxString m_strData;

    wxString m_strRoot;
    wxString m_strWildcard;
};

#endif
    // _REFEDITDLG_H_
