///////////////////////////////////////////////////////////////////////////////
// Name:        optlistctrl.h
// Purpose:     wxOptionListCtrl definition
// Author:      Francesco Montorsi
// Modified by:
// Created:     10/7/2006
// RCS-ID:      $Id: optlistctrl.h,v 1.1.1.1 2006/12/12 09:41:04 frm Exp $
// Copyright:   (c) Francesco Montorsi
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_OPTIONLIST_H_
#define _WX_OPTIONLIST_H_

#include "wx/treelistctrl.h"
#include "wxp/package.h"
class wxConfigBase;


// ----------------------------------------------------------------------------
// wxOptionListCtrl - a control to show package options
// ----------------------------------------------------------------------------

class wxOptionListCtrl : public wxTreeListCtrl
{
    DECLARE_DYNAMIC_CLASS( wxOptionListCtrl )
    DECLARE_EVENT_TABLE()

public:
    wxOptionListCtrl() {}

    wxOptionListCtrl(wxWindow* parent, wxWindowID id,
                       const wxPoint& pos = wxDefaultPosition,
                       const wxSize& size = wxDefaultSize,
                       long style = 0,
                       const wxString& name = wxT("wxOptionListCtrl"))
        { Create(parent, id, pos, size, style, name); }

    bool Create(wxWindow* parent, wxWindowID id,
                         const wxPoint& pos = wxDefaultPosition,
                         const wxSize& size = wxDefaultSize,
                         long style = 0,
                         const wxString& name = wxT("wxOptionListCtrl"));


public:     // wxOptionListCtrl-specific API

    //! Loads from given path the strings previously saved by a #Save call.
    //! All previous contents are cleared.
    bool Load(wxConfigBase *, const wxString &path);

    //! Saves in given path all the currently contained strings.
    //! Order will be preserved by #Load.
    void Save(wxConfigBase *, const wxString &path) const;

    //! Sets the options associated to this control and the stage it controls.
    //! Only the options which can be used with the given format & given stage
    //! are shown. The value wxPCF_INVALID means that the check on the compiler
    //! is skipped.
    bool SetOptions(const wxPackageCommandOptionArray &opt)
        { m_arr = opt; m_arr.SetDirty(false); return TransferDataToWindow(); }

    void SetBuildSystemType(wxPackageBuildSystemType type)
        { m_buildsys = type; TransferDataToWindow(); }
    void SetStages(long stages)
        { m_stages = stages; TransferDataToWindow(); }
    void SetCompilerFormats(long formats)
        { m_formats = formats; TransferDataToWindow(); }

    //! Returns all options with the values currently set in this control.
    //! Note that if you modify the returned array, in order to make the
    //! changes appear in the control you have to call #TransferDataToWindow().
    wxPackageCommandOptionArray &GetOptions()
        { return m_arr; }

    //! Returns true if the options have been changed by the user since last
    //! call to SetOptions().
    bool IsDirty() const
        { return m_arr.IsDirty(); }

    bool TransferDataFromWindow();
    bool TransferDataToWindow();


    // functions which work on selected item:

    void DeleteSelected();
    wxString GetSelectedOptName() const;


public:     // event handlers

    void OnItemActivated(wxTreeEvent &ev);

protected:
    wxPackageCommandOptionArray m_arr;

    // filters of the m_arr options above:
    wxPackageBuildSystemType m_buildsys;
    long m_stages;
    long m_formats;
};


// ----------------------------------------------------------------------------
// wxEVT_COMMAND_OPTION_DCLICK
// ----------------------------------------------------------------------------

BEGIN_DECLARE_EVENT_TYPES()
    //DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP, wxEVT_COMMAND_FILTER_PACKAGES, 1000000)
        DECLARE_EVENT_TYPE(wxEVT_COMMAND_OPTION_DCLICK, 31230000)
END_DECLARE_EVENT_TYPES()

#define EVT_OPTION_DCLICK(id, fn) \
        wx__DECLARE_EVT1(wxEVT_COMMAND_OPTION_DCLICK, id, wxCommandEventHandler(fn))


#endif
    // _WX_OPTIONLIST_H_

